1.74.0 • Published 2 years ago

@shiplux/form v1.74.0

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
2 years ago

shiplux-form-library

Tutorial

a library to do forms faster

This CDN works with the react, tailwind and Babel CDN.

So in your Head HTML you will need:

 <!-- Tailwind -->
  <script src="https://cdn.tailwindcss.com"></script>

 <!-- external script -->
 <script
    crossorigin
    src="https://unpkg.com/react@18/umd/react.development.js"
 ></script>
 <script
    crossorigin
    src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
  ></script>
  <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>

  # form cnd
  <script type="text/babel" src="https://unpkg.com/shiplux-form-library@1.1.12/index.js"></script>

And in place that you want your form paste this:

<div id="shiplux-form"></div>

The ID can be whatever you want.

Then, create an js file, for example:

<script type="text/babel" src="./js/index.js" crossorigin></script>

And call the windows function to create the form:

const state = window.renderForm(formProps, "shiplux-form");

You will need the form props to create the form. this is an example:

Props example

const formProps = {
background: "#D7E9FF",
color: "",
title: "International car shipping quote",
description: "Get a detailed price instantly after complete all data. No annoying calls and additional sales!",
titleSize: 32,
width: 392,
height: 468,
numberStep: false,
isPagination: true,
pagination: {
  bgActive: "#4E91FF",
  bg: "#738CB6",
  color: "#ffffff",
},
isInternational: true,
international: {
  bg: "#ffffff",
  bgActive: "#BAD5F7",
  color: "#000000",
  borderColor: "#4E91FF",
},
steps: [
  {
    steps: [
      {
        label: "Pick Up",
        placeholder: "Select a country",
        name: "pickup",
        validations: { required: true },
        location: {
          cityZipLookup: true,
        },
      },
      {
        label: "Delivery",
        placeholder: "Select a country",
        name: "delivery",
        validations: { required: true },
        location: {
          cityZipLookup: true,
        },
      },
      {
        label: "Ship date",
        placeholder: "MM/DD/YYYY",
        name: "shipdate",
        type: "date",
      },
      {
        label: "Transport Type",
        select: true,
        name: "TransportType",
        options: [
          {
            label: "Open",
            value: 0,
          },
          {
            label: "Enclosed",
            value: 1,
          },
        ],
        validations: {
          required: true,
        },
      },
    ],
  },
  {
    title: "Step 2: Vehicles",
    isAddVehicle: true,
    isVehicleStep: true,
    steps: [
      {
        placeholder: "Type a year",
        name: "vehicleYear",
        type: "number",
        validations: {
          required: true,
        },
      },
      {
        placeholder: "Type a vehicle",
        name: "vehicleMake",
        validations: {
          required: true,
        },
      },
      {
        placeholder: "Type a model",
        name: "vehicleModel",
        validations: {
          required: true,
        },
      },
      {
        select: true,
        name: "VehicleType",
        options: [
          {
            label: "Car",
            value: "car",
          },
          {
            label: "Suv",
            value: "SUV",
          },
          {
            label: "Pickup",
            value: "pickup",
          },
          {
            label: "Van",
            value: "van",
          },
        ],
        validations: {
          required: true,
        },
      },
    ],
  },
  {
    title: "Step 3: People",
    steps: [
      {
        label: "Transport Running",
        select: true,
        name: "VehicleRunning",
        options: [
          {
            label: "Yes",
            value: 0,
          },
          {
            label: "No",
            value: 1,
          },
        ],
        validations: {
          required: true,
        },
      },
      {
        label: "First Name",
        placeholder: "Your Name",
        name: "firstName",
        validations: {
          required: true,
        },
      },
      {
        label: "Email",
        placeholder: "Your Email",
        name: "email",
        validations: {
          required: true,
        },
      },
      {
        label: "Phone Number",
        placeholder: "Your Phone",
        name: "phoneNumber",
        validations: {
          required: true,
        },
      },
    ],
  },
],
};

Sandbox:

https://codesandbox.io/s/form-sdk-shiplux-fjr35d

API:

Form

NameTypeOptional
backgroundstringYes
colorstringYes
placeholder_colorstringYes
titlestringYes
descriptionstringYes
titleSizenumberYes
widthnumberYes
heightnumberYes
stepsArray<{Step}>No
numberStepbooleanYes
isPaginationbooleanYes
paginationObject<Options>Yes
isInternationalbooleanYes
internationalObject<Options>Yes
inputOutlinebooleanYes
queryParamsstringYes
inlineInputbooleanYes
inputWidthnumberYes
buttonWidthnumberYes

Options

NameTypeOptional
bgActivestringNo
bgstringNo
colorstringNo
borderColorstringNo
firstTitlestringYes
secondTitlestringYes
isCoverbooleanYes
isBottombooleanYes

Step

NameTypeOptional
stepsArray<Input>No
titlestringYes
isAddVehiclebooleanYes
isVehicleStepbooleanYes
isshippingMethodbooleanYes

Input

NameTypeOptional
labelstringYes
placeholderstringYes
namestringNo
LocationObject<Location>No
selectbooleanYes
optionsArray<Option>Yes
validationsObject<Validation>Yes
typeinput typesYes
vehicleYearbooleanYes
vehicleMakeAPIbooleanYes
vehicleModelAPIbooleanYes

Option

NameTypeOptional
labelstringNo
Valuestring or numberNo
defaultValuestring or numberYes

Validation

NameTypeOptional
requiredbooleanYes
minnumberYes
maxnumberYes

Location

NameTypeOptional
cityZipLookupbooleanYes
autoCompletebooleanYes
1.74.0

2 years ago

1.73.0

2 years ago

1.72.0

2 years ago

1.71.0

2 years ago

1.70.0

2 years ago

1.69.0

2 years ago

1.68.0

2 years ago

1.67.0

2 years ago

1.66.0

2 years ago

1.65.0

2 years ago

1.64.0

2 years ago

1.63.0

2 years ago

1.62.0

2 years ago

1.61.0

2 years ago

1.60.0

2 years ago

1.59.0

2 years ago

1.58.0

2 years ago

1.57.0

2 years ago

1.56.0

2 years ago

1.55.0

2 years ago

1.54.0

2 years ago

1.53.0

2 years ago

1.52.0

2 years ago

1.51.0

2 years ago

1.50.0

2 years ago

1.49.0

2 years ago

1.48.0

2 years ago

1.47.0

2 years ago

1.46.0

2 years ago

1.45.0

2 years ago

1.44.0

2 years ago

1.43.0

2 years ago

1.42.0

2 years ago

1.41.0

2 years ago

1.40.0

2 years ago

1.39.0

2 years ago

1.38.0

2 years ago

1.37.0

2 years ago

1.36.0

2 years ago

1.35.0

2 years ago

1.34.0

2 years ago

1.33.0

2 years ago

1.32.0

2 years ago

1.31.0

2 years ago

1.30.0

2 years ago

1.29.0

2 years ago

1.28.0

2 years ago

1.27.0

2 years ago

1.26.0

2 years ago

1.25.0

2 years ago

1.24.0

2 years ago

1.23.0

2 years ago

1.22.0

2 years ago

1.21.0

2 years ago

1.20.0

2 years ago

1.19.0

2 years ago

1.18.0

2 years ago

1.17.0

2 years ago

1.16.0

2 years ago

1.15.0

2 years ago

1.14.0

2 years ago

1.13.0

2 years ago

1.12.0

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago