@things-factory/pdf 10.1.176 → 10.1.179
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-client/pages/pdf-template/pdf-template-editor.d.ts +1 -0
- package/dist-client/pages/pdf-template/pdf-template-editor.js +11 -3
- package/dist-client/pages/pdf-template/pdf-template-editor.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/translations/en.json +2 -1
- package/translations/es.json +2 -1
- package/translations/ja.json +2 -1
- package/translations/ko.json +2 -1
- package/translations/ms.json +2 -1
- package/translations/zh.json +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@operato/input/ox-input-file.js';
|
|
2
3
|
import '@operato/list-state/ox-page-state.js';
|
|
3
4
|
import { client } from '@operato/graphql';
|
|
4
5
|
import { i18next, localize } from '@operato/i18n';
|
|
@@ -127,8 +128,8 @@ let PDFTemplateEditor = class PDFTemplateEditor extends localize(i18next)(PageVi
|
|
|
127
128
|
this.preview = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }));
|
|
128
129
|
});
|
|
129
130
|
}
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
/* Read here into the part's text, never uploaded: the picker is local and checks the type only. */
|
|
132
|
+
async load(key, file) {
|
|
132
133
|
if (file)
|
|
133
134
|
this.form = { ...this.form, [key]: await file.text() };
|
|
134
135
|
}
|
|
@@ -138,7 +139,14 @@ let PDFTemplateEditor = class PDFTemplateEditor extends localize(i18next)(PageVi
|
|
|
138
139
|
const part = (key, label, wide = '') => html `<label class="wide"
|
|
139
140
|
>${label}
|
|
140
141
|
<textarea class=${wide} .value=${this.form[key] ?? ''} @input=${(e) => patch(key, e.target.value)}></textarea>
|
|
141
|
-
<input
|
|
142
|
+
<ox-input-file
|
|
143
|
+
quiet
|
|
144
|
+
local
|
|
145
|
+
hide-filelist
|
|
146
|
+
accept=".html,.htm,text/html"
|
|
147
|
+
.label=${i18next.t('button.load-html-file')}
|
|
148
|
+
@change=${(e) => this.load(key, e.detail?.[0])}
|
|
149
|
+
></ox-input-file>
|
|
142
150
|
</label>`;
|
|
143
151
|
return html `<div class="page">
|
|
144
152
|
${this.failure ? html `<p class="notice crit" role="alert">${this.failure}</p>` : nothing}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-template-editor.js","sourceRoot":"","sources":["../../../client/pages/pdf-template/pdf-template-editor.ts"],"names":[],"mappings":";AAAA,OAAO,sCAAsC,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACnF,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,MAAM,MAAM,GAAG,oIAAoI,CAAA;AACnJ,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AACnE,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe,EAAE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@operato/i18n'\nimport { navigate, PageView } from '@operato/shell'\nimport { ButtonStyles, DocumentPageStyles, FormFieldStyles } from '@operato/styles'\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nconst FIELDS = 'id name description active state page_size watermark content_template header_template footer_template cover_template last_template'\nconst PAGE_SIZES = ['A4', 'A3', 'A5', 'Letter', 'Legal', 'Tabloid']\nconst blank = () => ({ name: '', description: '', active: true, state: 'draft', page_size: 'A4', watermark: '', content_template: '', header_template: '', footer_template: '', cover_template: '', last_template: '' })\n\n/**\n * One PDF template: its parts are Handlebars HTML, written here or loaded from a file, and printed to a PDF with\n * sample data before it is used.\n */\n@customElement('pdf-template-editor')\nexport class PDFTemplateEditor extends localize(i18next)(PageView) {\n static styles = [\n DocumentPageStyles,\n FormFieldStyles,\n ButtonStyles,\n css`\n .form {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));\n gap: var(--spacing-large);\n }\n label {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small);\n }\n label.wide {\n grid-column: 1 / -1;\n }\n textarea {\n font-family: monospace;\n min-height: 12em;\n }\n textarea.content {\n min-height: 40vh;\n }\n iframe {\n width: 100%;\n height: 80vh;\n border: 1px solid var(--md-sys-color-outline-variant);\n }\n `\n ]\n\n @state() private templateId = ''\n @state() private form: Record<string, any> = blank()\n @state() private sample = '{}'\n @state() private preview = ''\n @state() private busy = false\n @state() private failure = ''\n\n get context() {\n return {\n title: i18next.t('title.pdf-template'),\n menu: 'pdf-template-list-page',\n frame: 'document',\n actions: this.busy ? [] : [{ title: i18next.t('button.save'), icon: 'save', emphasis: { raised: true }, action: () => this.save() }]\n }\n }\n\n pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n this.templateId = lifecycle?.params?.id ?? ''\n this.form = blank()\n this.preview = ''\n if (this.templateId) this.read()\n }\n\n private async read() {\n const response = await client.query({ query: gql(`query ($id: String!) { PDFTemplate(id: $id) { ${FIELDS} } }`), variables: { id: this.templateId }, fetchPolicy: 'no-cache' })\n const { id, ...template } = response.data?.PDFTemplate ?? {}\n if (id) this.form = { ...blank(), ...Object.fromEntries(Object.entries(template).map(([key, value]) => [key, value ?? ''])) }\n }\n\n private async run(work: () => Promise<void>) {\n if (this.busy) return\n this.busy = true\n this.failure = ''\n this.updateContext()\n try {\n await work()\n } catch (error: any) {\n this.failure = error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error)\n } finally {\n this.busy = false\n this.updateContext()\n }\n }\n\n private save() {\n return this.run(async () => {\n const id = this.templateId\n const response = await client.mutate({\n mutation: gql(\n id\n ? `mutation ($id: String!, $patch: PDFTemplatePatch!) { template: updatePDFTemplate(id: $id, patch: $patch) { id } }`\n : `mutation ($template: NewPDFTemplate!) { template: createPDFTemplate(pdfTemplate: $template) { id } }`\n ),\n variables: id ? { id, patch: this.form } : { template: this.form }\n })\n if (response.errors?.length) throw response\n if (!id) navigate(`pdf-template-editor?id=${response.data.template.id}`)\n })\n }\n\n /** The saved template printed with the sample data — save first to see a change. */\n private showPreview() {\n if (this.preview) {\n URL.revokeObjectURL(this.preview)\n this.preview = ''\n return\n }\n return this.run(async () => {\n const data = JSON.parse(this.sample || '{}')\n const response = await client.query({ query: gql`query ($id: String!, $data: Object) { renderPDF(templateId: $id, data: $data) }`, variables: { id: this.templateId, data }, fetchPolicy: 'no-cache' })\n if (response.errors?.length) throw response\n const bytes = Uint8Array.from(atob(response.data.renderPDF), c => c.charCodeAt(0))\n this.preview = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }))\n })\n }\n\n private async load(key: string, e: Event) {\n const file = (e.target as HTMLInputElement).files?.[0]\n if (file) this.form = { ...this.form, [key]: await file.text() }\n }\n\n render() {\n const patch = (key: string, value: any) => (this.form = { ...this.form, [key]: value })\n const text = (key: string, label: string) => html`<label>${label}<input .value=${this.form[key] ?? ''} @input=${(e: any) => patch(key, e.target.value)} /></label>`\n const part = (key: string, label: string, wide = '') => html`<label class=\"wide\"\n >${label}\n <textarea class=${wide} .value=${this.form[key] ?? ''} @input=${(e: any) => patch(key, e.target.value)}></textarea>\n <input type=\"file\" accept=\".html,.htm,text/html\" @change=${(e: Event) => this.load(key, e)} />\n </label>`\n return html`<div class=\"page\">\n ${this.failure ? html`<p class=\"notice crit\" role=\"alert\">${this.failure}</p>` : nothing}\n <section class=\"page-section\">\n <div class=\"form\">\n ${text('name', i18next.t('field.name'))}${text('description', i18next.t('field.description'))}\n <label\n >${i18next.t('field.page_size')}\n <select .value=${this.form.page_size} @change=${(e: any) => patch('page_size', e.target.value)}>\n ${PAGE_SIZES.map(size => html`<option value=${size} ?selected=${size === this.form.page_size}>${size}</option>`)}\n </select></label\n >\n ${text('watermark', i18next.t('field.watermark'))}\n ${part('content_template', i18next.t('field.content_template'), 'content')}${part('header_template', i18next.t('field.header_template'))}${part('footer_template', i18next.t('field.footer_template'))}${part('cover_template', i18next.t('field.cover_template'))}${part('last_template', i18next.t('field.last_template'))}\n </div>\n </section>\n ${this.templateId\n ? html`<section class=\"page-section\">\n <div class=\"form\">\n <label class=\"wide\">${i18next.t('field.pdf-sample-data')}<textarea .value=${this.sample} @input=${(e: any) => (this.sample = e.target.value)}></textarea></label>\n </div>\n <button ?disabled=${this.busy} @click=${() => this.showPreview()}>${i18next.t('button.pdf-preview')}</button>\n ${this.preview ? html`<iframe title=${i18next.t('button.pdf-preview')} src=${this.preview}></iframe>` : nothing}\n </section>`\n : nothing}\n </div>`\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pdf-template-editor.js","sourceRoot":"","sources":["../../../client/pages/pdf-template/pdf-template-editor.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,sCAAsC,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAA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AAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;;gCAE1H,IAAI,CAAC,IAAI,WAAW,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC;cACjG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,iBAAiB,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,QAAQ,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,OAAO;qBACtG;YACb,CAAC,CAAC,OAAO;WACN,CAAA;IACT,CAAC;;AA1HgB;IAAhB,KAAK,EAAE;;qDAAwB;AACf;IAAhB,KAAK,EAAE;;+CAA4C;AACnC;IAAhB,KAAK,EAAE;;iDAAsB;AACb;IAAhB,KAAK,EAAE;;kDAAqB;AACZ;IAAhB,KAAK,EAAE;;+CAAqB;AACZ;IAAhB,KAAK,EAAE;;kDAAqB;AAvClB,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CA6J7B","sourcesContent":["import '@operato/input/ox-input-file.js'\nimport '@operato/list-state/ox-page-state.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView } from '@operato/shell'\nimport { ButtonStyles, DocumentPageStyles, FormFieldStyles } from '@operato/styles'\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nconst FIELDS = 'id name description active state page_size watermark content_template header_template footer_template cover_template last_template'\nconst PAGE_SIZES = ['A4', 'A3', 'A5', 'Letter', 'Legal', 'Tabloid']\nconst blank = () => ({ name: '', description: '', active: true, state: 'draft', page_size: 'A4', watermark: '', content_template: '', header_template: '', footer_template: '', cover_template: '', last_template: '' })\n\n/**\n * One PDF template: its parts are Handlebars HTML, written here or loaded from a file, and printed to a PDF with\n * sample data before it is used.\n */\n@customElement('pdf-template-editor')\nexport class PDFTemplateEditor extends localize(i18next)(PageView) {\n static styles = [\n DocumentPageStyles,\n FormFieldStyles,\n ButtonStyles,\n css`\n .form {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));\n gap: var(--spacing-large);\n }\n label {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small);\n }\n label.wide {\n grid-column: 1 / -1;\n }\n textarea {\n font-family: monospace;\n min-height: 12em;\n }\n textarea.content {\n min-height: 40vh;\n }\n iframe {\n width: 100%;\n height: 80vh;\n border: 1px solid var(--md-sys-color-outline-variant);\n }\n `\n ]\n\n @state() private templateId = ''\n @state() private form: Record<string, any> = blank()\n @state() private sample = '{}'\n @state() private preview = ''\n @state() private busy = false\n @state() private failure = ''\n\n get context() {\n return {\n title: i18next.t('title.pdf-template'),\n menu: 'pdf-template-list-page',\n frame: 'document',\n actions: this.busy ? [] : [{ title: i18next.t('button.save'), icon: 'save', emphasis: { raised: true }, action: () => this.save() }]\n }\n }\n\n pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n this.templateId = lifecycle?.params?.id ?? ''\n this.form = blank()\n this.preview = ''\n if (this.templateId) this.read()\n }\n\n private async read() {\n const response = await client.query({ query: gql(`query ($id: String!) { PDFTemplate(id: $id) { ${FIELDS} } }`), variables: { id: this.templateId }, fetchPolicy: 'no-cache' })\n const { id, ...template } = response.data?.PDFTemplate ?? {}\n if (id) this.form = { ...blank(), ...Object.fromEntries(Object.entries(template).map(([key, value]) => [key, value ?? ''])) }\n }\n\n private async run(work: () => Promise<void>) {\n if (this.busy) return\n this.busy = true\n this.failure = ''\n this.updateContext()\n try {\n await work()\n } catch (error: any) {\n this.failure = error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error)\n } finally {\n this.busy = false\n this.updateContext()\n }\n }\n\n private save() {\n return this.run(async () => {\n const id = this.templateId\n const response = await client.mutate({\n mutation: gql(\n id\n ? `mutation ($id: String!, $patch: PDFTemplatePatch!) { template: updatePDFTemplate(id: $id, patch: $patch) { id } }`\n : `mutation ($template: NewPDFTemplate!) { template: createPDFTemplate(pdfTemplate: $template) { id } }`\n ),\n variables: id ? { id, patch: this.form } : { template: this.form }\n })\n if (response.errors?.length) throw response\n if (!id) navigate(`pdf-template-editor?id=${response.data.template.id}`)\n })\n }\n\n /** The saved template printed with the sample data — save first to see a change. */\n private showPreview() {\n if (this.preview) {\n URL.revokeObjectURL(this.preview)\n this.preview = ''\n return\n }\n return this.run(async () => {\n const data = JSON.parse(this.sample || '{}')\n const response = await client.query({ query: gql`query ($id: String!, $data: Object) { renderPDF(templateId: $id, data: $data) }`, variables: { id: this.templateId, data }, fetchPolicy: 'no-cache' })\n if (response.errors?.length) throw response\n const bytes = Uint8Array.from(atob(response.data.renderPDF), c => c.charCodeAt(0))\n this.preview = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }))\n })\n }\n\n /* Read here into the part's text, never uploaded: the picker is local and checks the type only. */\n private async load(key: string, file?: File) {\n if (file) this.form = { ...this.form, [key]: await file.text() }\n }\n\n render() {\n const patch = (key: string, value: any) => (this.form = { ...this.form, [key]: value })\n const text = (key: string, label: string) => html`<label>${label}<input .value=${this.form[key] ?? ''} @input=${(e: any) => patch(key, e.target.value)} /></label>`\n const part = (key: string, label: string, wide = '') => html`<label class=\"wide\"\n >${label}\n <textarea class=${wide} .value=${this.form[key] ?? ''} @input=${(e: any) => patch(key, e.target.value)}></textarea>\n <ox-input-file\n quiet\n local\n hide-filelist\n accept=\".html,.htm,text/html\"\n .label=${i18next.t('button.load-html-file')}\n @change=${(e: CustomEvent) => this.load(key, e.detail?.[0])}\n ></ox-input-file>\n </label>`\n return html`<div class=\"page\">\n ${this.failure ? html`<p class=\"notice crit\" role=\"alert\">${this.failure}</p>` : nothing}\n <section class=\"page-section\">\n <div class=\"form\">\n ${text('name', i18next.t('field.name'))}${text('description', i18next.t('field.description'))}\n <label\n >${i18next.t('field.page_size')}\n <select .value=${this.form.page_size} @change=${(e: any) => patch('page_size', e.target.value)}>\n ${PAGE_SIZES.map(size => html`<option value=${size} ?selected=${size === this.form.page_size}>${size}</option>`)}\n </select></label\n >\n ${text('watermark', i18next.t('field.watermark'))}\n ${part('content_template', i18next.t('field.content_template'), 'content')}${part('header_template', i18next.t('field.header_template'))}${part('footer_template', i18next.t('field.footer_template'))}${part('cover_template', i18next.t('field.cover_template'))}${part('last_template', i18next.t('field.last_template'))}\n </div>\n </section>\n ${this.templateId\n ? html`<section class=\"page-section\">\n <div class=\"form\">\n <label class=\"wide\">${i18next.t('field.pdf-sample-data')}<textarea .value=${this.sample} @input=${(e: any) => (this.sample = e.target.value)}></textarea></label>\n </div>\n <button ?disabled=${this.busy} @click=${() => this.showPreview()}>${i18next.t('button.pdf-preview')}</button>\n ${this.preview ? html`<iframe title=${i18next.t('button.pdf-preview')} src=${this.preview}></iframe>` : nothing}\n </section>`\n : nothing}\n </div>`\n }\n}\n"]}
|