dinocollab-core 2.2.49 → 2.2.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/components/index.js +1 -1
  2. package/dist/form/index.js +1 -1
  3. package/dist/src/components/buttons.js.map +1 -1
  4. package/dist/src/components/confirm-button.js +2 -0
  5. package/dist/src/components/confirm-button.js.map +1 -0
  6. package/dist/src/data-surface/view-grid/styleds.js +1 -1
  7. package/dist/src/data-surface/view-grid/styleds.js.map +1 -1
  8. package/dist/src/data-surface/view-list/index.js +1 -1
  9. package/dist/src/data-surface/view-list/index.js.map +1 -1
  10. package/dist/src/data-surface/view-list/styled.js +1 -1
  11. package/dist/src/data-surface/view-list/styled.js.map +1 -1
  12. package/dist/src/filter-bar/menu/create-form-field-string.js +1 -1
  13. package/dist/src/filter-bar/menu/create-form-field-string.js.map +1 -1
  14. package/dist/src/form/create.checkbox.js +2 -0
  15. package/dist/src/form/create.checkbox.js.map +1 -0
  16. package/dist/src/form/create.form-base.js +1 -1
  17. package/dist/src/form/create.form-base.js.map +1 -1
  18. package/dist/src/form/create.form-grid-layout.js +1 -1
  19. package/dist/src/form/create.form-grid-layout.js.map +1 -1
  20. package/dist/src/form/create.input.file.js +1 -1
  21. package/dist/src/form/create.input.file.js.map +1 -1
  22. package/dist/src/form/create.input.js.map +1 -1
  23. package/dist/src/form/create.select-simple.js +1 -1
  24. package/dist/src/form/create.select-simple.js.map +1 -1
  25. package/dist/src/form/create.select-with-api.js +1 -1
  26. package/dist/src/form/create.select-with-api.js.map +1 -1
  27. package/dist/src/form/decorator.form.js +1 -1
  28. package/dist/src/form/decorator.form.js.map +1 -1
  29. package/dist/src/form/decorator.units.js +1 -1
  30. package/dist/src/form/decorator.units.js.map +1 -1
  31. package/dist/src/form/dino-form.js +1 -1
  32. package/dist/src/form/dino-form.js.map +1 -1
  33. package/dist/src/form/error-handler.js +1 -1
  34. package/dist/src/form/error-handler.js.map +1 -1
  35. package/dist/src/form/helpers.js +1 -1
  36. package/dist/src/form/helpers.js.map +1 -1
  37. package/dist/src/form/v2/create.autocomplete.chips.js +2 -0
  38. package/dist/src/form/v2/create.autocomplete.chips.js.map +1 -0
  39. package/dist/src/form/v2/create.color-picker.js +2 -0
  40. package/dist/src/form/v2/create.color-picker.js.map +1 -0
  41. package/dist/src/form/v2/create.date-expired.js +2 -0
  42. package/dist/src/form/v2/create.date-expired.js.map +1 -0
  43. package/dist/src/form/v2/create.date-picker.js +2 -0
  44. package/dist/src/form/v2/create.date-picker.js.map +1 -0
  45. package/dist/src/form/v2/create.input.js +2 -0
  46. package/dist/src/form/v2/create.input.js.map +1 -0
  47. package/dist/src/form/v2/create.select-simple.js +2 -0
  48. package/dist/src/form/v2/create.select-simple.js.map +1 -0
  49. package/dist/src/form/v2/create.select-with-api.js +2 -0
  50. package/dist/src/form/v2/create.select-with-api.js.map +1 -0
  51. package/dist/src/form/validator.js +1 -1
  52. package/dist/src/form/validator.js.map +1 -1
  53. package/dist/types/components/confirm-button.d.ts +30 -0
  54. package/dist/types/components/index.d.ts +1 -0
  55. package/dist/types/filter-bar/menu/create-form-field-string.d.ts +1 -0
  56. package/dist/types/form/create.checkbox.d.ts +41 -0
  57. package/dist/types/form/create.form-base.d.ts +14 -0
  58. package/dist/types/form/create.input.d.ts +1 -0
  59. package/dist/types/form/create.input.file.d.ts +109 -9
  60. package/dist/types/form/create.select-simple.d.ts +1 -1
  61. package/dist/types/form/create.select-with-api.d.ts +3 -3
  62. package/dist/types/form/decorator.form.d.ts +17 -0
  63. package/dist/types/form/dino-form.d.ts +17 -6
  64. package/dist/types/form/helpers.d.ts +4 -4
  65. package/dist/types/form/index.d.ts +12 -0
  66. package/dist/types/form/v2/create.autocomplete.chips.d.ts +45 -0
  67. package/dist/types/form/v2/create.color-picker.d.ts +37 -0
  68. package/dist/types/form/v2/create.date-expired.d.ts +53 -0
  69. package/dist/types/form/v2/create.date-picker.d.ts +43 -0
  70. package/dist/types/form/v2/create.input.d.ts +36 -0
  71. package/dist/types/form/v2/create.select-simple.d.ts +84 -0
  72. package/dist/types/form/v2/create.select-with-api.d.ts +66 -0
  73. package/package.json +1 -1
  74. package/dist/src/form/create.input-file.csv-local-parser.js +0 -2
  75. package/dist/src/form/create.input-file.csv-local-parser.js.map +0 -1
  76. package/dist/src/form/create.input.image-file.js +0 -2
  77. package/dist/src/form/create.input.image-file.js.map +0 -1
  78. package/dist/types/form/create.input-file.csv-local-parser.d.ts +0 -66
  79. package/dist/types/form/create.input.image-file.d.ts +0 -20
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.select-simple.js","sources":["../../../../src/form/v2/create.select-simple.tsx"],"sourcesContent":["import { Component, Fragment } from 'react'\nimport {\n Box,\n BoxProps,\n Collapse,\n FormControl,\n FormHelperText,\n MenuItem,\n PaperProps,\n Select,\n SelectProps,\n Typography,\n TypographyProps,\n alpha,\n styled\n} from '@mui/material'\nimport { mergeObjects } from '../../utils/helpers'\nimport { getErrorMessage } from '../helpers'\nimport { HelpOutlinePulseIcon, RichTooltip } from '../../components/rich-tooltip'\nimport type { ComponentType } from 'react'\nimport type { IFormInputBase } from '../types'\nimport type { IRichTooltipPanelConfig } from '../../components/rich-tooltip'\n\nexport interface ISelectSimpleOption<T = any> {\n /** The value of the option. */\n value: T\n /** Display label for the option. If omitted, value is used as label. */\n label?: string\n}\n\nexport function getOptionDisplayLabel(item: ISelectSimpleOption): string {\n return item.label ?? item.value?.toString() ?? ''\n}\n\nexport interface ISelectSimpleSlots {\n /** MUI Select component props override. */\n selectProps?: Omit<SelectProps, 'variant'>\n /** Automatically select the first option if no value/defaultValue is provided. @default false */\n autoSelectFirst?: boolean\n /** Outer container Box props override. */\n wrapProps?: BoxProps\n}\n\nexport interface ISelectSimpleProps<T> extends Partial<IFormInputBase<T, ISelectSimpleSlots>> {\n /** List of predefined options. */\n options?: ISelectSimpleOption[]\n /** Controlled value. */\n value?: any\n /** Placeholder text shown when no option is selected. @default 'Select [label]' */\n placeholder?: string\n /** Callback fired when an option is selected. */\n onChange?: (value: ISelectSimpleOption) => void\n /** Slots override props. */\n slots?: ISelectSimpleSlots\n /** @default true */\n fullWidth?: boolean\n /** Rich Tooltip configuration. */\n tooltip?: IRichTooltipPanelConfig\n /** Element placed at the end of the input. */\n endAdornment?: React.ReactNode\n}\n\nexport interface ISelectSimpleState {\n value?: string\n}\n\nexport interface ISelectSimpleParams extends ISelectSimpleSlots {\n /** List of predefined options. */\n options?: ISelectSimpleOption[]\n /** Placeholder text shown when no option is selected. @default 'Select [label]' */\n placeholder?: string\n /** Automatically select the first option if no value/defaultValue is provided. @default false */\n autoSelectFirst?: boolean\n /** Rich Tooltip configuration. */\n tooltip?: IRichTooltipPanelConfig\n /** Element placed at the end of the input. */\n endAdornment?: React.ReactNode\n}\n\nexport const selectSimpleClasses = {\n root: 'DinoSelectSimple-root',\n label: 'DinoSelectSimple-label',\n select: 'DinoSelectSimple-select',\n selectHeader: 'DinoSelectSimple-selectHeader',\n placeholder: 'DinoSelectSimple-placeholder',\n tooltipWrap: 'DinoSelectSimple-tooltipWrap',\n small: 'DinoSelectSimple-small',\n tooltip: 'DinoSelectSimple-tooltip',\n endAdornment: 'DinoSelectSimple-endAdornment'\n}\n\n/**\n * Modern Custom Styled Select Simple Creator for DinoForm V2.\n *\n * Synchronized with V2 design aesthetics (Top Label, rounded corners 10px, #cbd5e1 border, placeholder when unselected, styled menu items).\n *\n * @example\n * @formField({\n * type: String,\n * label: 'Language',\n * renderInput: DinoForm.createSelectSimpleV2({\n * options: [\n * { label: 'English', value: 'en' },\n * { label: 'Spanish', value: 'es' }\n * ],\n * placeholder: 'Select a language'\n * })\n * })\n * language?: string\n */\nexport function createSelectSimple<T = any>(args?: ISelectSimpleParams): ComponentType<ISelectSimpleProps<T>> {\n class SelectSimple extends Component<ISelectSimpleProps<T>, ISelectSimpleState> {\n constructor(props: ISelectSimpleProps<T>) {\n super(props)\n this.state = { value: this.getDefaultValue() }\n }\n\n get label(): string {\n if (this.props.label && typeof this.props.label === 'string') return this.props.label\n if (this.props.name) return this.props.name.toString()\n return ''\n }\n\n get placeholderText(): string {\n if (this.props.placeholder) return this.props.placeholder\n if (args?.placeholder) return args.placeholder\n return this.label ? `Select a ${this.label}` : 'Select an option'\n }\n\n shouldComponentUpdate(nextProps: Readonly<ISelectSimpleProps<T>>): boolean {\n const currentDValue = this.getDefaultValue()\n const nextDValue = this.getDefaultValue(nextProps)\n if (currentDValue !== nextDValue && nextDValue !== this.state.value) {\n this.setState({ value: nextDValue })\n return false\n }\n return true\n }\n\n mapProps = (): SelectProps => {\n const options = this.getOptions()\n const currentValue = this.state.value ?? ''\n const errorMessage = getErrorMessage(this.props.messageErrors, this.props.name)\n\n const tfp: SelectProps = {\n id: this.props.name?.toString(),\n name: this.props.name?.toString(),\n value: currentValue,\n error: errorMessage.error,\n displayEmpty: true,\n renderValue: (selected) => {\n if (!selected) {\n return (\n <Typography className={selectSimpleClasses.placeholder} sx={{ color: '#94a3b8', fontSize: '0.875rem' }}>\n {this.placeholderText}\n </Typography>\n )\n }\n const found = options.find((x) => x.value?.toString() === (selected as string))\n return found ? getOptionDisplayLabel(found) : (selected as string)\n },\n onChange: (event) => {\n const value: string = event.target.value + ''\n this.setState({ value }, () => {\n if (!!this.props.name) {\n this.props.onBlur && this.props.onBlur(this.props.name)\n }\n const temp = options.find((x) => x.value?.toString() === value)\n if (!temp) return\n this.props.onChange && this.props.onChange(temp)\n })\n },\n disabled: this.props.disabled,\n fullWidth: this.props.fullWidth !== undefined ? this.props.fullWidth : true,\n endAdornment: this.props.endAdornment ?? args?.endAdornment ?? undefined,\n MenuProps: { PaperProps: { sx: paperSx } }\n }\n const selectProps = this.props.slots?.selectProps ?? args?.selectProps\n return mergeObjects({}, tfp, selectProps)\n }\n\n render() {\n const data = this.getOptions()\n const errorMessage = getErrorMessage(this.props.messageErrors, this.props.name)\n const titleColor = errorMessage.error ? 'error.main' : 'text.primary'\n\n return (\n <Fragment>\n {!!this.props.disabled && <input hidden name={this.props.name?.toString()} defaultValue={this.state.value} />}\n <SelectSimpleStyled className={this.getRootClasses()} {...args?.wrapProps} {...this.props.slots?.wrapProps}>\n {/* Top Label */}\n {this.label && (\n <Typography className={selectSimpleClasses.label} variant='subtitle2' sx={{ fontWeight: 600, mb: 0.5, color: titleColor }}>\n {this.label}\n </Typography>\n )}\n\n <Select className={selectSimpleClasses.select} variant='outlined' {...this.mapProps()}>\n {/* Header Label at top of dropdown menu */}\n {this.placeholderText && <MenuHeaderStyled className={selectSimpleClasses.selectHeader}>{this.placeholderText}</MenuHeaderStyled>}\n\n {data.map((item) => (\n <MenuItem key={item.value?.toString()} value={item.value}>\n {getOptionDisplayLabel(item)}\n </MenuItem>\n ))}\n </Select>\n\n <Collapse in={errorMessage.error} unmountOnExit>\n <FormHelperText error sx={{ mt: 0.5, fontWeight: 500, color: 'error.main' }}>\n {errorMessage.message}\n </FormHelperText>\n </Collapse>\n {this.renderTooltip()}\n </SelectSimpleStyled>\n </Fragment>\n )\n }\n\n renderTooltip = () => {\n const tooltip = this.props.tooltip || args?.tooltip\n if (!tooltip) return null\n return (\n <div className={selectSimpleClasses.tooltipWrap}>\n <RichTooltip panel={tooltip}>\n <HelpOutlinePulseIcon fontSize='small' />\n </RichTooltip>\n </div>\n )\n }\n\n getRootClasses = () => {\n const classes = [selectSimpleClasses.root]\n const tooltip = this.props.tooltip || args?.tooltip\n if (tooltip) classes.push(selectSimpleClasses.tooltip)\n if (this.props.endAdornment || args?.endAdornment) classes.push(selectSimpleClasses.endAdornment)\n const selectPropsSize = this.props.slots?.selectProps?.size ?? args?.selectProps?.size\n if (selectPropsSize === 'small') classes.push(selectSimpleClasses.small)\n return classes.join(' ')\n }\n\n getDefaultValue = (forceProps?: ISelectSimpleProps<T>): string => {\n const currentProps = forceProps ?? this.props\n const { data, name } = currentProps\n const raw = currentProps.defaultValue?.toString() ?? (!!data && !!name ? data[name]?.toString() : undefined)\n if (raw !== undefined && raw !== null && raw !== '') {\n return raw\n }\n const autoSelectFirst = currentProps.slots?.autoSelectFirst ?? args?.autoSelectFirst\n if (autoSelectFirst) {\n const options = this.getOptions()\n return options[0]?.value?.toString() ?? ''\n }\n return ''\n }\n\n getOptions = (): ISelectSimpleOption[] => {\n return args?.options ?? this.props.options ?? []\n }\n }\n return SelectSimple\n}\n\nexport default createSelectSimple\n\n// Styled components\nconst paperSx: PaperProps['sx'] = {\n borderRadius: '12px',\n mt: 0.8,\n boxShadow: 'rgba(0, 0, 0, 0.08) 0px 4px 20px 0px',\n border: '1px solid #e2e8f0',\n padding: '4px',\n '& .MuiMenuItem-root': {\n borderRadius: '8px',\n margin: '2px 4px',\n fontSize: '0.875rem',\n fontWeight: 500,\n color: '#1e293b',\n transition: 'all 0.15s ease-in-out',\n '&:hover': {\n backgroundColor: '#f1f5f9'\n },\n '&.Mui-selected': {\n backgroundColor: '#f3f0ff',\n color: '#6366f1',\n fontWeight: 600,\n '&:hover': {\n backgroundColor: '#e0e7ff'\n }\n }\n }\n}\n\nconst SelectSimpleStyled = styled(Box)(({ theme }) => ({\n position: 'relative',\n [`.${selectSimpleClasses.label}`]: {\n display: 'flex',\n alignItems: 'center',\n marginBottom: theme.spacing(0.5),\n height: 'var(--dino-height-input-label, 21px)'\n },\n '& .MuiOutlinedInput-root': {\n borderRadius: '10px',\n backgroundColor: '#ffffff',\n height: 'var(--dino-min-height-input, 42px)',\n minHeight: 'var(--dino-min-height-input, 42px)',\n boxSizing: 'border-box',\n transition: 'all 0.2s ease-in-out',\n '& fieldset': {\n borderColor: '#cbd5e1',\n borderWidth: '1px'\n },\n '&:hover fieldset': {\n borderColor: '#94a3b8'\n },\n '&.Mui-focused fieldset': {\n borderColor: theme.palette.primary.main,\n borderWidth: '1.5px'\n },\n '&.Mui-error fieldset': {\n borderColor: theme.palette.error.main\n }\n },\n '.MuiSelect-select': {\n padding: theme.spacing(0, 1.5),\n height: '100%',\n minHeight: 'var(--dino-min-height-input, 42px)',\n boxSizing: 'border-box',\n fontSize: '0.875rem',\n color: theme.palette.text.primary,\n display: 'flex',\n alignItems: 'center'\n },\n [`.${selectSimpleClasses.tooltipWrap}`]: {\n position: 'absolute',\n top: theme.spacing(4.2),\n right: theme.spacing(1.5),\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(0.5)\n }\n}))\n\nconst MenuHeaderStyled = styled((p: TypographyProps) => <Typography component='div' {...p} />)(({ theme }) => ({\n pointerEvents: 'none',\n cursor: 'default',\n userSelect: 'none',\n color: alpha(theme.palette.text.secondary, 0.3),\n fontWeight: 600,\n fontSize: '0.8125rem',\n padding: theme.spacing(1, 2),\n marginTop: theme.spacing(-1)\n}))\n"],"names":["getOptionDisplayLabel","item","_ref","_item$label","_item$value","label","value","toString","selectSimpleClasses","root","select","selectHeader","placeholder","tooltipWrap","small","tooltip","endAdornment","createSelectSimple","args","SelectSimple","props","_this","_classCallCheck","_callSuper","_defineProperty","_this$state$value","_this$props$name","_this$props$name2","_ref2","_this$props$endAdornm","_this$props$slots$sel","_this$props$slots","options","getOptions","currentValue","state","errorMessage","getErrorMessage","messageErrors","name","tfp","id","error","displayEmpty","renderValue","selected","_jsx","Typography","className","sx","color","fontSize","children","placeholderText","found","find","x","_x$value","onChange","event","target","setState","onBlur","temp","_x$value2","disabled","fullWidth","undefined","MenuProps","PaperProps","paperSx","selectProps","slots","mergeObjects","RichTooltip","panel","HelpOutlinePulseIcon","_this$props$slots$sel2","_this$props$slots2","_args$selectProps","classes","push","size","join","forceProps","_currentProps$default","_currentProps$default2","_data$name","_currentProps$slots$a","_currentProps$slots","_options$0$value$toSt","_options$","currentProps","data","raw","defaultValue","autoSelectFirst","_ref3","_args$options","getDefaultValue","_inherits","Component","_createClass","key","get","this","concat","nextProps","currentDValue","nextDValue","_this$props$name3","_this$props$slots3","titleColor","_jsxs","Fragment","hidden","SelectSimpleStyled","_objectSpread","getRootClasses","wrapProps","variant","fontWeight","mb","Select","mapProps","MenuHeaderStyled","map","_item$value2","MenuItem","Collapse","in","unmountOnExit","FormHelperText","mt","message","renderTooltip","borderRadius","boxShadow","border","padding","margin","transition","backgroundColor","styled","Box","_ref4","theme","position","display","alignItems","marginBottom","spacing","height","minHeight","boxSizing","borderColor","borderWidth","palette","primary","main","text","top","right","gap","p","component","_ref6","pointerEvents","cursor","userSelect","alpha","secondary","marginTop"],"mappings":"6kBA8BM,SAAUA,EAAsBC,GAAyB,IAAAC,EAAAC,EAAAC,EAC7D,OAA2CF,QAA3CA,EAAiB,QAAjBC,EAAOF,EAAKI,aAAK,IAAAF,EAAAA,EAAcC,QAAdA,EAAIH,EAAKK,aAALF,IAAUA,OAAVA,EAAAA,EAAYG,kBAAUL,IAAAA,EAAAA,EAAI,EACjD,CA+CO,IAAMM,EAAsB,CACjCC,KAAM,wBACNJ,MAAO,yBACPK,OAAQ,0BACRC,aAAc,gCACdC,YAAa,+BACbC,YAAa,+BACbC,MAAO,yBACPC,QAAS,2BACTC,aAAc,iCAsBV,SAAUC,EAA4BC,GAsJ1C,kBApJE,SAAAC,EAAYC,GAA4B,IAAAC,EAEQ,OAFRC,OAAAH,GACtCE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAAA,WA0BH,WAAkB,IAAAI,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EACrBC,EAAUX,EAAKY,aACfC,EAA+BT,QAAnBA,EAAGJ,EAAKc,MAAM7B,aAAKmB,IAAAA,EAAAA,EAAI,GACnCW,EAAeC,EAAgBhB,EAAKD,MAAMkB,cAAejB,EAAKD,MAAMmB,MAEpEC,EAAmB,CACvBC,GAAmB,QAAjBf,EAAEL,EAAKD,MAAMmB,YAAXb,IAAeA,OAAfA,EAAAA,EAAiBnB,WACrBgC,KAAqB,QAAjBZ,EAAEN,EAAKD,MAAMmB,YAAXZ,IAAeA,OAAfA,EAAAA,EAAiBpB,WACvBD,MAAO4B,EACPQ,MAAON,EAAaM,MACpBC,cAAc,EACdC,YAAa,SAACC,GACZ,IAAKA,EAC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kB,EAAO,SAACqB,GAAkB,OAAKtH,EAACC,EAAUsE,EAAA,CAACgD,UAAU,OAAUD,GAAK,EAApErB,CAAsE,SAAAuB,GAAA,IAAGpB,EAAKoB,EAALpB,MAAK,MAAQ,CAC7GqB,cAAe,OACfC,OAAQ,UACRC,WAAY,OACZvH,MAAOwH,EAAMxB,EAAMW,QAAQG,KAAKW,UAAW,IAC3ClD,WAAY,IACZtE,SAAU,YACVwF,QAASO,EAAMK,QAAQ,EAAG,GAC1BqB,UAAW1B,EAAMK,SAAU,GAC5B"}
@@ -0,0 +1,2 @@
1
+ import{defineProperty as t,inherits as e,createClass as o,objectSpread2 as r,classCallCheck as n,callSuper as i,objectWithoutProperties as l,asyncToGenerator as a,regenerator as s}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as u,jsx as p}from"react/jsx-runtime";import{Component as d}from"react";import{styled as c,Box as f,Paper as h,TextField as v,Typography as m,Autocomplete as g,Collapse as b,FormHelperText as x}from"@mui/material";import{getErrorMessage as S}from"../helpers.js";import{RichTooltip as C,HelpOutlinePulseIcon as y}from"../../components/rich-tooltip.js";import{ApiAlertContext as I}from"../../api-context/alert-global.js";var O=["key"],W={root:"DinoSelectWithApi-root",label:"DinoSelectWithApi-label",input:"DinoSelectWithApi-input",error:"DinoSelectWithApi-error",tooltip:"DinoSelectWithApi-tooltip",tooltipWrap:"DinoSelectWithApi-tooltipWrap"};function k(c){var f=function(){function f(e){var o,u,d;return n(this,f),u=i(this,f,[e]),t(u,"abortController",{signalController:new AbortController}),t(u,"refInput",null),t(u,"existedIds",[]),t(u,"renderTooltip",function(){var t=u.props.tooltip||(null==c?void 0:c.tooltip);return t?p("div",{className:W.tooltipWrap,children:p(C,{panel:t,children:p(y,{fontSize:"small"})})}):null}),t(u,"getRootClasses",function(){var t=[W.root];return(u.props.tooltip||(null==c?void 0:c.tooltip))&&t.push(W.tooltip),t.join(" ")}),t(u,"getFetchDataFunc",function(){var t,e;return null!==(t=null!==(e=u.props.fetchData)&&void 0!==e?e:null==c?void 0:c.fetchData)&&void 0!==t?t:function(){return Promise.resolve([])}}),t(u,"getWrappedRenderOption",function(){var t,e,o=null!==(t=null===(e=u.props.slots)||void 0===e?void 0:e.renderOption)&&void 0!==t?t:null==c?void 0:c.renderOption;if(o)return function(t,e,n){var i=t.key,a=l(t,O);return p("li",r(r({},a),{},{style:r({width:"100%",boxSizing:"border-box"},a.style),children:o(a,e,n)}),i)}}),t(u,"timer",{_timer:0,_second:500,callback:(d=a(s().m(function t(e){var o,r,n;return s().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,u.abortController.signalController=new AbortController,t.n=1,u.getFetchDataFunc()(e,u.abortController.signalController.signal);case 1:o=t.v,r=u.getOptionsFilter(o,u.existedIds),u.setState({options:r}),t.n=3;break;case 2:t.p=2,t.v,null===(n=I.ApiAlert)||void 0===n||n.PushError("Error from server!");case 3:return t.p=3,u.setState({statusText:"no items"}),t.f(3);case 4:return t.a(2)}},t,null,[[0,2,3,4]])})),function(t){return d.apply(this,arguments)}),start:function(t){u.timer.clear(),u.timer._timer=window.setTimeout(function(){return u.timer.callback(t)},u.timer._second)},clear:function(){u.abortController.signalController.abort(),clearTimeout(u.timer._timer)}}),t(u,"fetchData",a(s().m(function t(){var e,o,r,n,i,l;return s().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,o=u.getDefaultValue(),t.n=1,u.getFetchDataFunc()(o,u.abortController.signalController.signal);case 1:if(r=t.v,Array.isArray(r)){t.n=2;break}return t.a(2);case 2:return n=u.getOptionsFilter(r,u.existedIds),i=null!==(e=n.find(function(t){return t.value===o}))&&void 0!==e?e:null,u.setState({options:n,optionSelected:i,loading:!1}),t.a(2);case 3:t.p=3,t.v,null===(l=I.ApiAlert)||void 0===l||l.PushError("Error from server!");case 4:return t.p=4,u.setState({statusText:"no items",loading:!1}),t.f(4);case 5:return t.a(2)}},t,null,[[0,3,4,5]])}))),t(u,"handleChange",function(t,e){var o;u.setState({optionSelected:e}),u.refInput&&(u.refInput.value=null!==(o=null==e?void 0:e.value)&&void 0!==o?o:""),u.props.onChange&&u.props.onChange(e)}),t(u,"handleInputChange",function(t,e){var o,r={inputValue:e};if(e!==(null===(o=u.state.optionSelected)||void 0===o?void 0:o.label)){var n=e.trim().toLowerCase(),i=u.state.options.findIndex(function(t){var e;return null===(e=t.label)||void 0===e?void 0:e.trim().toLowerCase().includes(n)});(i<0||""===n)&&(r.statusText="loading..."),u.setState(r,function(){(i<0||""===n)&&u.timer.start(n)})}else u.setState(r)}),t(u,"fillterOptions",function(t,e){return t.filter(function(t){var o,r=e.inputValue.toLowerCase();return t.value.toLowerCase().includes(r)||(null===(o=t.label)||void 0===o?void 0:o.toLowerCase().includes(r))})}),t(u,"getDefaultValue",function(){var t,e,o;if(u.props.name)return null===(t=null!==(e=u.props.defaultValue)&&void 0!==e?e:null===(o=u.props.data)||void 0===o?void 0:o[u.props.name])||void 0===t?void 0:t.toString()}),t(u,"clear",function(){u.setState({optionSelected:null,inputValue:""}),u.refInput&&(u.refInput.value="")}),u.state={options:[],statusText:"no items",optionSelected:null,inputValue:"",loading:!0},u.existedIds=null!==(o=e.existedIds)&&void 0!==o?o:[],u}return e(f,d),o(f,[{key:"label",get:function(){return this.props.label&&"string"==typeof this.props.label?this.props.label:this.props.name?this.props.name.toString():""}},{key:"componentDidMount",value:function(){this.fetchData()}},{key:"componentWillUnmount",value:function(){this.timer.clear()}},{key:"componentDidUpdate",value:function(t){var e;JSON.stringify(t.existedIds)!==JSON.stringify(this.props.existedIds)&&(this.existedIds=null!==(e=this.props.existedIds)&&void 0!==e?e:[])}},{key:"render",value:function(){var t,e,o,n,i,l,a,s,d=this,f=this.getDefaultValue(),h=S(this.props.messageErrors,this.props.name),v=h.error?"error.main":"text.primary",C=this.getWrappedRenderOption(),y=null!==(t=null!==(e=this.props.placeholder)&&void 0!==e?e:null==c?void 0:c.placeholder)&&void 0!==t?t:this.label?"Select ".concat(this.label):"Search option...";return u(w,r(r(r({className:this.getRootClasses()},null==c||null===(o=c.slots)||void 0===o?void 0:o.wrapProps),null===(n=this.props.slots)||void 0===n?void 0:n.wrapProps),{},{children:[this.label&&p(m,{className:W.label,variant:"subtitle2",sx:{fontWeight:600,mb:.5,color:v},children:this.label}),p(g,{disabled:this.state.loading||this.props.disabled,fullWidth:!0,noOptionsText:this.state.statusText,options:this.state.options,getOptionLabel:function(t){var e;return null!==(e=t.label)&&void 0!==e?e:t.value},getOptionKey:function(t){return JSON.stringify(t)},isOptionEqualToValue:function(t,e){return t.value.toString()===e.value.toString()&&t.label===e.label},filterOptions:this.fillterOptions,renderOption:C,value:this.state.optionSelected,onChange:this.handleChange,inputValue:this.state.inputValue,onInputChange:this.handleInputChange,PaperComponent:function(t){return p(D,r({},t))},renderInput:function(t){var e,o=null===(e=d.props.slots)||void 0===e?void 0:e.textFieldProps,n=[W.input,null==o?void 0:o.className].filter(Boolean).join(" ");return p(A,r(r(r({},t),o),{},{placeholder:y,className:n,error:h.error,variant:"outlined",onBlur:function(){d.props.name&&d.props.onBlur&&d.props.onBlur(d.props.name)}}))}}),p(b,{in:h.error,unmountOnExit:!0,children:p(x,{error:!0,sx:{mt:.5,fontWeight:500,color:"error.main"},children:h.message})}),p("input",{ref:function(t){return d.refInput=t},hidden:!0,name:null===(i=this.props.name)||void 0===i?void 0:i.toString(),defaultValue:f}),(null===(l=this.state.optionSelected)||void 0===l?void 0:l.other)&&p("input",{hidden:!0,name:"".concat(null===(a=this.props.name)||void 0===a?void 0:a.toString(),"Other"),defaultValue:JSON.stringify(this.state.optionSelected.other)},null!==(s=this.state.optionSelected.value)&&void 0!==s?s:"key"),this.renderTooltip()]}))}},{key:"getOptionsFilter",value:function(t){var e=new Set(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]);return t.reduce(function(t,o){return e.has(o.value)||(t.push(o),e.add(o.value)),t},[])}}])}();return f}var w=c(f)(function(e){var o=e.theme;return t(t(t({position:"relative"},".".concat(W.label),{display:"flex",alignItems:"center",marginBottom:o.spacing(.5),height:"var(--dino-height-input-label, 21px)"}),".".concat(W.tooltipWrap),{position:"absolute",top:o.spacing(4.2),right:o.spacing(1.5),display:"flex",alignItems:"center",gap:o.spacing(.5)}),"&.".concat(W.tooltip),{"& .MuiInputBase-root .MuiAutocomplete-endAdornment":{right:o.spacing(4.5)}})}),D=c(h)(function(t){return t.theme,{borderRadius:"12px",marginTop:"6px",boxShadow:"rgba(0, 0, 0, 0.08) 0px 4px 20px 0px",border:"1px solid #e2e8f0",backgroundColor:"#ffffff",padding:"4px","& .MuiAutocomplete-option":{borderRadius:"8px",margin:"2px 4px",fontSize:"0.875rem",fontWeight:500,color:"#1e293b",transition:"all 0.15s ease-in-out","&:hover":{backgroundColor:"#f1f5f9"},'&[aria-selected="true"]':{backgroundColor:"#f3f0ff",color:"#6366f1",fontWeight:600,"&:hover":{backgroundColor:"#e0e7ff"}}}}}),A=c(v)(function(t){var e=t.theme;return{"& .MuiOutlinedInput-root":{borderRadius:"10px",backgroundColor:"#ffffff",height:"var(--dino-min-height-input, 42px)",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",paddingTop:"0 !important",paddingBottom:"0 !important",paddingLeft:e.spacing(1.5),paddingRight:e.spacing(1.5),transition:"all 0.2s ease-in-out","& fieldset":{borderColor:"#cbd5e1",borderWidth:"1px"},"&:hover fieldset":{borderColor:"#94a3b8"},"&.Mui-focused fieldset":{borderColor:e.palette.primary.main,borderWidth:"1.5px"},"&.Mui-error fieldset":{borderColor:e.palette.error.main}},"& .MuiOutlinedInput-input":{padding:"0 !important",height:"100%",boxSizing:"border-box",fontSize:"0.875rem",color:e.palette.text.primary,"&::placeholder":{color:"#94a3b8",opacity:1}}}});export{k as createSelectWithApi,k as default,W as selectWithApiClasses};
2
+ //# sourceMappingURL=create.select-with-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.select-with-api.js","sources":["../../../../src/form/v2/create.select-with-api.tsx"],"sourcesContent":["import React, { Component, ComponentType } from 'react'\nimport { Autocomplete, Box, BoxProps, Collapse, FormHelperText, Paper, styled, TextField, TextFieldProps, Typography } from '@mui/material'\nimport { IFormInputBase } from '../types'\nimport { getErrorMessage } from '../helpers'\nimport { ApiAlertContext } from '../../api-context'\nimport { RichTooltip, HelpOutlinePulseIcon } from '../../components/rich-tooltip'\nimport type { FilterOptionsState, AutocompleteRenderOptionState } from '@mui/material'\nimport type { IRichTooltipPanelConfig } from '../../components/rich-tooltip'\n\nexport interface ISelectWithApiOption<TOther = any> {\n value: string\n label?: string\n other?: TOther\n}\n\nexport interface ISelectWithApiPropsSlots<O extends ISelectWithApiOption = ISelectWithApiOption> {\n textFieldProps?: TextFieldProps\n wrapProps?: BoxProps\n renderOption?: (props: React.HTMLAttributes<HTMLElement>, option: O, state: AutocompleteRenderOptionState) => React.ReactNode\n}\n\nexport type ISelectWithApiFetchData<O extends ISelectWithApiOption> = (value?: string, signal?: AbortSignal) => Promise<O[]>\n\nexport interface ISelectWithApiProps<T, O extends ISelectWithApiOption = ISelectWithApiOption>\n extends IFormInputBase<T, ISelectWithApiPropsSlots<O>>, ISelectWithApiParams<O> {\n placeholder?: string\n tooltip?: IRichTooltipPanelConfig\n onChange?: (value: O | null) => void\n existedIds?: string[]\n slots?: ISelectWithApiPropsSlots<O>\n}\n\nexport interface ISelectWithApiState<O extends ISelectWithApiOption> {\n options: O[]\n statusText?: string\n optionSelected: O | null\n inputValue: string\n loading?: boolean\n}\n\nexport interface ISelectWithApiParams<O extends ISelectWithApiOption = ISelectWithApiOption> {\n placeholder?: string\n fetchData?: ISelectWithApiFetchData<O>\n tooltip?: IRichTooltipPanelConfig\n renderOption?: (props: React.HTMLAttributes<HTMLElement>, option: O, state: AutocompleteRenderOptionState) => React.ReactNode\n slots?: ISelectWithApiPropsSlots<O>\n}\n\nexport interface ISelectWithApiHandle {\n clear: () => void\n}\n\nexport const selectWithApiClasses = {\n root: 'DinoSelectWithApi-root',\n label: 'DinoSelectWithApi-label',\n input: 'DinoSelectWithApi-input',\n error: 'DinoSelectWithApi-error',\n tooltip: 'DinoSelectWithApi-tooltip',\n tooltipWrap: 'DinoSelectWithApi-tooltipWrap'\n}\n\n/**\n * Modern Custom Styled Select With API Creator for DinoForm V2.\n *\n * Synchronized with V2 design aesthetics (Top Label, rounded corners 10px, #cbd5e1 border, styled dropdown paper & items).\n *\n * @example\n * @formField({\n * type: String,\n * label: 'Assignee',\n * renderInput: DinoForm.createSelectWithApiV2({\n * placeholder: 'Search assignee...',\n * fetchData: async (search) => fetchUsers(search)\n * })\n * })\n * assigneeId?: string\n */\nexport function createSelectWithApi<T = any, O extends ISelectWithApiOption = ISelectWithApiOption>(\n params?: ISelectWithApiParams<O>\n): ComponentType<ISelectWithApiProps<T, O>> {\n class SelectWithApi extends Component<ISelectWithApiProps<T, O>, ISelectWithApiState<O>> implements ISelectWithApiHandle {\n abortController = { signalController: new AbortController() }\n refInput: HTMLInputElement | null = null\n existedIds: string[] = []\n\n constructor(props: ISelectWithApiProps<T, O>) {\n super(props)\n this.state = {\n options: [],\n statusText: 'no items',\n optionSelected: null,\n inputValue: '',\n loading: true\n }\n this.existedIds = props.existedIds ?? []\n }\n\n get label(): string {\n if (this.props.label && typeof this.props.label === 'string') return this.props.label\n if (this.props.name) return this.props.name.toString()\n return ''\n }\n\n componentDidMount() {\n this.fetchData()\n }\n\n componentWillUnmount(): void {\n this.timer.clear()\n }\n\n componentDidUpdate(prevProps: Readonly<ISelectWithApiProps<T, O>>): void {\n if (JSON.stringify(prevProps.existedIds) !== JSON.stringify(this.props.existedIds)) {\n this.existedIds = this.props.existedIds ?? []\n }\n }\n\n render() {\n const defaultValue = this.getDefaultValue()\n const eMessage = getErrorMessage(this.props.messageErrors, this.props.name)\n const titleColor = eMessage.error ? 'error.main' : 'text.primary'\n const renderOption = this.getWrappedRenderOption()\n const placeholder = this.props.placeholder ?? params?.placeholder ?? (this.label ? `Select ${this.label}` : 'Search option...')\n\n return (\n <SelectWithApiStyled className={this.getRootClasses()} {...params?.slots?.wrapProps} {...this.props.slots?.wrapProps}>\n {/* Top Label */}\n {this.label && (\n <Typography className={selectWithApiClasses.label} variant='subtitle2' sx={{ fontWeight: 600, mb: 0.5, color: titleColor }}>\n {this.label}\n </Typography>\n )}\n\n <Autocomplete\n disabled={this.state.loading || this.props.disabled}\n fullWidth\n noOptionsText={this.state.statusText}\n options={this.state.options}\n getOptionLabel={(x) => x.label ?? x.value}\n getOptionKey={(x) => JSON.stringify(x)}\n isOptionEqualToValue={(o, v) => o.value.toString() === v.value.toString() && o.label === v.label}\n filterOptions={this.fillterOptions}\n renderOption={renderOption}\n value={this.state.optionSelected}\n onChange={this.handleChange}\n inputValue={this.state.inputValue}\n onInputChange={this.handleInputChange}\n PaperComponent={(paperProps) => <PaperStyled {...paperProps} />}\n renderInput={(inputParams) => {\n const tfProps = this.props.slots?.textFieldProps\n const combinedClassName = [selectWithApiClasses.input, tfProps?.className].filter(Boolean).join(' ')\n return (\n <StyledTextField\n {...inputParams}\n {...tfProps}\n placeholder={placeholder}\n className={combinedClassName}\n error={eMessage.error}\n variant='outlined'\n onBlur={() => {\n if (!this.props.name) return\n this.props.onBlur && this.props.onBlur(this.props.name)\n }}\n />\n )\n }}\n />\n\n <Collapse in={eMessage.error} unmountOnExit>\n <FormHelperText error sx={{ mt: 0.5, fontWeight: 500, color: 'error.main' }}>\n {eMessage.message}\n </FormHelperText>\n </Collapse>\n\n <input ref={(ref) => (this.refInput = ref)} hidden name={this.props.name?.toString()} defaultValue={defaultValue} />\n {this.state.optionSelected?.other && (\n <input\n hidden\n name={`${this.props.name?.toString()}Other`}\n key={this.state.optionSelected.value ?? 'key'}\n defaultValue={JSON.stringify(this.state.optionSelected.other)}\n />\n )}\n {this.renderTooltip()}\n </SelectWithApiStyled>\n )\n }\n\n renderTooltip = () => {\n const tooltip = this.props.tooltip || params?.tooltip\n if (!tooltip) return null\n return (\n <div className={selectWithApiClasses.tooltipWrap}>\n <RichTooltip panel={tooltip}>\n <HelpOutlinePulseIcon fontSize='small' />\n </RichTooltip>\n </div>\n )\n }\n\n getRootClasses = () => {\n const classes = [selectWithApiClasses.root]\n const tooltip = this.props.tooltip || params?.tooltip\n if (tooltip) classes.push(selectWithApiClasses.tooltip)\n return classes.join(' ')\n }\n\n getFetchDataFunc = (): ISelectWithApiFetchData<O> => {\n return this.props.fetchData ?? params?.fetchData ?? (() => Promise.resolve([]))\n }\n\n getWrappedRenderOption = () => {\n const userRenderOption = this.props.slots?.renderOption ?? params?.renderOption\n if (!userRenderOption) return undefined\n\n return (props: any, option: O, state: AutocompleteRenderOptionState) => {\n const { key, ...propsWithoutKey } = props\n return (\n <li key={key} {...(propsWithoutKey as any)} style={{ width: '100%', boxSizing: 'border-box', ...propsWithoutKey.style }}>\n {userRenderOption(propsWithoutKey as React.HTMLAttributes<HTMLElement>, option, state)}\n </li>\n )\n }\n }\n\n timer = {\n _timer: 0,\n _second: 500,\n callback: async (value: string) => {\n try {\n this.abortController.signalController = new AbortController()\n const res = await this.getFetchDataFunc()(value, this.abortController.signalController.signal)\n const options = this.getOptionsFilter(res, this.existedIds)\n this.setState({ options })\n } catch (error) {\n ApiAlertContext.ApiAlert?.PushError('Error from server!')\n } finally {\n this.setState({ statusText: 'no items' })\n }\n },\n start: (text: string) => {\n this.timer.clear()\n this.timer._timer = window.setTimeout(() => this.timer.callback(text), this.timer._second)\n },\n clear: () => {\n this.abortController.signalController.abort()\n clearTimeout(this.timer._timer)\n }\n }\n\n fetchData = async () => {\n try {\n const defaultValue = this.getDefaultValue()\n const res = await this.getFetchDataFunc()(defaultValue, this.abortController.signalController.signal)\n if (!Array.isArray(res)) return\n const options = this.getOptionsFilter(res, this.existedIds)\n const optionSelected = options.find((x) => x.value === defaultValue) ?? null\n this.setState({ options, optionSelected, loading: false })\n return\n } catch (error) {\n ApiAlertContext.ApiAlert?.PushError('Error from server!')\n } finally {\n this.setState({ statusText: 'no items', loading: false })\n }\n }\n\n handleChange = (_: React.SyntheticEvent, value: O | null) => {\n this.setState({ optionSelected: value })\n if (this.refInput) this.refInput.value = value?.value ?? ''\n this.props.onChange && this.props.onChange(value)\n }\n\n handleInputChange = (_: React.SyntheticEvent, value: string) => {\n const state: Pick<ISelectWithApiState<O>, 'inputValue' | 'statusText' | 'loading'> = { inputValue: value }\n if (value === this.state.optionSelected?.label) {\n this.setState(state)\n return\n }\n const valueFormated = value.trim().toLowerCase()\n const selectedIndex = this.state.options.findIndex((x) => {\n return x.label?.trim().toLowerCase().includes(valueFormated)\n })\n if (selectedIndex < 0 || valueFormated === '') state.statusText = 'loading...'\n this.setState(state, () => {\n if (selectedIndex < 0 || valueFormated === '') this.timer.start(valueFormated)\n })\n }\n\n fillterOptions = (options: O[], state: FilterOptionsState<O>) => {\n return options.filter((x) => {\n const value = state.inputValue.toLowerCase()\n return x.value.toLowerCase().includes(value) || x.label?.toLowerCase().includes(value)\n })\n }\n\n getDefaultValue = () => {\n if (!this.props.name) return\n return (this.props.defaultValue ?? this.props.data?.[this.props.name])?.toString()\n }\n\n getOptionsFilter<O extends ISelectWithApiOption = ISelectWithApiOption>(options: O[], existedId: string[] = []): O[] {\n const ids = new Set<string | number>(existedId)\n return options.reduce<O[]>((a, b) => {\n if (!ids.has(b.value)) {\n a.push(b)\n ids.add(b.value)\n }\n return a\n }, [])\n }\n\n clear = () => {\n this.setState({ optionSelected: null, inputValue: '' })\n if (this.refInput) this.refInput.value = ''\n }\n }\n\n return SelectWithApi\n}\n\nexport default createSelectWithApi\n\n// Styled components\nconst SelectWithApiStyled = styled(Box)(({ theme }) => ({\n position: 'relative',\n [`.${selectWithApiClasses.label}`]: {\n display: 'flex',\n alignItems: 'center',\n marginBottom: theme.spacing(0.5),\n height: 'var(--dino-height-input-label, 21px)'\n },\n [`.${selectWithApiClasses.tooltipWrap}`]: {\n position: 'absolute',\n top: theme.spacing(4.2),\n right: theme.spacing(1.5),\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(0.5)\n },\n [`&.${selectWithApiClasses.tooltip}`]: {\n '& .MuiInputBase-root .MuiAutocomplete-endAdornment': {\n right: theme.spacing(4.5)\n }\n }\n}))\n\nconst PaperStyled = styled(Paper)(({ theme }) => ({\n borderRadius: '12px',\n marginTop: '6px',\n boxShadow: 'rgba(0, 0, 0, 0.08) 0px 4px 20px 0px',\n border: '1px solid #e2e8f0',\n backgroundColor: '#ffffff',\n padding: '4px',\n '& .MuiAutocomplete-option': {\n borderRadius: '8px',\n margin: '2px 4px',\n fontSize: '0.875rem',\n fontWeight: 500,\n color: '#1e293b',\n transition: 'all 0.15s ease-in-out',\n '&:hover': {\n backgroundColor: '#f1f5f9'\n },\n '&[aria-selected=\"true\"]': {\n backgroundColor: '#f3f0ff',\n color: '#6366f1',\n fontWeight: 600,\n '&:hover': {\n backgroundColor: '#e0e7ff'\n }\n }\n }\n}))\n\nconst StyledTextField = styled(TextField)(({ theme }) => ({\n '& .MuiOutlinedInput-root': {\n borderRadius: '10px',\n backgroundColor: '#ffffff',\n height: 'var(--dino-min-height-input, 42px)',\n minHeight: 'var(--dino-min-height-input, 42px)',\n boxSizing: 'border-box',\n paddingTop: '0 !important',\n paddingBottom: '0 !important',\n paddingLeft: theme.spacing(1.5),\n paddingRight: theme.spacing(1.5),\n transition: 'all 0.2s ease-in-out',\n '& fieldset': {\n borderColor: '#cbd5e1',\n borderWidth: '1px'\n },\n '&:hover fieldset': {\n borderColor: '#94a3b8'\n },\n '&.Mui-focused fieldset': {\n borderColor: theme.palette.primary.main,\n borderWidth: '1.5px'\n },\n '&.Mui-error fieldset': {\n borderColor: theme.palette.error.main\n }\n },\n '& .MuiOutlinedInput-input': {\n padding: '0 !important',\n height: '100%',\n boxSizing: 'border-box',\n fontSize: '0.875rem',\n color: theme.palette.text.primary,\n '&::placeholder': {\n color: '#94a3b8',\n opacity: 1\n }\n }\n}))\n"],"names":["selectWithApiClasses","root","label","input","error","tooltip","tooltipWrap","createSelectWithApi","params","SelectWithApi","props","_props$existedIds","_this","_callback","_classCallCheck","_callSuper","_defineProperty","signalController","AbortController","_jsx","className","children","RichTooltip","panel","HelpOutlinePulseIcon","fontSize","classes","push","join","_ref","_this$props$fetchData","fetchData","Promise","resolve","_this$props$slots$ren","_this$props$slots","userRenderOption","slots","renderOption","option","state","key","propsWithoutKey","_objectWithoutProperties","_excluded","_objectSpread","style","width","boxSizing","_timer","_second","callback","_asyncToGenerator","_regenerator","m","_callee","value","res","options","_ApiAlertContext$ApiA","w","_context","p","n","abortController","getFetchDataFunc","signal","v","getOptionsFilter","existedIds","setState","ApiAlertContext","ApiAlert","PushError","statusText","f","a","_x","apply","this","arguments","start","text","timer","clear","window","setTimeout","abort","clearTimeout","_callee2","_options$find","defaultValue","optionSelected","_ApiAlertContext$ApiA2","_context2","getDefaultValue","Array","isArray","find","x","loading","_","_value$value","refInput","onChange","_this$state$optionSel","inputValue","valueFormated","trim","toLowerCase","selectedIndex","findIndex","_x$label","includes","filter","_x$label2","_ref3","_this$props$defaultVa","_this$props$data","name","data","toString","_inherits","Component","_createClass","get","prevProps","_this$props$existedId","JSON","stringify","_ref4","_this$props$placehold","_params$slots","_this$props$slots2","_this$props$name","_this$state$optionSel2","_this$props$name2","_this$state$optionSel3","_this2","eMessage","getErrorMessage","messageErrors","titleColor","getWrappedRenderOption","placeholder","concat","_jsxs","SelectWithApiStyled","getRootClasses","wrapProps","Typography","variant","sx","fontWeight","mb","color","Autocomplete","disabled","fullWidth","noOptionsText","getOptionLabel","_x$label3","getOptionKey","isOptionEqualToValue","o","filterOptions","fillterOptions","handleChange","onInputChange","handleInputChange","PaperComponent","paperProps","PaperStyled","renderInput","inputParams","_this2$props$slots","tfProps","textFieldProps","combinedClassName","Boolean","StyledTextField","onBlur","Collapse","in","unmountOnExit","FormHelperText","mt","message","ref","hidden","other","renderTooltip","ids","Set","length","undefined","reduce","b","has","add","styled","Box","_ref6","theme","position","display","alignItems","marginBottom","spacing","height","top","right","gap","Paper","_ref8","borderRadius","marginTop","boxShadow","border","backgroundColor","padding","margin","transition","TextField","_ref9","min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AAiB,UACjBC,QAAS,MACT,4BAA6B,CAC3BL,aAAc,MACdM,OAAQ,UACRpM,SAAU,WACVgI,WAAY,IACZE,MAAO,UACPmE,WAAY,wBACZ,UAAW,CACTH,gBAAiB,WAEnB,0BAA2B,CACzBA,gBAAiB,UACjBhE,MAAO,UACPF,WAAY,IACZ,UAAW,CACTkE,gBAAiB,aAIxB,GAEKvC,EAAkBoB,EAAOuB,EAAPvB,CAAkB,SAAAwB,GAAA,IAAGrB,EAAKqB,EAALrB,MAAK,MAAQ,CACxD,2BAA4B,CAC1BY,aAAc,OACdI,gBAAiB,UACjBV,OAAQ,qCACRgB,UAAW,qCACXjL,UAAW,aACXkL,WAAY,eACZC,cAAe,eACfC,YAAazB,EAAMK,QAAQ,KAC3BqB,aAAc1B,EAAMK,QAAQ,KAC5Bc,WAAY,uBACZ,aAAc,CACZQ,YAAa,UACbC,YAAa,OAEf,mBAAoB,CAClBD,YAAa,WAEf,yBAA0B,CACxBA,YAAa3B,EAAM6B,QAAQC,QAAQC,KACnCH,YAAa,SAEf,uBAAwB,CACtBD,YAAa3B,EAAM6B,QAAQpO,MAAMsO,OAGrC,4BAA6B,CAC3Bd,QAAS,eACTX,OAAQ,OACRjK,UAAW,aACXvB,SAAU,WACVkI,MAAOgD,EAAM6B,QAAQtJ,KAAKuJ,QAC1B,iBAAkB,CAChB9E,MAAO,UACPgF,QAAS,IAGd"}
@@ -1,2 +1,2 @@
1
- import{defineProperty as e,createClass as r,classCallCheck as i}from"../../_virtual/_rollupPluginBabelHelpers.js";import{formatFileSize as u}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";var t,n;!function(e){e.Required="Required",e.Regex="Regex",e.RequiredValue="RequiredValue",e.Array="Array",e.Number="Number",e.Email="Email",e.PhoneNumber="PhoneNumber",e.Url="Url",e.File="File",e.FileRequired="FileRequired",e.Custom="Custom"}(n||(n={}));var s={Required:"The {0} is required",Regex:"The {0} is not match {1}",RequiredValue:"the {0} is not equal {1}",Array:"The {0} is not valid",Number:"{0} must be a number",Email:"The {0} is not valid",PhoneNumber:"The {0} is not valid",Url:"The {0} is not valid",File:"File size must be less than {1}",FileRequired:"The {0} is required",Custom:"Error Custom"},a=function(e,r){return r},l=r(function r(t){var l=this;i(this,r),e(this,"AddRules",function(e){var r,i=l.configs[e];i||(i={Rules:[]},l.configs[e]=i);for(var u=arguments.length,t=new Array(u>1?u-1:0),n=1;n<u;n++)t[n-1]=arguments[n];return(r=i.Rules).push.apply(r,t),l}),e(this,"Required",function(e,r){return null==r||""===r}),e(this,"Regex",function(e,r,i){return!!r&&!e.Value.test(r)}),e(this,"RequiredValue",function(e,r){return!!r&&r!==e.Value}),e(this,"Custom",function(e,r,i){return"function"!=typeof e.Value||e.Value(r,i)}),e(this,"Array",function(e,r){return!!r&&("number"!=typeof e.Value||(!Array.isArray(r)||r.length<=e.Value))}),e(this,"Number",function(e,r){return!!r&&isNaN(Number(r))}),e(this,"Email",function(e,r){if(!r)return!1;return!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(r)}),e(this,"PhoneNumber",function(e,r){if(!r)return!1;return!/^(\+?\d{1,4}[\s-]?)?((\(\d{1,4}\))|\d{1,4})[\s-]?\d{1,4}[\s-]?\d{1,9}$/.test((null!=r?r:"").trim())}),e(this,"Url",function(e,r){if(!r)return!1;try{return new URL(r),!1}catch(e){return!0}}),e(this,"File",function(e,r){if(!r)return!1;var i=a(0,e.options),u=Array.isArray(r)?r:[r];return!!i&&(!0===i.all?u.reduce(function(e,r){return e+=r.size},0)>i.maxSize:u.some(function(e){return e.size>i.maxSize}))}),e(this,"FileRequired",function(e,r){return!!(Array.isArray(r)?r:[r]).filter(function(e){return!!e}).some(function(e){return e.size<=0})}),e(this,"RenderMessage",function(e,r,i,t){if(t&&"string"==typeof t)e.message=t;else if(!e.message)switch(e.message=s[e.rule].replace("{0}",null!=i?i:r),e.rule){case n.Regex:e.message=e.message.replace("{1}",e.Value.source);break;case n.RequiredValue:var l,o;e.message=e.message.replace("{1}",null!==(l=null===(o=e.Value)||void 0===o?void 0:o.toString())&&void 0!==l?l:"");break;case n.File:var c,f,m=a(0,e.options);if(!0===(null==m?void 0:m.all))e.message="Total file size must be less than ".concat(u((null!==(c=null==m?void 0:m.maxSize)&&void 0!==c?c:0)/1024));else e.message=e.message.replace("{1}",u((null!==(f=null==m?void 0:m.maxSize)&&void 0!==f?f:0)/1024))}return e.message=e.message.replace("{0}",r),e}),e(this,"run",function(e){var r=Object.keys(l.configs),i={};return r.forEach(function(r){var u=l.configs[r];if(u){var t=l.Executed(u,e[r],e);t.length<1||(i[r]=t.map(function(e){return l.RenderMessage(e.rule,r,u.label,e.value)}))}}),i}),e(this,"Executed",function(e,r,i){return e.Rules.map(function(e){var u=l[e.rule.toString()],t=u&&u(e,r,i);return{value:t,rule:e}}).filter(function(e){return e.value})}),this.configs=t});t=l,e(l,"initial",function(e){return new t(e)});var o=function(){return new l({})};export{l as FormValidator,n as SingleRuleValidate,o as createFormValidator,l as default,a as mapRuleOptions};
1
+ import{defineProperty as e,createClass as r,classCallCheck as i}from"../../_virtual/_rollupPluginBabelHelpers.js";import{formatFileSize as u}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";var n,t;!function(e){e.Required="Required",e.Regex="Regex",e.RequiredValue="RequiredValue",e.Array="Array",e.Number="Number",e.Email="Email",e.PhoneNumber="PhoneNumber",e.Url="Url",e.File="File",e.FileRequired="FileRequired",e.Custom="Custom"}(t||(t={}));var s={Required:"The {0} is required",Regex:"The {0} is not match {1}",RequiredValue:"the {0} is not equal {1}",Array:"The {0} is not valid",Number:"{0} must be a number",Email:"The {0} is not valid",PhoneNumber:"The {0} is not valid",Url:"The {0} is not valid",File:"File size must be less than {1}",FileRequired:"The {0} is required",Custom:"Error Custom"},a=function(e,r){return r},l=r(function r(n){var l=this;i(this,r),e(this,"AddRules",function(e){var r,i=l.configs[e];i||(i={Rules:[]},l.configs[e]=i);for(var u=arguments.length,n=new Array(u>1?u-1:0),t=1;t<u;t++)n[t-1]=arguments[t];return(r=i.Rules).push.apply(r,n),l}),e(this,"Required",function(e,r){return null==r||""===r||!1===r}),e(this,"Regex",function(e,r,i){return!!r&&!e.Value.test(r)}),e(this,"RequiredValue",function(e,r){return r!==e.Value}),e(this,"Custom",function(e,r,i){return"function"!=typeof e.Value||e.Value(r,i)}),e(this,"Array",function(e,r){return!!r&&("number"!=typeof e.Value||(!Array.isArray(r)||r.length<=e.Value))}),e(this,"Number",function(e,r){return!!r&&isNaN(Number(r))}),e(this,"Email",function(e,r){if(!r)return!1;return!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(r)}),e(this,"PhoneNumber",function(e,r){if(!r)return!1;return!/^(\+?\d{1,4}[\s-]?)?((\(\d{1,4}\))|\d{1,4})[\s-]?\d{1,4}[\s-]?\d{1,9}$/.test((null!=r?r:"").trim())}),e(this,"Url",function(e,r){if(!r)return!1;try{return new URL(r),!1}catch(e){return!0}}),e(this,"File",function(e,r){if(!r)return!1;var i=a(0,e.options),u=Array.isArray(r)?r:[r];return!!i&&(!0===i.all?u.reduce(function(e,r){return e+=r.size},0)>i.maxSize:u.some(function(e){return e.size>i.maxSize}))}),e(this,"FileRequired",function(e,r){return null==r||""===r||"[]"===r||(Array.isArray(r)?0===r.length||r.some(function(e){return!e||e instanceof File&&e.size<=0}):r instanceof File&&r.size<=0)}),e(this,"RenderMessage",function(e,r,i,n){if(n&&"string"==typeof n)e.message=n;else if(!e.message)switch(e.message=s[e.rule].replace("{0}",null!=i?i:r),e.rule){case t.Regex:e.message=e.message.replace("{1}",e.Value.source);break;case t.RequiredValue:var l,o;e.message=e.message.replace("{1}",null!==(l=null===(o=e.Value)||void 0===o?void 0:o.toString())&&void 0!==l?l:"");break;case t.File:var c,f,m=a(0,e.options);if(!0===(null==m?void 0:m.all))e.message="Total file size must be less than ".concat(u((null!==(c=null==m?void 0:m.maxSize)&&void 0!==c?c:0)/1024));else e.message=e.message.replace("{1}",u((null!==(f=null==m?void 0:m.maxSize)&&void 0!==f?f:0)/1024))}return e.message=e.message.replace("{0}",r),e}),e(this,"run",function(e){var r=Object.keys(l.configs),i={};return r.forEach(function(r){var u=l.configs[r];if(u){var n=l.Executed(u,e[r],e);n.length<1||(i[r]=n.map(function(e){return l.RenderMessage(e.rule,r,u.label,e.value)}))}}),i}),e(this,"Executed",function(e,r,i){return e.Rules.map(function(e){var u=l[e.rule.toString()],n=u&&u(e,r,i);return{value:n,rule:e}}).filter(function(e){return e.value})}),this.configs=n});n=l,e(l,"initial",function(e){return new n(e)});var o=function(){return new l({})};export{l as FormValidator,t as SingleRuleValidate,o as createFormValidator,l as default,a as mapRuleOptions};
2
2
  //# sourceMappingURL=validator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validator.js","sources":["../../../src/form/validator.ts"],"sourcesContent":["import { formatFileSize } from '../utils'\r\n\r\nexport type IModelBase = { [key: string]: any }\r\n\r\nexport enum SingleRuleValidate {\r\n Required = 'Required',\r\n Regex = 'Regex',\r\n RequiredValue = 'RequiredValue',\r\n Array = 'Array',\r\n Number = 'Number',\r\n Email = 'Email',\r\n PhoneNumber = 'PhoneNumber',\r\n Url = 'Url',\r\n File = 'File',\r\n FileRequired = 'FileRequired',\r\n Custom = 'Custom'\r\n}\r\n\r\nconst MessageDefault = {\r\n Required: 'The {0} is required',\r\n Regex: 'The {0} is not match {1}',\r\n RequiredValue: 'the {0} is not equal {1}',\r\n Array: 'The {0} is not valid',\r\n Number: '{0} must be a number',\r\n Email: 'The {0} is not valid',\r\n PhoneNumber: 'The {0} is not valid',\r\n Url: 'The {0} is not valid',\r\n File: 'File size must be less than {1}',\r\n FileRequired: 'The {0} is required',\r\n Custom: 'Error Custom'\r\n}\r\n\r\nexport interface IRuleOptions {\r\n File: {\r\n maxSize: number\r\n // total size of files\r\n all?: boolean\r\n }\r\n}\r\n\r\nexport const mapRuleOptions = <TK extends keyof IRuleOptions>(key: TK, options?: IRuleOptions[TK]) => options\r\n\r\nexport interface IRuleOption<T = any> {\r\n rule: SingleRuleValidate\r\n message?: string\r\n Value?: RegExp | ((value: any, model: T) => boolean | string) | number | Array<any> | boolean\r\n options?: any\r\n}\r\n\r\nexport interface IConfigValue<T = any> {\r\n Rules: IRuleOption<T>[]\r\n label?: string\r\n}\r\n\r\nexport interface IModelError {\r\n message: string\r\n error: boolean\r\n}\r\n\r\nexport type IFormValidatorConfig<T> = {\r\n [key in keyof Extract<T, IModelBase>]?: IConfigValue<T>\r\n}\r\n\r\nexport type IPartialError<T> = {\r\n [key in keyof T]?: IRuleOption<T>[]\r\n}\r\n\r\nexport class FormValidator<T> {\r\n configs: IFormValidatorConfig<T>\r\n constructor(configs: IFormValidatorConfig<T>) {\r\n this.configs = configs\r\n }\r\n\r\n static initial = <T>(configs: IFormValidatorConfig<T>) => new FormValidator(configs)\r\n\r\n AddRules = (key: keyof T, ...rule: IRuleOption<T>[]) => {\r\n let fieldConfig = this.configs[key]\r\n if (!fieldConfig) {\r\n fieldConfig = { Rules: [] }\r\n this.configs[key] = fieldConfig\r\n }\r\n fieldConfig.Rules.push(...rule)\r\n return this\r\n }\r\n\r\n Required = (RuleOption: IRuleOption, value: any) => {\r\n return value === null || value === undefined || value === ''\r\n }\r\n Regex = (RuleOption: IRuleOption, value: string, Regex: RegExp) => {\r\n if (!value) return false\r\n return !(RuleOption.Value as RegExp).test(value)\r\n }\r\n RequiredValue = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n return value !== RuleOption.Value\r\n }\r\n Custom = (RuleOption: IRuleOption, value: any, model: any) => {\r\n if (typeof RuleOption.Value === 'function') {\r\n return RuleOption.Value(value, model)\r\n }\r\n return true\r\n }\r\n Array = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n if (typeof RuleOption.Value === 'number') {\r\n return Array.isArray(value) ? value.length <= RuleOption.Value : true\r\n }\r\n return true\r\n }\r\n Number = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n return isNaN(Number(value))\r\n }\r\n Email = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\r\n return !regex.test(value)\r\n }\r\n PhoneNumber = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n const phoneRegex = /^(\\+?\\d{1,4}[\\s-]?)?((\\(\\d{1,4}\\))|\\d{1,4})[\\s-]?\\d{1,4}[\\s-]?\\d{1,9}$/\r\n return !phoneRegex.test((value ?? '').trim())\r\n }\r\n Url = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n try {\r\n new URL(value)\r\n return false\r\n } catch (err) {\r\n return true\r\n }\r\n }\r\n File = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n const options = mapRuleOptions('File', RuleOption.options)\r\n const files: File[] = Array.isArray(value) ? value : [value]\r\n if (!options) return false\r\n if (options.all === true) {\r\n const size = files.reduce((a, b) => {\r\n a += b.size\r\n return a\r\n }, 0)\r\n return size > options.maxSize\r\n } else {\r\n return files.some((x) => x.size > options.maxSize)\r\n }\r\n }\r\n FileRequired = (RuleOption: IRuleOption, value: any) => {\r\n const files: File[] = Array.isArray(value) ? value : [value]\r\n return !!files.filter((x) => !!x).some((x) => x.size <= 0)\r\n }\r\n RenderMessage = (RuleOption: IRuleOption, key: string, label?: string, message?: string | boolean) => {\r\n if (!!message && typeof message === 'string') {\r\n RuleOption.message = message\r\n } else if (!RuleOption.message) {\r\n RuleOption.message = MessageDefault[RuleOption.rule].replace('{0}', label ?? key)\r\n switch (RuleOption.rule) {\r\n case SingleRuleValidate.Regex: {\r\n RuleOption.message = RuleOption.message.replace('{1}', (RuleOption.Value as RegExp).source)\r\n break\r\n }\r\n case SingleRuleValidate.RequiredValue: {\r\n RuleOption.message = RuleOption.message.replace('{1}', RuleOption.Value?.toString() ?? '')\r\n break\r\n }\r\n case SingleRuleValidate.File: {\r\n const options = mapRuleOptions('File', RuleOption.options)\r\n if (options?.all === true) {\r\n RuleOption.message = `Total file size must be less than ${formatFileSize((options?.maxSize ?? 0) / 1024)}`\r\n } else {\r\n RuleOption.message = RuleOption.message.replace('{1}', formatFileSize((options?.maxSize ?? 0) / 1024))\r\n }\r\n break\r\n }\r\n default:\r\n break\r\n }\r\n }\r\n RuleOption.message = RuleOption.message.replace('{0}', key)\r\n return RuleOption\r\n }\r\n run = (model: T) => {\r\n const keys = Object.keys(this.configs)\r\n const data: IPartialError<T> = {}\r\n keys.forEach((key) => {\r\n const config = this.configs[key]\r\n if (!config) return\r\n const tmp = this.Executed(config, (model as any)[key], model)\r\n if (tmp.length < 1) return\r\n ;(data as any)[key] = tmp.map((x) => this.RenderMessage(x.rule, key, config.label, x.value))\r\n })\r\n return data\r\n }\r\n Executed = (Config: IConfigValue, valueField: any, model: any) => {\r\n return Config.Rules.map((Value) => {\r\n const action = (this as any)[Value.rule.toString()]\r\n const res = action && action(Value, valueField, model)\r\n return { value: typeof res === 'boolean' ? res : (res as string), rule: Value }\r\n }).filter((x) => x.value)\r\n }\r\n}\r\n\r\nexport default FormValidator\r\n\r\nexport const createFormValidator = <T>() => {\r\n return new FormValidator<Partial<T>>({})\r\n}\r\n"],"names":["SingleRuleValidate","MessageDefault","Required","Regex","RequiredValue","Array","Number","Email","PhoneNumber","Url","File","FileRequired","Custom","mapRuleOptions","key","options","FormValidator","_createClass","configs","_this","this","_classCallCheck","_defineProperty","_fieldConfig$Rules","fieldConfig","Rules","_len","arguments","length","rule","_key","push","apply","RuleOption","value","Value","test","model","isArray","isNaN","trim","URL","err","files","all","reduce","a","b","size","maxSize","some","x","filter","label","message","replace","source","_RuleOption$Value$toS","_RuleOption$Value","toString","_options$maxSize","_options$maxSize2","concat","formatFileSize","keys","Object","data","forEach","config","tmp","Executed","map","RenderMessage","Config","valueField","action","res","createFormValidator"],"mappings":"8OAIYA,GAAZ,SAAYA,GACVA,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R5C,kBACU,SAACmD,EAAsBC,EAAiBrC,GACjD,OAAOoC,EAAOhD,MAAM8C,IAAI,SAACpC,GACvB,IAAMwC,EAAUxD,EAAagB,EAAMN,KAAK8B,YAClCiB,EAAMD,GAAUA,EAAOxC,EAAOuC,EAAYrC,GAChD,MAAO,CAAEH,MAAkC0C,EAAuB/C,KAAMM,EAC1E,GAAGiB,OAAO,SAACD,GAAC,OAAKA,EAAEjB,UAhInBd,KAAKF,QAAUA,CACjB,KAJWF,EAAaM,EAAbN,EAMM,UAAA,SAAIE,GAAgC,OAAK,IAAIF,EAAcE,EAAQ,OAmIzE2D,EAAsB,WACjC,OAAO,IAAI7D,EAA0B,GACvC"}
1
+ {"version":3,"file":"validator.js","sources":["../../../src/form/validator.ts"],"sourcesContent":["import { formatFileSize } from '../utils'\r\n\r\nexport type IModelBase = { [key: string]: any }\r\n\r\nexport enum SingleRuleValidate {\r\n Required = 'Required',\r\n Regex = 'Regex',\r\n RequiredValue = 'RequiredValue',\r\n Array = 'Array',\r\n Number = 'Number',\r\n Email = 'Email',\r\n PhoneNumber = 'PhoneNumber',\r\n Url = 'Url',\r\n File = 'File',\r\n FileRequired = 'FileRequired',\r\n Custom = 'Custom'\r\n}\r\n\r\nconst MessageDefault = {\r\n Required: 'The {0} is required',\r\n Regex: 'The {0} is not match {1}',\r\n RequiredValue: 'the {0} is not equal {1}',\r\n Array: 'The {0} is not valid',\r\n Number: '{0} must be a number',\r\n Email: 'The {0} is not valid',\r\n PhoneNumber: 'The {0} is not valid',\r\n Url: 'The {0} is not valid',\r\n File: 'File size must be less than {1}',\r\n FileRequired: 'The {0} is required',\r\n Custom: 'Error Custom'\r\n}\r\n\r\nexport interface IRuleOptions {\r\n File: {\r\n maxSize: number\r\n // total size of files\r\n all?: boolean\r\n }\r\n}\r\n\r\nexport const mapRuleOptions = <TK extends keyof IRuleOptions>(key: TK, options?: IRuleOptions[TK]) => options\r\n\r\nexport interface IRuleOption<T = any> {\r\n rule: SingleRuleValidate\r\n message?: string\r\n Value?: RegExp | ((value: any, model: T) => boolean | string) | number | Array<any> | boolean\r\n options?: any\r\n}\r\n\r\nexport interface IConfigValue<T = any> {\r\n Rules: IRuleOption<T>[]\r\n label?: string\r\n}\r\n\r\nexport interface IModelError {\r\n message: string\r\n error: boolean\r\n}\r\n\r\nexport type IFormValidatorConfig<T> = {\r\n [key in keyof Extract<T, IModelBase>]?: IConfigValue<T>\r\n}\r\n\r\nexport type IPartialError<T> = {\r\n [key in keyof T]?: IRuleOption<T>[]\r\n}\r\n\r\nexport class FormValidator<T> {\r\n configs: IFormValidatorConfig<T>\r\n constructor(configs: IFormValidatorConfig<T>) {\r\n this.configs = configs\r\n }\r\n\r\n static initial = <T>(configs: IFormValidatorConfig<T>) => new FormValidator(configs)\r\n\r\n AddRules = (key: keyof T, ...rule: IRuleOption<T>[]) => {\r\n let fieldConfig = this.configs[key]\r\n if (!fieldConfig) {\r\n fieldConfig = { Rules: [] }\r\n this.configs[key] = fieldConfig\r\n }\r\n fieldConfig.Rules.push(...rule)\r\n return this\r\n }\r\n\r\n Required = (RuleOption: IRuleOption, value: any) => {\r\n return value === null || value === undefined || value === '' || value === false\r\n }\r\n Regex = (RuleOption: IRuleOption, value: string, Regex: RegExp) => {\r\n if (!value) return false\r\n return !(RuleOption.Value as RegExp).test(value)\r\n }\r\n RequiredValue = (RuleOption: IRuleOption, value: any) => {\r\n return value !== RuleOption.Value\r\n }\r\n Custom = (RuleOption: IRuleOption, value: any, model: any) => {\r\n if (typeof RuleOption.Value === 'function') {\r\n return RuleOption.Value(value, model)\r\n }\r\n return true\r\n }\r\n Array = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n if (typeof RuleOption.Value === 'number') {\r\n return Array.isArray(value) ? value.length <= RuleOption.Value : true\r\n }\r\n return true\r\n }\r\n Number = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n return isNaN(Number(value))\r\n }\r\n Email = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\r\n return !regex.test(value)\r\n }\r\n PhoneNumber = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n const phoneRegex = /^(\\+?\\d{1,4}[\\s-]?)?((\\(\\d{1,4}\\))|\\d{1,4})[\\s-]?\\d{1,4}[\\s-]?\\d{1,9}$/\r\n return !phoneRegex.test((value ?? '').trim())\r\n }\r\n Url = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n try {\r\n new URL(value)\r\n return false\r\n } catch (err) {\r\n return true\r\n }\r\n }\r\n File = (RuleOption: IRuleOption, value: any) => {\r\n if (!value) return false\r\n const options = mapRuleOptions('File', RuleOption.options)\r\n const files: File[] = Array.isArray(value) ? value : [value]\r\n if (!options) return false\r\n if (options.all === true) {\r\n const size = files.reduce((a, b) => {\r\n a += b.size\r\n return a\r\n }, 0)\r\n return size > options.maxSize\r\n } else {\r\n return files.some((x) => x.size > options.maxSize)\r\n }\r\n }\r\n FileRequired = (RuleOption: IRuleOption, value: any) => {\r\n if (value === null || value === undefined || value === '' || value === '[]') return true\r\n if (Array.isArray(value)) {\r\n if (value.length === 0) return true\r\n return value.some((x) => !x || (x instanceof File && x.size <= 0))\r\n }\r\n if (value instanceof File) return value.size <= 0\r\n return false\r\n }\r\n RenderMessage = (RuleOption: IRuleOption, key: string, label?: string, message?: string | boolean) => {\r\n if (!!message && typeof message === 'string') {\r\n RuleOption.message = message\r\n } else if (!RuleOption.message) {\r\n RuleOption.message = MessageDefault[RuleOption.rule].replace('{0}', label ?? key)\r\n switch (RuleOption.rule) {\r\n case SingleRuleValidate.Regex: {\r\n RuleOption.message = RuleOption.message.replace('{1}', (RuleOption.Value as RegExp).source)\r\n break\r\n }\r\n case SingleRuleValidate.RequiredValue: {\r\n RuleOption.message = RuleOption.message.replace('{1}', RuleOption.Value?.toString() ?? '')\r\n break\r\n }\r\n case SingleRuleValidate.File: {\r\n const options = mapRuleOptions('File', RuleOption.options)\r\n if (options?.all === true) {\r\n RuleOption.message = `Total file size must be less than ${formatFileSize((options?.maxSize ?? 0) / 1024)}`\r\n } else {\r\n RuleOption.message = RuleOption.message.replace('{1}', formatFileSize((options?.maxSize ?? 0) / 1024))\r\n }\r\n break\r\n }\r\n default:\r\n break\r\n }\r\n }\r\n RuleOption.message = RuleOption.message.replace('{0}', key)\r\n return RuleOption\r\n }\r\n run = (model: T) => {\r\n const keys = Object.keys(this.configs)\r\n const data: IPartialError<T> = {}\r\n keys.forEach((key) => {\r\n const config = this.configs[key]\r\n if (!config) return\r\n const tmp = this.Executed(config, (model as any)[key], model)\r\n if (tmp.length < 1) return\r\n ;(data as any)[key] = tmp.map((x) => this.RenderMessage(x.rule, key, config.label, x.value))\r\n })\r\n return data\r\n }\r\n Executed = (Config: IConfigValue, valueField: any, model: any) => {\r\n return Config.Rules.map((Value) => {\r\n const action = (this as any)[Value.rule.toString()]\r\n const res = action && action(Value, valueField, model)\r\n return { value: typeof res === 'boolean' ? res : (res as string), rule: Value }\r\n }).filter((x) => x.value)\r\n }\r\n}\r\n\r\nexport default FormValidator\r\n\r\nexport const createFormValidator = <T>() => {\r\n return new FormValidator<Partial<T>>({})\r\n}\r\n"],"names":["SingleRuleValidate","MessageDefault","Required","Regex","RequiredValue","Array","Number","Email","PhoneNumber","Url","File","FileRequired","Custom","mapRuleOptions","key","options","FormValidator","_createClass","configs","_this","this","_classCallCheck","_defineProperty","_fieldConfig$Rules","fieldConfig","Rules","_len","arguments","length","rule","_key","push","apply","RuleOption","value","Value","test","model","isArray","isNaN","trim","URL","err","files","all","reduce","a","b","size","maxSize","some","x","label","message","replace","source","_RuleOption$Value$toS","_RuleOption$Value","toString","_options$maxSize","_options$maxSize2","concat","formatFileSize","keys","Object","data","forEach","config","tmp","Executed","map","RenderMessage","Config","valueField","action","res","filter","createFormValidator"],"mappings":"8OAIYA,GAAZ,SAAYA,GACVA,EAAA,SAAA,WACA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KAAMf,EAAKqD,EAAOf,MAAOD,EAAEjB,SAHxE,CAIf,GACO+B,IACR3C,kBACU,SAACkD,EAAsBC,EAAiBpC,GACjD,OAAOmC,EAAO/C,MAAM6C,IAAI,SAACnC,GACvB,IAAMuC,EAAUvD,EAAagB,EAAMN,KAAK6B,YAClCiB,EAAMD,GAAUA,EAAOvC,EAAOsC,EAAYpC,GAChD,MAAO,CAAEH,MAAkCyC,EAAuB9C,KAAMM,EAC1E,GAAGyC,OAAO,SAACzB,GAAC,OAAKA,EAAEjB,UApInBd,KAAKF,QAAUA,CACjB,KAJWF,EAAaM,EAAbN,EAMM,UAAA,SAAIE,GAAgC,OAAK,IAAIF,EAAcE,EAAQ,OAuIzE2D,EAAsB,WACjC,OAAO,IAAI7D,EAA0B,GACvC"}
@@ -0,0 +1,30 @@
1
+ import React, { Component } from 'react';
2
+ import { SxProps, Theme } from '@mui/material';
3
+ export interface IConfirmButtonSlots {
4
+ size?: 'micro' | 'small' | 'medium';
5
+ color?: 'primary' | 'inherit' | 'error';
6
+ buttonElement?: React.ComponentType<{
7
+ onClick: () => void;
8
+ }>;
9
+ }
10
+ export interface IConfirmButtonProps {
11
+ onSubmit?: () => void;
12
+ onCancel?: () => void;
13
+ disabled?: boolean;
14
+ title?: string;
15
+ children?: React.ReactNode;
16
+ slots?: IConfirmButtonSlots;
17
+ }
18
+ export interface IConfirmButtonState {
19
+ isCheck: boolean;
20
+ }
21
+ export declare class ConfirmButton extends Component<IConfirmButtonProps, IConfirmButtonState> {
22
+ constructor(props: IConfirmButtonProps);
23
+ render(): import("react/jsx-runtime").JSX.Element;
24
+ renderContent: () => import("react/jsx-runtime").JSX.Element;
25
+ handleClickDone: (e?: React.MouseEvent) => void;
26
+ handleClickCancel: (e?: React.MouseEvent | MouseEvent | TouchEvent) => void;
27
+ handlingClick: (e?: React.MouseEvent) => void;
28
+ getSxWrap: () => SxProps<Theme>;
29
+ }
30
+ export default ConfirmButton;
@@ -7,3 +7,4 @@ export * from './create.multi-select-dropdown';
7
7
  export * from './image-with-fallback';
8
8
  export * from './help-tooltip';
9
9
  export * from './rich-tooltip';
10
+ export * from './confirm-button';
@@ -9,6 +9,7 @@ export interface IFormFieldStringParam<T> {
9
9
  /** Optional configuration for the form field */
10
10
  config?: IFieldMenuConfig<T>;
11
11
  top?: ReactNode;
12
+ multiline?: boolean;
12
13
  }
13
14
  /**
14
15
  * Factory function that creates a `FormFieldString` filter-menu component.
@@ -0,0 +1,41 @@
1
+ import { ComponentType } from 'react';
2
+ import { BoxProps, CheckboxProps, TypographyProps } from '@mui/material';
3
+ import { IFormInputBase } from './types';
4
+ export interface ICheckboxSlots {
5
+ wrapProps?: BoxProps;
6
+ checkboxProps?: CheckboxProps;
7
+ labelProps?: TypographyProps;
8
+ }
9
+ export interface ICheckboxProps<T = any> extends IFormInputBase<T, ICheckboxSlots> {
10
+ onChange?: (checked: boolean) => void;
11
+ }
12
+ export interface ICheckboxState {
13
+ checked: boolean;
14
+ }
15
+ export interface ICheckboxParams<T = any> extends ICheckboxSlots {
16
+ }
17
+ /** Standard class names for styling DinoCheckbox sub-components. */
18
+ export declare const checkboxClasses: {
19
+ root: string;
20
+ row: string;
21
+ box: string;
22
+ label: string;
23
+ error: string;
24
+ checked: string;
25
+ disabled: string;
26
+ };
27
+ /**
28
+ * Modern Custom Styled Checkbox Component Creator for Boolean fields in DinoForm V2.
29
+ *
30
+ * Renders a rounded square checkbox with custom check icon matching modern design aesthetics.
31
+ *
32
+ * @example
33
+ * @formField({
34
+ * type: Boolean,
35
+ * label: 'Same as billing address',
36
+ * renderInput: DinoForm.createCheckbox()
37
+ * })
38
+ * isSameBilling?: boolean
39
+ */
40
+ export declare function createCheckbox<T = any>(params?: ICheckboxParams<T>): ComponentType<ICheckboxProps<T>>;
41
+ export default createCheckbox;
@@ -11,15 +11,29 @@ export interface IFormBaseErrorHandlers<T> {
11
11
  errorCommonGetter?: IErrorCommonGetter;
12
12
  }
13
13
  export interface IFormBaseConfig<T> extends IFormBaseErrorHandlers<T> {
14
+ /** Custom validator used to validate form data */
14
15
  validate?: FormValidator<Partial<T>>;
16
+ /** Automatically trim string data before processing */
15
17
  dataTrimed?: boolean;
18
+ /** Function to extract/transform form data */
16
19
  dataGetter?: (data: Partial<T>) => Partial<T>;
20
+ /** Enable/disable checking for data changes before submit. @default true (when data has initial values) */
21
+ checkChanged?: boolean;
22
+ /** Message displayed when no fields have been modified. @default 'Please change at least one field to proceed' */
23
+ noChangeMessage?: string;
17
24
  }
18
25
  export interface IFormBaseProps<T> extends PropsWithChildren, IFormBaseConfig<T> {
26
+ /** Custom CSS class for the form element */
19
27
  className?: string;
28
+ /** Initial form data model to compare changes against */
29
+ data?: Partial<T>;
30
+ /** Handler called when submitting the form */
20
31
  onSubmit: (data: Partial<T>, e: React.FormEvent<HTMLFormElement>) => Promise<void>;
32
+ /** Callback for validation errors or unmodified form data errors */
21
33
  onError?: (error: IPartialError<T>) => void;
34
+ /** Render form as a flexbox layout (flex: 1). @default false */
22
35
  flexBox?: boolean;
36
+ /** Custom slots for form container props */
23
37
  slots?: IFormBaseSlots;
24
38
  }
25
39
  export interface IFormBaseState<T> {
@@ -13,6 +13,7 @@ export interface InputBaseImage<T> extends Omit<Partial<IImageWithFallbackPropsO
13
13
  }
14
14
  export interface IInputSlots<T> {
15
15
  maxLength?: number;
16
+ placeholder?: string;
16
17
  textFieldProps?: TextFieldProps;
17
18
  pastenable?: boolean;
18
19
  imageLeft?: InputBaseImage<T>;
@@ -1,16 +1,116 @@
1
- import { ComponentType } from 'react';
2
- import { TextFieldProps } from '@mui/material';
1
+ import { BoxProps } from '@mui/material';
2
+ import { ComponentType, ReactNode } from 'react';
3
3
  import { IFormInputBase } from './types';
4
- export interface IInputFileProps<T> extends IFormInputBase<T> {
4
+ /** Supported operation modes for the file input component. */
5
+ export type IInputFileMode = 'file' | 'image' | 'csv';
6
+ /**
7
+ * Slots and customizable parameters for file input components.
8
+ */
9
+ export interface IInputFileSlots<T = any> {
10
+ /** Custom BoxProps passed to the outer wrapper container. */
11
+ wrapProps?: BoxProps;
12
+ /** Allowed file extensions or MIME types (e.g. '.pdf,.txt,.docx', 'image/*', 'text/csv'). */
5
13
  accept?: string;
14
+ /** Whether multiple file selection is enabled. @default false */
6
15
  multiple?: boolean;
7
- textFieldProps?: TextFieldProps;
16
+ /** Custom React node for the primary dropzone title. @default 'Upload your files here' */
17
+ dropzoneTitle?: ReactNode;
18
+ /** Custom React node for the secondary dropzone subtitle. Shows allowed file extensions if omitted. */
19
+ dropzoneSubtitle?: ReactNode;
20
+ /** Sample CSV download URL for CSV mode. */
21
+ downloadSampleUrl?: string;
22
+ /** Instructional guidance text for CSV mode. */
23
+ instructionalText?: string;
24
+ /** Primary title text displayed above the dropzone container. */
25
+ titleText?: string;
26
+ /** Subtext displayed below the title or above the dropzone. */
27
+ subText?: string;
28
+ /** Function to resolve displayable image URL string for an individual field value item. */
29
+ imageGetter?: (value?: any, data?: Partial<T>, index?: number) => string | undefined;
30
+ /** Async upload function for mode 'image'. Returns remote image URL string. */
31
+ upload?: (file: File, data?: Partial<T>) => Promise<string | null>;
8
32
  }
9
- export interface IInputFileState {
10
- }
11
- export interface IInputFileParams {
33
+ /**
34
+ * Props passed to the rendered file input component.
35
+ */
36
+ export interface IInputFileProps<T> extends IFormInputBase<T, IInputFileSlots<T>> {
37
+ /** Mode of operation: 'file' (generic), 'image' (with preview/upload), 'csv' (local CSV parser). */
38
+ mode?: IInputFileMode;
39
+ /** Allowed file extensions or MIME types (e.g. '.pdf,.txt,.png'). */
12
40
  accept?: string;
41
+ /** Enable selecting multiple files or images. @default false */
13
42
  multiple?: boolean;
43
+ /** Function to resolve displayable image URL string for an individual field value item. */
44
+ imageGetter?: (value?: any, data?: Partial<T>, index?: number) => string | undefined;
45
+ /** Async upload function for mode 'image'. Returns remote image URL string. */
46
+ upload?: (file: File, data?: Partial<T>) => Promise<string | null>;
47
+ /** Callback fired when file selection or parsing changes. */
48
+ onChange?: (value: any) => void;
49
+ /** Tooltip configuration panel. */
50
+ tooltip?: any;
51
+ }
52
+ export interface IInputFileState {
53
+ isDragOver: boolean;
54
+ selectedFiles: File[];
55
+ imageUrls: string[];
56
+ csvData?: any[];
57
+ isParsingCsv?: boolean;
58
+ isUploading?: boolean;
59
+ }
60
+ /**
61
+ * Parameters passed to `createInputFile` factory function.
62
+ */
63
+ export interface IInputFileParams<T = any> extends IInputFileSlots<T> {
64
+ /** Mode of operation: 'file' | 'image' | 'csv'. Defaults to 'file' or auto-detection. */
65
+ mode?: IInputFileMode;
14
66
  }
15
- declare function CreateInputFile<T>(params?: IInputFileParams): ComponentType<IFormInputBase<T>>;
16
- export default CreateInputFile;
67
+ /**
68
+ * Single Universal File Input Creator for DinoForm.
69
+ *
70
+ * Supports generic files (.pdf, .txt, .docx), single or multiple image uploads with preview & server upload API, and local CSV parsing.
71
+ *
72
+ * @example
73
+ * // 1. Generic Multiple File Mode (PDF, TXT, DOCX)
74
+ * @formField({
75
+ * type: String,
76
+ * label: 'Upload Documents (.pdf, .txt)',
77
+ * renderInput: DinoForm.createInputFile({
78
+ * accept: '.pdf,.txt,.docx',
79
+ * multiple: true
80
+ * })
81
+ * })
82
+ * DocumentFiles?: any
83
+ *
84
+ * // 2. Multiple Images Upload with Server API
85
+ * @formField({
86
+ * type: String,
87
+ * label: 'Gallery Images',
88
+ * renderInput: DinoForm.createInputFile({
89
+ * mode: 'image',
90
+ * accept: 'image/*',
91
+ * multiple: true,
92
+ * imageGetter: (val, data) => val ? `https://cdn.site.com/${val}` : undefined,
93
+ * upload: async (file) => {
94
+ * const res = await api.upload(file)
95
+ * return res.url
96
+ * }
97
+ * })
98
+ * })
99
+ * GalleryUrls?: string[]
100
+ *
101
+ * // 3. CSV Mode with Local Parser
102
+ * @formField({
103
+ * type: String,
104
+ * label: 'Import CSV Data',
105
+ * renderInput: DinoForm.createInputFile({
106
+ * mode: 'csv',
107
+ * downloadSampleUrl: '/sample.csv'
108
+ * })
109
+ * })
110
+ * CsvRecords?: any[]
111
+ *
112
+ * @param params - Configuration parameters for mode, accept types (e.g. '.pdf,.txt'), upload functions, and titles.
113
+ * @returns A React component configured for file drag-and-drop uploading.
114
+ */
115
+ export declare function createInputFile<T = any, C = any>(params?: IInputFileParams<T>): ComponentType<IInputFileProps<T>>;
116
+ export default createInputFile;
@@ -3,7 +3,7 @@ import type { SelectProps } from '@mui/material';
3
3
  import type { IFormInputBase } from '../form/types';
4
4
  import type { IRichTooltipPanelConfig } from '../components/rich-tooltip';
5
5
  export interface ISelectSimpleOption<T extends string = string> {
6
- name: string;
6
+ label?: string;
7
7
  value: T;
8
8
  }
9
9
  export interface ISelectSimpleSlots {
@@ -3,9 +3,9 @@ import { IFormInputBase } from './types';
3
3
  import type { FilterOptionsState, TextFieldProps, AutocompleteRenderOptionState } from '@mui/material';
4
4
  import type { IRichTooltipPanelConfig } from '../components/rich-tooltip';
5
5
  export interface ISelectWithApiOption<TOther = any> {
6
- Id: string;
7
- Name?: string;
8
- Other?: TOther;
6
+ value: string;
7
+ label?: string;
8
+ other?: TOther;
9
9
  }
10
10
  export interface ISelectWithApiPropsSlots<O extends ISelectWithApiOption = ISelectWithApiOption> {
11
11
  textFieldProps: TextFieldProps;
@@ -8,6 +8,7 @@ export interface IDecoratorFieldProps<T = any> extends IFormInputBase<T> {
8
8
  type?: any;
9
9
  visible?: boolean | ((data: T) => boolean);
10
10
  renderInput?: ComponentType<IFormInputBase<T>>;
11
+ defaultInput?: ComponentType<IFormInputBase<T>>;
11
12
  }
12
13
  export interface IDecoratorFormSlots<T> {
13
14
  top?: React.ReactNode;
@@ -20,16 +21,32 @@ export interface IDecoratorFormSlots<T> {
20
21
  footerSlots?: IFormFooterSlots;
21
22
  }
22
23
  export interface IDecoratorFormProps<T = any> extends IFormBaseErrorHandlers<T> {
24
+ /** Form configuration class decorated with `@registerForm` */
23
25
  configClass?: any;
26
+ /** Initial or current data model for the form */
24
27
  data?: T;
28
+ /** Callback triggered when submitting form data */
25
29
  onSubmit?: (data: Partial<T>, signal?: AbortSignal) => Promise<void>;
30
+ /** Callback triggered when an error occurs during form submit */
26
31
  onError?: (error: any) => void;
32
+ /** Callback triggered when form validation fails */
27
33
  onSubmitError?: (error: IPartialError<T>) => void;
34
+ /** Callback triggered after `onSubmit` successfully completes */
28
35
  onSuccess?: (data: Partial<T>) => void;
36
+ /** Callback triggered when user clicks the cancel button */
29
37
  onCancel?: ButtonProps['onClick'];
38
+ /** Custom slots for UI components inside the form */
30
39
  slots?: IDecoratorFormSlots<T>;
40
+ /** Disable padding/margin gutters around the form container. @default false */
31
41
  disableGutters?: boolean;
42
+ /** Loading state displaying an overlay over the form. @default false */
32
43
  loading?: boolean;
44
+ /** Enable/disable checking for data changes before submit. @default true (when data !== undefined) */
45
+ checkChanged?: boolean;
46
+ /** Message displayed when no fields have been modified. @default 'Please change at least one field to proceed' */
47
+ noChangeMessage?: string;
48
+ /** Custom default Input component to replace the default V1 createInput for String/Number fields */
49
+ defaultInput?: ComponentType<IFormInputBase<T>>;
33
50
  }
34
51
  export type IDecoratorFormConfig<T> = Partial<Omit<IDecoratorFormProps<T>, 'configClass'>>;
35
52
  export declare const createDecoratorForm: <T>(configClass?: any, config?: Partial<Omit<IDecoratorFormProps<T>, "configClass">> | undefined) => ComponentType<IDecoratorFormProps<T>>;
@@ -1,13 +1,18 @@
1
1
  /// <reference types="react" />
2
- import { createInputFileCsvLocalParser } from './create.input-file.csv-local-parser';
3
2
  import FormValidator from './validator';
4
- import CreateInputFile from './create.input.file';
3
+ import createCheckbox from './create.checkbox';
4
+ import createInputFile from './create.input.file';
5
+ import createDatePickerV2 from './v2/create.date-picker';
5
6
  import createColorPicker from './create.color-picker';
7
+ import createColorPickerV2 from './v2/create.color-picker';
6
8
  import CreateDateExpired from './create.date-expired';
9
+ import createDateExpiredV2 from './v2/create.date-expired';
7
10
  import createSelectSimple from './create.select-simple';
11
+ import createSelectSimpleV2 from './v2/create.select-simple';
8
12
  import createSelectWithApi from './create.select-with-api';
9
- import createInputImageFile from './create.input.image-file';
13
+ import createSelectWithApiV2 from './v2/create.select-with-api';
10
14
  import CreateAutocompleteChip from './create.autocomplete.chips';
15
+ import createAutocompleteChipV2 from './v2/create.autocomplete.chips';
11
16
  declare class DinoFormBase {
12
17
  ModalWrap: import("react").FC<import("./modal-wrapper").IFormModalWrapperProps>;
13
18
  BottomBarWrap: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
@@ -20,15 +25,21 @@ declare class DinoFormBase {
20
25
  createFormGridLayout: <T>(params: import("./create.form-grid-layout").IFormGridLayoutParams<T>) => import("react").ComponentType<import("./create.form-grid-layout").IFormGridLayoutProps<T>>;
21
26
  createDecoratorForm: <T>(configClass?: any, config?: Partial<Omit<import("./decorator.form").IDecoratorFormProps<T>, "configClass">> | undefined) => import("react").ComponentType<import("./decorator.form").IDecoratorFormProps<T>>;
22
27
  createColorPicker: typeof createColorPicker;
28
+ createColorPickerV2: typeof createColorPickerV2;
23
29
  createDateExpired: typeof CreateDateExpired;
30
+ createDateExpiredV2: typeof createDateExpiredV2;
24
31
  createDatePicker: <T extends Object>(params?: import("./create.date-picker").IDatePickerSlots | undefined) => import("react").ComponentType<import("./create.date-picker").IDatePickerProps<T>>;
32
+ createDatePickerV2: typeof createDatePickerV2;
25
33
  createAutocompleteChip: typeof CreateAutocompleteChip;
26
- createInputFileCsvLocalParser: typeof createInputFileCsvLocalParser;
27
- createInputFile: typeof CreateInputFile;
28
- createInputImageFile: typeof createInputImageFile;
34
+ createAutocompleteChipV2: typeof createAutocompleteChipV2;
35
+ createInputFile: typeof createInputFile;
29
36
  createInput: <T>(params?: import("./create.input").IInputParams<T> | undefined) => import("react").ComponentType<import("./create.input").IInputProps<T>>;
37
+ createInputV2: <T>(params?: import("./v2/create.input").IInputParams<T> | undefined) => import("react").ComponentType<import("./v2/create.input").IInputProps<T>>;
38
+ createCheckbox: typeof createCheckbox;
30
39
  createSelectSimple: typeof createSelectSimple;
40
+ createSelectSimpleV2: typeof createSelectSimpleV2;
31
41
  createSelectWithApi: typeof createSelectWithApi;
42
+ createSelectWithApiV2: typeof createSelectWithApiV2;
32
43
  }
33
44
  declare const DinoForm: DinoFormBase;
34
45
  export default DinoForm;