cell-router
Version:
Web Component Router based on WebCell & MobX
662 lines (632 loc) • 31.5 kB
JavaScript
require("urlpattern-polyfill");
var $iUaHk$webutility = require("web-utility");
var $iUaHk$mobx = require("mobx");
var $iUaHk$domrendererjsxruntime = require("dom-renderer/jsx-runtime");
var $iUaHk$domrenderer = require("dom-renderer");
var $iUaHk$webcell = require("web-cell");
function $parcel$exportWildcard(dest, source) {
Object.keys(source).forEach(function(key) {
if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {
return;
}
Object.defineProperty(dest, key, {
enumerable: true,
get: function get() {
return source[key];
}
});
});
return dest;
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $f52103fdbf0b41a3$exports = {};
$parcel$export($f52103fdbf0b41a3$exports, "RouterMode", () => $f52103fdbf0b41a3$export$fc55ead6785c2297);
$parcel$export($f52103fdbf0b41a3$exports, "History", () => $f52103fdbf0b41a3$export$84202caead5689ba);
var $f52103fdbf0b41a3$var$__runInitializers = undefined && undefined.__runInitializers || function(thisArg, initializers, value) {
var useValue = arguments.length > 2;
for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
return useValue ? value : void 0;
};
var $f52103fdbf0b41a3$var$__esDecorate = undefined && undefined.__esDecorate || function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
function accept(f) {
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
return f;
}
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
var _, done = false;
for(var i = decorators.length - 1; i >= 0; i--){
var context = {};
for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p];
for(var p in contextIn.access)context.access[p] = contextIn.access[p];
context.addInitializer = function(f) {
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
extraInitializers.push(accept(f || null));
};
var result = (0, decorators[i])(kind === "accessor" ? {
get: descriptor.get,
set: descriptor.set
} : descriptor[key], context);
if (kind === "accessor") {
if (result === void 0) continue;
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
if (_ = accept(result.get)) descriptor.get = _;
if (_ = accept(result.set)) descriptor.set = _;
if (_ = accept(result.init)) initializers.unshift(_);
} else if (_ = accept(result)) {
if (kind === "field") initializers.unshift(_);
else descriptor[key] = _;
}
}
if (target) Object.defineProperty(target, contextIn.name, descriptor);
done = true;
};
var $f52103fdbf0b41a3$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var $f52103fdbf0b41a3$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
};
var $f52103fdbf0b41a3$var$_a, $f52103fdbf0b41a3$var$_b;
const { location: $f52103fdbf0b41a3$var$location, history: $f52103fdbf0b41a3$var$history } = window;
const $f52103fdbf0b41a3$var$basePath = ($f52103fdbf0b41a3$var$_a = document.querySelector('base')) === null || $f52103fdbf0b41a3$var$_a === void 0 ? void 0 : $f52103fdbf0b41a3$var$_a.getAttribute('href');
const $f52103fdbf0b41a3$var$defaultBaseURL = ($f52103fdbf0b41a3$var$basePath ? new URL($f52103fdbf0b41a3$var$basePath, $f52103fdbf0b41a3$var$location.origin) + '' : $f52103fdbf0b41a3$var$location.href.split(/\?|#/)[0]).replace(/\/$/, '');
const $f52103fdbf0b41a3$var$originalTitle = ($f52103fdbf0b41a3$var$_b = document.querySelector('title')) === null || $f52103fdbf0b41a3$var$_b === void 0 ? void 0 : $f52103fdbf0b41a3$var$_b.textContent.trim();
var $f52103fdbf0b41a3$export$fc55ead6785c2297;
(function(RouterMode) {
RouterMode["hash"] = "#";
RouterMode["history"] = "/";
})($f52103fdbf0b41a3$export$fc55ead6785c2297 || ($f52103fdbf0b41a3$export$fc55ead6785c2297 = {}));
let $f52103fdbf0b41a3$export$84202caead5689ba = (()=>{
var _a, _History_path_accessor_storage, _History_oldPath_accessor_storage;
let _instanceExtraInitializers = [];
let _path_decorators;
let _path_initializers = [];
let _path_extraInitializers = [];
let _oldPath_decorators;
let _oldPath_initializers = [];
let _oldPath_extraInitializers = [];
let _push_decorators;
return _a = class History {
get path() {
return $f52103fdbf0b41a3$var$__classPrivateFieldGet(this, _History_path_accessor_storage, "f");
}
set path(value) {
$f52103fdbf0b41a3$var$__classPrivateFieldSet(this, _History_path_accessor_storage, value, "f");
}
get oldPath() {
return $f52103fdbf0b41a3$var$__classPrivateFieldGet(this, _History_oldPath_accessor_storage, "f");
}
set oldPath(value) {
$f52103fdbf0b41a3$var$__classPrivateFieldSet(this, _History_oldPath_accessor_storage, value, "f");
}
constructor(baseURL = $f52103fdbf0b41a3$var$defaultBaseURL, delimiter = $f52103fdbf0b41a3$export$fc55ead6785c2297.hash){
Object.defineProperty(this, "baseURL", {
enumerable: true,
configurable: true,
writable: true,
value: ($f52103fdbf0b41a3$var$__runInitializers(this, _instanceExtraInitializers), baseURL)
});
Object.defineProperty(this, "delimiter", {
enumerable: true,
configurable: true,
writable: true,
value: delimiter
});
_History_path_accessor_storage.set(this, $f52103fdbf0b41a3$var$__runInitializers(this, _path_initializers, void 0));
_History_oldPath_accessor_storage.set(this, ($f52103fdbf0b41a3$var$__runInitializers(this, _path_extraInitializers), $f52103fdbf0b41a3$var$__runInitializers(this, _oldPath_initializers, void 0)));
Object.defineProperty(this, "restore", {
enumerable: true,
configurable: true,
writable: true,
value: ($f52103fdbf0b41a3$var$__runInitializers(this, _oldPath_extraInitializers), ()=>{
const { state: state } = $f52103fdbf0b41a3$var$history;
this.push();
document.title = (state === null || state === void 0 ? void 0 : state.title) || this.titleOf() || $f52103fdbf0b41a3$var$originalTitle || $f52103fdbf0b41a3$var$location.href;
})
});
Object.defineProperty(this, "handleForm", {
enumerable: true,
configurable: true,
writable: true,
value: (event, form)=>{
const { method: method, target: target } = form;
if (method !== 'get' || (target || '_self') !== '_self') return;
event.preventDefault();
const path = form.getAttribute('action'), data = (0, $iUaHk$webutility.buildURLData)((0, $iUaHk$webutility.formToJSON)(form));
this.push(`${path}?${data}`);
}
});
this.restore();
window.addEventListener('hashchange', this.restore);
window.addEventListener('popstate', this.restore);
document.addEventListener('click', (0, $iUaHk$webutility.delegate)('a[href], area[href]', this.handleLink.bind(this)));
document.addEventListener('submit', (0, $iUaHk$webutility.delegate)('form[action]', this.handleForm));
}
push(path = $f52103fdbf0b41a3$var$location.href) {
var _b;
path = path.replace(this.baseURL, '');
if (this.delimiter === $f52103fdbf0b41a3$export$fc55ead6785c2297.hash) path = ((_b = path.match(/#.*/)) === null || _b === void 0 ? void 0 : _b[0]) || $f52103fdbf0b41a3$export$fc55ead6785c2297.hash;
if (path === this.path) return path;
this.oldPath = this.path;
return this.path = path;
}
static dataOf(path) {
const [before, after] = path.split('#');
return (0, $iUaHk$webutility.parseURLData)(after || before);
}
match(pattern, path = this.path) {
var _b;
if (!path) return;
const { pathname: pathname, hash: hash } = new URLPattern(pattern, this.baseURL).exec(new URL(path.split('?')[0], this.baseURL)) || {};
return (_b = hash || pathname) === null || _b === void 0 ? void 0 : _b.groups;
}
static getTitle(root) {
return root.title || (0, $iUaHk$webutility.getVisibleText)(root);
}
titleOf(path = this.path) {
path = path.replace(/^\//, '');
if (path) for (const node of document.querySelectorAll(`a[href="${path}"], area[href="${path}"]`)){
const title = _a.getTitle(node);
if (title) return title;
}
}
handleLink(event, link) {
const path = link.getAttribute('href');
if ((link.target || '_self') !== '_self' || (0, $iUaHk$webutility.isXDomain)(path) || link.download) return;
event.preventDefault();
if (path.startsWith('#')) try {
if (document.querySelector(path) || path === '#top') return (0, $iUaHk$webutility.scrollTo)(path, event.currentTarget);
} catch (_b) {}
const title = _a.getTitle(link);
$f52103fdbf0b41a3$var$history.pushState({
title: title
}, document.title = title, path);
this.push(path);
}
}, _History_path_accessor_storage = new WeakMap(), _History_oldPath_accessor_storage = new WeakMap(), (()=>{
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_path_decorators = [
(0, $iUaHk$mobx.observable)
];
_oldPath_decorators = [
(0, $iUaHk$mobx.observable)
];
_push_decorators = [
(0, $iUaHk$mobx.action)
];
$f52103fdbf0b41a3$var$__esDecorate(_a, null, _path_decorators, {
kind: "accessor",
name: "path",
static: false,
private: false,
access: {
has: (obj)=>"path" in obj,
get: (obj)=>obj.path,
set: (obj, value)=>{
obj.path = value;
}
},
metadata: _metadata
}, _path_initializers, _path_extraInitializers);
$f52103fdbf0b41a3$var$__esDecorate(_a, null, _oldPath_decorators, {
kind: "accessor",
name: "oldPath",
static: false,
private: false,
access: {
has: (obj)=>"oldPath" in obj,
get: (obj)=>obj.oldPath,
set: (obj, value)=>{
obj.oldPath = value;
}
},
metadata: _metadata
}, _oldPath_initializers, _oldPath_extraInitializers);
$f52103fdbf0b41a3$var$__esDecorate(_a, null, _push_decorators, {
kind: "method",
name: "push",
static: false,
private: false,
access: {
has: (obj)=>"push" in obj,
get: (obj)=>obj.push
},
metadata: _metadata
}, null, _instanceExtraInitializers);
if (_metadata) Object.defineProperty(_a, Symbol.metadata, {
enumerable: true,
configurable: true,
writable: true,
value: _metadata
});
})(), _a;
})();
var $4f817c7d46c18f8e$exports = {};
$parcel$export($4f817c7d46c18f8e$exports, "CellRoute", () => $4f817c7d46c18f8e$export$d6c529ca17cdd16f);
$parcel$export($4f817c7d46c18f8e$exports, "CellRouter", () => $4f817c7d46c18f8e$export$b1119cfa2764f723);
var $4f817c7d46c18f8e$var$__esDecorate = undefined && undefined.__esDecorate || function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
function accept(f) {
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
return f;
}
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
var _, done = false;
for(var i = decorators.length - 1; i >= 0; i--){
var context = {};
for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p];
for(var p in contextIn.access)context.access[p] = contextIn.access[p];
context.addInitializer = function(f) {
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
extraInitializers.push(accept(f || null));
};
var result = (0, decorators[i])(kind === "accessor" ? {
get: descriptor.get,
set: descriptor.set
} : descriptor[key], context);
if (kind === "accessor") {
if (result === void 0) continue;
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
if (_ = accept(result.get)) descriptor.get = _;
if (_ = accept(result.set)) descriptor.set = _;
if (_ = accept(result.init)) initializers.unshift(_);
} else if (_ = accept(result)) {
if (kind === "field") initializers.unshift(_);
else descriptor[key] = _;
}
}
if (target) Object.defineProperty(target, contextIn.name, descriptor);
done = true;
};
var $4f817c7d46c18f8e$var$__runInitializers = undefined && undefined.__runInitializers || function(thisArg, initializers, value) {
var useValue = arguments.length > 2;
for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
return useValue ? value : void 0;
};
var $4f817c7d46c18f8e$var$__setFunctionName = undefined && undefined.__setFunctionName || function(f, name, prefix) {
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
return Object.defineProperty(f, "name", {
configurable: true,
value: prefix ? "".concat(prefix, " ", name) : name
});
};
var $4f817c7d46c18f8e$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var $4f817c7d46c18f8e$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
};
var $4f817c7d46c18f8e$var$__rest = undefined && undefined.__rest || function(s, e) {
var t = {};
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") {
for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
let $4f817c7d46c18f8e$export$d6c529ca17cdd16f = (()=>{
var _CellRoute_path_accessor_storage;
let _classDecorators = [
(0, $iUaHk$webcell.component)({
tagName: 'cell-route'
}),
(0, $iUaHk$webcell.observer)
];
let _classDescriptor;
let _classExtraInitializers = [];
let _classThis;
let _classSuper = HTMLElement;
let _path_decorators;
let _path_initializers = [];
let _path_extraInitializers = [];
var CellRoute = _classThis = class extends _classSuper {
constructor(){
super(...arguments);
_CellRoute_path_accessor_storage.set(this, $4f817c7d46c18f8e$var$__runInitializers(this, _path_initializers, void 0));
Object.defineProperty(this, "component", {
enumerable: true,
configurable: true,
writable: true,
value: $4f817c7d46c18f8e$var$__runInitializers(this, _path_extraInitializers)
});
}
get path() {
return $4f817c7d46c18f8e$var$__classPrivateFieldGet(this, _CellRoute_path_accessor_storage, "f");
}
set path(value) {
$4f817c7d46c18f8e$var$__classPrivateFieldSet(this, _CellRoute_path_accessor_storage, value, "f");
}
};
_CellRoute_path_accessor_storage = new WeakMap();
$4f817c7d46c18f8e$var$__setFunctionName(_classThis, "CellRoute");
(()=>{
var _a;
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
_path_decorators = [
(0, $iUaHk$webcell.attribute),
(0, $iUaHk$mobx.observable)
];
$4f817c7d46c18f8e$var$__esDecorate(_classThis, null, _path_decorators, {
kind: "accessor",
name: "path",
static: false,
private: false,
access: {
has: (obj)=>"path" in obj,
get: (obj)=>obj.path,
set: (obj, value)=>{
obj.path = value;
}
},
metadata: _metadata
}, _path_initializers, _path_extraInitializers);
$4f817c7d46c18f8e$var$__esDecorate(null, _classDescriptor = {
value: _classThis
}, _classDecorators, {
kind: "class",
name: _classThis.name,
metadata: _metadata
}, null, _classExtraInitializers);
CellRoute = _classThis = _classDescriptor.value;
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
enumerable: true,
configurable: true,
writable: true,
value: _metadata
});
$4f817c7d46c18f8e$var$__runInitializers(_classThis, _classExtraInitializers);
})();
return CellRoute = _classThis;
})();
let $4f817c7d46c18f8e$export$b1119cfa2764f723 = (()=>{
var _CellRouter_renderer, _CellRouter_history_accessor_storage, _CellRouter_routes_accessor_storage;
var _a, _b;
let _classDecorators = [
(0, $iUaHk$webcell.component)({
tagName: 'cell-router',
mode: 'open'
}),
(0, $iUaHk$webcell.observer)
];
let _classDescriptor;
let _classExtraInitializers = [];
let _classThis;
let _classSuper = HTMLElement;
let _instanceExtraInitializers = [];
let _history_decorators;
let _history_initializers = [];
let _history_extraInitializers = [];
let _routes_decorators;
let _routes_initializers = [];
let _routes_extraInitializers = [];
let _renderChildren_decorators;
var CellRouter = _classThis = class extends _classSuper {
constructor(){
super(...arguments);
_CellRouter_history_accessor_storage.set(this, ($4f817c7d46c18f8e$var$__runInitializers(this, _instanceExtraInitializers), $4f817c7d46c18f8e$var$__runInitializers(this, _history_initializers, void 0)));
_CellRouter_routes_accessor_storage.set(this, ($4f817c7d46c18f8e$var$__runInitializers(this, _history_extraInitializers), $4f817c7d46c18f8e$var$__runInitializers(this, _routes_initializers, [])));
_CellRouter_renderer.set(this, ($4f817c7d46c18f8e$var$__runInitializers(this, _routes_extraInitializers), new (0, $iUaHk$domrenderer.DOMRenderer)()));
Object.defineProperty(this, "handleSlotChange", {
enumerable: true,
configurable: true,
writable: true,
value: ({ currentTarget: currentTarget })=>{
const routes = currentTarget.assignedElements().filter((node)=>node instanceof $4f817c7d46c18f8e$export$d6c529ca17cdd16f).map(({ path: path, component: component })=>({
path: path,
component: component
}));
if (routes[0]) this.routes = routes;
}
});
}
get history() {
return $4f817c7d46c18f8e$var$__classPrivateFieldGet(this, _CellRouter_history_accessor_storage, "f");
}
set history(value) {
$4f817c7d46c18f8e$var$__classPrivateFieldSet(this, _CellRouter_history_accessor_storage, value, "f");
}
get routes() {
return $4f817c7d46c18f8e$var$__classPrivateFieldGet(this, _CellRouter_routes_accessor_storage, "f");
}
set routes(value) {
$4f817c7d46c18f8e$var$__classPrivateFieldSet(this, _CellRouter_routes_accessor_storage, value, "f");
}
mountedCallback() {
this.history || (this.history = new (0, $f52103fdbf0b41a3$export$84202caead5689ba)());
this.renderChildren();
}
async renderChildren() {
var _a;
const { history: history, routes: routes } = this;
if (!history) return;
const { path: path } = history;
const [_b] = [
...routes
].sort(({ path: a }, { path: b })=>b.split('/').length - a.split('/').length).map(({ path: path, component: component })=>{
const matched = history.match(path);
return matched && Object.assign({
component: component
}, matched);
}).filter(Boolean), _c = _b === void 0 ? {} : _b, { component: Tag } = _c, matched = $4f817c7d46c18f8e$var$__rest(_c, [
"component"
]);
const vNode = Tag ? (0, $iUaHk$domrendererjsxruntime.jsx)(Tag, Object.assign({}, matched, (0, $f52103fdbf0b41a3$export$84202caead5689ba).dataOf(path), {
path: path,
history: history
})) : (0, $iUaHk$domrendererjsxruntime.jsx)((0, $iUaHk$domrendererjsxruntime.Fragment), {});
const render = ()=>{
$4f817c7d46c18f8e$var$__classPrivateFieldGet(this, _CellRouter_renderer, "f").render(vNode, this);
return {};
};
const { finished: finished, updateCallbackDone: updateCallbackDone } = ((_a = document.startViewTransition) === null || _a === void 0 ? void 0 : _a.call(document, render)) || render();
try {
await finished;
} catch (_d) {
return updateCallbackDone;
}
}
render() {
return (0, $iUaHk$domrendererjsxruntime.jsx)("slot", {
onSlotChange: this.handleSlotChange
});
}
};
_CellRouter_renderer = new WeakMap();
_CellRouter_history_accessor_storage = new WeakMap();
_CellRouter_routes_accessor_storage = new WeakMap();
$4f817c7d46c18f8e$var$__setFunctionName(_classThis, "CellRouter");
(()=>{
var _a;
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
_history_decorators = [
(_a = (0, $iUaHk$mobx.observable)).shallow.bind(_a)
];
_routes_decorators = [
(_b = (0, $iUaHk$mobx.observable)).shallow.bind(_b)
];
_renderChildren_decorators = [
(0, $iUaHk$webcell.reaction)(({ history: history })=>history === null || history === void 0 ? void 0 : history.path)
];
$4f817c7d46c18f8e$var$__esDecorate(_classThis, null, _history_decorators, {
kind: "accessor",
name: "history",
static: false,
private: false,
access: {
has: (obj)=>"history" in obj,
get: (obj)=>obj.history,
set: (obj, value)=>{
obj.history = value;
}
},
metadata: _metadata
}, _history_initializers, _history_extraInitializers);
$4f817c7d46c18f8e$var$__esDecorate(_classThis, null, _routes_decorators, {
kind: "accessor",
name: "routes",
static: false,
private: false,
access: {
has: (obj)=>"routes" in obj,
get: (obj)=>obj.routes,
set: (obj, value)=>{
obj.routes = value;
}
},
metadata: _metadata
}, _routes_initializers, _routes_extraInitializers);
$4f817c7d46c18f8e$var$__esDecorate(_classThis, null, _renderChildren_decorators, {
kind: "method",
name: "renderChildren",
static: false,
private: false,
access: {
has: (obj)=>"renderChildren" in obj,
get: (obj)=>obj.renderChildren
},
metadata: _metadata
}, null, _instanceExtraInitializers);
$4f817c7d46c18f8e$var$__esDecorate(null, _classDescriptor = {
value: _classThis
}, _classDecorators, {
kind: "class",
name: _classThis.name,
metadata: _metadata
}, null, _classExtraInitializers);
CellRouter = _classThis = _classDescriptor.value;
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, {
enumerable: true,
configurable: true,
writable: true,
value: _metadata
});
$4f817c7d46c18f8e$var$__runInitializers(_classThis, _classExtraInitializers);
})();
return CellRouter = _classThis;
})();
var $118b8dd15265946f$exports = {};
var $a7c196c05a33728c$exports = {};
$parcel$export($a7c196c05a33728c$exports, "createRouter", () => $a7c196c05a33728c$export$baddd0131ee8c05b);
var $a7c196c05a33728c$var$__rest = undefined && undefined.__rest || function(s, e) {
var t = {};
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") {
for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
function $a7c196c05a33728c$export$baddd0131ee8c05b({ mode: mode = 'hash', linkTags: linkTags } = {}) {
const prefix = (0, $f52103fdbf0b41a3$export$fc55ead6785c2297)[mode];
const extraComponentList = Object.entries(linkTags || {}).map(([name, Component])=>[
name,
(_a)=>{
var { href: href } = _a, props = $a7c196c05a33728c$var$__rest(_a, [
"href"
]);
return (0, $iUaHk$domrendererjsxruntime.jsx)(Component, Object.assign({}, props, {
href: prefix + (href || '')
}));
}
]);
const extraComponentMap = Object.fromEntries(extraComponentList);
return Object.assign(Object.assign({}, extraComponentMap), {
Router: (_a)=>{
var { routes: routes } = _a, props = $a7c196c05a33728c$var$__rest(_a, [
"routes"
]);
return (0, $iUaHk$domrendererjsxruntime.jsx)((0, $4f817c7d46c18f8e$export$b1119cfa2764f723), Object.assign({}, props, {
routes: routes === null || routes === void 0 ? void 0 : routes.map((route)=>Object.assign(Object.assign({}, route), {
path: prefix + route.path
}))
}));
},
Route: (_a)=>{
var { path: path } = _a, props = $a7c196c05a33728c$var$__rest(_a, [
"path"
]);
return (0, $iUaHk$domrendererjsxruntime.jsx)((0, $4f817c7d46c18f8e$export$d6c529ca17cdd16f), Object.assign({}, props, {
path: prefix + path
}));
},
Link: (_a)=>{
var { to: to, children: children } = _a, props = $a7c196c05a33728c$var$__rest(_a, [
"to",
"children"
]);
return (0, $iUaHk$domrendererjsxruntime.jsx)("a", Object.assign({}, props, {
href: prefix + to,
children: children
}));
},
Form: (_a)=>{
var { action: action, children: children } = _a, props = $a7c196c05a33728c$var$__rest(_a, [
"action",
"children"
]);
return (0, $iUaHk$domrendererjsxruntime.jsx)("form", Object.assign({}, props, {
action: prefix + action,
children: children
}));
}
});
}
$parcel$exportWildcard(module.exports, $f52103fdbf0b41a3$exports);
$parcel$exportWildcard(module.exports, $4f817c7d46c18f8e$exports);
$parcel$exportWildcard(module.exports, $118b8dd15265946f$exports);
$parcel$exportWildcard(module.exports, $a7c196c05a33728c$exports);
//# sourceMappingURL=index.js.map