0.2.13 • Published 3 years ago

@bugsworld85/neocomponents v0.2.13

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Neo VueJS Components

Pre built VueJS components to make developer's life easier.

Available Components!

  • NeoTable - with first row and multiple column freezing.
  • NeoWindow - movable, drag and drop window component.
  • NeoPaginator - pagination component.

Upcoming components:

  • NeoFloater - an element that is draggable across the screen.

Pre-Requisite

Dependencies

  • Lodash - A modern JavaScript utility library delivering modularity, performance & extras.
  • MomentJS - Parse, validate, manipulate, and display dates and times in JavaScript.

Dev-Dependencies

Install global or within package, its up to you.

Installation

NeoComponents requires Node.js v12+ to run.

Install the dependencies and devDependencies and start the server.

$ npm install --save @bugsworld85/neocomponents

Include into your component.

import { NeoTable, NeoWindow, NeoPaginator } from "@bugsworld85/neocomponents"

Component Testing

$ npm run serve

Components

NeoTable

Dynamic table component

<neo-table
    :data="data"
    :columns="columns"
></neo-table>
import { NeoTable } from "@bugsworld85/neocomponents";
import moment from "moment";

export default {
    components: {
        NeoTable
    },
    data() {
        return {
            data: [], // array of object data
            columns: [
                {
                    key: "id",
                    title: "ID",
                    freeze: true
                },
                {
                    key: "sku",
                    title: "SKU",
                    searchable: true,
                    sortable: true,
                    freeze: true, // freezed initially
                    type: 'template',
                    template: Vue.components("your-component", {
                        template: `<span>${row.sku}</span>`,
                        props: ["row", "column", "index"],
                    }),
                    // ---- OR ----
                    // template: YourComponent
                },
                {
                    key: "name",
                    title: "Name",
                    searchable: true,
                    sortable: true,
                    type: 'text' // double click to edit
                    // available events
                    change(e, row, column) {},
                    keydown(e, row, column) {},
                    keyup(e, row, column) {},
                    input(e, row, column) {},
                    blur(e, row, column) {},
                    doubleClick(e, row, column) {},
                },
                {
                    key: "qty",
                    title: "Quantity",
                    searchable: true,
                    sortable: true,
                    type: 'number' // double click to edit
                    disableFreezing: true // do not show freeze button in this column
                },
                {
                    key: "created_at",
                    title: "Date Created",
                    sortable: true,
                    mutate: (value) => {
                        return moment(value).format("DD-MM-YYYY");
                    },
                },
                {
                    key: "actions",
                    type: "actions",
                    textAlign: "right",
                    width: 10,
                    actions: [
                        Vue.component("view-product", {
                            template: `<a class="btn" :href="link"><i class="fa fa-edit"></i></a>`,
                            props: ["column", "row"],
                            computed: {
                                link() {
                                    return `https://test.com/product/${this.row.id}`;
                                },
                            },
                        }),
                    ],
                },
            ],
        }
    }
}

Component Properties

NameTypeDefaultDescription
columnsArray[]Define column properties, cell value mutation or event callbacks.
dataArray[]Data to be inserted into the table.
emptyMessageString"No data available"Message to display if data is empty.
enableSearchBooleanfalseEnable and display search field. Searches from given data only.
exludeColumnsArray[]Exclude properties from given data.
freezeColumnInteger0Freeze number of columns starting from first column with index 0.
isAscBooleantrueSort direction. Ascending if true, descending if false
limitInteger15Number of data to be displayed in each pagination.
loadingMessageString"Loading..."Message to display when data is being loaded.
maxHeightIntegernullThe maximum height of the table. Screen height by default.
allowMultipleRowSelectionBooleantrueEnable multiple row selection.
pageInteger1@deprecated Page to display if showAll is false and pagination is present.
placeholderString"Search for..."Placeholder text on search input field.
searchedKeywordStringnullThe search keyword string.
enableDataFilterBooleanfalse@deprecated Enable or disable built-in data filtration. Useful if you are just passing data and does the filtration manually.
enableDataSortingBooleanfalse@deprecated Enable or disable built-in data table sorting. Useful if you are sorting data manually.
enableDataPaginationBooleanfalse@deprecated Enable or disable built-in data pagination. Useful if you are paginating data manually.
sortedColumnStringnullThe sorted column.
totalTableRowsInteger0The length of data.

Component Events

EventAcceptsDescription
@onRowSelectisChecked, row, index, data, eventFired when you selected a row via checkbox. Only when allowMultipleRowSelection is true. data contains all checked items.
@onCheckAllisChecked, data, eventFired when you check column header checkbox. Only when allowMultipleRowSelection is true.
@sortClicksortColumnKey, isAscFired when you click on column header title.
@rowClickrowListen to row click.
@mountedNeoTableHook when NeoTable is mounted.
@rowMountedrow, index, TableRowHook when table row is mounted.

Column Properties

PropertyTypeDefaultRequiredDescription
keyStringnullyesServes as the column identifier and can be any property of an object from the data and will render the value of that property instantly. But you can use any column identifier and use along side mutate.
titleStringnullnoTitle of the column. Can be empty string.
searchableBooleanfalsenoIncludes the column from data searching.
sortableBooleanfalsenoDetermines if the column is sortable.
freezeBooleanfalsenoDetermines whether to freeze the column initially.
textAlignStringleftnoleft, center, right
widthIntegernullnoWidth of the column.
messageStringnullnoMessage to display when column prompt type has been triggered.
typeString"string"nostring, text, number, switch, checkbox, actions, template, options, prompt, divider, columns. Definition of each type is described below.
disableFreezingBooleanfalsenoHide's the freeze button from the table header.
optionsArray[]noOptions for select column type. Accepts Array of { value: text } object.
editOnClickBooleanfalsenoEdit target cell on a single click. Works on input type columns only.

Column Methods

PropertyTypeDefaultAcceptsRequiredDescription
mutateFunctionnullvalue, row, column, TableRownoCallback function to mutate or alter column data value. Accepts 2 parameters which is the cell value and the row data. Must return desired output.
confirmedFunctionnullvalue, row, oldValue, TableRownoCallback function after confirming the prompt input.

Column Available Events (text and number column types only)

PropertyTypeAcceptsDescription
changeFunctione, value, rowchange event of a text, number, checkbox, select input elements.
keydownFunctione, value, rowkeydown event of a text, number input elements.
keyupFunctione, value, rowkeyup event of a text, number input elements.
inputFunctione, value, rowinput event of a text, number input elements.
blurFunctione, value, rowblur event of a text, number input elements.
doubleClickFunctione, value, rowdoubleClick event of a text, number input elements.

Column Types

TypeDescription
stringRegular string. No events attached.
textInput of type text. Double click to edit.
numberInput of type number. Double click to edit.
switchCheckbox displayed as a switch. Capture input value via change column method.
checkboxInput of type checkbox. Capture input value via change column method.
selectselect dropdown options. options property is required when using this type.
promptOpens browser input prompt. Capture input value via confirm column method.
actionsArray of Vue components and can be anything you want.
templateA single Vue component. Can be anything you want to display within the column and handle column cell events independently from NeoTable.
dividerA simple column divider. Does not require key column property.
Coming Soon!
TypeDescription
columnsSub columns. Array of columns. key and title properties are required. key should match object property from your data array.

Slots

NameDescription
searchReplaces table search component.
filterAdd additional components right next to table search field.
before-tableAdd additional components before table.
paginateReplaces the pagination data in the footer.
loadingReplaces the loading section.
emptyDisplays when table is empty.
table-headReplace the table header (thead) with your your custom component.
table-rowReplace the table row (tr) with your your custom component.

Todos

  • Write documentation on NeoWindow
  • Write documentation on NeoPaginator
  • Include textarea in column types.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT © Jovanni G

0.2.13

3 years ago

0.2.12

3 years ago

0.2.10

3 years ago

0.2.7

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.5

3 years ago

0.2.3

3 years ago

0.2.4

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.20

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.8

3 years ago

0.1.17

3 years ago

0.1.7

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago