New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

daply-ui

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daply-ui

A React component library for building beautiful, modern forms that integrate seamlessly with the Daply backend. Features professional styling inspired by Daply forms with automatic light/dark theme support.

latest
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

@daply-ui

A React component library for building beautiful, modern forms that integrate seamlessly with the Daply backend. Features professional styling inspired by Daply forms with automatic light/dark theme support.

✨ Features

  • 🎨 Modern Design - Clean, professional styling matching Daply form aesthetics
  • 🌓 Theme Support - Automatic light/dark theme adaptation
  • Built-in Validation - Required fields, email, URL validation
  • 🔧 Custom Validation - Define your own validation rules
  • 🚀 API Integration - Automatic submission to Daply backend
  • 📱 Responsive - Mobile-first design that works everywhere
  • 💪 TypeScript - Full type safety and IntelliSense support
  • 🎯 Customizable - Override any styling with custom classes

Installation

npm install daply-ui

No additional dependencies required! The library uses inline styles, so it works out of the box without needing Tailwind CSS or any other CSS framework.

Components

Button Component

A beautiful animated button component with shadow effects and hover animations:

  • 🎨 Animated Shadow - 3D push-down effect on hover
  • 🎯 Multiple Variants - Primary and secondary styles
  • 📏 Size Options - Small, default, and large sizes
  • 🎨 Theme Support - Automatic light/dark theme adaptation
  • 🔘 Icon Support - Add icons to left or right
  • Smooth Animations - Transition effects on all interactions

Form Component

A fully-featured form component with built-in validation and Daply backend integration.

MultiStepForm Component

A powerful multi-step form component that breaks long forms into manageable steps with:

  • Step Navigation - Forward and backward navigation with validation
  • 📊 Progress Indicator - Visual step progress tracking
  • 💾 Data Persistence - Form data persists across all steps
  • Step Validation - Validates each step before allowing navigation
  • 🎨 Custom Styling - Title and description for each step

VideoPlayer Component

A modern video player component with support for multiple video sources:

  • 🎬 YouTube Support - Embed YouTube videos with optimized parameters
  • 📺 HLS Streaming - Support for HLS streams (including Daply transcoder)
  • 🖼️ Custom Thumbnails - Display custom thumbnails before playback
  • Performance Optimized - Lazy loading and efficient video embedding
  • 🎨 Theme Support - Automatic light/dark theme adaptation
  • 🔗 External Links - Open videos in new tab

Basic Usage

Button Usage

import { Button } from 'daply-ui';

// Primary Button
function PrimaryButtonExample() {
  return (
    <Button
      label="Click Me"
      variant="primary"
      theme="light"
      onClick={() => alert('Clicked!')}
    />
  );
}

// Secondary Button
function SecondaryButtonExample() {
  return (
    <Button
      label="Secondary"
      variant="secondary"
      theme="dark"
    />
  );
}

// Button with Icon
function IconButtonExample() {
  return (
    <Button
      label="Download"
      variant="primary"
      icon={<DownloadIcon />}
      iconPosition="right"
      size="large"
    />
  );
}

// Different Sizes
function SizeExamples() {
  return (
    <>
      <Button label="Small" size="small" variant="primary" />
      <Button label="Default" size="default" variant="primary" />
      <Button label="Large" size="large" variant="primary" />
    </>
  );
}

// Disabled State
function DisabledExample() {
  return (
    <Button
      label="Disabled"
      disabled={true}
      variant="primary"
    />
  );
}

Form Usage

import { Form } from 'daply-ui';

function App() {
  return (
    <Form
      formId="contact-form"
      siteId="my-website"
      baseUrl="https://api.daply.com"
      apiToken="your-api-token-here"
      encryptedDbName="ff95d16da2340fe621ce03a61b9e6ee5b2c5dacbb12bd1914cb3dae6e5ad1bea73029edd7bf8bae1eefaa23cde52ea28"
      theme="dark" // 'light', 'dark', or 'auto' (default)
      fields={[
        {
          name: "name",
          type: "text",
          label: "Name",
          required: true,
          placeholder: "Enter your name"
        },
        {
          name: "email",
          type: "email",
          label: "Email",
          required: true,
          placeholder: "your.email@example.com"
        },
        {
          name: "subject",
          type: "text",
          label: "Subject",
          required: true,
          placeholder: "What's this about?"
        },
        {
          name: "message",
          type: "textarea",
          label: "Message",
          required: true,
          rows: 6,
          placeholder: "Your message here..."
        }
      ]}
      onSuccess={(response) => {
        console.log("Form submitted successfully!", response);
        alert("Thank you for your submission!");
      }}
      onError={(error) => {
        console.error("Form submission failed:", error);
        alert("Something went wrong. Please try again.");
      }}
    />
  );
}

Multi-Step Form Usage

Break long forms into manageable steps with automatic data persistence and step validation.

import { MultiStepForm } from 'daply-ui';

function App() {
  return (
    <MultiStepForm
      formId="signup"
      siteId="my-website"
      baseUrl="https://api.daply.com"
      apiToken="your-api-token-here"
      encryptedDbName="ff95d16da2340fe621ce03a61b9e6ee5b2c5dacbb12bd1914cb3dae6e5ad1bea73029edd7bf8bae1eefaa23cde52ea28"
      theme="dark"
      showStepIndicator={true} // Show visual progress indicator
      steps={[
        {
          id: 'account',
          title: 'Account Information',
          description: 'Let\'s start with your basic account details',
          fields: [
            { 
              name: 'email', 
              type: 'email',
              label: 'Email Address', 
              required: true,
              placeholder: 'you@example.com'
            },
            { 
              name: 'password', 
              type: 'text',
              label: 'Password', 
              required: true,
              placeholder: 'Create a strong password',
              validation: (value) => {
                if (value.length < 8) {
                  return "Password must be at least 8 characters";
                }
                return undefined;
              }
            },
          ],
        },
        {
          id: 'profile',
          title: 'Personal Information',
          description: 'Tell us a bit about yourself',
          fields: [
            { 
              name: 'firstName', 
              type: 'text',
              label: 'First Name',
              required: true,
              placeholder: 'John'
            },
            { 
              name: 'lastName', 
              type: 'text',
              label: 'Last Name',
              required: true,
              placeholder: 'Doe'
            },
          ],
        },
      ]}
      submitButtonText="Create Account"
      onSuccess={(response) => {
        console.log("Form submitted successfully!", response);
        alert("Account created successfully!");
      }}
      onError={(error) => {
        console.error("Form submission failed:", error);
        alert("Something went wrong. Please try again.");
      }}
    />
  );
}

MultiStepForm Features

  • Automatic Data Persistence: Form data is preserved as users navigate between steps
  • Step Validation: Each step is validated before allowing forward navigation
  • Visual Progress: Optional step indicator shows users where they are in the process
  • Back Button: Users can go back to previous steps to review or edit their data
  • Custom Step Content: Each step can have its own title and description
  • All Form Features: Supports all the same validation, theming, and customization options as the regular Form component

Video Player Usage

Play YouTube videos, HLS streams, or custom video files with a beautiful, responsive player.

import { VideoPlayer } from 'daply-ui';

// YouTube Video
function YouTubeVideoExample() {
  return (
    <VideoPlayer
      youtubeUrl="https://www.youtube.com/watch?v=dQw4w9WgXcQ"
      title="My YouTube Video"
      author="Creator Name"
      theme="auto"
      onVideoClick={() => console.log('Video clicked!')}
    />
  );
}

// HLS Stream (Daply or any HLS)
function HLSStreamExample() {
  return (
    <VideoPlayer
      videoUrl="https://storage.googleapis.com/daply-transcoder-storage/sample/manifest.m3u8"
      title="Live HLS Stream"
      author="Daply"
      thumbnailUrl="https://example.com/thumbnail.jpg"
      theme="dark"
      autoplay={false}
    />
  );
}

// Custom Video File
function CustomVideoExample() {
  return (
    <VideoPlayer
      videoUrl="https://example.com/video.mp4"
      title="Custom Video"
      author="Your Company"
      date={new Date().toISOString()}
      thumbnailUrl="https://example.com/thumbnail.jpg"
      theme="light"
    />
  );
}

VideoPlayer Features

  • Multiple Video Sources: YouTube, HLS streams, or standard video files (mp4, webm, etc.)
  • Smart Detection: Automatically detects video type and uses appropriate player
  • Custom Thumbnails: Display custom preview images before playback
  • Lazy Loading: Videos load only when needed for better performance
  • Theme Support: Adapts to light, dark, or auto themes
  • Responsive Design: Perfect 16:9 aspect ratio on all devices
  • External Links: Built-in button to open videos in new tabs
  • Loading States: Smooth loading indicators during video initialization
  • Optimized YouTube Embeds: Pre-configured parameters for best performance

Advanced Usage

Custom Styling

<Form
  formId="styled-form"
  siteId="my-website"
  baseUrl="https://api.daply.com"
  apiToken="your-api-token-here"
  fields={[
    {
      name: "username",
      type: "text",
      label: "Username",
      required: true,
      className: "custom-input-class"
    }
  ]}
  formClassName="my-custom-form"
  submitButtonClassName="my-custom-button"
  submitButtonText="Send Message"
  loadingText="Sending..."
/>

With Metadata and Tracking

<Form
  formId="contact-form"
  siteId="my-website"
  baseUrl="https://api.daply.com"
  apiToken="your-api-token-here"
  pageUrl={window.location.href}
  pageId="contact-page"
  sessionId="user-session-id"
  metadata={{
    source: "contact page",
    campaign: "organic",
    userAgent: navigator.userAgent
  }}
  fields={[
    // ... your fields
  ]}
/>

Custom Validation

<Form
  formId="signup-form"
  siteId="my-website"
  baseUrl="https://api.daply.com"
  apiToken="your-api-token-here"
  fields={[
    {
      name: "password",
      type: "text",
      label: "Password",
      required: true,
      validation: (value) => {
        if (value.length < 8) {
          return "Password must be at least 8 characters";
        }
        if (!/[A-Z]/.test(value)) {
          return "Password must contain at least one uppercase letter";
        }
        if (!/[0-9]/.test(value)) {
          return "Password must contain at least one number";
        }
        return undefined; // No error
      }
    }
  ]}
/>

All Available Field Types

<Form
  formId="all-fields-form"
  siteId="my-website"
  baseUrl="https://api.daply.com"
  apiToken="your-api-token-here"
  fields={[
    {
      name: "text_field",
      type: "text",
      label: "Text Input",
      placeholder: "Enter text"
    },
    {
      name: "email_field",
      type: "email",
      label: "Email Input",
      placeholder: "email@example.com"
    },
    {
      name: "number_field",
      type: "number",
      label: "Number Input",
      placeholder: "123"
    },
    {
      name: "tel_field",
      type: "tel",
      label: "Phone Number",
      placeholder: "+1 (555) 123-4567"
    },
    {
      name: "url_field",
      type: "url",
      label: "Website URL",
      placeholder: "https://example.com"
    },
    {
      name: "textarea_field",
      type: "textarea",
      label: "Textarea",
      rows: 5,
      placeholder: "Enter multiple lines..."
    }
  ]}
/>

API Reference

Button Props

PropTypeRequiredDescription
labelstringNoButton text label
childrenReactNodeNoCustom button content (overrides label)
disabledbooleanNoWhether button is disabled (default: false)
colorstringNoColor identifier (default: "blue-900")
iconReactNodeNoIcon to display with button
iconPosition'left' | 'right'NoIcon position (default: 'right')
classNamestringNoAdditional CSS classes
styleCSSPropertiesNoInline styles object
type'button' | 'submit' | 'reset'NoButton type (default: 'button')
size'small' | 'default' | 'large'NoButton size (default: 'default')
variant'primary' | 'secondary'NoButton style variant (default: 'primary')
theme'light' | 'dark' | 'auto'NoTheme mode (default: 'auto')
onClick(e: MouseEvent) => voidNoClick handler function
isNoLabelForSmbooleanNoHide label on small screens (default: false)

FormConfig Props

PropTypeRequiredDescription
formIdstringYesUnique identifier for the form
siteIdstringYesIdentifier for your site
baseUrlstringYesDaply API base URL
apiTokenstringYesBearer token for authentication
encryptedDbNamestringYesEncrypted database name for x-encrypted-db-name header
fieldsFormField[]YesArray of form fields (see below)
theme'light' | 'dark' | 'auto'NoTheme mode (default: 'auto')
pageUrlstringNoCurrent page URL for tracking
pageIdstringNoPage identifier for tracking
sessionIdstringNoUser session ID for tracking
metadataobjectNoAdditional metadata to send with form
onSuccess(response: any) => voidNoCallback when form submits successfully
onError(error: Error) => voidNoCallback when form submission fails
submitButtonTextstringNoSubmit button text (default: "Submit")
submitButtonClassNamestringNoCustom CSS class for submit button
formClassNamestringNoCustom CSS class for form wrapper
loadingTextstringNoLoading text (default: "Submitting...")

FormField Props

PropTypeRequiredDescription
namestringYesField name (must be unique)
typeFieldTypeYesField type: text, email, textarea, number, tel, url
labelstringNoLabel text displayed above field
requiredbooleanNoWhether field is required (default: false)
placeholderstringNoPlaceholder text
defaultValuestringNoDefault value for the field
rowsnumberNoNumber of rows (for textarea only)
classNamestringNoCustom CSS class for input element
validation(value: string) => string | undefinedNoCustom validation function

MultiStepFormConfig Props

MultiStepFormConfig extends all FormConfig props (except fields) and adds:

PropTypeRequiredDescription
stepsFormStep[]YesArray of form steps (see below)
showStepIndicatorbooleanNoWhether to show step progress indicator (default: true)

Note: All other props from FormConfig (formId, siteId, baseUrl, apiToken, etc.) are also required.

FormStep Props

PropTypeRequiredDescription
idstringYesUnique identifier for the step
titlestringNoTitle displayed at the top of the step
descriptionstringNoDescription text displayed below the title
fieldsFormField[]YesArray of form fields for this step

VideoPlayerConfig Props

PropTypeRequiredDescription
videoUrlstring | null | undefinedNoDirect video URL (mp4, webm, HLS manifest)
youtubeUrlstring | null | undefinedNoYouTube video URL
titlestringYesVideo title displayed in thumbnail and metadata
authorstringNoAuthor/creator name (default: "Daply")
datestringNoISO date string for video metadata
thumbnailUrlstring | null | undefinedNoCustom thumbnail image URL
autoplaybooleanNoWhether to autoplay video (default: false)
classNamestringNoAdditional CSS classes
onVideoClick() => voidNoCallback when video play button is clicked
theme'light' | 'dark' | 'auto'NoTheme mode (default: 'auto')

Note: Either videoUrl or youtubeUrl must be provided.

Styling

The components use inline styles for maximum compatibility and zero dependencies. They work out of the box without requiring Tailwind CSS or any other CSS framework.

Theme Support

The components automatically adapt to light and dark modes:

// Light theme
<Form theme="light" {...props} />

// Dark theme (like Oasis Energy form)
<Form theme="dark" {...props} />

// Auto-detect user's system preference (default)
<Form theme="auto" {...props} />

Default Styles

  • Form Container: Clean white (light) / dark #1a1a1a (dark) with subtle shadows
  • Input Fields: Large padding (16px), rounded corners, smooth transitions
  • Focus States: Blue ring with smooth animations
  • Error States: Red border and background tint
  • Submit Button: Gradient blue with hover effects and uppercase text

Customization Options

You can add custom classes for additional styling:

<Form
  formClassName="my-custom-form"
  submitButtonClassName="my-custom-button"
  fields={[
    {
      name: "email",
      type: "email",
      className: "my-custom-input"
      // Add your own CSS classes
    }
  ]}
/>

Note: Inline styles take precedence, but you can use !important in your custom CSS to override them if needed.

TypeScript Support

Full TypeScript support with exported types:

import type {
  FormConfig,
  FormField,
  FormSchema,
  FormData,
  FieldType,
  FieldSchema,
  DaplyFormSubmission,
  MultiStepFormConfig,
  FormStep,
  VideoPlayerConfig
} from 'daply-ui';

API Endpoint

The form submits to:

POST {{baseUrl}}/api/v1/form-submissions

With the following payload structure:

{
  "formId": "contact-form",
  "siteId": "my-website",
  "formData": {
    "name": "John Doe",
    "email": "john@example.com",
    "subject": "Inquiry",
    "message": "This is a test message."
  },
  "formSchema": {
    "name": { "type": "text", "required": true },
    "email": { "type": "email", "required": true },
    "subject": { "type": "text", "required": true },
    "message": { "type": "textarea", "required": true }
  },
  "pageUrl": "https://example.com/contact",
  "pageId": "contact-page",
  "sessionId": "sess_123456789",
  "metadata": {
    "source": "contact page",
    "campaign": "organic"
  }
}

Headers:

Content-Type: application/json
Authorization: Bearer {your-api-token}
x-encrypted-db-name: {your-encrypted-db-name}

Important: Store your apiToken and encryptedDbName securely in environment variables:

<Form
  apiToken={process.env.REACT_APP_DAPLY_TOKEN}
  encryptedDbName={process.env.REACT_APP_ENCRYPTED_DB_NAME}
  // ... other props
/>

Features

  • Animated Buttons - Beautiful 3D push-down effect with shadows
  • Multiple Button Variants - Primary and secondary styles
  • Button Sizes - Small, default, and large options
  • ✅ Built-in validation (required fields, email, URL)
  • ✅ Custom validation functions
  • ✅ Automatic form submission to Daply backend
  • ✅ Loading states with smooth animations
  • ✅ Error handling with user-friendly messages
  • ✅ Success/error callbacks
  • ✅ Full TypeScript support
  • ✅ Modern, clean design inspired by Daply forms
  • ✅ Light & Dark theme support (automatic)
  • ✅ Customizable styling with Tailwind CSS
  • ✅ Multiple field types (text, email, textarea, number, tel, url)
  • ✅ Metadata and tracking support
  • ✅ Smooth transitions and hover effects
  • ✅ Mobile-responsive design
  • Multi-step forms with automatic data persistence
  • Step validation - validate each step before proceeding
  • Visual progress indicator - show users their progress
  • Back/Next navigation - easily navigate between steps
  • Video Player - YouTube, HLS streams, and custom videos
  • Optimized Video Playback - lazy loading and performance optimizations
  • Custom Thumbnails - beautiful video previews

Development

# Install dependencies
npm install

# Run development server
npm run dev

# Build library
npm run build

# Publish to npm
npm run publish

License

MIT

Support

For issues and questions, please visit our GitHub repository.

FAQs

Package last updated on 08 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts