adou-ui
Version:
feat:修复了TagInput无法清空的问题
1,371 lines (1,274 loc) • 254 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("react-dom"));
else if(typeof define === 'function' && define.amd)
define(["react", "react-dom"], factory);
else if(typeof exports === 'object')
exports["RPB"] = factory(require("react"), require("react-dom"));
else
root["RPB"] = factory(root["React"], root["ReactDOM"]);
})(this, (__WEBPACK_EXTERNAL_MODULE__442__, __WEBPACK_EXTERNAL_MODULE__3__) => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 191:
/***/ ((module) => {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function (cssWithMappingToString) {
var list = [];
// return the list of modules as css string
list.toString = function toString() {
return this.map(function (item) {
var content = "";
var needLayer = typeof item[5] !== "undefined";
if (item[4]) {
content += "@supports (".concat(item[4], ") {");
}
if (item[2]) {
content += "@media ".concat(item[2], " {");
}
if (needLayer) {
content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
}
content += cssWithMappingToString(item);
if (needLayer) {
content += "}";
}
if (item[2]) {
content += "}";
}
if (item[4]) {
content += "}";
}
return content;
}).join("");
};
// import a list of modules into the list
list.i = function i(modules, media, dedupe, supports, layer) {
if (typeof modules === "string") {
modules = [[null, modules, undefined]];
}
var alreadyImportedModules = {};
if (dedupe) {
for (var k = 0; k < this.length; k++) {
var id = this[k][0];
if (id != null) {
alreadyImportedModules[id] = true;
}
}
}
for (var _k = 0; _k < modules.length; _k++) {
var item = [].concat(modules[_k]);
if (dedupe && alreadyImportedModules[item[0]]) {
continue;
}
if (typeof layer !== "undefined") {
if (typeof item[5] === "undefined") {
item[5] = layer;
} else {
item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
item[5] = layer;
}
}
if (media) {
if (!item[2]) {
item[2] = media;
} else {
item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
item[2] = media;
}
}
if (supports) {
if (!item[4]) {
item[4] = "".concat(supports);
} else {
item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
item[4] = supports;
}
}
list.push(item);
}
};
return list;
};
/***/ }),
/***/ 73:
/***/ ((module) => {
module.exports = function (item) {
var content = item[1];
var cssMapping = item[3];
if (!cssMapping) {
return content;
}
if (typeof btoa === "function") {
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
var sourceMapping = "/*# ".concat(data, " */");
return [content].concat([sourceMapping]).join("\n");
}
return [content].join("\n");
};
/***/ }),
/***/ 137:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
var __webpack_unused_export__;
var m = __webpack_require__(3);
if (true) {
exports.H = m.createRoot;
__webpack_unused_export__ = m.hydrateRoot;
} else { var i; }
/***/ }),
/***/ 736:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73);
/* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(191);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
// Imports
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
// Module
___CSS_LOADER_EXPORT___.push([module.id, `/* Loading.css */
.loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
background: transparent;
pointer-events: "auto";
}
.loading-spinner {
border: 8px solid #f3f3f3;
/* Light grey */
border-top: 8px solid #3498db;
/* Blue */
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}`, "",{"version":3,"sources":["webpack://./src/hooks/loading.scss"],"names":[],"mappings":"AAAA,gBAAA;AACA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,aAAA;EACA,mBAAA;EACA,uBAAA;EACA,aAAA;EACA,uBAAA;EACA,sBAAA;AACJ;;AAEA;EACI,yBAAA;EACA,eAAA;EACA,6BAAA;EACA,SAAA;EACA,kBAAA;EACA,WAAA;EACA,YAAA;EACA,kCAAA;AACJ;;AAEA;EACI;IACI,uBAAA;EACN;EAEE;IACI,yBAAA;EAAN;AACF","sourcesContent":["/* Loading.css */\r\n.loading-overlay {\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n z-index: 9999;\r\n background: transparent;\r\n pointer-events: \"auto\";\r\n}\r\n\r\n.loading-spinner {\r\n border: 8px solid #f3f3f3;\r\n /* Light grey */\r\n border-top: 8px solid #3498db;\r\n /* Blue */\r\n border-radius: 50%;\r\n width: 50px;\r\n height: 50px;\r\n animation: spin 2s linear infinite;\r\n}\r\n\r\n@keyframes spin {\r\n 0% {\r\n transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n transform: rotate(360deg);\r\n }\r\n}"],"sourceRoot":""}]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 151:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73);
/* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(191);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
// Imports
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
// Module
___CSS_LOADER_EXPORT___.push([module.id, `.adou-notification-container {
position: fixed;
top: 20px;
right: 0px;
z-index: 1000;
}
.adou-notification-container .adou-notification {
width: 320px;
position: relative;
padding: 15px;
margin-bottom: 15px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
background-color: #fff;
transition: all 0.3s ease;
transform: translateX(100%);
}
.adou-notification-container .adou-notification-appearing {
transform: translateX(-20px);
}
.adou-notification-container .adou-notification-disappearing {
opacity: 0;
transform: translateX(100%) !important;
}
.adou-notification-container .adou-notification:hover {
cursor: pointer;
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.adou-notification-container .adou-notification-header {
display: flex;
align-items: start;
justify-content: space-between;
margin-bottom: 10px;
}
.adou-notification-container .adou-notification-header-title {
font-size: 18px;
font-weight: 600;
color: #333;
display: flex;
}
.adou-notification-container .adou-notification-header-title-icon {
margin-right: 8px;
}
.adou-notification-container .adou-notification-header-close {
cursor: pointer;
font-size: 16px;
color: #999;
transition: all 0.3s ease;
}
.adou-notification-container .adou-notification-header-close:hover {
color: #ff4d4f;
transform: scale(1.2);
}
.adou-notification-container .adou-notification-content {
font-size: 14px;
color: #666;
line-height: 1.5;
}`, "",{"version":3,"sources":["webpack://./src/hooks/notification.scss"],"names":[],"mappings":"AAAA;EACI,eAAA;EACA,SAAA;EACA,UAAA;EACA,aAAA;AACJ;AACI;EACI,YAAA;EACA,kBAAA;EACA,aAAA;EACA,mBAAA;EACA,kBAAA;EACA,yCAAA;EACA,sBAAA;EACA,yBAAA;EAEA,2BAAA;AAAR;AAEQ;EAEI,4BAAA;AADZ;AAIQ;EACI,UAAA;EACA,sCAAA;AAFZ;AAKQ;EACI,eAAA;EACA,0CAAA;AAHZ;AAOQ;EACI,aAAA;EACA,kBAAA;EACA,8BAAA;EACA,mBAAA;AALZ;AAOY;EACI,eAAA;EACA,gBAAA;EACA,WAAA;EACA,aAAA;AALhB;AAOgB;EACI,iBAAA;AALpB;AASY;EACI,eAAA;EACA,eAAA;EACA,WAAA;EACA,yBAAA;AAPhB;AASgB;EACI,cAAA;EACA,qBAAA;AAPpB;AAYQ;EACI,eAAA;EACA,WAAA;EACA,gBAAA;AAVZ","sourcesContent":[".adou-notification-container {\r\n position: fixed;\r\n top: 20px;\r\n right: 0px;\r\n z-index: 1000;\r\n\r\n .adou-notification {\r\n width: 320px;\r\n position: relative;\r\n padding: 15px;\r\n margin-bottom: 15px;\r\n border-radius: 8px;\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\r\n background-color: #fff;\r\n transition: all 0.3s ease;\r\n // opacity: 0;\r\n transform: translateX(100%);\r\n\r\n &-appearing {\r\n // opacity: 1;\r\n transform: translateX(-20px);\r\n }\r\n\r\n &-disappearing {\r\n opacity: 0;\r\n transform: translateX(100%) !important;\r\n }\r\n\r\n &:hover {\r\n cursor: pointer;\r\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);\r\n // transform: translate(-20px, -2px);\r\n }\r\n\r\n &-header {\r\n display: flex;\r\n align-items: start;\r\n justify-content: space-between;\r\n margin-bottom: 10px;\r\n\r\n &-title {\r\n font-size: 18px;\r\n font-weight: 600;\r\n color: #333;\r\n display: flex;\r\n\r\n &-icon {\r\n margin-right: 8px;\r\n }\r\n }\r\n\r\n &-close {\r\n cursor: pointer;\r\n font-size: 16px;\r\n color: #999;\r\n transition: all 0.3s ease;\r\n\r\n &:hover {\r\n color: #ff4d4f;\r\n transform: scale(1.2);\r\n }\r\n }\r\n }\r\n\r\n &-content {\r\n font-size: 14px;\r\n color: #666;\r\n line-height: 1.5;\r\n }\r\n }\r\n}"],"sourceRoot":""}]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 323:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73);
/* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(191);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
// Imports
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
// Module
___CSS_LOADER_EXPORT___.push([module.id, `.adou-toast-container {
position: absolute;
top: 20px;
left: 50%;
transform: translate(-50%, 0%);
z-index: 1000;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.adou-toast-container .adou-toast {
width: 300px;
position: relative;
padding: 15px;
padding-right: 20px;
margin: 10px 0;
border-radius: 5px;
color: white;
opacity: 0;
transform: translateY(-20px);
transition: transform 0.5s ease, opacity 0.5s ease;
}
.adou-toast-container .adou-toast-success {
background-color: #4caf50;
}
.adou-toast-container .adou-toast-error {
background-color: #f44336;
}
.adou-toast-container .adou-toast-warning {
background-color: #ff9800;
}
.adou-toast-container .adou-toast.appearing {
opacity: 1;
transform: translateY(0);
}
.adou-toast-container .adou-toast.disappearing {
opacity: 0;
transform: translateY(-20px) scaleX(0.9);
}
.adou-toast-container .adou-toast-timer {
position: absolute;
bottom: 0;
left: 0;
height: 4px;
background-color: rgba(255, 255, 255, 0.7);
transition: width 0.1s linear;
}
.adou-toast-container .adou-toast-close {
position: absolute;
top: -5px;
right: 1px;
background: none;
border: none;
color: #fff;
font-size: 20px;
cursor: pointer;
margin-left: 10px;
transition: color 0.3s;
}
.adou-toast-container .adou-toast-close:hover {
color: #ccc;
}`, "",{"version":3,"sources":["webpack://./src/hooks/toast.scss"],"names":[],"mappings":"AAIA;EACI,kBAAA;EACA,SAAA;EACA,SAAA;EACA,8BAAA;EACA,aAAA;EACA,aAAA;EACA,sBAAA;EACA,mBAAA;EACA,uBAAA;AAHJ;AAKI;EACI,YAAA;EACA,kBAAA;EACA,aAAA;EACA,mBAAA;EACA,cAAA;EACA,kBAAA;EACA,YAAA;EACA,UAAA;EAEA,4BAAA;EACA,kDAAA;AAJR;AAMQ;EACI,yBA7BU;AAyBtB;AAOQ;EACI,yBAhCQ;AA2BpB;AAQQ;EACI,yBAnCU;AA6BtB;AASQ;EACI,UAAA;EAEA,wBAAA;AARZ;AAWQ;EACI,UAAA;EACA,wCAAA;AATZ;AAYQ;EACI,kBAAA;EACA,SAAA;EACA,OAAA;EACA,WAAA;EACA,0CAAA;EACA,6BAAA;AAVZ;AAaQ;EACI,kBAAA;EACA,SAAA;EACA,UAAA;EACA,gBAAA;EACA,YAAA;EACA,WAAA;EACA,eAAA;EACA,eAAA;EACA,iBAAA;EACA,sBAAA;AAXZ;AAaY;EACI,WAAA;AAXhB","sourcesContent":["$toast-success-color: #4caf50;\r\n$toast-error-color: #f44336;\r\n$toast-warning-color: #ff9800;\r\n\r\n.adou-toast-container {\r\n position: absolute;\r\n top: 20px;\r\n left: 50%; // 水平中心\r\n transform: translate(-50%, 0%); // 将容器移动到中心\r\n z-index: 1000;\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n\r\n .adou-toast {\r\n width: 300px;\r\n position: relative;\r\n padding: 15px;\r\n padding-right: 20px;\r\n margin: 10px 0;\r\n border-radius: 5px;\r\n color: white;\r\n opacity: 0;\r\n // 仅向下移动,不缩小 -- 配合 &.appearing的transform: translateY(0);不能删除哦\r\n transform: translateY(-20px);\r\n transition: transform 0.5s ease, opacity 0.5s ease;\r\n\r\n &-success {\r\n background-color: $toast-success-color;\r\n }\r\n\r\n &-error {\r\n background-color: $toast-error-color;\r\n }\r\n\r\n &-warning {\r\n background-color: $toast-warning-color;\r\n }\r\n\r\n &.appearing {\r\n opacity: 1;\r\n // 仅向下移动,不缩小 -- 配合 .adou-toast的transform: translateY(-20px); 不能删除哦\r\n transform: translateY(0);\r\n }\r\n\r\n &.disappearing {\r\n opacity: 0;\r\n transform: translateY(-20px) scaleX(0.9); // 向上移动并缩小宽度\r\n }\r\n\r\n &-timer {\r\n position: absolute;\r\n bottom: 0;\r\n left: 0;\r\n height: 4px;\r\n background-color: rgba(255, 255, 255, 0.7);\r\n transition: width 0.1s linear; // 平滑缩短动画\r\n }\r\n\r\n &-close {\r\n position: absolute;\r\n top: -5px;\r\n right: 1px;\r\n background: none;\r\n border: none;\r\n color: #fff;\r\n font-size: 20px;\r\n cursor: pointer;\r\n margin-left: 10px;\r\n transition: color 0.3s;\r\n\r\n &:hover {\r\n color: #ccc;\r\n }\r\n }\r\n }\r\n}"],"sourceRoot":""}]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 591:
/***/ ((module) => {
var stylesInDOM = [];
function getIndexByIdentifier(identifier) {
var result = -1;
for (var i = 0; i < stylesInDOM.length; i++) {
if (stylesInDOM[i].identifier === identifier) {
result = i;
break;
}
}
return result;
}
function modulesToDom(list, options) {
var idCountMap = {};
var identifiers = [];
for (var i = 0; i < list.length; i++) {
var item = list[i];
var id = options.base ? item[0] + options.base : item[0];
var count = idCountMap[id] || 0;
var identifier = "".concat(id, " ").concat(count);
idCountMap[id] = count + 1;
var indexByIdentifier = getIndexByIdentifier(identifier);
var obj = {
css: item[1],
media: item[2],
sourceMap: item[3],
supports: item[4],
layer: item[5]
};
if (indexByIdentifier !== -1) {
stylesInDOM[indexByIdentifier].references++;
stylesInDOM[indexByIdentifier].updater(obj);
} else {
var updater = addElementStyle(obj, options);
options.byIndex = i;
stylesInDOM.splice(i, 0, {
identifier: identifier,
updater: updater,
references: 1
});
}
identifiers.push(identifier);
}
return identifiers;
}
function addElementStyle(obj, options) {
var api = options.domAPI(options);
api.update(obj);
var updater = function updater(newObj) {
if (newObj) {
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
return;
}
api.update(obj = newObj);
} else {
api.remove();
}
};
return updater;
}
module.exports = function (list, options) {
options = options || {};
list = list || [];
var lastIdentifiers = modulesToDom(list, options);
return function update(newList) {
newList = newList || [];
for (var i = 0; i < lastIdentifiers.length; i++) {
var identifier = lastIdentifiers[i];
var index = getIndexByIdentifier(identifier);
stylesInDOM[index].references--;
}
var newLastIdentifiers = modulesToDom(newList, options);
for (var _i = 0; _i < lastIdentifiers.length; _i++) {
var _identifier = lastIdentifiers[_i];
var _index = getIndexByIdentifier(_identifier);
if (stylesInDOM[_index].references === 0) {
stylesInDOM[_index].updater();
stylesInDOM.splice(_index, 1);
}
}
lastIdentifiers = newLastIdentifiers;
};
};
/***/ }),
/***/ 128:
/***/ ((module) => {
var memo = {};
/* istanbul ignore next */
function getTarget(target) {
if (typeof memo[target] === "undefined") {
var styleTarget = document.querySelector(target);
// Special case to return head of iframe instead of iframe itself
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch (e) {
// istanbul ignore next
styleTarget = null;
}
}
memo[target] = styleTarget;
}
return memo[target];
}
/* istanbul ignore next */
function insertBySelector(insert, style) {
var target = getTarget(insert);
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
}
target.appendChild(style);
}
module.exports = insertBySelector;
/***/ }),
/***/ 51:
/***/ ((module) => {
/* istanbul ignore next */
function insertStyleElement(options) {
var element = document.createElement("style");
options.setAttributes(element, options.attributes);
options.insert(element, options.options);
return element;
}
module.exports = insertStyleElement;
/***/ }),
/***/ 855:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/* istanbul ignore next */
function setAttributesWithoutAttributes(styleElement) {
var nonce = true ? __webpack_require__.nc : 0;
if (nonce) {
styleElement.setAttribute("nonce", nonce);
}
}
module.exports = setAttributesWithoutAttributes;
/***/ }),
/***/ 740:
/***/ ((module) => {
/* istanbul ignore next */
function apply(styleElement, options, obj) {
var css = "";
if (obj.supports) {
css += "@supports (".concat(obj.supports, ") {");
}
if (obj.media) {
css += "@media ".concat(obj.media, " {");
}
var needLayer = typeof obj.layer !== "undefined";
if (needLayer) {
css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
}
css += obj.css;
if (needLayer) {
css += "}";
}
if (obj.media) {
css += "}";
}
if (obj.supports) {
css += "}";
}
var sourceMap = obj.sourceMap;
if (sourceMap && typeof btoa !== "undefined") {
css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
}
// For old IE
/* istanbul ignore if */
options.styleTagTransform(css, styleElement, options.options);
}
function removeStyleElement(styleElement) {
// istanbul ignore if
if (styleElement.parentNode === null) {
return false;
}
styleElement.parentNode.removeChild(styleElement);
}
/* istanbul ignore next */
function domAPI(options) {
if (typeof document === "undefined") {
return {
update: function update() {},
remove: function remove() {}
};
}
var styleElement = options.insertStyleElement(options);
return {
update: function update(obj) {
apply(styleElement, options, obj);
},
remove: function remove() {
removeStyleElement(styleElement);
}
};
}
module.exports = domAPI;
/***/ }),
/***/ 656:
/***/ ((module) => {
/* istanbul ignore next */
function styleTagTransform(css, styleElement) {
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = css;
} else {
while (styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild);
}
styleElement.appendChild(document.createTextNode(css));
}
}
module.exports = styleTagTransform;
/***/ }),
/***/ 442:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_MODULE__442__;
/***/ }),
/***/ 3:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ id: moduleId,
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/nonce */
/******/ (() => {
/******/ __webpack_require__.nc = undefined;
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
convertArrayKeysToCamelCase: () => (/* reexport */ libs_convertArrayKeysToCamelCase),
convertArrayKeysToSnakeCase: () => (/* reexport */ libs_convertArrayKeysToSnakeCase),
convertListToTree: () => (/* reexport */ libs_convertListToTree),
convertToTag: () => (/* reexport */ libs_convertToTag),
flattenDataWithoutNesting: () => (/* reexport */ libs_flattenDataWithoutNesting),
getAbsolutePosition: () => (/* reexport */ libs_getAbsolutePositionOfStage),
getContentWidth: () => (/* reexport */ libs_getContentWidth),
isEmptyO: () => (/* reexport */ libs_isEmptyO),
splitFilesIntoColumns: () => (/* reexport */ libs_splitFilesIntoColumns),
timeFormatter: () => (/* reexport */ time_formatter_namespaceObject),
useClickOutside: () => (/* reexport */ hooks_useClickOutside),
useDrag: () => (/* reexport */ hooks_useDrag),
useForm: () => (/* reexport */ hooks_useForm),
useLoading: () => (/* reexport */ useLoading),
useNavigateTo: () => (/* reexport */ hooks_useNavigateTo),
useNotification: () => (/* reexport */ hooks_useNotification),
useThrottle: () => (/* reexport */ hooks_useThrottle),
useToast: () => (/* reexport */ hooks_useToast)
});
// NAMESPACE OBJECT: ./src/libs/time-formatter.js
var time_formatter_namespaceObject = {};
__webpack_require__.r(time_formatter_namespaceObject);
__webpack_require__.d(time_formatter_namespaceObject, {
"default": () => (time_formatter)
});
;// CONCATENATED MODULE: ./src/libs/getAbsolutePositionOfStage.js
function getAbsolutePositionOfStage(domElement) {
let left = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
let top = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
if (!parseInt(left)) {
left = 0;
} else {
left = parseInt(left);
}
if (!parseInt(top)) {
top = 0;
} else {
top = parseInt(top);
}
if (!domElement) {
return {
x: 0,
y: 0,
width: 0,
height: 0
};
}
const box = domElement === null || domElement === void 0 ? void 0 : domElement.getBoundingClientRect();
const body = document.body;
const docElem = document.documentElement;
const scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;
const scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
const clientTop = docElem.clientTop || body.clientTop || 0;
const clientLeft = docElem.clientLeft || body.clientLeft || 0;
const attr = {};
attr.y = box.top + scrollTop - clientTop + top;
attr.x = box.left + scrollLeft - clientLeft + left;
attr.width = box.width;
attr.height = box.height;
return attr;
}
/* harmony default export */ const libs_getAbsolutePositionOfStage = (getAbsolutePositionOfStage);
;// CONCATENATED MODULE: ./src/libs/convertToTag.js
const convertToTag = str => {
let tags = [];
const regex = /\[(.*?)\]/g;
const temp = str === null || str === void 0 ? void 0 : str.match(regex);
temp && (tags = temp.map(match => match === null || match === void 0 ? void 0 : match.slice(1, -1)));
return tags;
};
/* harmony default export */ const libs_convertToTag = (convertToTag);
;// CONCATENATED MODULE: ./src/libs/time-formatter.js
function formatDateTime(dateString) {
let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "YYYY-MM-DD";
const date = new Date(dateString);
switch (format) {
case "MM-DD HH:mm":
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return "".concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes);
case "YYYY-MM-DD HH:mm:ss":
const year = date.getFullYear();
const month2 = String(date.getMonth() + 1).padStart(2, "0");
const day2 = String(date.getDate()).padStart(2, "0");
const hours2 = String(date.getHours()).padStart(2, "0");
const minutes2 = String(date.getMinutes()).padStart(2, "0");
const seconds2 = String(date.getSeconds()).padStart(2, "0");
return "".concat(year, "-").concat(month2, "-").concat(day2, " ").concat(hours2, ":").concat(minutes2, ":").concat(seconds2);
case "YYYY-MM-DD":
const year2 = date.getFullYear();
const month3 = String(date.getMonth() + 1).padStart(2, "0");
const day3 = String(date.getDate()).padStart(2, "0");
return "".concat(year2, "-").concat(month3, "-").concat(day3);
case "HH:mm:ss":
const hours4 = String(date.getHours()).padStart(2, "0");
const minutes4 = String(date.getMinutes()).padStart(2, "0");
const seconds4 = String(date.getSeconds()).padStart(2, "0");
console.log("`${hours4}:${minutes4}:${seconds4}`: ", "".concat(hours4, ":").concat(minutes4, ":").concat(seconds4));
return "".concat(hours4, ":").concat(minutes4, ":").concat(seconds4);
case "YYYY-MM-DD HH:mm":
const year5 = date.getFullYear();
const month5 = String(date.getMonth() + 1).padStart(2, "0");
const day5 = String(date.getDate()).padStart(2, "0");
const hours5 = String(date.getHours()).padStart(2, "0");
const minutes5 = String(date.getMinutes()).padStart(2, "0");
return "".concat(year5, "-").concat(month5, "-").concat(day5, " ").concat(hours5, ":").concat(minutes5);
default:
break;
}
}
/* harmony default export */ const time_formatter = (formatDateTime);
;// CONCATENATED MODULE: ./src/libs/isEmptyO.js
function isEmptyO(obj) {
return Object.keys(obj !== null && obj !== void 0 ? obj : {}).length === 0;
}
/* harmony default export */ const libs_isEmptyO = (isEmptyO);
;// CONCATENATED MODULE: ./src/libs/convertArrayKeysToCamelCase.js
function snakeToCamel(name) {
return name.replace(/_([a-z])/g, (match, letter) => letter.toUpperCase());
}
function convertKeysToCamelCase(obj) {
return Object.fromEntries(Object.entries(obj).map(_ref => {
let [key, value] = _ref;
return [snakeToCamel(key), value || ""];
}));
}
function convertArrayKeysToCamelCase(arr) {
return arr.map(item => convertKeysToCamelCase(item));
}
/* harmony default export */ const libs_convertArrayKeysToCamelCase = (convertArrayKeysToCamelCase);
;// CONCATENATED MODULE: ./src/libs/convertArrayKeysToSnakeCase.js
function camelToSnake(name) {
return name.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
}
function convertKeysToSnakeCase(obj) {
return Object.fromEntries(Object.entries(obj).map(_ref => {
let [key, value] = _ref;
return [camelToSnake(key), value];
}));
}
function convertArrayKeysToSnakeCase(arr) {
return arr.map(item => convertKeysToSnakeCase(item));
}
/* harmony default export */ const libs_convertArrayKeysToSnakeCase = (convertArrayKeysToSnakeCase);
;// CONCATENATED MODULE: ./src/libs/convertListToTree.ts
const convertListToTree = (list, pid) => {
let level = 0;
// 递归辅助函数,用于处理每个节点及其子节点
const buildTree = (items, parentId, currentLevel) => {
const children = [];
items.forEach(item => {
if (item.pid === parentId) {
item.level = currentLevel;
children.push(item);
// 递归调用自身处理子节点,层级加1
item.children = buildTree(list, item.id, currentLevel + 1);
}
});
return children;
};
const data = buildTree(list, pid, level);
return data;
};
/* harmony default export */ const libs_convertListToTree = (convertListToTree);
;// CONCATENATED MODULE: ./src/libs/flattenDataWithoutNesting.ts
function flattenDataWithoutNesting(data) {
let flattened = [];
function flattenRecursive(node, parentId) {
const {
id,
name,
isExpanded
} = node;
flattened.push({
...node,
id,
name,
isExpanded,
pid: parentId
});
if (node.children && node.children.length > 0) {
node.children.forEach(child => {
flattenRecursive(child, id);
});
}
}
data.forEach(rootNode => {
flattenRecursive(rootNode, null);
});
return flattened;
}
/* harmony default export */ const libs_flattenDataWithoutNesting = (flattenDataWithoutNesting);
;// CONCATENATED MODULE: ./src/libs/splitFilesIntoColumns.ts
// 根据列数和每列展示的文件数量来分割文件
const splitFilesIntoColumns = (files, filesPerColumn) => {
const result = [];
let currentColumn = [];
files.forEach((file, index) => {
currentColumn.push(file);
if ((index + 1) % filesPerColumn === 0 || index === files.length - 1) {
result.push(currentColumn);
currentColumn = [];
}
});
return result;
};
/* harmony default export */ const libs_splitFilesIntoColumns = (splitFilesIntoColumns);
;// CONCATENATED MODULE: ./src/libs/getContentWidth.ts
function getContentWidth(element) {
const computedStyle = window.getComputedStyle(element);
const offsetWidth = element.offsetWidth;
const borderWidthLeftRight = parseInt(computedStyle.borderLeftWidth) + parseInt(computedStyle.borderRightWidth);
const paddingWidthLeftRight = parseInt(computedStyle.paddingLeft) + parseInt(computedStyle.paddingRight);
return offsetWidth - borderWidthLeftRight - paddingWidthLeftRight;
}
/* harmony default export */ const libs_getContentWidth = (getContentWidth);
;// CONCATENATED MODULE: ../../node_modules/@remix-run/router/dist/router.js
/**
* @remix-run/router v1.5.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
////////////////////////////////////////////////////////////////////////////////
//#region Types and Constants
////////////////////////////////////////////////////////////////////////////////
/**
* Actions represent the type of change to a location value.
*/
var router_Action;
(function (Action) {
/**
* A POP indicates a change to an arbitrary index in the history stack, such
* as a back or forward navigation. It does not describe the direction of the
* navigation, only that the current index changed.
*
* Note: This is the default action for newly created history objects.
*/
Action["Pop"] = "POP";
/**
* A PUSH indicates a new entry being added to the history stack, such as when
* a link is clicked and a new page loads. When this happens, all subsequent
* entries in the stack are lost.
*/
Action["Push"] = "PUSH";
/**
* A REPLACE indicates the entry at the current index in the history stack
* being replaced by a new one.
*/
Action["Replace"] = "REPLACE";
})(router_Action || (router_Action = {}));
const PopStateEventType = "popstate";
/**
* Memory history stores the current location in memory. It is designed for use
* in stateful non-browser environments like tests and React Native.
*/
function router_createMemoryHistory(options) {
if (options === void 0) {
options = {};
}
let {
initialEntries = ["/"],
initialIndex,
v5Compat = false
} = options;
let entries; // Declare so we can access from createMemoryLocation
entries = initialEntries.map((entry, index) => createMemoryLocation(entry, typeof entry === "string" ? null : entry.state, index === 0 ? "default" : undefined));
let index = clampIndex(initialIndex == null ? entries.length - 1 : initialIndex);
let action = router_Action.Pop;
let listener = null;
function clampIndex(n) {
return Math.min(Math.max(n, 0), entries.length - 1);
}
function getCurrentLocation() {
return entries[index];
}
function createMemoryLocation(to, state, key) {
if (state === void 0) {
state = null;
}
let location = createLocation(entries ? getCurrentLocation().pathname : "/", to, state, key);
warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in memory history: " + JSON.stringify(to));
return location;
}
function createHref(to) {
return typeof to === "string" ? to : createPath(to);
}
let history = {
get index() {
return index;
},
get action() {
return action;
},
get location() {
return getCurrentLocation();
},
createHref,
createURL(to) {
return new URL(createHref(to), "http://localhost");
},
encodeLocation(to) {
let path = typeof to === "string" ? router_parsePath(to) : to;
return {
pathname: path.pathname || "",
search: path.search || "",
hash: path.hash || ""
};
},
push(to, state) {
action = router_Action.Push;
let nextLocation = createMemoryLocation(to, state);
index += 1;
entries.splice(index, entries.length, nextLocation);
if (v5Compat && listener) {
listener({
action,
location: nextLocation,
delta: 1
});
}
},
replace(to, state) {
action = router_Action.Replace;
let nextLocation = createMemoryLocation(to, state);
entries[index] = nextLocation;
if (v5Compat && listener) {
listener({
action,
location: nextLocation,
delta: 0
});
}
},
go(delta) {
action = router_Action.Pop;
let nextIndex = clampIndex(index + delta);
let nextLocation = entries[nextIndex];
index = nextIndex;
if (listener) {
listener({
action,
location: nextLocation,
delta
});
}
},
listen(fn) {
listener = fn;
return () => {
listener = null;
};
}
};
return history;
}
/**
* Browser history stores the location in regular URLs. This is the standard for
* most web apps, but it requires some configuration on the server to ensure you
* serve the same app at multiple URLs.
*
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
*/
function createBrowserHistory(options) {
if (options === void 0) {
options = {};
}
function createBrowserLocation(window, globalHistory) {
let {
pathname,
search,
hash
} = window.location;
return createLocation("", {
pathname,
search,
hash
},
// state defaults to `null` because `window.history.state` does
globalHistory.state && globalHistory.state.usr || null, globalHistory.state && globalHistory.state.key || "default");
}
function createBrowserHref(window, to) {
return typeof to === "string" ? to : createPath(to);
}
return getUrlBasedHistory(createBrowserLocation, createBrowserHref, null, options);
}
/**
* Hash history stores the location in window.location.hash. This makes it ideal
* for situations where you don't want to send the location to the server for
* some reason, either because you do cannot configure it or the URL space is
* reserved for something else.
*
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
*/
function createHashHistory(options) {
if (options === void 0) {
options = {};
}
function createHashLocation(window, globalHistory) {
let {
pathname = "/",
search = "",
hash = ""
} = router_parsePath(window.location.hash.substr(1));
return createLocation("", {
pathname,
search,
hash
},
// state defaults to `null` because `window.history.state` does
globalHistory.state && globalHistory.state.usr || null, globalHistory.state && globalHistory.state.key || "default");
}
function createHashHref(window, to) {
let base = window.document.querySelector("base");
let href = "";
if (base && base.getAttribute("href")) {
let url = window.location.href;
let hashIndex = url.indexOf("#");
href = hashIndex === -1 ? url : url.slice(0, hashIndex);
}
return href + "#" + (typeof to === "string" ? to : createPath(to));
}
function validateHashLocation(location, to) {
warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in hash history.push(" + JSON.stringify(to) + ")");
}
return getUrlBasedHistory(createHashLocation, createHashHref, validateHashLocation, options);
}
function invariant(value, message) {
if (value === false || value === null || typeof value === "undefined") {
throw new Error(message);
}
}
function warning(cond, message) {
if (!cond) {
// eslint-disable-next-line no-console
if (typeof console !== "undefined") console.warn(message);
try {
// Welcome to debugging history!
//
// This error is thrown as a convenience so you can more easily
// find the source for a warning that appears in the console by
// enabling "pause on exceptions" in your JavaScript debugger.
throw new Error(message); // eslint-disable-next-line no-empty
} catch (e) {}
}
}
function createKey() {
return Math.random().toString(36).substr(2, 8);
}
/**
* For browser-based histories, we combine the state and key into an object
*/
function getHistoryState(location, index) {
return {
usr: location.state,
key: location.key,
idx: index
};
}
/**
* Creates a Location object with a unique key from the given Path
*/
function createLocation(current, to, state, key) {
if (state === void 0) {
state = null;
}
let location = _extends({
pathname: typeof current === "string" ? current : current.pathname,
search: "",
hash: ""
}, typeof to === "string" ? router_parsePath(to) : to, {
state,
// TODO: This could be cleaned up. push/replace should probably just take
// full Locations now and avoid the need to run through this flow at all
// But that's a pretty big refactor to the current test suite so going to
// keep as is for the time being and just let any incoming keys take precedence
key: to && to.key || key || createKey()
});
return location;
}
/**
* Creates a string URL path from the given pathname, search, and hash components.
*/
function createPath(_ref) {
let {
pathname = "/",
search = "",
hash = ""
} = _ref;
if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
return pathname;
}
/**
* Parses a string URL path into its separate pathname, search, and hash components.
*/
function router_parsePath(path) {
let parsedPath = {};
if (path) {
let hashIndex = path.indexOf("#");
if (hashIndex >= 0) {
parsedPath.hash = path.substr(hashIndex);
path = path.substr(0, hashIndex);
}
let searchIndex = path.indexOf("?");
if (searchIndex >= 0) {
parsedPath.search = path.substr(searchIndex);
path = path.substr(0, searchIndex);
}
if (path) {
parsedPath.pathname = path;
}
}
return parsedPath;
}
function getUrlBasedHistory(getLocation, createHref, validateLocation, options) {
if (options === void 0) {
options = {};
}
let {
window = document.defaultView,
v5Compat = false
} = options;
let globalHistory = window.history;
let action = router_Action.Pop;
let listener = null;
let index = getIndex(); // Index should only be null when we initialize. If not, it's because the
// user called history.pushState or history.replaceState directly, in which
// case we should log a warning as it will result in bugs.
if (index == null) {
index = 0;
globalHistory.replaceState(_extends({}, globalHistory.state, {
idx: index
}), "");
}
function getIndex() {
let state = globalHistory.state || {
idx: null
};
return state.idx;
}
function handlePop() {
action = router_Action.Pop;
let nextIndex = getIndex();
let delta = nextIndex == null ? null : nextIndex - index;
index = nextIndex;
if (listener) {
listener({
action,
location: history.location,
delta
});
}
}
function push(to, state) {
action = router_Action.Push;
let location = createLocation(history.location, to, state);
if (validateLocation) validateLocation(location, to);
index = getIndex() + 1;
let historyState = getHistoryState(location, index);
let url = history.createHref(location); // try...catch because iOS limits us to 100 pushState calls :/
try {
globalHistory.pushState(historyState, "", url);
} catch (error) {
// They are going to lose state here, but there is no real
// way to warn them about it since the page will refresh...
window.location.assign(url);
}
if (v5Compat && listener) {
listener({
action,
location: history.location,
delta: 1
});
}
}
function replace(to, state) {
action = router_Action.Replace;
let location = createLocation(history.location, to, state);
if (validateLocation) validateLocation(location, to);
index = getIndex();
let historyState = getHistoryState(location, index);
let url = history.createHref(location);
globalHistory.replaceState(historyState, "", url);
if (v5Compat && listener) {
listener({
action,
location: history.location,
delta: 0
});
}
}
function createURL(to) {
// window.location.origin is "null" (the literal string value) in Firefox
// under certain conditions, notably when serving from a local HTML file
// See https://bugzilla.mozilla.org/show_bug.cgi?id=878297
let base = window.location.origin !== "null" ? window.location.origin : window.location.href;
let href = typeof to === "string" ? to : createPath(to);
invariant(base, "No window.location.(origin|href) available to create URL for href: " + href);
return new URL(href, base);
}
let history = {
get action() {
return action;
},
get location() {
return getLocation(window, globalHistory);
},
listen(fn) {
if (listener) {
throw new Error("A history only accepts one active listener");
}
window.addEventListener(PopStateEventType, handlePop);
listener = fn;
return () => {
window.removeEventListener(PopStateEventType, handlePop);
listener = null;
};
},
createHref(to) {
return createHref(window, to);
},
createURL,
encodeLocation(to) {
// Encode a Location the same way window.location would
let url = createURL(to);
return {
pathname: url.pathname,
search: url.search,
hash: url.hash
};