dinocollab-core 2.2.57 → 2.2.59

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 (135) hide show
  1. package/dist/components/index.js +1 -1
  2. package/dist/filter-bar/index.js +1 -1
  3. package/dist/form/index.js +1 -1
  4. package/dist/src/components/confirm-button.js +1 -1
  5. package/dist/src/components/confirm-button.js.map +1 -1
  6. package/dist/src/components/copy-to-clipboard.js +1 -1
  7. package/dist/src/components/copy-to-clipboard.js.map +1 -1
  8. package/dist/src/components/image-with-fallback.js +1 -1
  9. package/dist/src/components/image-with-fallback.js.map +1 -1
  10. package/dist/src/data-surface/index.create.js +1 -1
  11. package/dist/src/data-surface/index.create.js.map +1 -1
  12. package/dist/src/data-surface/types.js.map +1 -1
  13. package/dist/src/data-surface/ui.units.js +1 -1
  14. package/dist/src/data-surface/ui.units.js.map +1 -1
  15. package/dist/src/data-surface/view-grid/index.js +1 -1
  16. package/dist/src/data-surface/view-grid/index.js.map +1 -1
  17. package/dist/src/data-surface/view-list/column-selector.js +1 -1
  18. package/dist/src/data-surface/view-list/column-selector.js.map +1 -1
  19. package/dist/src/data-surface/view-list/helpers.js +1 -1
  20. package/dist/src/data-surface/view-list/helpers.js.map +1 -1
  21. package/dist/src/data-surface/view-list/hooks.js +1 -1
  22. package/dist/src/data-surface/view-list/hooks.js.map +1 -1
  23. package/dist/src/data-surface/view-list/index.js +1 -1
  24. package/dist/src/data-surface/view-list/index.js.map +1 -1
  25. package/dist/src/data-surface/view-list/types.js.map +1 -1
  26. package/dist/src/filter-bar/filter-input.js +1 -1
  27. package/dist/src/filter-bar/filter-input.js.map +1 -1
  28. package/dist/src/filter-bar/filter-input.types.js.map +1 -1
  29. package/dist/src/filter-bar/filter-input.units.js +1 -1
  30. package/dist/src/filter-bar/filter-input.units.js.map +1 -1
  31. package/dist/src/filter-bar/filter-menu.helpers.js +1 -1
  32. package/dist/src/filter-bar/filter-menu.helpers.js.map +1 -1
  33. package/dist/src/filter-bar/filter-menu.js +1 -1
  34. package/dist/src/filter-bar/filter-menu.js.map +1 -1
  35. package/dist/src/filter-bar/filter-summary.js +1 -1
  36. package/dist/src/filter-bar/filter-summary.js.map +1 -1
  37. package/dist/src/filter-bar/form-field/create-form-field-boolean.js +1 -1
  38. package/dist/src/filter-bar/form-field/create-form-field-boolean.js.map +1 -1
  39. package/dist/src/filter-bar/form-field/create-form-field-number.js +1 -1
  40. package/dist/src/filter-bar/form-field/create-form-field-number.js.map +1 -1
  41. package/dist/src/filter-bar/form-field/create-form-field-select-with-api.js +1 -1
  42. package/dist/src/filter-bar/form-field/create-form-field-select-with-api.js.map +1 -1
  43. package/dist/src/filter-bar/form-field/create-form-field-select.fallback.js +1 -1
  44. package/dist/src/filter-bar/form-field/create-form-field-select.fallback.js.map +1 -1
  45. package/dist/src/filter-bar/form-field/create-form-field-select.js +1 -1
  46. package/dist/src/filter-bar/form-field/create-form-field-select.js.map +1 -1
  47. package/dist/src/filter-bar/form-field/create-form-field-string.js +1 -1
  48. package/dist/src/filter-bar/form-field/create-form-field-string.js.map +1 -1
  49. package/dist/src/filter-bar/index.create.js +1 -1
  50. package/dist/src/filter-bar/index.create.js.map +1 -1
  51. package/dist/src/filter-bar/index.dino.js +1 -1
  52. package/dist/src/filter-bar/index.dino.js.map +1 -1
  53. package/dist/src/filter-bar/types.js.map +1 -1
  54. package/dist/src/form/create.form-base.js +1 -1
  55. package/dist/src/form/create.form-base.js.map +1 -1
  56. package/dist/src/form/create.form-confirm.js +2 -0
  57. package/dist/src/form/create.form-confirm.js.map +1 -0
  58. package/dist/src/form/create.form-grid-layout.js +1 -1
  59. package/dist/src/form/create.form-grid-layout.js.map +1 -1
  60. package/dist/src/form/create.form-grid-layout.units.js +1 -1
  61. package/dist/src/form/create.form-grid-layout.units.js.map +1 -1
  62. package/dist/src/form/create.input.object.js +1 -1
  63. package/dist/src/form/create.input.object.js.map +1 -1
  64. package/dist/src/form/create.input.object.styled.js +1 -1
  65. package/dist/src/form/create.input.object.styled.js.map +1 -1
  66. package/dist/src/form/create.input.object.units.js +2 -0
  67. package/dist/src/form/create.input.object.units.js.map +1 -0
  68. package/dist/src/form/decorator.form.js +1 -1
  69. package/dist/src/form/decorator.form.js.map +1 -1
  70. package/dist/src/form/decorator.units.js +1 -1
  71. package/dist/src/form/decorator.units.js.map +1 -1
  72. package/dist/src/form/dino-form.js +1 -1
  73. package/dist/src/form/dino-form.js.map +1 -1
  74. package/dist/src/form/error-handler.js +1 -1
  75. package/dist/src/form/error-handler.js.map +1 -1
  76. package/dist/src/form/v2/create.date-picker.js +1 -1
  77. package/dist/src/form/v2/create.date-picker.js.map +1 -1
  78. package/dist/src/form/v2/create.input.js +1 -1
  79. package/dist/src/form/v2/create.input.js.map +1 -1
  80. package/dist/src/form/v2/create.select-simple.js +1 -1
  81. package/dist/src/form/v2/create.select-simple.js.map +1 -1
  82. package/dist/src/form/validator.js +1 -1
  83. package/dist/src/form/validator.js.map +1 -1
  84. package/dist/src/form/validator.units.js +2 -0
  85. package/dist/src/form/validator.units.js.map +1 -0
  86. package/dist/src/table/create.table.js +1 -1
  87. package/dist/src/table/create.table.js.map +1 -1
  88. package/dist/src/table/dino.js +1 -1
  89. package/dist/src/table/dino.js.map +1 -1
  90. package/dist/src/table/table.error-panel.js +2 -0
  91. package/dist/src/table/table.error-panel.js.map +1 -0
  92. package/dist/table/index.js +1 -1
  93. package/dist/types/components/confirm-button.d.ts +7 -0
  94. package/dist/types/components/copy-to-clipboard.d.ts +2 -1
  95. package/dist/types/data-surface/index.create.d.ts +21 -6
  96. package/dist/types/data-surface/types.d.ts +1 -1
  97. package/dist/types/data-surface/ui.units.d.ts +2 -2
  98. package/dist/types/data-surface/view-list/column-selector.d.ts +2 -2
  99. package/dist/types/data-surface/view-list/helpers.d.ts +9 -4
  100. package/dist/types/data-surface/view-list/types.d.ts +32 -14
  101. package/dist/types/filter-bar/filter-input.types.d.ts +2 -2
  102. package/dist/types/filter-bar/filter-input.units.d.ts +6 -2
  103. package/dist/types/filter-bar/filter-menu.types.d.ts +2 -2
  104. package/dist/types/filter-bar/filter-summary.types.d.ts +2 -2
  105. package/dist/types/filter-bar/form-field/create-form-field-boolean.d.ts +1 -1
  106. package/dist/types/filter-bar/form-field/create-form-field-number.d.ts +1 -1
  107. package/dist/types/filter-bar/form-field/create-form-field-select-with-api.d.ts +1 -1
  108. package/dist/types/filter-bar/form-field/create-form-field-select.d.ts +1 -1
  109. package/dist/types/filter-bar/form-field/create-form-field-string.d.ts +1 -1
  110. package/dist/types/filter-bar/index.dino.d.ts +6 -6
  111. package/dist/types/filter-bar/types.d.ts +4 -2
  112. package/dist/types/form/create.form-confirm.d.ts +33 -0
  113. package/dist/types/form/create.form-grid-layout.d.ts +15 -5
  114. package/dist/types/form/create.form-grid-layout.units.d.ts +15 -1
  115. package/dist/types/form/create.input.object.d.ts +15 -57
  116. package/dist/types/form/create.input.object.styled.d.ts +5 -0
  117. package/dist/types/form/create.input.object.units.d.ts +88 -0
  118. package/dist/types/form/decorator.units.d.ts +3 -1
  119. package/dist/types/form/dino-form.d.ts +2 -2
  120. package/dist/types/form/error-handler.d.ts +34 -4
  121. package/dist/types/form/index.d.ts +4 -1
  122. package/dist/types/form/v2/create.date-picker.d.ts +3 -3
  123. package/dist/types/form/v2/create.input.d.ts +42 -3
  124. package/dist/types/form/v2/create.select-simple.d.ts +1 -1
  125. package/dist/types/form/validator.d.ts +3 -52
  126. package/dist/types/form/validator.units.d.ts +65 -0
  127. package/dist/types/table/create.table.d.ts +7 -2
  128. package/dist/types/table/dino.d.ts +1 -0
  129. package/dist/types/table/index.d.ts +1 -0
  130. package/dist/types/table/table.error-panel.d.ts +7 -0
  131. package/dist/types/table/types.d.ts +2 -0
  132. package/package.json +1 -1
  133. package/dist/src/form/create.form-comfirm.js +0 -2
  134. package/dist/src/form/create.form-comfirm.js.map +0 -1
  135. package/dist/types/form/create.form-comfirm.d.ts +0 -20
@@ -1,2 +1,2 @@
1
- import{defineProperty as e,inherits as t,createClass as r,objectSpread2 as i,classCallCheck as o,callSuper as n,objectWithoutProperties as a,asyncToGenerator as l,regenerator as s}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as p,jsx as d,Fragment as u}from"react/jsx-runtime";import{Component as c}from"react";import{styled as h,Box as m,TextField as f,Typography as g,Collapse as v,FormHelperText as b,InputAdornment as x,Tooltip as S,IconButton as y,CircularProgress as k}from"@mui/material";import I from"@mui/icons-material/ContentPaste";import{mergeObjects as C}from"../../utils/helpers.js";import"../../utils/dayjs-config.js";import"../../utils/query-param.js";import{getErrorMessage as P}from"../helpers.js";import{ImageWithFallback as j}from"../../components/image-with-fallback.js";import{RichTooltip as z,HelpOutlinePulseIcon as w}from"../../components/rich-tooltip.js";var L=["src","element","alt","fallbackSrc","debounceDelay"],M=function(h){return function(){function f(t){var r,c;return o(this,f),c=n(this,f,[t]),e(c,"_cachedSlots",{}),e(c,"mapTextFieldProps",function(){var e,t,r,o,n,a=P(c.props.messageErrors,c.props.name),l={fullWidth:!0,variant:"outlined",name:null===(e=c.props.name)||void 0===e?void 0:e.toString(),error:a.error,disabled:c.props.disabled,onBlur:function(){c.props.name&&c.props.checkValidateField&&c.props.checkValidateField(c.props.name)},placeholder:null!==(t=c.props.placeholder)&&void 0!==t?t:c.slots.placeholder,value:null!==(r=c.state.value)&&void 0!==r?r:"",onChange:c.handleChange};return l.InputProps||(l.InputProps={}),(c.slots.pastenable||c.slots.tooltip)&&(l.InputProps.endAdornment=p(x,{position:"end",children:[c.slots.pastenable&&d(S,{title:"Paste from clipboard",placement:"top",arrow:!0,children:d(y,{onClick:c.handlePaste,edge:"end",size:"small",children:d(I,{fontSize:"inherit"})})}),c.slots.tooltip&&d(z,{panel:c.slots.tooltip,children:d(w,{fontSize:"small"})})]})),null!==(o=c.slots)&&void 0!==o&&o.maxLength&&(l.inputProps=i(i({},l.inputProps),{},{maxLength:c.slots.maxLength})),C({},l,null===(n=c.slots)||void 0===n?void 0:n.textFieldProps)}),e(c,"renderImageSide",function(e){var t="left"===e?c.slots.imageLeft:c.slots.imageRight;if(!t)return d(u,{});var r=t.src,o=t.element,n=t.alt,l=void 0===n?"input-image":n,s=t.fallbackSrc,p=void 0===s?"":s,h=t.debounceDelay,m=void 0===h?700:h,f=a(t,L);if(o)return d(W,{children:d(o,{value:c.state.value,model:c.props.data})});var g="function"==typeof r?r(c.state.value,c.props.data):null!=r?r:c.state.value,b={src:g,alt:l,fallbackSrc:p,debounceDelay:m};return d(v,{sx:{mx:"10px"},in:!!g,unmountOnExit:!0,orientation:"horizontal",children:d(W,{children:d(j,i(i(i({},f),b),{},{loading:d(O,{})}))})})}),e(c,"mergeSlots",function(e){var t=C({},h,e),r=t.imageLeft,o=t.imageRight;return null!=r&&r.mirror&&!o?(t.imageRight=i({},r),delete t.imageRight.mirror):null!=o&&o.mirror&&!r&&(t.imageLeft=i({},o),delete t.imageLeft.mirror),t}),e(c,"handleChange",function(e){c.setState({value:e.target.value})}),e(c,"handlePaste",l(s().m(function e(){var t,r;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,navigator.clipboard.readText();case 1:t=e.v,c.setState({value:t}),e.n=3;break;case 2:e.p=2,r=e.v,console.error("Error clipboard:",r);case 3:return e.a(2)}},e,null,[[0,2]])}))),c._cachedSlots=null!==(r=c.mergeSlots(t.slots))&&void 0!==r?r:{},c.state={value:c.defaulValue},c}return t(f,c),r(f,[{key:"slots",get:function(){return this._cachedSlots}},{key:"defaulValue",get:function(){var e,t,r=this.props,i=r.data,o=r.name;return null!==(e=i&&o?null===(t=i[o])||void 0===t?void 0:t.toString():void 0)&&void 0!==e?e:this.props.defaultValue}},{key:"label",get:function(){var e,t,r;if(this.props.label)return null!==(e=this.slots)&&void 0!==e&&e.maxLength?"".concat(this.props.label," (").concat(null!==(t=null===(r=this.state.value)||void 0===r?void 0:r.length)&&void 0!==t?t:0,"/").concat(this.slots.maxLength,")"):this.props.label.toString()}},{key:"componentDidUpdate",value:function(e){e.slots!==this.props.slots&&(this._cachedSlots=this.mergeSlots(this.props.slots))}},{key:"shouldComponentUpdate",value:function(e){var t=this.props,r=t.name;t.slots;if(r){var i,o,n,a,l=null!==(i=null===(o=this.props.data)||void 0===o||null===(o=o[r])||void 0===o?void 0:o.toString())&&void 0!==i?i:"",s=null!==(n=null===(a=e.data)||void 0===a||null===(a=a[r])||void 0===a?void 0:a.toString())&&void 0!==n?n:"";if(l!==s)return this.setState({value:s}),!1}return e.slots,!0}},{key:"render",value:function(){var e,t=this.label,r=this.mapTextFieldProps(),o=r.error?"error.main":"text.primary";return p(V,{className:R.root,children:[t&&d(g,{className:R.label,variant:"subtitle2",sx:{fontWeight:600,color:o},children:t}),p(m,{sx:{display:"flex",alignItems:"center"},children:[!!this.props.disabled&&d("input",{hidden:!0,name:null===(e=this.props.name)||void 0===e?void 0:e.toString(),defaultValue:this.defaulValue}),this.renderImageSide("left"),d(D,i({},r)),this.renderImageSide("right")]}),d(v,{in:!!r.error,unmountOnExit:!0,children:d(b,{error:!0,sx:{mt:.5,fontWeight:500,color:"error.main"},children:P(this.props.messageErrors,this.props.name).message})})]})}}])}()},O=function(){return d("div",{children:d(k,{size:24})})},R={root:"DinoInput-root",label:"DinoInput-label"},V=h(m)(function(t){var r=t.theme;return e({},".".concat(R.label),{display:"flex",alignItems:"center",marginBottom:r.spacing(.5),height:"var(--dino-height-input-label, 21px)"})}),D=h(f)(function(e){var t=e.theme;return{"& .MuiOutlinedInput-root":{borderRadius:"10px",backgroundColor:"#ffffff",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",transition:"all 0.2s ease-in-out","& fieldset":{borderColor:"#cbd5e1",borderWidth:"1px"},"&:hover fieldset":{borderColor:"#94a3b8"},"&.Mui-focused fieldset":{borderColor:t.palette.primary.main,borderWidth:"1.5px"},"&.Mui-error fieldset":{borderColor:t.palette.error.main},"&.MuiInputBase-multiline":{height:"auto",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",padding:"8px 14px",".MuiInputAdornment-root":{alignSelf:"center"},".MuiOutlinedInput-input":{padding:0,flex:1,minHeight:"0"}}},"& .MuiOutlinedInput-input":{padding:"10.5px 14px",fontSize:"0.875rem",color:t.palette.text.primary,"&::placeholder":{color:"#94a3b8",opacity:1}},"& .MuiOutlinedInput-inputMultiline":{padding:"0 !important"}}}),W=h(m)({fontSize:"1rem",height:"var(--input-base-image-size, 42px)",width:"var(--input-base-image-size, 42px)",position:"relative",borderRadius:"8px",boxShadow:"rgba(0, 0, 0, 0.16) 0px 1px 4px",overflow:"hidden",flexShrink:0,"& > img":{position:"absolute",top:0,left:0,backgroundRepeat:"no-repeat",height:"100%",width:"100%",backgroundSize:"contain"},"& > div":{position:"absolute",top:0,left:0,height:"100%",width:"100%",background:"#fafafa",zIndex:1,display:"flex",alignItems:"center",justifyContent:"center"}});export{M as default,R as inputClasses};
1
+ import{defineProperty as e,inherits as t,createClass as i,typeof as o,objectSpread2 as r,classCallCheck as n,callSuper as a,objectWithoutProperties as l,asyncToGenerator as s,regenerator as d}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as p,jsx as u,Fragment as c}from"react/jsx-runtime";import{Component as h}from"react";import{styled as m,Box as v,TextField as f,Typography as g,Switch as b,Collapse as x,FormHelperText as S,InputAdornment as k,Tooltip as C,IconButton as w,CircularProgress as y}from"@mui/material";import I from"@mui/icons-material/ContentPaste";import{mergeObjects as P}from"../../utils/helpers.js";import"../../utils/dayjs-config.js";import"../../utils/query-param.js";import{getErrorMessage as j}from"../helpers.js";import{ImageWithFallback as L}from"../../components/image-with-fallback.js";import{RichTooltip as E,HelpOutlinePulseIcon as z}from"../../components/rich-tooltip.js";var D=["src","element","alt","fallbackSrc","debounceDelay","wrapProps"],M=function(m){return function(){function f(t){var i,o;return n(this,f),o=a(this,f,[t]),e(o,"_cachedSlots",{}),e(o,"resolveInitialSwitchChecked",function(){var e,t,i,r,n,a=o.props,l=a.data,s=a.name,d=a.switchChecked,p=a.switchCheckedGetter,u=null===(e=o.slots)||void 0===e?void 0:e.switchChecked,c=null!==(t=null===(i=o.slots)||void 0===i?void 0:i.switchCheckedGetter)&&void 0!==t?t:p,h=null!==(r=l&&s?null===(n=l[s])||void 0===n?void 0:n.toString():void 0)&&void 0!==r?r:o.props.defaultValue;if(c)return c(h,l);var m=null!=d?d:u;return void 0!==m?m:void 0!==h&&""!==h}),e(o,"mapTextFieldProps",function(){var e,t,i,n,a,l,s=j(o.props.messageErrors,o.props.name),d=o.isEffectiveDisabled,c=o.isSwitchable&&!o.state.switchChecked,h={fullWidth:!0,variant:"outlined",name:c||null===(e=o.props.name)||void 0===e?void 0:e.toString(),error:s.error,disabled:d,onBlur:function(){o.props.name&&o.props.checkValidateField&&o.props.checkValidateField(o.props.name)},placeholder:null!==(t=o.props.placeholder)&&void 0!==t?t:o.slots.placeholder,value:c?"":null!==(i=o.state.value)&&void 0!==i?i:"",onChange:o.handleChange},m=null!==(n=o.props.endInput)&&void 0!==n?n:o.slots.endInput,f="function"==typeof m?m({disabled:d,value:o.state.value}):m;return Boolean(o.slots.pastenable||o.slots.tooltip||f)&&(h.InputProps||(h.InputProps={}),h.InputProps.endAdornment=p(k,{position:"end",sx:{pointerEvents:"auto",display:"flex",alignItems:"center",gap:.5},children:[o.slots.pastenable&&!d&&u(C,{title:"Paste from clipboard",placement:"top",arrow:!0,children:u(w,{onClick:o.handlePaste,edge:"end",size:"small",children:u(I,{fontSize:"inherit"})})}),o.slots.tooltip&&u(v,{sx:{display:"inline-flex",pointerEvents:"auto"},children:u(E,{panel:o.slots.tooltip,children:u(z,{fontSize:"small",color:"primary"})})}),f&&u(v,{sx:{display:"inline-flex",pointerEvents:"auto"},children:f})]})),null!==(a=o.slots)&&void 0!==a&&a.maxLength&&(h.inputProps=r(r({},h.inputProps),{},{maxLength:o.slots.maxLength})),P({},h,null===(l=o.slots)||void 0===l?void 0:l.textFieldProps)}),e(o,"renderImageSide",function(e){var t="left"===e?o.slots.imageLeft:o.slots.imageRight;if(!t)return u(c,{});var i=t.src,n=t.element,a=t.alt,s=void 0===a?"input-image":a,d=t.fallbackSrc,p=void 0===d?"":d,h=t.debounceDelay,m=void 0===h?700:h,v=t.wrapProps,f=l(t,D),g=r(r({},v),{},{sx:r({aspectRatio:"1/1"},null==v?void 0:v.sx)});if(n){var b,S=n;return u(O,r(r({},g),{},{children:u(S,{value:o.state.value,model:o.props.data,modelState:null===(b=o.props.formContext)||void 0===b?void 0:b.modelState})}))}var k,C=void 0;"function"==typeof i?C=i(o.state.value,o.props.data,null===(k=o.props.formContext)||void 0===k?void 0:k.modelState):C=null!=i?i:o.state.value;var w={src:C,alt:s,fallbackSrc:p,debounceDelay:m};return u(x,{sx:{mx:"10px"},in:!!C,unmountOnExit:!0,orientation:"horizontal",children:u(O,r(r({},g),{},{children:u(L,r(r(r({},f),w),{},{loading:u(V,{})}))}))})}),e(o,"mergeSlots",function(e){var t=P({},m,e),i=t.imageLeft,o=t.imageRight;return null!=i&&i.mirror&&!o?(t.imageRight=r({},i),delete t.imageRight.mirror):null!=o&&o.mirror&&!i&&(t.imageLeft=r({},o),delete t.imageLeft.mirror),t}),e(o,"handleChange",function(e){var t,i=e.target.value,r=null===(t=o.slots)||void 0===t?void 0:t.maxLength,n=r&&r>0?i.slice(0,r):i;n!==o.state.value?o.setState({value:n},function(){o.props.onChange&&o.props.onChange(n)}):e.target.value!==n&&(e.target.value=n)}),e(o,"handleSwitchChange",function(e){o.setState({switchChecked:e},function(){var t,i=e&&null!==(t=o.state.value)&&void 0!==t?t:"";o.props.onChange&&o.props.onChange(i);var r=o.props,n=r.name,a=r.checkValidateField;n&&a&&a(n)})}),e(o,"handlePaste",s(d().m(function e(){var t,i,r,n,a;return d().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,navigator.clipboard.readText();case 1:if(i=e.v,r=null===(t=o.slots)||void 0===t?void 0:t.maxLength,(n=r&&r>0?i.slice(0,r):i)!==o.state.value){e.n=2;break}return e.a(2);case 2:o.setState({value:n},function(){o.props.onChange&&o.props.onChange(n),o.props.name&&o.props.checkValidateField&&o.props.checkValidateField(o.props.name)}),e.n=4;break;case 3:e.p=3,a=e.v,console.error("Error clipboard:",a);case 4:return e.a(2)}},e,null,[[0,3]])}))),o._cachedSlots=null!==(i=o.mergeSlots(t.slots))&&void 0!==i?i:{},o.state={value:o.defaulValue,switchChecked:o.resolveInitialSwitchChecked()},o.id="dino-input-"+Math.random().toString(36).substring(2,9),o}return t(f,h),i(f,[{key:"slots",get:function(){return this._cachedSlots}},{key:"isSwitchable",get:function(){return!0===this.props.switchable||!0===this.slots.switchable}},{key:"isEffectiveDisabled",get:function(){return!!this.props.disabled||!(!this.isSwitchable||this.state.switchChecked)}},{key:"switchLabelText",get:function(){var e,t,i,r=null!==(e=this.props.switchLabel)&&void 0!==e?e:this.slots.switchLabel;return"string"==typeof r?r:r&&"object"===o(r)?this.state.switchChecked?null!==(t=r.on)&&void 0!==t?t:"Enabled":null!==(i=r.off)&&void 0!==i?i:"Disabled":this.state.switchChecked?"Enabled":"Disabled"}},{key:"defaulValue",get:function(){var e,t,i=this.props,o=i.data,r=i.name;return null!==(e=o&&r?null===(t=o[r])||void 0===t?void 0:t.toString():void 0)&&void 0!==e?e:this.props.defaultValue}},{key:"label",get:function(){var e,t,i;if(this.props.label)return null!==(e=this.slots)&&void 0!==e&&e.maxLength?"".concat(this.props.label," (").concat(null!==(t=null===(i=this.state.value)||void 0===i?void 0:i.length)&&void 0!==t?t:0,"/").concat(this.slots.maxLength,")"):this.props.label.toString()}},{key:"componentDidUpdate",value:function(e){e.slots!==this.props.slots&&(this._cachedSlots=this.mergeSlots(this.props.slots))}},{key:"shouldComponentUpdate",value:function(e,t){if(this.state.switchChecked!==t.switchChecked)return!0;if(this.state.value!==t.value)return!0;var i=this.props,o=i.name;i.slots;if(o){var r,n,a,l,s=null!==(r=null===(n=this.props.data)||void 0===n||null===(n=n[o])||void 0===n?void 0:n.toString())&&void 0!==r?r:"",d=null!==(a=null===(l=e.data)||void 0===l||null===(l=l[o])||void 0===l?void 0:l.toString())&&void 0!==a?a:"";if(s!==d)return this.setState({value:d}),!1}return e.slots,!0}},{key:"render",value:function(){var e,t,i=this,o=this.label,n=this.mapTextFieldProps(),a=n.error?"error.main":"text.primary",l=this.isSwitchable,s=l&&!this.state.switchChecked;return p(F,{className:W.root,children:[(o||l)&&p(v,{className:W.labelWrapper,children:[u(v,{sx:{display:"flex",alignItems:"center",gap:1},children:o&&u(g,{className:W.label,variant:"subtitle2",sx:{fontWeight:600,color:a},children:o})}),l&&p(v,{className:W.control,sx:{display:"flex",alignItems:"center",gap:1},children:[u(g,{variant:"caption",className:W.labelSwitch,htmlFor:this.id,component:"label",sx:{fontWeight:600,cursor:"pointer",color:this.state.switchChecked?"primary.main":"text.secondary"},children:this.switchLabelText}),u(b,r({id:this.id,size:"small",color:"primary",checked:this.state.switchChecked,disabled:this.props.disabled,onChange:function(e,t){return i.handleSwitchChange(t)}},this.slots.switchProps))]})]}),p(v,{sx:{display:"flex",alignItems:"center"},children:[s&&u("input",{type:"hidden",name:null===(e=this.props.name)||void 0===e?void 0:e.toString(),value:""}),!!this.props.disabled&&!s&&u("input",{type:"hidden",name:null===(t=this.props.name)||void 0===t?void 0:t.toString(),defaultValue:this.defaulValue}),this.renderImageSide("left"),u(R,r({},n)),this.renderImageSide("right")]}),u(x,{in:!!n.error,unmountOnExit:!0,children:u(S,{error:!0,sx:{mt:.5,fontWeight:500,color:"error.main"},children:j(this.props.messageErrors,this.props.name).message})})]})}}])}()},V=function(){return u("div",{children:u(y,{size:24})})},W={root:"DinoInput-root",labelWrapper:"DinoInput-labelWrapper",label:"DinoInput-label",control:"DinoInput-control",labelSwitch:"DinoInput-labelSwitch"},F=m(v)(function(t){var i=t.theme;return e(e({},".".concat(W.labelWrapper),{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:i.spacing(.5),minHeight:"var(--dino-height-input-label, 21px)"}),".".concat(W.label),{display:"flex",alignItems:"center"})}),R=m(f)(function(e){var t=e.theme;return{"& .MuiOutlinedInput-root":{borderRadius:"10px",backgroundColor:"#ffffff",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",transition:"all 0.2s ease-in-out","& fieldset":{borderColor:"#cbd5e1",borderWidth:"1px"},"&:hover fieldset":{borderColor:"#94a3b8"},"&.Mui-focused fieldset":{borderColor:t.palette.primary.main,borderWidth:"1.5px"},"&.Mui-error fieldset":{borderColor:t.palette.error.main},"&.Mui-disabled":{backgroundColor:"#f8fafc","& fieldset":{borderColor:"#e2e8f0"},"& .MuiInputAdornment-root":{pointerEvents:"auto",color:"inherit",cursor:"default","& *":{pointerEvents:"auto"}}},"&.MuiInputBase-multiline":{height:"auto",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",padding:"8px 14px",".MuiInputAdornment-root":{alignSelf:"center"},".MuiOutlinedInput-input":{padding:0,flex:1,minHeight:"0"}}},"& .MuiOutlinedInput-input":{padding:"10.5px 14px",fontSize:"0.875rem",color:t.palette.text.primary,"&::placeholder":{color:"#94a3b8",opacity:1}},"& .MuiOutlinedInput-inputMultiline":{padding:"0 !important"}}}),O=m(v)({fontSize:"1rem",height:"var(--input-base-image-size, 42px)",width:"auto",position:"relative",borderRadius:"8px",boxShadow:"rgba(0, 0, 0, 0.16) 0px 1px 4px",overflow:"hidden",flexShrink:0,"& > img":{position:"absolute",top:0,left:0,backgroundRepeat:"no-repeat",height:"100%",width:"100%",backgroundSize:"contain"},"& > div":{position:"absolute",top:0,left:0,height:"100%",width:"100%",background:"#fafafa",zIndex:1,display:"flex",alignItems:"center",justifyContent:"center"}});export{M as default,W as inputClasses};
2
2
  //# sourceMappingURL=create.input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.input.js","sources":["../../../../src/form/v2/create.input.tsx"],"sourcesContent":["import React, { Component, ComponentType, FC } from 'react'\nimport { styled, TextField, TextFieldProps, Tooltip, Typography } from '@mui/material'\nimport { Box, CircularProgress, Collapse, FormHelperText, IconButton, InputAdornment } from '@mui/material'\nimport ContentPasteIcon from '@mui/icons-material/ContentPaste'\nimport { mergeObjects } from '../../utils'\nimport { IFormInputBase } from './../types'\nimport { getErrorMessage } from './../helpers'\nimport { ImageWithFallback, IImageWithFallbackPropsOwner } from '../../components/image-with-fallback'\nimport { IRichTooltipPanelConfig, RichTooltip, HelpOutlinePulseIcon } from '../../components/rich-tooltip'\n\nexport interface InputBaseImage<T> extends Omit<Partial<IImageWithFallbackPropsOwner>, 'src'> {\n src?: string | ((value: any, model?: Partial<T>) => string | undefined)\n element?: React.ComponentType<{ value: any; model?: Partial<T> }>\n mirror?: boolean\n}\n\nexport interface IInputSlots<T> {\n maxLength?: number\n placeholder?: string\n textFieldProps?: TextFieldProps\n pastenable?: boolean\n imageLeft?: InputBaseImage<T>\n imageRight?: InputBaseImage<T>\n tooltip?: IRichTooltipPanelConfig\n}\n\nexport interface IInputProps<T> extends IFormInputBase<T, IInputSlots<T>> {}\n\nexport interface IInputState {\n value?: string\n}\n\nexport interface IInputParams<T> extends IInputSlots<T> {}\n\nconst createInput = function <T>(params?: IInputParams<T>): ComponentType<IInputProps<T>> {\n class InputBase extends Component<IInputProps<T>, IInputState> {\n private _cachedSlots: IInputSlots<T> = {}\n constructor(props: IInputProps<T>) {\n super(props)\n this._cachedSlots = this.mergeSlots(props.slots) ?? {}\n this.state = { value: this.defaulValue }\n }\n\n get slots() {\n return this._cachedSlots\n }\n\n get defaulValue(): string {\n const { data, name } = this.props\n return (!!data && !!name ? data[name]?.toString() : undefined) ?? this.props.defaultValue\n }\n\n get label(): string | undefined {\n if (!this.props.label) return undefined\n if (!this.slots?.maxLength) return this.props.label.toString()\n return `${this.props.label} (${this.state.value?.length ?? 0}/${this.slots.maxLength})`\n }\n\n componentDidUpdate(prevProps: IInputProps<T>) {\n if (prevProps.slots !== this.props.slots) {\n this._cachedSlots = this.mergeSlots(this.props.slots)\n }\n }\n\n shouldComponentUpdate(nextProps: Readonly<IInputProps<T>>): boolean {\n const { name, slots } = this.props\n if (!!name) {\n const currentDataValue = this.props.data?.[name]?.toString() ?? ''\n const nextDataValue = nextProps.data?.[name]?.toString() ?? ''\n if (currentDataValue !== nextDataValue) {\n this.setState({ value: nextDataValue })\n return false\n }\n }\n\n if (slots !== nextProps.slots) {\n return true\n }\n return true\n }\n\n mapTextFieldProps = (): TextFieldProps => {\n const errorMessage = getErrorMessage(this.props.messageErrors, this.props.name)\n const tfp: TextFieldProps = {\n fullWidth: true,\n variant: 'outlined',\n name: this.props.name?.toString(),\n error: errorMessage.error,\n disabled: this.props.disabled,\n onBlur: () => {\n if (!this.props.name) return\n this.props.checkValidateField && this.props.checkValidateField(this.props.name)\n },\n placeholder: this.props.placeholder ?? this.slots.placeholder,\n value: this.state.value ?? '',\n onChange: this.handleChange\n }\n if (!tfp.InputProps) tfp.InputProps = {}\n if (this.slots.pastenable || this.slots.tooltip) {\n tfp.InputProps.endAdornment = (\n <InputAdornment position='end'>\n {this.slots.pastenable && (\n <Tooltip title='Paste from clipboard' placement='top' arrow>\n <IconButton onClick={this.handlePaste} edge='end' size='small'>\n <ContentPasteIcon fontSize='inherit' />\n </IconButton>\n </Tooltip>\n )}\n {this.slots.tooltip && (\n <RichTooltip panel={this.slots.tooltip}>\n <HelpOutlinePulseIcon fontSize='small' />\n </RichTooltip>\n )}\n </InputAdornment>\n )\n }\n if (this.slots?.maxLength) tfp.inputProps = { ...tfp.inputProps, maxLength: this.slots.maxLength }\n return mergeObjects<TextFieldProps>({}, tfp, this.slots?.textFieldProps)\n }\n\n //#region Render\n render() {\n const labelText = this.label\n const tfProps = this.mapTextFieldProps()\n const titleColor = tfProps.error ? 'error.main' : 'text.primary'\n\n return (\n <RootStyled className={inputClasses.root}>\n {/* Label at Top (synchronized with createInputFile) */}\n {labelText && (\n <Typography className={inputClasses.label} variant='subtitle2' sx={{ fontWeight: 600, color: titleColor }}>\n {labelText}\n </Typography>\n )}\n\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n {!!this.props.disabled && <input hidden name={this.props.name?.toString()} defaultValue={this.defaulValue} />}\n {this.renderImageSide('left')}\n <StyledTextField {...tfProps} />\n {this.renderImageSide('right')}\n </Box>\n\n <Collapse in={!!tfProps.error} unmountOnExit>\n <FormHelperText error sx={{ mt: 0.5, fontWeight: 500, color: 'error.main' }}>\n {getErrorMessage(this.props.messageErrors, this.props.name).message}\n </FormHelperText>\n </Collapse>\n </RootStyled>\n )\n }\n\n renderImageSide = (side: 'left' | 'right') => {\n const image = side === 'left' ? this.slots.imageLeft : this.slots.imageRight\n if (!image) return <></>\n const { src, element, alt = 'input-image', fallbackSrc = '', debounceDelay = 700, ...imageOther } = image\n if (element) {\n const Element = element\n return (\n <WrapImage>\n <Element value={this.state.value} model={this.props.data} />\n </WrapImage>\n )\n }\n const finalSrc = typeof src === 'function' ? src(this.state.value, this.props.data) : (src ?? this.state.value)\n const imageProps: IImageWithFallbackPropsOwner = { src: finalSrc, alt, fallbackSrc, debounceDelay }\n return (\n <Collapse sx={{ mx: '10px' }} in={!!finalSrc} unmountOnExit orientation='horizontal'>\n <WrapImage>\n <ImageWithFallback {...imageOther} {...imageProps} loading={<LoadingCircularProgress />} />\n </WrapImage>\n </Collapse>\n )\n }\n //#endregion\n\n private mergeSlots = (currentSlots?: IInputSlots<T>): IInputSlots<T> => {\n const base = mergeObjects<IInputSlots<T>>({}, params, currentSlots)\n const { imageLeft, imageRight } = base\n\n // mirror from left to right\n if (imageLeft?.mirror && !imageRight) {\n base.imageRight = { ...imageLeft }\n delete base.imageRight.mirror\n }\n // mirror from right to left\n else if (imageRight?.mirror && !imageLeft) {\n base.imageLeft = { ...imageRight }\n delete base.imageLeft.mirror\n }\n\n return base\n }\n\n handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n this.setState({ value: event.target.value })\n }\n\n handlePaste = async () => {\n try {\n const clipboardText = await navigator.clipboard.readText()\n this.setState({ value: clipboardText })\n } catch (error) {\n console.error('Error clipboard:', error)\n }\n }\n }\n return InputBase\n}\n\nexport default createInput\n\nconst LoadingCircularProgress: FC = () => (\n <div>\n <CircularProgress size={24} />\n </div>\n)\n\nexport const inputClasses = {\n root: 'DinoInput-root',\n label: 'DinoInput-label',\n input: 'DinoInput-input'\n}\n\nconst RootStyled = styled(Box)(({ theme }) => ({\n [`.${inputClasses.label}`]: {\n display: 'flex',\n alignItems: 'center',\n marginBottom: theme.spacing(0.5),\n height: 'var(--dino-height-input-label, 21px)'\n }\n}))\n\nconst StyledTextField = styled(TextField)(({ theme }) => ({\n '& .MuiOutlinedInput-root': {\n borderRadius: '10px',\n backgroundColor: '#ffffff',\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 '&.MuiInputBase-multiline': {\n height: 'auto',\n minHeight: 'var(--dino-min-height-input, 42px)',\n boxSizing: 'border-box',\n padding: '8px 14px',\n // alignItems: 'flex-start',\n '.MuiInputAdornment-root': { alignSelf: 'center' },\n '.MuiOutlinedInput-input': { padding: 0, flex: 1, minHeight: '0' }\n }\n },\n '& .MuiOutlinedInput-input': {\n padding: '10.5px 14px',\n fontSize: '0.875rem',\n color: theme.palette.text.primary,\n '&::placeholder': { color: '#94a3b8', opacity: 1 }\n },\n '& .MuiOutlinedInput-inputMultiline': {\n padding: '0 !important'\n }\n}))\n\nconst WrapImage = styled(Box)({\n fontSize: '1rem',\n height: 'var(--input-base-image-size, 42px)',\n width: 'var(--input-base-image-size, 42px)',\n position: 'relative',\n borderRadius: '8px',\n boxShadow: 'rgba(0, 0, 0, 0.16) 0px 1px 4px',\n overflow: 'hidden',\n flexShrink: 0,\n '& > img': {\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundRepeat: 'no-repeat',\n height: '100%',\n width: '100%',\n backgroundSize: 'contain'\n },\n '& > div': {\n position: 'absolute',\n top: 0,\n left: 0,\n height: '100%',\n width: '100%',\n background: '#fafafa',\n zIndex: 1,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center'\n }\n})\n"],"names":["createInput","params","InputBase","props","_this$mergeSlots","_this","_classCallCheck","_callSuper","_defineProperty","_this$props$name","_this$props$placehold","_this$state$value","_this$slots","_this$slots2","errorMessage","getErrorMessage","messageErrors","name","tfp","fullWidth","variant","toString","error","disabled","onBlur","checkValidateField","placeholder","slots","value","state","onChange","handleChange","InputProps","pastenable","tooltip","endAdornment","_jsxs","InputAdornment","position","_jsx","Tooltip","title","placement","arrow","children","IconButton","onClick","handlePaste","edge","size","ContentPasteIcon","fontSize","RichTooltip","panel","HelpOutlinePulseIcon","maxLength","inputProps","_objectSpread","mergeObjects","textFieldProps","side","image","imageLeft","imageRight","src","element","_image$alt","alt","_image$fallbackSrc","fallbackSrc","_image$debounceDelay","debounceDelay","imageOther","_objectWithoutProperties","_excluded","WrapImage","model","data","finalSrc","imageProps","Collapse","sx","mx","in","unmountOnExit","orientation","ImageWithFallback","loading","LoadingCircularProgress","currentSlots","base","mirror","event","setState","target","_asyncToGenerator","_regenerator","m","_callee","clipboardText","_t","w","_context","p","n","navigator","clipboard","readText","v","console","a","_cachedSlots","mergeSlots","defaulValue","_inherits","Component","_createClass","key","get","this","_ref2","_data$name","_this$props","undefined","defaultValue","_this$slots3","_this$state$value$len","_this$state$value2","label","concat","length","prevProps","nextProps","_this$props2","_this$props$data$name","_this$props$data","_nextProps$data$name$","_nextProps$data","currentDataValue","nextDataValue","_this$props$name2","labelText","tfProps","mapTextFieldProps","titleColor","RootStyled","className","inputClasses","root","Typography","fontWeight","color","Box","display","alignItems","hidden","renderImageSide","StyledTextField","FormHelperText","mt","message","CircularProgress","styled","_ref3","theme","marginBottom","spacing","height","TextField","_ref5","borderRadius","backgroundColor","minHeight","boxSizing","transition","borderColor","borderWidth","palette","primary","main","padding","alignSelf","flex","text","opacity","width","boxShadow","overflow","flexShrink","top","left","backgroundRepeat","backgroundSize","background","zIndex","justifyContent"],"mappings":"i8BAkCMA,EAAc,SAAaC,GA4K/B,kBAzKE,SAAAC,EAAYC,GAAqB,IAAAC,EAAAC,EAGS,OAHTC,OAAAJ,GAC/BG,EAAAE,EAAAL,KAAAA,GAAMC,IAAMK,EAAAH,EAFyB,eAAA,IAAEG,EAAAH,EAAA,oBA6CrB,WAAqB,IAAAI,EAAAC,EAAAC,EAAAC,EAAAC,EACjCC,EAAeC,EAAgBV,EAAKF,MAAMa,cAAeX,EAAKF,MAAMc,MACpEC,EAAsB,CAC1BC,WAAW,EACXC,QAAS,WACTH,KAAqB,QAAjBR,EAAEJ,EAAKF,MAAMc,YAAXR,IAAeA,OAAfA,EAAAA,EAAiBY,WACvBC,MAAOR,EAAaQ,MACpBC,SAAUlB,EAAKF,MAAMoB,SACrBC,OAAQ,WACDnB,EAAKF,MAAMc,MAChBZ,EAAKF,MAAMsB,oBAAsBpB,EAAKF,MAAMsB,mBAAmBpB,EAAKF,MAAMc,KAC3E,EACDS,YAAmChB,QAAxBA,EAAEL,EAAKF,MAAMuB,uBAAWhB,EAAAA,EAAIL,EAAKsB,MAAMD,YAClDE,MAAuBjB,QAAlBA,EAAEN,EAAKwB,MAAMD,aAAKjB,IAAAA,EAAAA,EAAI,GAC3BmB,SAAUzB,EAAK0B,cAsBjB,OApBKb,EAAIc,aAAYd,EAAIc,WAAa,CAAE,IACpC3B,EAAKsB,MAAMM,YAAc5B,EAAKsB,MAAMO,WACtChB,EAAIc,WAAWG,aACbC,EAACC,EAAc,CAACC,SAAS,gBACtBjC,EAAKsB,MAAMM,YACVM,EAACC,EAAQ,CAAAC,MAAM,uBAAuBC,UAAU,MAAMC,OAAK,EAAAC,SACzDL,EAACM,EAAU,CAACC,QAASzC,EAAK0C,YAAaC,KAAK,MAAMC,KAAK,QAAOL,SAC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kB,YAClBxB,OAAQ,OACRkB,MAAO,OACPO,eAAgB,WAElB,UAAW,CACT1J,SAAU,WACVuJ,IAAK,EACLC,KAAM,EACNvB,OAAQ,OACRkB,MAAO,OACPQ,WAAY,UACZC,OAAQ,EACRzC,QAAS,OACTC,WAAY,SACZyC,eAAgB"}
1
+ {"version":3,"file":"create.input.js","sources":["../../../../src/form/v2/create.input.tsx"],"sourcesContent":["import React, { Component, ComponentType, FC, ReactNode } from 'react'\nimport { BoxProps, styled, TextField, TextFieldProps, Tooltip, Typography } from '@mui/material'\nimport { Box, CircularProgress, Collapse, FormHelperText, IconButton, InputAdornment, Switch, SwitchProps } from '@mui/material'\nimport ContentPasteIcon from '@mui/icons-material/ContentPaste'\nimport { mergeObjects } from '../../utils'\nimport { IFormInputBase } from './../types'\nimport { getErrorMessage } from './../helpers'\nimport { ImageWithFallback, IImageWithFallbackPropsOwner } from '../../components/image-with-fallback'\nimport { IRichTooltipPanelConfig, RichTooltip, HelpOutlinePulseIcon } from '../../components/rich-tooltip'\n\nexport interface InputBaseImage<T> extends Omit<Partial<IImageWithFallbackPropsOwner>, 'src'> {\n src?: string | ((value: any, model?: Partial<T>, modelState?: Partial<T>) => string | undefined)\n element?: React.ComponentType<{ value: any; model?: Partial<T>; modelState?: Partial<T> }>\n mirror?: boolean\n wrapProps?: BoxProps\n}\n\nexport interface IInputSlots<T> {\n maxLength?: number\n placeholder?: string\n textFieldProps?: TextFieldProps\n pastenable?: boolean\n imageLeft?: InputBaseImage<T>\n imageRight?: InputBaseImage<T>\n tooltip?: IRichTooltipPanelConfig\n /** Custom end input slot that remains active even when the input is disabled */\n endInput?: ReactNode | ((context: { disabled: boolean; value?: string }) => ReactNode)\n /** Enable switch to toggle input active state @default false */\n switchable?: boolean\n /** Controlled initial state of the switch */\n switchChecked?: boolean\n /** Custom getter to derive switch checked state from data model */\n switchCheckedGetter?: (value: any, model?: Partial<T>) => boolean\n /** Custom props passed to MUI Switch */\n switchProps?: SwitchProps\n /** Custom label for switch toggle @default { on: 'Enabled', off: 'Disabled' } */\n switchLabel?: string | { on?: string; off?: string }\n}\n\nexport interface IInputProps<T> extends IFormInputBase<T, IInputSlots<T>> {\n onChange?: (value: string) => void\n endInput?: ReactNode | ((context: { disabled: boolean; value?: string }) => ReactNode)\n switchable?: boolean\n switchChecked?: boolean\n switchCheckedGetter?: (value: any, model?: Partial<T>) => boolean\n switchProps?: SwitchProps\n switchLabel?: string | { on?: string; off?: string }\n}\n\nexport interface IInputState {\n value?: string\n switchChecked: boolean\n}\n\nexport interface IInputParams<T> extends IInputSlots<T> {}\n\nconst createInput = function <T>(params?: IInputParams<T>): ComponentType<IInputProps<T>> {\n class InputBase extends Component<IInputProps<T>, IInputState> {\n private _cachedSlots: IInputSlots<T> = {}\n private id: string\n\n constructor(props: IInputProps<T>) {\n super(props)\n this._cachedSlots = this.mergeSlots(props.slots) ?? {}\n this.state = {\n value: this.defaulValue,\n switchChecked: this.resolveInitialSwitchChecked()\n }\n this.id = 'dino-input-' + Math.random().toString(36).substring(2, 9)\n }\n\n get slots() {\n return this._cachedSlots\n }\n\n get isSwitchable(): boolean {\n return this.props.switchable === true || this.slots.switchable === true\n }\n\n get isEffectiveDisabled(): boolean {\n if (this.props.disabled) return true\n if (this.isSwitchable && !this.state.switchChecked) return true\n return false\n }\n\n get switchLabelText(): string {\n const customLabel = this.props.switchLabel ?? this.slots.switchLabel\n if (typeof customLabel === 'string') return customLabel\n if (customLabel && typeof customLabel === 'object') {\n return this.state.switchChecked ? (customLabel.on ?? 'Enabled') : (customLabel.off ?? 'Disabled')\n }\n return this.state.switchChecked ? 'Enabled' : 'Disabled'\n }\n\n get defaulValue(): string {\n const { data, name } = this.props\n return (!!data && !!name ? data[name]?.toString() : undefined) ?? this.props.defaultValue\n }\n\n get label(): string | undefined {\n if (!this.props.label) return undefined\n if (!this.slots?.maxLength) return this.props.label.toString()\n return `${this.props.label} (${this.state.value?.length ?? 0}/${this.slots.maxLength})`\n }\n\n private resolveInitialSwitchChecked = (): boolean => {\n const { data, name, switchChecked, switchCheckedGetter } = this.props\n const slotSwitchChecked = this.slots?.switchChecked\n const slotGetter = this.slots?.switchCheckedGetter ?? switchCheckedGetter\n const dValue = (!!data && !!name ? data[name]?.toString() : undefined) ?? this.props.defaultValue\n\n if (slotGetter) {\n return slotGetter(dValue, data)\n }\n const effective = switchChecked ?? slotSwitchChecked\n if (effective !== undefined) return effective\n\n return dValue !== undefined && dValue !== ''\n }\n\n componentDidUpdate(prevProps: IInputProps<T>) {\n if (prevProps.slots !== this.props.slots) {\n this._cachedSlots = this.mergeSlots(this.props.slots)\n }\n }\n\n shouldComponentUpdate(nextProps: Readonly<IInputProps<T>>, nextState: Readonly<IInputState>): boolean {\n if (this.state.switchChecked !== nextState.switchChecked) return true\n if (this.state.value !== nextState.value) return true\n\n const { name, slots } = this.props\n if (!!name) {\n const currentDataValue = this.props.data?.[name]?.toString() ?? ''\n const nextDataValue = nextProps.data?.[name]?.toString() ?? ''\n if (currentDataValue !== nextDataValue) {\n this.setState({ value: nextDataValue })\n return false\n }\n }\n\n if (slots !== nextProps.slots) {\n return true\n }\n return true\n }\n\n mapTextFieldProps = (): TextFieldProps => {\n const errorMessage = getErrorMessage(this.props.messageErrors, this.props.name)\n const disabled = this.isEffectiveDisabled\n const isSwitchOff = this.isSwitchable && !this.state.switchChecked\n\n const tfp: TextFieldProps = {\n fullWidth: true,\n variant: 'outlined',\n name: isSwitchOff ? undefined : this.props.name?.toString(),\n error: errorMessage.error,\n disabled: disabled,\n onBlur: () => {\n if (!this.props.name) return\n this.props.checkValidateField && this.props.checkValidateField(this.props.name)\n },\n placeholder: this.props.placeholder ?? this.slots.placeholder,\n value: isSwitchOff ? '' : (this.state.value ?? ''),\n onChange: this.handleChange\n }\n\n const endInputProp = this.props.endInput ?? this.slots.endInput\n const endInputNode = typeof endInputProp === 'function' ? endInputProp({ disabled, value: this.state.value }) : endInputProp\n\n const hasEndContent = Boolean(this.slots.pastenable || this.slots.tooltip || endInputNode)\n if (hasEndContent) {\n if (!tfp.InputProps) tfp.InputProps = {}\n tfp.InputProps.endAdornment = (\n <InputAdornment position='end' sx={{ pointerEvents: 'auto', display: 'flex', alignItems: 'center', gap: 0.5 }}>\n {this.slots.pastenable && !disabled && (\n <Tooltip title='Paste from clipboard' placement='top' arrow>\n <IconButton onClick={this.handlePaste} edge='end' size='small'>\n <ContentPasteIcon fontSize='inherit' />\n </IconButton>\n </Tooltip>\n )}\n {this.slots.tooltip && (\n <Box sx={{ display: 'inline-flex', pointerEvents: 'auto' }}>\n <RichTooltip panel={this.slots.tooltip}>\n <HelpOutlinePulseIcon fontSize='small' color='primary' />\n </RichTooltip>\n </Box>\n )}\n {endInputNode && <Box sx={{ display: 'inline-flex', pointerEvents: 'auto' }}>{endInputNode}</Box>}\n </InputAdornment>\n )\n }\n if (this.slots?.maxLength) tfp.inputProps = { ...tfp.inputProps, maxLength: this.slots.maxLength }\n return mergeObjects<TextFieldProps>({}, tfp, this.slots?.textFieldProps)\n }\n\n //#region Render\n render() {\n const labelText = this.label\n const tfProps = this.mapTextFieldProps()\n const titleColor = tfProps.error ? 'error.main' : 'text.primary'\n const isSwitchable = this.isSwitchable\n const isSwitchOff = isSwitchable && !this.state.switchChecked\n\n return (\n <RootStyled className={inputClasses.root}>\n {/* Header Row: Label on Left, Switch on Right (if switchable) */}\n {(labelText || isSwitchable) && (\n <Box className={inputClasses.labelWrapper}>\n <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>\n {labelText && (\n <Typography className={inputClasses.label} variant='subtitle2' sx={{ fontWeight: 600, color: titleColor }}>\n {labelText}\n </Typography>\n )}\n </Box>\n\n {isSwitchable && (\n <Box className={inputClasses.control} sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>\n <Typography\n variant='caption'\n className={inputClasses.labelSwitch}\n htmlFor={this.id}\n component='label'\n sx={{\n fontWeight: 600,\n cursor: 'pointer',\n color: this.state.switchChecked ? 'primary.main' : 'text.secondary'\n }}\n >\n {this.switchLabelText}\n </Typography>\n <Switch\n id={this.id}\n size='small'\n color='primary'\n checked={this.state.switchChecked}\n disabled={this.props.disabled}\n onChange={(_, checked) => this.handleSwitchChange(checked)}\n {...this.slots.switchProps}\n />\n </Box>\n )}\n </Box>\n )}\n\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n {/* When switch is off, submit empty string for form */}\n {isSwitchOff && <input type='hidden' name={this.props.name?.toString()} value='' />}\n {/* When component is disabled via prop, preserve default value */}\n {!!this.props.disabled && !isSwitchOff && <input type='hidden' name={this.props.name?.toString()} defaultValue={this.defaulValue} />}\n {this.renderImageSide('left')}\n <StyledTextField {...tfProps} />\n {this.renderImageSide('right')}\n </Box>\n\n <Collapse in={!!tfProps.error} unmountOnExit>\n <FormHelperText error sx={{ mt: 0.5, fontWeight: 500, color: 'error.main' }}>\n {getErrorMessage(this.props.messageErrors, this.props.name).message}\n </FormHelperText>\n </Collapse>\n </RootStyled>\n )\n }\n\n renderImageSide = (side: 'left' | 'right') => {\n const image = side === 'left' ? this.slots.imageLeft : this.slots.imageRight\n if (!image) return <></>\n const { src, element, alt = 'input-image', fallbackSrc = '', debounceDelay = 700, wrapProps, ...imageOther } = image\n const props = { ...wrapProps, sx: { aspectRatio: '1/1', ...wrapProps?.sx } }\n if (element) {\n const Element = element\n return (\n <WrapImage {...props}>\n <Element value={this.state.value} model={this.props.data} modelState={this.props.formContext?.modelState} />\n </WrapImage>\n )\n }\n\n let finalSrc: string | undefined = undefined\n if (typeof src === 'function') {\n finalSrc = src(this.state.value, this.props.data, this.props.formContext?.modelState)\n } else finalSrc = src ?? this.state.value\n\n const imageProps: IImageWithFallbackPropsOwner = { src: finalSrc, alt, fallbackSrc, debounceDelay }\n return (\n <Collapse sx={{ mx: '10px' }} in={!!finalSrc} unmountOnExit orientation='horizontal'>\n <WrapImage {...props}>\n <ImageWithFallback {...imageOther} {...imageProps} loading={<LoadingCircularProgress />} />\n </WrapImage>\n </Collapse>\n )\n }\n //#endregion\n\n private mergeSlots = (currentSlots?: IInputSlots<T>): IInputSlots<T> => {\n const base = mergeObjects<IInputSlots<T>>({}, params, currentSlots)\n const { imageLeft, imageRight } = base\n\n // mirror from left to right\n if (imageLeft?.mirror && !imageRight) {\n base.imageRight = { ...imageLeft }\n delete base.imageRight.mirror\n }\n // mirror from right to left\n else if (imageRight?.mirror && !imageLeft) {\n base.imageLeft = { ...imageRight }\n delete base.imageLeft.mirror\n }\n\n return base\n }\n\n handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const rawValue = event.target.value\n const maxLength = this.slots?.maxLength\n const nextValue = maxLength && maxLength > 0 ? rawValue.slice(0, maxLength) : rawValue\n if (nextValue === this.state.value) {\n if (event.target.value !== nextValue) {\n event.target.value = nextValue\n }\n return\n }\n this.setState({ value: nextValue }, () => {\n if (this.props.onChange) this.props.onChange(nextValue)\n })\n }\n\n handleSwitchChange = (checked: boolean) => {\n this.setState({ switchChecked: checked }, () => {\n const nextValue = checked ? (this.state.value ?? '') : ''\n if (this.props.onChange) this.props.onChange(nextValue)\n const { name, checkValidateField } = this.props\n if (name && checkValidateField) {\n checkValidateField(name)\n }\n })\n }\n\n handlePaste = async () => {\n try {\n const clipboardText = await navigator.clipboard.readText()\n const maxLength = this.slots?.maxLength\n const nextValue = maxLength && maxLength > 0 ? clipboardText.slice(0, maxLength) : clipboardText\n if (nextValue === this.state.value) return\n this.setState({ value: nextValue }, () => {\n if (this.props.onChange) this.props.onChange(nextValue)\n if (this.props.name && this.props.checkValidateField) {\n this.props.checkValidateField(this.props.name)\n }\n })\n } catch (error) {\n console.error('Error clipboard:', error)\n }\n }\n }\n return InputBase\n}\n\nexport default createInput\n\nconst LoadingCircularProgress: FC = () => (\n <div>\n <CircularProgress size={24} />\n </div>\n)\n\nexport const inputClasses = {\n root: 'DinoInput-root',\n labelWrapper: 'DinoInput-labelWrapper',\n label: 'DinoInput-label',\n control: 'DinoInput-control',\n labelSwitch: 'DinoInput-labelSwitch',\n switch: 'DinoInput-switch',\n input: 'DinoInput-input'\n}\n\nconst RootStyled = styled(Box)(({ theme }) => ({\n [`.${inputClasses.labelWrapper}`]: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n marginBottom: theme.spacing(0.5),\n minHeight: 'var(--dino-height-input-label, 21px)'\n },\n [`.${inputClasses.label}`]: {\n display: 'flex',\n alignItems: 'center'\n }\n}))\n\nconst StyledTextField = styled(TextField)(({ theme }) => ({\n '& .MuiOutlinedInput-root': {\n borderRadius: '10px',\n backgroundColor: '#ffffff',\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 '&.Mui-disabled': {\n backgroundColor: '#f8fafc',\n '& fieldset': { borderColor: '#e2e8f0' },\n '& .MuiInputAdornment-root': {\n pointerEvents: 'auto',\n color: 'inherit',\n cursor: 'default',\n '& *': { pointerEvents: 'auto' }\n }\n },\n '&.MuiInputBase-multiline': {\n height: 'auto',\n minHeight: 'var(--dino-min-height-input, 42px)',\n boxSizing: 'border-box',\n padding: '8px 14px',\n '.MuiInputAdornment-root': { alignSelf: 'center' },\n '.MuiOutlinedInput-input': { padding: 0, flex: 1, minHeight: '0' }\n }\n },\n '& .MuiOutlinedInput-input': {\n padding: '10.5px 14px',\n fontSize: '0.875rem',\n color: theme.palette.text.primary,\n '&::placeholder': { color: '#94a3b8', opacity: 1 }\n },\n '& .MuiOutlinedInput-inputMultiline': {\n padding: '0 !important'\n }\n}))\n\nconst WrapImage = styled(Box)({\n fontSize: '1rem',\n height: 'var(--input-base-image-size, 42px)',\n // width: 'var(--input-base-image-size, 42px)',\n width: 'auto',\n // aspectRatio: '1/1',\n position: 'relative',\n borderRadius: '8px',\n boxShadow: 'rgba(0, 0, 0, 0.16) 0px 1px 4px',\n overflow: 'hidden',\n flexShrink: 0,\n '& > img': {\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundRepeat: 'no-repeat',\n height: '100%',\n width: '100%',\n backgroundSize: 'contain'\n },\n '& > div': {\n position: 'absolute',\n top: 0,\n left: 0,\n height: '100%',\n width: '100%',\n background: '#fafafa',\n zIndex: 1,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center'\n }\n})\n"],"names":["createInput","params","InputBase","props","_this$mergeSlots","_this","_classCallCheck","_callSuper","_defineProperty","_this$slots","_this$slots$switchChe","_this$slots2","_ref","_data$name","_this$props","data","name","switchChecked","switchCheckedGetter","slotSwitchChecked","slots","slotGetter","dValue","toString","undefined","defaultValue","effective","_this$props$name","_this$props$placehold","_this$state$value","_this$props$endInput","_this$slots3","_this$slots4","errorMessage","getErrorMessage","messageErrors","disabled","isEffectiveDisabled","isSwitchOff","isSwitchable","state","tfp","fullWidth","variant","error","onBlur","checkValidateField","placeholder","value","onChange","handleChange","endInputProp","endInput","endInputNode","Boolean","pastenable","tooltip","InputProps","endAdornment","_jsxs","InputAdornment","position","sx","pointerEvents","display","alignItems","gap","children","_jsx","Tooltip","title","placement","arrow","IconButton","onClick","handlePaste","edge","size","ContentPasteIcon","fontSize","Box","RichTooltip","panel","HelpOutlinePulseIcon","color","maxLength","inputProps","_objectSpread","mergeObjects","textFieldProps","side","image","imageLeft","imageRight","src","element","_image$alt","alt","_image$fallbackSrc","fallbackSrc","_image$debounceDelay","debounceDelay","wrapProps","imageOther","_objectWithoutProperties","_excluded","aspectRatio","_this$props$formConte","Element","WrapImage","model","modelState","formContext","_this$props$formConte2","finalSrc","imageProps","Collapse","mx","in","unmountOnExit","orientation","ImageWithFallback","loading","LoadingCircularProgress","currentSlots","base","mirror","event","_this$slots5","rawValue","target","nextValue","slice","setState","checked","_this$state$value2","_this$props2","_asyncToGenerator","_regenerator","m","_callee","_this$slots6","clipboardText","_t","w","_context","p","n","navigator","clipboard","readText","v","a","console","_cachedSlots","mergeSlots","defaulValue","resolveInitialSwitchChecked","id","Math","random","substring","_inherits","Component","_createClass","key","get","this","switchable","_this$props$switchLab","_customLabel$on","_customLabel$off","customLabel","switchLabel","_typeof","on","off","_ref3","_data$name2","_this$props3","_this$slots7","_this$state$value$len","_this$state$value3","label","concat","length","prevProps","nextProps","nextState","_this$props4","_this$props$data$name","_this$props$data","_nextProps$data$name$","_nextProps$data","currentDataValue","nextDataValue","_this$props$name2","_this$props$name3","_this2","labelText","tfProps","mapTextFieldProps","titleColor","RootStyled","className","inputClasses","root","labelWrapper","Typography","fontWeight","control","labelSwitch","htmlFor","component","cursor","switchLabelText","Switch","_","handleSwitchChange","switchProps","type","renderImageSide","StyledTextField","FormHelperText","mt","message","CircularProgress","styled","_ref4","theme","justifyContent","marginBottom","spacing","minHeight","TextField","_ref6","borderRadius","backgroundColor","boxSizing","transition","borderColor","borderWidth","palette","primary","main","height","padding","alignSelf","flex","text","opacity","width","boxShadow","overflow","flexShrink","top","left","backgroundRepeat","backgroundSize","background","zIndex"],"mappings":"q+BAwDMA,EAAc,SAAaC,GA4S/B,kBAvSE,SAAAC,EAAYC,GAAqB,IAAAC,EAAAC,EAOqC,OAPrCC,OAAAJ,GAC/BG,EAAAE,EAAAL,KAAAA,GAAMC,IAAMK,EAAAH,EAJyB,eAAA,IAAEG,EAAAH,EAAA,8BA+CH,WAAc,IAAAI,EAAAC,EAAAC,EAAAC,EAAAC,EAClDC,EAA2DT,EAAKF,MAAxDY,EAAID,EAAJC,KAAMC,EAAIF,EAAJE,KAAMC,EAAaH,EAAbG,cAAeC,EAAmBJ,EAAnBI,oBAC7BC,EAA8B,QAAbV,EAAGJ,EAAKe,aAAK,IAAAX,OAAA,EAAVA,EAAYQ,cAChCI,EAA4C,QAAlCX,EAAa,QAAbC,EAAGN,EAAKe,aAALT,IAAUA,OAAVA,EAAAA,EAAYO,2BAAmBR,IAAAA,EA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BAA4B,CAC1BsL,OAAQ,OACRZ,UAAW,qCACXK,UAAW,aACXQ,QAAS,WACT,0BAA2B,CAAEC,UAAW,UACxC,0BAA2B,CAAED,QAAS,EAAGE,KAAM,EAAGf,UAAW,OAGjE,4BAA6B,CAC3Ba,QAAS,cACTvK,SAAU,WACVK,MAAOiJ,EAAMa,QAAQO,KAAKN,QAC1B,iBAAkB,CAAE/J,MAAO,UAAWsK,QAAS,IAEjD,qCAAsC,CACpCJ,QAAS,gBAEZ,GAEKzI,EAAYsH,EAAOnJ,EAAPmJ,CAAY,CAC5BpJ,SAAU,OACVsK,OAAQ,qCAERM,MAAO,OAEP9L,SAAU,WACV+K,aAAc,MACdgB,UAAW,kCACXC,SAAU,SACVC,WAAY,EACZ,UAAW,CACTjM,SAAU,WACVkM,IAAK,EACLC,KAAM,EACNC,iBAAkB,YAClBZ,OAAQ,OACRM,MAAO,OACPO,eAAgB,WAElB,UAAW,CACTrM,SAAU,WACVkM,IAAK,EACLC,KAAM,EACNX,OAAQ,OACRM,MAAO,OACPQ,WAAY,UACZC,OAAQ,EACRpM,QAAS,OACTC,WAAY,SACZqK,eAAgB"}
@@ -1,2 +1,2 @@
1
- import{defineProperty as e,objectSpread2 as o,inherits as t,createClass as l,classCallCheck as r,callSuper as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as n,jsxs as a}from"react/jsx-runtime";import{Fragment as s,Component as p}from"react";import{styled as d,Box as u,Typography as c,alpha as v,Select as h,MenuItem as m,Collapse as f,FormHelperText as g}from"@mui/material";import{mergeObjects as b}from"../../utils/helpers.js";import{getErrorMessage as S}from"../helpers.js";import{RichTooltip as x,HelpOutlinePulseIcon as C}from"../../components/rich-tooltip.js";function y(e){var o,t,l;return null!==(o=null!==(t=e.label)&&void 0!==t?t:null===(l=e.value)||void 0===l?void 0:l.toString())&&void 0!==o?o:""}var W={root:"DinoSelectSimple-root",label:"DinoSelectSimple-label",select:"DinoSelectSimple-select",selectHeader:"DinoSelectSimple-selectHeader",placeholder:"DinoSelectSimple-placeholder",tooltipWrap:"DinoSelectSimple-tooltipWrap",small:"DinoSelectSimple-small",tooltip:"DinoSelectSimple-tooltip",endAdornment:"DinoSelectSimple-endAdornment"};function D(d){return function(){function u(o){var t;return r(this,u),t=i(this,u,[o]),e(t,"mapProps",function(){var e,o,l,r,i,a,s,p=t.getOptions(),u=null!==(e=t.state.value)&&void 0!==e?e:"",v=S(t.props.messageErrors,t.props.name),h={id:null===(o=t.props.name)||void 0===o?void 0:o.toString(),name:null===(l=t.props.name)||void 0===l?void 0:l.toString(),value:u,error:v.error,displayEmpty:!0,renderValue:function(e){if(!e)return n(c,{className:W.placeholder,sx:{color:"#94a3b8",fontSize:"0.875rem"},children:t.placeholderText});var o=p.find(function(o){var t;return(null===(t=o.value)||void 0===t?void 0:t.toString())===e});return o?y(o):e},onChange:function(e){var o=e.target.value+"";t.setState({value:o},function(){t.props.name&&t.props.checkValidateField&&t.props.checkValidateField(t.props.name);var e=p.find(function(e){var t;return(null===(t=e.value)||void 0===t?void 0:t.toString())===o});e&&t.props.onChange&&t.props.onChange(e)})},disabled:t.props.disabled,fullWidth:void 0===t.props.fullWidth||t.props.fullWidth,endAdornment:null!==(r=null!==(i=t.props.endAdornment)&&void 0!==i?i:null==d?void 0:d.endAdornment)&&void 0!==r?r:void 0,MenuProps:{PaperProps:{sx:P}}},m=null!==(a=null===(s=t.props.slots)||void 0===s?void 0:s.selectProps)&&void 0!==a?a:null==d?void 0:d.selectProps;return b({},h,m)}),e(t,"renderTooltip",function(){var e=t.props.tooltip||(null==d?void 0:d.tooltip);return e?n("div",{className:W.tooltipWrap,children:n(x,{panel:e,children:n(C,{fontSize:"small"})})}):null}),e(t,"getRootClasses",function(){var e,o,l,r=[W.root];return(t.props.tooltip||(null==d?void 0:d.tooltip))&&r.push(W.tooltip),(t.props.endAdornment||null!=d&&d.endAdornment)&&r.push(W.endAdornment),"small"===(null!==(e=null===(o=t.props.slots)||void 0===o||null===(o=o.selectProps)||void 0===o?void 0:o.size)&&void 0!==e?e:null==d||null===(l=d.selectProps)||void 0===l?void 0:l.size)&&r.push(W.small),r.join(" ")}),e(t,"getDefaultValue",function(e){var o,l,r,i,n,a,s,p=null!=e?e:t.props,u=p.data,c=p.name,v=null!==(o=null===(l=p.defaultValue)||void 0===l?void 0:l.toString())&&void 0!==o?o:u&&c?null===(r=u[c])||void 0===r?void 0:r.toString():void 0;return null!=v&&""!==v?v:(null!==(i=null===(n=p.slots)||void 0===n?void 0:n.autoSelectFirst)&&void 0!==i?i:null==d?void 0:d.autoSelectFirst)&&null!==(a=null===(s=t.getOptions()[0])||void 0===s||null===(s=s.value)||void 0===s?void 0:s.toString())&&void 0!==a?a:""}),e(t,"getOptions",function(){var e,o;return null!==(e=null!==(o=null==d?void 0:d.options)&&void 0!==o?o:t.props.options)&&void 0!==e?e:[]}),t.state={value:t.getDefaultValue()},t}return t(u,p),l(u,[{key:"label",get:function(){return this.props.label&&"string"==typeof this.props.label?this.props.label:this.props.name?this.props.name.toString():""}},{key:"placeholderText",get:function(){return this.props.placeholder?this.props.placeholder:null!=d&&d.placeholder?d.placeholder:this.label?"Select a ".concat(this.label):"Select an option"}},{key:"shouldComponentUpdate",value:function(e){var o=this.getDefaultValue(),t=this.getDefaultValue(e);return o===t||t===this.state.value||(this.setState({value:t}),!1)}},{key:"render",value:function(){var e,t,l=this.getOptions(),r=S(this.props.messageErrors,this.props.name),i=r.error?"error.main":"text.primary";return a(s,{children:[!!this.props.disabled&&n("input",{hidden:!0,name:null===(e=this.props.name)||void 0===e?void 0:e.toString(),defaultValue:this.state.value}),a(k,o(o(o({className:this.getRootClasses()},null==d?void 0:d.wrapProps),null===(t=this.props.slots)||void 0===t?void 0:t.wrapProps),{},{children:[this.label&&n(c,{className:W.label,variant:"subtitle2",sx:{fontWeight:600,mb:.5,color:i},children:this.label}),a(h,o(o({className:W.select,variant:"outlined"},this.mapProps()),{},{children:[this.placeholderText&&n(z,{className:W.selectHeader,children:this.placeholderText}),l.map(function(e){var o;return n(m,{value:e.value,children:y(e)},null===(o=e.value)||void 0===o?void 0:o.toString())})]})),n(f,{in:r.error,unmountOnExit:!0,children:n(g,{error:!0,sx:{mt:.5,fontWeight:500,color:"error.main"},children:r.message})}),this.renderTooltip()]}))]})}}])}()}var P={borderRadius:"12px",mt:.8,boxShadow:"rgba(0, 0, 0, 0.08) 0px 4px 20px 0px",border:"1px solid #e2e8f0",padding:"4px","& .MuiMenuItem-root":{borderRadius:"8px",margin:"2px 4px",fontSize:"0.875rem",fontWeight:500,color:"#1e293b",transition:"all 0.15s ease-in-out","&:hover":{backgroundColor:"#f1f5f9"},"&.Mui-selected":{backgroundColor:"#f3f0ff",color:"#6366f1",fontWeight:600,"&:hover":{backgroundColor:"#e0e7ff"}}}},k=d(u)(function(o){var t=o.theme;return e(e(e(e({position:"relative"},".".concat(W.label),{display:"flex",alignItems:"center",marginBottom:t.spacing(.5),height:"var(--dino-height-input-label, 21px)"}),"& .MuiOutlinedInput-root",{borderRadius:"10px",backgroundColor:"#ffffff",height:"var(--dino-min-height-input, 42px)",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",transition:"all 0.2s ease-in-out","& fieldset":{borderColor:"#cbd5e1",borderWidth:"1px"},"&:hover fieldset":{borderColor:"#94a3b8"},"&.Mui-focused fieldset":{borderColor:t.palette.primary.main,borderWidth:"1.5px"},"&.Mui-error fieldset":{borderColor:t.palette.error.main}}),".MuiSelect-select",{padding:t.spacing(0,1.5),height:"100%",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",fontSize:"0.875rem",color:t.palette.text.primary,display:"flex",alignItems:"center"}),".".concat(W.tooltipWrap),{position:"absolute",top:t.spacing(4.2),right:t.spacing(1.5),display:"flex",alignItems:"center",gap:t.spacing(.5)})}),z=d(function(e){return n(c,o({component:"div"},e))})(function(e){var o=e.theme;return{pointerEvents:"none",cursor:"default",userSelect:"none",color:v(o.palette.text.secondary,.3),fontWeight:600,fontSize:"0.8125rem",padding:o.spacing(1,2),marginTop:o.spacing(-1)}});export{D as createSelectSimple,D as default,y as getOptionDisplayLabel,W as selectSimpleClasses};
1
+ import{defineProperty as e,objectSpread2 as o,inherits as t,createClass as l,classCallCheck as r,callSuper as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as n,jsxs as a}from"react/jsx-runtime";import{Fragment as s,Component as p}from"react";import{styled as d,Box as u,Typography as c,alpha as v,Select as h,MenuItem as m,Collapse as f,FormHelperText as g}from"@mui/material";import{getErrorMessage as b}from"../helpers.js";import{mergeObjects as S}from"../../utils/helpers.js";import{RichTooltip as x,HelpOutlinePulseIcon as C}from"../../components/rich-tooltip.js";function y(e){var o,t,l;return null!==(o=null!==(t=e.label)&&void 0!==t?t:null===(l=e.value)||void 0===l?void 0:l.toString())&&void 0!==o?o:""}var W={root:"DinoSelectSimple-root",label:"DinoSelectSimple-label",select:"DinoSelectSimple-select",selectHeader:"DinoSelectSimple-selectHeader",placeholder:"DinoSelectSimple-placeholder",tooltipWrap:"DinoSelectSimple-tooltipWrap",small:"DinoSelectSimple-small",tooltip:"DinoSelectSimple-tooltip",endAdornment:"DinoSelectSimple-endAdornment"};function D(d){return function(){function u(o){var t;return r(this,u),t=i(this,u,[o]),e(t,"mapProps",function(){var e,o,l,r,i,a,s,p=t.getOptions(),u=null!==(e=t.state.value)&&void 0!==e?e:"",v=b(t.props.messageErrors,t.props.name),h={id:null===(o=t.props.name)||void 0===o?void 0:o.toString(),name:null===(l=t.props.name)||void 0===l?void 0:l.toString(),value:u,error:v.error,displayEmpty:!0,renderValue:function(e){if(!e)return n(c,{className:W.placeholder,sx:{color:"#94a3b8",fontSize:"0.875rem"},children:t.placeholderText});var o=p.find(function(o){var t;return(null===(t=o.value)||void 0===t?void 0:t.toString())===e});return o?y(o):e},onChange:function(e){var o=e.target.value+"";t.setState({value:o},function(){t.props.name&&t.props.checkValidateField&&t.props.checkValidateField(t.props.name);var e=p.find(function(e){var t;return(null===(t=e.value)||void 0===t?void 0:t.toString())===o});e&&t.props.onChange&&t.props.onChange(e)})},disabled:t.props.disabled,fullWidth:void 0===t.props.fullWidth||t.props.fullWidth,endAdornment:null!==(r=null!==(i=t.props.endAdornment)&&void 0!==i?i:null==d?void 0:d.endAdornment)&&void 0!==r?r:void 0,MenuProps:{PaperProps:{sx:P}}},m=null!==(a=null===(s=t.props.slots)||void 0===s?void 0:s.selectProps)&&void 0!==a?a:null==d?void 0:d.selectProps;return S({},h,m)}),e(t,"renderTooltip",function(){var e=t.props.tooltip||(null==d?void 0:d.tooltip);return e?n("div",{className:W.tooltipWrap,children:n(x,{panel:e,children:n(C,{fontSize:"small"})})}):null}),e(t,"getRootClasses",function(){var e,o,l,r=[W.root];return(t.props.tooltip||(null==d?void 0:d.tooltip))&&r.push(W.tooltip),(t.props.endAdornment||null!=d&&d.endAdornment)&&r.push(W.endAdornment),"small"===(null!==(e=null===(o=t.props.slots)||void 0===o||null===(o=o.selectProps)||void 0===o?void 0:o.size)&&void 0!==e?e:null==d||null===(l=d.selectProps)||void 0===l?void 0:l.size)&&r.push(W.small),r.join(" ")}),e(t,"getDefaultValue",function(e){var o,l,r,i,n,a,s,p=null!=e?e:t.props,u=p.data,c=p.name,v=null!==(o=null===(l=p.defaultValue)||void 0===l?void 0:l.toString())&&void 0!==o?o:u&&c?null===(r=u[c])||void 0===r?void 0:r.toString():void 0;return null!=v&&""!==v?v:(null!==(i=null===(n=p.slots)||void 0===n?void 0:n.autoSelectFirst)&&void 0!==i?i:null==d?void 0:d.autoSelectFirst)&&null!==(a=null===(s=t.getOptions()[0])||void 0===s||null===(s=s.value)||void 0===s?void 0:s.toString())&&void 0!==a?a:""}),e(t,"getOptions",function(){var e,o;return null!==(e=null!==(o=null==d?void 0:d.options)&&void 0!==o?o:t.props.options)&&void 0!==e?e:[]}),t.state={value:t.getDefaultValue()},t}return t(u,p),l(u,[{key:"label",get:function(){return this.props.label&&"string"==typeof this.props.label?this.props.label:this.props.name?this.props.name.toString():""}},{key:"placeholderText",get:function(){return this.props.placeholder?this.props.placeholder:null!=d&&d.placeholder?d.placeholder:this.label?"Select a ".concat(this.label):"Select an option"}},{key:"shouldComponentUpdate",value:function(e){var o=this.getDefaultValue(),t=this.getDefaultValue(e);return o===t||t===this.state.value||(this.setState({value:t}),!1)}},{key:"render",value:function(){var e,t,l=this.getOptions(),r=b(this.props.messageErrors,this.props.name),i=r.error?"error.main":"text.primary";return a(s,{children:[!!this.props.disabled&&n("input",{hidden:!0,name:null===(e=this.props.name)||void 0===e?void 0:e.toString(),defaultValue:this.state.value}),a(k,o(o(o({className:this.getRootClasses()},null==d?void 0:d.wrapProps),null===(t=this.props.slots)||void 0===t?void 0:t.wrapProps),{},{children:[this.label&&n(c,{className:W.label,variant:"subtitle2",sx:{fontWeight:600,mb:.5,color:i},children:this.label}),a(h,o(o({className:W.select,variant:"outlined"},this.mapProps()),{},{children:[this.placeholderText&&n(z,{className:W.selectHeader,children:this.placeholderText}),l.map(function(e){var o;return n(m,{value:e.value,children:y(e)},null===(o=e.value)||void 0===o?void 0:o.toString())})]})),n(f,{in:r.error,unmountOnExit:!0,children:n(g,{error:!0,sx:{mt:.5,fontWeight:500,color:"error.main"},children:r.message})}),this.renderTooltip()]}))]})}}])}()}var P={borderRadius:"12px",mt:.8,boxShadow:"rgba(0, 0, 0, 0.08) 0px 4px 20px 0px",border:"1px solid #e2e8f0",padding:"4px","& .MuiMenuItem-root":{borderRadius:"8px",margin:"2px 4px",fontSize:"0.875rem",fontWeight:500,color:"#1e293b",transition:"all 0.15s ease-in-out","&:hover":{backgroundColor:"#f1f5f9"},"&.Mui-selected":{backgroundColor:"#f3f0ff",color:"#6366f1",fontWeight:600,"&:hover":{backgroundColor:"#e0e7ff"}}}},k=d(u)(function(o){var t=o.theme;return e(e(e(e({position:"relative"},".".concat(W.label),{display:"flex",alignItems:"center",marginBottom:t.spacing(.5),height:"var(--dino-height-input-label, 21px)"}),"& .MuiOutlinedInput-root",{borderRadius:"10px",backgroundColor:"#ffffff",height:"var(--dino-min-height-input, 42px)",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",transition:"all 0.2s ease-in-out","& fieldset":{borderColor:"#cbd5e1",borderWidth:"1px"},"&:hover fieldset":{borderColor:"#94a3b8"},"&.Mui-focused fieldset":{borderColor:t.palette.primary.main,borderWidth:"1.5px"},"&.Mui-error fieldset":{borderColor:t.palette.error.main}}),".MuiSelect-select",{padding:t.spacing(0,1.5),height:"100%",minHeight:"var(--dino-min-height-input, 42px)",boxSizing:"border-box",fontSize:"0.875rem",color:t.palette.text.primary,display:"flex",alignItems:"center"}),".".concat(W.tooltipWrap),{position:"absolute",top:t.spacing(4.2),right:t.spacing(1.5),display:"flex",alignItems:"center",gap:t.spacing(.5)})}),z=d(function(e){return n(c,o({component:"div"},e))})(function(e){var o=e.theme;return{pointerEvents:"none",cursor:"default",userSelect:"none",color:v(o.palette.text.secondary,.3),fontWeight:600,fontSize:"0.8125rem",padding:o.spacing(1,2),marginTop:o.spacing(-1)}});export{D as createSelectSimple,D as default,y as getOptionDisplayLabel,W as selectSimpleClasses};
2
2
  //# sourceMappingURL=create.select-simple.js.map
@@ -1 +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.checkValidateField && this.props.checkValidateField(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","checkValidateField","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,a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AMW,QAAQnH,MAAMqH,QAGrC,oBAAqB,CACnBpB,QAASO,EAAMK,QAAQ,EAAG,KAC1BC,OAAQ,OACRC,UAAW,qCACXC,UAAW,aACXvG,SAAU,WACVD,MAAOgG,EAAMW,QAAQG,KAAKF,QAC1BV,QAAS,OACTC,WAAY,eACb3C,OACIlG,EAAoBK,aAAgB,CACvCsI,SAAU,WACVc,IAAKf,EAAMK,QAAQ,KACnBW,MAAOhB,EAAMK,QAAQ,KACrBH,QAAS,OACTC,WAAY,SACZc,IAAKjB,EAAMK,QAAQ,KACpB,GAGG1B,EAAmBkB,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"}
1
+ {"version":3,"file":"create.select-simple.js","sources":["../../../../src/form/v2/create.select-simple.tsx"],"sourcesContent":["import { Component, Fragment } from 'react'\nimport { Box, Collapse, FormHelperText, MenuItem, Select, Typography, alpha, styled } from '@mui/material'\nimport { getErrorMessage } from '../helpers'\nimport { mergeObjects } from '../../utils/helpers'\nimport { HelpOutlinePulseIcon, RichTooltip } from '../../components/rich-tooltip'\nimport type { ComponentType } from 'react'\nimport type { BoxProps, PaperProps, SelectProps, TypographyProps } from '@mui/material'\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.checkValidateField && this.props.checkValidateField(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","checkValidateField","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":"6kBAiBM,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,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B,CACnBpB,QAASO,EAAMK,QAAQ,EAAG,KAC1BC,OAAQ,OACRC,UAAW,qCACXC,UAAW,aACXvG,SAAU,WACVD,MAAOgG,EAAMW,QAAQG,KAAKF,QAC1BV,QAAS,OACTC,WAAY,eACb3C,OACIlG,EAAoBK,aAAgB,CACvCsI,SAAU,WACVc,IAAKf,EAAMK,QAAQ,KACnBW,MAAOhB,EAAMK,QAAQ,KACrBH,QAAS,OACTC,WAAY,SACZc,IAAKjB,EAAMK,QAAQ,KACpB,GAGG1B,EAAmBkB,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"}
@@ -1,2 +1,2 @@
1
- import{defineProperty as e,createClass as t,classCallCheck as n,typeof as i,createForOfIteratorHelper as r,objectSpread2 as u}from"../../_virtual/_rollupPluginBabelHelpers.js";import{formatFileSize as a}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";var o,l,s;!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.FileImage="FileImage",e.FileRequired="FileRequired",e.Custom="Custom"}(s||(s={}));var c=(e(e(e(e(e(e(e(e(e(e(o={},s.Required,"The {0} is required"),s.Regex,"The {0} is not match {1}"),s.RequiredValue,"The {0} is not equal {1}"),s.Array,"The {0} is not valid"),s.Number,"{0} must be a number"),s.Email,"The {0} is not valid"),s.PhoneNumber,"The {0} is not valid"),s.Url,"The {0} is not valid"),s.File,"The {0} is not valid"),s.FileImage,"The {0} is not valid"),e(e(o,s.FileRequired,"The {0} is required"),s.Custom,"The {0} is not valid (Custom)")),m=t(function t(o){var l=this;n(this,t),e(this,"addRules",function(e){var t,n=l.configs[e];n||(n={rules:[]},l.configs[e]=n);for(var i=arguments.length,r=new Array(i>1?i-1:0),u=1;u<i;u++)r[u-1]=arguments[u];return(t=n.rules).push.apply(t,r),l}),e(this,"handleRequired",function(e){return null==e||!1===e||("string"==typeof e?""===e.trim():!!Array.isArray(e)&&0===e.length)}),e(this,"handleRegex",function(e,t){if(!e)return!1;var n=null==t?void 0:t.custom,i=null;if(n instanceof RegExp)i=n;else if("string"==typeof n&&n.length>0)try{i=new RegExp(n)}catch(e){return"Invalid regex pattern configured"}return i?!i.test(String(e)):"Invalid regex pattern configured"}),e(this,"handleRequiredValue",function(e,t){return void 0===(null==t?void 0:t.custom)?"Invalid required value configured":e!==t.custom}),e(this,"handleCustom",function(e,t,n){return"function"==typeof(null==t?void 0:t.custom)?t.custom(e,n):"Custom validation function is required"}),e(this,"handleArray",function(e,t){var n,i=e;if("string"==typeof e){var r=e.trim();if(r.startsWith("["))try{i=JSON.parse(r)}catch(e){try{i=JSON.parse(r.replace(/'/g,'"'))}catch(e){}}}var u=null==t||null===(n=t.options)||void 0===n?void 0:n.array;if(!i||Array.isArray(i)&&0===i.length){if(u){if("number"==typeof u.count&&u.count>0)return"{0} must have exactly ".concat(u.count," item").concat(1!==u.count?"s":"");if("number"==typeof u.minCount&&u.minCount>0)return"{0} must have at least ".concat(u.minCount," item").concat(1!==u.minCount?"s":"")}return!1}if(!Array.isArray(i))return!0;if(u){if("number"==typeof u.count&&i.length!==u.count)return"{0} must have exactly ".concat(u.count," item").concat(1!==u.count?"s":"");if("number"==typeof u.maxCount&&i.length>u.maxCount)return"{0} must have at most ".concat(u.maxCount," item").concat(1!==u.maxCount?"s":"");if("number"==typeof u.minCount&&i.length<u.minCount)return"{0} must have at least ".concat(u.minCount," item").concat(1!==u.minCount?"s":"")}return"number"==typeof(null==t?void 0:t.custom)&&i.length>t.custom}),e(this,"handleNumber",function(e){return null!=e&&""!==e&&(!("boolean"!=typeof e&&!Array.isArray(e)&&"symbol"!==i(e))||("string"!=typeof e||""!==e.trim())&&isNaN(Number(e)))}),e(this,"handleEmail",function(e){if(!e)return!1;var t=String(e).trim();return!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t)}),e(this,"handlePhoneNumber",function(e){if(!e)return!1;var t=String(e).trim();return!/^(\+?\d{1,4}[\s-]?)?((\(\d{1,4}\))|\d{1,4})[\s-]?\d{1,4}[\s-]?\d{1,9}$/.test(t)}),e(this,"handleUrl",function(e){if(!e)return!1;try{return new URL(String(e)),!1}catch(e){return!0}}),e(this,"handleFile",function(e,t){var n;if(!e||Array.isArray(e)&&0===e.length){var r,u=null==t||null===(r=t.options)||void 0===r?void 0:r.file;if(u){if("number"==typeof u.count&&u.count>0)return"{0} must have exactly ".concat(u.count," file").concat(1!==u.count?"s":"");if("number"==typeof u.minCount&&u.minCount>0)return"{0} must have at least ".concat(u.minCount," file").concat(1!==u.minCount?"s":"")}return!1}var a=e;if("string"==typeof e&&e.startsWith("["))try{a=JSON.parse(e)}catch(e){}var o=Array.isArray(a)?a:[a];if(0===o.length){var l,s=null==t||null===(l=t.options)||void 0===l?void 0:l.file;if(s){if("number"==typeof s.count&&s.count>0)return"{0} must have exactly ".concat(s.count," file").concat(1!==s.count?"s":"");if("number"==typeof s.minCount&&s.minCount>0)return"{0} must have at least ".concat(s.minCount," file").concat(1!==s.minCount?"s":"")}return!1}var c=null==t||null===(n=t.options)||void 0===n?void 0:n.file;if(c){if("number"==typeof c.count&&o.length!==c.count)return"{0} must have exactly ".concat(c.count," file").concat(1!==c.count?"s":"");if("number"==typeof c.maxCount&&o.length>c.maxCount)return"{0} must have at most ".concat(c.maxCount," file").concat(1!==c.maxCount?"s":"");if("number"==typeof c.minCount&&o.length<c.minCount)return"{0} must have at least ".concat(c.minCount," file").concat(1!==c.minCount?"s":"")}var m=o.filter(function(e){return e instanceof File||e&&"object"===i(e)&&"number"==typeof e.size});if(c&&m.length>0&&"number"==typeof c.maxSize){var f=c.maxSize;if(!0===c.sumSize){if(m.reduce(function(e,t){return e+((null==t?void 0:t.size)||0)},0)>f)return!0}else if(m.some(function(e){return e.size>f}))return!0}return!1}),e(this,"handleFileImage",function(e,t){var n;if(!e||Array.isArray(e)&&0===e.length){var u,a=null==t||null===(u=t.options)||void 0===u?void 0:u.image;if(a){if("number"==typeof a.count&&a.count>0)return"{0} must have exactly ".concat(a.count," image").concat(1!==a.count?"s":"");if("number"==typeof a.minCount&&a.minCount>0)return"{0} must have at least ".concat(a.minCount," image").concat(1!==a.minCount?"s":"")}return!1}var o=e;if("string"==typeof e&&e.startsWith("["))try{o=JSON.parse(e)}catch(e){}var l=Array.isArray(o)?o:[o];if(0===l.length){var s,c=null==t||null===(s=t.options)||void 0===s?void 0:s.image;if(c){if("number"==typeof c.count&&c.count>0)return"{0} must have exactly ".concat(c.count," image").concat(1!==c.count?"s":"");if("number"==typeof c.minCount&&c.minCount>0)return"{0} must have at least ".concat(c.minCount," image").concat(1!==c.minCount?"s":"")}return!1}var m=null==t||null===(n=t.options)||void 0===n?void 0:n.image;if(m){if("number"==typeof m.count&&l.length!==m.count)return"{0} must have exactly ".concat(m.count," image").concat(1!==m.count?"s":"");if("number"==typeof m.maxCount&&l.length>m.maxCount)return"{0} must have at most ".concat(m.maxCount," image").concat(1!==m.maxCount?"s":"");if("number"==typeof m.minCount&&l.length<m.minCount)return"{0} must have at least ".concat(m.minCount," image").concat(1!==m.minCount?"s":"")}var f=l.filter(function(e){return e instanceof File||e&&"object"===i(e)&&"number"==typeof e.size}),h=f.every(function(e){var t=e.type||"",n=e.name||"",i="string"==typeof t&&t.startsWith("image/"),r="string"==typeof n&&/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico|avif)$/i.test(n);return i||r||void 0!==e.width||void 0!==e.height});if(f.length>0&&!h)return!0;if(m&&f.length>0&&"number"==typeof m.maxSize){var d=m.maxSize;if(!0===m.sumSize){var v=f.reduce(function(e,t){return e+((null==t?void 0:t.size)||0)},0);if(v>d)return!0}else if(f.some(function(e){return e.size>d}))return!0}if(m){var g,y=r(l);try{for(y.s();!(g=y.n()).done;){var p,b,x,C,R=g.value;if(R&&"object"===i(R)){var z=null!==(p=R.width)&&void 0!==p?p:null===(b=R.dimensions)||void 0===b?void 0:b.width,A=null!==(x=R.height)&&void 0!==x?x:null===(C=R.dimensions)||void 0===C?void 0:C.height;if("number"==typeof z){if("number"==typeof m.maxWidth&&z>m.maxWidth)return"The {0} image width must be less than ".concat(m.maxWidth,"px");if("number"==typeof m.minWidth&&z<m.minWidth)return"The {0} image width must be at least ".concat(m.minWidth,"px")}if("number"==typeof A){if("number"==typeof m.maxHeight&&A>m.maxHeight)return"The {0} image height must be less than ".concat(m.maxHeight,"px");if("number"==typeof m.minHeight&&A<m.minHeight)return"The {0} image height must be at least ".concat(m.minHeight,"px")}}}}catch(e){y.e(e)}finally{y.f()}}return!1}),e(this,"handleFileRequired",function(e){return null==e||""===e||"[]"===e||(Array.isArray(e)?0===e.length||e.some(function(e){return!e||e instanceof File&&e.size<=0}):e instanceof File&&e.size<=0)}),e(this,"renderMessage",function(e,t,n,i){var r="";if(i&&"string"==typeof i)r=i;else if(e.message)r=e.message;else{var o;switch(r=null!==(o=c[e.rule])&&void 0!==o?o:"",e.rule){case s.Regex:var l=e.custom,m=l instanceof RegExp?l.source:String(null!=l?l:"");r=r.replace("{1}",m);break;case s.RequiredValue:var f,h;r=r.replace("{1}",null!==(f=null===(h=e.custom)||void 0===h?void 0:h.toString())&&void 0!==f?f:"");break;case s.File:var d,v=null===(d=e.options)||void 0===d?void 0:d.file;null!=v&&v.maxSize&&(r=!0===v.sumSize?"Total ".concat(null!=n?n:t," file size must be less than ").concat(a(v.maxSize/1024)):"The ".concat(null!=n?n:t," file size must be less than ").concat(a(v.maxSize/1024)));break;case s.FileImage:var g,y=null===(g=e.options)||void 0===g?void 0:g.image;null!=y&&y.maxSize&&(r=!0===y.sumSize?"Total ".concat(null!=n?n:t," image file size must be less than ").concat(a(y.maxSize/1024)):"The ".concat(null!=n?n:t," image file size must be less than ").concat(a(y.maxSize/1024)))}}return r=r.replace("{0}",null!=n?n:t),u(u({},e),{},{message:r})}),e(this,"getRuleValidator",function(e){switch(e){case s.Required:return l.handleRequired;case s.Regex:return l.handleRegex;case s.RequiredValue:return l.handleRequiredValue;case s.Custom:return l.handleCustom;case s.Array:return l.handleArray;case s.Number:return l.handleNumber;case s.Email:return l.handleEmail;case s.PhoneNumber:return l.handlePhoneNumber;case s.Url:return l.handleUrl;case s.File:return l.handleFile;case s.FileImage:return l.handleFileImage;case s.FileRequired:return l.handleFileRequired;default:return}}),e(this,"executed",function(e,t,n){return e.rules.map(function(e){var i=l.getRuleValidator(e.rule),r=i&&i(t,e,n);return{value:r,rule:e}}).filter(function(e){return e.value})}),e(this,"run",function(e){var t=Object.keys(l.configs),n={};return t.forEach(function(t){var i=l.configs[t];if(i){var r=l.executed(i,e[t],e);r.length<1||(n[t]=r.map(function(e){return l.renderMessage(e.rule,t,i.label,e.value)}))}}),n}),this.configs=o});l=m,e(m,"initialize",function(e){return new l(e)});var f=function(){return new m({})};export{s as EValidateRule,m as FormValidator,f as createFormValidator,m as default};
1
+ import{defineProperty as e,createClass as t,classCallCheck as n,typeof as r,createForOfIteratorHelper as i,objectSpread2 as u}from"../../_virtual/_rollupPluginBabelHelpers.js";import{formatFileSize as a}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";import{defaultMessage as o,EValidateRule as l}from"./validator.units.js";var s,c=t(function t(s){var c=this;n(this,t),e(this,"addRules",function(e){var t,n=c.configs[e];n||(n={rules:[]},c.configs[e]=n);for(var r=arguments.length,i=new Array(r>1?r-1:0),u=1;u<r;u++)i[u-1]=arguments[u];return(t=n.rules).push.apply(t,i),c}),e(this,"handleRequired",function(e){return null==e||!1===e||("string"==typeof e?""===e.trim():!!Array.isArray(e)&&0===e.length)}),e(this,"handleRegex",function(e,t){if(!e)return!1;var n=null==t?void 0:t.custom,r=null;if(n instanceof RegExp)r=n;else if("string"==typeof n&&n.length>0)try{r=new RegExp(n)}catch(e){return"Invalid regex pattern configured"}return r?!r.test(String(e)):"Invalid regex pattern configured"}),e(this,"handleRequiredValue",function(e,t){return void 0===(null==t?void 0:t.custom)?"Invalid required value configured":e!==t.custom}),e(this,"handleCustom",function(e,t,n){return"function"==typeof(null==t?void 0:t.custom)?t.custom(e,n):"Custom validation function is required"}),e(this,"handleArray",function(e,t){var n,r=e;if("string"==typeof e){var i=e.trim();if(i.startsWith("["))try{r=JSON.parse(i)}catch(e){try{r=JSON.parse(i.replace(/'/g,'"'))}catch(e){}}}var u=null==t||null===(n=t.options)||void 0===n?void 0:n.array;if(!r||Array.isArray(r)&&0===r.length){if(u){if("number"==typeof u.count&&u.count>0)return"{0} must have exactly ".concat(u.count," item").concat(1!==u.count?"s":"");if("number"==typeof u.minCount&&u.minCount>0)return"{0} must have at least ".concat(u.minCount," item").concat(1!==u.minCount?"s":"")}return!1}if(!Array.isArray(r))return!0;if(u){if("number"==typeof u.count&&r.length!==u.count)return"{0} must have exactly ".concat(u.count," item").concat(1!==u.count?"s":"");if("number"==typeof u.maxCount&&r.length>u.maxCount)return"{0} must have at most ".concat(u.maxCount," item").concat(1!==u.maxCount?"s":"");if("number"==typeof u.minCount&&r.length<u.minCount)return"{0} must have at least ".concat(u.minCount," item").concat(1!==u.minCount?"s":"")}return"number"==typeof(null==t?void 0:t.custom)&&r.length>t.custom}),e(this,"handleNumber",function(e,t){var n;if(null==e||""===e)return!1;if("boolean"==typeof e||Array.isArray(e)||"symbol"===r(e))return!0;if("string"==typeof e&&""===e.trim())return!1;var i=Number(e);if(isNaN(i))return!0;var u=null==t||null===(n=t.options)||void 0===n?void 0:n.number;if(u){if("number"==typeof u.min&&i<u.min)return"{0} must be at least ".concat(u.min);if("number"==typeof u.max&&i>u.max)return"{0} must be at most ".concat(u.max)}return!1}),e(this,"handleEmail",function(e){if(!e)return!1;var t=String(e).trim();return!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t)}),e(this,"handlePhoneNumber",function(e){if(!e)return!1;var t=String(e).trim();return!/^(\+?\d{1,4}[\s-]?)?((\(\d{1,4}\))|\d{1,4})[\s-]?\d{1,4}[\s-]?\d{1,9}$/.test(t)}),e(this,"handleUrl",function(e){if(!e)return!1;try{return new URL(String(e)),!1}catch(e){return!0}}),e(this,"handleFile",function(e,t){var n;if(!e||Array.isArray(e)&&0===e.length){var i,u=null==t||null===(i=t.options)||void 0===i?void 0:i.file;if(u){if("number"==typeof u.count&&u.count>0)return"{0} must have exactly ".concat(u.count," file").concat(1!==u.count?"s":"");if("number"==typeof u.minCount&&u.minCount>0)return"{0} must have at least ".concat(u.minCount," file").concat(1!==u.minCount?"s":"")}return!1}var a=e;if("string"==typeof e&&e.startsWith("["))try{a=JSON.parse(e)}catch(e){}var o=Array.isArray(a)?a:[a];if(0===o.length){var l,s=null==t||null===(l=t.options)||void 0===l?void 0:l.file;if(s){if("number"==typeof s.count&&s.count>0)return"{0} must have exactly ".concat(s.count," file").concat(1!==s.count?"s":"");if("number"==typeof s.minCount&&s.minCount>0)return"{0} must have at least ".concat(s.minCount," file").concat(1!==s.minCount?"s":"")}return!1}var c=null==t||null===(n=t.options)||void 0===n?void 0:n.file;if(c){if("number"==typeof c.count&&o.length!==c.count)return"{0} must have exactly ".concat(c.count," file").concat(1!==c.count?"s":"");if("number"==typeof c.maxCount&&o.length>c.maxCount)return"{0} must have at most ".concat(c.maxCount," file").concat(1!==c.maxCount?"s":"");if("number"==typeof c.minCount&&o.length<c.minCount)return"{0} must have at least ".concat(c.minCount," file").concat(1!==c.minCount?"s":"")}var m=o.filter(function(e){return e instanceof File||e&&"object"===r(e)&&"number"==typeof e.size});if(c&&m.length>0&&"number"==typeof c.maxSize){var f=c.maxSize;if(!0===c.sumSize){if(m.reduce(function(e,t){return e+((null==t?void 0:t.size)||0)},0)>f)return!0}else if(m.some(function(e){return e.size>f}))return!0}return!1}),e(this,"handleFileImage",function(e,t){var n;if(!e||Array.isArray(e)&&0===e.length){var u,a=null==t||null===(u=t.options)||void 0===u?void 0:u.image;if(a){if("number"==typeof a.count&&a.count>0)return"{0} must have exactly ".concat(a.count," image").concat(1!==a.count?"s":"");if("number"==typeof a.minCount&&a.minCount>0)return"{0} must have at least ".concat(a.minCount," image").concat(1!==a.minCount?"s":"")}return!1}var o=e;if("string"==typeof e&&e.startsWith("["))try{o=JSON.parse(e)}catch(e){}var l=Array.isArray(o)?o:[o];if(0===l.length){var s,c=null==t||null===(s=t.options)||void 0===s?void 0:s.image;if(c){if("number"==typeof c.count&&c.count>0)return"{0} must have exactly ".concat(c.count," image").concat(1!==c.count?"s":"");if("number"==typeof c.minCount&&c.minCount>0)return"{0} must have at least ".concat(c.minCount," image").concat(1!==c.minCount?"s":"")}return!1}var m=null==t||null===(n=t.options)||void 0===n?void 0:n.image;if(m){if("number"==typeof m.count&&l.length!==m.count)return"{0} must have exactly ".concat(m.count," image").concat(1!==m.count?"s":"");if("number"==typeof m.maxCount&&l.length>m.maxCount)return"{0} must have at most ".concat(m.maxCount," image").concat(1!==m.maxCount?"s":"");if("number"==typeof m.minCount&&l.length<m.minCount)return"{0} must have at least ".concat(m.minCount," image").concat(1!==m.minCount?"s":"")}var f=l.filter(function(e){return e instanceof File||e&&"object"===r(e)&&"number"==typeof e.size}),h=f.every(function(e){var t=e.type||"",n=e.name||"",r="string"==typeof t&&t.startsWith("image/"),i="string"==typeof n&&/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico|avif)$/i.test(n);return r||i||void 0!==e.width||void 0!==e.height});if(f.length>0&&!h)return!0;if(m&&f.length>0&&"number"==typeof m.maxSize){var d=m.maxSize;if(!0===m.sumSize){var v=f.reduce(function(e,t){return e+((null==t?void 0:t.size)||0)},0);if(v>d)return!0}else if(f.some(function(e){return e.size>d}))return!0}if(m){var g,p=i(l);try{for(p.s();!(g=p.n()).done;){var y,b,x,C,z=g.value;if(z&&"object"===r(z)){var A=null!==(y=z.width)&&void 0!==y?y:null===(b=z.dimensions)||void 0===b?void 0:b.width,S=null!==(x=z.height)&&void 0!==x?x:null===(C=z.dimensions)||void 0===C?void 0:C.height;if("number"==typeof A){if("number"==typeof m.maxWidth&&A>m.maxWidth)return"The {0} image width must be less than ".concat(m.maxWidth,"px");if("number"==typeof m.minWidth&&A<m.minWidth)return"The {0} image width must be at least ".concat(m.minWidth,"px")}if("number"==typeof S){if("number"==typeof m.maxHeight&&S>m.maxHeight)return"The {0} image height must be less than ".concat(m.maxHeight,"px");if("number"==typeof m.minHeight&&S<m.minHeight)return"The {0} image height must be at least ".concat(m.minHeight,"px")}}}}catch(e){p.e(e)}finally{p.f()}}return!1}),e(this,"handleFileRequired",function(e){return null==e||""===e||"[]"===e||(Array.isArray(e)?0===e.length||e.some(function(e){return!e||e instanceof File&&e.size<=0}):e instanceof File&&e.size<=0)}),e(this,"renderMessage",function(e,t,n,r){var i="";if(r&&"string"==typeof r)i=r;else if(e.message)i=e.message;else{var s;switch(i=null!==(s=o[e.rule])&&void 0!==s?s:"",e.rule){case l.Regex:var c=e.custom,m=c instanceof RegExp?c.source:String(null!=c?c:"");i=i.replace("{1}",m);break;case l.RequiredValue:var f,h;i=i.replace("{1}",null!==(f=null===(h=e.custom)||void 0===h?void 0:h.toString())&&void 0!==f?f:"");break;case l.File:var d,v=null===(d=e.options)||void 0===d?void 0:d.file;null!=v&&v.maxSize&&(i=!0===v.sumSize?"Total ".concat(null!=n?n:t," file size must be less than ").concat(a(v.maxSize/1024)):"The ".concat(null!=n?n:t," file size must be less than ").concat(a(v.maxSize/1024)));break;case l.FileImage:var g,p=null===(g=e.options)||void 0===g?void 0:g.image;null!=p&&p.maxSize&&(i=!0===p.sumSize?"Total ".concat(null!=n?n:t," image file size must be less than ").concat(a(p.maxSize/1024)):"The ".concat(null!=n?n:t," image file size must be less than ").concat(a(p.maxSize/1024)))}}return i=i.replace("{0}",null!=n?n:t),u(u({},e),{},{message:i})}),e(this,"getRuleValidator",function(e){switch(e){case l.Required:return c.handleRequired;case l.Regex:return c.handleRegex;case l.RequiredValue:return c.handleRequiredValue;case l.Custom:return c.handleCustom;case l.Array:return c.handleArray;case l.Number:return c.handleNumber;case l.Email:return c.handleEmail;case l.PhoneNumber:return c.handlePhoneNumber;case l.Url:return c.handleUrl;case l.File:return c.handleFile;case l.FileImage:return c.handleFileImage;case l.FileRequired:return c.handleFileRequired;default:return}}),e(this,"executed",function(e,t,n){return e.rules.map(function(e){var r=c.getRuleValidator(e.rule),i=r&&r(t,e,n);return{value:i,rule:e}}).filter(function(e){return e.value})}),e(this,"run",function(e){var t=Object.keys(c.configs),n={};return t.forEach(function(t){var r=c.configs[t];if(r){var i=c.executed(r,e[t],e);i.length<1||(n[t]=i.map(function(e){return c.renderMessage(e.rule,t,r.label,e.value)}))}}),n}),this.configs=s});s=c,e(c,"initialize",function(e){return new s(e)});var m=function(){return new c({})};export{l as EValidateRule,c as FormValidator,m as createFormValidator,c as default};
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 EValidateRule {\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 FileImage = 'FileImage',\r\n FileRequired = 'FileRequired',\r\n Custom = 'Custom'\r\n}\r\n\r\nexport type EValidateRuleString = `${EValidateRule}`\r\n\r\ntype IValidateRuleType = EValidateRule | EValidateRuleString\r\n\r\ntype IDefaultMessage = { [key in EValidateRule]: string }\r\n\r\nconst defaultMessage: IDefaultMessage = {\r\n [EValidateRule.Required]: 'The {0} is required',\r\n [EValidateRule.Regex]: 'The {0} is not match {1}',\r\n [EValidateRule.RequiredValue]: 'The {0} is not equal {1}',\r\n [EValidateRule.Array]: 'The {0} is not valid',\r\n [EValidateRule.Number]: '{0} must be a number',\r\n [EValidateRule.Email]: 'The {0} is not valid',\r\n [EValidateRule.PhoneNumber]: 'The {0} is not valid',\r\n [EValidateRule.Url]: 'The {0} is not valid',\r\n [EValidateRule.File]: 'The {0} is not valid',\r\n [EValidateRule.FileImage]: 'The {0} is not valid',\r\n [EValidateRule.FileRequired]: 'The {0} is required',\r\n [EValidateRule.Custom]: 'The {0} is not valid (Custom)'\r\n}\r\n\r\nexport interface IFileRuleOptions {\r\n /** Max size of single file in bytes */\r\n maxSize?: number\r\n /** If true, maxSize applies to the total combined size of all files instead of each individual file */\r\n sumSize?: boolean\r\n /** Exact number of files required */\r\n count?: number\r\n /** Max number of files allowed */\r\n maxCount?: number\r\n /** Min number of files required */\r\n minCount?: number\r\n}\r\n\r\nexport interface IFileImageRuleOptions extends IFileRuleOptions {\r\n /** Max image width in pixels */\r\n maxWidth?: number\r\n /** Max image height in pixels */\r\n maxHeight?: number\r\n /** Min image width in pixels */\r\n minWidth?: number\r\n /** Min image height in pixels */\r\n minHeight?: number\r\n}\r\n\r\nexport interface IArrayRuleOptions {\r\n /** Exact number of items required in the array */\r\n count?: number\r\n /** Max number of items allowed in the array */\r\n maxCount?: number\r\n /** Min number of items required in the array */\r\n minCount?: number\r\n}\r\n\r\nexport interface IRuleOptions {\r\n /** Only apply for file rule */\r\n file?: IFileRuleOptions\r\n /** Only apply for file image rule */\r\n image?: IFileImageRuleOptions\r\n /** Only apply for array rule */\r\n array?: IArrayRuleOptions\r\n}\r\n\r\nexport interface IValidateRule<T = any> {\r\n /** The validation rule type to execute */\r\n rule: IValidateRuleType\r\n /** Custom error message string returned when validation fails */\r\n message?: string\r\n /**\r\n * - Custom target value, RegExp pattern, max count limit, or predicate function.\r\n * - For predicate function `(value, model)`: returning `true` or a non-empty `string` (custom error message) indicates INVALID (has error), while returning `false` indicates VALID (no error).\r\n */\r\n custom?: RegExp | ((value: any, model: T) => boolean | string) | number | Array<any> | boolean | string\r\n /** Additional rule options (e.g. file size limits or image dimension constraints) */\r\n options?: IRuleOptions\r\n}\r\n\r\n/**\r\n * - Handler function to validate a single rule against a field value and model state.\r\n * - Returns `true` or an error message string if validation fails (invalid state), or `false` if validation passes (valid state).\r\n *\r\n * @param value Current value of the field being validated\r\n * @param ruleOption Configuration options for the rule being validated\r\n * @param model Entire form model data\r\n * @returns `boolean | string` (true / string = validation failed, false = valid)\r\n */\r\nexport type IRuleValidatorHandler<T = any> = (value: any, ruleOption?: IValidateRule<T>, model?: T) => boolean | string\r\n\r\nexport interface IFieldValidateConfig<T = any> {\r\n label?: string\r\n rules: IValidateRule<T>[]\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>]?: IFieldValidateConfig<T>\r\n}\r\n\r\nexport type IPartialError<T> = {\r\n [key in keyof T]?: IValidateRule<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 initialize = <T>(configs: IFormValidatorConfig<T>) => new FormValidator(configs)\r\n\r\n addRules = (key: keyof T, ...rule: IValidateRule<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 private handleRequired: IRuleValidatorHandler<T> = (value) => {\r\n if (value === null || value === undefined || value === false) return true\r\n if (typeof value === 'string') return value.trim() === ''\r\n if (Array.isArray(value)) return value.length === 0\r\n return false\r\n }\r\n\r\n private handleRegex: IRuleValidatorHandler<T> = (value, ruleOption) => {\r\n if (!value) return false\r\n const custom = ruleOption?.custom\r\n let pattern: RegExp | null = null\r\n\r\n if (custom instanceof RegExp) {\r\n pattern = custom\r\n } else if (typeof custom === 'string' && custom.length > 0) {\r\n try {\r\n pattern = new RegExp(custom)\r\n } catch {\r\n return 'Invalid regex pattern configured'\r\n }\r\n }\r\n\r\n if (!pattern) {\r\n return 'Invalid regex pattern configured'\r\n }\r\n\r\n return !pattern.test(String(value))\r\n }\r\n\r\n private handleRequiredValue: IRuleValidatorHandler<T> = (value, ruleOption) => {\r\n if (ruleOption?.custom === undefined) {\r\n return 'Invalid required value configured'\r\n }\r\n return value !== ruleOption.custom\r\n }\r\n\r\n private handleCustom: IRuleValidatorHandler<T> = (value, ruleOption, model) => {\r\n if (typeof ruleOption?.custom === 'function') {\r\n return ruleOption.custom(value, model as T)\r\n }\r\n return 'Custom validation function is required'\r\n }\r\n\r\n private handleArray: IRuleValidatorHandler<T> = (value, ruleOption) => {\r\n let items = value\r\n if (typeof value === 'string') {\r\n const trimmed = value.trim()\r\n if (trimmed.startsWith('[')) {\r\n try {\r\n items = JSON.parse(trimmed)\r\n } catch {\r\n try {\r\n items = JSON.parse(trimmed.replace(/'/g, '\"'))\r\n } catch {\r\n /* keep as-is */\r\n }\r\n }\r\n }\r\n }\r\n\r\n const options = ruleOption?.options?.array\r\n\r\n if (!items || (Array.isArray(items) && items.length === 0)) {\r\n if (options) {\r\n if (typeof options.count === 'number' && options.count > 0)\r\n return `{0} must have exactly ${options.count} item${options.count !== 1 ? 's' : ''}`\r\n if (typeof options.minCount === 'number' && options.minCount > 0)\r\n return `{0} must have at least ${options.minCount} item${options.minCount !== 1 ? 's' : ''}`\r\n }\r\n return false\r\n }\r\n\r\n if (!Array.isArray(items)) return true\r\n\r\n if (options) {\r\n if (typeof options.count === 'number' && items.length !== options.count)\r\n return `{0} must have exactly ${options.count} item${options.count !== 1 ? 's' : ''}`\r\n if (typeof options.maxCount === 'number' && items.length > options.maxCount)\r\n return `{0} must have at most ${options.maxCount} item${options.maxCount !== 1 ? 's' : ''}`\r\n if (typeof options.minCount === 'number' && items.length < options.minCount)\r\n return `{0} must have at least ${options.minCount} item${options.minCount !== 1 ? 's' : ''}`\r\n }\r\n\r\n if (typeof ruleOption?.custom === 'number') {\r\n return items.length > ruleOption.custom\r\n }\r\n\r\n return false\r\n }\r\n\r\n private handleNumber: IRuleValidatorHandler<T> = (value) => {\r\n if (value === null || value === undefined || value === '') return false\r\n if (typeof value === 'boolean' || Array.isArray(value) || typeof value === 'symbol') return true\r\n if (typeof value === 'string' && value.trim() === '') return false\r\n return isNaN(Number(value))\r\n }\r\n\r\n private handleEmail: IRuleValidatorHandler<T> = (value) => {\r\n if (!value) return false\r\n const strVal = String(value).trim()\r\n const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\r\n return !regex.test(strVal)\r\n }\r\n\r\n private handlePhoneNumber: IRuleValidatorHandler<T> = (value) => {\r\n if (!value) return false\r\n const strVal = String(value).trim()\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(strVal)\r\n }\r\n\r\n private handleUrl: IRuleValidatorHandler<T> = (value) => {\r\n if (!value) return false\r\n try {\r\n new URL(String(value))\r\n return false\r\n } catch {\r\n return true\r\n }\r\n }\r\n\r\n private handleFile: IRuleValidatorHandler<T> = (value, ruleOption) => {\r\n if (!value || (Array.isArray(value) && value.length === 0)) {\r\n const options = ruleOption?.options?.file\r\n if (options) {\r\n if (typeof options.count === 'number' && options.count > 0)\r\n return `{0} must have exactly ${options.count} file${options.count !== 1 ? 's' : ''}`\r\n if (typeof options.minCount === 'number' && options.minCount > 0)\r\n return `{0} must have at least ${options.minCount} file${options.minCount !== 1 ? 's' : ''}`\r\n }\r\n return false\r\n }\r\n\r\n // Normalize: parse JSON string (e.g. '[\"url1\",\"url2\"]') into an array\r\n let normalized = value\r\n if (typeof value === 'string' && value.startsWith('[')) {\r\n try {\r\n normalized = JSON.parse(value)\r\n } catch {\r\n /* keep as-is */\r\n }\r\n }\r\n const files: any[] = Array.isArray(normalized) ? normalized : [normalized]\r\n if (files.length === 0) {\r\n const options = ruleOption?.options?.file\r\n if (options) {\r\n if (typeof options.count === 'number' && options.count > 0)\r\n return `{0} must have exactly ${options.count} file${options.count !== 1 ? 's' : ''}`\r\n if (typeof options.minCount === 'number' && options.minCount > 0)\r\n return `{0} must have at least ${options.minCount} file${options.minCount !== 1 ? 's' : ''}`\r\n }\r\n return false\r\n }\r\n\r\n const options = ruleOption?.options?.file\r\n\r\n // Check count options against total items (both string URLs and File objects)\r\n if (options) {\r\n if (typeof options.count === 'number' && files.length !== options.count)\r\n return `{0} must have exactly ${options.count} file${options.count !== 1 ? 's' : ''}`\r\n if (typeof options.maxCount === 'number' && files.length > options.maxCount)\r\n return `{0} must have at most ${options.maxCount} file${options.maxCount !== 1 ? 's' : ''}`\r\n if (typeof options.minCount === 'number' && files.length < options.minCount)\r\n return `{0} must have at least ${options.minCount} file${options.minCount !== 1 ? 's' : ''}`\r\n }\r\n\r\n // Extract local File / file-like objects to perform size validation\r\n const fileObjs = files.filter((f) => f instanceof File || (f && typeof f === 'object' && typeof f.size === 'number'))\r\n\r\n if (options && fileObjs.length > 0) {\r\n if (typeof options.maxSize === 'number') {\r\n const maxSize = options.maxSize\r\n if (options.sumSize === true) {\r\n const totalSize = fileObjs.reduce((acc, f) => acc + (f?.size || 0), 0)\r\n if (totalSize > maxSize) return true\r\n } else {\r\n if (fileObjs.some((f) => f.size > maxSize)) return true\r\n }\r\n }\r\n }\r\n\r\n return false\r\n }\r\n\r\n private handleFileImage: IRuleValidatorHandler<T> = (value, ruleOption) => {\r\n if (!value || (Array.isArray(value) && value.length === 0)) {\r\n const options = ruleOption?.options?.image\r\n if (options) {\r\n if (typeof options.count === 'number' && options.count > 0)\r\n return `{0} must have exactly ${options.count} image${options.count !== 1 ? 's' : ''}`\r\n if (typeof options.minCount === 'number' && options.minCount > 0)\r\n return `{0} must have at least ${options.minCount} image${options.minCount !== 1 ? 's' : ''}`\r\n }\r\n return false\r\n }\r\n\r\n // Normalize: parse JSON string (e.g. '[\"url1\",\"url2\"]') into an array\r\n let normalized = value\r\n if (typeof value === 'string' && value.startsWith('[')) {\r\n try {\r\n normalized = JSON.parse(value)\r\n } catch {\r\n /* keep as-is */\r\n }\r\n }\r\n const files: any[] = Array.isArray(normalized) ? normalized : [normalized]\r\n if (files.length === 0) {\r\n const options = ruleOption?.options?.image\r\n if (options) {\r\n if (typeof options.count === 'number' && options.count > 0)\r\n return `{0} must have exactly ${options.count} image${options.count !== 1 ? 's' : ''}`\r\n if (typeof options.minCount === 'number' && options.minCount > 0)\r\n return `{0} must have at least ${options.minCount} image${options.minCount !== 1 ? 's' : ''}`\r\n }\r\n return false\r\n }\r\n\r\n const options = ruleOption?.options?.image\r\n\r\n // Check count options against total items (both string URLs and File objects)\r\n if (options) {\r\n if (typeof options.count === 'number' && files.length !== options.count)\r\n return `{0} must have exactly ${options.count} image${options.count !== 1 ? 's' : ''}`\r\n if (typeof options.maxCount === 'number' && files.length > options.maxCount)\r\n return `{0} must have at most ${options.maxCount} image${options.maxCount !== 1 ? 's' : ''}`\r\n if (typeof options.minCount === 'number' && files.length < options.minCount)\r\n return `{0} must have at least ${options.minCount} image${options.minCount !== 1 ? 's' : ''}`\r\n }\r\n\r\n // Extract local File / file-like objects to perform type and size validation\r\n const fileObjs = files.filter((f) => f instanceof File || (f && typeof f === 'object' && typeof f.size === 'number'))\r\n\r\n const isAllValidImages = fileObjs.every((f) => {\r\n const type = f.type || ''\r\n const name = f.name || ''\r\n const isImageType = typeof type === 'string' && type.startsWith('image/')\r\n const isImageExt = typeof name === 'string' && /\\.(jpg|jpeg|png|gif|webp|svg|bmp|ico|avif)$/i.test(name)\r\n return isImageType || isImageExt || f.width !== undefined || f.height !== undefined\r\n })\r\n\r\n if (fileObjs.length > 0 && !isAllValidImages) {\r\n return true\r\n }\r\n\r\n if (options && fileObjs.length > 0) {\r\n if (typeof options.maxSize === 'number') {\r\n const maxSize = options.maxSize\r\n if (options.sumSize === true) {\r\n const totalSize = fileObjs.reduce((acc, f) => acc + (f?.size || 0), 0)\r\n if (totalSize > maxSize) return true\r\n } else {\r\n if (fileObjs.some((f) => f.size > maxSize)) return true\r\n }\r\n }\r\n }\r\n\r\n if (options) {\r\n // Check width / height dimensions if present on file object\r\n for (const f of files) {\r\n if (!f || typeof f !== 'object') continue\r\n const width = f.width ?? f.dimensions?.width\r\n const height = f.height ?? f.dimensions?.height\r\n\r\n if (typeof width === 'number') {\r\n if (typeof options.maxWidth === 'number' && width > options.maxWidth) {\r\n return `The {0} image width must be less than ${options.maxWidth}px`\r\n }\r\n if (typeof options.minWidth === 'number' && width < options.minWidth) {\r\n return `The {0} image width must be at least ${options.minWidth}px`\r\n }\r\n }\r\n\r\n if (typeof height === 'number') {\r\n if (typeof options.maxHeight === 'number' && height > options.maxHeight) {\r\n return `The {0} image height must be less than ${options.maxHeight}px`\r\n }\r\n if (typeof options.minHeight === 'number' && height < options.minHeight) {\r\n return `The {0} image height must be at least ${options.minHeight}px`\r\n }\r\n }\r\n }\r\n }\r\n\r\n return false\r\n }\r\n\r\n private handleFileRequired: IRuleValidatorHandler<T> = (value) => {\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\r\n private renderMessage = (ruleOption: IValidateRule, key: string, label?: string, message?: string | boolean): IValidateRule => {\r\n let resultMessage = ''\r\n\r\n if (!!message && typeof message === 'string') {\r\n resultMessage = message\r\n } else if (ruleOption.message) {\r\n resultMessage = ruleOption.message\r\n } else {\r\n resultMessage = defaultMessage[ruleOption.rule] ?? ''\r\n switch (ruleOption.rule) {\r\n case EValidateRule.Regex: {\r\n const custom = ruleOption.custom\r\n const patternStr = custom instanceof RegExp ? custom.source : String(custom ?? '')\r\n resultMessage = resultMessage.replace('{1}', patternStr)\r\n break\r\n }\r\n case EValidateRule.RequiredValue: {\r\n resultMessage = resultMessage.replace('{1}', ruleOption.custom?.toString() ?? '')\r\n break\r\n }\r\n case EValidateRule.File: {\r\n const options = ruleOption.options?.file\r\n if (options?.maxSize) {\r\n if (options.sumSize === true) {\r\n resultMessage = `Total ${label ?? key} file size must be less than ${formatFileSize(options.maxSize / 1024)}`\r\n } else {\r\n resultMessage = `The ${label ?? key} file size must be less than ${formatFileSize(options.maxSize / 1024)}`\r\n }\r\n }\r\n break\r\n }\r\n case EValidateRule.FileImage: {\r\n const options = ruleOption.options?.image\r\n if (options?.maxSize) {\r\n if (options.sumSize === true) {\r\n resultMessage = `Total ${label ?? key} image file size must be less than ${formatFileSize(options.maxSize / 1024)}`\r\n } else {\r\n resultMessage = `The ${label ?? key} image file size must be less than ${formatFileSize(options.maxSize / 1024)}`\r\n }\r\n }\r\n break\r\n }\r\n default:\r\n break\r\n }\r\n }\r\n resultMessage = resultMessage.replace('{0}', label ?? key)\r\n return {\r\n ...ruleOption,\r\n message: resultMessage\r\n }\r\n }\r\n\r\n private getRuleValidator = (rule: IValidateRuleType): IRuleValidatorHandler<T> | undefined => {\r\n switch (rule) {\r\n case EValidateRule.Required:\r\n return this.handleRequired\r\n case EValidateRule.Regex:\r\n return this.handleRegex\r\n case EValidateRule.RequiredValue:\r\n return this.handleRequiredValue\r\n case EValidateRule.Custom:\r\n return this.handleCustom\r\n case EValidateRule.Array:\r\n return this.handleArray\r\n case EValidateRule.Number:\r\n return this.handleNumber\r\n case EValidateRule.Email:\r\n return this.handleEmail\r\n case EValidateRule.PhoneNumber:\r\n return this.handlePhoneNumber\r\n case EValidateRule.Url:\r\n return this.handleUrl\r\n case EValidateRule.File:\r\n return this.handleFile\r\n case EValidateRule.FileImage:\r\n return this.handleFileImage\r\n case EValidateRule.FileRequired:\r\n return this.handleFileRequired\r\n default:\r\n return undefined\r\n }\r\n }\r\n\r\n private executed = (config: IFieldValidateConfig, valueField: any, model: any) => {\r\n return config.rules\r\n .map((ruleOption) => {\r\n const action = this.getRuleValidator(ruleOption.rule)\r\n const res = action && action(valueField, ruleOption, model)\r\n return { value: typeof res === 'boolean' ? res : (res as string), rule: ruleOption }\r\n })\r\n .filter((x) => x.value)\r\n }\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}\r\n\r\nexport default FormValidator\r\n\r\nexport const createFormValidator = <T>() => new FormValidator<Partial<T>>({})\r\n"],"names":["EValidateRule","defaultMessage","_defineProperty","_defaultMessage","Required","Regex","RequiredValue","Array","Number","Email","PhoneNumber","Url","File","FileImage","FileRequired","Custom","FormValidator","_createClass","configs","_this","this","_classCallCheck","key","_fieldConfig$rules","fieldConfig","rules","_len","arguments","length","rule","_key","push","apply","value","trim","isArray","ruleOption","custom","pattern","RegExp","_unused","test","String","undefined","model","_ruleOption$options","items","trimmed","startsWith","JSON","parse","_unused2","replace","_unused3","options","array","count","concat","minCount","maxCount","_typeof","isNaN","strVal","URL","_unused4","_ruleOption$options4","_ruleOption$options2","file","normalized","_unused5","files","_ruleOption$options3","fileObjs","filter","f","size","maxSize","sumSize","reduce","acc","some","_ruleOption$options7","_ruleOption$options5","image","_unused6","_ruleOption$options6","isAllValidImages","every","type","name","isImageType","isImageExt","width","height","totalSize","_step","_iterator","_createForOfIteratorHelper","s","n","done","_f$width","_f$dimensions","_f$height","_f$dimensions2","dimensions","maxWidth","minWidth","maxHeight","minHeight","err","e","x","label","message","resultMessage","_defaultMessage$ruleO","patternStr","source","_ruleOption$custom$to","_ruleOption$custom","toString","_ruleOption$options8","formatFileSize","_ruleOption$options9","_objectSpread","handleRequired","handleRegex","handleRequiredValue","handleCustom","handleArray","handleNumber","handleEmail","handlePhoneNumber","handleUrl","handleFile","handleFileImage","handleFileRequired","config","valueField","map","action","getRuleValidator","res","keys","Object","data","forEach","tmp","executed","renderMessage","createFormValidator"],"mappings":"8SAIYA,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,UAAA,YACAA,EAAA,aAAA,eACAA,EAAA,OAAA,QACD,CAbD,CAAYA,IAAAA,EAaX,CAAA,IAQD,IAAMC,GAAcC,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAC,EAAA,CAAA,EACjBH,EAAcI,SAAW,uBACzBJ,EAAcK,MAAQ,4BACtBL,EAAcM,cAAgB,4BAC9BN,EAAcO,MAAQ,wBACtBP,EAAcQ,OAAS,wBACvBR,EAAcS,MAAQ,wBACtBT,EAAcU,YAAc,wBAC5BV,EAAcW,IAAM,wBACpBX,EAAcY,KAAO,wBACrBZ,EAAca,UAAY,wBAAsBX,EAAAA,EAAAC,EAChDH,EAAcc,aAAe,uBAC7Bd,EAAce,OAAS,kCAwFbC,EAAaC,EAExB,SAAAD,EAAYE,GAAgC,IAAAC,EAAAC,KAAAC,OAAAL,GAAAd,EAAAkB,KAAA,WAMjC,SAACE,GAA6C,IAAAC,EACnDC,EAAcL,EAAKD,QAAQI,GAC1BE,IACHA,EAAc,CAAEC,MAAO,IACvBN,EAAKD,QAAQI,GAAOE,GACrB,IAAAE,IAAAA,EAAAC,UAAAC,OAL0BC,MAAwBtB,M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MF,GAAUA,EAAOF,EAAYvG,EAAYQ,GACrD,MAAO,CAAEX,MAAkC8G,EAAuBlH,KAAMO,EAC1E,GACCqC,OAAO,SAACuC,GAAC,OAAKA,EAAE/E,UACpB/B,EAAAkB,KAAA,MAEK,SAACwB,GACL,IAAMoG,EAAOC,OAAOD,KAAK7H,EAAKD,SACxBgI,EAAyB,CAAE,EAQjC,OAPAF,EAAKG,QAAQ,SAAC7H,GACZ,IAAMoH,EAASvH,EAAKD,QAAQI,GAC5B,GAAKoH,EAAL,CACA,IAAMU,EAAMjI,EAAKkI,SAASX,EAAS9F,EAActB,GAAMsB,GACnDwG,EAAIxH,OAAS,IACfsH,EAAa5H,GAAO8H,EAAIR,IAAI,SAAC5B,GAAC,OAAK7F,EAAKmI,cAActC,EAAEnF,KAAMP,EAAKoH,EAAOzB,MAAOD,EAAE/E,SAHxE,CAIf,GACOiH,IA/ZP9H,KAAKF,QAAUA,CACjB,KAJWF,EAAad,EAAbc,EAMS,aAAA,SAAIE,GAAgC,OAAK,IAAIF,EAAcE,EAAQ,GAka5EqI,IAAAA,EAAsB,WAAH,OAAY,IAAIvI,EAA0B,GAAG"}
1
+ {"version":3,"file":"validator.js","sources":["../../../src/form/validator.ts"],"sourcesContent":["import { formatFileSize } from '../utils'\nimport { defaultMessage, EValidateRule, IRuleOptions } from './validator.units'\n\nexport { EValidateRule } from './validator.units'\nexport type { INumberRuleOptions, IRuleOptions, IArrayRuleOptions, IFileRuleOptions, IFileImageRuleOptions } from './validator.units'\n\nexport type IModelBase = { [key: string]: any }\n\nexport type EValidateRuleString = `${EValidateRule}`\n\ntype IValidateRuleType = EValidateRule | EValidateRuleString\n\nexport interface IValidateRule<T = any> {\n /** The validation rule type to execute */\n rule: IValidateRuleType\n /** Custom error message string returned when validation fails */\n message?: string\n /**\n * - Custom target value, RegExp pattern, max count limit, or predicate function.\n * - For predicate function `(value, model)`: returning `true` or a non-empty `string` (custom error message) indicates INVALID (has error), while returning `false` indicates VALID (no error).\n */\n custom?: RegExp | ((value: any, model: T) => boolean | string) | number | Array<any> | boolean | string\n /** Additional rule options (e.g. file size limits or image dimension constraints) */\n options?: IRuleOptions\n}\n\n/**\n * - Handler function to validate a single rule against a field value and model state.\n * - Returns `true` or an error message string if validation fails (invalid state), or `false` if validation passes (valid state).\n *\n * @param value Current value of the field being validated\n * @param ruleOption Configuration options for the rule being validated\n * @param model Entire form model data\n * @returns `boolean | string` (true / string = validation failed, false = valid)\n */\nexport type IRuleValidatorHandler<T = any> = (value: any, ruleOption?: IValidateRule<T>, model?: T) => boolean | string\n\nexport interface IFieldValidateConfig<T = any> {\n label?: string\n rules: IValidateRule<T>[]\n}\n\nexport interface IModelError {\n message: string\n error: boolean\n}\n\nexport type IFormValidatorConfig<T> = {\n [key in keyof Extract<T, IModelBase>]?: IFieldValidateConfig<T>\n}\n\nexport type IPartialError<T> = {\n [key in keyof T]?: IValidateRule<T>[]\n}\n\nexport class FormValidator<T> {\n configs: IFormValidatorConfig<T>\n constructor(configs: IFormValidatorConfig<T>) {\n this.configs = configs\n }\n\n static initialize = <T>(configs: IFormValidatorConfig<T>) => new FormValidator(configs)\n\n addRules = (key: keyof T, ...rule: IValidateRule<T>[]) => {\n let fieldConfig = this.configs[key]\n if (!fieldConfig) {\n fieldConfig = { rules: [] }\n this.configs[key] = fieldConfig\n }\n fieldConfig.rules.push(...rule)\n return this\n }\n\n private handleRequired: IRuleValidatorHandler<T> = (value) => {\n if (value === null || value === undefined || value === false) return true\n if (typeof value === 'string') return value.trim() === ''\n if (Array.isArray(value)) return value.length === 0\n return false\n }\n\n private handleRegex: IRuleValidatorHandler<T> = (value, ruleOption) => {\n if (!value) return false\n const custom = ruleOption?.custom\n let pattern: RegExp | null = null\n\n if (custom instanceof RegExp) {\n pattern = custom\n } else if (typeof custom === 'string' && custom.length > 0) {\n try {\n pattern = new RegExp(custom)\n } catch {\n return 'Invalid regex pattern configured'\n }\n }\n\n if (!pattern) {\n return 'Invalid regex pattern configured'\n }\n\n return !pattern.test(String(value))\n }\n\n private handleRequiredValue: IRuleValidatorHandler<T> = (value, ruleOption) => {\n if (ruleOption?.custom === undefined) {\n return 'Invalid required value configured'\n }\n return value !== ruleOption.custom\n }\n\n private handleCustom: IRuleValidatorHandler<T> = (value, ruleOption, model) => {\n if (typeof ruleOption?.custom === 'function') {\n return ruleOption.custom(value, model as T)\n }\n return 'Custom validation function is required'\n }\n\n private handleArray: IRuleValidatorHandler<T> = (value, ruleOption) => {\n let items = value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (trimmed.startsWith('[')) {\n try {\n items = JSON.parse(trimmed)\n } catch {\n try {\n items = JSON.parse(trimmed.replace(/'/g, '\"'))\n } catch {\n /* keep as-is */\n }\n }\n }\n }\n\n const options = ruleOption?.options?.array\n\n if (!items || (Array.isArray(items) && items.length === 0)) {\n if (options) {\n if (typeof options.count === 'number' && options.count > 0)\n return `{0} must have exactly ${options.count} item${options.count !== 1 ? 's' : ''}`\n if (typeof options.minCount === 'number' && options.minCount > 0)\n return `{0} must have at least ${options.minCount} item${options.minCount !== 1 ? 's' : ''}`\n }\n return false\n }\n\n if (!Array.isArray(items)) return true\n\n if (options) {\n if (typeof options.count === 'number' && items.length !== options.count)\n return `{0} must have exactly ${options.count} item${options.count !== 1 ? 's' : ''}`\n if (typeof options.maxCount === 'number' && items.length > options.maxCount)\n return `{0} must have at most ${options.maxCount} item${options.maxCount !== 1 ? 's' : ''}`\n if (typeof options.minCount === 'number' && items.length < options.minCount)\n return `{0} must have at least ${options.minCount} item${options.minCount !== 1 ? 's' : ''}`\n }\n\n if (typeof ruleOption?.custom === 'number') {\n return items.length > ruleOption.custom\n }\n\n return false\n }\n\n private handleNumber: IRuleValidatorHandler<T> = (value, ruleOption) => {\n if (value === null || value === undefined || value === '') return false\n if (typeof value === 'boolean' || Array.isArray(value) || typeof value === 'symbol') return true\n if (typeof value === 'string' && value.trim() === '') return false\n\n const num = Number(value)\n if (isNaN(num)) return true\n\n const options = ruleOption?.options?.number\n if (options) {\n if (typeof options.min === 'number' && num < options.min) {\n return `{0} must be at least ${options.min}`\n }\n if (typeof options.max === 'number' && num > options.max) {\n return `{0} must be at most ${options.max}`\n }\n }\n\n return false\n }\n\n private handleEmail: IRuleValidatorHandler<T> = (value) => {\n if (!value) return false\n const strVal = String(value).trim()\n const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\n return !regex.test(strVal)\n }\n\n private handlePhoneNumber: IRuleValidatorHandler<T> = (value) => {\n if (!value) return false\n const strVal = String(value).trim()\n const phoneRegex = /^(\\+?\\d{1,4}[\\s-]?)?((\\(\\d{1,4}\\))|\\d{1,4})[\\s-]?\\d{1,4}[\\s-]?\\d{1,9}$/\n return !phoneRegex.test(strVal)\n }\n\n private handleUrl: IRuleValidatorHandler<T> = (value) => {\n if (!value) return false\n try {\n new URL(String(value))\n return false\n } catch {\n return true\n }\n }\n\n private handleFile: IRuleValidatorHandler<T> = (value, ruleOption) => {\n if (!value || (Array.isArray(value) && value.length === 0)) {\n const options = ruleOption?.options?.file\n if (options) {\n if (typeof options.count === 'number' && options.count > 0)\n return `{0} must have exactly ${options.count} file${options.count !== 1 ? 's' : ''}`\n if (typeof options.minCount === 'number' && options.minCount > 0)\n return `{0} must have at least ${options.minCount} file${options.minCount !== 1 ? 's' : ''}`\n }\n return false\n }\n\n // Normalize: parse JSON string (e.g. '[\"url1\",\"url2\"]') into an array\n let normalized = value\n if (typeof value === 'string' && value.startsWith('[')) {\n try {\n normalized = JSON.parse(value)\n } catch {\n /* keep as-is */\n }\n }\n const files: any[] = Array.isArray(normalized) ? normalized : [normalized]\n if (files.length === 0) {\n const options = ruleOption?.options?.file\n if (options) {\n if (typeof options.count === 'number' && options.count > 0)\n return `{0} must have exactly ${options.count} file${options.count !== 1 ? 's' : ''}`\n if (typeof options.minCount === 'number' && options.minCount > 0)\n return `{0} must have at least ${options.minCount} file${options.minCount !== 1 ? 's' : ''}`\n }\n return false\n }\n\n const options = ruleOption?.options?.file\n\n // Check count options against total items (both string URLs and File objects)\n if (options) {\n if (typeof options.count === 'number' && files.length !== options.count)\n return `{0} must have exactly ${options.count} file${options.count !== 1 ? 's' : ''}`\n if (typeof options.maxCount === 'number' && files.length > options.maxCount)\n return `{0} must have at most ${options.maxCount} file${options.maxCount !== 1 ? 's' : ''}`\n if (typeof options.minCount === 'number' && files.length < options.minCount)\n return `{0} must have at least ${options.minCount} file${options.minCount !== 1 ? 's' : ''}`\n }\n\n // Extract local File / file-like objects to perform size validation\n const fileObjs = files.filter((f) => f instanceof File || (f && typeof f === 'object' && typeof f.size === 'number'))\n\n if (options && fileObjs.length > 0) {\n if (typeof options.maxSize === 'number') {\n const maxSize = options.maxSize\n if (options.sumSize === true) {\n const totalSize = fileObjs.reduce((acc, f) => acc + (f?.size || 0), 0)\n if (totalSize > maxSize) return true\n } else {\n if (fileObjs.some((f) => f.size > maxSize)) return true\n }\n }\n }\n\n return false\n }\n\n private handleFileImage: IRuleValidatorHandler<T> = (value, ruleOption) => {\n if (!value || (Array.isArray(value) && value.length === 0)) {\n const options = ruleOption?.options?.image\n if (options) {\n if (typeof options.count === 'number' && options.count > 0)\n return `{0} must have exactly ${options.count} image${options.count !== 1 ? 's' : ''}`\n if (typeof options.minCount === 'number' && options.minCount > 0)\n return `{0} must have at least ${options.minCount} image${options.minCount !== 1 ? 's' : ''}`\n }\n return false\n }\n\n // Normalize: parse JSON string (e.g. '[\"url1\",\"url2\"]') into an array\n let normalized = value\n if (typeof value === 'string' && value.startsWith('[')) {\n try {\n normalized = JSON.parse(value)\n } catch {\n /* keep as-is */\n }\n }\n const files: any[] = Array.isArray(normalized) ? normalized : [normalized]\n if (files.length === 0) {\n const options = ruleOption?.options?.image\n if (options) {\n if (typeof options.count === 'number' && options.count > 0)\n return `{0} must have exactly ${options.count} image${options.count !== 1 ? 's' : ''}`\n if (typeof options.minCount === 'number' && options.minCount > 0)\n return `{0} must have at least ${options.minCount} image${options.minCount !== 1 ? 's' : ''}`\n }\n return false\n }\n\n const options = ruleOption?.options?.image\n\n // Check count options against total items (both string URLs and File objects)\n if (options) {\n if (typeof options.count === 'number' && files.length !== options.count)\n return `{0} must have exactly ${options.count} image${options.count !== 1 ? 's' : ''}`\n if (typeof options.maxCount === 'number' && files.length > options.maxCount)\n return `{0} must have at most ${options.maxCount} image${options.maxCount !== 1 ? 's' : ''}`\n if (typeof options.minCount === 'number' && files.length < options.minCount)\n return `{0} must have at least ${options.minCount} image${options.minCount !== 1 ? 's' : ''}`\n }\n\n // Extract local File / file-like objects to perform type and size validation\n const fileObjs = files.filter((f) => f instanceof File || (f && typeof f === 'object' && typeof f.size === 'number'))\n\n const isAllValidImages = fileObjs.every((f) => {\n const type = f.type || ''\n const name = f.name || ''\n const isImageType = typeof type === 'string' && type.startsWith('image/')\n const isImageExt = typeof name === 'string' && /\\.(jpg|jpeg|png|gif|webp|svg|bmp|ico|avif)$/i.test(name)\n return isImageType || isImageExt || f.width !== undefined || f.height !== undefined\n })\n\n if (fileObjs.length > 0 && !isAllValidImages) {\n return true\n }\n\n if (options && fileObjs.length > 0) {\n if (typeof options.maxSize === 'number') {\n const maxSize = options.maxSize\n if (options.sumSize === true) {\n const totalSize = fileObjs.reduce((acc, f) => acc + (f?.size || 0), 0)\n if (totalSize > maxSize) return true\n } else {\n if (fileObjs.some((f) => f.size > maxSize)) return true\n }\n }\n }\n\n if (options) {\n // Check width / height dimensions if present on file object\n for (const f of files) {\n if (!f || typeof f !== 'object') continue\n const width = f.width ?? f.dimensions?.width\n const height = f.height ?? f.dimensions?.height\n\n if (typeof width === 'number') {\n if (typeof options.maxWidth === 'number' && width > options.maxWidth) {\n return `The {0} image width must be less than ${options.maxWidth}px`\n }\n if (typeof options.minWidth === 'number' && width < options.minWidth) {\n return `The {0} image width must be at least ${options.minWidth}px`\n }\n }\n\n if (typeof height === 'number') {\n if (typeof options.maxHeight === 'number' && height > options.maxHeight) {\n return `The {0} image height must be less than ${options.maxHeight}px`\n }\n if (typeof options.minHeight === 'number' && height < options.minHeight) {\n return `The {0} image height must be at least ${options.minHeight}px`\n }\n }\n }\n }\n\n return false\n }\n\n private handleFileRequired: IRuleValidatorHandler<T> = (value) => {\n if (value === null || value === undefined || value === '' || value === '[]') return true\n if (Array.isArray(value)) {\n if (value.length === 0) return true\n return value.some((x) => !x || (x instanceof File && x.size <= 0))\n }\n if (value instanceof File) return value.size <= 0\n return false\n }\n\n private renderMessage = (ruleOption: IValidateRule, key: string, label?: string, message?: string | boolean): IValidateRule => {\n let resultMessage = ''\n\n if (!!message && typeof message === 'string') {\n resultMessage = message\n } else if (ruleOption.message) {\n resultMessage = ruleOption.message\n } else {\n resultMessage = defaultMessage[ruleOption.rule] ?? ''\n switch (ruleOption.rule) {\n case EValidateRule.Regex: {\n const custom = ruleOption.custom\n const patternStr = custom instanceof RegExp ? custom.source : String(custom ?? '')\n resultMessage = resultMessage.replace('{1}', patternStr)\n break\n }\n case EValidateRule.RequiredValue: {\n resultMessage = resultMessage.replace('{1}', ruleOption.custom?.toString() ?? '')\n break\n }\n case EValidateRule.File: {\n const options = ruleOption.options?.file\n if (options?.maxSize) {\n if (options.sumSize === true) {\n resultMessage = `Total ${label ?? key} file size must be less than ${formatFileSize(options.maxSize / 1024)}`\n } else {\n resultMessage = `The ${label ?? key} file size must be less than ${formatFileSize(options.maxSize / 1024)}`\n }\n }\n break\n }\n case EValidateRule.FileImage: {\n const options = ruleOption.options?.image\n if (options?.maxSize) {\n if (options.sumSize === true) {\n resultMessage = `Total ${label ?? key} image file size must be less than ${formatFileSize(options.maxSize / 1024)}`\n } else {\n resultMessage = `The ${label ?? key} image file size must be less than ${formatFileSize(options.maxSize / 1024)}`\n }\n }\n break\n }\n default:\n break\n }\n }\n resultMessage = resultMessage.replace('{0}', label ?? key)\n return {\n ...ruleOption,\n message: resultMessage\n }\n }\n\n private getRuleValidator = (rule: IValidateRuleType): IRuleValidatorHandler<T> | undefined => {\n switch (rule) {\n case EValidateRule.Required:\n return this.handleRequired\n case EValidateRule.Regex:\n return this.handleRegex\n case EValidateRule.RequiredValue:\n return this.handleRequiredValue\n case EValidateRule.Custom:\n return this.handleCustom\n case EValidateRule.Array:\n return this.handleArray\n case EValidateRule.Number:\n return this.handleNumber\n case EValidateRule.Email:\n return this.handleEmail\n case EValidateRule.PhoneNumber:\n return this.handlePhoneNumber\n case EValidateRule.Url:\n return this.handleUrl\n case EValidateRule.File:\n return this.handleFile\n case EValidateRule.FileImage:\n return this.handleFileImage\n case EValidateRule.FileRequired:\n return this.handleFileRequired\n default:\n return undefined\n }\n }\n\n private executed = (config: IFieldValidateConfig, valueField: any, model: any) => {\n return config.rules\n .map((ruleOption) => {\n const action = this.getRuleValidator(ruleOption.rule)\n const res = action && action(valueField, ruleOption, model)\n return { value: typeof res === 'boolean' ? res : (res as string), rule: ruleOption }\n })\n .filter((x) => x.value)\n }\n\n run = (model: T) => {\n const keys = Object.keys(this.configs)\n const data: IPartialError<T> = {}\n keys.forEach((key) => {\n const config = this.configs[key]\n if (!config) return\n const tmp = this.executed(config, (model as any)[key], model)\n if (tmp.length < 1) return\n ;(data as any)[key] = tmp.map((x) => this.renderMessage(x.rule, key, config.label, x.value))\n })\n return data\n }\n}\n\nexport default FormValidator\n\nexport const createFormValidator = <T>() => new FormValidator<Partial<T>>({})\n"],"names":["FormValidator","_createClass","configs","_this","this","_classCallCheck","_defineProperty","key","_fieldConfig$rules","fieldConfig","rules","_len","arguments","length","rule","Array","_key","push","apply","value","trim","isArray","ruleOption","custom","pattern","RegExp","_unused","test","String","undefined","model","_ruleOption$options","items","trimmed","startsWith","JSON","parse","_unused2","replace","_unused3","options","array","count","concat","minCount","maxCount","_ruleOption$options2","_typeof","num","Number","isNaN","number","min","max","strVal","URL","_unused4","_ruleOption$options5","_ruleOption$options3","file","normalized","_unused5","files","_ruleOption$options4","fileObjs","filter","f","File","size","maxSize","sumSize","reduce","acc","some","_ruleOption$options8","_ruleOption$options6","image","_unused6","_ruleOption$options7","isAllValidImages","every","type","name","isImageType","isImageExt","width","height","totalSize","_step","_iterator","_createForOfIteratorHelper","s","n","done","_f$width","_f$dimensions","_f$height","_f$dimensions2","dimensions","maxWidth","minWidth","maxHeight","minHeight","err","e","x","label","message","resultMessage","_defaultMessage$ruleO","defaultMessage","EValidateRule","Regex","patternStr","source","RequiredValue","_ruleOption$custom$to","_ruleOption$custom","toString","_ruleOption$options9","formatFileSize","FileImage","_ruleOption$options0","_objectSpread","Required","handleRequired","handleRegex","handleRequiredValue","Custom","handleCustom","handleArray","handleNumber","Email","handleEmail","PhoneNumber","handlePhoneNumber","Url","handleUrl","handleFile","handleFileImage","FileRequired","handleFileRequired","config","valueField","map","action","getRuleValidator","res","keys","Object","data","forEach","tmp","executed","renderMessage","createFormValidator"],"mappings":"qXAuDaA,EAAaC,EAExB,SAAAD,EAAYE,GAAgC,IAAAC,EAAAC,KAAAC,OAAAL,GAAAM,EAAAF,KAAA,WAMjC,SAACG,GAA6C,IAAAC,EACnDC,EAAcN,EAAKD,QAAQK,GAC1BE,IACHA,EAAc,CAAEC,MAAO,IACvBP,EAAKD,QAAQK,GAAOE,GACrB,IAAAE,IAAAA,EAAAC,UAAAC,OAL0BC,MAAwBC,MAAAJ,EAAAA,EAAAA,OAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAxBF,EAAwBE,EAAAJ,GAAAA,UAAAI,GAOnD,OADAR,EAAAC,EAAYC,OAAMO,KAAIC,MAAAV,EAAIM,GACnBX,IACRG,EAAAF,KAAA,iBAEkD,SAACe,GAClD,OAAIA,UAAmD,IAAVA,IACxB,iBAAVA,EAA4C,KAAjBA,EAAMC,SACxCL,MAAMM,QAAQF,IAAgC,IAAjBA,EAAMN,UAExCP,EAE+CF,KAAA,cAAA,SAACe,EAAOG,GACtD,IAAKH,EAAO,OAAO,EACnB,IAAMI,EAASD,aAAAA,EAAAA,EAAYC,OACvBC,EAAyB,KAE7B,GAAID,aAAkBE,OACpBD,EAAUD,OACL,GAAsB,iBAAXA,GA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