@nuralyui/document 0.0.8 → 0.0.9

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.
Files changed (2) hide show
  1. package/bundle.js +169 -1
  2. package/package.json +1 -1
package/bundle.js CHANGED
@@ -1 +1,169 @@
1
- import{css as e,LitElement as o,html as i}from"lit";import{property as t,state as r,customElement as s}from"lit/decorators.js";import{classMap as a}from"lit/directives/class-map.js";import{styleMap as d}from"lit/directives/style-map.js";import{NuralyUIBaseMixin as l}from"@nuralyui/common/mixins";var n=e`:host{display:block}.pdf-container{display:flex;flex-direction:column;border:1px solid #ccc;border-radius:4px;overflow:hidden;background-color:#f5f5f5;position:relative}.toolbar{display:flex;align-items:center;padding:8px;background-color:#f0f0f0;border-bottom:1px solid #ddd;gap:8px}.toolbar button{background-color:#fff;border:1px solid #ccc;border-radius:4px;padding:4px 8px;cursor:pointer;font-size:14px}.toolbar button:hover{background-color:#e6e6e6}.toolbar button:disabled{opacity:.5;cursor:not-allowed}.toolbar span{margin:0 4px;font-size:14px}.canvas-container{flex:1;overflow:auto;display:flex;justify-content:center;align-items:flex-start;background-color:#e0e0e0;padding:16px;min-height:200px}canvas{box-shadow:0 2px 10px rgba(0,0,0,.2);background-color:#fff}.preview-modal{position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,.8);z-index:1000;display:flex;justify-content:center;align-items:center}.preview-content{position:relative;display:flex;flex-direction:column;width:90%;height:90%;background-color:#f5f5f5;border-radius:8px;overflow:hidden}.preview-toolbar{display:flex;align-items:center;padding:12px;background-color:#f0f0f0;border-bottom:1px solid #ddd;gap:12px}.preview-toolbar button{background-color:#fff;border:1px solid #ccc;border-radius:4px;padding:6px 12px;cursor:pointer;font-size:16px}.preview-toolbar span{margin:0 6px;font-size:16px}.preview-close{position:absolute;top:10px;right:10px;background-color:transparent;border:none;font-size:24px;cursor:pointer;z-index:1010;color:#333}.preview-close:hover{color:#000}.preview-modal canvas{max-width:100%;max-height:calc(100% - 60px);object-fit:contain;margin:auto;display:block;flex:1}`,c=function(e,o,i,t){for(var r,s=arguments.length,a=s<3?o:null===t?t=Object.getOwnPropertyDescriptor(o,i):t,d=e.length-1;d>=0;d--)(r=e[d])&&(a=(s<3?r(a):s>3?r(o,i,a):r(o,i))||a);return s>3&&a&&Object.defineProperty(o,i,a),a};let p=class extends(l(o)){constructor(){super(...arguments),this.type="pdf",this.width="auto",this.height="500px",this.previewable=!1,this.block=!1,this.showPreview=!1,this.hasError=!1,this.defaultFallback="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgdmlld0JveD0iMCAwIDEyMCAxMjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNFRkYxRjMiLz48cGF0aCBkPSJNNTkuNCA2Mi44VjgwLjRINDguMlY0MS42SDYzLjRDNjcuMSA0MS42IDcwLjEgNDIuNiA3Mi40IDQ0LjdDNzQuNyA0Ni44IDc1LjggNDkuNiA3NS44IDUzQzc1LjggNTYuNSA3NC43IDU5LjIgNzIuNCA2MS4zQzcwLjIgNjMuNCA2Ny4yIDY0LjQgNjMuNCA2NC40SDU5LjRWNjIuOFpNNTkuNCA1NC42SDYzLjRDNjUgNTQuNiA2Ni4zIDU0LjEgNjcuMiA1M0M2OC4xIDUxLjkgNjguNiA1MC42IDY4LjYgNDlDNjguNiA0Ny41IDY4LjEgNDYuMiA2Ny4yIDQ1LjFDNjYuMyA0NCA2NSA0My40IDYzLjQgNDMuNEg1OS40VjU0LjZaIiBmaWxsPSIjNjg3Nzg3Ii8+PC9zdmc+"}handleError(){this.hasError=!0,this.dispatchEvent(new CustomEvent("nr-document-error",{bubbles:!0,composed:!0,detail:{error:`Error loading document: ${this.src}`,src:this.src,type:this.type}}))}handleLoad(){this.dispatchEvent(new CustomEvent("nr-document-load",{bubbles:!0,composed:!0,detail:{src:this.src,type:this.type}}))}showPreviewModal(){this.previewable&&!this.hasError&&(this.showPreview=!0,this.dispatchEvent(new CustomEvent("nr-document-preview-open",{bubbles:!0,composed:!0,detail:{src:this.src,type:this.type}})))}closePreviewModal(){this.showPreview=!1,this.dispatchEvent(new CustomEvent("nr-document-preview-close",{bubbles:!0,composed:!0,detail:{src:this.src,type:this.type}}))}render(){const e={"document-container":!0,"document--error":this.hasError},o={width:"number"==typeof this.width?`${this.width}px`:this.width,height:"number"==typeof this.height?`${this.height}px`:this.height};return this.hasError?i`<div class="${a(e)}" style="${d(o)}"><div class="error-message"><img class="error-icon" src="${this.defaultFallback}" alt="Document error"><p>Unable to load document</p></div></div>`:i`<div class="${a(e)}" style="${d(o)}"><iframe class="document-iframe" src="${this.src}" @error="${this.handleError}" @load="${this.handleLoad}" title="Document viewer"></iframe>${this.previewable?i`<button class="preview-button" @click="${this.showPreviewModal}"><svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M5.5 5.5A.5.5 0 0 1 6 6v3a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v3a.5.5 0 0 0 1 0V6z"/><path d="M2 1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H2zM1 2a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2z"/></svg> Fullscreen</button>`:""} ${this.showPreview?i`<div class="preview-modal"><div class="preview-header"><button class="preview-close" @click="${this.closePreviewModal}" aria-label="Close preview">×</button></div><iframe src="${this.src}" title="Document viewer fullscreen"></iframe></div>`:""}</div>`}};p.styles=n,c([t({type:String})],p.prototype,"src",void 0),c([t({type:String})],p.prototype,"type",void 0),c([t({type:String})],p.prototype,"width",void 0),c([t({type:String})],p.prototype,"height",void 0),c([t({type:Boolean})],p.prototype,"previewable",void 0),c([t({type:Boolean,reflect:!0})],p.prototype,"block",void 0),c([r()],p.prototype,"showPreview",void 0),c([r()],p.prototype,"hasError",void 0),p=c([s("nr-document")],p);export{p as NrDocumentElement};
1
+ import{css as e,LitElement as o,html as i}from"lit";import{property as t,state as r,customElement as s}from"lit/decorators.js";import{classMap as a}from"lit/directives/class-map.js";import{styleMap as d}from"lit/directives/style-map.js";import{NuralyUIBaseMixin as l}from"@nuralyui/common/mixins";var n=e`
2
+ :host {
3
+ display: block;
4
+ }
5
+
6
+ .pdf-container {
7
+ display: flex;
8
+ flex-direction: column;
9
+ border: 1px solid #ccc;
10
+ border-radius: 4px;
11
+ overflow: hidden;
12
+ background-color: #f5f5f5;
13
+ position: relative;
14
+ }
15
+
16
+ .toolbar {
17
+ display: flex;
18
+ align-items: center;
19
+ padding: 8px;
20
+ background-color: #f0f0f0;
21
+ border-bottom: 1px solid #ddd;
22
+ gap: 8px;
23
+ }
24
+
25
+ .toolbar button {
26
+ background-color: #fff;
27
+ border: 1px solid #ccc;
28
+ border-radius: 4px;
29
+ padding: 4px 8px;
30
+ cursor: pointer;
31
+ font-size: 14px;
32
+ }
33
+
34
+ .toolbar button:hover {
35
+ background-color: #e6e6e6;
36
+ }
37
+
38
+ .toolbar button:disabled {
39
+ opacity: 0.5;
40
+ cursor: not-allowed;
41
+ }
42
+
43
+ .toolbar span {
44
+ margin: 0 4px;
45
+ font-size: 14px;
46
+ }
47
+
48
+ .canvas-container {
49
+ flex: 1;
50
+ overflow: auto;
51
+ display: flex;
52
+ justify-content: center;
53
+ align-items: flex-start;
54
+ background-color: #e0e0e0;
55
+ padding: 16px;
56
+ min-height: 200px;
57
+ }
58
+
59
+ canvas {
60
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
61
+ background-color: white;
62
+ }
63
+
64
+ .preview-modal {
65
+ position: fixed;
66
+ top: 0;
67
+ left: 0;
68
+ right: 0;
69
+ bottom: 0;
70
+ background-color: rgba(0, 0, 0, 0.8);
71
+ z-index: 1000;
72
+ display: flex;
73
+ justify-content: center;
74
+ align-items: center;
75
+ }
76
+
77
+ .preview-content {
78
+ position: relative;
79
+ display: flex;
80
+ flex-direction: column;
81
+ width: 90%;
82
+ height: 90%;
83
+ background-color: #f5f5f5;
84
+ border-radius: 8px;
85
+ overflow: hidden;
86
+ }
87
+
88
+ .preview-toolbar {
89
+ display: flex;
90
+ align-items: center;
91
+ padding: 12px;
92
+ background-color: #f0f0f0;
93
+ border-bottom: 1px solid #ddd;
94
+ gap: 12px;
95
+ }
96
+
97
+ .preview-toolbar button {
98
+ background-color: #fff;
99
+ border: 1px solid #ccc;
100
+ border-radius: 4px;
101
+ padding: 6px 12px;
102
+ cursor: pointer;
103
+ font-size: 16px;
104
+ }
105
+
106
+ .preview-toolbar span {
107
+ margin: 0 6px;
108
+ font-size: 16px;
109
+ }
110
+
111
+ .preview-close {
112
+ position: absolute;
113
+ top: 10px;
114
+ right: 10px;
115
+ background-color: transparent;
116
+ border: none;
117
+ font-size: 24px;
118
+ cursor: pointer;
119
+ z-index: 1010;
120
+ color: #333;
121
+ }
122
+
123
+ .preview-close:hover {
124
+ color: #000;
125
+ }
126
+
127
+ .preview-modal canvas {
128
+ max-width: 100%;
129
+ max-height: calc(100% - 60px); /* Account for toolbar height */
130
+ object-fit: contain;
131
+ margin: auto;
132
+ display: block;
133
+ flex: 1;
134
+ }
135
+ `,c=function(e,o,i,t){for(var r,s=arguments.length,a=s<3?o:null===t?t=Object.getOwnPropertyDescriptor(o,i):t,d=e.length-1;d>=0;d--)(r=e[d])&&(a=(s<3?r(a):s>3?r(o,i,a):r(o,i))||a);return s>3&&a&&Object.defineProperty(o,i,a),a};let p=class extends(l(o)){constructor(){super(...arguments),this.type="pdf",this.width="auto",this.height="500px",this.previewable=!1,this.block=!1,this.showPreview=!1,this.hasError=!1,this.defaultFallback="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgdmlld0JveD0iMCAwIDEyMCAxMjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNFRkYxRjMiLz48cGF0aCBkPSJNNTkuNCA2Mi44VjgwLjRINDguMlY0MS42SDYzLjRDNjcuMSA0MS42IDcwLjEgNDIuNiA3Mi40IDQ0LjdDNzQuNyA0Ni44IDc1LjggNDkuNiA3NS44IDUzQzc1LjggNTYuNSA3NC43IDU5LjIgNzIuNCA2MS4zQzcwLjIgNjMuNCA2Ny4yIDY0LjQgNjMuNCA2NC40SDU5LjRWNjIuOFpNNTkuNCA1NC42SDYzLjRDNjUgNTQuNiA2Ni4zIDU0LjEgNjcuMiA1M0M2OC4xIDUxLjkgNjguNiA1MC42IDY4LjYgNDlDNjguNiA0Ny41IDY4LjEgNDYuMiA2Ny4yIDQ1LjFDNjYuMyA0NCA2NSA0My40IDYzLjQgNDMuNEg1OS40VjU0LjZaIiBmaWxsPSIjNjg3Nzg3Ii8+PC9zdmc+"}handleError(){this.hasError=!0,this.dispatchEvent(new CustomEvent("nr-document-error",{bubbles:!0,composed:!0,detail:{error:`Error loading document: ${this.src}`,src:this.src,type:this.type}}))}handleLoad(){this.dispatchEvent(new CustomEvent("nr-document-load",{bubbles:!0,composed:!0,detail:{src:this.src,type:this.type}}))}showPreviewModal(){this.previewable&&!this.hasError&&(this.showPreview=!0,this.dispatchEvent(new CustomEvent("nr-document-preview-open",{bubbles:!0,composed:!0,detail:{src:this.src,type:this.type}})))}closePreviewModal(){this.showPreview=!1,this.dispatchEvent(new CustomEvent("nr-document-preview-close",{bubbles:!0,composed:!0,detail:{src:this.src,type:this.type}}))}render(){const e={"document-container":!0,"document--error":this.hasError},o={width:"number"==typeof this.width?`${this.width}px`:this.width,height:"number"==typeof this.height?`${this.height}px`:this.height};return this.hasError?i`
136
+ <div class=${a(e)} style=${d(o)}>
137
+ <div class="error-message">
138
+ <img class="error-icon" src=${this.defaultFallback} alt="Document error" />
139
+ <p>Unable to load document</p>
140
+ </div>
141
+ </div>
142
+ `:i`
143
+ <div class=${a(e)} style=${d(o)}>
144
+ <iframe
145
+ class="document-iframe"
146
+ src=${this.src}
147
+ @error=${this.handleError}
148
+ @load=${this.handleLoad}
149
+ title="Document viewer"
150
+ ></iframe>
151
+ ${this.previewable?i`
152
+ <button class="preview-button" @click=${this.showPreviewModal}>
153
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
154
+ <path d="M5.5 5.5A.5.5 0 0 1 6 6v3a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v3a.5.5 0 0 0 1 0V6z"/>
155
+ <path d="M2 1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H2zM1 2a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2z"/>
156
+ </svg>
157
+ Fullscreen
158
+ </button>
159
+ `:""}
160
+ ${this.showPreview?i`
161
+ <div class="preview-modal">
162
+ <div class="preview-header">
163
+ <button class="preview-close" @click=${this.closePreviewModal} aria-label="Close preview">×</button>
164
+ </div>
165
+ <iframe src=${this.src} title="Document viewer fullscreen"></iframe>
166
+ </div>
167
+ `:""}
168
+ </div>
169
+ `}};p.styles=n,c([t({type:String})],p.prototype,"src",void 0),c([t({type:String})],p.prototype,"type",void 0),c([t({type:String})],p.prototype,"width",void 0),c([t({type:String})],p.prototype,"height",void 0),c([t({type:Boolean})],p.prototype,"previewable",void 0),c([t({type:Boolean,reflect:!0})],p.prototype,"block",void 0),c([r()],p.prototype,"showPreview",void 0),c([r()],p.prototype,"hasError",void 0),p=c([s("nr-document")],p);export{p as NrDocumentElement};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuralyui/document",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",