@pod-os/elements 0.0.1 → 0.0.2
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/dist/cjs/elements.cjs.js +1 -1
- package/dist/cjs/{ion-app_32.cjs.entry.js → ion-app_33.cjs.entry.js} +424 -41
- package/dist/cjs/ion-card-subtitle.cjs.entry.js +30 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/apps/pos-app-generic/pos-app-generic.js +20 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/pos-app/pos-app.js +6 -6
- package/dist/collection/components/pos-demo-app/pos-demo-app.js +3 -34
- package/dist/collection/components/pos-login/pos-login.js +7 -7
- package/dist/collection/components/pos-resource/pos-resource.js +6 -3
- package/dist/collection/components/pos-rich-link/pos-rich-link.js +1 -1
- package/dist/collection/components/pos-router/pos-router.js +38 -0
- package/dist/collection/store/session.js +2 -2
- package/dist/collection/test/mockPodOS.js +15 -1
- package/dist/custom-elements/index.d.ts +12 -0
- package/dist/custom-elements/index.js +439 -27
- package/dist/elements/elements.esm.js +1 -1
- package/dist/elements/p-30c47b84.entry.js +1 -0
- package/dist/elements/p-7d1985a3.entry.js +1 -0
- package/dist/esm/elements.js +1 -1
- package/dist/esm/{ion-app_32.entry.js → ion-app_33.entry.js} +421 -39
- package/dist/esm/ion-card-subtitle.entry.js +26 -0
- package/dist/esm/loader.js +1 -1
- package/dist/types/apps/pos-app-generic/pos-app-generic.d.ts +3 -0
- package/dist/types/components/pos-app/pos-app.d.ts +2 -2
- package/dist/types/components/pos-demo-app/pos-demo-app.d.ts +0 -2
- package/dist/types/components/pos-login/pos-login.d.ts +1 -1
- package/dist/types/components/pos-resource/pos-resource.d.ts +1 -1
- package/dist/types/components/pos-rich-link/pos-rich-link.d.ts +1 -1
- package/dist/types/components/pos-router/pos-router.d.ts +8 -0
- package/dist/types/components.d.ts +28 -2
- package/dist/types/store/session.d.ts +3 -3
- package/dist/types/test/mockPodOS.d.ts +1 -0
- package/package.json +13 -4
- package/readme.md +9 -64
- package/dist/elements/p-64fbf059.entry.js +0 -1
|
@@ -293,27 +293,6 @@ CardHeader.style = {
|
|
|
293
293
|
md: cardHeaderMdCss
|
|
294
294
|
};
|
|
295
295
|
|
|
296
|
-
const cardSubtitleIosCss = ":host{display:block;position:relative;color:var(--color)}:host(.ion-color){color:var(--ion-color-base)}:host{--color:var(--ion-color-step-600, #666666);margin-left:0;margin-right:0;margin-top:0;margin-bottom:4px;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;font-size:12px;font-weight:700;letter-spacing:0.4px;text-transform:uppercase}";
|
|
297
|
-
|
|
298
|
-
const cardSubtitleMdCss = ":host{display:block;position:relative;color:var(--color)}:host(.ion-color){color:var(--ion-color-base)}:host{--color:var(--ion-color-step-550, #737373);margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;font-size:14px;font-weight:500}";
|
|
299
|
-
|
|
300
|
-
const CardSubtitle = class {
|
|
301
|
-
constructor(hostRef) {
|
|
302
|
-
index.registerInstance(this, hostRef);
|
|
303
|
-
}
|
|
304
|
-
render() {
|
|
305
|
-
const mode = ionicGlobal.getIonMode(this);
|
|
306
|
-
return (index.h(index.Host, { role: "heading", "aria-level": "3", class: theme.createColorClasses(this.color, {
|
|
307
|
-
'ion-inherit-color': true,
|
|
308
|
-
[mode]: true
|
|
309
|
-
}) }, index.h("slot", null)));
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
CardSubtitle.style = {
|
|
313
|
-
ios: cardSubtitleIosCss,
|
|
314
|
-
md: cardSubtitleMdCss
|
|
315
|
-
};
|
|
316
|
-
|
|
317
296
|
const cardTitleIosCss = ":host{display:block;position:relative;color:var(--color)}:host(.ion-color){color:var(--ion-color-base)}:host{--color:var(--ion-text-color, #000);margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;font-size:28px;font-weight:700;line-height:1.2}";
|
|
318
297
|
|
|
319
298
|
const cardTitleMdCss = ":host{display:block;position:relative;color:var(--color)}:host(.ion-color){color:var(--ion-color-base)}:host{--color:var(--ion-color-step-850, #262626);margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;font-size:20px;font-weight:500;line-height:1.2}";
|
|
@@ -2150,7 +2129,7 @@ const createStore = (defaultState, shouldUpdate) => {
|
|
|
2150
2129
|
|
|
2151
2130
|
const getIdpUrl = () => prompt('Please enter your Identity Provider URL', 'http://localhost:3000');
|
|
2152
2131
|
|
|
2153
|
-
const
|
|
2132
|
+
const store = createStore({
|
|
2154
2133
|
getIdpUrl,
|
|
2155
2134
|
isLoggedIn: false,
|
|
2156
2135
|
webId: '',
|
|
@@ -2169,11 +2148,11 @@ const PosApp = class {
|
|
|
2169
2148
|
this.os = createPodOS();
|
|
2170
2149
|
this.os.handleIncomingRedirect();
|
|
2171
2150
|
this.os.trackSession(sessionInfo => {
|
|
2172
|
-
state.isLoggedIn = sessionInfo.isLoggedIn;
|
|
2173
|
-
state.webId = sessionInfo.webId;
|
|
2151
|
+
store.state.isLoggedIn = sessionInfo.isLoggedIn;
|
|
2152
|
+
store.state.webId = sessionInfo.webId;
|
|
2174
2153
|
});
|
|
2175
2154
|
}
|
|
2176
|
-
async
|
|
2155
|
+
async initializeOs(event) {
|
|
2177
2156
|
event.stopPropagation();
|
|
2178
2157
|
event.detail(this.os);
|
|
2179
2158
|
}
|
|
@@ -2182,16 +2161,21 @@ const PosApp = class {
|
|
|
2182
2161
|
}
|
|
2183
2162
|
};
|
|
2184
2163
|
|
|
2185
|
-
const
|
|
2164
|
+
const PosAppGeneric = class {
|
|
2186
2165
|
constructor(hostRef) {
|
|
2187
2166
|
index.registerInstance(this, hostRef);
|
|
2188
|
-
this.url = 'http://localhost:3000/alice/games/minecraft#it';
|
|
2189
2167
|
}
|
|
2190
|
-
|
|
2191
|
-
|
|
2168
|
+
render() {
|
|
2169
|
+
return (index.h("ion-grid", null, index.h("ion-row", null, index.h("ion-col", { size: "12", "size-sm": true }, index.h("ion-card", null, index.h("ion-card-header", null, index.h("img", { src: "https://dummyimage.com/250/ffffff/000000" }), index.h("ion-card-title", null, index.h("pos-label", null))), index.h("ion-card-content", null, index.h("pos-description", null)))), index.h("ion-col", { size: "12", "size-sm": true }, index.h("pos-literals", null)), index.h("ion-col", { size: "12", "size-sm": true }, index.h("pos-relations", null)))));
|
|
2170
|
+
}
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2173
|
+
const PosDemoApp = class {
|
|
2174
|
+
constructor(hostRef) {
|
|
2175
|
+
index.registerInstance(this, hostRef);
|
|
2192
2176
|
}
|
|
2193
2177
|
render() {
|
|
2194
|
-
return (index.h("pos-app", null, index.h("ion-header", null, index.h("ion-toolbar", null, index.h("ion-title", { slot: "start" }, "pod os"), index.h("pos-login", null))), index.h("ion-content",
|
|
2178
|
+
return (index.h("pos-app", null, index.h("ion-header", null, index.h("ion-toolbar", null, index.h("ion-title", { slot: "start" }, "pod os"), index.h("pos-login", null))), index.h("ion-content", null, index.h("pos-router", null)), index.h("ion-footer", null, index.h("ion-toolbar", null, index.h("ion-title", null, "Footer")))));
|
|
2195
2179
|
}
|
|
2196
2180
|
};
|
|
2197
2181
|
|
|
@@ -2211,7 +2195,7 @@ const PosDescription = class {
|
|
|
2211
2195
|
}
|
|
2212
2196
|
};
|
|
2213
2197
|
|
|
2214
|
-
const PosLabel
|
|
2198
|
+
const PosLabel = class {
|
|
2215
2199
|
constructor(hostRef) {
|
|
2216
2200
|
index.registerInstance(this, hostRef);
|
|
2217
2201
|
this.getResource = index.createEvent(this, "pod-os:resource", 7);
|
|
@@ -2248,23 +2232,23 @@ const PosLiterals = class {
|
|
|
2248
2232
|
const PosLogin = class {
|
|
2249
2233
|
constructor(hostRef) {
|
|
2250
2234
|
index.registerInstance(this, hostRef);
|
|
2251
|
-
this.
|
|
2235
|
+
this.initializeOsEmitter = index.createEvent(this, "pod-os:init", 7);
|
|
2252
2236
|
this.setOs = async (os) => {
|
|
2253
2237
|
this.os = os;
|
|
2254
2238
|
};
|
|
2255
2239
|
}
|
|
2256
2240
|
componentWillLoad() {
|
|
2257
|
-
this.
|
|
2241
|
+
this.initializeOsEmitter.emit(this.setOs);
|
|
2258
2242
|
}
|
|
2259
2243
|
login() {
|
|
2260
|
-
const idp = state.getIdpUrl();
|
|
2244
|
+
const idp = store.state.getIdpUrl();
|
|
2261
2245
|
this.os.login(idp);
|
|
2262
2246
|
}
|
|
2263
2247
|
logout() {
|
|
2264
2248
|
this.os.logout();
|
|
2265
2249
|
}
|
|
2266
2250
|
render() {
|
|
2267
|
-
return (index.h(index.Host, null, state.isLoggedIn ? (index.h("pos-resource", { uri: state.webId }, index.h("pos-label", null))) : (''), !state.isLoggedIn && index.h("ion-button", { onClick: () => this.login() }, "Login"), state.isLoggedIn && index.h("ion-button", { onClick: () => this.logout() }, "Logout")));
|
|
2251
|
+
return (index.h(index.Host, null, store.state.isLoggedIn ? (index.h("pos-resource", { uri: store.state.webId }, index.h("pos-label", null))) : (''), !store.state.isLoggedIn && index.h("ion-button", { onClick: () => this.login() }, "Login"), store.state.isLoggedIn && index.h("ion-button", { onClick: () => this.logout() }, "Logout")));
|
|
2268
2252
|
}
|
|
2269
2253
|
};
|
|
2270
2254
|
|
|
@@ -2289,7 +2273,7 @@ const PosRelations = class {
|
|
|
2289
2273
|
const PosResource = class {
|
|
2290
2274
|
constructor(hostRef) {
|
|
2291
2275
|
index.registerInstance(this, hostRef);
|
|
2292
|
-
this.
|
|
2276
|
+
this.initializeOsEmitter = index.createEvent(this, "pod-os:init", 7);
|
|
2293
2277
|
this.consumers = [];
|
|
2294
2278
|
this.lazy = false;
|
|
2295
2279
|
this.loading = true;
|
|
@@ -2298,7 +2282,8 @@ const PosResource = class {
|
|
|
2298
2282
|
};
|
|
2299
2283
|
}
|
|
2300
2284
|
componentWillLoad() {
|
|
2301
|
-
|
|
2285
|
+
store.onChange('isLoggedIn', () => this.loadResource());
|
|
2286
|
+
this.initializeOsEmitter.emit(this.setOs);
|
|
2302
2287
|
}
|
|
2303
2288
|
async provideResource(event) {
|
|
2304
2289
|
event.stopPropagation();
|
|
@@ -2320,6 +2305,7 @@ const PosResource = class {
|
|
|
2320
2305
|
await this.os.fetch(this.uri);
|
|
2321
2306
|
}
|
|
2322
2307
|
this.resource = this.os.store.get(this.uri);
|
|
2308
|
+
this.error = null;
|
|
2323
2309
|
this.consumers.forEach(consumer => {
|
|
2324
2310
|
consumer.detail(this.resource);
|
|
2325
2311
|
});
|
|
@@ -2346,7 +2332,7 @@ const PosResource = class {
|
|
|
2346
2332
|
}; }
|
|
2347
2333
|
};
|
|
2348
2334
|
|
|
2349
|
-
const
|
|
2335
|
+
const PosRichLink = class {
|
|
2350
2336
|
constructor(hostRef) {
|
|
2351
2337
|
index.registerInstance(this, hostRef);
|
|
2352
2338
|
this.linkEmitter = index.createEvent(this, "pod-os:link", 7);
|
|
@@ -2359,12 +2345,407 @@ const PosLabel = class {
|
|
|
2359
2345
|
}
|
|
2360
2346
|
};
|
|
2361
2347
|
|
|
2348
|
+
const createRouter = (opts) => {
|
|
2349
|
+
var _a;
|
|
2350
|
+
const win = window;
|
|
2351
|
+
const url = new URL(win.location.href);
|
|
2352
|
+
const parseURL = (_a = opts === null || opts === void 0 ? void 0 : opts.parseURL) !== null && _a !== void 0 ? _a : DEFAULT_PARSE_URL;
|
|
2353
|
+
const { state, onChange, dispose } = createStore({
|
|
2354
|
+
url,
|
|
2355
|
+
activePath: parseURL(url)
|
|
2356
|
+
}, (newV, oldV, prop) => {
|
|
2357
|
+
if (prop === 'url') {
|
|
2358
|
+
return newV.href !== oldV.href;
|
|
2359
|
+
}
|
|
2360
|
+
return newV !== oldV;
|
|
2361
|
+
});
|
|
2362
|
+
const push = (href) => {
|
|
2363
|
+
history.pushState(null, null, href);
|
|
2364
|
+
const url = new URL(href, document.baseURI);
|
|
2365
|
+
state.url = url;
|
|
2366
|
+
state.activePath = parseURL(url);
|
|
2367
|
+
};
|
|
2368
|
+
const match = (routes) => {
|
|
2369
|
+
const { activePath } = state;
|
|
2370
|
+
for (let route of routes) {
|
|
2371
|
+
const params = matchPath(activePath, route.path);
|
|
2372
|
+
if (params) {
|
|
2373
|
+
if (route.to != null) {
|
|
2374
|
+
const to = (typeof route.to === 'string')
|
|
2375
|
+
? route.to
|
|
2376
|
+
: route.to(activePath);
|
|
2377
|
+
push(to);
|
|
2378
|
+
return match(routes);
|
|
2379
|
+
}
|
|
2380
|
+
else {
|
|
2381
|
+
return { params, route };
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
return undefined;
|
|
2386
|
+
};
|
|
2387
|
+
const navigationChanged = () => {
|
|
2388
|
+
const url = new URL(win.location.href);
|
|
2389
|
+
state.url = url;
|
|
2390
|
+
state.activePath = parseURL(url);
|
|
2391
|
+
};
|
|
2392
|
+
const Switch = (_, childrenRoutes) => {
|
|
2393
|
+
const result = match(childrenRoutes);
|
|
2394
|
+
if (result) {
|
|
2395
|
+
if (typeof result.route.jsx === 'function') {
|
|
2396
|
+
return result.route.jsx(result.params);
|
|
2397
|
+
}
|
|
2398
|
+
else {
|
|
2399
|
+
return result.route.jsx;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
};
|
|
2403
|
+
const disposeRouter = () => {
|
|
2404
|
+
win.removeEventListener('popstate', navigationChanged);
|
|
2405
|
+
dispose();
|
|
2406
|
+
};
|
|
2407
|
+
const router = {
|
|
2408
|
+
Switch,
|
|
2409
|
+
get url() {
|
|
2410
|
+
return state.url;
|
|
2411
|
+
},
|
|
2412
|
+
get activePath() {
|
|
2413
|
+
return state.activePath;
|
|
2414
|
+
},
|
|
2415
|
+
push,
|
|
2416
|
+
onChange: onChange,
|
|
2417
|
+
dispose: disposeRouter,
|
|
2418
|
+
};
|
|
2419
|
+
// Initial update
|
|
2420
|
+
navigationChanged();
|
|
2421
|
+
// Listen URL changes
|
|
2422
|
+
win.addEventListener('popstate', navigationChanged);
|
|
2423
|
+
return router;
|
|
2424
|
+
};
|
|
2425
|
+
const Route = (props, children) => {
|
|
2426
|
+
var _a;
|
|
2427
|
+
if ('to' in props) {
|
|
2428
|
+
return {
|
|
2429
|
+
path: props.path,
|
|
2430
|
+
to: props.to,
|
|
2431
|
+
};
|
|
2432
|
+
}
|
|
2433
|
+
return {
|
|
2434
|
+
path: props.path,
|
|
2435
|
+
id: props.id,
|
|
2436
|
+
jsx: (_a = props.render) !== null && _a !== void 0 ? _a : children,
|
|
2437
|
+
};
|
|
2438
|
+
};
|
|
2439
|
+
const matchPath = (pathname, path) => {
|
|
2440
|
+
if (typeof path === 'string') {
|
|
2441
|
+
if (path === pathname) {
|
|
2442
|
+
return {};
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
else if (typeof path === 'function') {
|
|
2446
|
+
const params = path(pathname);
|
|
2447
|
+
if (params) {
|
|
2448
|
+
return params === true
|
|
2449
|
+
? {}
|
|
2450
|
+
: { ...params };
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
else {
|
|
2454
|
+
const results = path.exec(pathname);
|
|
2455
|
+
if (results) {
|
|
2456
|
+
path.lastIndex = 0;
|
|
2457
|
+
return { ...results };
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
return undefined;
|
|
2461
|
+
};
|
|
2462
|
+
const DEFAULT_PARSE_URL = (url) => {
|
|
2463
|
+
return url.pathname.toLowerCase();
|
|
2464
|
+
};
|
|
2465
|
+
|
|
2466
|
+
/**
|
|
2467
|
+
* TS adaption of https://github.com/pillarjs/path-to-regexp/blob/master/index.js
|
|
2468
|
+
*/
|
|
2469
|
+
/**
|
|
2470
|
+
* Default configs.
|
|
2471
|
+
*/
|
|
2472
|
+
const DEFAULT_DELIMITER = '/';
|
|
2473
|
+
const DEFAULT_DELIMITERS = './';
|
|
2474
|
+
/**
|
|
2475
|
+
* The main path matching regexp utility.
|
|
2476
|
+
*/
|
|
2477
|
+
const PATH_REGEXP = new RegExp([
|
|
2478
|
+
// Match escaped characters that would otherwise appear in future matches.
|
|
2479
|
+
// This allows the user to escape special characters that won't transform.
|
|
2480
|
+
'(\\\\.)',
|
|
2481
|
+
// Match Express-style parameters and un-named parameters with a prefix
|
|
2482
|
+
// and optional suffixes. Matches appear as:
|
|
2483
|
+
//
|
|
2484
|
+
// "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?"]
|
|
2485
|
+
// "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined]
|
|
2486
|
+
'(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?'
|
|
2487
|
+
].join('|'), 'g');
|
|
2488
|
+
/**
|
|
2489
|
+
* Parse a string for the raw tokens.
|
|
2490
|
+
*/
|
|
2491
|
+
const parse = (str, options) => {
|
|
2492
|
+
var tokens = [];
|
|
2493
|
+
var key = 0;
|
|
2494
|
+
var index = 0;
|
|
2495
|
+
var path = '';
|
|
2496
|
+
var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER;
|
|
2497
|
+
var delimiters = (options && options.delimiters) || DEFAULT_DELIMITERS;
|
|
2498
|
+
var pathEscaped = false;
|
|
2499
|
+
var res;
|
|
2500
|
+
while ((res = PATH_REGEXP.exec(str)) !== null) {
|
|
2501
|
+
var m = res[0];
|
|
2502
|
+
var escaped = res[1];
|
|
2503
|
+
var offset = res.index;
|
|
2504
|
+
path += str.slice(index, offset);
|
|
2505
|
+
index = offset + m.length;
|
|
2506
|
+
// Ignore already escaped sequences.
|
|
2507
|
+
if (escaped) {
|
|
2508
|
+
path += escaped[1];
|
|
2509
|
+
pathEscaped = true;
|
|
2510
|
+
continue;
|
|
2511
|
+
}
|
|
2512
|
+
var prev = '';
|
|
2513
|
+
var next = str[index];
|
|
2514
|
+
var name = res[2];
|
|
2515
|
+
var capture = res[3];
|
|
2516
|
+
var group = res[4];
|
|
2517
|
+
var modifier = res[5];
|
|
2518
|
+
if (!pathEscaped && path.length) {
|
|
2519
|
+
var k = path.length - 1;
|
|
2520
|
+
if (delimiters.indexOf(path[k]) > -1) {
|
|
2521
|
+
prev = path[k];
|
|
2522
|
+
path = path.slice(0, k);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
// Push the current path onto the tokens.
|
|
2526
|
+
if (path) {
|
|
2527
|
+
tokens.push(path);
|
|
2528
|
+
path = '';
|
|
2529
|
+
pathEscaped = false;
|
|
2530
|
+
}
|
|
2531
|
+
var partial = prev !== '' && next !== undefined && next !== prev;
|
|
2532
|
+
var repeat = modifier === '+' || modifier === '*';
|
|
2533
|
+
var optional = modifier === '?' || modifier === '*';
|
|
2534
|
+
var delimiter = prev || defaultDelimiter;
|
|
2535
|
+
var pattern = capture || group;
|
|
2536
|
+
tokens.push({
|
|
2537
|
+
name: name || key++,
|
|
2538
|
+
prefix: prev,
|
|
2539
|
+
delimiter: delimiter,
|
|
2540
|
+
optional: optional,
|
|
2541
|
+
repeat: repeat,
|
|
2542
|
+
partial: partial,
|
|
2543
|
+
pattern: pattern ? escapeGroup(pattern) : '[^' + escapeString(delimiter) + ']+?'
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
// Push any remaining characters.
|
|
2547
|
+
if (path || index < str.length) {
|
|
2548
|
+
tokens.push(path + str.substr(index));
|
|
2549
|
+
}
|
|
2550
|
+
return tokens;
|
|
2551
|
+
};
|
|
2552
|
+
/**
|
|
2553
|
+
* Escape a regular expression string.
|
|
2554
|
+
*/
|
|
2555
|
+
const escapeString = (str) => {
|
|
2556
|
+
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1');
|
|
2557
|
+
};
|
|
2558
|
+
/**
|
|
2559
|
+
* Escape the capturing group by escaping special characters and meaning.
|
|
2560
|
+
*/
|
|
2561
|
+
const escapeGroup = (group) => {
|
|
2562
|
+
return group.replace(/([=!:$/()])/g, '\\$1');
|
|
2563
|
+
};
|
|
2564
|
+
/**
|
|
2565
|
+
* Get the flags for a regexp from the options.
|
|
2566
|
+
*/
|
|
2567
|
+
const flags = (options) => {
|
|
2568
|
+
return options && options.sensitive ? '' : 'i';
|
|
2569
|
+
};
|
|
2570
|
+
/**
|
|
2571
|
+
* Pull out keys from a regexp.
|
|
2572
|
+
*/
|
|
2573
|
+
const regexpToRegexp = (path, keys) => {
|
|
2574
|
+
if (!keys)
|
|
2575
|
+
return path;
|
|
2576
|
+
// Use a negative lookahead to match only capturing groups.
|
|
2577
|
+
var groups = path.source.match(/\((?!\?)/g);
|
|
2578
|
+
if (groups) {
|
|
2579
|
+
for (var i = 0; i < groups.length; i++) {
|
|
2580
|
+
keys.push({
|
|
2581
|
+
name: i,
|
|
2582
|
+
prefix: null,
|
|
2583
|
+
delimiter: null,
|
|
2584
|
+
optional: false,
|
|
2585
|
+
repeat: false,
|
|
2586
|
+
partial: false,
|
|
2587
|
+
pattern: null
|
|
2588
|
+
});
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
return path;
|
|
2592
|
+
};
|
|
2593
|
+
/**
|
|
2594
|
+
* Transform an array into a regexp.
|
|
2595
|
+
*/
|
|
2596
|
+
const arrayToRegexp = (path, keys, options) => {
|
|
2597
|
+
var parts = [];
|
|
2598
|
+
for (var i = 0; i < path.length; i++) {
|
|
2599
|
+
parts.push(pathToRegexp(path[i], keys, options).source);
|
|
2600
|
+
}
|
|
2601
|
+
return new RegExp('(?:' + parts.join('|') + ')', flags(options));
|
|
2602
|
+
};
|
|
2603
|
+
/**
|
|
2604
|
+
* Create a path regexp from string input.
|
|
2605
|
+
*/
|
|
2606
|
+
const stringToRegexp = (path, keys, options) => {
|
|
2607
|
+
return tokensToRegExp(parse(path, options), keys, options);
|
|
2608
|
+
};
|
|
2609
|
+
/**
|
|
2610
|
+
* Expose a function for taking tokens and returning a RegExp.
|
|
2611
|
+
*/
|
|
2612
|
+
const tokensToRegExp = (tokens, keys, options) => {
|
|
2613
|
+
options = options || {};
|
|
2614
|
+
var strict = options.strict;
|
|
2615
|
+
var end = options.end !== false;
|
|
2616
|
+
var delimiter = escapeString(options.delimiter || DEFAULT_DELIMITER);
|
|
2617
|
+
var delimiters = options.delimiters || DEFAULT_DELIMITERS;
|
|
2618
|
+
var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|');
|
|
2619
|
+
var route = '';
|
|
2620
|
+
var isEndDelimited = false;
|
|
2621
|
+
// Iterate over the tokens and create our regexp string.
|
|
2622
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
2623
|
+
var token = tokens[i];
|
|
2624
|
+
if (typeof token === 'string') {
|
|
2625
|
+
route += escapeString(token);
|
|
2626
|
+
isEndDelimited = i === tokens.length - 1 && delimiters.indexOf(token[token.length - 1]) > -1;
|
|
2627
|
+
}
|
|
2628
|
+
else {
|
|
2629
|
+
var prefix = escapeString(token.prefix || '');
|
|
2630
|
+
var capture = token.repeat
|
|
2631
|
+
? '(?:' + token.pattern + ')(?:' + prefix + '(?:' + token.pattern + '))*'
|
|
2632
|
+
: token.pattern;
|
|
2633
|
+
if (keys)
|
|
2634
|
+
keys.push(token);
|
|
2635
|
+
if (token.optional) {
|
|
2636
|
+
if (token.partial) {
|
|
2637
|
+
route += prefix + '(' + capture + ')?';
|
|
2638
|
+
}
|
|
2639
|
+
else {
|
|
2640
|
+
route += '(?:' + prefix + '(' + capture + '))?';
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
else {
|
|
2644
|
+
route += prefix + '(' + capture + ')';
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
if (end) {
|
|
2649
|
+
if (!strict)
|
|
2650
|
+
route += '(?:' + delimiter + ')?';
|
|
2651
|
+
route += endsWith === '$' ? '$' : '(?=' + endsWith + ')';
|
|
2652
|
+
}
|
|
2653
|
+
else {
|
|
2654
|
+
if (!strict)
|
|
2655
|
+
route += '(?:' + delimiter + '(?=' + endsWith + '))?';
|
|
2656
|
+
if (!isEndDelimited)
|
|
2657
|
+
route += '(?=' + delimiter + '|' + endsWith + ')';
|
|
2658
|
+
}
|
|
2659
|
+
return new RegExp('^' + route, flags(options));
|
|
2660
|
+
};
|
|
2661
|
+
/**
|
|
2662
|
+
* Normalize the given path string, returning a regular expression.
|
|
2663
|
+
*
|
|
2664
|
+
* An empty array can be passed in for the keys, which will hold the
|
|
2665
|
+
* placeholder key descriptions. For example, using `/user/:id`, `keys` will
|
|
2666
|
+
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
|
|
2667
|
+
*/
|
|
2668
|
+
const pathToRegexp = (path, keys, options) => {
|
|
2669
|
+
if (path instanceof RegExp) {
|
|
2670
|
+
return regexpToRegexp(path, keys);
|
|
2671
|
+
}
|
|
2672
|
+
if (Array.isArray(path)) {
|
|
2673
|
+
return arrayToRegexp(path, keys, options);
|
|
2674
|
+
}
|
|
2675
|
+
return stringToRegexp(path, keys, options);
|
|
2676
|
+
};
|
|
2677
|
+
|
|
2678
|
+
let cacheCount = 0;
|
|
2679
|
+
const patternCache = {};
|
|
2680
|
+
const cacheLimit = 10000;
|
|
2681
|
+
// Memoized function for creating the path match regex
|
|
2682
|
+
const compilePath = (pattern, options) => {
|
|
2683
|
+
const cacheKey = `${options.end}${options.strict}`;
|
|
2684
|
+
const cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
|
|
2685
|
+
const cachePattern = JSON.stringify(pattern);
|
|
2686
|
+
if (cache[cachePattern]) {
|
|
2687
|
+
return cache[cachePattern];
|
|
2688
|
+
}
|
|
2689
|
+
const keys = [];
|
|
2690
|
+
const re = pathToRegexp(pattern, keys, options);
|
|
2691
|
+
const compiledPattern = { re, keys };
|
|
2692
|
+
if (cacheCount < cacheLimit) {
|
|
2693
|
+
cache[cachePattern] = compiledPattern;
|
|
2694
|
+
cacheCount += 1;
|
|
2695
|
+
}
|
|
2696
|
+
return compiledPattern;
|
|
2697
|
+
};
|
|
2698
|
+
const match = (pathname, options = {}) => {
|
|
2699
|
+
const { exact = false, strict = false } = options;
|
|
2700
|
+
const { re, keys } = compilePath(pathname, { end: exact, strict });
|
|
2701
|
+
return (path) => {
|
|
2702
|
+
const match = re.exec(path);
|
|
2703
|
+
if (!match) {
|
|
2704
|
+
return undefined;
|
|
2705
|
+
}
|
|
2706
|
+
const [url, ...values] = match;
|
|
2707
|
+
const isExact = path === url;
|
|
2708
|
+
if (exact && !isExact) {
|
|
2709
|
+
return undefined;
|
|
2710
|
+
}
|
|
2711
|
+
return keys.reduce((memo, key, index) => {
|
|
2712
|
+
memo[key.name] = values[index];
|
|
2713
|
+
return memo;
|
|
2714
|
+
}, {});
|
|
2715
|
+
};
|
|
2716
|
+
};
|
|
2717
|
+
|
|
2718
|
+
const Router = createRouter();
|
|
2719
|
+
const PosRouter = class {
|
|
2720
|
+
constructor(hostRef) {
|
|
2721
|
+
index.registerInstance(this, hostRef);
|
|
2722
|
+
}
|
|
2723
|
+
linkClicked(e) {
|
|
2724
|
+
this.navigate(e.detail);
|
|
2725
|
+
}
|
|
2726
|
+
componentWillLoad() {
|
|
2727
|
+
this.updateUri();
|
|
2728
|
+
Router.onChange('url', () => {
|
|
2729
|
+
this.updateUri();
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
navigate(uri) {
|
|
2733
|
+
Router.push('?uri=' + encodeURIComponent(uri));
|
|
2734
|
+
}
|
|
2735
|
+
updateUri() {
|
|
2736
|
+
this.uri = new URLSearchParams(window.location.search).get('uri') || window.location.href;
|
|
2737
|
+
}
|
|
2738
|
+
render() {
|
|
2739
|
+
console.log('render router', this.uri);
|
|
2740
|
+
return (index.h(Router.Switch, null, index.h(Route, { path: match('', { exact: false }) }, index.h("pos-resource", { key: this.uri, uri: this.uri }, index.h("pos-app-generic", null)))));
|
|
2741
|
+
}
|
|
2742
|
+
};
|
|
2743
|
+
|
|
2362
2744
|
exports.ion_app = App;
|
|
2363
2745
|
exports.ion_button = Button;
|
|
2364
2746
|
exports.ion_card = Card;
|
|
2365
2747
|
exports.ion_card_content = CardContent;
|
|
2366
2748
|
exports.ion_card_header = CardHeader;
|
|
2367
|
-
exports.ion_card_subtitle = CardSubtitle;
|
|
2368
2749
|
exports.ion_card_title = CardTitle;
|
|
2369
2750
|
exports.ion_col = Col;
|
|
2370
2751
|
exports.ion_content = Content;
|
|
@@ -2383,11 +2764,13 @@ exports.ion_row = Row;
|
|
|
2383
2764
|
exports.ion_title = ToolbarTitle;
|
|
2384
2765
|
exports.ion_toolbar = Toolbar;
|
|
2385
2766
|
exports.pos_app = PosApp;
|
|
2767
|
+
exports.pos_app_generic = PosAppGeneric;
|
|
2386
2768
|
exports.pos_demo_app = PosDemoApp;
|
|
2387
2769
|
exports.pos_description = PosDescription;
|
|
2388
|
-
exports.pos_label = PosLabel
|
|
2770
|
+
exports.pos_label = PosLabel;
|
|
2389
2771
|
exports.pos_literals = PosLiterals;
|
|
2390
2772
|
exports.pos_login = PosLogin;
|
|
2391
2773
|
exports.pos_relations = PosRelations;
|
|
2392
2774
|
exports.pos_resource = PosResource;
|
|
2393
|
-
exports.pos_rich_link =
|
|
2775
|
+
exports.pos_rich_link = PosRichLink;
|
|
2776
|
+
exports.pos_router = PosRouter;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-6bf2cd3d.js');
|
|
6
|
+
const ionicGlobal = require('./ionic-global-167e590d.js');
|
|
7
|
+
const theme = require('./theme-98ccfc24.js');
|
|
8
|
+
|
|
9
|
+
const cardSubtitleIosCss = ":host{display:block;position:relative;color:var(--color)}:host(.ion-color){color:var(--ion-color-base)}:host{--color:var(--ion-color-step-600, #666666);margin-left:0;margin-right:0;margin-top:0;margin-bottom:4px;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;font-size:12px;font-weight:700;letter-spacing:0.4px;text-transform:uppercase}";
|
|
10
|
+
|
|
11
|
+
const cardSubtitleMdCss = ":host{display:block;position:relative;color:var(--color)}:host(.ion-color){color:var(--ion-color-base)}:host{--color:var(--ion-color-step-550, #737373);margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;font-size:14px;font-weight:500}";
|
|
12
|
+
|
|
13
|
+
const CardSubtitle = class {
|
|
14
|
+
constructor(hostRef) {
|
|
15
|
+
index.registerInstance(this, hostRef);
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
const mode = ionicGlobal.getIonMode(this);
|
|
19
|
+
return (index.h(index.Host, { role: "heading", "aria-level": "3", class: theme.createColorClasses(this.color, {
|
|
20
|
+
'ion-inherit-color': true,
|
|
21
|
+
[mode]: true
|
|
22
|
+
}) }, index.h("slot", null)));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
CardSubtitle.style = {
|
|
26
|
+
ios: cardSubtitleIosCss,
|
|
27
|
+
md: cardSubtitleMdCss
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.ion_card_subtitle = CardSubtitle;
|