@page-speed/forms 0.1.8 → 0.2.0

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.
@@ -155,7 +155,7 @@ function deserializeErrors(railsErrors) {
155
155
  }
156
156
  return formErrors;
157
157
  }
158
- var ChaiBlockErrorBoundary = class extends React__namespace.Component {
158
+ var BlockErrorBoundary = class extends React__namespace.Component {
159
159
  constructor(props) {
160
160
  super(props);
161
161
  this.state = { error: null };
@@ -164,7 +164,7 @@ var ChaiBlockErrorBoundary = class extends React__namespace.Component {
164
164
  return { error };
165
165
  }
166
166
  componentDidCatch(error, errorInfo) {
167
- console.error(`ChaiBlock render error (${this.props.block._id}):`, error, errorInfo);
167
+ console.error(`Block render error (${this.props.block._id}):`, error, errorInfo);
168
168
  }
169
169
  render() {
170
170
  if (this.state.error) {
@@ -174,7 +174,7 @@ var ChaiBlockErrorBoundary = class extends React__namespace.Component {
174
174
  return /* @__PURE__ */ React__namespace.createElement(
175
175
  "div",
176
176
  {
177
- className: "chai-block-error border border-red-300 bg-red-50 p-4 rounded text-red-700",
177
+ className: "block-error border border-red-300 bg-red-50 p-4 rounded text-red-700",
178
178
  "data-block-id": this.props.block._id,
179
179
  "data-block-type": this.props.block._type
180
180
  },
@@ -186,7 +186,7 @@ var ChaiBlockErrorBoundary = class extends React__namespace.Component {
186
186
  return this.props.children;
187
187
  }
188
188
  };
189
- function createChaiBlockAdapter(Component2, options = {}) {
189
+ function createBlockAdapter(Component2, options = {}) {
190
190
  const {
191
191
  defaultProps = {},
192
192
  transformProps,
@@ -209,12 +209,12 @@ function createChaiBlockAdapter(Component2, options = {}) {
209
209
  const renderedChildren = renderChildren ? renderChildren(block._id) : children;
210
210
  const element = /* @__PURE__ */ React__namespace.createElement(Component2, { ...componentProps }, renderedChildren);
211
211
  if (withErrorBoundary) {
212
- return /* @__PURE__ */ React__namespace.createElement(ChaiBlockErrorBoundary, { block, fallback: errorFallback }, element);
212
+ return /* @__PURE__ */ React__namespace.createElement(BlockErrorBoundary, { block, fallback: errorFallback }, element);
213
213
  }
214
214
  return element;
215
215
  };
216
216
  const componentName = Component2.displayName || Component2.name || "Component";
217
- AdaptedComponent.displayName = `ChaiBlockAdapter(${componentName})`;
217
+ AdaptedComponent.displayName = `BlockAdapter(${componentName})`;
218
218
  return AdaptedComponent;
219
219
  }
220
220
  function standardInputTransformer(blockProps, block) {
@@ -222,20 +222,20 @@ function standardInputTransformer(blockProps, block) {
222
222
  ...blockProps,
223
223
  // Use content as label if not already provided
224
224
  ...block.content && !blockProps.label && { label: block.content },
225
- // Apply ChaiBlock styles as className
225
+ // Apply Block styles as className
226
226
  ...block.styles && { className: block.styles }
227
227
  };
228
228
  }
229
- function createChaiBlockAdapters(components, options = {}) {
229
+ function createBlockAdapters(components, options = {}) {
230
230
  const adapted = {};
231
231
  for (const [name, component] of Object.entries(components)) {
232
- adapted[name] = createChaiBlockAdapter(component, options);
232
+ adapted[name] = createBlockAdapter(component, options);
233
233
  }
234
234
  return adapted;
235
235
  }
236
236
 
237
- exports.createChaiBlockAdapter = createChaiBlockAdapter;
238
- exports.createChaiBlockAdapters = createChaiBlockAdapters;
237
+ exports.createBlockAdapter = createBlockAdapter;
238
+ exports.createBlockAdapters = createBlockAdapters;
239
239
  exports.deserializeErrors = deserializeErrors;
240
240
  exports.serializeForRails = serializeForRails;
241
241
  exports.standardInputTransformer = standardInputTransformer;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/integration/ContactFormSerializer.ts","../src/integration/ChaiBlockAdapter.tsx"],"names":["camelField","errorMessage","React","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAM,eAAA,GAAkB;AAAA,EACtB,SAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA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AAM,OAAA,IAAW,CAAC,WAAW,KAAA,IAAS,EAAE,KAAA,EAAO,KAAA,CAAM,OAAA,EAAQ;AAAA;AAAA,IAEjE,GAAI,KAAA,CAAM,MAAA,IAAU,EAAE,SAAA,EAAW,MAAM,MAAA;AAAO,GAChD;AACF;AAiCO,SAAS,uBAAA,CAGd,UAAA,EACA,OAAA,GAAmC,EAAC,EACmC;AACvE,EAAA,MAAM,UAAsE,EAAC;AAE7E,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,SAAS,KAAK,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAA,EAAG;AAC1D,IAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,sBAAA,CAAuB,SAAA,EAAW,OAAO,CAAA;AAAA,EAC3D;AAEA,EAAA,OAAO,OAAA;AACT","file":"integration.cjs","sourcesContent":["/**\n * @page-speed/forms - Rails API Serializer\n *\n * Serializes form data for the DashTrack ContactsController API.\n * Handles field name conversion (camelCase → snake_case), custom fields separation,\n * and upload token arrays.\n *\n * @see https://github.com/opensite-ai/page-speed-forms\n */\n\n/**\n * Standard fields recognized by the Rails ContactsController API.\n * These are serialized to snake_case and sent in the contact object.\n */\nconst STANDARD_FIELDS = [\n \"content\",\n \"email\",\n \"firstName\",\n \"lastName\",\n \"locationId\",\n \"phone\",\n \"subject\",\n \"redemptionStatus\",\n \"birthday\",\n \"city\",\n \"state\",\n \"websiteFormAssignmentId\",\n \"websiteId\",\n \"acceptsSmsMarketing\",\n \"acceptsEmailMarketing\",\n \"visitorIpAddress\",\n] as const;\n\n/**\n * Configuration parameters for Rails API submission.\n */\nexport interface RailsApiConfig {\n /**\n * API key for authentication.\n * Sent as top-level parameter: api_key\n */\n apiKey: string;\n\n /**\n * Contact category token for categorization.\n * Sent as top-level parameter: contact_category_token\n */\n contactCategoryToken?: string;\n\n /**\n * Location ID for multi-location organizations.\n * Sent as top-level parameter: location_id\n */\n locationId?: string;\n\n /**\n * Website ID for tracking form submissions.\n * Sent within contact object: website_id\n */\n websiteId?: string;\n\n /**\n * Website form assignment ID for form tracking.\n * Sent within contact object: website_form_assignment_id\n */\n websiteFormAssignmentId?: string;\n\n /**\n * Visitor IP address. If not provided, will be auto-detected on server.\n * Sent within contact object: visitor_ip_address\n */\n visitorIpAddress?: string;\n}\n\n/**\n * Serialized form data ready for Rails API submission.\n */\nexport interface SerializedFormData {\n /**\n * Top-level API key parameter.\n */\n api_key: string;\n\n /**\n * Top-level contact category token (optional).\n */\n contact_category_token?: string;\n\n /**\n * Top-level location ID (optional).\n */\n location_id?: string;\n\n /**\n * Contact object with standard fields and metadata.\n */\n contact: {\n /**\n * Standard contact fields in snake_case.\n */\n [key: string]: unknown;\n\n /**\n * Custom fields that don't match standard schema.\n * Stored as separate hash in Rails.\n */\n custom_fields?: Record<string, unknown>;\n\n /**\n * Array of upload tokens from file uploads.\n * These reference ContactFormUpload records in Rails.\n */\n contact_form_upload_tokens?: string[];\n };\n}\n\n/**\n * Form values from the form library (camelCase keys).\n */\nexport type FormValues = Record<string, unknown>;\n\n/**\n * Convert camelCase to snake_case.\n *\n * @example\n * ```ts\n * camelToSnake(\"firstName\") // \"first_name\"\n * camelToSnake(\"acceptsSmsMarketing\") // \"accepts_sms_marketing\"\n * ```\n */\nfunction camelToSnake(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);\n}\n\n/**\n * Check if a field name is a standard Rails contact field.\n */\nfunction isStandardField(fieldName: string): boolean {\n return STANDARD_FIELDS.includes(fieldName as (typeof STANDARD_FIELDS)[number]);\n}\n\n/**\n * Extract upload tokens from form values.\n * Handles both string tokens and arrays of tokens.\n */\nfunction extractUploadTokens(values: FormValues): string[] {\n const tokens: string[] = [];\n\n for (const value of Object.values(values)) {\n if (typeof value === \"string\" && value.startsWith(\"upload_\")) {\n tokens.push(value);\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (typeof item === \"string\" && item.startsWith(\"upload_\")) {\n tokens.push(item);\n }\n }\n }\n }\n\n return tokens;\n}\n\n/**\n * Format date/time values for Rails API.\n * Rails expects ISO 8601 format.\n */\nfunction formatDateForRails(value: unknown): string | undefined {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (typeof value === \"string\") {\n // Attempt to parse and reformat to ensure valid ISO 8601\n const date = new Date(value);\n if (!isNaN(date.getTime())) {\n return date.toISOString();\n }\n }\n return undefined;\n}\n\n/**\n * Serialize form values for Rails ContactsController API.\n *\n * This function:\n * 1. Converts camelCase field names to snake_case\n * 2. Separates standard fields from custom fields\n * 3. Extracts upload tokens into contact_form_upload_tokens array\n * 4. Formats dates to ISO 8601\n * 5. Includes API configuration parameters\n *\n * @param values - Form values from useForm hook (camelCase keys)\n * @param config - Rails API configuration (apiKey, locationId, etc.)\n * @returns Serialized data ready for POST to /contacts\n *\n * @example\n * ```ts\n * const serialized = serializeForRails(\n * {\n * firstName: \"John\",\n * lastName: \"Doe\",\n * email: \"john@example.com\",\n * phone: \"555-1234\",\n * companySize: \"50-100\", // Custom field\n * resumeToken: \"upload_abc123\",\n * },\n * {\n * apiKey: \"key_123\",\n * contactCategoryToken: \"cat_xyz\",\n * locationId: \"loc_456\",\n * }\n * );\n *\n * // Result:\n * // {\n * // api_key: \"key_123\",\n * // contact_category_token: \"cat_xyz\",\n * // location_id: \"loc_456\",\n * // contact: {\n * // first_name: \"John\",\n * // last_name: \"Doe\",\n * // email: \"john@example.com\",\n * // phone: \"555-1234\",\n * // custom_fields: {\n * // company_size: \"50-100\"\n * // },\n * // contact_form_upload_tokens: [\"upload_abc123\"]\n * // }\n * // }\n * ```\n */\nexport function serializeForRails(\n values: FormValues,\n config: RailsApiConfig\n): SerializedFormData {\n const standardFields: Record<string, unknown> = {};\n const customFields: Record<string, unknown> = {};\n\n // Extract upload tokens\n const uploadTokens = extractUploadTokens(values);\n\n // Separate standard and custom fields\n for (const [key, value] of Object.entries(values)) {\n // Skip upload token fields - they're handled separately\n if (typeof value === \"string\" && value.startsWith(\"upload_\")) {\n continue;\n }\n if (Array.isArray(value) && value.every(\n (item) => typeof item === \"string\" && item.startsWith(\"upload_\")\n )) {\n continue;\n }\n\n const snakeKey = camelToSnake(key);\n\n if (isStandardField(key)) {\n // Format dates for birthday field\n if (key === \"birthday\") {\n const formatted = formatDateForRails(value);\n if (formatted) {\n standardFields[snakeKey] = formatted;\n }\n } else {\n standardFields[snakeKey] = value;\n }\n } else {\n // Custom fields\n customFields[snakeKey] = value;\n }\n }\n\n // Add config fields to standard fields if provided\n if (config.websiteId !== undefined) {\n standardFields.website_id = config.websiteId;\n }\n if (config.websiteFormAssignmentId !== undefined) {\n standardFields.website_form_assignment_id = config.websiteFormAssignmentId;\n }\n if (config.visitorIpAddress !== undefined) {\n standardFields.visitor_ip_address = config.visitorIpAddress;\n }\n\n // Build contact object\n const contact: SerializedFormData[\"contact\"] = {\n ...standardFields,\n };\n\n // Add custom fields if any\n if (Object.keys(customFields).length > 0) {\n contact.custom_fields = customFields;\n }\n\n // Add upload tokens if any\n if (uploadTokens.length > 0) {\n contact.contact_form_upload_tokens = uploadTokens;\n }\n\n // Build final serialized data\n const serialized: SerializedFormData = {\n api_key: config.apiKey,\n contact,\n };\n\n // Add optional top-level parameters\n if (config.contactCategoryToken !== undefined) {\n serialized.contact_category_token = config.contactCategoryToken;\n }\n if (config.locationId !== undefined) {\n serialized.location_id = config.locationId;\n }\n\n return serialized;\n}\n\n/**\n * Rails API error response format.\n */\nexport interface RailsErrorResponse {\n errors: {\n [field: string]: string[];\n };\n status: number;\n}\n\n/**\n * Form error format used by @page-speed/forms.\n */\nexport type FormErrors = Record<string, string | undefined>;\n\n/**\n * Convert snake_case to camelCase.\n *\n * @example\n * ```ts\n * snakeToCamel(\"first_name\") // \"firstName\"\n * snakeToCamel(\"accepts_sms_marketing\") // \"acceptsSmsMarketing\"\n * ```\n */\nfunction snakeToCamel(str: string): string {\n return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\n/**\n * Deserialize Rails API errors to form error format.\n *\n * Converts Rails error format to the format expected by @page-speed/forms:\n * - Maps snake_case field names to camelCase\n * - Flattens error arrays to single error string (first error)\n * - Handles custom_fields errors by mapping back to original field names\n * - Extracts base errors to form-level errors\n *\n * @param railsErrors - Error response from Rails API\n * @returns Form errors object (camelCase keys)\n *\n * @example\n * ```ts\n * const formErrors = deserializeErrors({\n * errors: {\n * first_name: [\"can't be blank\", \"is too short\"],\n * email: [\"is invalid\"],\n * custom_fields: {\n * company_size: [\"is required\"]\n * },\n * base: [\"Something went wrong\"]\n * },\n * status: 422\n * });\n *\n * // Result:\n * // {\n * // firstName: \"can't be blank\",\n * // email: \"is invalid\",\n * // companySize: \"is required\",\n * // _form: \"Something went wrong\"\n * // }\n * ```\n */\nexport function deserializeErrors(railsErrors: RailsErrorResponse): FormErrors {\n const formErrors: FormErrors = {};\n\n for (const [field, messages] of Object.entries(railsErrors.errors)) {\n // Handle base errors (form-level errors)\n if (field === \"base\") {\n formErrors._form = Array.isArray(messages) ? messages[0] : messages;\n continue;\n }\n\n // Handle custom_fields errors\n if (field === \"custom_fields\" && typeof messages === \"object\") {\n for (const [customField, customMessages] of Object.entries(messages)) {\n const camelField = snakeToCamel(customField);\n const errorMessage = Array.isArray(customMessages)\n ? customMessages[0]\n : customMessages;\n formErrors[camelField] = errorMessage;\n }\n continue;\n }\n\n // Handle standard field errors\n const camelField = snakeToCamel(field);\n const errorMessage = Array.isArray(messages) ? messages[0] : messages;\n formErrors[camelField] = errorMessage;\n }\n\n return formErrors;\n}\n","/**\n * @page-speed/forms - ChaiBlock Adapter\n *\n * Adapts form components for use in opensite-blocks ChaiBlock rendering system.\n * Wraps form components to accept ChaiBlock prop structure and transforms them\n * to component-native props.\n *\n * @see https://github.com/opensite-ai/page-speed-forms\n */\n\n\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * ChaiBlock structure from @opensite/blocks.\n * Minimal type definition for adapter compatibility.\n */\nexport interface ChaiBlock {\n _id: string;\n _type: string;\n _name?: string;\n _parent?: string | null;\n tag?: string;\n styles?: string;\n content?: string;\n blockProps?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\n/**\n * Options for ChaiBlock adapter.\n */\nexport interface ChaiBlockAdapterOptions {\n /**\n * Default props to merge with block props.\n */\n defaultProps?: Record<string, unknown>;\n\n /**\n * Transform function to convert ChaiBlock props to component props.\n * Useful for custom prop mapping logic.\n */\n transformProps?: (blockProps: Record<string, unknown>, block: ChaiBlock) => Record<string, unknown>;\n\n /**\n * Extract display name from block for debugging.\n * Defaults to using _name or _type from block.\n */\n getDisplayName?: (block: ChaiBlock) => string;\n\n /**\n * Enable React error boundary wrapping.\n * Defaults to true.\n */\n withErrorBoundary?: boolean;\n\n /**\n * Custom error fallback component.\n * If not provided, renders basic error message.\n */\n errorFallback?: (error: Error, block: ChaiBlock) => React.ReactNode;\n}\n\n/**\n * Props passed to adapted component.\n */\nexport interface AdaptedComponentProps {\n /**\n * ChaiBlock data from design payload.\n */\n block: ChaiBlock;\n\n /**\n * Child blocks for rendering nested content.\n * Used by container components like Form.\n */\n children?: React.ReactNode;\n\n /**\n * Callback to render child blocks.\n * Provided by opensite-blocks BlocksRenderer.\n */\n renderChildren?: (blockId: string) => React.ReactNode;\n}\n\n/**\n * Error boundary component for catching render errors.\n */\nclass ChaiBlockErrorBoundary extends React.Component<\n {\n block: ChaiBlock;\n fallback?: (error: Error, block: ChaiBlock) => React.ReactNode;\n children: React.ReactNode;\n },\n { error: Error | null }\n> {\n constructor(props: ChaiBlockErrorBoundary[\"props\"]) {\n super(props);\n this.state = { error: null };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error(`ChaiBlock render error (${this.props.block._id}):`, error, errorInfo);\n }\n\n render() {\n if (this.state.error) {\n if (this.props.fallback) {\n return this.props.fallback(this.state.error, this.props.block);\n }\n\n return (\n <div\n className=\"chai-block-error border border-red-300 bg-red-50 p-4 rounded text-red-700\"\n data-block-id={this.props.block._id}\n data-block-type={this.props.block._type}\n >\n <p className=\"font-semibold\">Block Render Error</p>\n <p className=\"text-sm\">\n Block: {this.props.block._name || this.props.block._id} ({this.props.block._type})\n </p>\n <p className=\"text-sm mt-1\">{this.state.error.message}</p>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\n/**\n * Create a ChaiBlock-compatible wrapper for a form component.\n *\n * This adapter transforms ChaiBlock props (from design payload) into\n * component-native props. It handles:\n * - Extracting props from `blockProps` field\n * - Merging with default props\n * - Custom prop transformation\n * - Error boundary wrapping\n * - Children rendering support\n *\n * @param Component - React component to adapt\n * @param options - Adapter configuration options\n * @returns ChaiBlock-compatible component\n *\n * @example\n * ```tsx\n * import { TextInput } from \"@page-speed/forms/inputs\";\n * import { createChaiBlockAdapter } from \"@page-speed/forms/integration\";\n *\n * // Create ChaiBlock-compatible TextInput\n * const ChaiTextInput = createChaiBlockAdapter(TextInput, {\n * defaultProps: {\n * placeholder: \"Enter text...\",\n * },\n * transformProps: (blockProps, block) => ({\n * ...blockProps,\n * // Map ChaiBlock content to component props\n * label: block.content || blockProps.label,\n * // Apply ChaiBlock styles as className\n * className: block.styles,\n * }),\n * });\n *\n * // Register with opensite-blocks\n * registerBlockType(\"TextInput\", ChaiTextInput);\n * ```\n *\n * @example\n * ```tsx\n * // ChaiBlock from design payload:\n * {\n * _id: \"field-email\",\n * _type: \"TextInput\",\n * _name: \"Email Field\",\n * content: \"Email Address\",\n * styles: \"w-full mb-4\",\n * blockProps: {\n * name: \"email\",\n * type: \"email\",\n * placeholder: \"you@example.com\",\n * required: true,\n * }\n * }\n *\n * // Transformed to TextInput props:\n * <TextInput\n * name=\"email\"\n * type=\"email\"\n * placeholder=\"you@example.com\"\n * required={true}\n * label=\"Email Address\"\n * className=\"w-full mb-4\"\n * />\n * ```\n */\nexport function createChaiBlockAdapter<TProps extends Record<string, unknown>>(\n Component: React.ComponentType<TProps>,\n options: ChaiBlockAdapterOptions = {}\n): React.ComponentType<AdaptedComponentProps> {\n const {\n defaultProps = {},\n transformProps,\n withErrorBoundary = true,\n errorFallback,\n } = options;\n\n const AdaptedComponent: React.FC<AdaptedComponentProps> = ({ block, children, renderChildren }) => {\n // Extract component props from blockProps\n const blockProps = (block.blockProps || {}) as Record<string, unknown>;\n\n // Merge with default props\n const mergedProps = { ...defaultProps, ...blockProps };\n\n // Apply custom transformation if provided\n const finalProps = transformProps\n ? transformProps(mergedProps, block)\n : mergedProps;\n\n // Add data attributes for debugging\n const dataAttrs = {\n \"data-block-id\": block._id,\n \"data-block-type\": block._type,\n ...(block._name && { \"data-block-name\": block._name }),\n };\n\n // Merge data attributes with final props\n const componentProps = {\n ...finalProps,\n ...dataAttrs,\n } as unknown as TProps;\n\n // Render children if renderChildren callback provided\n const renderedChildren = renderChildren ? renderChildren(block._id) : children;\n\n const element = (\n <Component {...componentProps}>\n {renderedChildren}\n </Component>\n );\n\n // Wrap with error boundary if enabled\n if (withErrorBoundary) {\n return (\n <ChaiBlockErrorBoundary block={block} fallback={errorFallback}>\n {element}\n </ChaiBlockErrorBoundary>\n );\n }\n\n return element;\n };\n\n // Set display name for debugging\n const componentName = Component.displayName || Component.name || \"Component\";\n AdaptedComponent.displayName = `ChaiBlockAdapter(${componentName})`;\n\n return AdaptedComponent;\n}\n\n/**\n * Standard prop transformer for form input components.\n *\n * Applies common transformations:\n * - Maps ChaiBlock `content` to `label`\n * - Maps ChaiBlock `styles` to `className`\n * - Preserves all blockProps\n *\n * @param blockProps - Props from ChaiBlock.blockProps\n * @param block - Full ChaiBlock object\n * @returns Transformed props for component\n *\n * @example\n * ```tsx\n * const ChaiTextInput = createChaiBlockAdapter(TextInput, {\n * transformProps: standardInputTransformer,\n * });\n * ```\n */\nexport function standardInputTransformer(\n blockProps: Record<string, unknown>,\n block: ChaiBlock\n): Record<string, unknown> {\n return {\n ...blockProps,\n // Use content as label if not already provided\n ...(block.content && !blockProps.label && { label: block.content }),\n // Apply ChaiBlock styles as className\n ...(block.styles && { className: block.styles }),\n };\n}\n\n/**\n * Create multiple ChaiBlock adapters with shared options.\n *\n * Convenience function for adapting multiple components at once\n * with the same configuration.\n *\n * @param components - Record of component name to component\n * @param options - Shared adapter options\n * @returns Record of adapted components\n *\n * @example\n * ```tsx\n * import * as Inputs from \"@page-speed/forms/inputs\";\n * import { createChaiBlockAdapters, standardInputTransformer } from \"@page-speed/forms/integration\";\n *\n * const ChaiInputs = createChaiBlockAdapters(\n * {\n * TextInput: Inputs.TextInput,\n * TextArea: Inputs.TextArea,\n * Select: Inputs.Select,\n * },\n * {\n * transformProps: standardInputTransformer,\n * withErrorBoundary: true,\n * }\n * );\n *\n * // ChaiInputs.TextInput, ChaiInputs.TextArea, ChaiInputs.Select\n * // are now ChaiBlock-compatible\n * ```\n */\nexport function createChaiBlockAdapters<\n TComponents extends Record<string, React.ComponentType<any>>\n>(\n components: TComponents,\n options: ChaiBlockAdapterOptions = {}\n): Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>> {\n const adapted: Record<string, React.ComponentType<AdaptedComponentProps>> = {};\n\n for (const [name, component] of Object.entries(components)) {\n adapted[name] = createChaiBlockAdapter(component, options);\n }\n\n return adapted as Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>>;\n}\n"]}
1
+ {"version":3,"sources":["../src/integration/ContactFormSerializer.ts","../src/integration/BlockAdapter.tsx"],"names":["camelField","errorMessage","React","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAM,eAAA,GAAkB;AAAA,EACtB,SAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,qBAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF,CAAA;AAmGA,SAAS,aAAa,GAAA,EAAqB;AACzC,EAAA,OAAO,GAA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W,MAAM,MAAA;AAAO,GAChD;AACF;AAiCO,SAAS,mBAAA,CAGd,UAAA,EACA,OAAA,GAA+B,EAAC,EACuC;AACvE,EAAA,MAAM,UAAsE,EAAC;AAE7E,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,SAAS,KAAK,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAA,EAAG;AAC1D,IAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,kBAAA,CAAmB,SAAA,EAAW,OAAO,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,OAAA;AACT","file":"integration.cjs","sourcesContent":["/**\n * @page-speed/forms - Rails API Serializer\n *\n * Serializes form data for the DashTrack ContactsController API.\n * Handles field name conversion (camelCase → snake_case), custom fields separation,\n * and upload token arrays.\n *\n * @see https://github.com/opensite-ai/page-speed-forms\n */\n\n/**\n * Standard fields recognized by the Rails ContactsController API.\n * These are serialized to snake_case and sent in the contact object.\n */\nconst STANDARD_FIELDS = [\n \"content\",\n \"email\",\n \"firstName\",\n \"lastName\",\n \"locationId\",\n \"phone\",\n \"subject\",\n \"redemptionStatus\",\n \"birthday\",\n \"city\",\n \"state\",\n \"websiteFormAssignmentId\",\n \"websiteId\",\n \"acceptsSmsMarketing\",\n \"acceptsEmailMarketing\",\n \"visitorIpAddress\",\n] as const;\n\n/**\n * Configuration parameters for Rails API submission.\n */\nexport interface RailsApiConfig {\n /**\n * API key for authentication.\n * Sent as top-level parameter: api_key\n */\n apiKey: string;\n\n /**\n * Contact category token for categorization.\n * Sent as top-level parameter: contact_category_token\n */\n contactCategoryToken?: string;\n\n /**\n * Location ID for multi-location organizations.\n * Sent as top-level parameter: location_id\n */\n locationId?: string;\n\n /**\n * Website ID for tracking form submissions.\n * Sent within contact object: website_id\n */\n websiteId?: string;\n\n /**\n * Website form assignment ID for form tracking.\n * Sent within contact object: website_form_assignment_id\n */\n websiteFormAssignmentId?: string;\n\n /**\n * Visitor IP address. If not provided, will be auto-detected on server.\n * Sent within contact object: visitor_ip_address\n */\n visitorIpAddress?: string;\n}\n\n/**\n * Serialized form data ready for Rails API submission.\n */\nexport interface SerializedFormData {\n /**\n * Top-level API key parameter.\n */\n api_key: string;\n\n /**\n * Top-level contact category token (optional).\n */\n contact_category_token?: string;\n\n /**\n * Top-level location ID (optional).\n */\n location_id?: string;\n\n /**\n * Contact object with standard fields and metadata.\n */\n contact: {\n /**\n * Standard contact fields in snake_case.\n */\n [key: string]: unknown;\n\n /**\n * Custom fields that don't match standard schema.\n * Stored as separate hash in Rails.\n */\n custom_fields?: Record<string, unknown>;\n\n /**\n * Array of upload tokens from file uploads.\n * These reference ContactFormUpload records in Rails.\n */\n contact_form_upload_tokens?: string[];\n };\n}\n\n/**\n * Form values from the form library (camelCase keys).\n */\nexport type FormValues = Record<string, unknown>;\n\n/**\n * Convert camelCase to snake_case.\n *\n * @example\n * ```ts\n * camelToSnake(\"firstName\") // \"first_name\"\n * camelToSnake(\"acceptsSmsMarketing\") // \"accepts_sms_marketing\"\n * ```\n */\nfunction camelToSnake(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);\n}\n\n/**\n * Check if a field name is a standard Rails contact field.\n */\nfunction isStandardField(fieldName: string): boolean {\n return STANDARD_FIELDS.includes(fieldName as (typeof STANDARD_FIELDS)[number]);\n}\n\n/**\n * Extract upload tokens from form values.\n * Handles both string tokens and arrays of tokens.\n */\nfunction extractUploadTokens(values: FormValues): string[] {\n const tokens: string[] = [];\n\n for (const value of Object.values(values)) {\n if (typeof value === \"string\" && value.startsWith(\"upload_\")) {\n tokens.push(value);\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (typeof item === \"string\" && item.startsWith(\"upload_\")) {\n tokens.push(item);\n }\n }\n }\n }\n\n return tokens;\n}\n\n/**\n * Format date/time values for Rails API.\n * Rails expects ISO 8601 format.\n */\nfunction formatDateForRails(value: unknown): string | undefined {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (typeof value === \"string\") {\n // Attempt to parse and reformat to ensure valid ISO 8601\n const date = new Date(value);\n if (!isNaN(date.getTime())) {\n return date.toISOString();\n }\n }\n return undefined;\n}\n\n/**\n * Serialize form values for Rails ContactsController API.\n *\n * This function:\n * 1. Converts camelCase field names to snake_case\n * 2. Separates standard fields from custom fields\n * 3. Extracts upload tokens into contact_form_upload_tokens array\n * 4. Formats dates to ISO 8601\n * 5. Includes API configuration parameters\n *\n * @param values - Form values from useForm hook (camelCase keys)\n * @param config - Rails API configuration (apiKey, locationId, etc.)\n * @returns Serialized data ready for POST to /contacts\n *\n * @example\n * ```ts\n * const serialized = serializeForRails(\n * {\n * firstName: \"John\",\n * lastName: \"Doe\",\n * email: \"john@example.com\",\n * phone: \"555-1234\",\n * companySize: \"50-100\", // Custom field\n * resumeToken: \"upload_abc123\",\n * },\n * {\n * apiKey: \"key_123\",\n * contactCategoryToken: \"cat_xyz\",\n * locationId: \"loc_456\",\n * }\n * );\n *\n * // Result:\n * // {\n * // api_key: \"key_123\",\n * // contact_category_token: \"cat_xyz\",\n * // location_id: \"loc_456\",\n * // contact: {\n * // first_name: \"John\",\n * // last_name: \"Doe\",\n * // email: \"john@example.com\",\n * // phone: \"555-1234\",\n * // custom_fields: {\n * // company_size: \"50-100\"\n * // },\n * // contact_form_upload_tokens: [\"upload_abc123\"]\n * // }\n * // }\n * ```\n */\nexport function serializeForRails(\n values: FormValues,\n config: RailsApiConfig\n): SerializedFormData {\n const standardFields: Record<string, unknown> = {};\n const customFields: Record<string, unknown> = {};\n\n // Extract upload tokens\n const uploadTokens = extractUploadTokens(values);\n\n // Separate standard and custom fields\n for (const [key, value] of Object.entries(values)) {\n // Skip upload token fields - they're handled separately\n if (typeof value === \"string\" && value.startsWith(\"upload_\")) {\n continue;\n }\n if (Array.isArray(value) && value.every(\n (item) => typeof item === \"string\" && item.startsWith(\"upload_\")\n )) {\n continue;\n }\n\n const snakeKey = camelToSnake(key);\n\n if (isStandardField(key)) {\n // Format dates for birthday field\n if (key === \"birthday\") {\n const formatted = formatDateForRails(value);\n if (formatted) {\n standardFields[snakeKey] = formatted;\n }\n } else {\n standardFields[snakeKey] = value;\n }\n } else {\n // Custom fields\n customFields[snakeKey] = value;\n }\n }\n\n // Add config fields to standard fields if provided\n if (config.websiteId !== undefined) {\n standardFields.website_id = config.websiteId;\n }\n if (config.websiteFormAssignmentId !== undefined) {\n standardFields.website_form_assignment_id = config.websiteFormAssignmentId;\n }\n if (config.visitorIpAddress !== undefined) {\n standardFields.visitor_ip_address = config.visitorIpAddress;\n }\n\n // Build contact object\n const contact: SerializedFormData[\"contact\"] = {\n ...standardFields,\n };\n\n // Add custom fields if any\n if (Object.keys(customFields).length > 0) {\n contact.custom_fields = customFields;\n }\n\n // Add upload tokens if any\n if (uploadTokens.length > 0) {\n contact.contact_form_upload_tokens = uploadTokens;\n }\n\n // Build final serialized data\n const serialized: SerializedFormData = {\n api_key: config.apiKey,\n contact,\n };\n\n // Add optional top-level parameters\n if (config.contactCategoryToken !== undefined) {\n serialized.contact_category_token = config.contactCategoryToken;\n }\n if (config.locationId !== undefined) {\n serialized.location_id = config.locationId;\n }\n\n return serialized;\n}\n\n/**\n * Rails API error response format.\n */\nexport interface RailsErrorResponse {\n errors: {\n [field: string]: string[];\n };\n status: number;\n}\n\n/**\n * Form error format used by @page-speed/forms.\n */\nexport type FormErrors = Record<string, string | undefined>;\n\n/**\n * Convert snake_case to camelCase.\n *\n * @example\n * ```ts\n * snakeToCamel(\"first_name\") // \"firstName\"\n * snakeToCamel(\"accepts_sms_marketing\") // \"acceptsSmsMarketing\"\n * ```\n */\nfunction snakeToCamel(str: string): string {\n return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\n/**\n * Deserialize Rails API errors to form error format.\n *\n * Converts Rails error format to the format expected by @page-speed/forms:\n * - Maps snake_case field names to camelCase\n * - Flattens error arrays to single error string (first error)\n * - Handles custom_fields errors by mapping back to original field names\n * - Extracts base errors to form-level errors\n *\n * @param railsErrors - Error response from Rails API\n * @returns Form errors object (camelCase keys)\n *\n * @example\n * ```ts\n * const formErrors = deserializeErrors({\n * errors: {\n * first_name: [\"can't be blank\", \"is too short\"],\n * email: [\"is invalid\"],\n * custom_fields: {\n * company_size: [\"is required\"]\n * },\n * base: [\"Something went wrong\"]\n * },\n * status: 422\n * });\n *\n * // Result:\n * // {\n * // firstName: \"can't be blank\",\n * // email: \"is invalid\",\n * // companySize: \"is required\",\n * // _form: \"Something went wrong\"\n * // }\n * ```\n */\nexport function deserializeErrors(railsErrors: RailsErrorResponse): FormErrors {\n const formErrors: FormErrors = {};\n\n for (const [field, messages] of Object.entries(railsErrors.errors)) {\n // Handle base errors (form-level errors)\n if (field === \"base\") {\n formErrors._form = Array.isArray(messages) ? messages[0] : messages;\n continue;\n }\n\n // Handle custom_fields errors\n if (field === \"custom_fields\" && typeof messages === \"object\") {\n for (const [customField, customMessages] of Object.entries(messages)) {\n const camelField = snakeToCamel(customField);\n const errorMessage = Array.isArray(customMessages)\n ? customMessages[0]\n : customMessages;\n formErrors[camelField] = errorMessage;\n }\n continue;\n }\n\n // Handle standard field errors\n const camelField = snakeToCamel(field);\n const errorMessage = Array.isArray(messages) ? messages[0] : messages;\n formErrors[camelField] = errorMessage;\n }\n\n return formErrors;\n}\n","/**\n * @page-speed/forms - Block Adapter\n *\n * Adapts form components for use in block-based rendering systems.\n * Wraps form components to accept block prop structure and transforms them\n * to component-native props.\n *\n * @see https://github.com/opensite-ai/page-speed-forms\n */\n\n\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * Block structure for design payloads.\n * Minimal type definition for adapter compatibility.\n */\nexport interface Block {\n _id: string;\n _type: string;\n _name?: string;\n _parent?: string | null;\n tag?: string;\n styles?: string;\n content?: string;\n blockProps?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\n/**\n * Options for Block adapter.\n */\nexport interface BlockAdapterOptions {\n /**\n * Default props to merge with block props.\n */\n defaultProps?: Record<string, unknown>;\n\n /**\n * Transform function to convert Block props to component props.\n * Useful for custom prop mapping logic.\n */\n transformProps?: (blockProps: Record<string, unknown>, block: Block) => Record<string, unknown>;\n\n /**\n * Extract display name from block for debugging.\n * Defaults to using _name or _type from block.\n */\n getDisplayName?: (block: Block) => string;\n\n /**\n * Enable React error boundary wrapping.\n * Defaults to true.\n */\n withErrorBoundary?: boolean;\n\n /**\n * Custom error fallback component.\n * If not provided, renders basic error message.\n */\n errorFallback?: (error: Error, block: Block) => React.ReactNode;\n}\n\n/**\n * Props passed to adapted component.\n */\nexport interface AdaptedComponentProps {\n /**\n * Block data from design payload.\n */\n block: Block;\n\n /**\n * Child blocks for rendering nested content.\n * Used by container components like Form.\n */\n children?: React.ReactNode;\n\n /**\n * Callback to render child blocks.\n * Provided by block rendering systems.\n */\n renderChildren?: (blockId: string) => React.ReactNode;\n}\n\n/**\n * Error boundary component for catching render errors.\n */\nclass BlockErrorBoundary extends React.Component<\n {\n block: Block;\n fallback?: (error: Error, block: Block) => React.ReactNode;\n children: React.ReactNode;\n },\n { error: Error | null }\n> {\n constructor(props: BlockErrorBoundary[\"props\"]) {\n super(props);\n this.state = { error: null };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error(`Block render error (${this.props.block._id}):`, error, errorInfo);\n }\n\n render() {\n if (this.state.error) {\n if (this.props.fallback) {\n return this.props.fallback(this.state.error, this.props.block);\n }\n\n return (\n <div\n className=\"block-error border border-red-300 bg-red-50 p-4 rounded text-red-700\"\n data-block-id={this.props.block._id}\n data-block-type={this.props.block._type}\n >\n <p className=\"font-semibold\">Block Render Error</p>\n <p className=\"text-sm\">\n Block: {this.props.block._name || this.props.block._id} ({this.props.block._type})\n </p>\n <p className=\"text-sm mt-1\">{this.state.error.message}</p>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\n/**\n * Create a Block-compatible wrapper for a form component.\n *\n * This adapter transforms Block props (from design payload) into\n * component-native props. It handles:\n * - Extracting props from `blockProps` field\n * - Merging with default props\n * - Custom prop transformation\n * - Error boundary wrapping\n * - Children rendering support\n *\n * @param Component - React component to adapt\n * @param options - Adapter configuration options\n * @returns Block-compatible component\n *\n * @example\n * ```tsx\n * import { TextInput } from \"@page-speed/forms/inputs\";\n * import { createBlockAdapter } from \"@page-speed/forms/integration\";\n *\n * // Create Block-compatible TextInput\n * const BlockTextInput = createBlockAdapter(TextInput, {\n * defaultProps: {\n * placeholder: \"Enter text...\",\n * },\n * transformProps: (blockProps, block) => ({\n * ...blockProps,\n * // Map Block content to component props\n * label: block.content || blockProps.label,\n * // Apply Block styles as className\n * className: block.styles,\n * }),\n * });\n *\n * // Register with rendering system\n * registerBlockType(\"TextInput\", BlockTextInput);\n * ```\n *\n * @example\n * ```tsx\n * // Block from design payload:\n * {\n * _id: \"field-email\",\n * _type: \"TextInput\",\n * _name: \"Email Field\",\n * content: \"Email Address\",\n * styles: \"w-full mb-4\",\n * blockProps: {\n * name: \"email\",\n * type: \"email\",\n * placeholder: \"you@example.com\",\n * required: true,\n * }\n * }\n *\n * // Transformed to TextInput props:\n * <TextInput\n * name=\"email\"\n * type=\"email\"\n * placeholder=\"you@example.com\"\n * required={true}\n * label=\"Email Address\"\n * className=\"w-full mb-4\"\n * />\n * ```\n */\nexport function createBlockAdapter<TProps extends Record<string, unknown>>(\n Component: React.ComponentType<TProps>,\n options: BlockAdapterOptions = {}\n): React.ComponentType<AdaptedComponentProps> {\n const {\n defaultProps = {},\n transformProps,\n withErrorBoundary = true,\n errorFallback,\n } = options;\n\n const AdaptedComponent: React.FC<AdaptedComponentProps> = ({ block, children, renderChildren }) => {\n // Extract component props from blockProps\n const blockProps = (block.blockProps || {}) as Record<string, unknown>;\n\n // Merge with default props\n const mergedProps = { ...defaultProps, ...blockProps };\n\n // Apply custom transformation if provided\n const finalProps = transformProps\n ? transformProps(mergedProps, block)\n : mergedProps;\n\n // Add data attributes for debugging\n const dataAttrs = {\n \"data-block-id\": block._id,\n \"data-block-type\": block._type,\n ...(block._name && { \"data-block-name\": block._name }),\n };\n\n // Merge data attributes with final props\n const componentProps = {\n ...finalProps,\n ...dataAttrs,\n } as unknown as TProps;\n\n // Render children if renderChildren callback provided\n const renderedChildren = renderChildren ? renderChildren(block._id) : children;\n\n const element = (\n <Component {...componentProps}>\n {renderedChildren}\n </Component>\n );\n\n // Wrap with error boundary if enabled\n if (withErrorBoundary) {\n return (\n <BlockErrorBoundary block={block} fallback={errorFallback}>\n {element}\n </BlockErrorBoundary>\n );\n }\n\n return element;\n };\n\n // Set display name for debugging\n const componentName = Component.displayName || Component.name || \"Component\";\n AdaptedComponent.displayName = `BlockAdapter(${componentName})`;\n\n return AdaptedComponent;\n}\n\n/**\n * Standard prop transformer for form input components.\n *\n * Applies common transformations:\n * - Maps Block `content` to `label`\n * - Maps Block `styles` to `className`\n * - Preserves all blockProps\n *\n * @param blockProps - Props from Block.blockProps\n * @param block - Full Block object\n * @returns Transformed props for component\n *\n * @example\n * ```tsx\n * const BlockTextInput = createBlockAdapter(TextInput, {\n * transformProps: standardInputTransformer,\n * });\n * ```\n */\nexport function standardInputTransformer(\n blockProps: Record<string, unknown>,\n block: Block\n): Record<string, unknown> {\n return {\n ...blockProps,\n // Use content as label if not already provided\n ...(block.content && !blockProps.label && { label: block.content }),\n // Apply Block styles as className\n ...(block.styles && { className: block.styles }),\n };\n}\n\n/**\n * Create multiple Block adapters with shared options.\n *\n * Convenience function for adapting multiple components at once\n * with the same configuration.\n *\n * @param components - Record of component name to component\n * @param options - Shared adapter options\n * @returns Record of adapted components\n *\n * @example\n * ```tsx\n * import * as Inputs from \"@page-speed/forms/inputs\";\n * import { createBlockAdapters, standardInputTransformer } from \"@page-speed/forms/integration\";\n *\n * const BlockInputs = createBlockAdapters(\n * {\n * TextInput: Inputs.TextInput,\n * TextArea: Inputs.TextArea,\n * Select: Inputs.Select,\n * },\n * {\n * transformProps: standardInputTransformer,\n * withErrorBoundary: true,\n * }\n * );\n *\n * // BlockInputs.TextInput, BlockInputs.TextArea, BlockInputs.Select\n * // are now Block-compatible\n * ```\n */\nexport function createBlockAdapters<\n TComponents extends Record<string, React.ComponentType<any>>\n>(\n components: TComponents,\n options: BlockAdapterOptions = {}\n): Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>> {\n const adapted: Record<string, React.ComponentType<AdaptedComponentProps>> = {};\n\n for (const [name, component] of Object.entries(components)) {\n adapted[name] = createBlockAdapter(component, options);\n }\n\n return adapted as Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>>;\n}\n"]}
@@ -186,20 +186,20 @@ type FormErrors = Record<string, string | undefined>;
186
186
  declare function deserializeErrors(railsErrors: RailsErrorResponse): FormErrors;
187
187
 
188
188
  /**
189
- * @page-speed/forms - ChaiBlock Adapter
189
+ * @page-speed/forms - Block Adapter
190
190
  *
191
- * Adapts form components for use in opensite-blocks ChaiBlock rendering system.
192
- * Wraps form components to accept ChaiBlock prop structure and transforms them
191
+ * Adapts form components for use in block-based rendering systems.
192
+ * Wraps form components to accept block prop structure and transforms them
193
193
  * to component-native props.
194
194
  *
195
195
  * @see https://github.com/opensite-ai/page-speed-forms
196
196
  */
197
197
 
198
198
  /**
199
- * ChaiBlock structure from @opensite/blocks.
199
+ * Block structure for design payloads.
200
200
  * Minimal type definition for adapter compatibility.
201
201
  */
202
- interface ChaiBlock {
202
+ interface Block {
203
203
  _id: string;
204
204
  _type: string;
205
205
  _name?: string;
@@ -211,23 +211,23 @@ interface ChaiBlock {
211
211
  [key: string]: unknown;
212
212
  }
213
213
  /**
214
- * Options for ChaiBlock adapter.
214
+ * Options for Block adapter.
215
215
  */
216
- interface ChaiBlockAdapterOptions {
216
+ interface BlockAdapterOptions {
217
217
  /**
218
218
  * Default props to merge with block props.
219
219
  */
220
220
  defaultProps?: Record<string, unknown>;
221
221
  /**
222
- * Transform function to convert ChaiBlock props to component props.
222
+ * Transform function to convert Block props to component props.
223
223
  * Useful for custom prop mapping logic.
224
224
  */
225
- transformProps?: (blockProps: Record<string, unknown>, block: ChaiBlock) => Record<string, unknown>;
225
+ transformProps?: (blockProps: Record<string, unknown>, block: Block) => Record<string, unknown>;
226
226
  /**
227
227
  * Extract display name from block for debugging.
228
228
  * Defaults to using _name or _type from block.
229
229
  */
230
- getDisplayName?: (block: ChaiBlock) => string;
230
+ getDisplayName?: (block: Block) => string;
231
231
  /**
232
232
  * Enable React error boundary wrapping.
233
233
  * Defaults to true.
@@ -237,16 +237,16 @@ interface ChaiBlockAdapterOptions {
237
237
  * Custom error fallback component.
238
238
  * If not provided, renders basic error message.
239
239
  */
240
- errorFallback?: (error: Error, block: ChaiBlock) => React.ReactNode;
240
+ errorFallback?: (error: Error, block: Block) => React.ReactNode;
241
241
  }
242
242
  /**
243
243
  * Props passed to adapted component.
244
244
  */
245
245
  interface AdaptedComponentProps {
246
246
  /**
247
- * ChaiBlock data from design payload.
247
+ * Block data from design payload.
248
248
  */
249
- block: ChaiBlock;
249
+ block: Block;
250
250
  /**
251
251
  * Child blocks for rendering nested content.
252
252
  * Used by container components like Form.
@@ -254,14 +254,14 @@ interface AdaptedComponentProps {
254
254
  children?: React.ReactNode;
255
255
  /**
256
256
  * Callback to render child blocks.
257
- * Provided by opensite-blocks BlocksRenderer.
257
+ * Provided by block rendering systems.
258
258
  */
259
259
  renderChildren?: (blockId: string) => React.ReactNode;
260
260
  }
261
261
  /**
262
- * Create a ChaiBlock-compatible wrapper for a form component.
262
+ * Create a Block-compatible wrapper for a form component.
263
263
  *
264
- * This adapter transforms ChaiBlock props (from design payload) into
264
+ * This adapter transforms Block props (from design payload) into
265
265
  * component-native props. It handles:
266
266
  * - Extracting props from `blockProps` field
267
267
  * - Merging with default props
@@ -271,34 +271,34 @@ interface AdaptedComponentProps {
271
271
  *
272
272
  * @param Component - React component to adapt
273
273
  * @param options - Adapter configuration options
274
- * @returns ChaiBlock-compatible component
274
+ * @returns Block-compatible component
275
275
  *
276
276
  * @example
277
277
  * ```tsx
278
278
  * import { TextInput } from "@page-speed/forms/inputs";
279
- * import { createChaiBlockAdapter } from "@page-speed/forms/integration";
279
+ * import { createBlockAdapter } from "@page-speed/forms/integration";
280
280
  *
281
- * // Create ChaiBlock-compatible TextInput
282
- * const ChaiTextInput = createChaiBlockAdapter(TextInput, {
281
+ * // Create Block-compatible TextInput
282
+ * const BlockTextInput = createBlockAdapter(TextInput, {
283
283
  * defaultProps: {
284
284
  * placeholder: "Enter text...",
285
285
  * },
286
286
  * transformProps: (blockProps, block) => ({
287
287
  * ...blockProps,
288
- * // Map ChaiBlock content to component props
288
+ * // Map Block content to component props
289
289
  * label: block.content || blockProps.label,
290
- * // Apply ChaiBlock styles as className
290
+ * // Apply Block styles as className
291
291
  * className: block.styles,
292
292
  * }),
293
293
  * });
294
294
  *
295
- * // Register with opensite-blocks
296
- * registerBlockType("TextInput", ChaiTextInput);
295
+ * // Register with rendering system
296
+ * registerBlockType("TextInput", BlockTextInput);
297
297
  * ```
298
298
  *
299
299
  * @example
300
300
  * ```tsx
301
- * // ChaiBlock from design payload:
301
+ * // Block from design payload:
302
302
  * {
303
303
  * _id: "field-email",
304
304
  * _type: "TextInput",
@@ -324,29 +324,29 @@ interface AdaptedComponentProps {
324
324
  * />
325
325
  * ```
326
326
  */
327
- declare function createChaiBlockAdapter<TProps extends Record<string, unknown>>(Component: React.ComponentType<TProps>, options?: ChaiBlockAdapterOptions): React.ComponentType<AdaptedComponentProps>;
327
+ declare function createBlockAdapter<TProps extends Record<string, unknown>>(Component: React.ComponentType<TProps>, options?: BlockAdapterOptions): React.ComponentType<AdaptedComponentProps>;
328
328
  /**
329
329
  * Standard prop transformer for form input components.
330
330
  *
331
331
  * Applies common transformations:
332
- * - Maps ChaiBlock `content` to `label`
333
- * - Maps ChaiBlock `styles` to `className`
332
+ * - Maps Block `content` to `label`
333
+ * - Maps Block `styles` to `className`
334
334
  * - Preserves all blockProps
335
335
  *
336
- * @param blockProps - Props from ChaiBlock.blockProps
337
- * @param block - Full ChaiBlock object
336
+ * @param blockProps - Props from Block.blockProps
337
+ * @param block - Full Block object
338
338
  * @returns Transformed props for component
339
339
  *
340
340
  * @example
341
341
  * ```tsx
342
- * const ChaiTextInput = createChaiBlockAdapter(TextInput, {
342
+ * const BlockTextInput = createBlockAdapter(TextInput, {
343
343
  * transformProps: standardInputTransformer,
344
344
  * });
345
345
  * ```
346
346
  */
347
- declare function standardInputTransformer(blockProps: Record<string, unknown>, block: ChaiBlock): Record<string, unknown>;
347
+ declare function standardInputTransformer(blockProps: Record<string, unknown>, block: Block): Record<string, unknown>;
348
348
  /**
349
- * Create multiple ChaiBlock adapters with shared options.
349
+ * Create multiple Block adapters with shared options.
350
350
  *
351
351
  * Convenience function for adapting multiple components at once
352
352
  * with the same configuration.
@@ -358,9 +358,9 @@ declare function standardInputTransformer(blockProps: Record<string, unknown>, b
358
358
  * @example
359
359
  * ```tsx
360
360
  * import * as Inputs from "@page-speed/forms/inputs";
361
- * import { createChaiBlockAdapters, standardInputTransformer } from "@page-speed/forms/integration";
361
+ * import { createBlockAdapters, standardInputTransformer } from "@page-speed/forms/integration";
362
362
  *
363
- * const ChaiInputs = createChaiBlockAdapters(
363
+ * const BlockInputs = createBlockAdapters(
364
364
  * {
365
365
  * TextInput: Inputs.TextInput,
366
366
  * TextArea: Inputs.TextArea,
@@ -372,10 +372,10 @@ declare function standardInputTransformer(blockProps: Record<string, unknown>, b
372
372
  * }
373
373
  * );
374
374
  *
375
- * // ChaiInputs.TextInput, ChaiInputs.TextArea, ChaiInputs.Select
376
- * // are now ChaiBlock-compatible
375
+ * // BlockInputs.TextInput, BlockInputs.TextArea, BlockInputs.Select
376
+ * // are now Block-compatible
377
377
  * ```
378
378
  */
379
- declare function createChaiBlockAdapters<TComponents extends Record<string, React.ComponentType<any>>>(components: TComponents, options?: ChaiBlockAdapterOptions): Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>>;
379
+ declare function createBlockAdapters<TComponents extends Record<string, React.ComponentType<any>>>(components: TComponents, options?: BlockAdapterOptions): Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>>;
380
380
 
381
- export { type AdaptedComponentProps, type ChaiBlock, type ChaiBlockAdapterOptions, type FormErrors, type RailsApiConfig, type RailsErrorResponse, type SerializedFormData, createChaiBlockAdapter, createChaiBlockAdapters, deserializeErrors, serializeForRails, standardInputTransformer };
381
+ export { type AdaptedComponentProps, type Block, type BlockAdapterOptions, type FormErrors, type RailsApiConfig, type RailsErrorResponse, type SerializedFormData, createBlockAdapter, createBlockAdapters, deserializeErrors, serializeForRails, standardInputTransformer };
@@ -186,20 +186,20 @@ type FormErrors = Record<string, string | undefined>;
186
186
  declare function deserializeErrors(railsErrors: RailsErrorResponse): FormErrors;
187
187
 
188
188
  /**
189
- * @page-speed/forms - ChaiBlock Adapter
189
+ * @page-speed/forms - Block Adapter
190
190
  *
191
- * Adapts form components for use in opensite-blocks ChaiBlock rendering system.
192
- * Wraps form components to accept ChaiBlock prop structure and transforms them
191
+ * Adapts form components for use in block-based rendering systems.
192
+ * Wraps form components to accept block prop structure and transforms them
193
193
  * to component-native props.
194
194
  *
195
195
  * @see https://github.com/opensite-ai/page-speed-forms
196
196
  */
197
197
 
198
198
  /**
199
- * ChaiBlock structure from @opensite/blocks.
199
+ * Block structure for design payloads.
200
200
  * Minimal type definition for adapter compatibility.
201
201
  */
202
- interface ChaiBlock {
202
+ interface Block {
203
203
  _id: string;
204
204
  _type: string;
205
205
  _name?: string;
@@ -211,23 +211,23 @@ interface ChaiBlock {
211
211
  [key: string]: unknown;
212
212
  }
213
213
  /**
214
- * Options for ChaiBlock adapter.
214
+ * Options for Block adapter.
215
215
  */
216
- interface ChaiBlockAdapterOptions {
216
+ interface BlockAdapterOptions {
217
217
  /**
218
218
  * Default props to merge with block props.
219
219
  */
220
220
  defaultProps?: Record<string, unknown>;
221
221
  /**
222
- * Transform function to convert ChaiBlock props to component props.
222
+ * Transform function to convert Block props to component props.
223
223
  * Useful for custom prop mapping logic.
224
224
  */
225
- transformProps?: (blockProps: Record<string, unknown>, block: ChaiBlock) => Record<string, unknown>;
225
+ transformProps?: (blockProps: Record<string, unknown>, block: Block) => Record<string, unknown>;
226
226
  /**
227
227
  * Extract display name from block for debugging.
228
228
  * Defaults to using _name or _type from block.
229
229
  */
230
- getDisplayName?: (block: ChaiBlock) => string;
230
+ getDisplayName?: (block: Block) => string;
231
231
  /**
232
232
  * Enable React error boundary wrapping.
233
233
  * Defaults to true.
@@ -237,16 +237,16 @@ interface ChaiBlockAdapterOptions {
237
237
  * Custom error fallback component.
238
238
  * If not provided, renders basic error message.
239
239
  */
240
- errorFallback?: (error: Error, block: ChaiBlock) => React.ReactNode;
240
+ errorFallback?: (error: Error, block: Block) => React.ReactNode;
241
241
  }
242
242
  /**
243
243
  * Props passed to adapted component.
244
244
  */
245
245
  interface AdaptedComponentProps {
246
246
  /**
247
- * ChaiBlock data from design payload.
247
+ * Block data from design payload.
248
248
  */
249
- block: ChaiBlock;
249
+ block: Block;
250
250
  /**
251
251
  * Child blocks for rendering nested content.
252
252
  * Used by container components like Form.
@@ -254,14 +254,14 @@ interface AdaptedComponentProps {
254
254
  children?: React.ReactNode;
255
255
  /**
256
256
  * Callback to render child blocks.
257
- * Provided by opensite-blocks BlocksRenderer.
257
+ * Provided by block rendering systems.
258
258
  */
259
259
  renderChildren?: (blockId: string) => React.ReactNode;
260
260
  }
261
261
  /**
262
- * Create a ChaiBlock-compatible wrapper for a form component.
262
+ * Create a Block-compatible wrapper for a form component.
263
263
  *
264
- * This adapter transforms ChaiBlock props (from design payload) into
264
+ * This adapter transforms Block props (from design payload) into
265
265
  * component-native props. It handles:
266
266
  * - Extracting props from `blockProps` field
267
267
  * - Merging with default props
@@ -271,34 +271,34 @@ interface AdaptedComponentProps {
271
271
  *
272
272
  * @param Component - React component to adapt
273
273
  * @param options - Adapter configuration options
274
- * @returns ChaiBlock-compatible component
274
+ * @returns Block-compatible component
275
275
  *
276
276
  * @example
277
277
  * ```tsx
278
278
  * import { TextInput } from "@page-speed/forms/inputs";
279
- * import { createChaiBlockAdapter } from "@page-speed/forms/integration";
279
+ * import { createBlockAdapter } from "@page-speed/forms/integration";
280
280
  *
281
- * // Create ChaiBlock-compatible TextInput
282
- * const ChaiTextInput = createChaiBlockAdapter(TextInput, {
281
+ * // Create Block-compatible TextInput
282
+ * const BlockTextInput = createBlockAdapter(TextInput, {
283
283
  * defaultProps: {
284
284
  * placeholder: "Enter text...",
285
285
  * },
286
286
  * transformProps: (blockProps, block) => ({
287
287
  * ...blockProps,
288
- * // Map ChaiBlock content to component props
288
+ * // Map Block content to component props
289
289
  * label: block.content || blockProps.label,
290
- * // Apply ChaiBlock styles as className
290
+ * // Apply Block styles as className
291
291
  * className: block.styles,
292
292
  * }),
293
293
  * });
294
294
  *
295
- * // Register with opensite-blocks
296
- * registerBlockType("TextInput", ChaiTextInput);
295
+ * // Register with rendering system
296
+ * registerBlockType("TextInput", BlockTextInput);
297
297
  * ```
298
298
  *
299
299
  * @example
300
300
  * ```tsx
301
- * // ChaiBlock from design payload:
301
+ * // Block from design payload:
302
302
  * {
303
303
  * _id: "field-email",
304
304
  * _type: "TextInput",
@@ -324,29 +324,29 @@ interface AdaptedComponentProps {
324
324
  * />
325
325
  * ```
326
326
  */
327
- declare function createChaiBlockAdapter<TProps extends Record<string, unknown>>(Component: React.ComponentType<TProps>, options?: ChaiBlockAdapterOptions): React.ComponentType<AdaptedComponentProps>;
327
+ declare function createBlockAdapter<TProps extends Record<string, unknown>>(Component: React.ComponentType<TProps>, options?: BlockAdapterOptions): React.ComponentType<AdaptedComponentProps>;
328
328
  /**
329
329
  * Standard prop transformer for form input components.
330
330
  *
331
331
  * Applies common transformations:
332
- * - Maps ChaiBlock `content` to `label`
333
- * - Maps ChaiBlock `styles` to `className`
332
+ * - Maps Block `content` to `label`
333
+ * - Maps Block `styles` to `className`
334
334
  * - Preserves all blockProps
335
335
  *
336
- * @param blockProps - Props from ChaiBlock.blockProps
337
- * @param block - Full ChaiBlock object
336
+ * @param blockProps - Props from Block.blockProps
337
+ * @param block - Full Block object
338
338
  * @returns Transformed props for component
339
339
  *
340
340
  * @example
341
341
  * ```tsx
342
- * const ChaiTextInput = createChaiBlockAdapter(TextInput, {
342
+ * const BlockTextInput = createBlockAdapter(TextInput, {
343
343
  * transformProps: standardInputTransformer,
344
344
  * });
345
345
  * ```
346
346
  */
347
- declare function standardInputTransformer(blockProps: Record<string, unknown>, block: ChaiBlock): Record<string, unknown>;
347
+ declare function standardInputTransformer(blockProps: Record<string, unknown>, block: Block): Record<string, unknown>;
348
348
  /**
349
- * Create multiple ChaiBlock adapters with shared options.
349
+ * Create multiple Block adapters with shared options.
350
350
  *
351
351
  * Convenience function for adapting multiple components at once
352
352
  * with the same configuration.
@@ -358,9 +358,9 @@ declare function standardInputTransformer(blockProps: Record<string, unknown>, b
358
358
  * @example
359
359
  * ```tsx
360
360
  * import * as Inputs from "@page-speed/forms/inputs";
361
- * import { createChaiBlockAdapters, standardInputTransformer } from "@page-speed/forms/integration";
361
+ * import { createBlockAdapters, standardInputTransformer } from "@page-speed/forms/integration";
362
362
  *
363
- * const ChaiInputs = createChaiBlockAdapters(
363
+ * const BlockInputs = createBlockAdapters(
364
364
  * {
365
365
  * TextInput: Inputs.TextInput,
366
366
  * TextArea: Inputs.TextArea,
@@ -372,10 +372,10 @@ declare function standardInputTransformer(blockProps: Record<string, unknown>, b
372
372
  * }
373
373
  * );
374
374
  *
375
- * // ChaiInputs.TextInput, ChaiInputs.TextArea, ChaiInputs.Select
376
- * // are now ChaiBlock-compatible
375
+ * // BlockInputs.TextInput, BlockInputs.TextArea, BlockInputs.Select
376
+ * // are now Block-compatible
377
377
  * ```
378
378
  */
379
- declare function createChaiBlockAdapters<TComponents extends Record<string, React.ComponentType<any>>>(components: TComponents, options?: ChaiBlockAdapterOptions): Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>>;
379
+ declare function createBlockAdapters<TComponents extends Record<string, React.ComponentType<any>>>(components: TComponents, options?: BlockAdapterOptions): Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>>;
380
380
 
381
- export { type AdaptedComponentProps, type ChaiBlock, type ChaiBlockAdapterOptions, type FormErrors, type RailsApiConfig, type RailsErrorResponse, type SerializedFormData, createChaiBlockAdapter, createChaiBlockAdapters, deserializeErrors, serializeForRails, standardInputTransformer };
381
+ export { type AdaptedComponentProps, type Block, type BlockAdapterOptions, type FormErrors, type RailsApiConfig, type RailsErrorResponse, type SerializedFormData, createBlockAdapter, createBlockAdapters, deserializeErrors, serializeForRails, standardInputTransformer };
@@ -133,7 +133,7 @@ function deserializeErrors(railsErrors) {
133
133
  }
134
134
  return formErrors;
135
135
  }
136
- var ChaiBlockErrorBoundary = class extends React.Component {
136
+ var BlockErrorBoundary = class extends React.Component {
137
137
  constructor(props) {
138
138
  super(props);
139
139
  this.state = { error: null };
@@ -142,7 +142,7 @@ var ChaiBlockErrorBoundary = class extends React.Component {
142
142
  return { error };
143
143
  }
144
144
  componentDidCatch(error, errorInfo) {
145
- console.error(`ChaiBlock render error (${this.props.block._id}):`, error, errorInfo);
145
+ console.error(`Block render error (${this.props.block._id}):`, error, errorInfo);
146
146
  }
147
147
  render() {
148
148
  if (this.state.error) {
@@ -152,7 +152,7 @@ var ChaiBlockErrorBoundary = class extends React.Component {
152
152
  return /* @__PURE__ */ React.createElement(
153
153
  "div",
154
154
  {
155
- className: "chai-block-error border border-red-300 bg-red-50 p-4 rounded text-red-700",
155
+ className: "block-error border border-red-300 bg-red-50 p-4 rounded text-red-700",
156
156
  "data-block-id": this.props.block._id,
157
157
  "data-block-type": this.props.block._type
158
158
  },
@@ -164,7 +164,7 @@ var ChaiBlockErrorBoundary = class extends React.Component {
164
164
  return this.props.children;
165
165
  }
166
166
  };
167
- function createChaiBlockAdapter(Component2, options = {}) {
167
+ function createBlockAdapter(Component2, options = {}) {
168
168
  const {
169
169
  defaultProps = {},
170
170
  transformProps,
@@ -187,12 +187,12 @@ function createChaiBlockAdapter(Component2, options = {}) {
187
187
  const renderedChildren = renderChildren ? renderChildren(block._id) : children;
188
188
  const element = /* @__PURE__ */ React.createElement(Component2, { ...componentProps }, renderedChildren);
189
189
  if (withErrorBoundary) {
190
- return /* @__PURE__ */ React.createElement(ChaiBlockErrorBoundary, { block, fallback: errorFallback }, element);
190
+ return /* @__PURE__ */ React.createElement(BlockErrorBoundary, { block, fallback: errorFallback }, element);
191
191
  }
192
192
  return element;
193
193
  };
194
194
  const componentName = Component2.displayName || Component2.name || "Component";
195
- AdaptedComponent.displayName = `ChaiBlockAdapter(${componentName})`;
195
+ AdaptedComponent.displayName = `BlockAdapter(${componentName})`;
196
196
  return AdaptedComponent;
197
197
  }
198
198
  function standardInputTransformer(blockProps, block) {
@@ -200,18 +200,18 @@ function standardInputTransformer(blockProps, block) {
200
200
  ...blockProps,
201
201
  // Use content as label if not already provided
202
202
  ...block.content && !blockProps.label && { label: block.content },
203
- // Apply ChaiBlock styles as className
203
+ // Apply Block styles as className
204
204
  ...block.styles && { className: block.styles }
205
205
  };
206
206
  }
207
- function createChaiBlockAdapters(components, options = {}) {
207
+ function createBlockAdapters(components, options = {}) {
208
208
  const adapted = {};
209
209
  for (const [name, component] of Object.entries(components)) {
210
- adapted[name] = createChaiBlockAdapter(component, options);
210
+ adapted[name] = createBlockAdapter(component, options);
211
211
  }
212
212
  return adapted;
213
213
  }
214
214
 
215
- export { createChaiBlockAdapter, createChaiBlockAdapters, deserializeErrors, serializeForRails, standardInputTransformer };
215
+ export { createBlockAdapter, createBlockAdapters, deserializeErrors, serializeForRails, standardInputTransformer };
216
216
  //# sourceMappingURL=integration.js.map
217
217
  //# sourceMappingURL=integration.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/integration/ContactFormSerializer.ts","../src/integration/ChaiBlockAdapter.tsx"],"names":["camelField","errorMessage","Component"],"mappings":";;;AAcA,IAAM,eAAA,GAAkB;AAAA,EACtB,SAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,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AAA,IACL,GAAG,UAAA;AAAA;AAAA,IAEH,GAAI,MAAM,OAAA,IAAW,CAAC,WAAW,KAAA,IAAS,EAAE,KAAA,EAAO,KAAA,CAAM,OAAA,EAAQ;AAAA;AAAA,IAEjE,GAAI,KAAA,CAAM,MAAA,IAAU,EAAE,SAAA,EAAW,MAAM,MAAA;AAAO,GAChD;AACF;AAiCO,SAAS,uBAAA,CAGd,UAAA,EACA,OAAA,GAAmC,EAAC,EACmC;AACvE,EAAA,MAAM,UAAsE,EAAC;AAE7E,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,SAAS,KAAK,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAA,EAAG;AAC1D,IAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,sBAAA,CAAuB,SAAA,EAAW,OAAO,CAAA;AAAA,EAC3D;AAEA,EAAA,OAAO,OAAA;AACT","file":"integration.js","sourcesContent":["/**\n * @page-speed/forms - Rails API Serializer\n *\n * Serializes form data for the DashTrack ContactsController API.\n * Handles field name conversion (camelCase → snake_case), custom fields separation,\n * and upload token arrays.\n *\n * @see https://github.com/opensite-ai/page-speed-forms\n */\n\n/**\n * Standard fields recognized by the Rails ContactsController API.\n * These are serialized to snake_case and sent in the contact object.\n */\nconst STANDARD_FIELDS = [\n \"content\",\n \"email\",\n \"firstName\",\n \"lastName\",\n \"locationId\",\n \"phone\",\n \"subject\",\n \"redemptionStatus\",\n \"birthday\",\n \"city\",\n \"state\",\n \"websiteFormAssignmentId\",\n \"websiteId\",\n \"acceptsSmsMarketing\",\n \"acceptsEmailMarketing\",\n \"visitorIpAddress\",\n] as const;\n\n/**\n * Configuration parameters for Rails API submission.\n */\nexport interface RailsApiConfig {\n /**\n * API key for authentication.\n * Sent as top-level parameter: api_key\n */\n apiKey: string;\n\n /**\n * Contact category token for categorization.\n * Sent as top-level parameter: contact_category_token\n */\n contactCategoryToken?: string;\n\n /**\n * Location ID for multi-location organizations.\n * Sent as top-level parameter: location_id\n */\n locationId?: string;\n\n /**\n * Website ID for tracking form submissions.\n * Sent within contact object: website_id\n */\n websiteId?: string;\n\n /**\n * Website form assignment ID for form tracking.\n * Sent within contact object: website_form_assignment_id\n */\n websiteFormAssignmentId?: string;\n\n /**\n * Visitor IP address. If not provided, will be auto-detected on server.\n * Sent within contact object: visitor_ip_address\n */\n visitorIpAddress?: string;\n}\n\n/**\n * Serialized form data ready for Rails API submission.\n */\nexport interface SerializedFormData {\n /**\n * Top-level API key parameter.\n */\n api_key: string;\n\n /**\n * Top-level contact category token (optional).\n */\n contact_category_token?: string;\n\n /**\n * Top-level location ID (optional).\n */\n location_id?: string;\n\n /**\n * Contact object with standard fields and metadata.\n */\n contact: {\n /**\n * Standard contact fields in snake_case.\n */\n [key: string]: unknown;\n\n /**\n * Custom fields that don't match standard schema.\n * Stored as separate hash in Rails.\n */\n custom_fields?: Record<string, unknown>;\n\n /**\n * Array of upload tokens from file uploads.\n * These reference ContactFormUpload records in Rails.\n */\n contact_form_upload_tokens?: string[];\n };\n}\n\n/**\n * Form values from the form library (camelCase keys).\n */\nexport type FormValues = Record<string, unknown>;\n\n/**\n * Convert camelCase to snake_case.\n *\n * @example\n * ```ts\n * camelToSnake(\"firstName\") // \"first_name\"\n * camelToSnake(\"acceptsSmsMarketing\") // \"accepts_sms_marketing\"\n * ```\n */\nfunction camelToSnake(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);\n}\n\n/**\n * Check if a field name is a standard Rails contact field.\n */\nfunction isStandardField(fieldName: string): boolean {\n return STANDARD_FIELDS.includes(fieldName as (typeof STANDARD_FIELDS)[number]);\n}\n\n/**\n * Extract upload tokens from form values.\n * Handles both string tokens and arrays of tokens.\n */\nfunction extractUploadTokens(values: FormValues): string[] {\n const tokens: string[] = [];\n\n for (const value of Object.values(values)) {\n if (typeof value === \"string\" && value.startsWith(\"upload_\")) {\n tokens.push(value);\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (typeof item === \"string\" && item.startsWith(\"upload_\")) {\n tokens.push(item);\n }\n }\n }\n }\n\n return tokens;\n}\n\n/**\n * Format date/time values for Rails API.\n * Rails expects ISO 8601 format.\n */\nfunction formatDateForRails(value: unknown): string | undefined {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (typeof value === \"string\") {\n // Attempt to parse and reformat to ensure valid ISO 8601\n const date = new Date(value);\n if (!isNaN(date.getTime())) {\n return date.toISOString();\n }\n }\n return undefined;\n}\n\n/**\n * Serialize form values for Rails ContactsController API.\n *\n * This function:\n * 1. Converts camelCase field names to snake_case\n * 2. Separates standard fields from custom fields\n * 3. Extracts upload tokens into contact_form_upload_tokens array\n * 4. Formats dates to ISO 8601\n * 5. Includes API configuration parameters\n *\n * @param values - Form values from useForm hook (camelCase keys)\n * @param config - Rails API configuration (apiKey, locationId, etc.)\n * @returns Serialized data ready for POST to /contacts\n *\n * @example\n * ```ts\n * const serialized = serializeForRails(\n * {\n * firstName: \"John\",\n * lastName: \"Doe\",\n * email: \"john@example.com\",\n * phone: \"555-1234\",\n * companySize: \"50-100\", // Custom field\n * resumeToken: \"upload_abc123\",\n * },\n * {\n * apiKey: \"key_123\",\n * contactCategoryToken: \"cat_xyz\",\n * locationId: \"loc_456\",\n * }\n * );\n *\n * // Result:\n * // {\n * // api_key: \"key_123\",\n * // contact_category_token: \"cat_xyz\",\n * // location_id: \"loc_456\",\n * // contact: {\n * // first_name: \"John\",\n * // last_name: \"Doe\",\n * // email: \"john@example.com\",\n * // phone: \"555-1234\",\n * // custom_fields: {\n * // company_size: \"50-100\"\n * // },\n * // contact_form_upload_tokens: [\"upload_abc123\"]\n * // }\n * // }\n * ```\n */\nexport function serializeForRails(\n values: FormValues,\n config: RailsApiConfig\n): SerializedFormData {\n const standardFields: Record<string, unknown> = {};\n const customFields: Record<string, unknown> = {};\n\n // Extract upload tokens\n const uploadTokens = extractUploadTokens(values);\n\n // Separate standard and custom fields\n for (const [key, value] of Object.entries(values)) {\n // Skip upload token fields - they're handled separately\n if (typeof value === \"string\" && value.startsWith(\"upload_\")) {\n continue;\n }\n if (Array.isArray(value) && value.every(\n (item) => typeof item === \"string\" && item.startsWith(\"upload_\")\n )) {\n continue;\n }\n\n const snakeKey = camelToSnake(key);\n\n if (isStandardField(key)) {\n // Format dates for birthday field\n if (key === \"birthday\") {\n const formatted = formatDateForRails(value);\n if (formatted) {\n standardFields[snakeKey] = formatted;\n }\n } else {\n standardFields[snakeKey] = value;\n }\n } else {\n // Custom fields\n customFields[snakeKey] = value;\n }\n }\n\n // Add config fields to standard fields if provided\n if (config.websiteId !== undefined) {\n standardFields.website_id = config.websiteId;\n }\n if (config.websiteFormAssignmentId !== undefined) {\n standardFields.website_form_assignment_id = config.websiteFormAssignmentId;\n }\n if (config.visitorIpAddress !== undefined) {\n standardFields.visitor_ip_address = config.visitorIpAddress;\n }\n\n // Build contact object\n const contact: SerializedFormData[\"contact\"] = {\n ...standardFields,\n };\n\n // Add custom fields if any\n if (Object.keys(customFields).length > 0) {\n contact.custom_fields = customFields;\n }\n\n // Add upload tokens if any\n if (uploadTokens.length > 0) {\n contact.contact_form_upload_tokens = uploadTokens;\n }\n\n // Build final serialized data\n const serialized: SerializedFormData = {\n api_key: config.apiKey,\n contact,\n };\n\n // Add optional top-level parameters\n if (config.contactCategoryToken !== undefined) {\n serialized.contact_category_token = config.contactCategoryToken;\n }\n if (config.locationId !== undefined) {\n serialized.location_id = config.locationId;\n }\n\n return serialized;\n}\n\n/**\n * Rails API error response format.\n */\nexport interface RailsErrorResponse {\n errors: {\n [field: string]: string[];\n };\n status: number;\n}\n\n/**\n * Form error format used by @page-speed/forms.\n */\nexport type FormErrors = Record<string, string | undefined>;\n\n/**\n * Convert snake_case to camelCase.\n *\n * @example\n * ```ts\n * snakeToCamel(\"first_name\") // \"firstName\"\n * snakeToCamel(\"accepts_sms_marketing\") // \"acceptsSmsMarketing\"\n * ```\n */\nfunction snakeToCamel(str: string): string {\n return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\n/**\n * Deserialize Rails API errors to form error format.\n *\n * Converts Rails error format to the format expected by @page-speed/forms:\n * - Maps snake_case field names to camelCase\n * - Flattens error arrays to single error string (first error)\n * - Handles custom_fields errors by mapping back to original field names\n * - Extracts base errors to form-level errors\n *\n * @param railsErrors - Error response from Rails API\n * @returns Form errors object (camelCase keys)\n *\n * @example\n * ```ts\n * const formErrors = deserializeErrors({\n * errors: {\n * first_name: [\"can't be blank\", \"is too short\"],\n * email: [\"is invalid\"],\n * custom_fields: {\n * company_size: [\"is required\"]\n * },\n * base: [\"Something went wrong\"]\n * },\n * status: 422\n * });\n *\n * // Result:\n * // {\n * // firstName: \"can't be blank\",\n * // email: \"is invalid\",\n * // companySize: \"is required\",\n * // _form: \"Something went wrong\"\n * // }\n * ```\n */\nexport function deserializeErrors(railsErrors: RailsErrorResponse): FormErrors {\n const formErrors: FormErrors = {};\n\n for (const [field, messages] of Object.entries(railsErrors.errors)) {\n // Handle base errors (form-level errors)\n if (field === \"base\") {\n formErrors._form = Array.isArray(messages) ? messages[0] : messages;\n continue;\n }\n\n // Handle custom_fields errors\n if (field === \"custom_fields\" && typeof messages === \"object\") {\n for (const [customField, customMessages] of Object.entries(messages)) {\n const camelField = snakeToCamel(customField);\n const errorMessage = Array.isArray(customMessages)\n ? customMessages[0]\n : customMessages;\n formErrors[camelField] = errorMessage;\n }\n continue;\n }\n\n // Handle standard field errors\n const camelField = snakeToCamel(field);\n const errorMessage = Array.isArray(messages) ? messages[0] : messages;\n formErrors[camelField] = errorMessage;\n }\n\n return formErrors;\n}\n","/**\n * @page-speed/forms - ChaiBlock Adapter\n *\n * Adapts form components for use in opensite-blocks ChaiBlock rendering system.\n * Wraps form components to accept ChaiBlock prop structure and transforms them\n * to component-native props.\n *\n * @see https://github.com/opensite-ai/page-speed-forms\n */\n\n\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * ChaiBlock structure from @opensite/blocks.\n * Minimal type definition for adapter compatibility.\n */\nexport interface ChaiBlock {\n _id: string;\n _type: string;\n _name?: string;\n _parent?: string | null;\n tag?: string;\n styles?: string;\n content?: string;\n blockProps?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\n/**\n * Options for ChaiBlock adapter.\n */\nexport interface ChaiBlockAdapterOptions {\n /**\n * Default props to merge with block props.\n */\n defaultProps?: Record<string, unknown>;\n\n /**\n * Transform function to convert ChaiBlock props to component props.\n * Useful for custom prop mapping logic.\n */\n transformProps?: (blockProps: Record<string, unknown>, block: ChaiBlock) => Record<string, unknown>;\n\n /**\n * Extract display name from block for debugging.\n * Defaults to using _name or _type from block.\n */\n getDisplayName?: (block: ChaiBlock) => string;\n\n /**\n * Enable React error boundary wrapping.\n * Defaults to true.\n */\n withErrorBoundary?: boolean;\n\n /**\n * Custom error fallback component.\n * If not provided, renders basic error message.\n */\n errorFallback?: (error: Error, block: ChaiBlock) => React.ReactNode;\n}\n\n/**\n * Props passed to adapted component.\n */\nexport interface AdaptedComponentProps {\n /**\n * ChaiBlock data from design payload.\n */\n block: ChaiBlock;\n\n /**\n * Child blocks for rendering nested content.\n * Used by container components like Form.\n */\n children?: React.ReactNode;\n\n /**\n * Callback to render child blocks.\n * Provided by opensite-blocks BlocksRenderer.\n */\n renderChildren?: (blockId: string) => React.ReactNode;\n}\n\n/**\n * Error boundary component for catching render errors.\n */\nclass ChaiBlockErrorBoundary extends React.Component<\n {\n block: ChaiBlock;\n fallback?: (error: Error, block: ChaiBlock) => React.ReactNode;\n children: React.ReactNode;\n },\n { error: Error | null }\n> {\n constructor(props: ChaiBlockErrorBoundary[\"props\"]) {\n super(props);\n this.state = { error: null };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error(`ChaiBlock render error (${this.props.block._id}):`, error, errorInfo);\n }\n\n render() {\n if (this.state.error) {\n if (this.props.fallback) {\n return this.props.fallback(this.state.error, this.props.block);\n }\n\n return (\n <div\n className=\"chai-block-error border border-red-300 bg-red-50 p-4 rounded text-red-700\"\n data-block-id={this.props.block._id}\n data-block-type={this.props.block._type}\n >\n <p className=\"font-semibold\">Block Render Error</p>\n <p className=\"text-sm\">\n Block: {this.props.block._name || this.props.block._id} ({this.props.block._type})\n </p>\n <p className=\"text-sm mt-1\">{this.state.error.message}</p>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\n/**\n * Create a ChaiBlock-compatible wrapper for a form component.\n *\n * This adapter transforms ChaiBlock props (from design payload) into\n * component-native props. It handles:\n * - Extracting props from `blockProps` field\n * - Merging with default props\n * - Custom prop transformation\n * - Error boundary wrapping\n * - Children rendering support\n *\n * @param Component - React component to adapt\n * @param options - Adapter configuration options\n * @returns ChaiBlock-compatible component\n *\n * @example\n * ```tsx\n * import { TextInput } from \"@page-speed/forms/inputs\";\n * import { createChaiBlockAdapter } from \"@page-speed/forms/integration\";\n *\n * // Create ChaiBlock-compatible TextInput\n * const ChaiTextInput = createChaiBlockAdapter(TextInput, {\n * defaultProps: {\n * placeholder: \"Enter text...\",\n * },\n * transformProps: (blockProps, block) => ({\n * ...blockProps,\n * // Map ChaiBlock content to component props\n * label: block.content || blockProps.label,\n * // Apply ChaiBlock styles as className\n * className: block.styles,\n * }),\n * });\n *\n * // Register with opensite-blocks\n * registerBlockType(\"TextInput\", ChaiTextInput);\n * ```\n *\n * @example\n * ```tsx\n * // ChaiBlock from design payload:\n * {\n * _id: \"field-email\",\n * _type: \"TextInput\",\n * _name: \"Email Field\",\n * content: \"Email Address\",\n * styles: \"w-full mb-4\",\n * blockProps: {\n * name: \"email\",\n * type: \"email\",\n * placeholder: \"you@example.com\",\n * required: true,\n * }\n * }\n *\n * // Transformed to TextInput props:\n * <TextInput\n * name=\"email\"\n * type=\"email\"\n * placeholder=\"you@example.com\"\n * required={true}\n * label=\"Email Address\"\n * className=\"w-full mb-4\"\n * />\n * ```\n */\nexport function createChaiBlockAdapter<TProps extends Record<string, unknown>>(\n Component: React.ComponentType<TProps>,\n options: ChaiBlockAdapterOptions = {}\n): React.ComponentType<AdaptedComponentProps> {\n const {\n defaultProps = {},\n transformProps,\n withErrorBoundary = true,\n errorFallback,\n } = options;\n\n const AdaptedComponent: React.FC<AdaptedComponentProps> = ({ block, children, renderChildren }) => {\n // Extract component props from blockProps\n const blockProps = (block.blockProps || {}) as Record<string, unknown>;\n\n // Merge with default props\n const mergedProps = { ...defaultProps, ...blockProps };\n\n // Apply custom transformation if provided\n const finalProps = transformProps\n ? transformProps(mergedProps, block)\n : mergedProps;\n\n // Add data attributes for debugging\n const dataAttrs = {\n \"data-block-id\": block._id,\n \"data-block-type\": block._type,\n ...(block._name && { \"data-block-name\": block._name }),\n };\n\n // Merge data attributes with final props\n const componentProps = {\n ...finalProps,\n ...dataAttrs,\n } as unknown as TProps;\n\n // Render children if renderChildren callback provided\n const renderedChildren = renderChildren ? renderChildren(block._id) : children;\n\n const element = (\n <Component {...componentProps}>\n {renderedChildren}\n </Component>\n );\n\n // Wrap with error boundary if enabled\n if (withErrorBoundary) {\n return (\n <ChaiBlockErrorBoundary block={block} fallback={errorFallback}>\n {element}\n </ChaiBlockErrorBoundary>\n );\n }\n\n return element;\n };\n\n // Set display name for debugging\n const componentName = Component.displayName || Component.name || \"Component\";\n AdaptedComponent.displayName = `ChaiBlockAdapter(${componentName})`;\n\n return AdaptedComponent;\n}\n\n/**\n * Standard prop transformer for form input components.\n *\n * Applies common transformations:\n * - Maps ChaiBlock `content` to `label`\n * - Maps ChaiBlock `styles` to `className`\n * - Preserves all blockProps\n *\n * @param blockProps - Props from ChaiBlock.blockProps\n * @param block - Full ChaiBlock object\n * @returns Transformed props for component\n *\n * @example\n * ```tsx\n * const ChaiTextInput = createChaiBlockAdapter(TextInput, {\n * transformProps: standardInputTransformer,\n * });\n * ```\n */\nexport function standardInputTransformer(\n blockProps: Record<string, unknown>,\n block: ChaiBlock\n): Record<string, unknown> {\n return {\n ...blockProps,\n // Use content as label if not already provided\n ...(block.content && !blockProps.label && { label: block.content }),\n // Apply ChaiBlock styles as className\n ...(block.styles && { className: block.styles }),\n };\n}\n\n/**\n * Create multiple ChaiBlock adapters with shared options.\n *\n * Convenience function for adapting multiple components at once\n * with the same configuration.\n *\n * @param components - Record of component name to component\n * @param options - Shared adapter options\n * @returns Record of adapted components\n *\n * @example\n * ```tsx\n * import * as Inputs from \"@page-speed/forms/inputs\";\n * import { createChaiBlockAdapters, standardInputTransformer } from \"@page-speed/forms/integration\";\n *\n * const ChaiInputs = createChaiBlockAdapters(\n * {\n * TextInput: Inputs.TextInput,\n * TextArea: Inputs.TextArea,\n * Select: Inputs.Select,\n * },\n * {\n * transformProps: standardInputTransformer,\n * withErrorBoundary: true,\n * }\n * );\n *\n * // ChaiInputs.TextInput, ChaiInputs.TextArea, ChaiInputs.Select\n * // are now ChaiBlock-compatible\n * ```\n */\nexport function createChaiBlockAdapters<\n TComponents extends Record<string, React.ComponentType<any>>\n>(\n components: TComponents,\n options: ChaiBlockAdapterOptions = {}\n): Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>> {\n const adapted: Record<string, React.ComponentType<AdaptedComponentProps>> = {};\n\n for (const [name, component] of Object.entries(components)) {\n adapted[name] = createChaiBlockAdapter(component, options);\n }\n\n return adapted as Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>>;\n}\n"]}
1
+ {"version":3,"sources":["../src/integration/ContactFormSerializer.ts","../src/integration/BlockAdapter.tsx"],"names":["camelField","errorMessage","Component"],"mappings":";;;AAcA,IAAM,eAAA,GAAkB;AAAA,EACtB,SAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,qBAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF,CAAA;AAmGA,SAAS,aAAa,GAAA,EAAqB;AACzC,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A,EAAW,MAAM,MAAA;AAAO,GAChD;AACF;AAiCO,SAAS,mBAAA,CAGd,UAAA,EACA,OAAA,GAA+B,EAAC,EACuC;AACvE,EAAA,MAAM,UAAsE,EAAC;AAE7E,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,SAAS,KAAK,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAA,EAAG;AAC1D,IAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,kBAAA,CAAmB,SAAA,EAAW,OAAO,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,OAAA;AACT","file":"integration.js","sourcesContent":["/**\n * @page-speed/forms - Rails API Serializer\n *\n * Serializes form data for the DashTrack ContactsController API.\n * Handles field name conversion (camelCase → snake_case), custom fields separation,\n * and upload token arrays.\n *\n * @see https://github.com/opensite-ai/page-speed-forms\n */\n\n/**\n * Standard fields recognized by the Rails ContactsController API.\n * These are serialized to snake_case and sent in the contact object.\n */\nconst STANDARD_FIELDS = [\n \"content\",\n \"email\",\n \"firstName\",\n \"lastName\",\n \"locationId\",\n \"phone\",\n \"subject\",\n \"redemptionStatus\",\n \"birthday\",\n \"city\",\n \"state\",\n \"websiteFormAssignmentId\",\n \"websiteId\",\n \"acceptsSmsMarketing\",\n \"acceptsEmailMarketing\",\n \"visitorIpAddress\",\n] as const;\n\n/**\n * Configuration parameters for Rails API submission.\n */\nexport interface RailsApiConfig {\n /**\n * API key for authentication.\n * Sent as top-level parameter: api_key\n */\n apiKey: string;\n\n /**\n * Contact category token for categorization.\n * Sent as top-level parameter: contact_category_token\n */\n contactCategoryToken?: string;\n\n /**\n * Location ID for multi-location organizations.\n * Sent as top-level parameter: location_id\n */\n locationId?: string;\n\n /**\n * Website ID for tracking form submissions.\n * Sent within contact object: website_id\n */\n websiteId?: string;\n\n /**\n * Website form assignment ID for form tracking.\n * Sent within contact object: website_form_assignment_id\n */\n websiteFormAssignmentId?: string;\n\n /**\n * Visitor IP address. If not provided, will be auto-detected on server.\n * Sent within contact object: visitor_ip_address\n */\n visitorIpAddress?: string;\n}\n\n/**\n * Serialized form data ready for Rails API submission.\n */\nexport interface SerializedFormData {\n /**\n * Top-level API key parameter.\n */\n api_key: string;\n\n /**\n * Top-level contact category token (optional).\n */\n contact_category_token?: string;\n\n /**\n * Top-level location ID (optional).\n */\n location_id?: string;\n\n /**\n * Contact object with standard fields and metadata.\n */\n contact: {\n /**\n * Standard contact fields in snake_case.\n */\n [key: string]: unknown;\n\n /**\n * Custom fields that don't match standard schema.\n * Stored as separate hash in Rails.\n */\n custom_fields?: Record<string, unknown>;\n\n /**\n * Array of upload tokens from file uploads.\n * These reference ContactFormUpload records in Rails.\n */\n contact_form_upload_tokens?: string[];\n };\n}\n\n/**\n * Form values from the form library (camelCase keys).\n */\nexport type FormValues = Record<string, unknown>;\n\n/**\n * Convert camelCase to snake_case.\n *\n * @example\n * ```ts\n * camelToSnake(\"firstName\") // \"first_name\"\n * camelToSnake(\"acceptsSmsMarketing\") // \"accepts_sms_marketing\"\n * ```\n */\nfunction camelToSnake(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);\n}\n\n/**\n * Check if a field name is a standard Rails contact field.\n */\nfunction isStandardField(fieldName: string): boolean {\n return STANDARD_FIELDS.includes(fieldName as (typeof STANDARD_FIELDS)[number]);\n}\n\n/**\n * Extract upload tokens from form values.\n * Handles both string tokens and arrays of tokens.\n */\nfunction extractUploadTokens(values: FormValues): string[] {\n const tokens: string[] = [];\n\n for (const value of Object.values(values)) {\n if (typeof value === \"string\" && value.startsWith(\"upload_\")) {\n tokens.push(value);\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (typeof item === \"string\" && item.startsWith(\"upload_\")) {\n tokens.push(item);\n }\n }\n }\n }\n\n return tokens;\n}\n\n/**\n * Format date/time values for Rails API.\n * Rails expects ISO 8601 format.\n */\nfunction formatDateForRails(value: unknown): string | undefined {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (typeof value === \"string\") {\n // Attempt to parse and reformat to ensure valid ISO 8601\n const date = new Date(value);\n if (!isNaN(date.getTime())) {\n return date.toISOString();\n }\n }\n return undefined;\n}\n\n/**\n * Serialize form values for Rails ContactsController API.\n *\n * This function:\n * 1. Converts camelCase field names to snake_case\n * 2. Separates standard fields from custom fields\n * 3. Extracts upload tokens into contact_form_upload_tokens array\n * 4. Formats dates to ISO 8601\n * 5. Includes API configuration parameters\n *\n * @param values - Form values from useForm hook (camelCase keys)\n * @param config - Rails API configuration (apiKey, locationId, etc.)\n * @returns Serialized data ready for POST to /contacts\n *\n * @example\n * ```ts\n * const serialized = serializeForRails(\n * {\n * firstName: \"John\",\n * lastName: \"Doe\",\n * email: \"john@example.com\",\n * phone: \"555-1234\",\n * companySize: \"50-100\", // Custom field\n * resumeToken: \"upload_abc123\",\n * },\n * {\n * apiKey: \"key_123\",\n * contactCategoryToken: \"cat_xyz\",\n * locationId: \"loc_456\",\n * }\n * );\n *\n * // Result:\n * // {\n * // api_key: \"key_123\",\n * // contact_category_token: \"cat_xyz\",\n * // location_id: \"loc_456\",\n * // contact: {\n * // first_name: \"John\",\n * // last_name: \"Doe\",\n * // email: \"john@example.com\",\n * // phone: \"555-1234\",\n * // custom_fields: {\n * // company_size: \"50-100\"\n * // },\n * // contact_form_upload_tokens: [\"upload_abc123\"]\n * // }\n * // }\n * ```\n */\nexport function serializeForRails(\n values: FormValues,\n config: RailsApiConfig\n): SerializedFormData {\n const standardFields: Record<string, unknown> = {};\n const customFields: Record<string, unknown> = {};\n\n // Extract upload tokens\n const uploadTokens = extractUploadTokens(values);\n\n // Separate standard and custom fields\n for (const [key, value] of Object.entries(values)) {\n // Skip upload token fields - they're handled separately\n if (typeof value === \"string\" && value.startsWith(\"upload_\")) {\n continue;\n }\n if (Array.isArray(value) && value.every(\n (item) => typeof item === \"string\" && item.startsWith(\"upload_\")\n )) {\n continue;\n }\n\n const snakeKey = camelToSnake(key);\n\n if (isStandardField(key)) {\n // Format dates for birthday field\n if (key === \"birthday\") {\n const formatted = formatDateForRails(value);\n if (formatted) {\n standardFields[snakeKey] = formatted;\n }\n } else {\n standardFields[snakeKey] = value;\n }\n } else {\n // Custom fields\n customFields[snakeKey] = value;\n }\n }\n\n // Add config fields to standard fields if provided\n if (config.websiteId !== undefined) {\n standardFields.website_id = config.websiteId;\n }\n if (config.websiteFormAssignmentId !== undefined) {\n standardFields.website_form_assignment_id = config.websiteFormAssignmentId;\n }\n if (config.visitorIpAddress !== undefined) {\n standardFields.visitor_ip_address = config.visitorIpAddress;\n }\n\n // Build contact object\n const contact: SerializedFormData[\"contact\"] = {\n ...standardFields,\n };\n\n // Add custom fields if any\n if (Object.keys(customFields).length > 0) {\n contact.custom_fields = customFields;\n }\n\n // Add upload tokens if any\n if (uploadTokens.length > 0) {\n contact.contact_form_upload_tokens = uploadTokens;\n }\n\n // Build final serialized data\n const serialized: SerializedFormData = {\n api_key: config.apiKey,\n contact,\n };\n\n // Add optional top-level parameters\n if (config.contactCategoryToken !== undefined) {\n serialized.contact_category_token = config.contactCategoryToken;\n }\n if (config.locationId !== undefined) {\n serialized.location_id = config.locationId;\n }\n\n return serialized;\n}\n\n/**\n * Rails API error response format.\n */\nexport interface RailsErrorResponse {\n errors: {\n [field: string]: string[];\n };\n status: number;\n}\n\n/**\n * Form error format used by @page-speed/forms.\n */\nexport type FormErrors = Record<string, string | undefined>;\n\n/**\n * Convert snake_case to camelCase.\n *\n * @example\n * ```ts\n * snakeToCamel(\"first_name\") // \"firstName\"\n * snakeToCamel(\"accepts_sms_marketing\") // \"acceptsSmsMarketing\"\n * ```\n */\nfunction snakeToCamel(str: string): string {\n return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\n/**\n * Deserialize Rails API errors to form error format.\n *\n * Converts Rails error format to the format expected by @page-speed/forms:\n * - Maps snake_case field names to camelCase\n * - Flattens error arrays to single error string (first error)\n * - Handles custom_fields errors by mapping back to original field names\n * - Extracts base errors to form-level errors\n *\n * @param railsErrors - Error response from Rails API\n * @returns Form errors object (camelCase keys)\n *\n * @example\n * ```ts\n * const formErrors = deserializeErrors({\n * errors: {\n * first_name: [\"can't be blank\", \"is too short\"],\n * email: [\"is invalid\"],\n * custom_fields: {\n * company_size: [\"is required\"]\n * },\n * base: [\"Something went wrong\"]\n * },\n * status: 422\n * });\n *\n * // Result:\n * // {\n * // firstName: \"can't be blank\",\n * // email: \"is invalid\",\n * // companySize: \"is required\",\n * // _form: \"Something went wrong\"\n * // }\n * ```\n */\nexport function deserializeErrors(railsErrors: RailsErrorResponse): FormErrors {\n const formErrors: FormErrors = {};\n\n for (const [field, messages] of Object.entries(railsErrors.errors)) {\n // Handle base errors (form-level errors)\n if (field === \"base\") {\n formErrors._form = Array.isArray(messages) ? messages[0] : messages;\n continue;\n }\n\n // Handle custom_fields errors\n if (field === \"custom_fields\" && typeof messages === \"object\") {\n for (const [customField, customMessages] of Object.entries(messages)) {\n const camelField = snakeToCamel(customField);\n const errorMessage = Array.isArray(customMessages)\n ? customMessages[0]\n : customMessages;\n formErrors[camelField] = errorMessage;\n }\n continue;\n }\n\n // Handle standard field errors\n const camelField = snakeToCamel(field);\n const errorMessage = Array.isArray(messages) ? messages[0] : messages;\n formErrors[camelField] = errorMessage;\n }\n\n return formErrors;\n}\n","/**\n * @page-speed/forms - Block Adapter\n *\n * Adapts form components for use in block-based rendering systems.\n * Wraps form components to accept block prop structure and transforms them\n * to component-native props.\n *\n * @see https://github.com/opensite-ai/page-speed-forms\n */\n\n\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * Block structure for design payloads.\n * Minimal type definition for adapter compatibility.\n */\nexport interface Block {\n _id: string;\n _type: string;\n _name?: string;\n _parent?: string | null;\n tag?: string;\n styles?: string;\n content?: string;\n blockProps?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\n/**\n * Options for Block adapter.\n */\nexport interface BlockAdapterOptions {\n /**\n * Default props to merge with block props.\n */\n defaultProps?: Record<string, unknown>;\n\n /**\n * Transform function to convert Block props to component props.\n * Useful for custom prop mapping logic.\n */\n transformProps?: (blockProps: Record<string, unknown>, block: Block) => Record<string, unknown>;\n\n /**\n * Extract display name from block for debugging.\n * Defaults to using _name or _type from block.\n */\n getDisplayName?: (block: Block) => string;\n\n /**\n * Enable React error boundary wrapping.\n * Defaults to true.\n */\n withErrorBoundary?: boolean;\n\n /**\n * Custom error fallback component.\n * If not provided, renders basic error message.\n */\n errorFallback?: (error: Error, block: Block) => React.ReactNode;\n}\n\n/**\n * Props passed to adapted component.\n */\nexport interface AdaptedComponentProps {\n /**\n * Block data from design payload.\n */\n block: Block;\n\n /**\n * Child blocks for rendering nested content.\n * Used by container components like Form.\n */\n children?: React.ReactNode;\n\n /**\n * Callback to render child blocks.\n * Provided by block rendering systems.\n */\n renderChildren?: (blockId: string) => React.ReactNode;\n}\n\n/**\n * Error boundary component for catching render errors.\n */\nclass BlockErrorBoundary extends React.Component<\n {\n block: Block;\n fallback?: (error: Error, block: Block) => React.ReactNode;\n children: React.ReactNode;\n },\n { error: Error | null }\n> {\n constructor(props: BlockErrorBoundary[\"props\"]) {\n super(props);\n this.state = { error: null };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error(`Block render error (${this.props.block._id}):`, error, errorInfo);\n }\n\n render() {\n if (this.state.error) {\n if (this.props.fallback) {\n return this.props.fallback(this.state.error, this.props.block);\n }\n\n return (\n <div\n className=\"block-error border border-red-300 bg-red-50 p-4 rounded text-red-700\"\n data-block-id={this.props.block._id}\n data-block-type={this.props.block._type}\n >\n <p className=\"font-semibold\">Block Render Error</p>\n <p className=\"text-sm\">\n Block: {this.props.block._name || this.props.block._id} ({this.props.block._type})\n </p>\n <p className=\"text-sm mt-1\">{this.state.error.message}</p>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\n/**\n * Create a Block-compatible wrapper for a form component.\n *\n * This adapter transforms Block props (from design payload) into\n * component-native props. It handles:\n * - Extracting props from `blockProps` field\n * - Merging with default props\n * - Custom prop transformation\n * - Error boundary wrapping\n * - Children rendering support\n *\n * @param Component - React component to adapt\n * @param options - Adapter configuration options\n * @returns Block-compatible component\n *\n * @example\n * ```tsx\n * import { TextInput } from \"@page-speed/forms/inputs\";\n * import { createBlockAdapter } from \"@page-speed/forms/integration\";\n *\n * // Create Block-compatible TextInput\n * const BlockTextInput = createBlockAdapter(TextInput, {\n * defaultProps: {\n * placeholder: \"Enter text...\",\n * },\n * transformProps: (blockProps, block) => ({\n * ...blockProps,\n * // Map Block content to component props\n * label: block.content || blockProps.label,\n * // Apply Block styles as className\n * className: block.styles,\n * }),\n * });\n *\n * // Register with rendering system\n * registerBlockType(\"TextInput\", BlockTextInput);\n * ```\n *\n * @example\n * ```tsx\n * // Block from design payload:\n * {\n * _id: \"field-email\",\n * _type: \"TextInput\",\n * _name: \"Email Field\",\n * content: \"Email Address\",\n * styles: \"w-full mb-4\",\n * blockProps: {\n * name: \"email\",\n * type: \"email\",\n * placeholder: \"you@example.com\",\n * required: true,\n * }\n * }\n *\n * // Transformed to TextInput props:\n * <TextInput\n * name=\"email\"\n * type=\"email\"\n * placeholder=\"you@example.com\"\n * required={true}\n * label=\"Email Address\"\n * className=\"w-full mb-4\"\n * />\n * ```\n */\nexport function createBlockAdapter<TProps extends Record<string, unknown>>(\n Component: React.ComponentType<TProps>,\n options: BlockAdapterOptions = {}\n): React.ComponentType<AdaptedComponentProps> {\n const {\n defaultProps = {},\n transformProps,\n withErrorBoundary = true,\n errorFallback,\n } = options;\n\n const AdaptedComponent: React.FC<AdaptedComponentProps> = ({ block, children, renderChildren }) => {\n // Extract component props from blockProps\n const blockProps = (block.blockProps || {}) as Record<string, unknown>;\n\n // Merge with default props\n const mergedProps = { ...defaultProps, ...blockProps };\n\n // Apply custom transformation if provided\n const finalProps = transformProps\n ? transformProps(mergedProps, block)\n : mergedProps;\n\n // Add data attributes for debugging\n const dataAttrs = {\n \"data-block-id\": block._id,\n \"data-block-type\": block._type,\n ...(block._name && { \"data-block-name\": block._name }),\n };\n\n // Merge data attributes with final props\n const componentProps = {\n ...finalProps,\n ...dataAttrs,\n } as unknown as TProps;\n\n // Render children if renderChildren callback provided\n const renderedChildren = renderChildren ? renderChildren(block._id) : children;\n\n const element = (\n <Component {...componentProps}>\n {renderedChildren}\n </Component>\n );\n\n // Wrap with error boundary if enabled\n if (withErrorBoundary) {\n return (\n <BlockErrorBoundary block={block} fallback={errorFallback}>\n {element}\n </BlockErrorBoundary>\n );\n }\n\n return element;\n };\n\n // Set display name for debugging\n const componentName = Component.displayName || Component.name || \"Component\";\n AdaptedComponent.displayName = `BlockAdapter(${componentName})`;\n\n return AdaptedComponent;\n}\n\n/**\n * Standard prop transformer for form input components.\n *\n * Applies common transformations:\n * - Maps Block `content` to `label`\n * - Maps Block `styles` to `className`\n * - Preserves all blockProps\n *\n * @param blockProps - Props from Block.blockProps\n * @param block - Full Block object\n * @returns Transformed props for component\n *\n * @example\n * ```tsx\n * const BlockTextInput = createBlockAdapter(TextInput, {\n * transformProps: standardInputTransformer,\n * });\n * ```\n */\nexport function standardInputTransformer(\n blockProps: Record<string, unknown>,\n block: Block\n): Record<string, unknown> {\n return {\n ...blockProps,\n // Use content as label if not already provided\n ...(block.content && !blockProps.label && { label: block.content }),\n // Apply Block styles as className\n ...(block.styles && { className: block.styles }),\n };\n}\n\n/**\n * Create multiple Block adapters with shared options.\n *\n * Convenience function for adapting multiple components at once\n * with the same configuration.\n *\n * @param components - Record of component name to component\n * @param options - Shared adapter options\n * @returns Record of adapted components\n *\n * @example\n * ```tsx\n * import * as Inputs from \"@page-speed/forms/inputs\";\n * import { createBlockAdapters, standardInputTransformer } from \"@page-speed/forms/integration\";\n *\n * const BlockInputs = createBlockAdapters(\n * {\n * TextInput: Inputs.TextInput,\n * TextArea: Inputs.TextArea,\n * Select: Inputs.Select,\n * },\n * {\n * transformProps: standardInputTransformer,\n * withErrorBoundary: true,\n * }\n * );\n *\n * // BlockInputs.TextInput, BlockInputs.TextArea, BlockInputs.Select\n * // are now Block-compatible\n * ```\n */\nexport function createBlockAdapters<\n TComponents extends Record<string, React.ComponentType<any>>\n>(\n components: TComponents,\n options: BlockAdapterOptions = {}\n): Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>> {\n const adapted: Record<string, React.ComponentType<AdaptedComponentProps>> = {};\n\n for (const [name, component] of Object.entries(components)) {\n adapted[name] = createBlockAdapter(component, options);\n }\n\n return adapted as Record<keyof TComponents, React.ComponentType<AdaptedComponentProps>>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@page-speed/forms",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "Ultra-high-performance React form library with field-level reactivity and tree-shakable architecture",
5
5
  "keywords": [
6
6
  "react",