From 9241971e9e6ab008c5d9bb0d03caae4784d6c207 Mon Sep 17 00:00:00 2001 From: hand-dot Date: Sun, 10 May 2026 08:06:54 +0900 Subject: [PATCH] style: format codebase --- packages/jsx/src/render.ts | 55 +++--- playground/e2e/index.test.ts | 80 +++++---- .../src/components/PlaygroundButton.tsx | 42 +++-- playground/src/routes/Designer.tsx | 157 +++++++++--------- playground/src/routes/FormAndViewer.tsx | 8 +- playground/src/routes/JsxPlayground.tsx | 2 +- playground/src/routes/Md2Pdf.tsx | 4 +- 7 files changed, 182 insertions(+), 166 deletions(-) diff --git a/packages/jsx/src/render.ts b/packages/jsx/src/render.ts index b265b35e..54a609b1 100644 --- a/packages/jsx/src/render.ts +++ b/packages/jsx/src/render.ts @@ -349,35 +349,36 @@ const layoutStaticBlocks = async (arg: { _cache: Map; }) => { const contentWidth = Math.max(0, arg.pageSize.width - arg.margin.left - arg.margin.right); - const blockFrames: Array<{ children: PdfJsxChild[]; frame: Rect; placement?: StaticPlacement }> = [ - { - children: arg.blocks.staticTop, - frame: { x: 0, y: 0, width: arg.pageSize.width, height: arg.pageSize.height }, - }, - { - children: arg.blocks.header, - frame: { - x: arg.margin.left, - y: 0, - width: contentWidth, - height: arg.margin.top, + const blockFrames: Array<{ children: PdfJsxChild[]; frame: Rect; placement?: StaticPlacement }> = + [ + { + children: arg.blocks.staticTop, + frame: { x: 0, y: 0, width: arg.pageSize.width, height: arg.pageSize.height }, }, - }, - { - children: arg.blocks.footer, - frame: { - x: arg.margin.left, - y: arg.pageSize.height - arg.margin.bottom, - width: contentWidth, - height: arg.margin.bottom, + { + children: arg.blocks.header, + frame: { + x: arg.margin.left, + y: 0, + width: contentWidth, + height: arg.margin.top, + }, }, - }, - { - children: arg.blocks.staticBottom, - frame: { x: 0, y: 0, width: arg.pageSize.width, height: arg.pageSize.height }, - placement: 'bottom', - }, - ]; + { + children: arg.blocks.footer, + frame: { + x: arg.margin.left, + y: arg.pageSize.height - arg.margin.bottom, + width: contentWidth, + height: arg.margin.bottom, + }, + }, + { + children: arg.blocks.staticBottom, + frame: { x: 0, y: 0, width: arg.pageSize.width, height: arg.pageSize.height }, + placement: 'bottom', + }, + ]; for (const { children, frame, placement } of blockFrames) { if (children.length === 0) continue; diff --git a/playground/e2e/index.test.ts b/playground/e2e/index.test.ts index ab80ef74..61a3483d 100644 --- a/playground/e2e/index.test.ts +++ b/playground/e2e/index.test.ts @@ -1,6 +1,12 @@ import puppeteer, { Browser, Page } from 'puppeteer'; import { pdf2img } from '@pdfme/converter'; -import { Template, Schema, PAGE_SIZE_PRESETS, cloneDeep, getInputFromTemplate } from '@pdfme/common'; +import { + Template, + Schema, + PAGE_SIZE_PRESETS, + cloneDeep, + getInputFromTemplate, +} from '@pdfme/common'; import { text, table, image, barcodes, select, checkbox, radioGroup } from '@pdfme/schemas'; import { ChildProcessWithoutNullStreams, spawn } from 'node:child_process'; import { stripVTControlCharacters } from 'node:util'; @@ -240,38 +246,47 @@ async function loadRouteWithStorage( storageState: PlaygroundStorageState, ) { const projectId = 'project_e2e_deterministic_template'; - const inputs = storageState.inputs ?? (storageState.template ? getInputFromTemplate(storageState.template) : []); + const inputs = + storageState.inputs ?? + (storageState.template ? getInputFromTemplate(storageState.template) : []); await page.goto(baseUrl, { waitUntil: 'networkidle2', timeout }); - await page.evaluate((state, resolvedInputs, id, projectsStorageKey, activeProjectStorageKey) => { - localStorage.removeItem('template'); - localStorage.removeItem('inputs'); - localStorage.removeItem('mode'); - localStorage.removeItem(projectsStorageKey); - localStorage.removeItem(activeProjectStorageKey); + await page.evaluate( + (state, resolvedInputs, id, projectsStorageKey, activeProjectStorageKey) => { + localStorage.removeItem('template'); + localStorage.removeItem('inputs'); + localStorage.removeItem('mode'); + localStorage.removeItem(projectsStorageKey); + localStorage.removeItem(activeProjectStorageKey); - if (state.template) { - const now = Date.now(); - localStorage.setItem( - projectsStorageKey, - JSON.stringify([ - { - createdAt: now, - id, - inputs: resolvedInputs, - kind: 'template', - template: state.template, - title: 'E2E deterministic template', - updatedAt: now, - }, - ]), - ); - localStorage.setItem(activeProjectStorageKey, id); - } - if (state.mode) { - localStorage.setItem('mode', state.mode); - } - }, storageState, inputs, projectId, playgroundProjectsStorageKey, activePlaygroundProjectStorageKey); + if (state.template) { + const now = Date.now(); + localStorage.setItem( + projectsStorageKey, + JSON.stringify([ + { + createdAt: now, + id, + inputs: resolvedInputs, + kind: 'template', + template: state.template, + title: 'E2E deterministic template', + updatedAt: now, + }, + ]), + ); + localStorage.setItem(activeProjectStorageKey, id); + } + if (state.mode) { + localStorage.setItem('mode', state.mode); + } + }, + storageState, + inputs, + projectId, + playgroundProjectsStorageKey, + activePlaygroundProjectStorageKey, + ); await page.goto(`${baseUrl}${path}?project=${encodeURIComponent(projectId)}`, { waitUntil: 'networkidle2', @@ -492,7 +507,10 @@ describe('Playground E2E Tests', () => { if (!browser || !page) throw new Error('Browser/Page not initialized'); // 5. Load the Pedigree designer directly to avoid flaky list-page navigation in CI - await page.goto(`${baseUrl}/designer?template=pedigree`, { waitUntil: 'networkidle2', timeout }); + await page.goto(`${baseUrl}/designer?template=pedigree`, { + waitUntil: 'networkidle2', + timeout, + }); await waitForDesignerReady(page, 'Pet Name'); diff --git a/playground/src/components/PlaygroundButton.tsx b/playground/src/components/PlaygroundButton.tsx index 981ded14..c335f47c 100644 --- a/playground/src/components/PlaygroundButton.tsx +++ b/playground/src/components/PlaygroundButton.tsx @@ -18,29 +18,25 @@ const buttonVariants: Record = { const joinClassNames = (...classes: Array) => classes.filter(Boolean).join(' '); -const PlaygroundButton = forwardRef(function PlaygroundButton( - { - className, - fullWidth = false, - type = 'button', - variant = 'secondary', - ...props +const PlaygroundButton = forwardRef( + function PlaygroundButton( + { className, fullWidth = false, type = 'button', variant = 'secondary', ...props }, + ref, + ) { + return ( +