dinocollab-core 1.0.2 → 1.0.4
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.
- package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -487
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/dist/api-context/alert-global.js +1 -165
- package/dist/api-context/alert-global.js.map +1 -1
- package/dist/api-context/drawer-global.js +1 -111
- package/dist/api-context/drawer-global.js.map +1 -1
- package/dist/api-context/global-modal.js +1 -94
- package/dist/api-context/global-modal.js.map +1 -1
- package/dist/api-context/popover-global.js +1 -109
- package/dist/api-context/popover-global.js.map +1 -1
- package/dist/api-context/popover.js +1 -93
- package/dist/api-context/popover.js.map +1 -1
- package/dist/api-context/ui.units.js +1 -22
- package/dist/api-context/ui.units.js.map +1 -1
- package/dist/components/breadcrumbs.js +1 -64
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/copy-to-clipboard.js +1 -111
- package/dist/components/copy-to-clipboard.js.map +1 -1
- package/dist/components/help-tooltip.js +1 -103
- package/dist/components/help-tooltip.js.map +1 -1
- package/dist/components/image-with-fallback.js +1 -50
- package/dist/components/image-with-fallback.js.map +1 -1
- package/dist/components/text-editor.js +1 -117
- package/dist/components/text-editor.js.map +1 -1
- package/dist/components/text-editor.preview.js +1 -26
- package/dist/components/text-editor.preview.js.map +1 -1
- package/dist/form/create.autocomplete.chips.js +1 -227
- package/dist/form/create.autocomplete.chips.js.map +1 -1
- package/dist/form/create.date-expired.js +1 -210
- package/dist/form/create.date-expired.js.map +1 -1
- package/dist/form/create.date-picker.js +1 -127
- package/dist/form/create.date-picker.js.map +1 -1
- package/dist/form/create.form-base.js +1 -140
- package/dist/form/create.form-base.js.map +1 -1
- package/dist/form/create.form-comfirm.js +1 -130
- package/dist/form/create.form-comfirm.js.map +1 -1
- package/dist/form/create.form-grid-layout.js +1 -187
- package/dist/form/create.form-grid-layout.js.map +1 -1
- package/dist/form/create.form-grid-layout.units.js +1 -41
- package/dist/form/create.form-grid-layout.units.js.map +1 -1
- package/dist/form/create.input.file.js +1 -78
- package/dist/form/create.input.file.js.map +1 -1
- package/dist/form/create.input.js +1 -275
- package/dist/form/create.input.js.map +1 -1
- package/dist/form/create.select-simple.js +1 -113
- package/dist/form/create.select-simple.js.map +1 -1
- package/dist/form/create.select-with-api.js +1 -276
- package/dist/form/create.select-with-api.js.map +1 -1
- package/dist/form/create.text-editor.js +1 -180
- package/dist/form/create.text-editor.js.map +1 -1
- package/dist/form/dino-form.js +1 -40
- package/dist/form/dino-form.js.map +1 -1
- package/dist/form/helper.js +1 -156
- package/dist/form/helper.js.map +1 -1
- package/dist/form/modal-wrapper.js +1 -81
- package/dist/form/modal-wrapper.js.map +1 -1
- package/dist/form/validator.js +1 -189
- package/dist/form/validator.js.map +1 -1
- package/dist/hooks/index.js +1 -47
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.js +1 -32
- package/dist/index.js.map +1 -1
- package/dist/redux/create.hoc-lazy.js +1 -70
- package/dist/redux/create.hoc-lazy.js.map +1 -1
- package/dist/redux/dino.js +1 -10
- package/dist/redux/dino.js.map +1 -1
- package/dist/redux/types.js +1 -8
- package/dist/redux/types.js.map +1 -1
- package/dist/redux/ui.error-page.js +1 -88
- package/dist/redux/ui.error-page.js.map +1 -1
- package/dist/redux/vector-404.webp.js +1 -3
- package/dist/redux/vector-404.webp.js.map +1 -1
- package/dist/table/context.js +1 -14
- package/dist/table/context.js.map +1 -1
- package/dist/table/create.action-row.js +1 -143
- package/dist/table/create.action-row.js.map +1 -1
- package/dist/table/create.table.js +1 -245
- package/dist/table/create.table.js.map +1 -1
- package/dist/table/custom.filter-operators.js +1 -88
- package/dist/table/custom.filter-operators.js.map +1 -1
- package/dist/table/dino.js +1 -135
- package/dist/table/dino.js.map +1 -1
- package/dist/table/helpers.js +1 -114
- package/dist/table/helpers.js.map +1 -1
- package/dist/table/model-filter.js +1 -22
- package/dist/table/model-filter.js.map +1 -1
- package/dist/table/toolbar-pannel.js +1 -142
- package/dist/table/toolbar-pannel.js.map +1 -1
- package/dist/table/ui.buttons.js +1 -66
- package/dist/table/ui.buttons.js.map +1 -1
- package/dist/table/ui.units.js +1 -247
- package/dist/table/ui.units.js.map +1 -1
- package/dist/utils/dayjs-config.js +1 -11
- package/dist/utils/dayjs-config.js.map +1 -1
- package/dist/utils/helpers.js +1 -198
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/json-object.js +1 -37
- package/dist/utils/json-object.js.map +1 -1
- package/dist/utils/query-param.js +1 -171
- package/dist/utils/query-param.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,79 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { Component } from 'react';
|
|
4
|
-
import { TextField } from '@mui/material';
|
|
5
|
-
import { getErrorMessage } from './helper.js';
|
|
6
|
-
|
|
7
|
-
function CreateInputFile(params) {
|
|
8
|
-
var FormInputFile = /*#__PURE__*/function (_Component) {
|
|
9
|
-
function FormInputFile() {
|
|
10
|
-
var _this;
|
|
11
|
-
_classCallCheck(this, FormInputFile);
|
|
12
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
|
-
args[_key] = arguments[_key];
|
|
14
|
-
}
|
|
15
|
-
_this = _callSuper(this, FormInputFile, [].concat(args));
|
|
16
|
-
_defineProperty(_this, "refInput", null);
|
|
17
|
-
_defineProperty(_this, "getMergeConfig", function () {
|
|
18
|
-
var _params$accept, _ref, _params$multiple;
|
|
19
|
-
return {
|
|
20
|
-
accept: (_params$accept = params === null || params === void 0 ? void 0 : params.accept) !== null && _params$accept !== void 0 ? _params$accept : _this.props.accept,
|
|
21
|
-
multiple: (_ref = (_params$multiple = params === null || params === void 0 ? void 0 : params.multiple) !== null && _params$multiple !== void 0 ? _params$multiple : _this.props.multiple) !== null && _ref !== void 0 ? _ref : false
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
_defineProperty(_this, "handleChange", function (e) {
|
|
25
|
-
if (!_this.props.name) return;
|
|
26
|
-
_this.props.onBlur && _this.props.onBlur(_this.props.name);
|
|
27
|
-
});
|
|
28
|
-
_defineProperty(_this, "isExploreOpen", false);
|
|
29
|
-
_defineProperty(_this, "handleClick", function (e) {
|
|
30
|
-
_this.isExploreOpen = true;
|
|
31
|
-
});
|
|
32
|
-
_defineProperty(_this, "handleFocus", function (e) {
|
|
33
|
-
if (_this.isExploreOpen === true) {
|
|
34
|
-
_this.isExploreOpen = false;
|
|
35
|
-
if (!_this.props.name) return;
|
|
36
|
-
_this.props.onBlur && _this.props.onBlur(_this.props.name);
|
|
37
|
-
setTimeout(function () {
|
|
38
|
-
_this.refInput && _this.refInput.blur();
|
|
39
|
-
}, 50);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return _this;
|
|
43
|
-
}
|
|
44
|
-
_inherits(FormInputFile, _Component);
|
|
45
|
-
return _createClass(FormInputFile, [{
|
|
46
|
-
key: "render",
|
|
47
|
-
value: function render() {
|
|
48
|
-
var _this2 = this,
|
|
49
|
-
_this$props$name,
|
|
50
|
-
_this$props$textField;
|
|
51
|
-
var eMessage = getErrorMessage(this.props.messageErrors, this.props.name);
|
|
52
|
-
var configs = this.getMergeConfig();
|
|
53
|
-
return jsx(TextField, _objectSpread2(_objectSpread2({
|
|
54
|
-
inputRef: function inputRef(ref) {
|
|
55
|
-
return _this2.refInput = ref;
|
|
56
|
-
},
|
|
57
|
-
name: (_this$props$name = this.props.name) === null || _this$props$name === void 0 ? void 0 : _this$props$name.toString(),
|
|
58
|
-
error: eMessage.error,
|
|
59
|
-
helperText: eMessage.message,
|
|
60
|
-
variant: 'outlined',
|
|
61
|
-
type: 'file',
|
|
62
|
-
fullWidth: true,
|
|
63
|
-
onChange: this.handleChange,
|
|
64
|
-
onClick: this.handleClick,
|
|
65
|
-
onFocus: this.handleFocus
|
|
66
|
-
}, this.props.textFieldProps), {}, {
|
|
67
|
-
inputProps: _objectSpread2({
|
|
68
|
-
accept: configs.accept,
|
|
69
|
-
multiple: configs.multiple
|
|
70
|
-
}, (_this$props$textField = this.props.textFieldProps) === null || _this$props$textField === void 0 ? void 0 : _this$props$textField.inputProps)
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
}]);
|
|
74
|
-
}(Component);
|
|
75
|
-
return FormInputFile;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export { CreateInputFile as default };
|
|
1
|
+
import{inherits as e,createClass as r,objectSpread2 as n,classCallCheck as t,callSuper as o,defineProperty as p}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as i}from"react/jsx-runtime";import{Component as l}from"react";import{TextField as s}from"@mui/material";import{getErrorMessage as u}from"./helper.js";function a(a){var c=function(){function c(){var e;t(this,c);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return e=o(this,c,[].concat(n)),p(e,"refInput",null),p(e,"getMergeConfig",(function(){var r,n,t;return{accept:null!==(r=null==a?void 0:a.accept)&&void 0!==r?r:e.props.accept,multiple:null!==(n=null!==(t=null==a?void 0:a.multiple)&&void 0!==t?t:e.props.multiple)&&void 0!==n&&n}})),p(e,"handleChange",(function(r){e.props.name&&e.props.onBlur&&e.props.onBlur(e.props.name)})),p(e,"isExploreOpen",!1),p(e,"handleClick",(function(r){e.isExploreOpen=!0})),p(e,"handleFocus",(function(r){if(!0===e.isExploreOpen){if(e.isExploreOpen=!1,!e.props.name)return;e.props.onBlur&&e.props.onBlur(e.props.name),setTimeout((function(){e.refInput&&e.refInput.blur()}),50)}})),e}return e(c,l),r(c,[{key:"render",value:function(){var e,r,t=this,o=u(this.props.messageErrors,this.props.name),p=this.getMergeConfig();return i(s,n(n({inputRef:function(e){return t.refInput=e},name:null===(e=this.props.name)||void 0===e?void 0:e.toString(),error:o.error,helperText:o.message,variant:"outlined",type:"file",fullWidth:!0,onChange:this.handleChange,onClick:this.handleClick,onFocus:this.handleFocus},this.props.textFieldProps),{},{inputProps:n({accept:p.accept,multiple:p.multiple},null===(r=this.props.textFieldProps)||void 0===r?void 0:r.inputProps)}))}}])}();return c}export{a as default};
|
|
79
2
|
//# sourceMappingURL=create.input.file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.input.file.js","sources":["../../src/form/create.input.file.tsx"],"sourcesContent":["import React, { Component, ComponentType } from 'react'\r\nimport { TextField, TextFieldProps } from '@mui/material'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helper'\r\n\r\nexport interface IInputFileProps<T> extends IFormInputBase<T> {\r\n accept?: string\r\n multiple?: boolean\r\n textFieldProps?: TextFieldProps\r\n}\r\n\r\nexport interface IInputFileState {}\r\n\r\nexport interface IInputFileParams {\r\n accept?: string\r\n multiple?: boolean\r\n}\r\n\r\nfunction CreateInputFile<T>(params?: IInputFileParams): ComponentType<IFormInputBase<T>> {\r\n class FormInputFile extends Component<IInputFileProps<T>, IInputFileState> {\r\n refInput: HTMLInputElement | null = null\r\n\r\n render() {\r\n const eMessage = getErrorMessage(this.props.messageErrors, this.props.name)\r\n const configs = this.getMergeConfig()\r\n return (\r\n <TextField\r\n inputRef={(ref) => (this.refInput = ref)}\r\n name={this.props.name?.toString()}\r\n error={eMessage.error}\r\n helperText={eMessage.message}\r\n variant='outlined'\r\n type='file'\r\n fullWidth\r\n onChange={this.handleChange}\r\n onClick={this.handleClick}\r\n onFocus={this.handleFocus}\r\n {...this.props.textFieldProps}\r\n inputProps={{\r\n accept: configs.accept,\r\n multiple: configs.multiple,\r\n ...this.props.textFieldProps?.inputProps\r\n }}\r\n />\r\n )\r\n }\r\n\r\n getMergeConfig = () => ({\r\n accept: params?.accept ?? this.props.accept,\r\n multiple: params?.multiple ?? this.props.multiple ?? false\r\n })\r\n\r\n handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\r\n if (!this.props.name) return\r\n this.props.onBlur && this.props.onBlur(this.props.name)\r\n }\r\n\r\n isExploreOpen = false\r\n\r\n handleClick: React.MouseEventHandler<HTMLDivElement> = (e) => {\r\n this.isExploreOpen = true\r\n }\r\n\r\n handleFocus: React.FocusEventHandler<HTMLInputElement> = (e) => {\r\n if (this.isExploreOpen === true) {\r\n this.isExploreOpen = false\r\n if (!this.props.name) return\r\n this.props.onBlur && this.props.onBlur(this.props.name)\r\n setTimeout(() => {\r\n this.refInput && this.refInput.blur()\r\n }, 50)\r\n }\r\n }\r\n }\r\n return FormInputFile\r\n}\r\n\r\nexport default CreateInputFile\r\n"],"names":["CreateInputFile","params","FormInputFile","
|
|
1
|
+
{"version":3,"file":"create.input.file.js","sources":["../../src/form/create.input.file.tsx"],"sourcesContent":["import React, { Component, ComponentType } from 'react'\r\nimport { TextField, TextFieldProps } from '@mui/material'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helper'\r\n\r\nexport interface IInputFileProps<T> extends IFormInputBase<T> {\r\n accept?: string\r\n multiple?: boolean\r\n textFieldProps?: TextFieldProps\r\n}\r\n\r\nexport interface IInputFileState {}\r\n\r\nexport interface IInputFileParams {\r\n accept?: string\r\n multiple?: boolean\r\n}\r\n\r\nfunction CreateInputFile<T>(params?: IInputFileParams): ComponentType<IFormInputBase<T>> {\r\n class FormInputFile extends Component<IInputFileProps<T>, IInputFileState> {\r\n refInput: HTMLInputElement | null = null\r\n\r\n render() {\r\n const eMessage = getErrorMessage(this.props.messageErrors, this.props.name)\r\n const configs = this.getMergeConfig()\r\n return (\r\n <TextField\r\n inputRef={(ref) => (this.refInput = ref)}\r\n name={this.props.name?.toString()}\r\n error={eMessage.error}\r\n helperText={eMessage.message}\r\n variant='outlined'\r\n type='file'\r\n fullWidth\r\n onChange={this.handleChange}\r\n onClick={this.handleClick}\r\n onFocus={this.handleFocus}\r\n {...this.props.textFieldProps}\r\n inputProps={{\r\n accept: configs.accept,\r\n multiple: configs.multiple,\r\n ...this.props.textFieldProps?.inputProps\r\n }}\r\n />\r\n )\r\n }\r\n\r\n getMergeConfig = () => ({\r\n accept: params?.accept ?? this.props.accept,\r\n multiple: params?.multiple ?? this.props.multiple ?? false\r\n })\r\n\r\n handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\r\n if (!this.props.name) return\r\n this.props.onBlur && this.props.onBlur(this.props.name)\r\n }\r\n\r\n isExploreOpen = false\r\n\r\n handleClick: React.MouseEventHandler<HTMLDivElement> = (e) => {\r\n this.isExploreOpen = true\r\n }\r\n\r\n handleFocus: React.FocusEventHandler<HTMLInputElement> = (e) => {\r\n if (this.isExploreOpen === true) {\r\n this.isExploreOpen = false\r\n if (!this.props.name) return\r\n this.props.onBlur && this.props.onBlur(this.props.name)\r\n setTimeout(() => {\r\n this.refInput && this.refInput.blur()\r\n }, 50)\r\n }\r\n }\r\n }\r\n return FormInputFile\r\n}\r\n\r\nexport default CreateInputFile\r\n"],"names":["CreateInputFile","params","FormInputFile","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","this","concat","_defineProperty","_params$accept","_ref","_params$multiple","accept","props","multiple","e","name","onBlur","isExploreOpen","setTimeout","refInput","blur","_inherits","Component","_createClass","key","value","_this$props$name","_this$props$textField","_this2","eMessage","getErrorMessage","messageErrors","configs","getMergeConfig","_jsx","TextField","_objectSpread","inputRef","ref","toString","error","helperText","message","variant","type","fullWidth","onChange","handleChange","onClick","handleClick","onFocus","handleFocus","textFieldProps","inputProps"],"mappings":"iUAkBA,SAASA,EAAmBC,GAAyB,IAC7CC,aAAc,SAAAA,IAAA,IAAAC,EAAAC,OAAAF,GAAA,IAAA,IAAAG,EAAAC,UAAAC,OAAAC,EAAAC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAAF,EAAAE,GAAAJ,UAAAI,GAqDjB,OArDiBP,EAAAQ,EAAAC,KAAAV,EAAAW,GAAAA,OAAAL,IAAAM,EAAAX,EAAA,WACkB,MAAIW,EAAAX,EA2BvB,kBAAA,WAAA,IAAAY,EAAAC,EAAAC,EAAA,MAAO,CACtB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C,KAAK4C,YACdC,QAAS7C,KAAK8C,aACV9C,KAAKO,MAAMwC,gBAAc,CAAA,EAAA,CAC7BC,WAAUjB,EAAA,CACRzB,OAAQqB,EAAQrB,OAChBE,SAAUmB,EAAQnB,UACU,QADFc,EACvBtB,KAAKO,MAAMwC,sBAAc,IAAAzB,OAAA,EAAzBA,EAA2B0B,cAItC,IAAC,IA6BH,OAAO1D,CACT"}
|
|
@@ -1,276 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { Component } from 'react';
|
|
4
|
-
import { styled, Box, TextField, InputAdornment, IconButton, Collapse, CircularProgress } from '@mui/material';
|
|
5
|
-
import ContentPasteIcon from '@mui/icons-material/ContentPaste';
|
|
6
|
-
import { mergeObjects as _mergeObjects } from '../utils/helpers.js';
|
|
7
|
-
import '../utils/query-param.js';
|
|
8
|
-
import '../utils/dayjs-config.js';
|
|
9
|
-
import { getErrorMessage } from './helper.js';
|
|
10
|
-
import '../components/breadcrumbs.js';
|
|
11
|
-
import 'clipboard-copy';
|
|
12
|
-
import '@mui/icons-material/Done';
|
|
13
|
-
import '@mui/icons-material/ContentCopy';
|
|
14
|
-
import ImageWithFallback from '../components/image-with-fallback.js';
|
|
15
|
-
import '../components/help-tooltip.js';
|
|
16
|
-
import '../components/text-editor.js';
|
|
17
|
-
|
|
18
|
-
var _excluded = ["srcValue", "element", "alt", "fallbackSrc", "debounceDelay"];
|
|
19
|
-
var CreateInput = function CreateInput(params) {
|
|
20
|
-
var InputBase = /*#__PURE__*/function (_Component) {
|
|
21
|
-
function InputBase(props) {
|
|
22
|
-
var _this$mergeSlots;
|
|
23
|
-
var _this;
|
|
24
|
-
_classCallCheck(this, InputBase);
|
|
25
|
-
_this = _callSuper(this, InputBase, [props]);
|
|
26
|
-
_defineProperty(_this, "_cachedSlots", {});
|
|
27
|
-
_defineProperty(_this, "mapTextFieldProps", function () {
|
|
28
|
-
var _this$props$name, _this$state$value, _this$slots, _this$slots2;
|
|
29
|
-
var errorMessage = getErrorMessage(_this.props.messageErrors, _this.props.name);
|
|
30
|
-
var tfp = {
|
|
31
|
-
fullWidth: true,
|
|
32
|
-
variant: 'outlined',
|
|
33
|
-
name: (_this$props$name = _this.props.name) === null || _this$props$name === void 0 ? void 0 : _this$props$name.toString(),
|
|
34
|
-
error: errorMessage.error,
|
|
35
|
-
helperText: errorMessage.message,
|
|
36
|
-
disabled: _this.props.disabled,
|
|
37
|
-
onBlur: function onBlur() {
|
|
38
|
-
if (!_this.props.name) return;
|
|
39
|
-
_this.props.onBlur && _this.props.onBlur(_this.props.name);
|
|
40
|
-
},
|
|
41
|
-
label: _this.getLabel(),
|
|
42
|
-
placeholder: _this.props.placeholder,
|
|
43
|
-
InputLabelProps: !!_this.state.value ? {
|
|
44
|
-
shrink: true
|
|
45
|
-
} : {},
|
|
46
|
-
value: (_this$state$value = _this.state.value) !== null && _this$state$value !== void 0 ? _this$state$value : '',
|
|
47
|
-
onChange: _this.handleChange
|
|
48
|
-
};
|
|
49
|
-
if (_this.slots.pastenable === true) {
|
|
50
|
-
tfp.InputProps = {
|
|
51
|
-
endAdornment: jsx(InputAdornment, {
|
|
52
|
-
position: 'end',
|
|
53
|
-
children: jsx(IconButton, {
|
|
54
|
-
onClick: _this.handlePaste,
|
|
55
|
-
edge: 'end',
|
|
56
|
-
children: jsx(ContentPasteIcon, {})
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if ((_this$slots = _this.slots) !== null && _this$slots !== void 0 && _this$slots.maxLength) tfp.inputProps = _objectSpread2(_objectSpread2({}, tfp.inputProps), {}, {
|
|
62
|
-
maxLength: _this.slots.maxLength
|
|
63
|
-
});
|
|
64
|
-
return _mergeObjects({}, tfp, (_this$slots2 = _this.slots) === null || _this$slots2 === void 0 ? void 0 : _this$slots2.textFieldProps);
|
|
65
|
-
});
|
|
66
|
-
_defineProperty(_this, "renderImageSide", function (side) {
|
|
67
|
-
var _imageOther$src;
|
|
68
|
-
var image = side === 'left' ? _this.slots.imageLeft : _this.slots.imageRight;
|
|
69
|
-
if (!image) return jsx(Fragment, {});
|
|
70
|
-
var srcValue = image.srcValue,
|
|
71
|
-
element = image.element,
|
|
72
|
-
_image$alt = image.alt,
|
|
73
|
-
alt = _image$alt === void 0 ? 'input-image' : _image$alt,
|
|
74
|
-
_image$fallbackSrc = image.fallbackSrc,
|
|
75
|
-
fallbackSrc = _image$fallbackSrc === void 0 ? '' : _image$fallbackSrc,
|
|
76
|
-
_image$debounceDelay = image.debounceDelay,
|
|
77
|
-
debounceDelay = _image$debounceDelay === void 0 ? 700 : _image$debounceDelay,
|
|
78
|
-
imageOther = _objectWithoutProperties(image, _excluded);
|
|
79
|
-
if (element) {
|
|
80
|
-
var Element = element;
|
|
81
|
-
return jsx(WrapImage, {
|
|
82
|
-
children: jsx(Element, {
|
|
83
|
-
value: _this.state.value,
|
|
84
|
-
model: _this.props.data
|
|
85
|
-
})
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
var src = srcValue ? srcValue(_this.state.value, _this.props.data) : (_imageOther$src = imageOther.src) !== null && _imageOther$src !== void 0 ? _imageOther$src : _this.state.value;
|
|
89
|
-
var imageProps = {
|
|
90
|
-
src: src,
|
|
91
|
-
alt: alt,
|
|
92
|
-
fallbackSrc: fallbackSrc,
|
|
93
|
-
debounceDelay: debounceDelay
|
|
94
|
-
};
|
|
95
|
-
return jsx(Collapse, {
|
|
96
|
-
sx: {
|
|
97
|
-
mx: '10px'
|
|
98
|
-
},
|
|
99
|
-
"in": !!src,
|
|
100
|
-
unmountOnExit: true,
|
|
101
|
-
orientation: 'horizontal',
|
|
102
|
-
children: jsx(WrapImage, {
|
|
103
|
-
children: jsx(ImageWithFallback, _objectSpread2(_objectSpread2(_objectSpread2({}, imageOther), imageProps), {}, {
|
|
104
|
-
loading: jsx(LoadingCircularProgress, {})
|
|
105
|
-
}))
|
|
106
|
-
})
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
//#endregion
|
|
110
|
-
_defineProperty(_this, "mergeSlots", function (currentSlots) {
|
|
111
|
-
var base = _mergeObjects({}, params, currentSlots);
|
|
112
|
-
var imageLeft = base.imageLeft,
|
|
113
|
-
imageRight = base.imageRight;
|
|
114
|
-
// mirror from left to right
|
|
115
|
-
if (imageLeft !== null && imageLeft !== void 0 && imageLeft.mirror && !imageRight) {
|
|
116
|
-
base.imageRight = _objectSpread2({}, imageLeft);
|
|
117
|
-
delete base.imageRight.mirror;
|
|
118
|
-
}
|
|
119
|
-
// mirror from right to left
|
|
120
|
-
else if (imageRight !== null && imageRight !== void 0 && imageRight.mirror && !imageLeft) {
|
|
121
|
-
base.imageLeft = _objectSpread2({}, imageRight);
|
|
122
|
-
delete base.imageLeft.mirror;
|
|
123
|
-
}
|
|
124
|
-
return base;
|
|
125
|
-
});
|
|
126
|
-
_defineProperty(_this, "getLabel", function () {
|
|
127
|
-
var _this$slots3, _this$state$value$len, _this$state$value2;
|
|
128
|
-
if (!_this.props.label) return;
|
|
129
|
-
if (!((_this$slots3 = _this.slots) !== null && _this$slots3 !== void 0 && _this$slots3.maxLength)) return _this.props.label;
|
|
130
|
-
return "".concat(_this.props.label, " (").concat((_this$state$value$len = (_this$state$value2 = _this.state.value) === null || _this$state$value2 === void 0 ? void 0 : _this$state$value2.length) !== null && _this$state$value$len !== void 0 ? _this$state$value$len : 0, "/").concat(_this.slots.maxLength, ")");
|
|
131
|
-
});
|
|
132
|
-
_defineProperty(_this, "handleChange", function (event) {
|
|
133
|
-
_this.setState(function (st) {
|
|
134
|
-
return _objectSpread2(_objectSpread2({}, st), {}, {
|
|
135
|
-
value: event.target.value
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
_defineProperty(_this, "handlePaste", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
140
|
-
var clipboardText;
|
|
141
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
142
|
-
while (1) switch (_context.prev = _context.next) {
|
|
143
|
-
case 0:
|
|
144
|
-
_context.prev = 0;
|
|
145
|
-
_context.next = 3;
|
|
146
|
-
return navigator.clipboard.readText();
|
|
147
|
-
case 3:
|
|
148
|
-
clipboardText = _context.sent;
|
|
149
|
-
_this.setState({
|
|
150
|
-
value: clipboardText
|
|
151
|
-
});
|
|
152
|
-
_context.next = 10;
|
|
153
|
-
break;
|
|
154
|
-
case 7:
|
|
155
|
-
_context.prev = 7;
|
|
156
|
-
_context.t0 = _context["catch"](0);
|
|
157
|
-
console.error('Error clipboard:', _context.t0);
|
|
158
|
-
case 10:
|
|
159
|
-
case "end":
|
|
160
|
-
return _context.stop();
|
|
161
|
-
}
|
|
162
|
-
}, _callee, null, [[0, 7]]);
|
|
163
|
-
})));
|
|
164
|
-
_this._cachedSlots = (_this$mergeSlots = _this.mergeSlots(props.slots)) !== null && _this$mergeSlots !== void 0 ? _this$mergeSlots : {};
|
|
165
|
-
_this.state = {
|
|
166
|
-
value: _this.defaulValue
|
|
167
|
-
};
|
|
168
|
-
return _this;
|
|
169
|
-
}
|
|
170
|
-
_inherits(InputBase, _Component);
|
|
171
|
-
return _createClass(InputBase, [{
|
|
172
|
-
key: "slots",
|
|
173
|
-
get: function get() {
|
|
174
|
-
return this._cachedSlots;
|
|
175
|
-
}
|
|
176
|
-
}, {
|
|
177
|
-
key: "defaulValue",
|
|
178
|
-
get: function get() {
|
|
179
|
-
var _this$props$defaultVa, _data$name;
|
|
180
|
-
var _this$props = this.props,
|
|
181
|
-
data = _this$props.data,
|
|
182
|
-
name = _this$props.name;
|
|
183
|
-
return (_this$props$defaultVa = this.props.defaultValue) !== null && _this$props$defaultVa !== void 0 ? _this$props$defaultVa : !!data && !!name ? (_data$name = data[name]) === null || _data$name === void 0 ? void 0 : _data$name.toString() : undefined;
|
|
184
|
-
}
|
|
185
|
-
}, {
|
|
186
|
-
key: "componentDidUpdate",
|
|
187
|
-
value: function componentDidUpdate(prevProps) {
|
|
188
|
-
if (prevProps.slots !== this.props.slots) {
|
|
189
|
-
this._cachedSlots = this.mergeSlots(this.props.slots);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}, {
|
|
193
|
-
key: "shouldComponentUpdate",
|
|
194
|
-
value: function shouldComponentUpdate(nextProps) {
|
|
195
|
-
var _this$props2 = this.props,
|
|
196
|
-
name = _this$props2.name,
|
|
197
|
-
slots = _this$props2.slots;
|
|
198
|
-
if (!!name) {
|
|
199
|
-
var _this$props$data$name, _this$props$data, _nextProps$data$name$, _nextProps$data;
|
|
200
|
-
var currentDataValue = (_this$props$data$name = (_this$props$data = this.props.data) === null || _this$props$data === void 0 || (_this$props$data = _this$props$data[name]) === null || _this$props$data === void 0 ? void 0 : _this$props$data.toString()) !== null && _this$props$data$name !== void 0 ? _this$props$data$name : '';
|
|
201
|
-
var nextDataValue = (_nextProps$data$name$ = (_nextProps$data = nextProps.data) === null || _nextProps$data === void 0 || (_nextProps$data = _nextProps$data[name]) === null || _nextProps$data === void 0 ? void 0 : _nextProps$data.toString()) !== null && _nextProps$data$name$ !== void 0 ? _nextProps$data$name$ : '';
|
|
202
|
-
if (currentDataValue !== nextDataValue) {
|
|
203
|
-
this.setState({
|
|
204
|
-
value: nextDataValue
|
|
205
|
-
});
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (slots !== nextProps.slots) {
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
key: "render",
|
|
216
|
-
value:
|
|
217
|
-
//#region Render
|
|
218
|
-
function render() {
|
|
219
|
-
var _this$props$name2;
|
|
220
|
-
return jsxs(Box, {
|
|
221
|
-
sx: {
|
|
222
|
-
display: 'flex',
|
|
223
|
-
alignItems: 'center'
|
|
224
|
-
},
|
|
225
|
-
children: [!!this.props.disabled && jsx("input", {
|
|
226
|
-
hidden: true,
|
|
227
|
-
name: (_this$props$name2 = this.props.name) === null || _this$props$name2 === void 0 ? void 0 : _this$props$name2.toString(),
|
|
228
|
-
defaultValue: this.defaulValue
|
|
229
|
-
}), this.renderImageSide('left'), jsx(TextField, _objectSpread2({}, this.mapTextFieldProps())), this.renderImageSide('right')]
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}]);
|
|
233
|
-
}(Component);
|
|
234
|
-
return InputBase;
|
|
235
|
-
};
|
|
236
|
-
// export type InputTextType<T> = ReturnType<typeof CreateInputBase<T>>
|
|
237
|
-
var LoadingCircularProgress = function LoadingCircularProgress() {
|
|
238
|
-
return jsx("div", {
|
|
239
|
-
children: jsx(CircularProgress, {
|
|
240
|
-
size: 24
|
|
241
|
-
})
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
var WrapImage = styled(Box)({
|
|
245
|
-
fontSize: '1rem',
|
|
246
|
-
height: 'var(--input-base-image-size, 54px)',
|
|
247
|
-
width: 'var(--input-base-image-size, 54px)',
|
|
248
|
-
position: 'relative',
|
|
249
|
-
borderRadius: '8px',
|
|
250
|
-
boxShadow: 'rgba(0, 0, 0, 0.16) 0px 1px 4px',
|
|
251
|
-
overflow: 'hidden',
|
|
252
|
-
'& > img': {
|
|
253
|
-
position: 'absolute',
|
|
254
|
-
top: 0,
|
|
255
|
-
left: 0,
|
|
256
|
-
backgroundRepeat: 'no-repeat',
|
|
257
|
-
height: '100%',
|
|
258
|
-
width: '100%',
|
|
259
|
-
backgroundSize: 'contain'
|
|
260
|
-
},
|
|
261
|
-
'& > div': {
|
|
262
|
-
position: 'absolute',
|
|
263
|
-
top: 0,
|
|
264
|
-
left: 0,
|
|
265
|
-
height: '100%',
|
|
266
|
-
width: '100%',
|
|
267
|
-
background: '#fafafa',
|
|
268
|
-
zIndex: 1,
|
|
269
|
-
display: 'flex',
|
|
270
|
-
alignItems: 'center',
|
|
271
|
-
justifyContent: 'center'
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
export { CreateInput as default };
|
|
1
|
+
import{inherits as e,createClass as t,objectSpread2 as r,classCallCheck as o,callSuper as a,defineProperty as i,objectWithoutProperties as n,asyncToGenerator as l,regeneratorRuntime as s}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as u,jsx as p,Fragment as d}from"react/jsx-runtime";import{Component as c}from"react";import{styled as m,Box as h,TextField as v,InputAdornment as f,IconButton as g,Collapse as b,CircularProgress as x}from"@mui/material";import S from"@mui/icons-material/ContentPaste";import{mergeObjects as k}from"../utils/helpers.js";import"../utils/query-param.js";import"../utils/dayjs-config.js";import{getErrorMessage as y}from"./helper.js";import"../components/breadcrumbs.js";import"clipboard-copy";import"@mui/icons-material/Done";import"@mui/icons-material/ContentCopy";import j from"../components/image-with-fallback.js";import"../components/help-tooltip.js";import"../components/text-editor.js";var P=["srcValue","element","alt","fallbackSrc","debounceDelay"],C=function(m){return function(){function x(e){var t,u;return o(this,x),u=a(this,x,[e]),i(u,"_cachedSlots",{}),i(u,"mapTextFieldProps",(function(){var e,t,o,a,i=y(u.props.messageErrors,u.props.name),n={fullWidth:!0,variant:"outlined",name:null===(e=u.props.name)||void 0===e?void 0:e.toString(),error:i.error,helperText:i.message,disabled:u.props.disabled,onBlur:function(){u.props.name&&u.props.onBlur&&u.props.onBlur(u.props.name)},label:u.getLabel(),placeholder:u.props.placeholder,InputLabelProps:u.state.value?{shrink:!0}:{},value:null!==(t=u.state.value)&&void 0!==t?t:"",onChange:u.handleChange};return!0===u.slots.pastenable&&(n.InputProps={endAdornment:p(f,{position:"end",children:p(g,{onClick:u.handlePaste,edge:"end",children:p(S,{})})})}),null!==(o=u.slots)&&void 0!==o&&o.maxLength&&(n.inputProps=r(r({},n.inputProps),{},{maxLength:u.slots.maxLength})),k({},n,null===(a=u.slots)||void 0===a?void 0:a.textFieldProps)})),i(u,"renderImageSide",(function(e){var t,o="left"===e?u.slots.imageLeft:u.slots.imageRight;if(!o)return p(d,{});var a=o.srcValue,i=o.element,l=o.alt,s=void 0===l?"input-image":l,c=o.fallbackSrc,m=void 0===c?"":c,h=o.debounceDelay,v=void 0===h?700:h,f=n(o,P);if(i)return p(w,{children:p(i,{value:u.state.value,model:u.props.data})});var g=a?a(u.state.value,u.props.data):null!==(t=f.src)&&void 0!==t?t:u.state.value,x={src:g,alt:s,fallbackSrc:m,debounceDelay:v};return p(b,{sx:{mx:"10px"},in:!!g,unmountOnExit:!0,orientation:"horizontal",children:p(w,{children:p(j,r(r(r({},f),x),{},{loading:p(L,{})}))})})})),i(u,"mergeSlots",(function(e){var t=k({},m,e),o=t.imageLeft,a=t.imageRight;return null!=o&&o.mirror&&!a?(t.imageRight=r({},o),delete t.imageRight.mirror):null!=a&&a.mirror&&!o&&(t.imageLeft=r({},a),delete t.imageLeft.mirror),t})),i(u,"getLabel",(function(){var e,t,r;if(u.props.label)return null!==(e=u.slots)&&void 0!==e&&e.maxLength?"".concat(u.props.label," (").concat(null!==(t=null===(r=u.state.value)||void 0===r?void 0:r.length)&&void 0!==t?t:0,"/").concat(u.slots.maxLength,")"):u.props.label})),i(u,"handleChange",(function(e){u.setState((function(t){return r(r({},t),{},{value:e.target.value})}))})),i(u,"handlePaste",l(s().mark((function e(){var t;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.clipboard.readText();case 3:t=e.sent,u.setState({value:t}),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.error("Error clipboard:",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))),u._cachedSlots=null!==(t=u.mergeSlots(e.slots))&&void 0!==t?t:{},u.state={value:u.defaulValue},u}return e(x,c),t(x,[{key:"slots",get:function(){return this._cachedSlots}},{key:"defaulValue",get:function(){var e,t,r=this.props,o=r.data,a=r.name;return null!==(e=this.props.defaultValue)&&void 0!==e?e:o&&a?null===(t=o[a])||void 0===t?void 0:t.toString():void 0}},{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 o,a,i,n,l=null!==(o=null===(a=this.props.data)||void 0===a||null===(a=a[r])||void 0===a?void 0:a.toString())&&void 0!==o?o:"",s=null!==(i=null===(n=e.data)||void 0===n||null===(n=n[r])||void 0===n?void 0:n.toString())&&void 0!==i?i:"";if(l!==s)return this.setState({value:s}),!1}return e.slots,!0}},{key:"render",value:function(){var e;return u(h,{sx:{display:"flex",alignItems:"center"},children:[!!this.props.disabled&&p("input",{hidden:!0,name:null===(e=this.props.name)||void 0===e?void 0:e.toString(),defaultValue:this.defaulValue}),this.renderImageSide("left"),p(v,r({},this.mapTextFieldProps())),this.renderImageSide("right")]})}}])}()},L=function(){return p("div",{children:p(x,{size:24})})},w=m(h)({fontSize:"1rem",height:"var(--input-base-image-size, 54px)",width:"var(--input-base-image-size, 54px)",position:"relative",borderRadius:"8px",boxShadow:"rgba(0, 0, 0, 0.16) 0px 1px 4px",overflow:"hidden","& > 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{C as default};
|
|
276
2
|
//# sourceMappingURL=create.input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.input.js","sources":["../../src/form/create.input.tsx"],"sourcesContent":["import React, { Component, ComponentType, FC } from 'react'\r\nimport { Box, CircularProgress, Collapse, IconButton, InputAdornment, styled, TextField, TextFieldProps } from '@mui/material'\r\nimport ContentPasteIcon from '@mui/icons-material/ContentPaste'\r\nimport { mergeObjects } from '../utils'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helper'\r\nimport { ImageWithFallback, IImageWithFallbackPropsOwner } from '../components'\r\n\r\nexport interface InputBaseImage<T> extends Partial<IImageWithFallbackPropsOwner> {\r\n srcValue?: (value: any, model?: Partial<T>) => string\r\n element?: React.ComponentType<{ value: any; model?: Partial<T> }>\r\n mirror?: boolean\r\n}\r\n\r\nexport interface IInputSlots<T> {\r\n maxLength?: number\r\n textFieldProps?: TextFieldProps\r\n pastenable?: boolean\r\n imageLeft?: InputBaseImage<T>\r\n imageRight?: InputBaseImage<T>\r\n}\r\n\r\nexport interface IInputProps<T> extends IFormInputBase<T> {\r\n slots?: IInputSlots<T>\r\n}\r\n\r\nexport interface IInputState {\r\n value?: string\r\n}\r\n\r\nexport interface IInputParams<T> extends IInputSlots<T> {}\r\n\r\nconst CreateInput = function <T>(params?: IInputParams<T>): ComponentType<IInputProps<T>> {\r\n class InputBase extends Component<IInputProps<T>, IInputState> {\r\n private _cachedSlots: IInputSlots<T> = {}\r\n constructor(props: IInputProps<T>) {\r\n super(props)\r\n this._cachedSlots = this.mergeSlots(props.slots) ?? {}\r\n this.state = { value: this.defaulValue }\r\n }\r\n\r\n get slots() {\r\n return this._cachedSlots\r\n }\r\n\r\n get defaulValue(): string {\r\n const { data, name } = this.props\r\n return this.props.defaultValue ?? (!!data && !!name ? data[name]?.toString() : undefined)\r\n }\r\n\r\n componentDidUpdate(prevProps: IInputProps<T>) {\r\n if (prevProps.slots !== this.props.slots) {\r\n this._cachedSlots = this.mergeSlots(this.props.slots)\r\n }\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<IInputProps<T>>): boolean {\r\n const { name, slots } = this.props\r\n if (!!name) {\r\n const currentDataValue = this.props.data?.[name]?.toString() ?? ''\r\n const nextDataValue = nextProps.data?.[name]?.toString() ?? ''\r\n if (currentDataValue !== nextDataValue) {\r\n this.setState({ value: nextDataValue })\r\n return false\r\n }\r\n }\r\n\r\n if (slots !== nextProps.slots) {\r\n return true\r\n }\r\n return true\r\n }\r\n\r\n mapTextFieldProps = (): TextFieldProps => {\r\n const errorMessage = getErrorMessage(this.props.messageErrors, this.props.name)\r\n const tfp: TextFieldProps = {\r\n fullWidth: true,\r\n variant: 'outlined',\r\n name: this.props.name?.toString(),\r\n error: errorMessage.error,\r\n helperText: errorMessage.message,\r\n disabled: this.props.disabled,\r\n onBlur: () => {\r\n if (!this.props.name) return\r\n this.props.onBlur && this.props.onBlur(this.props.name)\r\n },\r\n label: this.getLabel(),\r\n placeholder: this.props.placeholder,\r\n InputLabelProps: !!this.state.value ? { shrink: true } : {},\r\n value: this.state.value ?? '',\r\n onChange: this.handleChange\r\n }\r\n if (this.slots.pastenable === true) {\r\n tfp.InputProps = {\r\n endAdornment: (\r\n <InputAdornment position='end'>\r\n <IconButton onClick={this.handlePaste} edge='end'>\r\n <ContentPasteIcon />\r\n </IconButton>\r\n </InputAdornment>\r\n )\r\n }\r\n }\r\n if (this.slots?.maxLength) tfp.inputProps = { ...tfp.inputProps, maxLength: this.slots.maxLength }\r\n return mergeObjects<TextFieldProps>({}, tfp, this.slots?.textFieldProps)\r\n }\r\n\r\n //#region Render\r\n render() {\r\n return (\r\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\r\n {!!this.props.disabled && <input hidden name={this.props.name?.toString()} defaultValue={this.defaulValue} />}\r\n {this.renderImageSide('left')}\r\n <TextField {...this.mapTextFieldProps()} />\r\n {this.renderImageSide('right')}\r\n </Box>\r\n )\r\n }\r\n\r\n renderImageSide = (side: 'left' | 'right') => {\r\n const image = side === 'left' ? this.slots.imageLeft : this.slots.imageRight\r\n if (!image) return <></>\r\n const { srcValue, element, alt = 'input-image', fallbackSrc = '', debounceDelay = 700, ...imageOther } = image\r\n if (element) {\r\n const Element = element\r\n return (\r\n <WrapImage>\r\n <Element value={this.state.value} model={this.props.data} />\r\n </WrapImage>\r\n )\r\n }\r\n const src = srcValue ? srcValue(this.state.value, this.props.data) : imageOther.src ?? this.state.value\r\n const imageProps: IImageWithFallbackPropsOwner = { src, alt, fallbackSrc, debounceDelay }\r\n return (\r\n <Collapse sx={{ mx: '10px' }} in={!!src} unmountOnExit orientation='horizontal'>\r\n <WrapImage>\r\n <ImageWithFallback {...imageOther} {...imageProps} loading={<LoadingCircularProgress />} />\r\n </WrapImage>\r\n </Collapse>\r\n )\r\n }\r\n //#endregion\r\n\r\n private mergeSlots = (currentSlots?: IInputSlots<T>): IInputSlots<T> => {\r\n const base = mergeObjects<IInputSlots<T>>({}, params, currentSlots)\r\n const { imageLeft, imageRight } = base\r\n\r\n // mirror from left to right\r\n if (imageLeft?.mirror && !imageRight) {\r\n base.imageRight = { ...imageLeft }\r\n delete base.imageRight.mirror\r\n }\r\n // mirror from right to left\r\n else if (imageRight?.mirror && !imageLeft) {\r\n base.imageLeft = { ...imageRight }\r\n delete base.imageLeft.mirror\r\n }\r\n\r\n return base\r\n }\r\n\r\n getLabel = () => {\r\n if (!this.props.label) return\r\n if (!this.slots?.maxLength) return this.props.label\r\n return `${this.props.label} (${this.state.value?.length ?? 0}/${this.slots.maxLength})`\r\n }\r\n\r\n handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\r\n this.setState((st) => ({ ...st, value: event.target.value }))\r\n }\r\n\r\n handlePaste = async () => {\r\n try {\r\n const clipboardText = await navigator.clipboard.readText()\r\n this.setState({ value: clipboardText })\r\n } catch (error) {\r\n console.error('Error clipboard:', error)\r\n }\r\n }\r\n }\r\n return InputBase\r\n}\r\n\r\nexport default CreateInput\r\n\r\n// export type InputTextType<T> = ReturnType<typeof CreateInputBase<T>>\r\n\r\nconst LoadingCircularProgress: FC = () => (\r\n <div>\r\n <CircularProgress size={24} />\r\n </div>\r\n)\r\n\r\nconst WrapImage = styled(Box)({\r\n fontSize: '1rem',\r\n height: 'var(--input-base-image-size, 54px)',\r\n width: 'var(--input-base-image-size, 54px)',\r\n position: 'relative',\r\n borderRadius: '8px',\r\n boxShadow: 'rgba(0, 0, 0, 0.16) 0px 1px 4px',\r\n overflow: 'hidden',\r\n '& > img': {\r\n position: 'absolute',\r\n top: 0,\r\n left: 0,\r\n backgroundRepeat: 'no-repeat',\r\n height: '100%',\r\n width: '100%',\r\n backgroundSize: 'contain'\r\n },\r\n '& > div': {\r\n position: 'absolute',\r\n top: 0,\r\n left: 0,\r\n height: '100%',\r\n width: '100%',\r\n background: '#fafafa',\r\n zIndex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n }\r\n})\r\n"],"names":["CreateInput","params","InputBase","_Component","props","_this$mergeSlots","_this","_classCallCheck","_callSuper","_defineProperty","_this$props$name","_this$state$value","_this$slots","_this$slots2","errorMessage","getErrorMessage","messageErrors","name","tfp","fullWidth","variant","toString","error","helperText","message","disabled","onBlur","label","getLabel","placeholder","InputLabelProps","state","value","shrink","onChange","handleChange","slots","pastenable","InputProps","endAdornment","_jsx","InputAdornment","position","children","IconButton","onClick","handlePaste","edge","ContentPasteIcon","maxLength","inputProps","_objectSpread","mergeObjects","textFieldProps","side","_imageOther$src","image","imageLeft","imageRight","srcValue","element","_image$alt","alt","_image$fallbackSrc","fallbackSrc","_image$debounceDelay","debounceDelay","imageOther","_objectWithoutProperties","_excluded","Element","WrapImage","model","data","src","imageProps","Collapse","sx","mx","unmountOnExit","orientation","ImageWithFallback","loading","LoadingCircularProgress","currentSlots","base","mirror","_this$slots3","_this$state$value$len","_this$state$value2","concat","length","event","setState","st","target","_asyncToGenerator","_regeneratorRuntime","mark","_callee","clipboardText","wrap","_callee$","_context","prev","next","navigator","clipboard","readText","sent","t0","console","stop","_cachedSlots","mergeSlots","defaulValue","_inherits","_createClass","key","get","_this$props$defaultVa","_data$name","_this$props","defaultValue","undefined","componentDidUpdate","prevProps","shouldComponentUpdate","nextProps","_this$props2","_this$props$data$name","_this$props$data","_nextProps$data$name$","_nextProps$data","currentDataValue","nextDataValue","render","_this$props$name2","_jsxs","Box","display","alignItems","hidden","renderImageSide","TextField","mapTextFieldProps","Component","CircularProgress","size","styled","fontSize","height","width","borderRadius","boxShadow","overflow","top","left","backgroundRepeat","backgroundSize","background","zIndex","justifyContent"],"mappings":";;;;;;;;;;;;;;;;;;AAgCA,IAAM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,QAAQ;AACpBqB,IAAAA,cAAc,EAAE;AACjB;AACF,CAAA,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"create.input.js","sources":["../../src/form/create.input.tsx"],"sourcesContent":["import React, { Component, ComponentType, FC } from 'react'\r\nimport { Box, CircularProgress, Collapse, IconButton, InputAdornment, styled, TextField, TextFieldProps } from '@mui/material'\r\nimport ContentPasteIcon from '@mui/icons-material/ContentPaste'\r\nimport { mergeObjects } from '../utils'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helper'\r\nimport { ImageWithFallback, IImageWithFallbackPropsOwner } from '../components'\r\n\r\nexport interface InputBaseImage<T> extends Partial<IImageWithFallbackPropsOwner> {\r\n srcValue?: (value: any, model?: Partial<T>) => string\r\n element?: React.ComponentType<{ value: any; model?: Partial<T> }>\r\n mirror?: boolean\r\n}\r\n\r\nexport interface IInputSlots<T> {\r\n maxLength?: number\r\n textFieldProps?: TextFieldProps\r\n pastenable?: boolean\r\n imageLeft?: InputBaseImage<T>\r\n imageRight?: InputBaseImage<T>\r\n}\r\n\r\nexport interface IInputProps<T> extends IFormInputBase<T> {\r\n slots?: IInputSlots<T>\r\n}\r\n\r\nexport interface IInputState {\r\n value?: string\r\n}\r\n\r\nexport interface IInputParams<T> extends IInputSlots<T> {}\r\n\r\nconst CreateInput = function <T>(params?: IInputParams<T>): ComponentType<IInputProps<T>> {\r\n class InputBase extends Component<IInputProps<T>, IInputState> {\r\n private _cachedSlots: IInputSlots<T> = {}\r\n constructor(props: IInputProps<T>) {\r\n super(props)\r\n this._cachedSlots = this.mergeSlots(props.slots) ?? {}\r\n this.state = { value: this.defaulValue }\r\n }\r\n\r\n get slots() {\r\n return this._cachedSlots\r\n }\r\n\r\n get defaulValue(): string {\r\n const { data, name } = this.props\r\n return this.props.defaultValue ?? (!!data && !!name ? data[name]?.toString() : undefined)\r\n }\r\n\r\n componentDidUpdate(prevProps: IInputProps<T>) {\r\n if (prevProps.slots !== this.props.slots) {\r\n this._cachedSlots = this.mergeSlots(this.props.slots)\r\n }\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<IInputProps<T>>): boolean {\r\n const { name, slots } = this.props\r\n if (!!name) {\r\n const currentDataValue = this.props.data?.[name]?.toString() ?? ''\r\n const nextDataValue = nextProps.data?.[name]?.toString() ?? ''\r\n if (currentDataValue !== nextDataValue) {\r\n this.setState({ value: nextDataValue })\r\n return false\r\n }\r\n }\r\n\r\n if (slots !== nextProps.slots) {\r\n return true\r\n }\r\n return true\r\n }\r\n\r\n mapTextFieldProps = (): TextFieldProps => {\r\n const errorMessage = getErrorMessage(this.props.messageErrors, this.props.name)\r\n const tfp: TextFieldProps = {\r\n fullWidth: true,\r\n variant: 'outlined',\r\n name: this.props.name?.toString(),\r\n error: errorMessage.error,\r\n helperText: errorMessage.message,\r\n disabled: this.props.disabled,\r\n onBlur: () => {\r\n if (!this.props.name) return\r\n this.props.onBlur && this.props.onBlur(this.props.name)\r\n },\r\n label: this.getLabel(),\r\n placeholder: this.props.placeholder,\r\n InputLabelProps: !!this.state.value ? { shrink: true } : {},\r\n value: this.state.value ?? '',\r\n onChange: this.handleChange\r\n }\r\n if (this.slots.pastenable === true) {\r\n tfp.InputProps = {\r\n endAdornment: (\r\n <InputAdornment position='end'>\r\n <IconButton onClick={this.handlePaste} edge='end'>\r\n <ContentPasteIcon />\r\n </IconButton>\r\n </InputAdornment>\r\n )\r\n }\r\n }\r\n if (this.slots?.maxLength) tfp.inputProps = { ...tfp.inputProps, maxLength: this.slots.maxLength }\r\n return mergeObjects<TextFieldProps>({}, tfp, this.slots?.textFieldProps)\r\n }\r\n\r\n //#region Render\r\n render() {\r\n return (\r\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\r\n {!!this.props.disabled && <input hidden name={this.props.name?.toString()} defaultValue={this.defaulValue} />}\r\n {this.renderImageSide('left')}\r\n <TextField {...this.mapTextFieldProps()} />\r\n {this.renderImageSide('right')}\r\n </Box>\r\n )\r\n }\r\n\r\n renderImageSide = (side: 'left' | 'right') => {\r\n const image = side === 'left' ? this.slots.imageLeft : this.slots.imageRight\r\n if (!image) return <></>\r\n const { srcValue, element, alt = 'input-image', fallbackSrc = '', debounceDelay = 700, ...imageOther } = image\r\n if (element) {\r\n const Element = element\r\n return (\r\n <WrapImage>\r\n <Element value={this.state.value} model={this.props.data} />\r\n </WrapImage>\r\n )\r\n }\r\n const src = srcValue ? srcValue(this.state.value, this.props.data) : imageOther.src ?? this.state.value\r\n const imageProps: IImageWithFallbackPropsOwner = { src, alt, fallbackSrc, debounceDelay }\r\n return (\r\n <Collapse sx={{ mx: '10px' }} in={!!src} unmountOnExit orientation='horizontal'>\r\n <WrapImage>\r\n <ImageWithFallback {...imageOther} {...imageProps} loading={<LoadingCircularProgress />} />\r\n </WrapImage>\r\n </Collapse>\r\n )\r\n }\r\n //#endregion\r\n\r\n private mergeSlots = (currentSlots?: IInputSlots<T>): IInputSlots<T> => {\r\n const base = mergeObjects<IInputSlots<T>>({}, params, currentSlots)\r\n const { imageLeft, imageRight } = base\r\n\r\n // mirror from left to right\r\n if (imageLeft?.mirror && !imageRight) {\r\n base.imageRight = { ...imageLeft }\r\n delete base.imageRight.mirror\r\n }\r\n // mirror from right to left\r\n else if (imageRight?.mirror && !imageLeft) {\r\n base.imageLeft = { ...imageRight }\r\n delete base.imageLeft.mirror\r\n }\r\n\r\n return base\r\n }\r\n\r\n getLabel = () => {\r\n if (!this.props.label) return\r\n if (!this.slots?.maxLength) return this.props.label\r\n return `${this.props.label} (${this.state.value?.length ?? 0}/${this.slots.maxLength})`\r\n }\r\n\r\n handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\r\n this.setState((st) => ({ ...st, value: event.target.value }))\r\n }\r\n\r\n handlePaste = async () => {\r\n try {\r\n const clipboardText = await navigator.clipboard.readText()\r\n this.setState({ value: clipboardText })\r\n } catch (error) {\r\n console.error('Error clipboard:', error)\r\n }\r\n }\r\n }\r\n return InputBase\r\n}\r\n\r\nexport default CreateInput\r\n\r\n// export type InputTextType<T> = ReturnType<typeof CreateInputBase<T>>\r\n\r\nconst LoadingCircularProgress: FC = () => (\r\n <div>\r\n <CircularProgress size={24} />\r\n </div>\r\n)\r\n\r\nconst WrapImage = styled(Box)({\r\n fontSize: '1rem',\r\n height: 'var(--input-base-image-size, 54px)',\r\n width: 'var(--input-base-image-size, 54px)',\r\n position: 'relative',\r\n borderRadius: '8px',\r\n boxShadow: 'rgba(0, 0, 0, 0.16) 0px 1px 4px',\r\n overflow: 'hidden',\r\n '& > img': {\r\n position: 'absolute',\r\n top: 0,\r\n left: 0,\r\n backgroundRepeat: 'no-repeat',\r\n height: '100%',\r\n width: '100%',\r\n backgroundSize: 'contain'\r\n },\r\n '& > div': {\r\n position: 'absolute',\r\n top: 0,\r\n left: 0,\r\n height: '100%',\r\n width: '100%',\r\n background: '#fafafa',\r\n zIndex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n }\r\n})\r\n"],"names":["CreateInput","params","InputBase","props","_this$mergeSlots","_this","_classCallCheck","_callSuper","_defineProperty","_this$props$name","_this$state$value","_this$slots","_this$slots2","errorMessage","getErrorMessage","messageErrors","name","tfp","fullWidth","variant","toString","error","helperText","message","disabled","onBlur","label","getLabel","placeholder","InputLabelProps","state","value","shrink","onChange","handleChange","slots","pastenable","InputProps","endAdornment","_jsx","InputAdornment","position","children","IconButton","onClick","handlePaste","edge","ContentPasteIcon","maxLength","inputProps","_objectSpread","mergeObjects","textFieldProps","side","_imageOther$src","image","imageLeft","imageRight","srcValue","element","_image$alt","alt","_image$fallbackSrc","fallbackSrc","_image$debounceDelay","debounceDelay","imageOther","_objectWithoutProperties","_excluded","WrapImage","model","data","src","imageProps","Collapse","sx","mx","in","unmountOnExit","orientation","ImageWithFallback","loading","LoadingCircularProgress","currentSlots","base","mirror","_this$slots3","_this$state$value$len","_this$state$value2","concat","length","event","setState","st","target","_asyncToGenerator","_regeneratorRuntime","mark","_callee","clipboardText","wrap","_context","prev","next","navigator","clipboard","readText","sent","t0","console","stop","_cachedSlots","mergeSlots","defaulValue","_inherits","Component","_createClass","key","get","this","_this$props$defaultVa","_data$name","_this$props","defaultValue","undefined","prevProps","nextProps","_this$props2","_this$props$data$name","_this$props$data","_nextProps$data$name$","_nextProps$data","currentDataValue","nextDataValue","_this$props$name2","_jsxs","Box","display","alignItems","hidden","renderImageSide","TextField","mapTextFieldProps","CircularProgress","size","styled","fontSize","height","width","borderRadius","boxShadow","overflow","top","left","backgroundRepeat","backgroundSize","background","zIndex","justifyContent"],"mappings":"0+BAgCMA,EAAc,SAAaC,GAoJ/B,kBAjJE,SAAAC,EAAYC,GAAqB,IAAAC,EAAAC,EAGS,OAHTC,OAAAJ,GAC/BG,EAAAE,EAAAL,KAAAA,GAAMC,IAAMK,EAAAH,EAFyB,eAAA,IAAEG,EAAAH,EAAA,qBAuCrB,WAAqB,IAAAI,EAAAC,EAAAC,EAAAC,EACjCC,EAAeC,EAAgBT,EAAKF,MAAMY,cAAeV,EAAKF,MAAMa,MACpEC,EAAsB,CAC1BC,WAAW,EACXC,QAAS,WACTH,KAAqB,QAAjBP,EAAEJ,EAAKF,MAAMa,YAAXP,IAAeA,OAAfA,EAAAA,EAAiBW,WACvBC,MAAOR,EAAaQ,MACpBC,WAAYT,EAAaU,QACzBC,SAAUnB,EAAKF,MAAMqB,SACrBC,OAAQ,WACDpB,EAAKF,MAAMa,MAChBX,EAAKF,MAAMsB,QAAUpB,EAAKF,MAAMsB,OAAOpB,EAAKF,MAAMa,KACnD,EACDU,MAAOrB,EAAKsB,WACZC,YAAavB,EAAKF,MAAMyB,YACxBC,gBAAmBxB,EAAKyB,MAAMC,MAAQ,CAAEC,QAAQ,GAAS,CAAE,EAC3DD,MAAuBrB,QAAlBA,EAAEL,EAAKyB,MAAMC,aAAKrB,IAAAA,EAAAA,EAAI,GAC3BuB,SAAU5B,EAAK6B,cAcjB,OAZ8B,IAA1B7B,EAAK8B,MAAMC,aACbnB,EAAIoB,WAA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AAK,EACLC,KAAM,EACNN,OAAQ,OACRC,MAAO,OACPQ,WAAY,UACZC,OAAQ,EACRpB,QAAS,OACTC,WAAY,SACZoB,eAAgB"}
|
|
@@ -1,114 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import React, { Component } from 'react';
|
|
4
|
-
import { FormControl, InputLabel, Select, MenuItem, Collapse, FormHelperText } from '@mui/material';
|
|
5
|
-
import { mergeObjects as _mergeObjects } from '../utils/helpers.js';
|
|
6
|
-
import '../utils/query-param.js';
|
|
7
|
-
import '../utils/dayjs-config.js';
|
|
8
|
-
import { getErrorMessage } from './helper.js';
|
|
9
|
-
|
|
10
|
-
function CreateSelectSimple(args) {
|
|
11
|
-
var SelectSimple = /*#__PURE__*/function (_Component) {
|
|
12
|
-
function SelectSimple(props) {
|
|
13
|
-
var _this$getDefaultValue;
|
|
14
|
-
var _this;
|
|
15
|
-
_classCallCheck(this, SelectSimple);
|
|
16
|
-
_this = _callSuper(this, SelectSimple, [props]);
|
|
17
|
-
_defineProperty(_this, "mapProps", function () {
|
|
18
|
-
var _this$props$name, _this$props$name2, _this$props$name3, _this$props$slots$sel, _this$props$slots;
|
|
19
|
-
var label = _this.getLabel();
|
|
20
|
-
var tfp = {
|
|
21
|
-
id: (_this$props$name = _this.props.name) === null || _this$props$name === void 0 ? void 0 : _this$props$name.toString(),
|
|
22
|
-
labelId: ((_this$props$name2 = _this.props.name) === null || _this$props$name2 === void 0 ? void 0 : _this$props$name2.toString()) + label,
|
|
23
|
-
name: (_this$props$name3 = _this.props.name) === null || _this$props$name3 === void 0 ? void 0 : _this$props$name3.toString(),
|
|
24
|
-
label: label,
|
|
25
|
-
defaultValue: _this.getDefaultValue(),
|
|
26
|
-
value: _this.state.value,
|
|
27
|
-
onChange: function onChange(event) {
|
|
28
|
-
var value = event.target.value + '';
|
|
29
|
-
_this.setState({
|
|
30
|
-
value: value
|
|
31
|
-
}, function () {
|
|
32
|
-
if (!!_this.props.name) {
|
|
33
|
-
_this.props.onBlur && _this.props.onBlur(_this.props.name);
|
|
34
|
-
}
|
|
35
|
-
var options = _this.getOptions();
|
|
36
|
-
var temp = options.find(function (x) {
|
|
37
|
-
var _x$value;
|
|
38
|
-
return ((_x$value = x.value) === null || _x$value === void 0 ? void 0 : _x$value.toString()) === value;
|
|
39
|
-
});
|
|
40
|
-
if (!temp) return;
|
|
41
|
-
_this.props.onChange && _this.props.onChange(temp);
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
disabled: _this.props.disabled,
|
|
45
|
-
fullWidth: _this.props.fullWidth !== undefined ? _this.props.fullWidth : true
|
|
46
|
-
};
|
|
47
|
-
var selectProps = (_this$props$slots$sel = (_this$props$slots = _this.props.slots) === null || _this$props$slots === void 0 ? void 0 : _this$props$slots.selectProps) !== null && _this$props$slots$sel !== void 0 ? _this$props$slots$sel : args === null || args === void 0 ? void 0 : args.selectProps;
|
|
48
|
-
return _mergeObjects({}, tfp, selectProps);
|
|
49
|
-
});
|
|
50
|
-
_defineProperty(_this, "getLabel", function () {
|
|
51
|
-
var _this$props$name$toSt, _this$props$name4;
|
|
52
|
-
if (!!_this.props.label && typeof _this.props.label === 'string') return _this.props.label;
|
|
53
|
-
return (_this$props$name$toSt = (_this$props$name4 = _this.props.name) === null || _this$props$name4 === void 0 ? void 0 : _this$props$name4.toString()) !== null && _this$props$name$toSt !== void 0 ? _this$props$name$toSt : '';
|
|
54
|
-
});
|
|
55
|
-
_defineProperty(_this, "getDefaultValue", function () {
|
|
56
|
-
var _ref, _this$props$defaultVa, _this$props$defaultVa2, _options$;
|
|
57
|
-
var _this$props = _this.props,
|
|
58
|
-
data = _this$props.data,
|
|
59
|
-
name = _this$props.name;
|
|
60
|
-
var options = _this.getOptions();
|
|
61
|
-
return (_ref = (_this$props$defaultVa = (_this$props$defaultVa2 = _this.props.defaultValue) === null || _this$props$defaultVa2 === void 0 ? void 0 : _this$props$defaultVa2.toString()) !== null && _this$props$defaultVa !== void 0 ? _this$props$defaultVa : !!data && !!name ? data[name] : undefined) !== null && _ref !== void 0 ? _ref : (_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.value;
|
|
62
|
-
});
|
|
63
|
-
_defineProperty(_this, "getOptions", function () {
|
|
64
|
-
var _ref2, _args$options;
|
|
65
|
-
return (_ref2 = (_args$options = args === null || args === void 0 ? void 0 : args.options) !== null && _args$options !== void 0 ? _args$options : _this.props.options) !== null && _ref2 !== void 0 ? _ref2 : [];
|
|
66
|
-
});
|
|
67
|
-
_this.state = {
|
|
68
|
-
value: (_this$getDefaultValue = _this.getDefaultValue()) === null || _this$getDefaultValue === void 0 ? void 0 : _this$getDefaultValue.toString()
|
|
69
|
-
};
|
|
70
|
-
return _this;
|
|
71
|
-
}
|
|
72
|
-
_inherits(SelectSimple, _Component);
|
|
73
|
-
return _createClass(SelectSimple, [{
|
|
74
|
-
key: "render",
|
|
75
|
-
value: function render() {
|
|
76
|
-
var _this$props$name5, _this$props$name6;
|
|
77
|
-
var data = this.getOptions();
|
|
78
|
-
var label = this.getLabel();
|
|
79
|
-
var errorMessage = getErrorMessage(this.props.messageErrors, this.props.name);
|
|
80
|
-
return jsxs(React.Fragment, {
|
|
81
|
-
children: [!!this.props.disabled && jsx("input", {
|
|
82
|
-
hidden: true,
|
|
83
|
-
name: (_this$props$name5 = this.props.name) === null || _this$props$name5 === void 0 ? void 0 : _this$props$name5.toString(),
|
|
84
|
-
defaultValue: this.getDefaultValue()
|
|
85
|
-
}), jsxs(FormControl, {
|
|
86
|
-
fullWidth: true,
|
|
87
|
-
disabled: this.props.disabled,
|
|
88
|
-
error: errorMessage.error,
|
|
89
|
-
children: [jsx(InputLabel, {
|
|
90
|
-
id: ((_this$props$name6 = this.props.name) === null || _this$props$name6 === void 0 ? void 0 : _this$props$name6.toString()) + label,
|
|
91
|
-
children: label
|
|
92
|
-
}), jsx(Select, _objectSpread2(_objectSpread2({}, this.mapProps()), {}, {
|
|
93
|
-
children: data.map(function (item) {
|
|
94
|
-
return jsx(MenuItem, {
|
|
95
|
-
value: item.value,
|
|
96
|
-
children: item.name
|
|
97
|
-
}, item.value);
|
|
98
|
-
})
|
|
99
|
-
})), jsx(Collapse, {
|
|
100
|
-
"in": errorMessage.error,
|
|
101
|
-
children: jsx(FormHelperText, {
|
|
102
|
-
children: errorMessage.message
|
|
103
|
-
})
|
|
104
|
-
})]
|
|
105
|
-
})]
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}]);
|
|
109
|
-
}(Component);
|
|
110
|
-
return SelectSimple;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export { CreateSelectSimple as default };
|
|
1
|
+
import{inherits as e,createClass as r,objectSpread2 as o,classCallCheck as l,callSuper as t,defineProperty as i}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as a}from"react/jsx-runtime";import s,{Component as p}from"react";import{FormControl as u,InputLabel as d,Select as v,MenuItem as m,Collapse as f,FormHelperText as g}from"@mui/material";import{mergeObjects as h}from"../utils/helpers.js";import"../utils/query-param.js";import"../utils/dayjs-config.js";import{getErrorMessage as c}from"./helper.js";function b(b){return function(){function S(e){var r,o;return l(this,S),o=t(this,S,[e]),i(o,"mapProps",(function(){var e,r,l,t,i,n=o.getLabel(),a={id:null===(e=o.props.name)||void 0===e?void 0:e.toString(),labelId:(null===(r=o.props.name)||void 0===r?void 0:r.toString())+n,name:null===(l=o.props.name)||void 0===l?void 0:l.toString(),label:n,defaultValue:o.getDefaultValue(),value:o.state.value,onChange:function(e){var r=e.target.value+"";o.setState({value:r},(function(){o.props.name&&o.props.onBlur&&o.props.onBlur(o.props.name);var e=o.getOptions().find((function(e){var o;return(null===(o=e.value)||void 0===o?void 0:o.toString())===r}));e&&o.props.onChange&&o.props.onChange(e)}))},disabled:o.props.disabled,fullWidth:void 0===o.props.fullWidth||o.props.fullWidth},s=null!==(t=null===(i=o.props.slots)||void 0===i?void 0:i.selectProps)&&void 0!==t?t:null==b?void 0:b.selectProps;return h({},a,s)})),i(o,"getLabel",(function(){var e,r;return o.props.label&&"string"==typeof o.props.label?o.props.label:null!==(e=null===(r=o.props.name)||void 0===r?void 0:r.toString())&&void 0!==e?e:""})),i(o,"getDefaultValue",(function(){var e,r,l,t,i=o.props,n=i.data,a=i.name,s=o.getOptions();return null!==(e=null!==(r=null===(l=o.props.defaultValue)||void 0===l?void 0:l.toString())&&void 0!==r?r:n&&a?n[a]:void 0)&&void 0!==e?e:null===(t=s[0])||void 0===t?void 0:t.value})),i(o,"getOptions",(function(){var e,r;return null!==(e=null!==(r=null==b?void 0:b.options)&&void 0!==r?r:o.props.options)&&void 0!==e?e:[]})),o.state={value:null===(r=o.getDefaultValue())||void 0===r?void 0:r.toString()},o}return e(S,p),r(S,[{key:"render",value:function(){var e,r,l=this.getOptions(),t=this.getLabel(),i=c(this.props.messageErrors,this.props.name);return n(s.Fragment,{children:[!!this.props.disabled&&a("input",{hidden:!0,name:null===(e=this.props.name)||void 0===e?void 0:e.toString(),defaultValue:this.getDefaultValue()}),n(u,{fullWidth:!0,disabled:this.props.disabled,error:i.error,children:[a(d,{id:(null===(r=this.props.name)||void 0===r?void 0:r.toString())+t,children:t}),a(v,o(o({},this.mapProps()),{},{children:l.map((function(e){return a(m,{value:e.value,children:e.name},e.value)}))})),a(f,{in:i.error,children:a(g,{children:i.message})})]})]})}}])}()}export{b as default};
|
|
114
2
|
//# sourceMappingURL=create.select-simple.js.map
|