Daron  Moore

Daron Moore

1658034000

React-based Customizable Style Table Or List Components That Support

React-tabllist

React-based list (table) components that support events, callback functions, and custom styles.


  🔧 Install

npm install react-tabllist --save

📚 Usage

Use in browser

  <script src="https://cdn.bootcss.com/react/16.8.6/umd/react.development.js"></script>
  <script src="https://cdn.bootcss.com/react-dom/16.8.6/umd/react-dom.development.js"></script>
  <script src="https://cdn.bootcss.com/babel-standalone/7.0.0-beta.3/babel.min.js"></script>
  <script src='https://cdn.bootcss.com/lodash.js/4.17.11/lodash.core.js'></script>
  <script src='./react-tabllist.min.js'></script>

  <div id='example'></div>
  <script type='text/javascript'>
    var option = {
      data: [],
      property: {}
    }

    ReactDOM.render(
      React.createElement(ReactTabllist, option),
      document.getElementById('example')
    )
  </script>

Use in ES6 & jsx

  import ReactTabllist from 'react-tabllist';

  // Use default configuration
  ReactDOM.render(<ReactTabllist />, mountNode);

  // Custom data and configuration items
  const props = {
    className: 'demo',
    property: {},
    data: [
      ['1st column', '2nd column', '3rd column'],
      ['1st cell', '2nd cell', '3rd cell']
    ]
  }

  ReactDOM.render(<ReactTabllist {...props} />, mountNode);

  /**
   * Event callback function
   * @param {SyntheticEvent} event
   * @param {Exposes} exposes An object containing exposed properties and methods
   */
  function handleScroll(event, exposes) {
    // some code
  }

  // Use React native events
  ReactDOM.render(<ReactTabllist {...props} onScroll={handleScroll} />, mountNode);

  // Use custom events built into components
  ReactDOM.render(<ReactTabllist {...props} custom_onScrollToEnd={handleScroll} />, mountNode);

💻 Development

If you want to join the development to improve this component, please fork and start with the following command:

  $ git clone git@github.com:oceanxy/react-tabllist.git
  $ cd react-tabllist
  $ npm install
  $ npm start

Open your browser and visit http://localhost:3001.

📝 Version Information

Change Log

🧰 Configuration

propsdescriptiondetails
data 
{[Array, Array, Array,...]}
Render table dataprops.data
className 
{string}
Table outermost container style sheet name''
property 
{Object}
Wrapper table propertiesprops.property

props.className

You can customize the style through the props.classname attribute.

props.data

Data Format

The data data format is very similar to a two-dimensional array。

  • Each subarray in the array represents a row, and each element in the subarray represents a cell. The order in which cells are displayed is the order in which the arrays are indexed, so the order and display of each cell should be determined when reconstructing the data.
  [
    [cell, cell, cell], // row
    [
      cell, // cell
      cell,
      cell
    ],
    [cell, cell, cell],
    ...
  ]
  • An object can also represent a row in a two-dimensional array. This object has two required attributes: type='row' and cells=[], which respectively identify the object as a row and the cells contained in the row:
[
  {  // The rows are displayed as objects, and the in-row cells are contained in the cells field as an array.
    type: 'row',
    cells: [cell, cell, cell],
    ...
  },
  [  // Display rows as an array, each element representing a cell
    {type: 'button', ...},   // Generate a button in the cell
    cell,  // cell
    cell
  ],
  [
    cell,
    cell,
    [
        {type: 'radio'}, {type: 'radio'}, ... // Generate two or more radios in the same cell
    ]
  ],
  ...
]

Object Unit

The data format that cells can parse is divided into the following four categories:

  • String
  • Array,These four data formats can be nested inside the array again.
  • jsx,Such as: <button className='test-button' onclick='()=>{return null}'>click</button>
  • Object(Object cell),Details are as follows:
typedescription
rowGenerate a unit row, unit row object can only be written in the body, invalid elsewhere
imgGenerate an img tag inside the cell
buttonGenerate a button in the cell
linkGenerate a link in the cell (a tag)
radioGenerate a radio in the cell
checkboxGenerate a checkbox in the cell
select ^1.4.1Generate a select in the cell
text ^1.5.0Generate a plain text inside the cell. You can also replace the object unit with a string. If you don't plan to add events to this cell, you can do that.
input ^1.6.0Generate a text box in a cell.

Here are some examples:

row

{
  type: 'row',
  cells: [cell, cell, cell],
  data: 'row.id',
  value: 'row.typeID',
  event: 'onClick',
  callback: (data, cellData, event) => {},
  className: '',
  key: ''
}

button

{
  type: 'button',
  value: 'click me',
  className: 'test-btn',
  data: '123',
  event: 'onClick',
  callback: data => alert('hello react-tabllist', data) // hello react-tabllist, 123,
  key: ''
}

img

{
  type: 'img',
  src: 'http://www.xieyangogo.cn/pic.png',
  alt: '',
  text: 'IMG description',
  className: 'test-img',
  key: '',
  value:''
}

link (Choose one of the two)

{
  type: 'link',
  text: 'I am a link, I use the href attribute',
  className: 'test-link',
  key: '',
  href: 'https://github.com/oceanxy/react-tabllist',
  value:''
}
{
  type: 'link',
  text: 'I am a link, I use event and callback to implement custom functions',
  className: 'test-link',
  key: '',
  data:  {},
  event: 'onClick',
  callback: (data, cellData, event) => {},
  value:''
}

radio

{
  type: 'radio',
  name: 'group2',
  text: 'radio group 2-1',
  className: 'test-radio',
  callback: (data, cellData, event) => {},
  key: '',
  value:''
}

checkbox

{
  type: 'checkbox',
  name: 'checkbox1',
  text: 'checkbox',
  className: 'test-checkbox',
  callback: (data, cellData, event) => {},
  key: '',
  value:''
}

select

{
  type: 'select',
  text: 'please choose:',
  value: '',
  data: '',
  className: '',
  callback: (data, cellData, event) => {},
  option: [
    {
      id: '1',
      label: 'item 1',
      value: 1
    }
  ]
}

text

{
  type: 'text',
  text: 'I am a normal text',
  callback: (data, cellData, event) => {}
}

input

{
  type: 'input',
  text: 'username:',
  placeholder: 'enter username',
  defaultValue: 'oceanxy' // This attribute is not a standard HTML tag attribute, but it is a property of the React element (the purpose is to set the default value of the text box). As you can see, you can also use React's officially defined properties in object cells.
}

Object Unit Attribute

Attribute {type}Descriptionrowbuttonlinkimgradiocheckboxinputselecttext
uid 
{string} Available before version 1.2.2
Deprecated A unique identifier for a cell that can be used to save ids, and so on. This field function is similar to the key, and can also be replaced with a data field in conjunction with a callback function, so it is decided to discard this field in version 1.2.2.
type 
{string}
The type of HTML tag to be generated in the cell
text 
{string}
The text of the rendered HTML tag
event 
{string}
The way to trigger an event needs to be used with callback
callback 
{function}
The callback function after the trigger event, see the callback for details.
cells 
{object[]}
Can only be used with the row type, see the data for details.
data 
{*}
Custom attributes can theoretically pass any value. This value is not used inside the component, you can get this value in the first parameter of the callback
option 
{object[]}
Can only be used with the select type, see the option for details.

HTML Attribute

The usage of these attributes is the same as that of native HTML tags. They are listed to indicate the points to be aware of when using them.

Attribute {type}Description
name 
{string}
The attributes that the radio and checkbox must set, the same as the name attribute of the HTML-like tag.
value 
{number|string}
The value attribute of the generated HTML tag, **All object cell can be used starting with version 1.4.1**
src 
{string}
Image link, such as: 'http(s)://xxx' or 'data:image/xxx'
alt 
{string}
The alt attribute of the image
href 
{string}
The hyperlink type of the link type (the same as the href of the HTML a tag), or you can use this combination of event and callback to customize the event callback without passing this attribute.

For more tag attributes please visit w3schools.

React Element Attribute

Attribute {type}Description
key 
{string}
Jsx loop or array need to use the key attribute, Please ensure the uniqueness of the key
className 
{string}
Custom style sheet name
defaultValue 
{string|number}
The default value of labels such as text boxes, different from value

For more attributes, see the type definition file (d.ts) of the react library.

Callback

v1.5.0 and earlier

callback(data:Array[], objectUnit:object, event:SyntheticEvent)

Custom event callback function, can be used with event. If the event is undefined, the default click event is triggered after the callback.

  • data: Custom data attribute in Object Unit
  • objectUnit: Object unit data in the cell
  • event: React SyntheticBaseEvent

v1.5.1 - v1.6.1

callback(instance:object, objectUnit:object, event:SyntheticEvent)

Custom event callback function, can be used with event. If the event is undefined, the default click event is triggered after the callback.

  • instance: Some properties and methods exposed by the component instance object
  • objectUnit: Object unit data in the cell
  • event: React SyntheticBaseEvent

v1.7.0 and later

callback(exposes:object, objectUnit:object, event:SyntheticEvent)

Custom event callback function, can be used with event. If the event is undefined, the default click event is triggered after the callback.

  • exposes: Some properties and methods exposed
  • objectUnit: Object unit data in the cell
  • event: React SyntheticBaseEvent

Option

{type='select'}Object unit unique attribute.

key {type}description
idoption id
labeloption text
valueoption value

props.property

props.property {type}defaultdescription
border 
{cssProperties border}
{...}The border configuration of the table, including the row and cell inside the component (if the row or cell does not have a border style, this global configuration is used by default)
style 
{cssProperties}
{...}The style of the outermost container of the component
isScroll 
{boolean}
trueWhether to enable component scrolling (valid when the height of all rows exceeds the height of the component's viewable area) ⚠ This property is deprecated in version 1.4.0, please use scroll.enable instead
speed 
{number}
50The scrolling speed of the component list when scrolling is enabled ⚠ This property is deprecated in version 1.4.0, please use scroll.speed instead
scroll ^1.4.0 
{object}
{...}Component scrolling related settings. speed milliseconds scrolling distance distance.
scroll.enable ^1.4.0 
{boolean}
trueWhether to enable component scrolling (valid when the height of all rows exceeds the height of the component's viewable area)
scroll.speed ^1.4.0 
{number}
50The interval at which the component scrolls once, in milliseconds. Tip: Set a small time interval to achieve continuous scrolling animation.If combined with scroll.distance, you can achieve an interval scrolling effect, and you can scroll N rows at a time.
scroll.distance ^1.4.0 
{number}
1The distance at which the component scrolls each time. If the value is a positive integer, the unit is pixel; if 0, it means stop scrolling, the same as scroll.enable: false; if it is a negative integer, it scrolls in the unit of row, and the number of rows equals the absolute value of the value. If it is a non-numeric, take 0; if it is a positive decimal, take an integral upward. If it is a negative decimal, it is rounded down
header 
{object}
{...}Header related settings
header.show 
{boolean}
trueWhether to display the header. When true, the first subarray of data is the header data
header.style 
{cssProperties}
{...}Header style
header.cellStyle 
{cssProperties}
{...}The style of the cell inside the header. Note: The width value in this style will be invalid, because the header cell width of this component is automatically adapted according to the cell width in the body
body 
{object}
{...}Body related configuration
body.style 1.5.0 
{cssProperties}
{...}You can define partial styles for the body that usually do not affect the layout of the list. For example, you can use "backgroundColor", "backgroundImage" or "opacity", etc., but you can't use attributes such as "width", "height", "padding", and "margin" that change the size or position of the body
body.row 
{object}
{...}Row configuration in the body
body.row.onClick 1.2.0 
()=>{}
nullDeprecated Row click event, ⚠ This property is only available in version 1.2.0
body.row.transition 
{boolean}
trueWhether to enable the loading animation of the row inside the body
body.row.spacing 
{boolean}
0Row spacing
body.row.rowCheckBox 
{boolean}
falseDeprecated Whether to enable row selection ⚠ This property is deprecated in version 1.2.2, please use body.row.rowCheckbox instead
body.row.rowCheckbox^1.2.2 
{boolean}
falseDeprecated Whether to enable row selection ⚠ The value of this property was changed from Boolean to an object in version 1.5.0, as detailed in the next line
body.row.rowCheckbox ^1.5.0 
{object}
{...}Body row selection function related settings
body.row.rowCheckbox.show ^1.5.0 
{boolean}
falseWhether to enable row selection
body.row.rowCheckbox.column ^1.5.0 
{number}
1Which column of the list (table) is inserted into the column. Note that this value has a priority less than row.serialNumber.column, ie if the two values are the same, then this column will be ranked later
body.row.rowCheckbox.style ^1.5.0 
{cssProperties}
{...}The style of the label of the wrapped row selection box, not the style of the cell in which the row selection box is located
body.row.rowCheckbox.specialStyle ^1.5.0 
{cssProperties}
[]According to the array index, set the style of the label of the parcel row selection box. If you want to skip an index, you can use a comma placeholder
body.row.style 
{cssProperties}
{...}The style of the row inside the body
body.row.specialStyle 
{[cssProperties, cssProperties, ...]}
[]Set the style of each row according to the array index. If you want to skip an index, you can use a comma placeholder
body.row.visual 
{object}
{...}Improve the visual of the line: set another line style every N lines
body.row.visual.show 
{boolean}
trueWhether to turn on visual enhancement
body.row.visual.interval 
{number}
1Alternate every N lines
body.row.visual.style 
{cssProperties}
{...}Alternate row style configuration
body.row.silent 
{object}
{...}Whether to respond to mouse interaction
body.row.silent.show 
{boolean}
falseWhether row does not respond to mouse events, such as hover events. The default is false, that is, respond to mouse events
body.row.silent.style 
{cssProperties}
{...}Style when responding to mouse events
body.row.serialNumber 
{object}
{...}Line number related configuration
body.row.serialNumber.show 
{boolean}
falseWhether to display the line number
body.row.serialNumber.columnName ^1.5.0 
{string}
'SN'The column name of the column
body.row.serialNumber.formatter 
{string}
'{index}.'Line number formatting. {index} resolves to a number that increments from 0
body.row.serialNumber.column ^1.5.0 
{number}
1Which column of the list (table) is inserted into the column. Note that this value has a priority greater than row.rowCheckbox.column, ie if the two values are the same, then this column will be in front
body.row.serialNumber.style 
`{cssProperties}
{...}The style of the label that wraps the line number, not the style of the cell in which the line number is located
body.row.serialNumber.specialStyle 
{[cssProperties, ...]}
[]According to the array index, set the style of the label of the package line number. If you want to skip an index, you can use a comma placeholder
body.cellOfColumn 
{object}
{...}Configure cell styles by column
body.cellOfColumn.style 
{[cssProperties, ...]}
[]According to the array index, set the style of all the cells in each column. If you want to skip an index, you can use a comma placeholder
body.cell 
{object}
{...}Cell related configuration
body.cell.style 
{cssProperties}
{...}Cell style
body.cell.style.width 
{string|Array|number}
'auto'width is one of the properties of style, here you need to pay special attention: its usage is different from the width of css, see cellWidth
body.cell.iconStyle 
{cssProperties}
{...}Deprecated The icon style inside the cell needs to match the img of the object cell. In fact, you only need to use className instead of it in the object cell. ⚠ it looks a lot more, so it will be completely removed in a later version

cellWidth

Optional value for cellWidth:

  • 'auto':Automatically set the cell width based on the specific data in the cell.
  • 'avg':Each cell width approaches equal, but the width is appropriately adjusted based on the specific data in the cell.
  • [10, 20, 10]:Each cell in the row takes the value of the array in turn. If the value of an array index is a placeholder (ie ","), the width of the cell will be set to "auto"; when the length of the array is less than the number of columns, the remaining columns are set to "auto" by default.
  • '10,20,10':Each column takes values in turn, based on comma-separated values. The detailed rules are the same as the array form.

Note:

  1. Regardless of the method, if the final rendered cell width value is less than style.minWidth, the style.minWidth value is used.
  2. The total width of the component cannot be less than the sum of the widths of each column, otherwise the columns that exceed the width portion will be hidden.
  3. When customizing the width values of multiple columns, if each column defines a specific value, you should ensure that the sum of these values is equal to the width value of the component, otherwise the actual width of the column after rendering may not be the expected value. Under normal circumstances, we should ensure that the width of at least one column is automatically adapted, that is, no value is set or skipped with a comma.
  4. The priority order of the cell styles.

Event

v1.7.0 and later versions support React native events, and remove the event binding written inside the code in the previous version.

Added 3 custom scroll events:

  • custom_onScrollTo:Triggered after the end of discontinuous scrolling (when scroll.distance < 0) or after calling the public scroll to function.
  • custom_onScrollToEnd:Scroll to the end of the component to trigger. Triggered when the last line completely appears in the visible area of the component.
  • custom_onScrollFullCircle:Triggered after a complete roll.

For all events, including react native events and custom scroll events, there are two callback parameters:

  • event {SyntheticEvent}: Event callback parameter of event handle.
  • exposes {object}: An object that contains exposed properties and methods.

⛱️ Configuration Demonstration

The default value of the component is based on this configuration table.

{
  className: '',
  data: [
    ['1st column', '2nd column', '3rd column'],
    ['1st cell', '2nd cell', '3rd cell']
  ],
  property: {
    border: {
      borderWidth: 1,
      borderStyle: 'solid',
      borderColor: '#f4f4f4'
    },
    style: {
      width: '100%',
      margin: '0 auto',
      height: 300
    },
    scroll: {
      enable: true,
      speed: 50,
      distance: 1
    },
    header: {
      show: true,
      style: {
        height: 40
      },
      cellStyle: {
        color: '#000000',
        border: ''
      }
    },
    body: {
      style: {
        backgroundImage: '',
        backgroundColor: ''
      },
      row: {
        transition: true,
        spacing: 0,
        style: {
          height: 30
        },
        serialNumber: {
          show: false,
          columnName: 'SN',
          formatter: '{index}.',
          column: 1,
          style: {
            width: '100%',
            height: '100%',
            display: 'flex',
            justifyContent: 'center',
            alignItems: 'center',
            backgroundColor: '',
            backgroundImage: '',
            color: '#ffffff'
          },
          specialStyle: []
        },
        rowCheckbox: {
          show: false,
          column: 1,
          style: {},
          specialStyle: []
        },
        visual: {
          show: false,
          interval: 1,
          style: {
            backgroundColor: '#e8f4fc'
          }
        },
        specialStyle: [],
        silent: {
          show: false, // false代表开启
          style: {
              opacity: 0.8
          }
        }
      },
      cellOfColumn: {
        style: []
      },
      cell: {
        style: {
          fontSize: 16,
          minWidth: 50,
          color: '#000000',
          textAlign: 'center',
          border: '',
          width: 'auto'
        },
        iconStyle: {
          width: 24,
          height: 'auto'
        }
      }
    }
  }
}

💖 Thanks

The react-tabllist project can continue to serve everyone free of charge. One of the reasons is the free development tools provided by jetbrains. Thank them here!

🙋 Q&A


Q: Thanks to AimLuo for the question: Is it better to write object units in data or JSX syntax?

A: answer


Author: oceanxy
Source code: https://github.com/oceanxy/react-tabllist
License: MIT license

#react #javascript 

What is GEEK

Buddha Community

React-based Customizable Style Table Or List Components That Support
Autumn  Blick

Autumn Blick

1598839687

How native is React Native? | React Native vs Native App Development

If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?

In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.

A brief introduction to React Native

Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.

React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.

Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.

Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.

The popularity of React Native comes from its advantages. Some of its advantages are as follows:

  • Performance: It delivers optimal performance.
  • Cross-platform development: You can develop both Android and iOS apps with it. The reuse of code expedites development and reduces costs.
  • UI design: React Native enables you to design simple and responsive UI for your mobile app.
  • 3rd party plugins: This framework supports 3rd party plugins.
  • Developer community: A vibrant community of developers support React Native.

Why React Native is fundamentally different from earlier hybrid frameworks

Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.

React Native is very close to native. Consider the following aspects as described on the React Native website:

  • Access to many native platforms features: The primitives of React Native render to native platform UI. This means that your React Native app will use many native platform APIs as native apps would do.
  • Near-native user experience: React Native provides several native components, and these are platform agnostic.
  • The ease of accessing native APIs: React Native uses a declarative UI paradigm. This enables React Native to interact easily with native platform APIs since React Native wraps existing native code.

Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.

#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native

Aubrey  Price

Aubrey Price

1591207740

Implementing a dark theme toggle with react-redux and styled-components

To keep things simple and concise, we’ll start fresh with npx create-react-app dark-toggle . While we’re in our command line, let’s get the npm packages out of the way as well:
npm install styled-components styled-theming redux react-redux
styled-components: we’ll use this library to create isolated components that encapsulate their own styling
styled-theming: this library offers a very clean API to work with multiple themes in your styled components
redux and react-redux will do the heavy lifting regarding state management

#styled-components #react #react-hook #dark-theme #redux #react-native

Daron  Moore

Daron Moore

1658034000

React-based Customizable Style Table Or List Components That Support

React-tabllist

React-based list (table) components that support events, callback functions, and custom styles.


  🔧 Install

npm install react-tabllist --save

📚 Usage

Use in browser

  <script src="https://cdn.bootcss.com/react/16.8.6/umd/react.development.js"></script>
  <script src="https://cdn.bootcss.com/react-dom/16.8.6/umd/react-dom.development.js"></script>
  <script src="https://cdn.bootcss.com/babel-standalone/7.0.0-beta.3/babel.min.js"></script>
  <script src='https://cdn.bootcss.com/lodash.js/4.17.11/lodash.core.js'></script>
  <script src='./react-tabllist.min.js'></script>

  <div id='example'></div>
  <script type='text/javascript'>
    var option = {
      data: [],
      property: {}
    }

    ReactDOM.render(
      React.createElement(ReactTabllist, option),
      document.getElementById('example')
    )
  </script>

Use in ES6 & jsx

  import ReactTabllist from 'react-tabllist';

  // Use default configuration
  ReactDOM.render(<ReactTabllist />, mountNode);

  // Custom data and configuration items
  const props = {
    className: 'demo',
    property: {},
    data: [
      ['1st column', '2nd column', '3rd column'],
      ['1st cell', '2nd cell', '3rd cell']
    ]
  }

  ReactDOM.render(<ReactTabllist {...props} />, mountNode);

  /**
   * Event callback function
   * @param {SyntheticEvent} event
   * @param {Exposes} exposes An object containing exposed properties and methods
   */
  function handleScroll(event, exposes) {
    // some code
  }

  // Use React native events
  ReactDOM.render(<ReactTabllist {...props} onScroll={handleScroll} />, mountNode);

  // Use custom events built into components
  ReactDOM.render(<ReactTabllist {...props} custom_onScrollToEnd={handleScroll} />, mountNode);

💻 Development

If you want to join the development to improve this component, please fork and start with the following command:

  $ git clone git@github.com:oceanxy/react-tabllist.git
  $ cd react-tabllist
  $ npm install
  $ npm start

Open your browser and visit http://localhost:3001.

📝 Version Information

Change Log

🧰 Configuration

propsdescriptiondetails
data 
{[Array, Array, Array,...]}
Render table dataprops.data
className 
{string}
Table outermost container style sheet name''
property 
{Object}
Wrapper table propertiesprops.property

props.className

You can customize the style through the props.classname attribute.

props.data

Data Format

The data data format is very similar to a two-dimensional array。

  • Each subarray in the array represents a row, and each element in the subarray represents a cell. The order in which cells are displayed is the order in which the arrays are indexed, so the order and display of each cell should be determined when reconstructing the data.
  [
    [cell, cell, cell], // row
    [
      cell, // cell
      cell,
      cell
    ],
    [cell, cell, cell],
    ...
  ]
  • An object can also represent a row in a two-dimensional array. This object has two required attributes: type='row' and cells=[], which respectively identify the object as a row and the cells contained in the row:
[
  {  // The rows are displayed as objects, and the in-row cells are contained in the cells field as an array.
    type: 'row',
    cells: [cell, cell, cell],
    ...
  },
  [  // Display rows as an array, each element representing a cell
    {type: 'button', ...},   // Generate a button in the cell
    cell,  // cell
    cell
  ],
  [
    cell,
    cell,
    [
        {type: 'radio'}, {type: 'radio'}, ... // Generate two or more radios in the same cell
    ]
  ],
  ...
]

Object Unit

The data format that cells can parse is divided into the following four categories:

  • String
  • Array,These four data formats can be nested inside the array again.
  • jsx,Such as: <button className='test-button' onclick='()=>{return null}'>click</button>
  • Object(Object cell),Details are as follows:
typedescription
rowGenerate a unit row, unit row object can only be written in the body, invalid elsewhere
imgGenerate an img tag inside the cell
buttonGenerate a button in the cell
linkGenerate a link in the cell (a tag)
radioGenerate a radio in the cell
checkboxGenerate a checkbox in the cell
select ^1.4.1Generate a select in the cell
text ^1.5.0Generate a plain text inside the cell. You can also replace the object unit with a string. If you don't plan to add events to this cell, you can do that.
input ^1.6.0Generate a text box in a cell.

Here are some examples:

row

{
  type: 'row',
  cells: [cell, cell, cell],
  data: 'row.id',
  value: 'row.typeID',
  event: 'onClick',
  callback: (data, cellData, event) => {},
  className: '',
  key: ''
}

button

{
  type: 'button',
  value: 'click me',
  className: 'test-btn',
  data: '123',
  event: 'onClick',
  callback: data => alert('hello react-tabllist', data) // hello react-tabllist, 123,
  key: ''
}

img

{
  type: 'img',
  src: 'http://www.xieyangogo.cn/pic.png',
  alt: '',
  text: 'IMG description',
  className: 'test-img',
  key: '',
  value:''
}

link (Choose one of the two)

{
  type: 'link',
  text: 'I am a link, I use the href attribute',
  className: 'test-link',
  key: '',
  href: 'https://github.com/oceanxy/react-tabllist',
  value:''
}
{
  type: 'link',
  text: 'I am a link, I use event and callback to implement custom functions',
  className: 'test-link',
  key: '',
  data:  {},
  event: 'onClick',
  callback: (data, cellData, event) => {},
  value:''
}

radio

{
  type: 'radio',
  name: 'group2',
  text: 'radio group 2-1',
  className: 'test-radio',
  callback: (data, cellData, event) => {},
  key: '',
  value:''
}

checkbox

{
  type: 'checkbox',
  name: 'checkbox1',
  text: 'checkbox',
  className: 'test-checkbox',
  callback: (data, cellData, event) => {},
  key: '',
  value:''
}

select

{
  type: 'select',
  text: 'please choose:',
  value: '',
  data: '',
  className: '',
  callback: (data, cellData, event) => {},
  option: [
    {
      id: '1',
      label: 'item 1',
      value: 1
    }
  ]
}

text

{
  type: 'text',
  text: 'I am a normal text',
  callback: (data, cellData, event) => {}
}

input

{
  type: 'input',
  text: 'username:',
  placeholder: 'enter username',
  defaultValue: 'oceanxy' // This attribute is not a standard HTML tag attribute, but it is a property of the React element (the purpose is to set the default value of the text box). As you can see, you can also use React's officially defined properties in object cells.
}

Object Unit Attribute

Attribute {type}Descriptionrowbuttonlinkimgradiocheckboxinputselecttext
uid 
{string} Available before version 1.2.2
Deprecated A unique identifier for a cell that can be used to save ids, and so on. This field function is similar to the key, and can also be replaced with a data field in conjunction with a callback function, so it is decided to discard this field in version 1.2.2.
type 
{string}
The type of HTML tag to be generated in the cell
text 
{string}
The text of the rendered HTML tag
event 
{string}
The way to trigger an event needs to be used with callback
callback 
{function}
The callback function after the trigger event, see the callback for details.
cells 
{object[]}
Can only be used with the row type, see the data for details.
data 
{*}
Custom attributes can theoretically pass any value. This value is not used inside the component, you can get this value in the first parameter of the callback
option 
{object[]}
Can only be used with the select type, see the option for details.

HTML Attribute

The usage of these attributes is the same as that of native HTML tags. They are listed to indicate the points to be aware of when using them.

Attribute {type}Description
name 
{string}
The attributes that the radio and checkbox must set, the same as the name attribute of the HTML-like tag.
value 
{number|string}
The value attribute of the generated HTML tag, **All object cell can be used starting with version 1.4.1**
src 
{string}
Image link, such as: 'http(s)://xxx' or 'data:image/xxx'
alt 
{string}
The alt attribute of the image
href 
{string}
The hyperlink type of the link type (the same as the href of the HTML a tag), or you can use this combination of event and callback to customize the event callback without passing this attribute.

For more tag attributes please visit w3schools.

React Element Attribute

Attribute {type}Description
key 
{string}
Jsx loop or array need to use the key attribute, Please ensure the uniqueness of the key
className 
{string}
Custom style sheet name
defaultValue 
{string|number}
The default value of labels such as text boxes, different from value

For more attributes, see the type definition file (d.ts) of the react library.

Callback

v1.5.0 and earlier

callback(data:Array[], objectUnit:object, event:SyntheticEvent)

Custom event callback function, can be used with event. If the event is undefined, the default click event is triggered after the callback.

  • data: Custom data attribute in Object Unit
  • objectUnit: Object unit data in the cell
  • event: React SyntheticBaseEvent

v1.5.1 - v1.6.1

callback(instance:object, objectUnit:object, event:SyntheticEvent)

Custom event callback function, can be used with event. If the event is undefined, the default click event is triggered after the callback.

  • instance: Some properties and methods exposed by the component instance object
  • objectUnit: Object unit data in the cell
  • event: React SyntheticBaseEvent

v1.7.0 and later

callback(exposes:object, objectUnit:object, event:SyntheticEvent)

Custom event callback function, can be used with event. If the event is undefined, the default click event is triggered after the callback.

  • exposes: Some properties and methods exposed
  • objectUnit: Object unit data in the cell
  • event: React SyntheticBaseEvent

Option

{type='select'}Object unit unique attribute.

key {type}description
idoption id
labeloption text
valueoption value

props.property

props.property {type}defaultdescription
border 
{cssProperties border}
{...}The border configuration of the table, including the row and cell inside the component (if the row or cell does not have a border style, this global configuration is used by default)
style 
{cssProperties}
{...}The style of the outermost container of the component
isScroll 
{boolean}
trueWhether to enable component scrolling (valid when the height of all rows exceeds the height of the component's viewable area) ⚠ This property is deprecated in version 1.4.0, please use scroll.enable instead
speed 
{number}
50The scrolling speed of the component list when scrolling is enabled ⚠ This property is deprecated in version 1.4.0, please use scroll.speed instead
scroll ^1.4.0 
{object}
{...}Component scrolling related settings. speed milliseconds scrolling distance distance.
scroll.enable ^1.4.0 
{boolean}
trueWhether to enable component scrolling (valid when the height of all rows exceeds the height of the component's viewable area)
scroll.speed ^1.4.0 
{number}
50The interval at which the component scrolls once, in milliseconds. Tip: Set a small time interval to achieve continuous scrolling animation.If combined with scroll.distance, you can achieve an interval scrolling effect, and you can scroll N rows at a time.
scroll.distance ^1.4.0 
{number}
1The distance at which the component scrolls each time. If the value is a positive integer, the unit is pixel; if 0, it means stop scrolling, the same as scroll.enable: false; if it is a negative integer, it scrolls in the unit of row, and the number of rows equals the absolute value of the value. If it is a non-numeric, take 0; if it is a positive decimal, take an integral upward. If it is a negative decimal, it is rounded down
header 
{object}
{...}Header related settings
header.show 
{boolean}
trueWhether to display the header. When true, the first subarray of data is the header data
header.style 
{cssProperties}
{...}Header style
header.cellStyle 
{cssProperties}
{...}The style of the cell inside the header. Note: The width value in this style will be invalid, because the header cell width of this component is automatically adapted according to the cell width in the body
body 
{object}
{...}Body related configuration
body.style 1.5.0 
{cssProperties}
{...}You can define partial styles for the body that usually do not affect the layout of the list. For example, you can use "backgroundColor", "backgroundImage" or "opacity", etc., but you can't use attributes such as "width", "height", "padding", and "margin" that change the size or position of the body
body.row 
{object}
{...}Row configuration in the body
body.row.onClick 1.2.0 
()=>{}
nullDeprecated Row click event, ⚠ This property is only available in version 1.2.0
body.row.transition 
{boolean}
trueWhether to enable the loading animation of the row inside the body
body.row.spacing 
{boolean}
0Row spacing
body.row.rowCheckBox 
{boolean}
falseDeprecated Whether to enable row selection ⚠ This property is deprecated in version 1.2.2, please use body.row.rowCheckbox instead
body.row.rowCheckbox^1.2.2 
{boolean}
falseDeprecated Whether to enable row selection ⚠ The value of this property was changed from Boolean to an object in version 1.5.0, as detailed in the next line
body.row.rowCheckbox ^1.5.0 
{object}
{...}Body row selection function related settings
body.row.rowCheckbox.show ^1.5.0 
{boolean}
falseWhether to enable row selection
body.row.rowCheckbox.column ^1.5.0 
{number}
1Which column of the list (table) is inserted into the column. Note that this value has a priority less than row.serialNumber.column, ie if the two values are the same, then this column will be ranked later
body.row.rowCheckbox.style ^1.5.0 
{cssProperties}
{...}The style of the label of the wrapped row selection box, not the style of the cell in which the row selection box is located
body.row.rowCheckbox.specialStyle ^1.5.0 
{cssProperties}
[]According to the array index, set the style of the label of the parcel row selection box. If you want to skip an index, you can use a comma placeholder
body.row.style 
{cssProperties}
{...}The style of the row inside the body
body.row.specialStyle 
{[cssProperties, cssProperties, ...]}
[]Set the style of each row according to the array index. If you want to skip an index, you can use a comma placeholder
body.row.visual 
{object}
{...}Improve the visual of the line: set another line style every N lines
body.row.visual.show 
{boolean}
trueWhether to turn on visual enhancement
body.row.visual.interval 
{number}
1Alternate every N lines
body.row.visual.style 
{cssProperties}
{...}Alternate row style configuration
body.row.silent 
{object}
{...}Whether to respond to mouse interaction
body.row.silent.show 
{boolean}
falseWhether row does not respond to mouse events, such as hover events. The default is false, that is, respond to mouse events
body.row.silent.style 
{cssProperties}
{...}Style when responding to mouse events
body.row.serialNumber 
{object}
{...}Line number related configuration
body.row.serialNumber.show 
{boolean}
falseWhether to display the line number
body.row.serialNumber.columnName ^1.5.0 
{string}
'SN'The column name of the column
body.row.serialNumber.formatter 
{string}
'{index}.'Line number formatting. {index} resolves to a number that increments from 0
body.row.serialNumber.column ^1.5.0 
{number}
1Which column of the list (table) is inserted into the column. Note that this value has a priority greater than row.rowCheckbox.column, ie if the two values are the same, then this column will be in front
body.row.serialNumber.style 
`{cssProperties}
{...}The style of the label that wraps the line number, not the style of the cell in which the line number is located
body.row.serialNumber.specialStyle 
{[cssProperties, ...]}
[]According to the array index, set the style of the label of the package line number. If you want to skip an index, you can use a comma placeholder
body.cellOfColumn 
{object}
{...}Configure cell styles by column
body.cellOfColumn.style 
{[cssProperties, ...]}
[]According to the array index, set the style of all the cells in each column. If you want to skip an index, you can use a comma placeholder
body.cell 
{object}
{...}Cell related configuration
body.cell.style 
{cssProperties}
{...}Cell style
body.cell.style.width 
{string|Array|number}
'auto'width is one of the properties of style, here you need to pay special attention: its usage is different from the width of css, see cellWidth
body.cell.iconStyle 
{cssProperties}
{...}Deprecated The icon style inside the cell needs to match the img of the object cell. In fact, you only need to use className instead of it in the object cell. ⚠ it looks a lot more, so it will be completely removed in a later version

cellWidth

Optional value for cellWidth:

  • 'auto':Automatically set the cell width based on the specific data in the cell.
  • 'avg':Each cell width approaches equal, but the width is appropriately adjusted based on the specific data in the cell.
  • [10, 20, 10]:Each cell in the row takes the value of the array in turn. If the value of an array index is a placeholder (ie ","), the width of the cell will be set to "auto"; when the length of the array is less than the number of columns, the remaining columns are set to "auto" by default.
  • '10,20,10':Each column takes values in turn, based on comma-separated values. The detailed rules are the same as the array form.

Note:

  1. Regardless of the method, if the final rendered cell width value is less than style.minWidth, the style.minWidth value is used.
  2. The total width of the component cannot be less than the sum of the widths of each column, otherwise the columns that exceed the width portion will be hidden.
  3. When customizing the width values of multiple columns, if each column defines a specific value, you should ensure that the sum of these values is equal to the width value of the component, otherwise the actual width of the column after rendering may not be the expected value. Under normal circumstances, we should ensure that the width of at least one column is automatically adapted, that is, no value is set or skipped with a comma.
  4. The priority order of the cell styles.

Event

v1.7.0 and later versions support React native events, and remove the event binding written inside the code in the previous version.

Added 3 custom scroll events:

  • custom_onScrollTo:Triggered after the end of discontinuous scrolling (when scroll.distance < 0) or after calling the public scroll to function.
  • custom_onScrollToEnd:Scroll to the end of the component to trigger. Triggered when the last line completely appears in the visible area of the component.
  • custom_onScrollFullCircle:Triggered after a complete roll.

For all events, including react native events and custom scroll events, there are two callback parameters:

  • event {SyntheticEvent}: Event callback parameter of event handle.
  • exposes {object}: An object that contains exposed properties and methods.

⛱️ Configuration Demonstration

The default value of the component is based on this configuration table.

{
  className: '',
  data: [
    ['1st column', '2nd column', '3rd column'],
    ['1st cell', '2nd cell', '3rd cell']
  ],
  property: {
    border: {
      borderWidth: 1,
      borderStyle: 'solid',
      borderColor: '#f4f4f4'
    },
    style: {
      width: '100%',
      margin: '0 auto',
      height: 300
    },
    scroll: {
      enable: true,
      speed: 50,
      distance: 1
    },
    header: {
      show: true,
      style: {
        height: 40
      },
      cellStyle: {
        color: '#000000',
        border: ''
      }
    },
    body: {
      style: {
        backgroundImage: '',
        backgroundColor: ''
      },
      row: {
        transition: true,
        spacing: 0,
        style: {
          height: 30
        },
        serialNumber: {
          show: false,
          columnName: 'SN',
          formatter: '{index}.',
          column: 1,
          style: {
            width: '100%',
            height: '100%',
            display: 'flex',
            justifyContent: 'center',
            alignItems: 'center',
            backgroundColor: '',
            backgroundImage: '',
            color: '#ffffff'
          },
          specialStyle: []
        },
        rowCheckbox: {
          show: false,
          column: 1,
          style: {},
          specialStyle: []
        },
        visual: {
          show: false,
          interval: 1,
          style: {
            backgroundColor: '#e8f4fc'
          }
        },
        specialStyle: [],
        silent: {
          show: false, // false代表开启
          style: {
              opacity: 0.8
          }
        }
      },
      cellOfColumn: {
        style: []
      },
      cell: {
        style: {
          fontSize: 16,
          minWidth: 50,
          color: '#000000',
          textAlign: 'center',
          border: '',
          width: 'auto'
        },
        iconStyle: {
          width: 24,
          height: 'auto'
        }
      }
    }
  }
}

💖 Thanks

The react-tabllist project can continue to serve everyone free of charge. One of the reasons is the free development tools provided by jetbrains. Thank them here!

🙋 Q&A


Q: Thanks to AimLuo for the question: Is it better to write object units in data or JSX syntax?

A: answer


Author: oceanxy
Source code: https://github.com/oceanxy/react-tabllist
License: MIT license

#react #javascript 

Mathew Rini

1615544450

How to Select and Hire the Best React JS and React Native Developers?

Since March 2020 reached 556 million monthly downloads have increased, It shows that React JS has been steadily growing. React.js also provides a desirable amount of pliancy and efficiency for developing innovative solutions with interactive user interfaces. It’s no surprise that an increasing number of businesses are adopting this technology. How do you select and recruit React.js developers who will propel your project forward? How much does a React developer make? We’ll bring you here all the details you need.

What is React.js?

Facebook built and maintains React.js, an open-source JavaScript library for designing development tools. React.js is used to create single-page applications (SPAs) that can be used in conjunction with React Native to develop native cross-platform apps.

React vs React Native

  • React Native is a platform that uses a collection of mobile-specific components provided by the React kit, while React.js is a JavaScript-based library.
  • React.js and React Native have similar syntax and workflows, but their implementation is quite different.
  • React Native is designed to create native mobile apps that are distinct from those created in Objective-C or Java. React, on the other hand, can be used to develop web apps, hybrid and mobile & desktop applications.
  • React Native, in essence, takes the same conceptual UI cornerstones as standard iOS and Android apps and assembles them using React.js syntax to create a rich mobile experience.

What is the Average React Developer Salary?

In the United States, the average React developer salary is $94,205 a year, or $30-$48 per hour, This is one of the highest among JavaScript developers. The starting salary for junior React.js developers is $60,510 per year, rising to $112,480 for senior roles.

* React.js Developer Salary by Country

  • United States- $120,000
  • Canada - $110,000
  • United Kingdom - $71,820
  • The Netherlands $49,095
  • Spain - $35,423.00
  • France - $44,284
  • Ukraine - $28,990
  • India - $9,843
  • Sweden - $55,173
  • Singapore - $43,801

In context of software developer wage rates, the United States continues to lead. In high-tech cities like San Francisco and New York, average React developer salaries will hit $98K and $114per year, overall.

However, the need for React.js and React Native developer is outpacing local labour markets. As a result, many businesses have difficulty locating and recruiting them locally.

It’s no surprise that for US and European companies looking for professional and budget engineers, offshore regions like India are becoming especially interesting. This area has a large number of app development companies, a good rate with quality, and a good pool of React.js front-end developers.

As per Linkedin, the country’s IT industry employs over a million React specialists. Furthermore, for the same or less money than hiring a React.js programmer locally, you may recruit someone with much expertise and a broader technical stack.

How to Hire React.js Developers?

  • Conduct thorough candidate research, including portfolios and areas of expertise.
  • Before you sit down with your interviewing panel, do some homework.
  • Examine the final outcome and hire the ideal candidate.

Why is React.js Popular?

React is a very strong framework. React.js makes use of a powerful synchronization method known as Virtual DOM, which compares the current page architecture to the expected page architecture and updates the appropriate components as long as the user input.

React is scalable. it utilises a single language, For server-client side, and mobile platform.

React is steady.React.js is completely adaptable, which means it seldom, if ever, updates the user interface. This enables legacy projects to be updated to the most new edition of React.js without having to change the codebase or make a few small changes.

React is adaptable. It can be conveniently paired with various state administrators (e.g., Redux, Flux, Alt or Reflux) and can be used to implement a number of architectural patterns.

Is there a market for React.js programmers?
The need for React.js developers is rising at an unparalleled rate. React.js is currently used by over one million websites around the world. React is used by Fortune 400+ businesses and popular companies such as Facebook, Twitter, Glassdoor and Cloudflare.

Final thoughts:

As you’ve seen, locating and Hire React js Developer and Hire React Native developer is a difficult challenge. You will have less challenges selecting the correct fit for your projects if you identify growing offshore locations (e.g. India) and take into consideration the details above.

If you want to make this process easier, You can visit our website for more, or else to write a email, we’ll help you to finding top rated React.js and React Native developers easier and with strives to create this operation

#hire-react-js-developer #hire-react-native-developer #react #react-native #react-js #hire-react-js-programmer

Franz  Becker

Franz Becker

1651604400

React Starter Kit: Build Web Apps with React, Relay and GraphQL.

React Starter Kit — "isomorphic" web app boilerplate   

React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Express, GraphQL and React, containing modern web development tools such as Webpack, Babel and Browsersync. Helping you to stay productive following the best practices. A solid starting point for both professionals and newcomers to the industry.

See getting started guide, demo, docs, roadmap  |  Join #react-starter-kit chat room on Gitter  |  Visit our sponsors:

 

Hiring

Getting Started

Customization

The master branch of React Starter Kit doesn't include a Flux implementation or any other advanced integrations. Nevertheless, we have some integrations available to you in feature branches that you can use either as a reference or merge into your project:

You can see status of most reasonable merge combination as PRs labeled as TRACKING

If you think that any of these features should be on master, or vice versa, some features should removed from the master branch, please let us know. We love your feedback!

Comparison

 

React Starter Kit

React Static Boilerplate

ASP.NET Core Starter Kit

App typeIsomorphic (universal)Single-page applicationSingle-page application
Frontend
LanguageJavaScript (ES2015+, JSX)JavaScript (ES2015+, JSX)JavaScript (ES2015+, JSX)
LibrariesReact, History, Universal RouterReact, History, ReduxReact, History, Redux
RoutesImperative (functional)DeclarativeDeclarative, cross-stack
Backend
LanguageJavaScript (ES2015+, JSX)n/aC#, F#
LibrariesNode.js, Express, Sequelize,
GraphQL
n/aASP.NET Core, EF Core,
ASP.NET Identity
SSRYesn/an/a
Data APIGraphQLn/aWeb API

Backers

♥ React Starter Kit? Help us keep it alive by donating funds to cover project expenses via OpenCollective or Bountysource!

lehneres Tarkan Anlar Morten Olsen Adam David Ernst Zane Hitchcox  

How to Contribute

Anyone and everyone is welcome to contribute to this project. The best way to start is by checking our open issues, submit a new issue or feature request, participate in discussions, upvote or downvote the issues you like or dislike, send pull requests.

Learn More

Related Projects

  • GraphQL Starter Kit — Boilerplate for building data APIs with Node.js, JavaScript (via Babel) and GraphQL
  • Membership Database — SQL schema boilerplate for user accounts, profiles, roles, and auth claims
  • Babel Starter Kit — Boilerplate for authoring JavaScript/React.js libraries

Support

License

Copyright © 2014-present Kriasoft, LLC. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.


Author: kriasoft
Source Code: https://github.com/kriasoft/react-starter-kit
License: MIT License

#graphql #react