diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 74f7ba1..9f06c55 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,17 +19,7 @@ jobs: node-version: 20 cache: 'npm' - run: npm ci - - run: (cd ./packages/block-avatar;npm ci) - - run: (cd ./packages/block-button;npm ci) - - run: (cd ./packages/block-divider;npm ci) - - run: (cd ./packages/block-heading;npm ci) - - run: (cd ./packages/block-html;npm ci) - - run: (cd ./packages/block-image;npm ci) - - run: (cd ./packages/block-spacer;npm ci) - - run: (cd ./packages/block-text;npm ci) - - run: (cd ./packages/document-core;npm ci) - - run: (cd ./packages/editor-sample;npm ci) - run: npx eslint . - run: npx prettier . --check - - run: npx tsc --noEmit + - run: bash scripts/check_typescript.sh - run: npm test diff --git a/packages/document-core/package-lock.json b/packages/document-core/package-lock.json index 2084bc5..a90cee9 100644 --- a/packages/document-core/package-lock.json +++ b/packages/document-core/package-lock.json @@ -1,12 +1,12 @@ { "name": "@usewaypoint/document-core", - "version": "0.0.1", + "version": "0.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@usewaypoint/document-core", - "version": "0.0.1", + "version": "0.0.2", "license": "MIT", "peerDependencies": { "react": "^16 || ^17 || ^18", diff --git a/packages/document-core/package.json b/packages/document-core/package.json index 20b3316..2689af6 100644 --- a/packages/document-core/package.json +++ b/packages/document-core/package.json @@ -1,6 +1,6 @@ { "name": "@usewaypoint/document-core", - "version": "0.0.1", + "version": "0.0.2", "description": "Tools to render waypoint-style documents (core package)", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/document-core/src/builders/buildBlockComponent.ts b/packages/document-core/src/builders/buildBlockComponent.tsx similarity index 85% rename from packages/document-core/src/builders/buildBlockComponent.ts rename to packages/document-core/src/builders/buildBlockComponent.tsx index 40879eb..c49b360 100644 --- a/packages/document-core/src/builders/buildBlockComponent.ts +++ b/packages/document-core/src/builders/buildBlockComponent.tsx @@ -8,6 +8,7 @@ import { BaseZodDictionary, BlockConfiguration, DocumentBlocksDictionary } from */ export default function buildBlockComponent(blocks: DocumentBlocksDictionary) { return function BlockComponent({ type, data }: BlockConfiguration) { - return React.createElement(blocks[type].Component, data); + const Component = blocks[type].Component; + return ; }; } diff --git a/packages/document-core/src/utils.ts b/packages/document-core/src/utils.ts index 2233974..78e2a24 100644 --- a/packages/document-core/src/utils.ts +++ b/packages/document-core/src/utils.ts @@ -1,11 +1,10 @@ -import React from 'react'; import { z } from 'zod'; export type BaseZodDictionary = { [name: string]: z.AnyZodObject }; export type DocumentBlocksDictionary = { [K in keyof T]: { schema: T[K]; - Component: (props: z.infer) => React.ReactNode; + Component: (props: z.infer) => JSX.Element; }; }; diff --git a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/SpacerSidebarPanel.tsx b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/SpacerSidebarPanel.tsx index b7fc53b..143ae32 100644 --- a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/SpacerSidebarPanel.tsx +++ b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/SpacerSidebarPanel.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import { HeightOutlined } from '@mui/icons-material'; -import { SpacerProps, SpacerPropsSchema } from '@usewaypoint/block-spacer'; +import { SpacerProps, SpacerPropsDefaults, SpacerPropsSchema } from '@usewaypoint/block-spacer'; import BaseSidebarPanel from './helpers/BaseSidebarPanel'; import SliderInput from './helpers/inputs/SliderInput'; @@ -32,7 +32,7 @@ export default function SpacerSidebarPanel({ data, setData }: SpacerSidebarPanel step={4} min={4} max={128} - defaultValue={data.props.height ?? 16} + defaultValue={data.props?.height ?? SpacerPropsDefaults.height} onChange={(height) => updateData({ ...data, props: { ...data.props, height } })} /> diff --git a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/TextSidebarPanel.tsx b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/TextSidebarPanel.tsx index ffd752b..126b60d 100644 --- a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/TextSidebarPanel.tsx +++ b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/TextSidebarPanel.tsx @@ -28,7 +28,7 @@ export default function TextSidebarPanel({ data, setData }: TextSidebarPanelProp updateData({ ...data, props: { ...data.props, text } })} /> diff --git a/packages/editor-sample/src/documents/blocks/helpers/block-wrappers/index.tsx b/packages/editor-sample/src/documents/blocks/helpers/block-wrappers/index.tsx index dd1b74d..e41c581 100644 --- a/packages/editor-sample/src/documents/blocks/helpers/block-wrappers/index.tsx +++ b/packages/editor-sample/src/documents/blocks/helpers/block-wrappers/index.tsx @@ -8,7 +8,7 @@ type TCommonProps = { style: Record; }; -export function addReaderBlockWrapper(ChildComponent: (props: TProps) => React.ReactNode) { +export function addReaderBlockWrapper(ChildComponent: (props: TProps) => JSX.Element) { return (props: TProps) => { return ( @@ -18,7 +18,7 @@ export function addReaderBlockWrapper(ChildComponen }; } -export function addEditorBlockWrapper(ChildComponent: (props: TProps) => React.ReactNode) { +export function addEditorBlockWrapper(ChildComponent: (props: TProps) => JSX.Element) { return (props: TProps) => { return ( diff --git a/packages/editor-sample/src/getConfiguration/sample/one-time-passcode.ts b/packages/editor-sample/src/getConfiguration/sample/one-time-passcode.ts index 83f361b..43bbd98 100644 --- a/packages/editor-sample/src/getConfiguration/sample/one-time-passcode.ts +++ b/packages/editor-sample/src/getConfiguration/sample/one-time-passcode.ts @@ -31,8 +31,6 @@ const ONE_TIME_PASSCODE: TEditorConfiguration = { textAlign: 'center', }, props: { - height: 24, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_jc7ZfPvdHJ6rtH1W/&.png', alt: '', linkHref: null, diff --git a/packages/editor-sample/src/getConfiguration/sample/order-ecommerce.ts b/packages/editor-sample/src/getConfiguration/sample/order-ecommerce.ts index 43088c3..1ce06a0 100644 --- a/packages/editor-sample/src/getConfiguration/sample/order-ecommerce.ts +++ b/packages/editor-sample/src/getConfiguration/sample/order-ecommerce.ts @@ -261,8 +261,6 @@ const ORDER_ECOMMERCE: TEditorConfiguration = { textAlign: 'left', }, props: { - height: null, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_FBfTeYhbdXtqYpCA/kiran-ck-6rXpQzfCYlw-unsplash.jpg', alt: '', linkHref: null, @@ -366,8 +364,6 @@ const ORDER_ECOMMERCE: TEditorConfiguration = { textAlign: 'left', }, props: { - height: null, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_vjmjV2NrQ52h1iLj/coupon.png', alt: '', linkHref: null, diff --git a/packages/editor-sample/src/getConfiguration/sample/post-metrics-report.ts b/packages/editor-sample/src/getConfiguration/sample/post-metrics-report.ts index b3b5c35..1821467 100644 --- a/packages/editor-sample/src/getConfiguration/sample/post-metrics-report.ts +++ b/packages/editor-sample/src/getConfiguration/sample/post-metrics-report.ts @@ -36,8 +36,6 @@ const POST_METRICS_REPORT: TEditorConfiguration = { textAlign: 'left', }, props: { - height: 16, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_n3eLjsf37dcjFaj5/Narrative.png', alt: '', linkHref: null, @@ -80,8 +78,7 @@ const POST_METRICS_REPORT: TEditorConfiguration = { size: 32, shape: 'circle', imageUrl: 'https://ui-avatars.com/api/?name=John+Doe', - fallbackText: 'Jordan', - fallbackColor: null, + alt: 'Jordan', }, }, }, diff --git a/packages/editor-sample/src/getConfiguration/sample/reservation-reminder.ts b/packages/editor-sample/src/getConfiguration/sample/reservation-reminder.ts index 59fc404..e40818a 100644 --- a/packages/editor-sample/src/getConfiguration/sample/reservation-reminder.ts +++ b/packages/editor-sample/src/getConfiguration/sample/reservation-reminder.ts @@ -42,8 +42,6 @@ const RESERVATION_REMINDER: TEditorConfiguration = { textAlign: 'left', }, props: { - height: 32, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_RAFATLGe3CN1wDsb/birdhouse.png', alt: '', linkHref: null, @@ -111,8 +109,7 @@ const RESERVATION_REMINDER: TEditorConfiguration = { size: 64, shape: 'circle', imageUrl: '', - fallbackText: 'Elaina', - fallbackColor: null, + alt: 'Elaina', }, }, }, @@ -305,8 +302,6 @@ const RESERVATION_REMINDER: TEditorConfiguration = { textAlign: 'left', }, props: { - height: null, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_QWeWcucRbjPqoewY/L1030293.jpg', alt: 'Photo', linkHref: 'https://example.usewaypoint.com/listings/r029348209842', diff --git a/packages/editor-sample/src/getConfiguration/sample/reset-password.ts b/packages/editor-sample/src/getConfiguration/sample/reset-password.ts index a0f70c8..136fedc 100644 --- a/packages/editor-sample/src/getConfiguration/sample/reset-password.ts +++ b/packages/editor-sample/src/getConfiguration/sample/reset-password.ts @@ -32,8 +32,6 @@ const RESET_PASSWORD: TEditorConfiguration = { textAlign: 'left', }, props: { - height: 40, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_w9brVHZobEBhsJSK/marketbase.png', alt: '', linkHref: null, diff --git a/packages/editor-sample/src/getConfiguration/sample/respond-to-message.ts b/packages/editor-sample/src/getConfiguration/sample/respond-to-message.ts index 57d5d3c..96087f0 100644 --- a/packages/editor-sample/src/getConfiguration/sample/respond-to-message.ts +++ b/packages/editor-sample/src/getConfiguration/sample/respond-to-message.ts @@ -32,8 +32,6 @@ const RESPOND_TO_MESSAGE: TEditorConfiguration = { textAlign: null, }, props: { - height: 32, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_hW6RusynHUNTKoLm/boop.png', alt: '', linkHref: null, diff --git a/packages/editor-sample/src/getConfiguration/sample/subscription-receipt.ts b/packages/editor-sample/src/getConfiguration/sample/subscription-receipt.ts index 8681329..f54bb62 100644 --- a/packages/editor-sample/src/getConfiguration/sample/subscription-receipt.ts +++ b/packages/editor-sample/src/getConfiguration/sample/subscription-receipt.ts @@ -31,8 +31,6 @@ const SUBSCRIPTION_RECEIPT: TEditorConfiguration = { textAlign: 'left', }, props: { - height: 18, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_9TcdHLq5SpEkRADB/REMIX.png', alt: 'Remix', linkHref: 'https://remix.example.com', @@ -297,8 +295,6 @@ const SUBSCRIPTION_RECEIPT: TEditorConfiguration = { textAlign: 'left', }, props: { - height: null, - width: null, url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_8yUGBZcXaAtTEofB/invoice-skeleton.png', alt: 'Your invoice has been paid.', linkHref: 'http://remix.example.com/receipt/1923-2093', diff --git a/scripts/check_typescript.sh b/scripts/check_typescript.sh new file mode 100644 index 0000000..a12bf3d --- /dev/null +++ b/scripts/check_typescript.sh @@ -0,0 +1,10 @@ +(cd ./packages/block-avatar;npm ci;tsc --noEmit) +(cd ./packages/block-button;npm ci;tsc --noEmit) +(cd ./packages/block-divider;npm ci;tsc --noEmit) +(cd ./packages/block-heading;npm ci;tsc --noEmit) +(cd ./packages/block-html;npm ci;tsc --noEmit) +(cd ./packages/block-image;npm ci;tsc --noEmit) +(cd ./packages/block-spacer;npm ci;tsc --noEmit) +(cd ./packages/block-text;npm ci;tsc --noEmit) +(cd ./packages/document-core;npm ci;tsc --noEmit) +(cd ./packages/editor-sample;npm ci;tsc --noEmit)