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