onSelected('today')}\n title={todayButton}\n />\n )}\n
onSelected('next')}\n />\n
\n );\n}\n","import React, { useEffect, useMemo, useState } from 'react';\nimport formatter from '@uiw/formatter';\nimport { IProps, HTMLDivProps, noop } from '@uiw/utils';\nimport { TimePickerTime, TimePickerPanelProps } from '@uiw/react-time-picker';\nimport { DatePickerDay, DatePickerDayProps, DatePickerDayDateSource } from './DatePickerDay';\nimport { DatePickerMonth } from './DatePickerMonth';\nimport { DatePickerYear } from './DatePickerYear';\nimport { DatePickerCaption, DatePickerCaptionType } from './DatePickerCaption';\nimport './style/index.less';\n\nexport * from './DatePickerDay';\nexport * from './DatePickerMonth';\nexport * from './DatePickerYear';\nexport * from './DatePickerCaption';\n\nconst MONTH_LABEL = [\n '一月',\n '二月',\n '三月',\n '四月',\n '五月',\n '六月',\n '七月',\n '八月',\n '九月',\n '十月',\n '十一月',\n '十二月',\n];\n\nexport interface DatePickerShowTimeProps extends TimePickerPanelProps {\n format?: string;\n}\nexport interface DatePickerProps extends IProps, Omit
{\n onChange?: (selectedDate?: Date, dateSource?: DatePickerDayDateSource) => void;\n renderDay?: DatePickerDayProps['renderDay'];\n disabledDate?: DatePickerDayProps['disabledDate'];\n showTime?: DatePickerShowTimeProps | boolean;\n monthLabel?: React.ReactNode[];\n weekday?: string[];\n weekTitle?: string[];\n date?: Date;\n panelDate?: Date;\n today?: Date;\n todayButton?: string;\n onPanelChange?: (date?: Date, mode?: 'next' | 'prev') => void;\n}\nexport interface DatePickerState {\n panelDate?: Date;\n date?: Date;\n type?: 'day' | 'time' | DatePickerCaptionType;\n}\n\nexport default function DatePicker(props: DatePickerProps) {\n const {\n prefixCls = 'w-datepicker',\n className,\n weekday,\n weekTitle,\n monthLabel = MONTH_LABEL,\n date,\n today = new Date(),\n todayButton,\n panelDate = new Date(),\n disabledDate,\n renderDay,\n onChange = noop,\n onPanelChange = noop,\n showTime,\n ...other\n } = props;\n const [type, setType] = useState('day');\n const [selectDate, setSelectDate] = useState(date);\n const [selectPanelDate, setSelectPanelDate] = useState(panelDate);\n\n useEffect(() => {\n if (date) {\n setSelectDate(date);\n setSelectPanelDate(date);\n }\n }, [date]);\n\n const format = useMemo(\n () =>\n showTime && (showTime as DatePickerShowTimeProps).format\n ? (showTime as DatePickerShowTimeProps).format\n : 'HH:mm:ss',\n [showTime],\n );\n function handleSelected(curType: DatePickerState['type']) {\n if (curType && /^(year|month|time)$/.test(curType)) {\n if (type === 'time') {\n curType = 'day';\n }\n setType(curType);\n } else {\n let currentDate = new Date(selectDate || selectPanelDate);\n let month = currentDate.getMonth();\n if (curType === 'prev') {\n month -= 1;\n }\n if (curType === 'next') {\n month += 1;\n }\n currentDate.setMonth(month);\n if (curType === 'prev' || curType === 'next') {\n onPanelChange && onPanelChange(new Date(currentDate), curType);\n }\n setSelectPanelDate(curType === 'today' ? today : currentDate);\n setSelectDate(curType === 'today' ? today : currentDate);\n\n setType('day');\n }\n }\n\n function onSelectedTime(type: TimePickerPanelProps['type'], num: number) {\n (selectPanelDate || new Date())[`set${type}` as 'setHours'](num);\n setSelectPanelDate(new Date(selectPanelDate));\n onChange && onChange(new Date(selectPanelDate));\n }\n\n function onSelectedDate(type: 'setMonth' | 'setFullYear', month: number, paging?: boolean) {\n (selectPanelDate || new Date())[type](month);\n setSelectPanelDate(new Date(selectPanelDate));\n setType('day');\n onChange && onChange(new Date(selectPanelDate));\n }\n return (\n \n
\n {type === 'day' && (\n
{\n setSelectPanelDate(selectedDate!);\n onChange(selectedDate, dateSource);\n }}\n renderDay={renderDay}\n date={selectDate}\n today={today || new Date()}\n panelDate={selectPanelDate}\n weekday={weekday}\n weekTitle={weekTitle}\n />\n )}\n {type === 'month' && (\n onSelectedDate('setMonth', num)}\n />\n )}\n {type === 'year' && (\n onSelectedDate('setFullYear', num)}\n />\n )}\n {type === 'time' && (\n \n )}\n {showTime && format && (\n handleSelected('time')}>\n {formatter(format!, selectDate || selectPanelDate)}\n
\n )}\n \n );\n}\n","import React, { useMemo } from 'react';\nimport { CalendarProps } from './';\n\nexport type RenderDayProps = {\n prefixCls?: string;\n day?: number;\n data?: CalendarProps['data'];\n currentDate?: Date;\n};\n\nexport default function RenderDay(props: RenderDayProps) {\n const { prefixCls, day, data, currentDate } = props;\n\n const dayData = useMemo(\n () =>\n (data || []).filter((item) => {\n let arr: number[] = ((item.date && item.date.split('/')) || []).map((num) => Number(num));\n if (arr.length === 1) {\n return day === arr[0];\n }\n if (currentDate && arr.length === 2) {\n return currentDate.getMonth() + 1 === arr[0] && day === arr[1];\n }\n if (currentDate && arr.length === 3) {\n return currentDate.getFullYear() === arr[0] && currentDate.getMonth() + 1 === arr[1] && day === arr[2];\n }\n return false;\n }),\n [currentDate, day, data],\n );\n\n return useMemo(\n () => (\n \n
{day}
\n
\n {dayData &&\n dayData.length > 0 &&\n dayData.map((item, idx) => {\n const { date, label, ...other } = item;\n return (\n
\n {label}\n
\n );\n })}\n
\n
\n ),\n [dayData, day],\n );\n}\n","import React, { useEffect, useMemo, useState } from 'react';\nimport { DatePickerDay, DatePickerDayProps, DatePickerDayDateSource } from '@uiw/react-date-picker';\nimport Icon from '@uiw/react-icon';\nimport formatter from '@uiw/formatter';\nimport { IProps } from '@uiw/utils';\nimport RenderDay from './DayLabel';\nimport './style/index.less';\n\nexport interface CalendarProps extends IProps, DatePickerDayProps {\n /**\n * 设置日历面板上面的日期标题。\n */\n titleFormat?: string;\n /**\n * 点击选择日期回调\n */\n onSelectDay?: (selectDay?: Date, dateSource?: DatePickerDayDateSource) => void;\n /**\n * 日历面板默认展示哪一页\n */\n panelDate?: Date;\n /**\n * 默认高亮当天日期\n */\n today?: Date;\n /**\n * 在日历面板上面添加通知,数组中的对象可以设置 `ElementProps`,如:`style`, `onClick` 等属性。\n */\n data?: ICalendarData[];\n /**\n * 选中的日期\n */\n date?: Date;\n /**\n * `今天` 按钮的文本设置\n */\n todayLabel?: string;\n /**\n * 月份显示文本\n */\n monthLabel?: string[];\n /** 翻页触发事件 */\n onPaging?: (type: 'prev' | 'next' | 'today', month: number, panelDate?: Date) => void;\n}\n\nexport interface ICalendarData {\n label?: React.ReactNode;\n date?: string;\n [key: string]: any;\n}\n\nconst MONTH_LABEL = [\n '一月',\n '二月',\n '三月',\n '四月',\n '五月',\n '六月',\n '七月',\n '八月',\n '九月',\n '十月',\n '十一月',\n '十二月',\n];\n\nexport default function Calendar(props: CalendarProps) {\n const {\n prefixCls = 'w-calendar',\n className,\n style,\n today = new Date(),\n date,\n data,\n monthLabel = MONTH_LABEL,\n titleFormat = 'YYYY/MM',\n todayLabel = '今天',\n panelDate: _,\n onPaging,\n onSelectDay,\n ...otherProps\n } = props;\n const cls = [prefixCls, className].filter(Boolean).join(' ').trim();\n const [panelDate, setPanelDate] = useState(props.panelDate || new Date());\n\n useEffect(() => {\n if (props.panelDate !== panelDate) {\n setPanelDate(panelDate);\n }\n }, [props.panelDate]);\n\n function handlePaging(type: 'prev' | 'next' | 'today') {\n let currentDate = new Date();\n if (type === 'today') {\n currentDate = today || new Date();\n } else {\n const month = panelDate.getMonth();\n if (panelDate && type === 'prev') {\n panelDate.setMonth(month - 1);\n }\n if (panelDate && type === 'next') {\n panelDate.setMonth(month + 1);\n }\n currentDate = panelDate;\n }\n setPanelDate(new Date(currentDate));\n onPaging && onPaging(type, currentDate!.getMonth() + 1, currentDate);\n }\n\n const titleLable = useMemo(\n () => {formatter(titleFormat, panelDate)}
,\n [prefixCls, titleFormat, panelDate],\n );\n\n const btngroup = useMemo(\n () => (\n \n handlePaging('prev')} />\n handlePaging('today')}>\n {todayLabel}\n \n handlePaging('next')} />\n
\n ),\n [prefixCls, todayLabel],\n );\n\n return (\n \n
\n {titleLable}\n {btngroup}\n
\n
{\n setPanelDate(currentDate!);\n onSelectDay && onSelectDay(currentDate, dateSource);\n }}\n renderDay={(day, propsNext) => (\n \n )}\n date={date}\n today={today}\n panelDate={panelDate || new Date()}\n {...otherProps}\n />\n \n );\n}\n","import React, { useMemo } from 'react';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport './style/index.less';\n\nexport interface CardProps extends IProps, Omit {\n active?: boolean;\n bordered?: boolean;\n bodyStyle?: React.CSSProperties;\n bodyClassName?: string;\n title?: React.ReactNode;\n noHover?: boolean;\n extra?: React.ReactNode;\n footer?: React.ReactNode;\n}\n\nexport default React.forwardRef((props, ref) => {\n const {\n prefixCls = 'w-card',\n className,\n title,\n extra,\n footer,\n bordered = true,\n noHover = false,\n active = false,\n bodyStyle,\n bodyClassName,\n children,\n ...resetProps\n } = props;\n const cls = useMemo(\n () =>\n [\n prefixCls,\n className,\n bordered ? `${prefixCls}-bordered` : null,\n noHover ? `${prefixCls}-no-hover` : null,\n active ? 'active' : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim(),\n [prefixCls, className, bordered, noHover],\n );\n\n return (\n \n {(title || extra) && (\n
\n {title &&
{title}
}\n {extra &&
{extra}
}\n
\n )}\n {children && (\n
\n {children}\n
\n )}\n {footer &&
{footer}
}\n
\n );\n});\n","import React, { useState, useMemo } from 'react';\nimport { IProps, HTMLInputProps } from '@uiw/utils';\n\n/**\n * Constructs a type by picking all properties from `HTMLInputProps` and then removing `size`.\n * Omit: https://www.typescriptlang.org/docs/handbook/utility-types.html#omittk\n */\nexport interface RadioAbstractProps extends IProps, Omit {\n size?: 'large' | 'default' | 'small';\n checked?: boolean;\n disabled?: boolean;\n onChange?: (even: React.ChangeEvent) => void;\n}\n\nexport const RadioAbstract = React.forwardRef((props, ref) => {\n const {\n prefixCls = 'w-radio',\n type = 'radio',\n disabled = false,\n value = '',\n className,\n style,\n children,\n size,\n checked: prChecked = false,\n onChange,\n ...other\n } = props;\n\n const [checked, setChecked] = useState(prChecked);\n const [prevChecked, setPrevChecked] = useState();\n if (prChecked !== prevChecked) {\n setPrevChecked(prChecked);\n }\n useMemo(() => {\n if (prChecked !== prevChecked) {\n setChecked(prChecked);\n }\n }, [prevChecked]);\n\n const cls = [prefixCls, className, disabled ? 'disabled' : null, size ? `${prefixCls}-${size}` : null]\n .filter(Boolean)\n .join(' ')\n .trim();\n useMemo(() => {\n if (checked !== props.checked) {\n setChecked(!!props.checked);\n }\n }, [props.checked]);\n\n function handleChange(e: React.ChangeEvent) {\n e.persist();\n setChecked(e.target.checked);\n onChange && onChange(e);\n }\n\n const label = children || value;\n return (\n \n );\n});\n","import React from 'react';\nimport { RadioAbstract, RadioAbstractProps } from './RadioAbstract';\nimport './style/index.less';\n\nexport interface RadioProps extends RadioAbstractProps {}\n\nexport default React.forwardRef((props, ref) => {\n return ;\n});\n","import React from 'react';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport { RadioProps } from './Radio';\nimport './style/group.less';\n\nexport interface RadioGroupProps extends IProps, HTMLDivProps {\n name?: RadioProps['name'];\n value?: RadioProps['value'];\n onChange?: RadioProps['onChange'];\n}\n\nexport default React.forwardRef((props, ref) => {\n const { prefixCls = 'w-radio-group', className, name, value, onChange, children, ...other } = props;\n return (\n \n {React.Children.toArray(children).map((child) => {\n if (!child) return;\n if (!React.isValidElement(child)) return child;\n return React.cloneElement(child, {\n ...(child.props || {}),\n ...{\n checked: child.props.value === value,\n name,\n onChange,\n },\n });\n })}\n
\n );\n});\n","import React, { useMemo, useRef } from 'react';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport './style/group.less';\n\nexport type Value = string | number;\nexport interface CheckboxGroupPorps extends IProps, Omit {\n value?: Value[];\n name?: string;\n onChange?: (e: React.ChangeEvent, values: Value[]) => void;\n}\n\nexport const CheckboxGroup = React.forwardRef((props, ref) => {\n const { prefixCls = 'w-checkbox-group', className, name, value, onChange, ...other } = props;\n const valueRef = useRef([]);\n const cls = [prefixCls, className].filter(Boolean).join(' ').trim();\n const childs = React.Children.toArray(props.children);\n useMemo(() => (valueRef.current = value || []), [value]);\n return (\n \n {React.Children.map(childs, (element: React.ReactNode) => {\n if (!React.isValidElement(element)) return;\n if (\n Array.isArray(value) &&\n element &&\n element.props &&\n element.props.value &&\n value.includes(element.props.value)\n ) {\n if (!valueRef.current.includes(element.props.value)) {\n valueRef.current.push(element.props.value);\n }\n }\n return React.cloneElement(\n element,\n Object.assign({}, element.props, {\n name,\n checked: valueRef.current.includes(element.props.value),\n onChange: (e: React.ChangeEvent) => {\n if (e.target.type && e.target.type !== 'checkbox') return;\n const checked = e.target.checked;\n const include = valueRef.current.includes(element.props.value);\n if (!include && checked) {\n valueRef.current.push(element.props.value);\n } else if (include && !checked) {\n valueRef.current = valueRef.current.filter((val) => val !== element.props.value);\n }\n onChange && onChange(e, valueRef.current);\n },\n }),\n );\n })}\n
\n );\n});\n","import React from 'react';\nimport { RadioAbstract, RadioAbstractProps } from '@uiw/react-radio';\nimport { CheckboxGroup } from './Group';\nimport './style/index.less';\n\nexport interface CheckboxProps extends RadioAbstractProps {\n indeterminate?: boolean;\n}\n\nfunction InternalCheckbox(props: CheckboxProps, ref: React.ForwardedRef) {\n const {\n className,\n prefixCls = 'w-checkbox',\n type = 'checkbox',\n indeterminate = false,\n disabled = false,\n value = '',\n ...other\n } = props;\n\n const cls = [className, indeterminate && 'indeterminate'].filter(Boolean).join(' ').trim();\n return (\n \n );\n}\n\nconst Checkbox = React.forwardRef(InternalCheckbox);\ntype Checkbox = typeof Checkbox & {\n Group: typeof CheckboxGroup;\n};\n\n(Checkbox as Checkbox).Group = CheckboxGroup;\n\nexport default Checkbox as Checkbox;\n","import Checkbox from './Checkbox';\n\nexport * from './Checkbox';\nexport * from './Group';\nexport default Checkbox;\n","import React, { useState, useMemo } from 'react';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport Panel from './Panel';\nimport './style/index.less';\n\nexport interface CollapseProps extends IProps, Omit {\n accordion?: boolean;\n activeKey?: string | string[];\n bordered?: boolean;\n showArrow?: boolean;\n onChange?: (activeKey: string[]) => void;\n}\n\nexport interface CollapseState {\n activeKey: string[];\n}\n\nfunction toArray(activeKey: CollapseProps['activeKey']) {\n let currentActiveKey = activeKey;\n if (!Array.isArray(currentActiveKey)) {\n currentActiveKey = currentActiveKey ? [currentActiveKey] : [];\n }\n return currentActiveKey;\n}\n\nfunction InternalCollapse(props: CollapseProps, ref: React.ForwardedRef) {\n const {\n prefixCls = 'w-collapse',\n className,\n children,\n accordion = false,\n bordered,\n showArrow = true,\n activeKey: propsActiveKey,\n onChange,\n ...resetProps\n } = props;\n const [activeKey, setActiveKey] = useState(toArray(propsActiveKey));\n const cls = [prefixCls, className, bordered ? 'w-noborder' : null].filter(Boolean).join(' ').trim();\n function onItemClick(key: string) {\n let keys = activeKey;\n if (accordion) {\n keys = keys[0] === key ? [] : [key];\n } else {\n keys = [...keys];\n const index = keys.indexOf(key);\n const isActive = index > -1;\n if (isActive) {\n keys.splice(index, 1);\n } else {\n keys.push(key);\n }\n }\n setActiveKey(keys);\n }\n useMemo(() => {\n if (propsActiveKey !== activeKey) {\n setActiveKey(toArray(propsActiveKey));\n }\n }, [propsActiveKey]);\n useMemo(() => {\n if (propsActiveKey !== activeKey) {\n onChange && onChange(activeKey);\n }\n }, [activeKey, propsActiveKey]);\n return (\n \n {React.Children.map(children, (child: any, index) => {\n // 如果没有密钥提供,请使用面板顺序作为默认密钥\n const key = child.key || String(index);\n const { disabled } = child.props;\n let isActive = false;\n if (accordion) {\n // 手风琴模式下默认选择第一个\n isActive = activeKey[0] === key;\n } else {\n isActive = activeKey.indexOf(key) > -1;\n }\n const childProps = {\n prefixCls,\n isActive,\n disabled,\n showArrow,\n onItemClick: disabled ? () => {} : () => onItemClick(key),\n ...child.props,\n };\n return React.cloneElement(child, childProps);\n })}\n
\n );\n}\n\nconst Collapse = React.forwardRef(InternalCollapse);\ntype Collapse = typeof Collapse & {\n Panel: typeof Panel;\n};\n\n(Collapse as Collapse).Panel = Panel;\n\nexport default Collapse as Collapse;\n","import React from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport { TransitionStatus } from 'react-transition-group/Transition';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport Icon, { IconProps } from '@uiw/react-icon';\n\nexport interface CollapsePanelProps extends IProps, HTMLDivProps {\n disabled?: boolean;\n showArrow?: boolean;\n isActive?: boolean;\n header?: React.ReactNode;\n icon?: IconProps['type'];\n extra?: React.ReactNode;\n onItemClick?: (evn: React.MouseEvent) => void;\n}\n\nexport default function Panel(props: CollapsePanelProps) {\n const {\n prefixCls = 'w-collapse',\n className,\n icon = 'down',\n children,\n isActive,\n onItemClick,\n disabled = false,\n showArrow,\n header,\n extra,\n ...resetProps\n } = props;\n const cls = [\n prefixCls ? `${prefixCls}-item` : null,\n className,\n isActive ? `${prefixCls}-active` : null,\n disabled ? `${prefixCls}-disabled` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n const iconRender = typeof icon === 'string' ? : icon;\n\n const childStyle = (child: React.ReactElement) => {\n return Object.assign({}, child && child.props ? child.props.style : {}, {\n transitionDuration: '300ms',\n });\n };\n function getInstance(status: TransitionStatus, instance: any) {\n if (!instance) {\n return;\n }\n if (status === 'exited' || status === 'exiting') {\n instance.style.height = '1px';\n }\n if (status === 'entered' || status === 'entering') {\n instance.style.height = `${instance.scrollHeight}px`;\n }\n }\n return (\n \n
\n {showArrow && iconRender}\n
{header}\n {extra &&
{extra}
}\n
\n
\n {(status: TransitionStatus) =>\n React.cloneElement({children}
, {\n className: `${prefixCls}-panel`,\n style: childStyle(children as React.ReactElement),\n ref: (e: any) => getInstance(status, e),\n })\n }\n \n
\n );\n}\n","import Collapse from './Collapse';\n\nexport * from './Collapse';\nexport * from './Panel';\n\nexport default Collapse;\n","import React from 'react';\nimport copy from '@uiw/copy-to-clipboard';\nimport { IProps, HTMLSpanProps } from '@uiw/utils';\nimport './style/index.less';\n\nexport interface CopyToClipboardProps extends IProps, Omit {\n text?: string;\n onClick?: (text: string, isCopy: boolean, event: React.MouseEvent) => void;\n}\n\nexport default function CopyToClipboard(props: CopyToClipboardProps & T) {\n const {\n prefixCls = 'w-copy-to-clipboard',\n className,\n text = '',\n children,\n onClick = () => null,\n ...resetProps\n } = props;\n function handleClick(e: React.MouseEvent) {\n if (!text) {\n return onClick('', false, e);\n }\n copy(text, (isCopy: boolean) => {\n onClick(text, isCopy, e);\n });\n }\n const otherProps = {\n ...resetProps,\n className: [prefixCls, className].filter(Boolean).join(' ').trim(),\n onClick: handleClick,\n };\n return (\n \n {text}\n {children}\n \n );\n}\n","import React, { useEffect, useState } from 'react';\nimport Input, { InputProps } from '@uiw/react-input';\nimport Popover, { PopoverProps } from '@uiw/react-popover';\nimport DatePicker, { DatePickerProps } from '@uiw/react-date-picker';\nimport Icon from '@uiw/react-icon';\nimport { IProps } from '@uiw/utils';\nimport formatter from '@uiw/formatter';\nimport './style/date-input-range.less';\n\nexport interface DateInputRangeProps extends IProps, Omit {\n popoverProps?: PopoverProps;\n datePickerProps?: DatePickerProps;\n value?: Array;\n format?: string;\n allowClear?: boolean;\n bodyStyle?: object;\n onChange?: (selectedDate?: Date, dateRange?: Array) => void;\n}\n\nexport function DateInputRange(props: DateInputRangeProps) {\n const {\n prefixCls = 'w-dateinputrange',\n bodyStyle = undefined,\n className,\n popoverProps,\n datePickerProps,\n allowClear = true,\n format = 'YYYY/MM/DD',\n onChange,\n value,\n ...inputProps\n } = props;\n\n const [dateRange, setDateRange] = useState>([]);\n useEffect(() => {\n let valueTemp: Array = [];\n const propsValue = value;\n if (Array.isArray(propsValue) && !!propsValue?.length) {\n propsValue.forEach((date, index) => {\n valueTemp[index] = typeof propsValue[index] === 'string' ? new Date(date) : (date as Date);\n });\n }\n setDateRange(valueTemp);\n }, [JSON.stringify(value)]);\n\n function handleChange(cdate: Date | undefined, idx?: number) {\n const changeValue = [...dateRange];\n changeValue[idx!] = cdate;\n setDateRange(changeValue);\n onChange && onChange(cdate, changeValue);\n }\n\n return (\n \n );\n}\n","import React, { useEffect, useState } from 'react';\nimport Input, { InputProps } from '@uiw/react-input';\nimport Popover, { PopoverProps } from '@uiw/react-popover';\nimport DatePicker, { DatePickerProps } from '@uiw/react-date-picker';\nimport Icon from '@uiw/react-icon';\nimport { IProps } from '@uiw/utils';\nimport formatter from '@uiw/formatter';\nexport * from './DateInputRange';\nimport './style/index.less';\n\nexport interface DateInputProps extends IProps, Omit {\n popoverProps?: PopoverProps;\n datePickerProps?: DatePickerProps;\n value?: Date | string;\n format?: string;\n allowClear?: boolean;\n onChange?: (selectedDate?: Date) => void;\n}\n\nexport default function DateInput(props: DateInputProps) {\n const {\n prefixCls = 'w-dateinput',\n className,\n popoverProps,\n datePickerProps,\n allowClear = true,\n format = 'YYYY/MM/DD',\n onChange,\n ...inputProps\n } = props;\n const [date, setDate] = useState(props.value);\n\n const value = date || '';\n inputProps.value = typeof value === 'string' ? value : formatter(format, value);\n\n useEffect(() => {\n if (props.value !== date) {\n setDate(props.value);\n }\n }, [props.value]);\n\n function handleChange(cdate?: Date) {\n setDate(cdate);\n onChange && onChange(cdate);\n }\n if (allowClear && inputProps.value) {\n inputProps.addonAfter = (\n handleChange(undefined)} type=\"close\" />\n );\n }\n return (\n handleChange(selectedDate!)}\n />\n }\n >\n \n \n );\n}\n","import React from 'react';\nimport { IProps } from '@uiw/utils';\n\nexport interface DescriptionsItemProps extends IProps {\n label?: React.ReactNode;\n children: React.ReactNode;\n span?: number;\n}\n\nconst DescriptionsItem: React.FC = ({ children }) => children as JSX.Element;\n\nexport default DescriptionsItem;\n","import React, { Fragment } from 'react';\nimport { IProps } from '@uiw/utils';\nimport { DescriptionsItemProps } from './DescriptionsItem';\nimport { RowProps } from './Row';\n\nexport interface CellProps\n extends Omit,\n Omit,\n React.HTMLAttributes,\n IProps {\n children?: React.ReactElement | React.ReactNode;\n tagName?: 'td' | 'th';\n /**\n * 是否为一行的最后一个\n */\n isLastCell?: boolean;\n}\n\nfunction Cell(props: CellProps = {}) {\n const {\n prefixCls,\n className,\n tagName: TagName = 'td',\n layout,\n bordered,\n label,\n isLastCell,\n colon,\n span,\n children,\n column,\n ...other\n } = props;\n\n const labelProps: React.HTMLAttributes = {\n className: [\n prefixCls ? `${prefixCls}-item-label` : null,\n className,\n colon ? `${prefixCls}-item-colon` : null,\n !label ? `${prefixCls}-item-no-label` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim(),\n };\n if (layout === 'horizontal') {\n if (!bordered) {\n return (\n \n {label}\n {children}\n \n );\n }\n return (\n \n {label} | \n \n {children}\n \n \n );\n }\n return (\n \n {children}\n \n );\n}\n\nexport default Cell;\n","import React, { Fragment } from 'react';\nimport { IProps } from '@uiw/utils';\nimport { DescriptionsItemProps } from './DescriptionsItem';\nimport Cell from './Cell';\n\nexport interface RowProps extends IProps {\n children?: React.ReactElement[];\n bordered?: boolean;\n layout?: 'horizontal' | 'vertical';\n colon?: boolean;\n column?: number;\n}\n\nexport default function Row(props: RowProps = {}) {\n const { prefixCls, layout, bordered, column, colon, children = [] } = props;\n function handleCell(isHead?: boolean) {\n return children.map((child, index) => (\n \n {isHead ? child.props.label : child.props.children}\n | \n ));\n }\n const cls = prefixCls ? `${prefixCls}-row` : '';\n return (\n \n {layout === 'vertical' && {handleCell(true)}
}\n {handleCell()}
\n \n );\n}\n","import React from 'react';\nimport { IProps } from '@uiw/utils';\nimport DescriptionsItem, { DescriptionsItemProps } from './DescriptionsItem';\nimport Row, { RowProps } from './Row';\nimport './style/index.less';\n\nexport * from './DescriptionsItem';\n\nexport interface DescriptionsProps extends IProps {\n column?: number;\n title?: React.ReactNode;\n children?: React.ReactNode;\n bordered?: boolean;\n colon?: boolean;\n size?: 'large' | 'small' | 'default';\n layout?: RowProps['layout'];\n}\n\nconst generateChildrenRows = (\n children: React.ReactElement[],\n column: number,\n): Array[]> => {\n const rows: React.ReactElement[][] = [];\n let columns: React.ReactElement[] | null = null;\n let leftSpans: number;\n\n children.forEach((node: React.ReactElement, index: number) => {\n let itemNode = node;\n\n if (!columns) {\n leftSpans = column;\n columns = [];\n rows.push(columns);\n }\n\n // Always set last span to align the end of Descriptions\n const lastItem = index === children.length - 1;\n if (lastItem) {\n itemNode = React.cloneElement(itemNode, {\n span: leftSpans,\n });\n }\n // Calculate left fill span\n const { span = 1 } = itemNode.props;\n columns.push(itemNode);\n leftSpans -= span;\n\n if (leftSpans <= 0) {\n columns = null;\n }\n });\n\n return rows;\n};\n\nfunction InternalDescriptions(props: DescriptionsProps, ref: React.ForwardedRef) {\n const {\n prefixCls = 'w-descriptions',\n className,\n title,\n bordered,\n column = 3,\n size,\n colon = true,\n children,\n layout = 'horizontal',\n ...other\n } = props;\n const cls = [\n prefixCls,\n className,\n prefixCls && layout ? `${prefixCls}-${layout}` : null,\n bordered ? `${prefixCls}-bordered` : null,\n size ? `${prefixCls}-${size}` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n const cloneChildren = React.Children.toArray(children) as JSX.Element[];\n const childs: Array[]> = generateChildrenRows(cloneChildren, column!);\n\n return (\n \n
\n {title && {title}}\n \n {childs.map((child, index) => (\n \n {child}\n
\n ))}\n \n
\n
\n );\n}\n\nconst Descriptions = React.forwardRef(InternalDescriptions);\ntype Descriptions = typeof Descriptions & {\n Item: typeof DescriptionsItem;\n};\n\n(Descriptions as Descriptions).Item = DescriptionsItem;\n\nexport default Descriptions as Descriptions;\n","import React from 'react';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport './style/index.less';\n\nexport interface DividerProps extends IProps, HTMLDivProps {\n dashed?: boolean;\n type?: 'horizontal' | 'vertical';\n align?: 'left' | 'right' | 'center';\n}\n\nexport default React.forwardRef((props, ref) => {\n const {\n prefixCls = 'w-divider',\n className,\n children,\n dashed = false,\n type = 'horizontal',\n align = 'center',\n ...restProps\n } = props;\n const cls = [\n className,\n prefixCls,\n prefixCls && type ? `${prefixCls}-${type}` : null,\n prefixCls && align ? `${prefixCls}-${align}` : null,\n children ? `${prefixCls}-with-text` : null,\n !!dashed ? `${prefixCls}-dashed` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n return (\n \n {children && {children}}\n
\n );\n});\n","import React, { useMemo } from 'react';\nimport Overlay, { OverlayProps } from '@uiw/react-overlay';\nimport Icon, { IconProps } from '@uiw/react-icon';\nimport Button from '@uiw/react-button';\nimport { HTMLDivProps } from '@uiw/utils';\nimport './style/index.less';\n\nexport interface DrawerProps extends OverlayProps {\n footer?: React.ReactNode;\n icon?: IconProps['type'];\n title?: React.ReactNode;\n bodyProps?: HTMLDivProps;\n placement?: 'top' | 'right' | 'bottom' | 'left';\n size?: number;\n isCloseButtonShown?: boolean;\n onClose?: (e: React.MouseEvent) => void;\n}\n\nexport default (props: DrawerProps = {}) => {\n const {\n prefixCls = 'w-drawer',\n className,\n style,\n placement = 'right',\n size = 260,\n title,\n footer,\n icon,\n isCloseButtonShown = true,\n bodyProps,\n timeout = 300,\n isOpen = false,\n maskClosable = true,\n ...overlayProps\n } = props;\n const cls = [className, prefixCls, placement].filter(Boolean).join(' ').trim();\n const bodyCls = [bodyProps ? bodyProps.className : null, prefixCls ? `${prefixCls}-body-inner` : null]\n .filter(Boolean)\n .join(' ')\n .trim();\n const styl = {\n ...style,\n [/^(top|bottom)$/.test(placement!) ? 'height' : 'width']: size,\n };\n const footerView = useMemo(() => (footer ? {footer}
: null), [footer]);\n const iconView = useMemo(() => (icon ? : null), [icon]);\n const titleView = useMemo(() => (title ? {title}
: null), [title]);\n return (\n \n \n {(title || icon) && (\n
\n {iconView}\n {titleView}\n {title && isCloseButtonShown && }\n
\n )}\n
\n
\n {props.children}\n
\n
\n {footerView}\n
\n \n );\n};\n","import React from 'react';\nimport OverlayTrigger, { OverlayTriggerProps } from '@uiw/react-overlay-trigger';\nimport { IProps } from '@uiw/utils';\nimport { useMemo } from 'react';\n\nexport interface DropdownProps extends IProps, OverlayTriggerProps {\n menu?: React.ReactNode;\n}\n\nexport default function Dropdown(props: DropdownProps) {\n const { prefixCls = 'w-dropdown', placement = 'bottomLeft', className, menu, children, disabled, ...other } = props;\n\n const cls = useMemo(() => [prefixCls, className].filter(Boolean).join(' ').trim(), [prefixCls, className]);\n\n return (\n \n {React.cloneElement(children, Object.assign({}, children.props))}\n \n );\n}\n","import React from 'react';\nimport './style/index.less';\n\nexport interface EmptyProps extends React.HTMLAttributes {\n prefixCls?: string;\n icon?: React.ReactNode;\n size?: number | string;\n iconProps?: React.SVGProps;\n /** 自定义描述内容 */\n description?: React.ReactNode;\n}\n\nconst Empty = (props: EmptyProps) => {\n const {\n prefixCls = 'w-empty',\n className,\n icon,\n iconProps,\n size = 64,\n description = '暂无数据',\n children,\n ...other\n } = props;\n\n const cls = [prefixCls, className].filter(Boolean).join(' ').trim();\n return (\n \n
\n {icon ? (\n icon\n ) : (\n
\n )}\n
\n {description &&
{description}
}\n {children &&
{children}
}\n
\n );\n};\n\nexport default Empty;\n","import React from 'react';\nimport Input, { InputProps } from '@uiw/react-input';\nimport { FileInputProps } from './';\n\nexport interface InputUploadProps extends FileInputProps, InputProps {}\n\nexport default React.forwardRef((props, ref) => {\n const { className, dataLabel = 'Browse', prefixCls = 'w-fileinput', ...other } = props;\n const cls = [prefixCls, className].filter(Boolean).join(' ').trim();\n return ;\n});\n","import React from 'react';\nimport Icon from '@uiw/react-icon';\nimport { FileInputListProps } from './';\nimport './style/index.less';\n\nconst Picture = (props: FileInputListProps) => {\n const {\n className,\n prefixCls = 'w-fileinput-list',\n dataList = [],\n uploadType,\n size = 'middle',\n shape = 'round',\n readonly,\n children,\n showFileIcon = {\n showPreviewIcon: true,\n showRemoveIcon: true,\n },\n onPreview,\n onAdd,\n onRemove,\n } = props;\n\n const cls = [prefixCls, `${prefixCls}-size-${size}`, `${prefixCls}-shape-${shape}`, className]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n return (\n \n {children &&\n !readonly &&\n React.isValidElement(children) &&\n React.cloneElement(children, {\n onClick: onAdd,\n })}\n
\n {dataList.map((item, index) => (\n
\n {uploadType === 'picture' && (\n
\n
\n {showFileIcon?.showPreviewIcon && (\n
\n onPreview?.(item)}>\n \n \n
\n )}\n
\n )}\n
{item.name}
\n {showFileIcon?.showRemoveIcon && (\n
onRemove?.(index)}>\n \n
\n )}\n
\n ))}\n
\n
\n );\n};\n\nexport default Picture;\n","import React from 'react';\nimport Icon from '@uiw/react-icon';\nimport { FileInputListProps } from './';\nimport './style/index.less';\n\nconst Card = (props: FileInputListProps) => {\n const {\n className,\n prefixCls = 'w-fileinput-card',\n dataList = [],\n maxNumber = 3,\n shape = 'round',\n size = 'middle',\n readonly,\n children,\n showFileIcon = {\n showPreviewIcon: true,\n showRemoveIcon: true,\n },\n onAdd,\n onPreview,\n onRemove,\n } = props;\n const cls = [prefixCls, `${prefixCls}-size-${size}`, `${prefixCls}-shape-${shape}`, className]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n const isAction = showFileIcon.showPreviewIcon || showFileIcon.showRemoveIcon ? true : false;\n\n return (\n \n {dataList.map((item, index) => (\n
\n
\n
\n
\n\n
\n {showFileIcon?.showPreviewIcon && (\n onPreview?.(item)}>\n \n \n )}\n {showFileIcon?.showRemoveIcon && (\n onRemove?.(index)}>\n \n \n )}\n
\n
\n ))}\n {maxNumber > dataList.length && !readonly && (\n
\n {children}\n
\n )}\n
\n );\n};\n\nexport default Card;\n","import { FileInputValue } from './';\n\nexport const openFileDialog = (inputRef: any): void => {\n if (inputRef.current) inputRef.current.click();\n};\n\nexport const getAcceptTypeString = (accept?: Array) => {\n return accept && accept.length > 0 ? accept.map((item) => `.${item}`).join(', ') : 'image/*';\n};\n\nexport const getBase64 = (file: File): Promise => {\n const reader = new FileReader();\n return new Promise((resolve) => {\n reader.addEventListener('load', () => resolve(String(reader.result)));\n reader.readAsDataURL(file);\n });\n};\n\nexport const getListFiles = (files: FileList, dataURLKey: string): Promise => {\n const promiseFiles: Array> = [];\n for (let i = 0; i < files.length; i += 1) {\n promiseFiles.push(getBase64(files[i]));\n }\n return Promise.all(promiseFiles).then((fileListBase64: Array) => {\n const fileList: FileInputValue[] = fileListBase64.map((base64, index) => ({\n [dataURLKey]: base64,\n file: files[index],\n name: files[index].name,\n }));\n return fileList;\n });\n};\n\nexport const isUploadType = (type: string) => {\n return ['picture', 'text', 'card'].includes(type);\n};\n","import React, { useRef, useCallback, useEffect, useState } from 'react';\nimport List from './List';\nimport Card from './Card';\nimport { FileInputValue, FileInputListProps } from './';\nimport { FileInputUploadProps } from './types';\nimport { openFileDialog, getListFiles } from './utils';\n\nexport const FileList = (props: FileInputUploadProps) => {\n const { uploadType, value = [], multiple = false, maxNumber = 3, onChange } = props;\n const inputRef = useRef(null);\n const inValue: FileInputValue[] = value || [];\n const [fileList, setFileList] = useState([]);\n\n useEffect(() => {\n setFileList(inValue);\n }, []);\n\n const handleClickInput = useCallback(() => openFileDialog(inputRef), [inputRef]);\n\n const onFileUpload = useCallback((): void => {\n if (inputRef.current) inputRef.current.value = '';\n handleClickInput();\n }, [handleClickInput]);\n\n const onInputChange = async (e: React.ChangeEvent) => {\n const files = e.target.files;\n if (!files) return;\n const updatedFileList = await getListFiles(files, 'dataURL');\n let updatedList = [...fileList, ...updatedFileList];\n if (maxNumber < updatedList.length) {\n updatedList = updatedList.slice(0, maxNumber);\n }\n setFileList(updatedList);\n onChange?.(updatedList);\n };\n\n const onRemove = (index: number) => {\n const updatedList = [...fileList];\n updatedList.splice(index, 1);\n setFileList(updatedList);\n onChange?.(updatedList);\n };\n\n let Comp: ((props: FileInputListProps) => JSX.Element) | undefined;\n\n if (uploadType === 'card') {\n Comp = Card;\n }\n if (uploadType === 'picture' || uploadType === 'text') {\n Comp = List;\n }\n\n return (\n \n \n {Comp && (\n \n )}\n \n );\n};\n\nexport default FileList;\n","import React from 'react';\nimport Input from './Input';\nimport FileList from './FileList';\nimport { isUploadType } from './utils';\nimport { InputProps } from '@uiw/react-input';\nimport { UploadType, FileInputBaseProps, FileInputUploadProps, FileInputShowIconProps } from './types';\nimport './style/index.less';\nexport interface FileInputValue {\n dataURL?: string;\n file?: File;\n name?: string;\n [key: string]: any;\n}\nexport interface FileInputProps extends FileInputBaseProps, InputProps {\n dataLabel?: string;\n}\nexport interface FileInputListProps extends FileInputUploadProps {\n shape?: 'circle' | 'round';\n size?: 'large' | 'middle' | 'small';\n showFileIcon?: FileInputShowIconProps;\n dataList: FileInputValue[];\n onAdd?: () => void;\n onRemove?: (index: number) => void;\n}\n\ninterface Props {\n uploadType?: UploadType;\n [key: string]: any;\n}\n\nfunction Upload(props: Props) {\n const { uploadType = 'input' } = props;\n\n if (uploadType === 'input') {\n return ;\n }\n\n if (isUploadType(uploadType)) {\n return ;\n }\n return null;\n}\n\nexport default Upload;\n","import React from 'react';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport './style/col.less';\n\nexport interface ColProps extends IProps, HTMLDivProps {\n fixed?: boolean;\n span?: number | string;\n grow?: number | string;\n align?: 'top' | 'middle' | 'bottom' | 'baseline';\n}\n\nexport function Col(props: ColProps = {}) {\n const { prefixCls = 'w-col', className, fixed, span, grow, align, ...other } = props;\n const cls = [\n prefixCls,\n className,\n span ? `${prefixCls}-${span}` : null,\n fixed ? `${prefixCls}-fixed` : null,\n align ? `${prefixCls}-align-${align}` : null,\n fixed ? `${prefixCls}-grow-${grow}` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n return (\n \n {props.children}\n
\n );\n}\n","import React from 'react';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport './style/row.less';\n\nexport interface RowProps extends IProps, HTMLDivProps {\n fixed?: boolean;\n gutter?: number;\n justify?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';\n align?: 'top' | 'middle' | 'bottom' | 'baseline';\n}\n\nexport function Row(props: RowProps = {}) {\n const { prefixCls = 'w-row', className, gutter = 0, justify, align, ...other } = props;\n const cls = [\n prefixCls,\n className,\n align ? `${prefixCls}-align-${align}` : null,\n justify ? `${prefixCls}-justify-${justify}` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n const gutterStyl = !gutter ? {} : { paddingLeft: gutter / 2, paddingRight: gutter / 2 };\n return (\n \n {React.Children.toArray(props.children).map((child) => {\n if (!React.isValidElement(child)) return child;\n return React.cloneElement(\n child,\n Object.assign({}, child.props, {\n style: { ...child.props.style, ...gutterStyl },\n }),\n );\n })}\n
\n );\n}\n","import React from 'react';\nimport { Col, Row } from '@uiw/react-grid';\nimport { IProps, HTMLInputProps } from '@uiw/utils';\nimport { FormFieldsProps } from './Form';\nimport './style/form-item.less';\n\nexport interface FormItemProps extends IProps, HTMLInputProps {\n inline?: boolean;\n hasError?: boolean;\n label?: React.ReactNode;\n required?: boolean;\n labelFor?: string;\n labelClassName?: string;\n help?: React.ReactNode;\n labelStyle?: React.CSSProperties;\n initialValue?: string | number | T;\n validator?: FormFieldsProps['validator'];\n}\n\nexport default class FormItem extends React.PureComponent> {\n public static defaultProps = {\n prefixCls: 'w-form-item',\n };\n render() {\n const {\n prefixCls,\n className,\n required,\n style,\n label,\n labelFor,\n labelClassName,\n labelStyle,\n help,\n inline,\n initialValue,\n validator,\n hasError,\n ...otherProps\n } = this.props;\n\n const cls = [prefixCls, className, hasError ? `${prefixCls}-error` : null].filter(Boolean).join(' ').trim();\n const labelCls = ['w-form-label', labelClassName].filter(Boolean).join(' ').trim();\n if (inline) {\n return (\n \n \n \n {required && }\n \n \n {this.props.children}\n
\n {help && (\n \n {help}\n
\n )}\n
\n );\n }\n return (\n \n {label && (\n
\n {required && }\n \n \n )}\n
{this.props.children}\n {help &&
{help}
}\n
\n );\n }\n}\n","import React, { useState, useImperativeHandle, useMemo } from 'react';\nimport { IProps } from '@uiw/utils';\nimport FormItem, { FormItemProps } from './FormItem';\nimport './style/form.less';\n\nexport interface FormProps extends IProps, Omit, 'onChange' | 'onSubmit'> {\n prefixCls?: string;\n fields?: Record>;\n onSubmit?: (state: FormSubmitProps, event: React.FormEvent) => any;\n afterSubmit?: (result: FormAfterSubmitProps) => any;\n onChange?: (state: FormState) => void;\n onSubmitError?: (evn: any) => any;\n resetOnSubmit?: boolean;\n children?: (handle: FormChildrenProps) => JSX.Element | JSX.Element | undefined;\n}\n\nexport interface FormState {\n submitting: boolean;\n initial: Record;\n current: FormState['initial'];\n errors: Record;\n}\n\nexport interface FormFieldsProps extends FormItemProps {\n name?: string;\n children?: React.ReactNode;\n help?: React.ReactNode;\n labelFor?: string;\n inline?: boolean;\n checked?: boolean;\n initialValue?: string | number | T;\n required?: boolean;\n validator?: (currentValue: any) => any;\n}\n\nexport interface FormSubmitProps {\n initial: FormState['initial'];\n current: FormState['current'];\n}\n\nexport interface FormAfterSubmitProps {\n state: FormState;\n response: any;\n reset: () => void;\n}\n\nexport interface FormChildrenProps {\n fields: Record;\n resetForm: () => void;\n canSubmit: () => boolean;\n state: FormState;\n}\n\nexport type FormElementProps = {\n id?: string;\n name?: string;\n value?: string | boolean;\n checked?: boolean;\n onChange?: (env: React.BaseSyntheticEvent, list?: string[]) => void;\n};\n\nexport type FormRefType = Record<'onSubmit' | 'resetForm' | 'getFieldValues' | 'setFields', Function>;\n\nfunction newFormState(\n fields: FormProps['fields'],\n cb: (porps: FormFieldsProps) => {\n initialValue: FormFieldsProps['initialValue'];\n currentValue: FormFieldsProps['initialValue'];\n },\n): FormState {\n const state: FormState = {\n initial: {},\n current: {},\n submitting: false,\n errors: {},\n };\n for (const name in fields) {\n const props = fields[name];\n if (!props) continue;\n const { initialValue, currentValue } = cb({ ...props, name });\n state.initial[name] = Array.isArray(initialValue) ? [...initialValue] : initialValue;\n state.current[name] = currentValue;\n }\n return state;\n}\n\nfunction newInitialValue(value: FormFieldsProps['initialValue']) {\n return value === null || value === undefined ? '' : value;\n}\n\nconst isPromise = (promise: Promise) => promise && typeof promise.then === 'function';\n\nfunction Form(\n {\n prefixCls = 'w-form',\n className,\n fields,\n children,\n resetOnSubmit,\n onSubmitError,\n onChange,\n onSubmit,\n afterSubmit,\n ...others\n }: FormProps,\n ref: React.ForwardedRef, //| React.RefObject,\n) {\n const initData = useMemo(\n () =>\n newFormState(fields, ({ initialValue }) => {\n initialValue = newInitialValue(initialValue);\n return { initialValue, currentValue: initialValue };\n }),\n [],\n );\n const [data, setData] = useState(initData);\n\n useImperativeHandle(\n ref,\n () => ({\n onSubmit: handleSubmit,\n resetForm: handleReset,\n getFieldValues: () => data.current,\n getError: () => data.errors,\n setFields: setFields,\n setFieldValue: setFieldValue,\n }),\n [data],\n );\n\n const formUnits: FormChildrenProps['fields'] = {};\n for (const name in fields) {\n const props = fields[name];\n if (!props) continue;\n const error = data.errors[name];\n if (typeof props.initialValue === 'boolean') {\n props.checked = props.initialValue;\n }\n const childField: FormFieldsProps = controlField({\n ...props,\n name,\n });\n const help = error || props.help;\n const labelFor = props.labelFor;\n formUnits[name] = (\n \n );\n }\n\n function setFields(fields: FormState['current']) {\n const tempData = { ...data, current: fields };\n setData(tempData);\n }\n\n function setFieldValue(fieldName: string, value: V) {\n const tempData = { ...data, current: { ...data.current, [fieldName]: value } };\n setData(tempData);\n }\n\n function handleChange(\n name: string,\n validator: FormFieldsProps['validator'],\n element?: React.ReactElement,\n cb?: (env: React.BaseSyntheticEvent) => void,\n ) {\n return (env: React.BaseSyntheticEvent, list?: string[]) => {\n let value = env && env.target && 'value' in env.target ? env.target.value : env;\n // 控件 Checkbox.Group 多选值的处理\n value = list || value;\n // 控件 Checkbox 值的处理\n if (!list && element && env && env.target && /(radio)/.test(env.target.type)) {\n // 控件 Switch/Radio/Checkbox 值的处理\n value = env.target.value ? env.target.value : env.target.checked;\n }\n if (!list && element && env && env.target && /(checkbox)/.test(env.target.type)) {\n // 控件 Switch/Radio/Checkbox 值的处理\n value = env.target.checked;\n }\n const nextState = {\n current: { ...data.current, [name]: value },\n } as FormState;\n const error = validator && validator(value);\n if (!error) {\n nextState.errors = { ...data.errors };\n delete nextState.errors[name];\n }\n if (env && env.persist && typeof env.persist === 'function') env.persist();\n setData({ ...data, ...nextState });\n if (cb) {\n cb(env);\n }\n onChange && onChange({ ...data, ...nextState });\n };\n }\n\n function handleSubmit(e: React.FormEvent) {\n e && e.preventDefault();\n const { initial, current } = data;\n setData({ ...data, submitting: true });\n const nextState = { submitting: false } as FormState;\n const onError = (evn: unknown) =>\n setData({\n ...data,\n ...nextState,\n errors: (onSubmitError && onSubmitError(evn)) || {},\n });\n const onSuccess = (response: any) => {\n if (resetOnSubmit) {\n nextState.current = initial;\n }\n setData({ ...data, ...nextState, errors: {} });\n afterSubmit && afterSubmit({ state: data, response, reset: handleReset });\n };\n try {\n const afterSubmitPromise = onSubmit ? onSubmit({ initial, current }, e) : undefined;\n if (afterSubmitPromise && isPromise(afterSubmitPromise)) {\n return afterSubmitPromise.then(onSuccess).catch(onError);\n } else {\n return onSuccess(afterSubmitPromise);\n }\n } catch (evn) {\n onError(evn);\n }\n }\n\n function canSubmit() {\n const { submitting, current = {} } = data;\n let passesValidators = true;\n for (const name in fields) {\n if (Object.prototype.hasOwnProperty.call(fields, name)) {\n const props: FormFieldsProps = fields[name];\n if (!props) continue;\n if (props.validator && props.validator(current[name])) {\n passesValidators = false;\n break;\n }\n }\n }\n return !submitting && passesValidators;\n }\n\n function handleReset() {\n let { initial } = data;\n const initials = { ...initial };\n Object.entries(initials).map(([key, value]) => {\n if (Array.isArray(value)) {\n initials[key] = [...value];\n }\n });\n setData({ ...data, initial, current: initials, errors: {} });\n }\n\n function controlField({\n children,\n validator,\n name,\n help,\n label,\n labelFor,\n labelClassName,\n labelStyle,\n inline,\n initialValue,\n ...other\n }: FormFieldsProps) {\n const element =\n typeof children !== 'function'\n ? children\n : children({\n onChange: handleChange(name!, validator),\n onSubmit: handleSubmit,\n canSubmit: canSubmit,\n });\n if (!element || React.Children.count(element) !== 1 || !name) return element;\n const props = {\n name: element.props.name || name,\n ...other,\n } as FormElementProps;\n const hasCurrentValue = Object.prototype.hasOwnProperty.call(data.current, name);\n props.id = element.props.id;\n props.value = hasCurrentValue ? data.current && data.current[name] : props.value;\n // : element.props.value;\n\n const type = element.props.type;\n // console.log('type', element)\n if (type === 'checkbox' || type === 'switch' || typeof props.value === 'boolean') {\n props.checked = !!props.value;\n delete props.value;\n }\n props.onChange = handleChange(name, validator, element, element.props.onChange) as FormElementProps['onChange'];\n return React.cloneElement(element, props as FormElementProps);\n }\n\n return (\n \n );\n}\n\nexport default React.forwardRef>(Form);\n","import Form from './Form';\n\nexport * from './Form';\nexport * from './FormItem';\nexport { default as FormItem } from './FormItem';\n\nexport default Form;\n","import React, { Fragment } from 'react';\nimport { IProps } from '@uiw/utils';\n\nexport type TagType = React.ComponentType | keyof JSX.IntrinsicElements;\n\nexport interface ListItemProps extends IProps, React.HTMLProps {\n disabled?: boolean;\n active?: boolean;\n extra?: React.ReactNode;\n href?: string;\n tagName?: Tag;\n}\n\nexport const ListItem = React.forwardRef(\n (props: ListItemProps, ref: React.Ref>) => {\n const {\n prefixCls = 'w-list-item',\n className,\n children,\n extra,\n tagName = 'div',\n active = false,\n ...resetProps\n } = props;\n const cls = [prefixCls, className, props.disabled ? 'w-disabled' : null, active ? 'w-active' : null]\n .filter(Boolean)\n .join(' ')\n .trim();\n const TagName = props.href && typeof tagName === 'string' ? 'a' : tagName;\n return React.createElement(\n TagName,\n {\n ...resetProps,\n className: cls,\n ref,\n } as any,\n !extra || resetProps.href ? (\n children\n ) : (\n \n {children}
\n {extra}
\n \n ),\n );\n },\n);\n\nListItem.displayName = 'List.Item';\n","import React from 'react';\nimport { IProps, HTMLDivProps, noop } from '@uiw/utils';\nimport { ListItem } from './Item';\nimport './style/index.less';\n\nexport * from './Item';\n\nexport interface ListProps extends IProps, HTMLDivProps {\n bordered?: boolean;\n striped?: boolean;\n noHover?: boolean;\n active?: boolean;\n header?: React.ReactNode;\n footer?: React.ReactNode;\n size?: 'small' | 'default' | 'large';\n renderItem?: (item: any, idx: number) => React.ReactNode;\n dataSource?: T[];\n}\n\nfunction InternalList(props: ListProps, ref: React.ForwardedRef) {\n const {\n prefixCls = 'w-list',\n bordered = true,\n striped = false,\n noHover = false,\n active = false,\n size = 'default',\n renderItem = noop,\n className,\n children,\n header,\n footer,\n dataSource = [],\n ...resetProps\n } = props;\n let items: React.ReactNode;\n if (dataSource && dataSource.length > 0) {\n items = dataSource.map((item: any, index: number) => renderItem!(item, index));\n } else {\n items = children;\n }\n let childrenList = React.Children.map(\n items,\n (child: React.ReactNode, index) =>\n React.isValidElement(child) &&\n React.cloneElement(child, {\n key: index,\n }),\n );\n const classString = [\n prefixCls,\n className,\n striped ? `${prefixCls}-striped` : null,\n noHover ? `${prefixCls}-no-hover` : null,\n active ? `${prefixCls}-active` : null,\n bordered ? `${prefixCls}-bordered` : null,\n size && size !== 'default' ? `${prefixCls}-size-${size}` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n return (\n \n {header &&
{header}
}\n {childrenList}\n {footer &&
{footer}
}\n
\n );\n}\n\nconst List = React.forwardRef>(InternalList);\ntype List = typeof List & {\n Item: typeof ListItem;\n};\n\n(List as List).Item = ListItem;\n\nexport default List as List;\n","import React, { useMemo } from 'react';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\nimport './style/index.less';\n\nexport interface LoaderProps extends IProps, HTMLDivProps {\n size?: 'small' | 'default' | 'large';\n loading?: boolean;\n fullscreen?: boolean;\n color?: string;\n bgColor?: string;\n vertical?: boolean;\n tip?: React.ReactNode;\n indicator?: React.ReactNode;\n children?: any | React.ReactNode;\n}\n\nexport default (props: LoaderProps = {}) => {\n const {\n prefixCls = 'w-loader',\n className,\n size = 'default',\n loading = true,\n tip,\n vertical,\n color,\n bgColor,\n children,\n indicator,\n fullscreen = false,\n ...otherProps\n } = props;\n const cls = [prefixCls, className, size ? `${prefixCls}-${size}` : null].filter(Boolean).join(' ').trim();\n\n const indicatorView = useMemo(\n () => (\n \n ),\n [],\n );\n\n const tipsView = useMemo(\n () => (\n \n
\n {indicator || indicatorView}\n {tip && (\n
\n {tip}\n
\n )}\n
\n
\n ),\n [fullscreen, bgColor, prefixCls, vertical, tip],\n );\n\n return (\n \n {(loading || fullscreen) && tipsView}\n {children &&\n React.cloneElement(\n children,\n Object.assign({}, children.props, {\n className: [`${prefixCls}-warp`, loading ? `${prefixCls}-blur` : null].filter(Boolean).join(' ').trim(),\n }),\n )}\n
\n );\n};\n","import React, { Fragment } from 'react';\nimport Icon, { IconProps } from '@uiw/react-icon';\nimport { IProps } from '@uiw/utils';\nimport './style/item.less';\n\nconst disabledProps = {\n href: undefined,\n onClick: undefined,\n onMouseDown: undefined,\n onMouseEnter: undefined,\n onMouseLeave: undefined,\n tabIndex: -1,\n};\n\nexport type TagType = React.ComponentType | keyof JSX.IntrinsicElements;\n\nexport interface MenuItemProps extends IProps, React.HTMLProps {\n text?: React.ReactNode;\n addonAfter?: React.ReactNode;\n tagName?: Tag;\n multiline?: boolean;\n isSubMenuItem?: boolean;\n disabled?: boolean;\n active?: boolean;\n icon?: IconProps['type'];\n children?: React.ReactNode;\n}\n\nfunction Internal(props: MenuItemProps, ref: React.Ref>) {\n const {\n prefixCls = 'w-menu-item',\n className,\n tagName: TagName = 'a',\n children,\n disabled = false,\n multiline = false,\n icon,\n text,\n active = false,\n addonAfter,\n isSubMenuItem,\n ...htmlProps\n } = props;\n const anchorCls = [prefixCls, active ? 'active' : null, disabled ? 'w-disabled' : null, className]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n const tagComp = React.createElement(\n TagName,\n {\n ...htmlProps,\n ...(disabled ? disabledProps : {}),\n className: anchorCls,\n ref,\n } as any,\n \n \n \n {text}\n
\n {addonAfter}\n ,\n );\n if (isSubMenuItem) {\n return tagComp;\n }\n return {tagComp} ;\n}\n\nexport const MenuItem = React.forwardRef(Internal);\n\nMenuItem.displayName = 'uiw.MenuItem';\n","import React from 'react';\nimport { IProps, HTMLLiProps } from '@uiw/utils';\n\nexport interface MenuDividerProps extends IProps, Omit {\n title?: React.ReactNode;\n}\n\nexport const MenuDivider = React.forwardRef((props, ref) => {\n const { prefixCls = 'w-menu-divider', className, title, ...htmlProps } = props;\n const cls = [prefixCls, className].filter(Boolean).join(' ').trim();\n if (!title) {\n return ;\n }\n return (\n \n {title}\n \n );\n});\n\nMenuDivider.displayName = 'uiw.MenuDivider';\n","import React, { useMemo, useState } from 'react';\nimport { CSSTransitionProps } from 'react-transition-group/CSSTransition';\nimport OverlayTrigger, { OverlayTriggerProps, OverlayTriggerRef } from '@uiw/react-overlay-trigger';\nimport Icon from '@uiw/react-icon';\nimport { IProps } from '@uiw/utils';\nimport { MenuItem, MenuItemProps, TagType } from './MenuItem';\nimport Menu, { MenuProps } from './Menu';\nimport './style/submenu.less';\n\nexport interface SubMenuProps extends IProps, MenuItemProps {\n overlayProps?: OverlayTriggerProps;\n collapse?: boolean;\n disabled?: boolean;\n inlineCollapsed?: boolean;\n inlineIndent?: number;\n}\n\nfunction checkedMenuItem(node?: HTMLElement) {\n let isCheck = false;\n if (node) {\n // eslint-disable-next-line\n do {\n if (!node.dataset.menu) {\n isCheck = true;\n }\n if (node.dataset.menu && /^(subitem|divider)$/.test(node.dataset.menu)) {\n isCheck = false;\n }\n } while (!node.dataset.menu && (node = node.parentNode as HTMLElement));\n }\n return isCheck;\n}\n\nfunction IconView({ prefixCls, collapse, isOpen }: { prefixCls?: string; collapse?: boolean; isOpen: boolean }) {\n return useMemo(\n () => (\n \n ),\n [prefixCls, collapse, isOpen],\n );\n}\nexport const SubMenu = React.forwardRef(function (\n props: SubMenuProps,\n ref: React.Ref,\n) {\n const {\n prefixCls = 'w-menu-subitem',\n className,\n disabled,\n overlayProps = {},\n children,\n collapse = false,\n inlineIndent,\n inlineCollapsed,\n ...other\n } = props;\n const overlayTriggerProps = {} as OverlayTriggerProps & CSSTransitionProps;\n const menuProps: MenuProps = {\n bordered: true,\n children,\n inlineIndent,\n className: [prefixCls ? `${prefixCls}-overlay` : null].filter(Boolean).join(' ').trim(),\n };\n const popupRef = React.useRef(null);\n const [isOpen, setIsOpen] = useState(false);\n useMemo(() => {\n setIsOpen(false);\n }, [collapse]);\n\n function onClick(e: React.MouseEvent) {\n const target = e.currentTarget;\n const related = (e.relatedTarget || e.nativeEvent.target) as HTMLElement;\n if (target.children.length < 1) return;\n if (checkedMenuItem(related)) {\n if (popupRef.current) {\n popupRef.current!.hide();\n }\n }\n }\n function onExit(node: HTMLElement) {\n node.style.height = `${node.scrollHeight}px`;\n setIsOpen(false);\n }\n function onExiting(node: HTMLElement) {\n node.style.height = '0px';\n }\n function onEnter(node: HTMLElement) {\n node.style.height = '1px';\n setIsOpen(true);\n }\n function onEntering(node: HTMLElement) {\n node.style.height = `${node.scrollHeight}px`;\n }\n function onEntered(node: HTMLElement) {\n node.style.height = 'initial';\n }\n\n if (!collapse) {\n delete menuProps.onClick;\n menuProps.bordered = false;\n overlayTriggerProps.className = `${prefixCls}-collapse`;\n overlayTriggerProps.appear = false;\n overlayTriggerProps.isOutside = true;\n overlayTriggerProps.isClickOutside = false;\n overlayTriggerProps.unmountOnExit = false;\n overlayTriggerProps.trigger = 'click';\n overlayTriggerProps.transitionName = `${prefixCls}`;\n overlayTriggerProps.onExit = onExit;\n overlayTriggerProps.onExiting = onExiting;\n overlayTriggerProps.onEnter = onEnter;\n overlayTriggerProps.onEntered = onEntered;\n overlayTriggerProps.onEntering = onEntering;\n } else {\n overlayTriggerProps.className = `${prefixCls}-popup`;\n overlayTriggerProps.trigger = 'hover';\n overlayTriggerProps.usePortal = true;\n menuProps.onClick = onClick;\n }\n return (\n \n }\n >\n }\n className={[\n prefixCls ? `${prefixCls}-title` : null,\n !collapse ? `${prefixCls}-collapse-title` : null,\n className,\n ]\n .filter(Boolean)\n .join(' ')\n .trim()}\n />\n \n \n );\n});\n\nSubMenu.displayName = 'uiw.SubMenu';\n","import React, { useMemo } from 'react';\nimport { IProps, HTMLUlProps } from '@uiw/utils';\nimport { MenuItem } from './MenuItem';\nimport { MenuDivider } from './Divider';\nimport { SubMenu } from './SubMenu';\nimport './style/menu.less';\n\nexport interface MenuProps extends IProps, HTMLUlProps {\n /** 主题颜色 */\n theme?: 'light' | 'dark';\n /**\n * 垂直是否收起菜单\n * Default: `false`\n */\n inlineCollapsed?: boolean;\n /**\n * 菜单缩进宽度 Default: `10`\n */\n inlineIndent?: number;\n bordered?: boolean;\n}\n\nconst Menu = React.forwardRef((props, ref) => {\n const {\n prefixCls = 'w-menu',\n className,\n children,\n bordered,\n theme = 'light',\n inlineIndent = 10,\n inlineCollapsed,\n ...htmlProps\n } = props;\n const cls = useMemo(\n () =>\n [\n prefixCls,\n bordered ? 'w-bordered' : null,\n inlineCollapsed ? `${prefixCls}-inline-collapsed` : null,\n theme ? `${prefixCls}-${theme}` : null,\n className,\n ]\n .filter(Boolean)\n .join(' ')\n .trim(),\n [prefixCls, bordered, inlineCollapsed, theme, className],\n );\n\n return (\n \n {React.Children.map(children, (child: React.ReactNode, key) => {\n if (!React.isValidElement(child)) return child;\n const props: { inlineIndent?: number; inlineCollapsed?: boolean } = {};\n // Sub Menu\n if (child.props.children && child.type === (SubMenu as any)) {\n props.inlineIndent = inlineIndent;\n }\n return React.cloneElement(child, Object.assign({ ...props }, child.props, { key: `${key}` }));\n })}\n
\n );\n});\n\nMenu.displayName = 'uiw.Menu';\n\ntype Menu = typeof Menu & {\n Item: typeof MenuItem;\n SubMenu: typeof SubMenu;\n Divider: typeof MenuDivider;\n};\n\n(Menu as Menu).Item = MenuItem;\n(Menu as Menu).SubMenu = SubMenu;\n(Menu as Menu).Divider = MenuDivider;\n\nexport default Menu as Menu;\n","import Menu from './Menu';\n\nexport * from './Menu';\nexport * from './MenuItem';\nexport * from './SubMenu';\nexport * from './Divider';\n\nexport default Menu;\n","import React from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport Icon, { IconProps } from '@uiw/react-icon';\nimport Button from '@uiw/react-button';\nimport './style/index.less';\nimport { IProps, HTMLDivProps } from '@uiw/utils';\n\nexport interface MessageProps extends IProps, Omit {\n title?: React.ReactNode;\n icon?: IconProps['type'];\n type?: 'success' | 'warning' | 'info' | 'error';\n description?: React.ReactNode;\n showIcon?: boolean;\n isCloseButtonShown?: boolean;\n rounded?: boolean;\n onClose?: (e: React.MouseEvent) => void;\n}\n\nexport interface IMessageState {\n isOpen: boolean;\n}\n\nexport default class Message extends React.Component {\n public static defaultProps: MessageProps = {\n prefixCls: 'w-message',\n rounded: true,\n isCloseButtonShown: false,\n };\n constructor(props: MessageProps) {\n super(props);\n this.state = {\n isOpen: true,\n };\n }\n handleClosed = (e: React.MouseEvent) => {\n const { onClose } = this.props;\n this.setState({ isOpen: false });\n onClose && onClose(e);\n };\n renderIcon = () => {\n const { type, showIcon } = this.props;\n let icon = this.props.icon;\n if (!icon && showIcon) {\n switch (type) {\n case 'success':\n icon = 'circle-check';\n break;\n case 'warning':\n icon = 'warning';\n break;\n case 'info':\n icon = 'information';\n break;\n case 'error':\n icon = 'circle-close';\n break;\n default:\n break;\n }\n }\n return icon;\n };\n render() {\n const {\n prefixCls,\n className,\n type,\n title,\n description,\n showIcon,\n icon,\n rounded,\n isCloseButtonShown,\n ...elementProps\n } = this.props;\n const children = description || this.props.children;\n const cls = [\n prefixCls,\n className,\n `${prefixCls}-${type}`,\n rounded ? `${prefixCls}-rounded` : null,\n showIcon ? `${prefixCls}-icon` : null,\n showIcon ? `${prefixCls}${title ? '-title' : ''}${children ? '-description' : ''}` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n const Child = (\n \n {isCloseButtonShown && }\n {showIcon && }\n {title}\n {children}\n
\n );\n if (!isCloseButtonShown) {\n return Child;\n }\n return (\n \n {Child}\n \n );\n }\n}\n","import React, { useEffect, useMemo, useState } from 'react';\nimport Input, { InputProps } from '@uiw/react-input';\nimport Popover, { PopoverProps } from '@uiw/react-popover';\nimport { IProps } from '@uiw/utils';\nimport Button from '@uiw/react-button';\nimport formatter from '@uiw/formatter';\nimport { DatePickerMonth, DatePickerYear, DatePickerCaption, DatePickerCaptionProps } from '@uiw/react-date-picker';\nimport './style/index.less';\n\nexport interface MonthPickerProps extends IProps, Omit {\n popoverProps?: PopoverProps;\n pickerCaptionProps?: DatePickerCaptionProps;\n value?: Date | string;\n format?: string;\n monthLabel?: string[];\n allowClear?: boolean;\n onChange?: (date?: Date, formatDate?: string) => void;\n}\n\nconst MONTH_LABEL = [\n '一月',\n '二月',\n '三月',\n '四月',\n '五月',\n '六月',\n '七月',\n '八月',\n '九月',\n '十月',\n '十一月',\n '十二月',\n];\n\nexport default function MonthPicker(props: MonthPickerProps) {\n const {\n prefixCls = 'w-monthpicker',\n format = 'YYYY/MM',\n onChange = () => {},\n className,\n popoverProps,\n pickerCaptionProps = {},\n allowClear = true,\n monthLabel = MONTH_LABEL,\n ...inputProps\n } = props;\n\n const [isOpen, setIsOpen] = useState(false);\n const [panelDate, setPanelDate] = useState(new Date());\n const [type, setType] = useState('month');\n const [date, setDate] = useState(props.value);\n\n useEffect(() => setDate(props.value), [props.value]);\n\n inputProps.value = useMemo(\n () => (typeof date === 'string' ? date : date ? formatter(format, date) : ''),\n [format, date],\n );\n\n if (allowClear && inputProps.value) {\n inputProps.addonAfter = (\n