@nuralyui/document 0.0.10 → 0.0.11
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/document.component.d.ts +1 -1
- package/document.component.js.map +1 -1
- package/document.style.js.map +1 -1
- package/document.types.js.map +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/react.js.map +1 -1
package/document.component.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class NrDocumentElement extends NrDocumentElement_base {
|
|
|
16
16
|
private handleLoad;
|
|
17
17
|
private showPreviewModal;
|
|
18
18
|
private closePreviewModal;
|
|
19
|
-
render(): import("lit").TemplateResult<1>;
|
|
19
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
20
20
|
}
|
|
21
21
|
declare global {
|
|
22
22
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.component.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"document.component.js","sourceRoot":"","sources":["../../../../src/components/document/document.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAIzC,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,iBAAiB,CAAC,UAAU,CAAC;IAApE;;QAOE,SAAI,gCAAkC;QAGtC,UAAK,GAAG,MAAM,CAAC;QAGf,WAAM,GAAG,OAAO,CAAC;QAGjB,gBAAW,GAAG,KAAK,CAAC;QAGpB,UAAK,GAAG,KAAK,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;CACF,CAAA;AApHiB,wBAAM,GAAG,MAAO,CAAA;AAGhC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACd;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACW;AAGtC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACZ;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sDACR;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAC7B;AAGd;IADC,KAAK,EAAE;sDACoB;AAG5B;IADC,KAAK,EAAE;mDACiB;AAzBd,iBAAiB;IAD7B,aAAa,CAAC,aAAa,CAAC;GAChB,iBAAiB,CAqH7B;SArHY,iBAAiB","sourcesContent":["import { html, LitElement } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { styleMap } from \"lit/directives/style-map.js\";\nimport { NuralyUIBaseMixin } from '@nuralyui/common/mixins';\nimport styles from \"./document.style.js\";\nimport { DocumentType } from \"./document.types.js\";\n\n@customElement('nr-document')\nexport class NrDocumentElement extends NuralyUIBaseMixin(LitElement) {\n static override styles = styles;\n\n @property({ type: String })\n src!: string;\n\n @property({ type: String })\n type: DocumentType = DocumentType.PDF;\n\n @property({ type: String })\n width = 'auto';\n\n @property({ type: String })\n height = '500px';\n\n @property({ type: Boolean })\n previewable = false;\n\n @property({ type: Boolean, reflect: true })\n block = false;\n\n @state()\n private showPreview = false;\n\n @state()\n private hasError = false;\n\n private readonly defaultFallback = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgdmlld0JveD0iMCAwIDEyMCAxMjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNFRkYxRjMiLz48cGF0aCBkPSJNNTkuNCA2Mi44VjgwLjRINDguMlY0MS42SDYzLjRDNjcuMSA0MS42IDcwLjEgNDIuNiA3Mi40IDQ0LjdDNzQuNyA0Ni44IDc1LjggNDkuNiA3NS44IDUzQzc1LjggNTYuNSA3NC43IDU5LjIgNzIuNCA2MS4zQzcwLjIgNjMuNCA2Ny4yIDY0LjQgNjMuNCA2NC40SDU5LjRWNjIuOFpNNTkuNCA1NC42SDYzLjRDNjUgNTQuNiA2Ni4zIDU0LjEgNjcuMiA1M0M2OC4xIDUxLjkgNjguNiA1MC42IDY4LjYgNDlDNjguNiA0Ny41IDY4LjEgNDYuMiA2Ny4yIDQ1LjFDNjYuMyA0NCA2NSA0My40IDYzLjQgNDMuNEg1OS40VjU0LjZaIiBmaWxsPSIjNjg3Nzg3Ii8+PC9zdmc+';\n\n private handleError() {\n this.hasError = true;\n this.dispatchEvent(new CustomEvent('nr-document-error', {\n bubbles: true,\n composed: true,\n detail: { error: `Error loading document: ${this.src}`, src: this.src, type: this.type }\n }));\n }\n\n private handleLoad() {\n this.dispatchEvent(new CustomEvent('nr-document-load', {\n bubbles: true,\n composed: true,\n detail: { src: this.src, type: this.type }\n }));\n }\n\n private showPreviewModal() {\n if (this.previewable && !this.hasError) {\n this.showPreview = true;\n this.dispatchEvent(new CustomEvent('nr-document-preview-open', {\n bubbles: true,\n composed: true,\n detail: { src: this.src, type: this.type }\n }));\n }\n }\n\n private closePreviewModal() {\n this.showPreview = false;\n this.dispatchEvent(new CustomEvent('nr-document-preview-close', {\n bubbles: true,\n composed: true,\n detail: { src: this.src, type: this.type }\n }));\n }\n\n override render() {\n const containerClasses = {\n 'document-container': true,\n 'document--error': this.hasError\n };\n\n const containerStyles: Record<string, string> = {\n width: typeof this.width === 'number' ? `${this.width}px` : this.width,\n height: typeof this.height === 'number' ? `${this.height}px` : this.height,\n };\n\n if (this.hasError) {\n return html`\n <div class=${classMap(containerClasses)} style=${styleMap(containerStyles)}>\n <div class=\"error-message\">\n <img class=\"error-icon\" src=${this.defaultFallback} alt=\"Document error\" />\n <p>Unable to load document</p>\n </div>\n </div>\n `;\n }\n\n return html`\n <div class=${classMap(containerClasses)} style=${styleMap(containerStyles)}>\n <iframe\n class=\"document-iframe\"\n src=${this.src}\n @error=${this.handleError}\n @load=${this.handleLoad}\n title=\"Document viewer\"\n ></iframe>\n ${this.previewable ? html`\n <button class=\"preview-button\" @click=${this.showPreviewModal}>\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\">\n <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\"/>\n <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\"/>\n </svg>\n Fullscreen\n </button>\n ` : ''}\n ${this.showPreview ? html`\n <div class=\"preview-modal\">\n <div class=\"preview-header\">\n <button class=\"preview-close\" @click=${this.closePreviewModal} aria-label=\"Close preview\">×</button>\n </div>\n <iframe src=${this.src} title=\"Document viewer fullscreen\"></iframe>\n </div>\n ` : ''}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nr-document': NrDocumentElement;\n }\n}\n"]}
|
package/document.style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.style.js","sourceRoot":"","sources":["
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+MjB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport default css`\n :host {\n display: block;\n }\n\n .document-container {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n position: relative;\n background-color: #f5f5f5;\n }\n\n .document-iframe {\n width: 100%;\n height: 100%;\n border: none;\n flex: 1;\n }\n\n .error-message {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding: 2rem;\n text-align: center;\n }\n\n .error-icon {\n width: 64px;\n height: 64px;\n margin-bottom: 1rem;\n }\n\n .preview-button {\n position: absolute;\n bottom: 10px;\n right: 10px;\n background-color: rgba(255, 255, 255, 0.9);\n border: 1px solid #ccc;\n border-radius: 4px;\n padding: 8px 12px;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 14px;\n z-index: 10;\n }\n\n .preview-button:hover {\n background-color: #fff;\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-modal iframe {\n width: 100%;\n height: 100%;\n border: none;\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: rgba(255, 255, 255, 0.9);\n border: none;\n border-radius: 50%;\n width: 32px;\n height: 32px;\n font-size: 24px;\n cursor: pointer;\n z-index: 1010;\n color: #333;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .preview-close:hover {\n background-color: #fff;\n color: #000;\n }\n\n .preview-header {\n position: absolute;\n top: 0;\n right: 0;\n z-index: 1010;\n padding: 10px;\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/document.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"document.types.js","sourceRoot":"","sources":["../../../../src/components/document/document.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\n/**\n * Document viewer type\n */\nexport const enum DocumentType {\n /** PDF document */\n PDF = 'pdf',\n /** Image document */\n Image = 'image',\n /** Other/unknown type */\n Other = 'other',\n}\n\n/**\n * Document fit mode\n */\nexport const enum DocumentFit {\n /** Fit to width */\n Width = 'width',\n /** Fit to height */\n Height = 'height',\n /** Fit to page */\n Page = 'page',\n /** Auto fit */\n Auto = 'auto',\n}\n\n/**\n * Document configuration interface\n */\nexport interface DocumentConfig {\n /** Document source URL */\n src: string;\n \n /** Document type */\n type?: DocumentType;\n \n /** Fallback document URL or image */\n fallback?: string;\n \n /** Document width */\n width?: string | number;\n \n /** Document height */\n height?: string | number;\n \n /** Whether document is previewable (fullscreen) */\n previewable?: boolean;\n \n /** Fit mode for document display */\n fit?: DocumentFit;\n \n /** Custom CSS class */\n customClass?: string;\n \n /** Callback when document loads */\n onLoad?: () => void;\n \n /** Callback when document fails to load */\n onError?: (error: Error) => void;\n}\n\n/**\n * Document event detail\n */\nexport interface DocumentEventDetail {\n /** Original event */\n originalEvent?: Event;\n \n /** Error message if applicable */\n error?: string;\n \n /** Document source */\n src?: string;\n \n /** Document type */\n type?: DocumentType;\n}\n"]}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/document/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './document.component.js';\nexport * from './document.types.js';\n"]}
|
package/package.json
CHANGED
package/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../../src/components/document/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;IACxC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,iBAAiB;IAC/B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN,MAAM,EAAE,kBAAkB;QAC1B,OAAO,EAAE,mBAAmB;QAC5B,aAAa,EAAE,0BAA0B;QACzC,cAAc,EAAE,2BAA2B;KAC5C;CACF,CAAC,CAAC","sourcesContent":["import { createComponent } from '@lit-labs/react';\nimport * as React from 'react';\nimport { NrDocumentElement } from './document.component.js';\n\nexport const NrDocument = createComponent({\n tagName: 'nr-document',\n elementClass: NrDocumentElement,\n react: React,\n events: {\n onLoad: 'nr-document-load',\n onError: 'nr-document-error',\n onPreviewOpen: 'nr-document-preview-open',\n onPreviewClose: 'nr-document-preview-close',\n },\n});\n"]}
|