How to use @uform/react - 10 common examples

To help you get started, we’ve selected a few @uform/react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alibaba / uform / packages / antd / src / fields / upload.js View on Github external
: val
  if (isArr(result)) {
    result = result.map(item => ({
      ...item,
      // 必须要有一个不重复的uid
      uid:
        item.uid ||
        Math.random()
          .toFixed(16)
          .slice(2, 10)
    }))
  }
  return result
}

registerFormField(
  'upload',
  connect({
    getProps: mapStyledProps
  })(
    class Uploader extends React.Component {
      static defaultProps = {
        action: 'https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload',
        listType: 'text',
        multiple: true,
        className: 'antd-uploader'
      }

      constructor(props) {
        super(props)
        this.state = {
          value: shallowClone(toArr(props.value))
github alibaba / uform / packages / antd / src / components / layout.tsx View on Github external
{children.reduce((buf, child, key) => {
            return child
              ? buf.concat(
                  
                    {child}
                  
                )
              : buf
          }, [])}
        
      )
    }
  }
)

export const FormCard = createVirtualBox(
  'card',
  styled(
    class extends Component {
      public static defaultProps = {
        // bodyHeight: 'auto'
      }
      public render() {
        const { children, className, ...props } = this.props
        return (
          
            {children}
          
        )
      }
    }
  )`
github alibaba / uform / packages / antd / src / components / layout.tsx View on Github external
}
    }
  )`
    margin-bottom: 30px;
    .ant-card-body {
      padding-top: 30px;
      padding-bottom: 0 !important;
    }
    &.ant-card {
      display: block;
      margin-bottom: 30px;
    }
  `
)

export const FormBlock = createVirtualBox(
  'block',
  styled(
    class extends Component {
      public static defaultProps = {
        // bodyHeight: 'auto'
      }

      public render() {
        const { children, className, ...props } = this.props
        return (
          
            {children}
          
        )
      }
    }
github alibaba / uform / packages / next / src / components / layout.tsx View on Github external
}
  )`
    margin-bottom: 0px;
    .next-card-body {
      padding-top: 20px;
      padding-bottom: 0 !important;
    }
    &.next-card {
      border: none;
      padding: 0 15px;
      padding-bottom: 15px;
    }
  `
)

export const FormTextBox = createControllerBox(
  'text-box',
  styled(({ children, schema, className }) => {
    const { title, help, text, name, extra, ...props } = schema['x-props']
    const ref: React.RefObject = useRef()
    const arrChildren = toArr(children)
    const split = String(text).split('%s')
    let index = 0
    useLayoutEffect(() => {
      if (ref.current) {
        const elements = ref.current.querySelectorAll('.text-box-field')
        const syncLayouts = Array.prototype.map.call(
          elements,
          (el: HTMLElement) => {
            return [
              el,
              () => {
github alibaba / uform / packages / antd / src / components / layout.tsx View on Github external
padding-bottom: 15px;
      display: block;
      box-shadow: none;
    }
    .ant-card-head {
      padding: 0 !important;
      min-height: 24px;
      font-weight: normal;
    }
    .ant-card-head-title {
      padding: 0;
    }
  `
)

export const FormTextBox = createControllerBox(
  'text-box',
  styled(({ children, schema, className }) => {
    const { title, help, text, name, extra, ...props } = schema['x-props']
    const ref: React.RefObject = useRef()
    const arrChildren = toArr(children)
    const split = String(text).split('%s')
    useLayoutEffect(() => {
      if (ref.current) {
        const elements = ref.current.querySelectorAll('.text-box-field')
        const syncLayouts = Array.prototype.map.call(
          elements,
          (el: HTMLElement) => {
            return [
              el,
              () => {
                const ctrl = el.querySelector(
github alibaba / uform / packages / antd / src / fields / checkbox.js View on Github external
import { connect, registerFormField } from '@uform/react'
import { Checkbox } from 'antd'
import {
  transformDataSourceKey,
  mapStyledProps,
  mapTextComponent
} from '../utils'

const { Group: CheckboxGroup } = Checkbox

registerFormField(
  'checkbox',
  connect({
    getProps: mapStyledProps,
    getComponent: mapTextComponent
  })(transformDataSourceKey(CheckboxGroup, 'options'))
)
github alibaba / uform / packages / antd / src / fields / date.tsx View on Github external
registerFormField(
  'month',
  connect({
    getValueFromEvent(_, value) {
      return transformMoment(value)
    },
    getProps: compose(
      mapStyledProps,
      mapMomentValue
    ),
    getComponent: mapTextComponent
  })(MonthPicker)
)

registerFormField(
  'week',
  connect({
    getValueFromEvent(_, value) {
      return transformMoment(value, 'gggg-wo')
    },
    getProps: compose(
      mapStyledProps,
      props => {
        if (isStr(props.value) && props.value) {
          const parsed = props.value.match(/\D*(\d+)\D*(\d+)\D*/) || [
            '',
            '',
            ''
          ]
          props.value = moment(parsed[1], 'YYYY').add(parsed[2] - 1, 'weeks')
        }
github alibaba / uform / packages / antd / src / fields / range.js View on Github external
import React from 'react'
import { connect, registerFormField } from '@uform/react'
import { Slider } from 'antd'
import { mapStyledProps } from '../utils'

registerFormField(
  'range',
  connect({
    defaultProps: {
      style: {
        width: 320
      }
    },
    getProps: mapStyledProps
  })(
    class Component extends React.Component {
      render() {
        const { onChange, value, min, max, marks } = this.props
        let newMarks = {}
        if (Array.isArray(marks)) {
          marks.forEach(mark => {
            newMarks[mark] = mark
github alibaba / uform / packages / antd / src / fields / radio.js View on Github external
import { connect, registerFormField } from '@uform/react'
import { Radio } from 'antd'
import {
  transformDataSourceKey,
  mapStyledProps,
  mapTextComponent
} from '../utils'

const { Group: RadioGroup } = Radio

registerFormField(
  'radio',
  connect({
    getProps: mapStyledProps,
    getComponent: mapTextComponent
  })(transformDataSourceKey(RadioGroup, 'options'))
)
github alibaba / uform / packages / antd / src / fields / boolean.js View on Github external
import { connect, registerFormField } from '@uform/react'
import { acceptEnum, mapStyledProps } from '../utils'
import { Switch } from 'antd'

registerFormField(
  'boolean',
  connect({
    valueName: 'checked',
    getProps: mapStyledProps
  })(acceptEnum(Switch))
)

@uform/react

English | [简体中文](./README.zh-cn.md)

MIT
Latest version published 4 years ago

Package Health Score

62 / 100
Full package analysis

Similar packages