@nuralyui/document 0.0.1
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/demo/document-demo.d.ts +12 -0
- package/demo/document-demo.d.ts.map +1 -0
- package/demo/document-demo.js +40 -0
- package/demo/document-demo.js.map +1 -0
- package/document.component.d.ts +17 -0
- package/document.component.d.ts.map +1 -0
- package/document.component.js +226 -0
- package/document.component.js.map +1 -0
- package/document.style.d.ts +3 -0
- package/document.style.d.ts.map +1 -0
- package/document.style.js +137 -0
- package/document.style.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -0
- package/index.js +2 -0
- package/index.js.map +1 -0
- package/package.json +12 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import '../document.component.js';
|
|
8
|
+
export declare class HyDatePickerDemoElement extends LitElement {
|
|
9
|
+
selectedLanguage: string;
|
|
10
|
+
render(): import("lit").TemplateResult<1>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=document-demo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-demo.d.ts","sourceRoot":"","sources":["../../../../src/components/document/demo/document-demo.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAEvC,OAAO,0BAA0B,CAAC;AAElC,qBACa,uBAAwB,SAAQ,UAAU;IAErD,gBAAgB,SAAQ;IAEf,MAAM;CAYhB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
import { LitElement, html } from 'lit';
|
|
13
|
+
import { customElement, state } from 'lit/decorators.js';
|
|
14
|
+
import '../document.component.js';
|
|
15
|
+
let HyDatePickerDemoElement = class HyDatePickerDemoElement extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.selectedLanguage = 'en';
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
return html `
|
|
22
|
+
<hy-pdf-viewer
|
|
23
|
+
previewable="true"
|
|
24
|
+
id="url-viewer"
|
|
25
|
+
src="http://localhost:7004/api/v1/storage/preview/my-folder%2FRNE%20Public.pdf"
|
|
26
|
+
width="100%"
|
|
27
|
+
height="500px"
|
|
28
|
+
previewable
|
|
29
|
+
></hy-pdf-viewer>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__decorate([
|
|
34
|
+
state()
|
|
35
|
+
], HyDatePickerDemoElement.prototype, "selectedLanguage", void 0);
|
|
36
|
+
HyDatePickerDemoElement = __decorate([
|
|
37
|
+
customElement('hy-document-demo')
|
|
38
|
+
], HyDatePickerDemoElement);
|
|
39
|
+
export { HyDatePickerDemoElement };
|
|
40
|
+
//# sourceMappingURL=document-demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-demo.js","sourceRoot":"","sources":["../../../../src/components/document/demo/document-demo.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,0BAA0B,CAAC;AAGlC,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,UAAU;IAAvD;;QAEE,qBAAgB,GAAG,IAAI,CAAC;IAc1B,CAAC;IAZU,MAAM;QACb,OAAO,IAAI,CAAA;;;;;;;;;KASV,CAAC;IACJ,CAAC;CACF,CAAA;AAdC;IADC,KAAK,EAAE;iEACgB;AAFb,uBAAuB;IADnC,aAAa,CAAC,kBAAkB,CAAC;GACrB,uBAAuB,CAgBnC;SAhBY,uBAAuB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { LitElement, html } from 'lit';\nimport { customElement, state } from 'lit/decorators.js';\nimport '../document.component.js';\n\n@customElement('hy-document-demo')\nexport class HyDatePickerDemoElement extends LitElement {\n @state()\n selectedLanguage = 'en';\n\n override render() {\n return html`\n <hy-pdf-viewer \n previewable=\"true\"\n id=\"url-viewer\"\n src=\"http://localhost:7004/api/v1/storage/preview/my-folder%2FRNE%20Public.pdf\"\n width=\"100%\"\n height=\"500px\"\n previewable\n ></hy-pdf-viewer>\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
export declare class HyPdfViewer extends LitElement {
|
|
3
|
+
src: string;
|
|
4
|
+
width: string;
|
|
5
|
+
height: string;
|
|
6
|
+
fallback: null;
|
|
7
|
+
previewable: boolean;
|
|
8
|
+
private isFullscreen;
|
|
9
|
+
defaultFallBack: string;
|
|
10
|
+
static styles: import("lit").CSSResult;
|
|
11
|
+
render(): import("lit").TemplateResult<1>;
|
|
12
|
+
_handleError(e: Event): void;
|
|
13
|
+
_openFullscreen(): void;
|
|
14
|
+
_closeFullscreen(): void;
|
|
15
|
+
disconnectedCallback(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=document.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.component.d.ts","sourceRoot":"","sources":["../../../src/components/document/document.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,qBACa,WAAY,SAAQ,UAAU;IAEzC,GAAG,EAAG,MAAM,CAAC;IAGb,KAAK,SAAU;IAGf,MAAM,SAAU;IAGhB,QAAQ,OAAQ;IAGhB,WAAW,UAAS;IAGpB,OAAO,CAAC,YAAY,CAAS;IAE7B,eAAe,SAAw0B;IAEv1B,OAAgB,MAAM,0BAgGpB;IAEO,MAAM;IA6Cf,YAAY,CAAC,CAAC,EAAE,KAAK;IA0BrB,eAAe;IAMf,gBAAgB;IAOP,oBAAoB;CAO9B"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, css } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
|
+
let HyPdfViewer = class HyPdfViewer extends LitElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.width = 'auto';
|
|
13
|
+
this.height = 'auto';
|
|
14
|
+
this.fallback = null;
|
|
15
|
+
this.previewable = false;
|
|
16
|
+
this.isFullscreen = false;
|
|
17
|
+
this.defaultFallBack = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KPHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNFRkYxRjMiLz4NCjxwYXRoIGQ9Ik01OS40IDYyLjhWODAuNEg0OC4yVjQxLjZINjMuNEM2Ny4xIDQxLjYgNzAuMSA0Mi42IDcyLjQgNDQuN0M3NC43IDQ2LjggNzUuOCA0OS42IDc1LjggNTNDNzUuOCA1Ni41IDc0LjcgNTkuMiA3Mi40IDYxLjNDNzAuMiA2My40IDY3LjIgNjQuNCA2My40IDY0LjRINTkuNFY2Mi44Wk01OS40IDU0LjZINjMuNEM2NSA1NC42IDY2LjMgNTQuMSA2Ny4yIDUzQzY4LjEgNTEuOSA2OC42IDUwLjYgNjguNiA0OUM2OC42IDQ3LjUgNjguMSA0Ni4yIDY3LjIgNDUuMUM2Ni4zIDQ0IDY1IDQzLjQgNjMuNCA0My40SDU5LjRWNTQuNloiIGZpbGw9IiM2ODc3ODciLz4NCjwvc3ZnPg==';
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
return html `
|
|
21
|
+
<div class="pdf-container" style="width:${this.width}; height:${this.height};">
|
|
22
|
+
<iframe
|
|
23
|
+
class="pdf-iframe"
|
|
24
|
+
src="${this.src}"
|
|
25
|
+
title="PDF Viewer"
|
|
26
|
+
@error=${this._handleError}
|
|
27
|
+
></iframe>
|
|
28
|
+
|
|
29
|
+
${this.previewable ? html `
|
|
30
|
+
<button class="preview-button" @click=${this._openFullscreen}>
|
|
31
|
+
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
32
|
+
<path d="M5.5 1H1.5C1.22386 1 1 1.22386 1 1.5V5.5C1 5.77614 1.22386 6 1.5 6C1.77614 6 2 5.77614 2 5.5V2H5.5C5.77614 2 6 1.77614 6 1.5C6 1.22386 5.77614 1 5.5 1Z" fill="currentColor"/>
|
|
33
|
+
<path d="M14.5 1H10.5C10.2239 1 10 1.22386 10 1.5C10 1.77614 10.2239 2 10.5 2H14V5.5C14 5.77614 14.2239 6 14.5 6C14.7761 6 15 5.77614 15 5.5V1.5C15 1.22386 14.7761 1 14.5 1Z" fill="currentColor"/>
|
|
34
|
+
<path d="M5.5 14H2V10.5C2 10.2239 1.77614 10 1.5 10C1.22386 10 1 10.2239 1 10.5V14.5C1 14.7761 1.22386 15 1.5 15H5.5C5.77614 15 6 14.7761 6 14.5C6 14.2239 5.77614 14 5.5 14Z" fill="currentColor"/>
|
|
35
|
+
<path d="M14.5 10C14.2239 10 14 10.2239 14 10.5V14H10.5C10.2239 14 10 14.2239 10 14.5C10 14.7761 10.2239 15 10.5 15H14.5C14.7761 15 15 14.7761 15 14.5V10.5C15 10.2239 14.7761 10 14.5 10Z" fill="currentColor"/>
|
|
36
|
+
</svg>
|
|
37
|
+
Fullscreen
|
|
38
|
+
</button>
|
|
39
|
+
` : ''}
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
${this.isFullscreen ? html `
|
|
43
|
+
<div class="fullscreen-overlay">
|
|
44
|
+
<div class="fullscreen-header">
|
|
45
|
+
<button class="close-button" @click=${this._closeFullscreen}>
|
|
46
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
47
|
+
<path d="M12.5 3.5L3.5 12.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
48
|
+
<path d="M12.5 12.5L3.5 3.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
49
|
+
</svg>
|
|
50
|
+
</button>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="fullscreen-content">
|
|
53
|
+
<iframe
|
|
54
|
+
class="fullscreen-iframe"
|
|
55
|
+
src="${this.src}"
|
|
56
|
+
title="Fullscreen PDF"
|
|
57
|
+
></iframe>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
` : ''}
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
_handleError(e) {
|
|
64
|
+
var _a;
|
|
65
|
+
console.error('PDF loading error:', e);
|
|
66
|
+
this.dispatchEvent(new CustomEvent('onError', {
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
detail: {
|
|
70
|
+
error: `Error loading PDF: PDF viewer not supported or file cannot be loaded`
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
// Show fallback image when error occurs
|
|
74
|
+
const container = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.pdf-container');
|
|
75
|
+
if (container) {
|
|
76
|
+
const iframe = container.querySelector('iframe');
|
|
77
|
+
if (iframe) {
|
|
78
|
+
const img = document.createElement('img');
|
|
79
|
+
img.src = this.fallback || this.defaultFallBack;
|
|
80
|
+
img.alt = "PDF failed to load";
|
|
81
|
+
img.style.width = "100%";
|
|
82
|
+
img.style.height = "100%";
|
|
83
|
+
img.style.objectFit = "contain";
|
|
84
|
+
container.replaceChild(img, iframe);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
_openFullscreen() {
|
|
89
|
+
this.isFullscreen = true;
|
|
90
|
+
// Prevent scrolling of the background when fullscreen is active
|
|
91
|
+
document.body.style.overflow = 'hidden';
|
|
92
|
+
}
|
|
93
|
+
_closeFullscreen() {
|
|
94
|
+
this.isFullscreen = false;
|
|
95
|
+
// Restore scrolling when fullscreen is closed
|
|
96
|
+
document.body.style.overflow = '';
|
|
97
|
+
}
|
|
98
|
+
// Clean up when component is removed
|
|
99
|
+
disconnectedCallback() {
|
|
100
|
+
super.disconnectedCallback();
|
|
101
|
+
// Ensure body scrolling is restored if component is removed while in fullscreen
|
|
102
|
+
if (this.isFullscreen) {
|
|
103
|
+
document.body.style.overflow = '';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
HyPdfViewer.styles = css `
|
|
108
|
+
:host {
|
|
109
|
+
display: block;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.pdf-container {
|
|
113
|
+
position: relative;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
min-height: 100px;
|
|
116
|
+
background-color: #f5f5f5;
|
|
117
|
+
border: 1px solid #e0e0e0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.pdf-iframe {
|
|
121
|
+
border: none;
|
|
122
|
+
display: block;
|
|
123
|
+
width: 100%;
|
|
124
|
+
height: 100%;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.preview-button {
|
|
128
|
+
position: absolute;
|
|
129
|
+
top: 10px;
|
|
130
|
+
right: 10px;
|
|
131
|
+
background-color: rgba(255, 255, 255, 0.8);
|
|
132
|
+
border: 1px solid #ccc;
|
|
133
|
+
border-radius: 4px;
|
|
134
|
+
padding: 5px 10px;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
139
|
+
font-size: 12px;
|
|
140
|
+
z-index: 10;
|
|
141
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.preview-button:hover {
|
|
145
|
+
background-color: rgba(255, 255, 255, 1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.preview-button svg {
|
|
149
|
+
margin-right: 4px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.fullscreen-overlay {
|
|
153
|
+
position: fixed;
|
|
154
|
+
top: 0;
|
|
155
|
+
left: 0;
|
|
156
|
+
width: 100vw;
|
|
157
|
+
height: 100vh;
|
|
158
|
+
background-color: rgba(0, 0, 0, 0.95);
|
|
159
|
+
z-index: 9999;
|
|
160
|
+
display: flex;
|
|
161
|
+
flex-direction: column;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.fullscreen-header {
|
|
165
|
+
display: flex;
|
|
166
|
+
justify-content: flex-end;
|
|
167
|
+
padding: 16px;
|
|
168
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.close-button {
|
|
172
|
+
background-color: white;
|
|
173
|
+
border: none;
|
|
174
|
+
border-radius: 4px;
|
|
175
|
+
padding: 8px;
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
display: flex;
|
|
178
|
+
align-items: center;
|
|
179
|
+
justify-content: center;
|
|
180
|
+
width: 32px;
|
|
181
|
+
height: 32px;
|
|
182
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.close-button:hover {
|
|
186
|
+
background-color: #f0f0f0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.fullscreen-content {
|
|
190
|
+
flex: 1;
|
|
191
|
+
padding: 0;
|
|
192
|
+
display: flex;
|
|
193
|
+
align-items: center;
|
|
194
|
+
justify-content: center;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.fullscreen-iframe {
|
|
198
|
+
width: 100%;
|
|
199
|
+
height: 100%;
|
|
200
|
+
border: none;
|
|
201
|
+
background-color: white;
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
__decorate([
|
|
205
|
+
property()
|
|
206
|
+
], HyPdfViewer.prototype, "src", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property()
|
|
209
|
+
], HyPdfViewer.prototype, "width", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property()
|
|
212
|
+
], HyPdfViewer.prototype, "height", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
property({ type: Object })
|
|
215
|
+
], HyPdfViewer.prototype, "fallback", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
property({ type: Boolean })
|
|
218
|
+
], HyPdfViewer.prototype, "previewable", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
state()
|
|
221
|
+
], HyPdfViewer.prototype, "isFullscreen", void 0);
|
|
222
|
+
HyPdfViewer = __decorate([
|
|
223
|
+
customElement('hy-pdf-viewer')
|
|
224
|
+
], HyPdfViewer);
|
|
225
|
+
export { HyPdfViewer };
|
|
226
|
+
//# sourceMappingURL=document.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.component.js","sourceRoot":"","sources":["../../../src/components/document/document.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAGnE,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,UAAU;IAA3C;;QAKE,UAAK,GAAG,MAAM,CAAC;QAGf,WAAM,GAAG,MAAM,CAAC;QAGhB,aAAQ,GAAG,IAAI,CAAC;QAGhB,gBAAW,GAAG,KAAK,CAAC;QAGZ,iBAAY,GAAG,KAAK,CAAC;QAE7B,oBAAe,GAAG,o0BAAo0B,CAAC;IA+Lz1B,CAAC;IA3FU,MAAM;QACb,OAAO,IAAI,CAAA;gDACiC,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC,MAAM;;;iBAGhE,IAAI,CAAC,GAAG;;mBAEN,IAAI,CAAC,YAAY;;;UAG1B,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA;kDACiB,IAAI,CAAC,eAAe;;;;;;;;;SAS7D,CAAC,CAAC,CAAC,EAAE;;;QAGN,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAA;;;kDAGkB,IAAI,CAAC,gBAAgB;;;;;;;;;;qBAUlD,IAAI,CAAC,GAAG;;;;;OAKtB,CAAC,CAAC,CAAC,EAAE;KACP,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,CAAQ;;QACnB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,SAAS,EAAE;YAC5C,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE;gBACN,KAAK,EAAE,sEAAsE;aAC9E;SACF,CAAC,CAAC,CAAC;QAEJ,wCAAwC;QACxC,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,UAAU,0CAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;QACnE,IAAI,SAAS,EAAE;YACb,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YACjD,IAAI,MAAM,EAAE;gBACV,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAC1C,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,eAAe,CAAC;gBAChD,GAAG,CAAC,GAAG,GAAG,oBAAoB,CAAC;gBAC/B,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;gBACzB,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;gBAC1B,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;gBAChC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;aACrC;SACF;IACH,CAAC;IAED,eAAe;QACb,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,gEAAgE;QAChE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1C,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,8CAA8C;QAC9C,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,qCAAqC;IAC5B,oBAAoB;QAC3B,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC7B,gFAAgF;QAChF,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC;SACnC;IACH,CAAC;CACF,CAAA;AA7LiB,kBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgG1B,CAAA;AAnHF;IADC,QAAQ,EAAE;wCACE;AAGb;IADC,QAAQ,EAAE;0CACI;AAGf;IADC,QAAQ,EAAE;2CACK;AAGhB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACT;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACR;AAGpB;IADC,KAAK,EAAE;iDACqB;AAjBlB,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAkNvB;SAlNY,WAAW","sourcesContent":["import { LitElement, html, css } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\n\n@customElement('hy-pdf-viewer')\nexport class HyPdfViewer extends LitElement {\n @property()\n src!: string;\n\n @property()\n width = 'auto';\n\n @property()\n height = 'auto';\n\n @property({type: Object})\n fallback = null;\n\n @property({ type: Boolean })\n previewable = false;\n\n @state()\n private isFullscreen = false;\n\n defaultFallBack = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KPHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNFRkYxRjMiLz4NCjxwYXRoIGQ9Ik01OS40IDYyLjhWODAuNEg0OC4yVjQxLjZINjMuNEM2Ny4xIDQxLjYgNzAuMSA0Mi42IDcyLjQgNDQuN0M3NC43IDQ2LjggNzUuOCA0OS42IDc1LjggNTNDNzUuOCA1Ni41IDc0LjcgNTkuMiA3Mi40IDYxLjNDNzAuMiA2My40IDY3LjIgNjQuNCA2My40IDY0LjRINTkuNFY2Mi44Wk01OS40IDU0LjZINjMuNEM2NSA1NC42IDY2LjMgNTQuMSA2Ny4yIDUzQzY4LjEgNTEuOSA2OC42IDUwLjYgNjguNiA0OUM2OC42IDQ3LjUgNjguMSA0Ni4yIDY3LjIgNDUuMUM2Ni4zIDQ0IDY1IDQzLjQgNjMuNCA0My40SDU5LjRWNTQuNloiIGZpbGw9IiM2ODc3ODciLz4NCjwvc3ZnPg==';\n\n static override styles = css`\n :host {\n display: block;\n }\n \n .pdf-container {\n position: relative;\n overflow: hidden;\n min-height: 100px;\n background-color: #f5f5f5;\n border: 1px solid #e0e0e0;\n }\n \n .pdf-iframe {\n border: none;\n display: block;\n width: 100%;\n height: 100%;\n }\n \n .preview-button {\n position: absolute;\n top: 10px;\n right: 10px;\n background-color: rgba(255, 255, 255, 0.8);\n border: 1px solid #ccc;\n border-radius: 4px;\n padding: 5px 10px;\n cursor: pointer;\n display: flex;\n align-items: center;\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 12px;\n z-index: 10;\n box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n }\n \n .preview-button:hover {\n background-color: rgba(255, 255, 255, 1);\n }\n\n .preview-button svg {\n margin-right: 4px;\n }\n \n .fullscreen-overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.95);\n z-index: 9999;\n display: flex;\n flex-direction: column;\n }\n \n .fullscreen-header {\n display: flex;\n justify-content: flex-end;\n padding: 16px;\n background-color: rgba(0, 0, 0, 0.4);\n }\n \n .close-button {\n background-color: white;\n border: none;\n border-radius: 4px;\n padding: 8px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n box-shadow: 0 2px 4px rgba(0,0,0,0.2);\n }\n\n .close-button:hover {\n background-color: #f0f0f0;\n }\n \n .fullscreen-content {\n flex: 1;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .fullscreen-iframe {\n width: 100%;\n height: 100%;\n border: none;\n background-color: white;\n }\n `;\n\n override render() {\n return html`\n <div class=\"pdf-container\" style=\"width:${this.width}; height:${this.height};\">\n <iframe \n class=\"pdf-iframe\"\n src=\"${this.src}\" \n title=\"PDF Viewer\"\n @error=${this._handleError}\n ></iframe>\n \n ${this.previewable ? html`\n <button class=\"preview-button\" @click=${this._openFullscreen}>\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5.5 1H1.5C1.22386 1 1 1.22386 1 1.5V5.5C1 5.77614 1.22386 6 1.5 6C1.77614 6 2 5.77614 2 5.5V2H5.5C5.77614 2 6 1.77614 6 1.5C6 1.22386 5.77614 1 5.5 1Z\" fill=\"currentColor\"/>\n <path d=\"M14.5 1H10.5C10.2239 1 10 1.22386 10 1.5C10 1.77614 10.2239 2 10.5 2H14V5.5C14 5.77614 14.2239 6 14.5 6C14.7761 6 15 5.77614 15 5.5V1.5C15 1.22386 14.7761 1 14.5 1Z\" fill=\"currentColor\"/>\n <path d=\"M5.5 14H2V10.5C2 10.2239 1.77614 10 1.5 10C1.22386 10 1 10.2239 1 10.5V14.5C1 14.7761 1.22386 15 1.5 15H5.5C5.77614 15 6 14.7761 6 14.5C6 14.2239 5.77614 14 5.5 14Z\" fill=\"currentColor\"/>\n <path d=\"M14.5 10C14.2239 10 14 10.2239 14 10.5V14H10.5C10.2239 14 10 14.2239 10 14.5C10 14.7761 10.2239 15 10.5 15H14.5C14.7761 15 15 14.7761 15 14.5V10.5C15 10.2239 14.7761 10 14.5 10Z\" fill=\"currentColor\"/>\n </svg>\n Fullscreen\n </button>\n ` : ''}\n </div>\n \n ${this.isFullscreen ? html`\n <div class=\"fullscreen-overlay\">\n <div class=\"fullscreen-header\">\n <button class=\"close-button\" @click=${this._closeFullscreen}>\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12.5 3.5L3.5 12.5\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <path d=\"M12.5 12.5L3.5 3.5\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n </button>\n </div>\n <div class=\"fullscreen-content\">\n <iframe \n class=\"fullscreen-iframe\"\n src=\"${this.src}\" \n title=\"Fullscreen PDF\"\n ></iframe>\n </div>\n </div>\n ` : ''}\n `;\n }\n\n _handleError(e: Event) {\n console.error('PDF loading error:', e);\n this.dispatchEvent(new CustomEvent('onError', {\n bubbles: true,\n composed: true,\n detail: {\n error: `Error loading PDF: PDF viewer not supported or file cannot be loaded`\n }\n }));\n \n // Show fallback image when error occurs\n const container = this.shadowRoot?.querySelector('.pdf-container');\n if (container) {\n const iframe = container.querySelector('iframe');\n if (iframe) {\n const img = document.createElement('img');\n img.src = this.fallback || this.defaultFallBack;\n img.alt = \"PDF failed to load\";\n img.style.width = \"100%\";\n img.style.height = \"100%\";\n img.style.objectFit = \"contain\";\n container.replaceChild(img, iframe);\n }\n }\n }\n\n _openFullscreen() {\n this.isFullscreen = true;\n // Prevent scrolling of the background when fullscreen is active\n document.body.style.overflow = 'hidden';\n }\n\n _closeFullscreen() {\n this.isFullscreen = false;\n // Restore scrolling when fullscreen is closed\n document.body.style.overflow = '';\n }\n\n // Clean up when component is removed\n override disconnectedCallback() {\n super.disconnectedCallback();\n // Ensure body scrolling is restored if component is removed while in fullscreen\n if (this.isFullscreen) {\n document.body.style.overflow = '';\n }\n }\n}"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.style.d.ts","sourceRoot":"","sources":["../../../src/components/document/document.style.ts"],"names":[],"mappings":";AAEA,wBAsIE"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export default css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.pdf-container {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
border: 1px solid #ccc;
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
background-color: #f5f5f5;
|
|
14
|
+
position: relative;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.toolbar {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
padding: 8px;
|
|
21
|
+
background-color: #f0f0f0;
|
|
22
|
+
border-bottom: 1px solid #ddd;
|
|
23
|
+
gap: 8px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.toolbar button {
|
|
27
|
+
background-color: #fff;
|
|
28
|
+
border: 1px solid #ccc;
|
|
29
|
+
border-radius: 4px;
|
|
30
|
+
padding: 4px 8px;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
font-size: 14px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.toolbar button:hover {
|
|
36
|
+
background-color: #e6e6e6;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.toolbar button:disabled {
|
|
40
|
+
opacity: 0.5;
|
|
41
|
+
cursor: not-allowed;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.toolbar span {
|
|
45
|
+
margin: 0 4px;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.canvas-container {
|
|
50
|
+
flex: 1;
|
|
51
|
+
overflow: auto;
|
|
52
|
+
display: flex;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
align-items: flex-start;
|
|
55
|
+
background-color: #e0e0e0;
|
|
56
|
+
padding: 16px;
|
|
57
|
+
min-height: 200px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
canvas {
|
|
61
|
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
|
62
|
+
background-color: white;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.preview-modal {
|
|
66
|
+
position: fixed;
|
|
67
|
+
top: 0;
|
|
68
|
+
left: 0;
|
|
69
|
+
right: 0;
|
|
70
|
+
bottom: 0;
|
|
71
|
+
background-color: rgba(0, 0, 0, 0.8);
|
|
72
|
+
z-index: 1000;
|
|
73
|
+
display: flex;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
align-items: center;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.preview-content {
|
|
79
|
+
position: relative;
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
width: 90%;
|
|
83
|
+
height: 90%;
|
|
84
|
+
background-color: #f5f5f5;
|
|
85
|
+
border-radius: 8px;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.preview-toolbar {
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
padding: 12px;
|
|
93
|
+
background-color: #f0f0f0;
|
|
94
|
+
border-bottom: 1px solid #ddd;
|
|
95
|
+
gap: 12px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.preview-toolbar button {
|
|
99
|
+
background-color: #fff;
|
|
100
|
+
border: 1px solid #ccc;
|
|
101
|
+
border-radius: 4px;
|
|
102
|
+
padding: 6px 12px;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
font-size: 16px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.preview-toolbar span {
|
|
108
|
+
margin: 0 6px;
|
|
109
|
+
font-size: 16px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.preview-close {
|
|
113
|
+
position: absolute;
|
|
114
|
+
top: 10px;
|
|
115
|
+
right: 10px;
|
|
116
|
+
background-color: transparent;
|
|
117
|
+
border: none;
|
|
118
|
+
font-size: 24px;
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
z-index: 1010;
|
|
121
|
+
color: #333;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.preview-close:hover {
|
|
125
|
+
color: #000;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.preview-modal canvas {
|
|
129
|
+
max-width: 100%;
|
|
130
|
+
max-height: calc(100% - 60px); /* Account for toolbar height */
|
|
131
|
+
object-fit: contain;
|
|
132
|
+
margin: auto;
|
|
133
|
+
display: block;
|
|
134
|
+
flex: 1;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
//# sourceMappingURL=document.style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.style.js","sourceRoot":"","sources":["../../../src/components/document/document.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsIjB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport default css`\n :host {\n display: block;\n }\n \n .pdf-container {\n display: flex;\n flex-direction: column;\n border: 1px solid #ccc;\n border-radius: 4px;\n overflow: hidden;\n background-color: #f5f5f5;\n position: relative;\n }\n \n .toolbar {\n display: flex;\n align-items: center;\n padding: 8px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #ddd;\n gap: 8px;\n }\n \n .toolbar button {\n background-color: #fff;\n border: 1px solid #ccc;\n border-radius: 4px;\n padding: 4px 8px;\n cursor: pointer;\n font-size: 14px;\n }\n \n .toolbar button:hover {\n background-color: #e6e6e6;\n }\n \n .toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n \n .toolbar span {\n margin: 0 4px;\n font-size: 14px;\n }\n \n .canvas-container {\n flex: 1;\n overflow: auto;\n display: flex;\n justify-content: center;\n align-items: flex-start;\n background-color: #e0e0e0;\n padding: 16px;\n min-height: 200px;\n }\n \n canvas {\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);\n background-color: white;\n }\n \n .preview-modal {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.8);\n z-index: 1000;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n \n .preview-content {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 90%;\n height: 90%;\n background-color: #f5f5f5;\n border-radius: 8px;\n overflow: hidden;\n }\n \n .preview-toolbar {\n display: flex;\n align-items: center;\n padding: 12px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #ddd;\n gap: 12px;\n }\n \n .preview-toolbar button {\n background-color: #fff;\n border: 1px solid #ccc;\n border-radius: 4px;\n padding: 6px 12px;\n cursor: pointer;\n font-size: 16px;\n }\n \n .preview-toolbar span {\n margin: 0 6px;\n font-size: 16px;\n }\n \n .preview-close {\n position: absolute;\n top: 10px;\n right: 10px;\n background-color: transparent;\n border: none;\n font-size: 24px;\n cursor: pointer;\n z-index: 1010;\n color: #333;\n }\n \n .preview-close:hover {\n color: #000;\n }\n \n .preview-modal canvas {\n max-width: 100%;\n max-height: calc(100% - 60px); /* Account for toolbar height */\n object-fit: contain;\n margin: auto;\n display: block;\n flex: 1;\n }\n`;"]}
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/document/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA"}
|
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/document/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA","sourcesContent":["export * from './document.component.js'"]}
|
package/package.json
ADDED