0.2.11 • Published 8 months ago

tec-web-base v0.2.11

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Tec Web Base

Welcome to the comprehensive documentation for our tec-web-base npm package, a dynamic foundation meticulously built on React.js, integrating essential components and best practices for seamless and efficient software development. This robust starting point encapsulates a wealth of features, including custom hooks for HTTP services and sessions, Material-UI for component design. Whether you are a seasoned developer or just starting, this documentation provides a roadmap to leverage the rich functionalities and ensure a smooth development journey.

Getting Started

Install npm package tec-web-base in your project through this command:

npm i tec-web-base

Components

Our package comes equipped with a versatile set of components, carefully selected to enhance your development experience. Each component is designed to seamlessly integrate with your projects, providing consistent styling and behavior. Let's explore the main components included in our package:

Backdrop

The Backdrop component narrows the user's focus to a particular element on the screen.

import {Backdrop} from 'tec-web-base';

<Backdrop loading={loading}/>

Props

NameTypeDefaultDescription
loadingbooleanfalseControls the visibility of the backdrop. When set to true, the backdrop is visible; when set to false, the backdrop is hidden.

Note: You can further enhance the functionality by including the additional props available for the MUI Backdrop component... Read More

Button

The Button component allows users to take actions and make choices with a single tap.

import {Button} from 'tec-web-base';

<Button
    variant={"contained"}
    title={"Title"}
    startIcon={<AddIcon/>}
    onClick={() => {
    }}
/>

Props

NameTypeDefaultDescription
titlestring'Button'The text displayed on the button

Note: You can further enhance the functionality by including the additional props available for the MUI Button component... Read More

Checkbox

The Checkboxes allow the user to select one or more items from a set.

import {CheckBox} from 'tec-web-base';

<CheckBox
    name="jobType"
    label="Job Type"
    value={['full-time', 'contract']}
    options={[
        {id: 'full-time', label: 'Full Time', checked: false},
        {id: 'part-time', label: 'Part Time', checked: false},
        {id: 'contract', label: 'Contract', checked: false}
    ]}
    onChangeHandler={(event, selectedValues) => {
        console.log('job type', event.target.value, selectedValues)
    }}
    errors={{jobType: {message: 'Something went wrong'}}}
/>

Props

NameTypeDefaultDescription
namestring-This property will be used when you are using a checkbox in a form or when displaying errors.
labelstring'Checkbox'The text displayed as the title of the checkbox.
optionsarray-TIn this property, you will send an array of options for the checkbox.
valuearray-Represent the current state of the checkbox group. The array should contain the IDs of items that are to be checked by default.
disabledbooleanfalseThis is used to disable the checkbox group.

Note: You can further enhance the functionality by including the additional props available for the MUI FormGroup component... Read More

Dialog

A Dialog is a type of modal window that appears in front of app content to provide critical information or ask for a decision. Dialogs disable all app functionality when they appear and remain on screen until confirmed, dismissed, or a required action has been taken.

import * as React from 'react';
import Box from '@mui/material/Box';
import {Dialog} from 'tec-web-base';

export default function Component() {
    const [open, setOpen] = React.useState(false);
    return (
        <Box>
            <Dialog
                open={open}
                setOpen={setOpen}
            />
        </Box>
    );
}

You can pass children to Dialog components. This allows you to include additional content, such as text, buttons, or other components, within the dialog.

import * as React from 'react';
import Box from '@mui/material/Box';
import {Dialog} from 'tec-web-base';

export default function Component() {
    const [open, setOpen] = React.useState(false);
    return (
        <Box>
            <Dialog
                open={open}
                setOpen={setOpen}
                children={<Typography>You can pass any JSX/React component here.</Typography>}
            />
        </Box>
    );
}

Props

NameTypeDefaultDescription
openbooleanfalseIf true, the component is shown.
setOpenfunction-'setOpen' is a function that will change the state of 'open'.
actionobject{ title: 'Okay', variant: 'contained', onClick: function () {setOpen(false)} }Action is an object that contains additional props for the action button. For more details, see the 'Action Props'.
headingstring'Success!'The heading prop contains the title of the dialog.
descriptionstring'Your action has been completed successfully.'It contains the message of the dialog.
childrennode-Dialog children, usually the included sub-components.

Note: You can further enhance the functionality by including the additional props available for the MUI Dialog component... Read More

Action Props

NameTypeDefaultDescription
titlestring'Okay'The text displayed on the action button.
variantstring'contained', 'outlined', 'text', 'string'The variant to use.
onClickfunctionfunction () { setOpen(false) }Function that will call on action button click.

Note: You can further enhance the functionality by including the additional props available for the MUI Button component... Read More

FileUpload

The File Upload component allows users to easily select and upload files.

import * as React from 'react';
import Box from '@mui/material/Box';
import {FileUpload} from 'tec-web-base';

export default function BasicTextFields() {
    const [open, setOpen] = React.useState(false);
    return (
        <Box>
            <FileUpload
                name="logo"
                label="Logo"
                accept="image/*"
                onChangeHandler={(event) => {
                    let {files} = event?.target;
                    //Here You can implement your logic.
                }}
            />
        </Box>
    );
}

Props

NameTypeDefaultDescription
namestring-This property will be used when you are using a FileUpload Field in a form or when displaying errors.
labelstring'Upload File'The text displayed as the title of the
variant'contained', 'outlined', 'filled''outlined'The variant to use.
onChangeHandlerfunction-function(event: object) => void event The event source of the callback. You can pull out the new value by accessing event.target.value (string).
acceptstring'image/*'The accept attribute specifies the types of files that are allowed to be uploaded using this file input field

Note: You can further enhance the functionality by including the additional props available for the MUI Text Field component... Read More

Form

Creating a form is no more complicated while building a React application.

import React, {useEffect} from "react";
import {Form, useForm} from "tec-web-base";

export default function BasicForm() {
    const {getFormValues, setFormValues, ...others} = useForm();
    var fieldsData = [
        {
            name: "full_name",
            label: "Full Name",
            fieldStyle: {gridColumn: 'span 3'}
        },
        {
            name: "gender",
            label: "Gender",
            required: true,
            type: "select",
            fieldStyle: {gridColumn: 'span 1'},
            options: [
                {id: 1, label: "Male"},
                {id: 2, label: "FeMale"}
            ],
            disabled: false,
        },
        {
            name: "status",
            label: "Status",
            required: true,
            type: "select",
            options: [
                {id: "active", label: "Active"},
                {id: "inactive", label: "In Active"}
            ]
        },
        {
            name: "city",
            label: "City",
            type: "treeSelect",
            required: true,
            fieldStyle: {gridColumn: 'span 3/2'},
            options: [{
                id: 1,
                name: "Punjab",
                childs: [
                    {
                        id: 10,
                        name: "Lahore",
                        childs: [
                            {
                                id: 100,
                                name: "Shalimar Town",
                                childs: [],
                            },
                            {
                                id: 101,
                                name: "Gulberg",
                                childs: [],
                            },
                        ],
                    },
                    {
                        id: 11,
                        name: "Faisalabad",
                        childs: [
                            {
                                id: 105,
                                name: "Lyallpur Town",
                                childs: [],
                            },
                            {
                                id: 106,
                                name: "Madina Town",
                                childs: [
                                    {
                                        id: 115,
                                        name: "D Ground",
                                        childs: [],
                                    },
                                    {
                                        id: 116,
                                        name: "Peoples Colony",
                                        childs: [],
                                    },
                                ],
                            },
                        ],
                    },
                ],
            }
            ]
        }
    ];
    useEffect(() => {
        setFormValues({...getFormValues, full_name: 'XYZ'})
    }, [])
    return (<Form
        fieldsData={fieldsData}
        getFormValues={getFormValues}
        setFormValues={setFormValues}
        submitHandler={(values, event) => {
            //Here You can implement your logic.
        }}
        formStyle={{display: 'grid', gap: 2, gridTemplateColumns: 'repeat(3, 1fr)'}}
        actions={[
            {
                title: 'Submit',
                type: 'submit',
                variant: 'outlined',
                gridStyle: {sx: {minWidth: "15vw"}}
            },
            {
                title: 'Cancel', onClick: () => {
                    //Here You can implement your logic.
                }
            }]}
        {...others}
    />);
};

Props

NameTypeDefaultDescription
fieldsDataarray-The 'fieldsData' property, containing the fields you want to display in the form. The 'type' should be 'text', 'textarea', 'number', 'date', 'email', 'password', 'color', 'file', 'select', 'multiselect', 'checkbox' and 'radio'.
actionsarray-The 'actions' property, containing the actions you want to display in the form.
submitHandlerfunction-The function to use.
formStyleobject{display: 'grid', gap: 2, gridTemplateColumns: 'repeat(3, 1fr)'}Quickly manage the layout, alignment, and sizing of grid columns, navigation, components, and more with a full suite of responsive grid utilities. Read More

Note: 1- You can further enhance the functionality by including the additional props available for the useForm Hook... Read More

2- You can further enhance the functionality of Form Fields by including the additional props available for the MUI Input components e.g 'Text Field', 'Select', 'CheckBox' etc. Read More

TreeSelect

The TreeSelect component is a customizable tree selection input for React applications using Material-UI components. It allows users to select an item from a hierarchical list of options.

import * as React from 'react';
import Box from '@mui/material/Box';
import {TreeSelect} from 'tec-web-base';

export default function BasicTreeSelect() {
    const [value, setValue] = React.useState(null);
    const options = [
        {
            id: 1,
            name: "Punjab",
            childs: [
                {
                    id: 10,
                    name: "Lahore",
                    childs: [
                        {
                            id: 100,
                            name: "Shalimar Town",
                            childs: [],
                        },
                        {
                            id: 101,
                            name: "Gulberg",
                            childs: [],
                        },
                    ],
                },
                {
                    id: 11,
                    name: "Faisalabad",
                    childs: [
                        {
                            id: 105,
                            name: "Lyallpur Town",
                            childs: [],
                        },
                        {
                            id: 106,
                            name: "Madina Town",
                            childs: [
                                {
                                    id: 115,
                                    name: "D Ground",
                                    childs: [],
                                },
                                {
                                    id: 116,
                                    name: "Peoples Colony",
                                    childs: [],
                                },
                            ],
                        },
                    ],
                },
            ],
        },
        {
            id: 2,
            name: "Sindh",
            childs: [
                {
                    id: 20,
                    name: "Karachi",
                    childs: [
                        {
                            id: 200,
                            name: "Saddar Town",
                            childs: [],
                        },
                        {
                            id: 201,
                            name: "Gulshan Town",
                            childs: [],
                        },
                    ],
                },
                {
                    id: 21,
                    name: "Hyderabad",
                    childs: [
                        {
                            id: 205,
                            name: "Qasimabad",
                            childs: [],
                        },
                        {
                            id: 206,
                            name: "Latifabad",
                            childs: [],
                        },
                    ],
                },
            ],
        },
    ];

    return (
        <Box>
            <TreeSelect
                name="city"
                label="City"
                value={value}
                options={options}
                onChangeHandler={(event, value) => {
                    console.log(value, event);
                    setValue(value);
                }}
            />
        </Box>
    );
}

Props

NameTypeDefaultDescription
idstring-The ID for the component
namestring-This property will be used when you are using a FileUpload Field in a form or when displaying errors.
labelstring'Tree Select'The text displayed as the title of the Field
onChangeHandlerfunction-function(event: object, value: object) => void event The event source of the callback. You can pull out the new value by accessing event.target.value (string).

Note: You can further enhance the functionality by including the additional props available for the MUI OutlinedInput component... Read More

Note: The documentation for tec-web-base is currently incomplete and is still in the process of being developed. We apologize for any inconvenience this may cause and appreciate your patience.

0.2.11

8 months ago

0.2.10

8 months ago

0.2.7

8 months ago

0.2.9

8 months ago

0.2.8

8 months ago

0.1.96

1 year ago

0.1.97

1 year ago

0.1.98

1 year ago

0.1.90

1 year ago

0.1.91

1 year ago

0.1.92

1 year ago

0.1.93

1 year ago

0.1.94

1 year ago

0.1.95

1 year ago

0.1.85

1 year ago

0.1.86

1 year ago

0.1.87

1 year ago

0.1.88

1 year ago

0.1.89

1 year ago

0.1.81

1 year ago

0.1.82

1 year ago

0.1.83

1 year ago

0.1.84

1 year ago

0.2.1

12 months ago

0.2.0

1 year ago

0.2.6

10 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.2.5

11 months ago

0.2.4

11 months ago

0.1.80

1 year ago

0.1.79

1 year ago

0.1.78

1 year ago

0.1.74

1 year ago

0.1.75

1 year ago

0.1.76

1 year ago

0.1.77

1 year ago

0.1.73

1 year ago

0.1.72

1 year ago

0.1.71

1 year ago

0.1.70

1 year ago

0.1.66

1 year ago

0.1.67

1 year ago

0.1.68

1 year ago

0.1.69

1 year ago

0.1.63

1 year ago

0.1.64

1 year ago

0.1.65

1 year ago

0.1.62

1 year ago

0.1.58

1 year ago

0.1.59

1 year ago

0.1.60

1 year ago

0.1.61

1 year ago

0.1.52

1 year ago

0.1.53

1 year ago

0.1.55

1 year ago

0.1.56

1 year ago

0.1.57

1 year ago

0.1.50

1 year ago

0.1.51

1 year ago

0.1.49

1 year ago

0.1.47

1 year ago

0.1.48

1 year ago

0.1.43

1 year ago

0.1.44

1 year ago

0.1.45

1 year ago

0.1.46

1 year ago

0.1.41

1 year ago

0.1.42

1 year ago

0.1.40

1 year ago

0.1.38

1 year ago

0.1.39

1 year ago

0.1.30

1 year ago

0.1.31

1 year ago

0.1.32

1 year ago

0.1.33

1 year ago

0.1.34

1 year ago

0.1.35

1 year ago

0.1.36

1 year ago

0.1.37

1 year ago

0.1.29

1 year ago

0.1.27

1 year ago

0.1.28

1 year ago

0.1.24

1 year ago

0.1.25

1 year ago

0.1.26

1 year ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.12

1 year ago

0.1.13

1 year ago

0.1.14

1 year ago

0.1.15

1 year ago

0.1.20

1 year ago

0.1.21

1 year ago

0.1.22

1 year ago

0.1.23

1 year ago

0.1.16

1 year ago

0.1.17

1 year ago

0.1.18

1 year ago

0.1.19

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.9

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago