dinocollab-core 2.2.49 → 2.2.52

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 (93) 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/helpers.js +1 -1
  9. package/dist/src/data-surface/view-list/helpers.js.map +1 -1
  10. package/dist/src/data-surface/view-list/index.js +1 -1
  11. package/dist/src/data-surface/view-list/index.js.map +1 -1
  12. package/dist/src/data-surface/view-list/styled.js +1 -1
  13. package/dist/src/data-surface/view-list/styled.js.map +1 -1
  14. package/dist/src/data-surface/view-list/types.js.map +1 -1
  15. package/dist/src/filter-bar/components/filter-input.units.js +1 -1
  16. package/dist/src/filter-bar/components/filter-input.units.js.map +1 -1
  17. package/dist/src/filter-bar/components/filter-sort.js +1 -1
  18. package/dist/src/filter-bar/components/filter-sort.js.map +1 -1
  19. package/dist/src/filter-bar/menu/create-form-field-string.js +1 -1
  20. package/dist/src/filter-bar/menu/create-form-field-string.js.map +1 -1
  21. package/dist/src/filter-bar/menu/create.js +1 -1
  22. package/dist/src/filter-bar/menu/create.js.map +1 -1
  23. package/dist/src/form/create.checkbox.js +2 -0
  24. package/dist/src/form/create.checkbox.js.map +1 -0
  25. package/dist/src/form/create.form-base.js +1 -1
  26. package/dist/src/form/create.form-base.js.map +1 -1
  27. package/dist/src/form/create.form-grid-layout.js +1 -1
  28. package/dist/src/form/create.form-grid-layout.js.map +1 -1
  29. package/dist/src/form/create.input.file.js +1 -1
  30. package/dist/src/form/create.input.file.js.map +1 -1
  31. package/dist/src/form/create.input.js.map +1 -1
  32. package/dist/src/form/create.select-simple.js +1 -1
  33. package/dist/src/form/create.select-simple.js.map +1 -1
  34. package/dist/src/form/create.select-with-api.js +1 -1
  35. package/dist/src/form/create.select-with-api.js.map +1 -1
  36. package/dist/src/form/decorator.form.js +1 -1
  37. package/dist/src/form/decorator.form.js.map +1 -1
  38. package/dist/src/form/decorator.units.js +1 -1
  39. package/dist/src/form/decorator.units.js.map +1 -1
  40. package/dist/src/form/dino-form.js +1 -1
  41. package/dist/src/form/dino-form.js.map +1 -1
  42. package/dist/src/form/error-handler.js +1 -1
  43. package/dist/src/form/error-handler.js.map +1 -1
  44. package/dist/src/form/helpers.js +1 -1
  45. package/dist/src/form/helpers.js.map +1 -1
  46. package/dist/src/form/v2/create.autocomplete.chips.js +2 -0
  47. package/dist/src/form/v2/create.autocomplete.chips.js.map +1 -0
  48. package/dist/src/form/v2/create.color-picker.js +2 -0
  49. package/dist/src/form/v2/create.color-picker.js.map +1 -0
  50. package/dist/src/form/v2/create.date-expired.js +2 -0
  51. package/dist/src/form/v2/create.date-expired.js.map +1 -0
  52. package/dist/src/form/v2/create.date-picker.js +2 -0
  53. package/dist/src/form/v2/create.date-picker.js.map +1 -0
  54. package/dist/src/form/v2/create.input.js +2 -0
  55. package/dist/src/form/v2/create.input.js.map +1 -0
  56. package/dist/src/form/v2/create.select-simple.js +2 -0
  57. package/dist/src/form/v2/create.select-simple.js.map +1 -0
  58. package/dist/src/form/v2/create.select-with-api.js +2 -0
  59. package/dist/src/form/v2/create.select-with-api.js.map +1 -0
  60. package/dist/src/form/validator.js +1 -1
  61. package/dist/src/form/validator.js.map +1 -1
  62. package/dist/types/components/confirm-button.d.ts +30 -0
  63. package/dist/types/components/index.d.ts +1 -0
  64. package/dist/types/data-surface/view-list/types.d.ts +2 -0
  65. package/dist/types/filter-bar/components/filter-input.types.d.ts +2 -0
  66. package/dist/types/filter-bar/components/filter-sort.types.d.ts +2 -0
  67. package/dist/types/filter-bar/index.d.ts +1 -0
  68. package/dist/types/filter-bar/menu/create-form-field-string.d.ts +1 -0
  69. package/dist/types/filter-bar/menu/types.d.ts +2 -0
  70. package/dist/types/form/create.checkbox.d.ts +41 -0
  71. package/dist/types/form/create.form-base.d.ts +14 -0
  72. package/dist/types/form/create.input.d.ts +1 -0
  73. package/dist/types/form/create.input.file.d.ts +109 -9
  74. package/dist/types/form/create.select-simple.d.ts +1 -1
  75. package/dist/types/form/create.select-with-api.d.ts +3 -3
  76. package/dist/types/form/decorator.form.d.ts +17 -0
  77. package/dist/types/form/dino-form.d.ts +17 -6
  78. package/dist/types/form/helpers.d.ts +4 -4
  79. package/dist/types/form/index.d.ts +12 -0
  80. package/dist/types/form/v2/create.autocomplete.chips.d.ts +45 -0
  81. package/dist/types/form/v2/create.color-picker.d.ts +37 -0
  82. package/dist/types/form/v2/create.date-expired.d.ts +53 -0
  83. package/dist/types/form/v2/create.date-picker.d.ts +43 -0
  84. package/dist/types/form/v2/create.input.d.ts +36 -0
  85. package/dist/types/form/v2/create.select-simple.d.ts +84 -0
  86. package/dist/types/form/v2/create.select-with-api.d.ts +66 -0
  87. package/package.json +1 -1
  88. package/dist/src/form/create.input-file.csv-local-parser.js +0 -2
  89. package/dist/src/form/create.input-file.csv-local-parser.js.map +0 -1
  90. package/dist/src/form/create.input.image-file.js +0 -2
  91. package/dist/src/form/create.input.image-file.js.map +0 -1
  92. package/dist/types/form/create.input-file.csv-local-parser.d.ts +0 -66
  93. package/dist/types/form/create.input.image-file.d.ts +0 -20
@@ -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","minHeight","paddingTop","paddingBottom","paddingLeft","paddingRight","borderColor","borderWidth","palette","primary","main","opacity"],"mappings":"sqBAoDaA,EAAuB,CAClCC,KAAM,yBACNC,MAAO,0BACPC,MAAO,0BACPC,MAAO,0BACPC,QAAS,4BACTC,YAAa,iCAmBT,SAAUC,EACdC,GAAgC,IAE1BC,aAKJ,SAAAA,EAAYC,GAAgC,IAAAC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AAkBoB,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,EAAA,SAAA,WACAA,EAAA,MAAA,QACAA,EAAA,cAAA,gBACAA,EAAA,MAAA,QACAA,EAAA,OAAA,SACAA,EAAA,MAAA,QACAA,EAAA,YAAA,cACAA,EAAA,IAAA,MACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,QACD,CAZD,CAAYA,IAAAA,EAYX,CAAA,IAED,IAAMC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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,WACAA,EAAA,MAAA,QACAA,EAAA,cAAA,gBACAA,EAAA,MAAA,QACAA,EAAA,OAAA,SACAA,EAAA,MAAA,QACAA,EAAA,YAAA,cACAA,EAAA,IAAA,MACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,QACD,CAZD,CAAYA,IAAAA,EAYX,CAAA,IAED,IAAMC,EAAiB,CACrBC,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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';
@@ -38,6 +38,8 @@ export interface TListColumn<T> {
38
38
  field: keyof T;
39
39
  /** Column header label shown in the header. */
40
40
  label?: string;
41
+ /** If true, the column is visible in the list @default true */
42
+ visible?: boolean;
41
43
  /** Explicit column width. Accepts px number or CSS string (e.g. '120px', '20%'). */
42
44
  width?: number | string;
43
45
  /** Minimum column width in pixels. */
@@ -29,6 +29,8 @@ export type TFieldMatchConfigs<T> = Partial<Record<TFieldType<T>, Omit<TFieldMat
29
29
  export interface IFieldInputConfig<T> {
30
30
  field: TFieldType<T>;
31
31
  label?: string;
32
+ /** If true, the field is visible in the input menu @default true */
33
+ visible?: boolean;
32
34
  singleValue?: boolean;
33
35
  }
34
36
  export type TFieldInputConfigs<T> = Partial<Record<TFieldType<T>, Omit<IFieldInputConfig<T>, 'field'>>>;
@@ -9,6 +9,8 @@ export type FieldSortDirection = keyof typeof FieldSortDirection;
9
9
  export interface TFieldSort<T> {
10
10
  field: TFieldType<T>;
11
11
  label?: string;
12
+ /** If true, the field is visible in the sort menu @default true */
13
+ visible?: boolean;
12
14
  }
13
15
  export type TFieldSorts<T> = Partial<Record<TFieldType<T>, Omit<TFieldSort<T>, 'field'>>>;
14
16
  export interface IFilterSortSlots {
@@ -10,4 +10,5 @@ export * from './menu/create-form-field-datetime';
10
10
  export * from './menu/create-form-field-number';
11
11
  export * from './menu/create-form-field-select-with-api';
12
12
  export * from './menu/types';
13
+ export type { IFilterSortConfig } from './components/filter-sort.types';
13
14
  export { mergeValueToStoreFilter, mergeSingleValueToStoreFilter } from './hooks';
@@ -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.
@@ -10,6 +10,8 @@ export interface IFieldMenuConfig<T> {
10
10
  label?: string;
11
11
  /** Optional description for the field, shown as a subtitle in the menu and as tooltip in chip viewers */
12
12
  description?: string;
13
+ /** If true, the field is visible in the menu @default true */
14
+ visible?: boolean;
13
15
  /** If true, the form will only allow a single value to be added for the field */
14
16
  singleValue?: boolean;
15
17
  /** If true, the form will replace the existing value with the new value */
@@ -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;
@@ -3,16 +3,14 @@ export declare const getErrorMessage: <T>(MessageErrors: IPartialError<T> | unde
3
3
  type IModelBase = {
4
4
  [key: string]: any;
5
5
  };
6
- export declare const convertFormDataToJson: <T>(form: FormData) => Partial<T>;
6
+ export declare const convertFormDataToJson: <T>(form: FormData, formElement?: HTMLFormElement) => Partial<T>;
7
7
  export declare const trimAllStrings: <T>(obj: T) => Partial<T>;
8
8
  export declare const singleValidate: <T, TPartial = T>(key: keyof T, modelState: TPartial, MessageErrors: IPartialError<T>, Validator: FormValidator<TPartial>) => {
9
9
  [key: string]: any;
10
10
  } | null;
11
11
  export declare const clearFieldEmpty: <T>(model: Extract<T, IModelBase>) => void;
12
12
  export declare const validateMerge: <T>(...validateor: (FormValidator<T> | undefined)[]) => FormValidator<T>;
13
- /**
14
- * Interface representing the result of a CSV validation.
15
- */
13
+ /** Interface representing the result of a CSV validation. */
16
14
  export interface IValidateCsv {
17
15
  /** Indicates whether the CSV data is valid */
18
16
  valid: boolean;
@@ -30,4 +28,6 @@ interface IValidateCsvOptions {
30
28
  * @returns An object indicating whether the data is valid and an optional error message.
31
29
  */
32
30
  export declare const validateCsvModel: <T extends Record<string, any>>(data: T[], requiredKeys: (keyof T)[], options?: IValidateCsvOptions) => IValidateCsv;
31
+ export declare const isValueEqual: (val1: any, val2: any) => boolean;
32
+ export declare function isChanged<T extends Record<string, any>>(value: T, oldValue?: T): boolean;
33
33
  export {};
@@ -8,4 +8,16 @@ export type { InputBaseImage } from './create.input';
8
8
  export type { ISelectSimpleOption } from './create.select-simple';
9
9
  export * from './decorator';
10
10
  export * from './decorator.form';
11
+ export { default as createColorPickerV2 } from './v2/create.color-picker';
12
+ export * from './v2/create.color-picker';
13
+ export { default as createDatePickerV2 } from './v2/create.date-picker';
14
+ export * from './v2/create.date-picker';
15
+ export { default as createDateExpiredV2 } from './v2/create.date-expired';
16
+ export * from './v2/create.date-expired';
17
+ export { default as createAutocompleteChipV2 } from './v2/create.autocomplete.chips';
18
+ export * from './v2/create.autocomplete.chips';
19
+ export { default as createSelectSimpleV2 } from './v2/create.select-simple';
20
+ export * from './v2/create.select-simple';
21
+ export { default as createSelectWithApiV2 } from './v2/create.select-with-api';
22
+ export * from './v2/create.select-with-api';
11
23
  export { formGridLayoutClasses } from './create.form-grid-layout.units';