Skip to content

Commit 0ebc251

Browse files
committed
feat: rename pos-pdf and pos-app-pdf-viewer to reflect their generic handling of documents, route other document types to pos-app-document-viewer
1 parent 23d808d commit 0ebc251

File tree

11 files changed

+222
-107
lines changed

11 files changed

+222
-107
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import { newSpecPage } from '@stencil/core/testing';
2-
import { PosAppPdfViewer } from './pos-app-pdf-viewer';
2+
import { PosAppDocumentViewer } from './pos-app-document-viewer';
33

4-
describe('pos-app-pdf-viewer', () => {
4+
describe('pos-app-document-viewer', () => {
55
it('is empty initially', async () => {
66
const page = await newSpecPage({
7-
components: [PosAppPdfViewer],
8-
html: `<pos-app-pdf-viewer />`,
7+
components: [PosAppDocumentViewer],
8+
html: `<pos-app-document-viewer />`,
99
});
1010
expect(page.root).toEqualHtml(`
11-
<pos-app-pdf-viewer>
11+
<pos-app-document-viewer>
1212
<mock:shadow-root></mock:shadow-root>
13-
</pos-app-pdf-viewer>
13+
</pos-app-document-viewer>
1414
`);
1515
});
1616

1717
it('renders a download link after resource is received', async () => {
1818
const page = await newSpecPage({
19-
components: [PosAppPdfViewer],
20-
html: `<pos-app-pdf-viewer />`,
19+
components: [PosAppDocumentViewer],
20+
html: `<pos-app-document-viewer />`,
2121
supportsShadowDom: false,
2222
});
2323
await page.rootInstance.receiveResource({
2424
uri: 'https://resource.test/document.pdf',
2525
});
2626
await page.waitForChanges();
27-
const pdf = page.root.querySelector('pos-pdf');
28-
expect(pdf).toEqualHtml('<pos-pdf src="https://resource.test/document.pdf" />');
27+
const document = page.root.querySelector('pos-document');
28+
expect(document).toEqualHtml('<pos-document src="https://resource.test/document.pdf" />');
2929
});
3030
});

elements/src/apps/pos-app-pdf-viewer/pos-app-pdf-viewer.tsx renamed to elements/src/apps/pos-app-document-viewer/pos-app-document-viewer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { Component, Event, EventEmitter, h, State } from '@stencil/core';
33
import { ResourceAware, subscribeResource } from '../../components/events/ResourceAware';
44

55
@Component({
6-
tag: 'pos-app-pdf-viewer',
6+
tag: 'pos-app-document-viewer',
77
shadow: true,
88
})
9-
export class PosAppPdfViewer implements ResourceAware {
9+
export class PosAppDocumentViewer implements ResourceAware {
1010
@State() resource: Thing;
1111

1212
@Event({ eventName: 'pod-os:resource' }) subscribeResource: EventEmitter;
@@ -28,7 +28,7 @@ export class PosAppPdfViewer implements ResourceAware {
2828
<ion-grid>
2929
<ion-row>
3030
<ion-col size="12" size-sm>
31-
<pos-pdf src={this.resource.uri} />
31+
<pos-document src={this.resource.uri} />
3232
</ion-col>
3333
<ion-col size="12" size-sm>
3434
<ion-card>

elements/src/components.d.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ export namespace Components {
1010
}
1111
interface PosAppBrowser {
1212
}
13+
interface PosAppDocumentViewer {
14+
}
1315
interface PosAppGeneric {
1416
}
1517
interface PosAppImageViewer {
1618
}
17-
interface PosAppPdfViewer {
18-
}
1919
interface PosAppRdfDocument {
2020
}
2121
interface PosDescription {
2222
}
23+
interface PosDocument {
24+
"alt": string;
25+
"src": string;
26+
}
2327
interface PosImage {
2428
"alt": string;
2529
"src": string;
@@ -33,10 +37,6 @@ export namespace Components {
3337
interface PosNavigationBar {
3438
"uri": string;
3539
}
36-
interface PosPdf {
37-
"alt": string;
38-
"src": string;
39-
}
4040
interface PosPicture {
4141
}
4242
interface PosRelations {
@@ -60,18 +60,22 @@ export namespace Components {
6060
interface PosTypeRouter {
6161
}
6262
}
63-
export interface PosAppImageViewerCustomEvent<T> extends CustomEvent<T> {
63+
export interface PosAppDocumentViewerCustomEvent<T> extends CustomEvent<T> {
6464
detail: T;
65-
target: HTMLPosAppImageViewerElement;
65+
target: HTMLPosAppDocumentViewerElement;
6666
}
67-
export interface PosAppPdfViewerCustomEvent<T> extends CustomEvent<T> {
67+
export interface PosAppImageViewerCustomEvent<T> extends CustomEvent<T> {
6868
detail: T;
69-
target: HTMLPosAppPdfViewerElement;
69+
target: HTMLPosAppImageViewerElement;
7070
}
7171
export interface PosDescriptionCustomEvent<T> extends CustomEvent<T> {
7272
detail: T;
7373
target: HTMLPosDescriptionElement;
7474
}
75+
export interface PosDocumentCustomEvent<T> extends CustomEvent<T> {
76+
detail: T;
77+
target: HTMLPosDocumentElement;
78+
}
7579
export interface PosImageCustomEvent<T> extends CustomEvent<T> {
7680
detail: T;
7781
target: HTMLPosImageElement;
@@ -92,10 +96,6 @@ export interface PosNavigationBarCustomEvent<T> extends CustomEvent<T> {
9296
detail: T;
9397
target: HTMLPosNavigationBarElement;
9498
}
95-
export interface PosPdfCustomEvent<T> extends CustomEvent<T> {
96-
detail: T;
97-
target: HTMLPosPdfElement;
98-
}
9999
export interface PosPictureCustomEvent<T> extends CustomEvent<T> {
100100
detail: T;
101101
target: HTMLPosPictureElement;
@@ -141,6 +141,12 @@ declare global {
141141
prototype: HTMLPosAppBrowserElement;
142142
new (): HTMLPosAppBrowserElement;
143143
};
144+
interface HTMLPosAppDocumentViewerElement extends Components.PosAppDocumentViewer, HTMLStencilElement {
145+
}
146+
var HTMLPosAppDocumentViewerElement: {
147+
prototype: HTMLPosAppDocumentViewerElement;
148+
new (): HTMLPosAppDocumentViewerElement;
149+
};
144150
interface HTMLPosAppGenericElement extends Components.PosAppGeneric, HTMLStencilElement {
145151
}
146152
var HTMLPosAppGenericElement: {
@@ -153,12 +159,6 @@ declare global {
153159
prototype: HTMLPosAppImageViewerElement;
154160
new (): HTMLPosAppImageViewerElement;
155161
};
156-
interface HTMLPosAppPdfViewerElement extends Components.PosAppPdfViewer, HTMLStencilElement {
157-
}
158-
var HTMLPosAppPdfViewerElement: {
159-
prototype: HTMLPosAppPdfViewerElement;
160-
new (): HTMLPosAppPdfViewerElement;
161-
};
162162
interface HTMLPosAppRdfDocumentElement extends Components.PosAppRdfDocument, HTMLStencilElement {
163163
}
164164
var HTMLPosAppRdfDocumentElement: {
@@ -171,6 +171,12 @@ declare global {
171171
prototype: HTMLPosDescriptionElement;
172172
new (): HTMLPosDescriptionElement;
173173
};
174+
interface HTMLPosDocumentElement extends Components.PosDocument, HTMLStencilElement {
175+
}
176+
var HTMLPosDocumentElement: {
177+
prototype: HTMLPosDocumentElement;
178+
new (): HTMLPosDocumentElement;
179+
};
174180
interface HTMLPosImageElement extends Components.PosImage, HTMLStencilElement {
175181
}
176182
var HTMLPosImageElement: {
@@ -201,12 +207,6 @@ declare global {
201207
prototype: HTMLPosNavigationBarElement;
202208
new (): HTMLPosNavigationBarElement;
203209
};
204-
interface HTMLPosPdfElement extends Components.PosPdf, HTMLStencilElement {
205-
}
206-
var HTMLPosPdfElement: {
207-
prototype: HTMLPosPdfElement;
208-
new (): HTMLPosPdfElement;
209-
};
210210
interface HTMLPosPictureElement extends Components.PosPicture, HTMLStencilElement {
211211
}
212212
var HTMLPosPictureElement: {
@@ -264,17 +264,17 @@ declare global {
264264
interface HTMLElementTagNameMap {
265265
"pos-app": HTMLPosAppElement;
266266
"pos-app-browser": HTMLPosAppBrowserElement;
267+
"pos-app-document-viewer": HTMLPosAppDocumentViewerElement;
267268
"pos-app-generic": HTMLPosAppGenericElement;
268269
"pos-app-image-viewer": HTMLPosAppImageViewerElement;
269-
"pos-app-pdf-viewer": HTMLPosAppPdfViewerElement;
270270
"pos-app-rdf-document": HTMLPosAppRdfDocumentElement;
271271
"pos-description": HTMLPosDescriptionElement;
272+
"pos-document": HTMLPosDocumentElement;
272273
"pos-image": HTMLPosImageElement;
273274
"pos-label": HTMLPosLabelElement;
274275
"pos-literals": HTMLPosLiteralsElement;
275276
"pos-login": HTMLPosLoginElement;
276277
"pos-navigation-bar": HTMLPosNavigationBarElement;
277-
"pos-pdf": HTMLPosPdfElement;
278278
"pos-picture": HTMLPosPictureElement;
279279
"pos-relations": HTMLPosRelationsElement;
280280
"pos-resource": HTMLPosResourceElement;
@@ -291,19 +291,24 @@ declare namespace LocalJSX {
291291
}
292292
interface PosAppBrowser {
293293
}
294+
interface PosAppDocumentViewer {
295+
"onPod-os:resource"?: (event: PosAppDocumentViewerCustomEvent<any>) => void;
296+
}
294297
interface PosAppGeneric {
295298
}
296299
interface PosAppImageViewer {
297300
"onPod-os:resource"?: (event: PosAppImageViewerCustomEvent<any>) => void;
298301
}
299-
interface PosAppPdfViewer {
300-
"onPod-os:resource"?: (event: PosAppPdfViewerCustomEvent<any>) => void;
301-
}
302302
interface PosAppRdfDocument {
303303
}
304304
interface PosDescription {
305305
"onPod-os:resource"?: (event: PosDescriptionCustomEvent<any>) => void;
306306
}
307+
interface PosDocument {
308+
"alt"?: string;
309+
"onPod-os:init"?: (event: PosDocumentCustomEvent<any>) => void;
310+
"src"?: string;
311+
}
307312
interface PosImage {
308313
"alt"?: string;
309314
"onPod-os:init"?: (event: PosImageCustomEvent<any>) => void;
@@ -322,11 +327,6 @@ declare namespace LocalJSX {
322327
"onPod-os:link"?: (event: PosNavigationBarCustomEvent<any>) => void;
323328
"uri"?: string;
324329
}
325-
interface PosPdf {
326-
"alt"?: string;
327-
"onPod-os:init"?: (event: PosPdfCustomEvent<any>) => void;
328-
"src"?: string;
329-
}
330330
interface PosPicture {
331331
"onPod-os:resource"?: (event: PosPictureCustomEvent<any>) => void;
332332
}
@@ -359,17 +359,17 @@ declare namespace LocalJSX {
359359
interface IntrinsicElements {
360360
"pos-app": PosApp;
361361
"pos-app-browser": PosAppBrowser;
362+
"pos-app-document-viewer": PosAppDocumentViewer;
362363
"pos-app-generic": PosAppGeneric;
363364
"pos-app-image-viewer": PosAppImageViewer;
364-
"pos-app-pdf-viewer": PosAppPdfViewer;
365365
"pos-app-rdf-document": PosAppRdfDocument;
366366
"pos-description": PosDescription;
367+
"pos-document": PosDocument;
367368
"pos-image": PosImage;
368369
"pos-label": PosLabel;
369370
"pos-literals": PosLiterals;
370371
"pos-login": PosLogin;
371372
"pos-navigation-bar": PosNavigationBar;
372-
"pos-pdf": PosPdf;
373373
"pos-picture": PosPicture;
374374
"pos-relations": PosRelations;
375375
"pos-resource": PosResource;
@@ -387,17 +387,17 @@ declare module "@stencil/core" {
387387
interface IntrinsicElements {
388388
"pos-app": LocalJSX.PosApp & JSXBase.HTMLAttributes<HTMLPosAppElement>;
389389
"pos-app-browser": LocalJSX.PosAppBrowser & JSXBase.HTMLAttributes<HTMLPosAppBrowserElement>;
390+
"pos-app-document-viewer": LocalJSX.PosAppDocumentViewer & JSXBase.HTMLAttributes<HTMLPosAppDocumentViewerElement>;
390391
"pos-app-generic": LocalJSX.PosAppGeneric & JSXBase.HTMLAttributes<HTMLPosAppGenericElement>;
391392
"pos-app-image-viewer": LocalJSX.PosAppImageViewer & JSXBase.HTMLAttributes<HTMLPosAppImageViewerElement>;
392-
"pos-app-pdf-viewer": LocalJSX.PosAppPdfViewer & JSXBase.HTMLAttributes<HTMLPosAppPdfViewerElement>;
393393
"pos-app-rdf-document": LocalJSX.PosAppRdfDocument & JSXBase.HTMLAttributes<HTMLPosAppRdfDocumentElement>;
394394
"pos-description": LocalJSX.PosDescription & JSXBase.HTMLAttributes<HTMLPosDescriptionElement>;
395+
"pos-document": LocalJSX.PosDocument & JSXBase.HTMLAttributes<HTMLPosDocumentElement>;
395396
"pos-image": LocalJSX.PosImage & JSXBase.HTMLAttributes<HTMLPosImageElement>;
396397
"pos-label": LocalJSX.PosLabel & JSXBase.HTMLAttributes<HTMLPosLabelElement>;
397398
"pos-literals": LocalJSX.PosLiterals & JSXBase.HTMLAttributes<HTMLPosLiteralsElement>;
398399
"pos-login": LocalJSX.PosLogin & JSXBase.HTMLAttributes<HTMLPosLoginElement>;
399400
"pos-navigation-bar": LocalJSX.PosNavigationBar & JSXBase.HTMLAttributes<HTMLPosNavigationBarElement>;
400-
"pos-pdf": LocalJSX.PosPdf & JSXBase.HTMLAttributes<HTMLPosPdfElement>;
401401
"pos-picture": LocalJSX.PosPicture & JSXBase.HTMLAttributes<HTMLPosPictureElement>;
402402
"pos-relations": LocalJSX.PosRelations & JSXBase.HTMLAttributes<HTMLPosRelationsElement>;
403403
"pos-resource": LocalJSX.PosResource & JSXBase.HTMLAttributes<HTMLPosResourceElement>;
File renamed without changes.

0 commit comments

Comments
 (0)