Skip to content

Commit

Permalink
Adjust display items in form options.
Browse files Browse the repository at this point in the history
  • Loading branch information
1000-x-t30 committed Oct 3, 2024
1 parent f4e47e5 commit 2ecb6df
Show file tree
Hide file tree
Showing 36 changed files with 507 additions and 475 deletions.
211 changes: 150 additions & 61 deletions dist/bundle.js

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions lib/components/genelator/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,10 @@ function Field() {
setField: setField,
})
),
field.type !== 'media' &&
field.type !== 'richEditor' &&
field.type !== 'table' &&
/*#__PURE__*/ _react.default.createElement(_Validator.Validator, {
field: field,
setField: setField,
}),
/*#__PURE__*/ _react.default.createElement(_Validator.Validator, {
field: field,
setField: setField,
}),
/*#__PURE__*/ _react.default.createElement(_Operator.Operator, {
setField: setField,
onSubmit: onSubmit,
Expand Down
29 changes: 23 additions & 6 deletions lib/components/genelator/base/Validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports.Validator = Validator;
var _react = _interopRequireWildcard(require('react'));
var _reactTooltip = _interopRequireDefault(require('react-tooltip'));
var _NoSearchBox = require('./NoSearchBox');
var _MakerContext = require('../../../store/MakerContext');
function _getRequireWildcardCache(e) {
if ('function' != typeof WeakMap) return null;
var r = new WeakMap(),
Expand Down Expand Up @@ -35,6 +36,9 @@ function Validator(props) {
field: { type, validator, openValidator, converter, noSearch },
setField,
} = props;
const {
preview: { mode },
} = (0, _MakerContext.useMakerContext)();
const [height, setHeight] = (0, _react.useState)(0);
const contentRef = (0, _react.useRef)(null);
const updateHeight = (0, _react.useCallback)(() => {
Expand Down Expand Up @@ -66,7 +70,18 @@ function Validator(props) {
};
}, [updateHeight]);
const isConverter = (0, _react.useMemo)(() => {
const possibleConverter = ['text', 'textarea', 'checkbox', 'selectbox', 'radioButton'];
const possibleConverter = [
'text',
'tel',
'number',
'email',
'password',
'textarea',
'liteEditor',
'checkbox',
'selectbox',
'radioButton',
];
return possibleConverter.includes(type);
}, [type]);
const updateValidatorOption = (idx, option) => {
Expand Down Expand Up @@ -517,11 +532,13 @@ function Validator(props) {
'\u8FFD\u52A0'
)
),
/text|number|tel|email|password|textarea|radioButton|selectbox/.exec(type) &&
/*#__PURE__*/ _react.default.createElement(_NoSearchBox.NoSearchBox, {
noSearch: noSearch,
setField: setField,
})
(mode === 'customfield') | (mode === 'customunit') &&
/text|number|tel|email|password|textarea|radioButton|selectbox/.exec(type)
? /*#__PURE__*/ _react.default.createElement(_NoSearchBox.NoSearchBox, {
noSearch: noSearch,
setField: setField,
})
: /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null)
)
)
);
Expand Down
4 changes: 4 additions & 0 deletions lib/components/html/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ function Checkbox(props) {
}),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
})
),
mode === 'unitgroup' &&
Expand Down
6 changes: 2 additions & 4 deletions lib/components/html/FileInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var _react = _interopRequireDefault(require('react'));
var _classnames = _interopRequireDefault(require('classnames'));
var _MakerContext = require('../../store/MakerContext');
var _OptionValidator = require('./OptionValidator');
var _OptionNoSearch = require('./OptionNoSearch');
function FileInput(props) {
const { item, id, isValue = true } = props;
const {
Expand Down Expand Up @@ -125,9 +124,8 @@ function FileInput(props) {
name: ''.concat(item.name, '@filename'),
value: '@rawfilename',
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
})
),
mode === 'fieldgroup' &&
Expand Down
12 changes: 3 additions & 9 deletions lib/components/html/ImageInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var _react = _interopRequireDefault(require('react'));
var _classnames = _interopRequireDefault(require('classnames'));
var _MakerContext = require('../../store/MakerContext');
var _OptionValidator = require('./OptionValidator');
var _OptionNoSearch = require('./OptionNoSearch');
function ImageInput(props) {
const { item, id, isAttribute = true } = props;
const {
Expand Down Expand Up @@ -161,10 +160,6 @@ function ImageInput(props) {
}),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
})
),
mode === 'fieldgroup' &&
Expand Down Expand Up @@ -529,10 +524,9 @@ function ImageInput(props) {
name: ''.concat(item.name, '{id}@').concat(item.square, '[]'),
value: item.squareSize,
}),
isAttribute &&
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
})
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
})
)
)
);
Expand Down
3 changes: 3 additions & 0 deletions lib/components/html/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ function Media(props) {
type: 'hidden',
name: ''.concat(item.name, ':extension'),
value: 'media',
}),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
})
),
mode === 'fieldgroup' &&
Expand Down
4 changes: 4 additions & 0 deletions lib/components/html/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ function RadioButton(props) {
}),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
})
),
mode === 'unitgroup' &&
Expand Down
63 changes: 37 additions & 26 deletions lib/components/html/Selectbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,37 +136,48 @@ function Selectbox(props) {
}),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
})
),
mode === 'unitgroup' &&
/*#__PURE__*/ _react.default.createElement(
'select',
{
name: ''.concat(item.name, '{id}[]'),
className: (0, _classnames.default)({
'acms-admin-form-width-full': acmscss,
_react.default.Fragment,
null,
/*#__PURE__*/ _react.default.createElement(
'select',
{
name: ''.concat(item.name, '{id}[]'),
className: (0, _classnames.default)({
'acms-admin-form-width-full': acmscss,
}),
},
/*#__PURE__*/ _react.default.createElement('option', {
value: '',
}),
},
/*#__PURE__*/ _react.default.createElement('option', {
value: '',
}),
item.option.map((option, index) => {
if (!option.label) {
return null;
}
return /*#__PURE__*/ _react.default.createElement(
'option',
(0, _extends2.default)(
{
key: index,
value: option.value,
},
isSelected && {
'data-tmp': '{'.concat(item.name, ':selected#').concat(option.value, '}'),
}
),
option.label
);
item.option.map((option, index) => {
if (!option.label) {
return null;
}
return /*#__PURE__*/ _react.default.createElement(
'option',
(0, _extends2.default)(
{
key: index,
value: option.value,
},
isSelected && {
'data-tmp': '{'.concat(item.name, ':selected#').concat(option.value, '}'),
}
),
option.label
);
})
),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
})
)
);
Expand Down
64 changes: 39 additions & 25 deletions lib/components/html/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ function TextInput(props) {
: {}
)
),
/*#__PURE__*/ _react.default.createElement('input', {
type: 'hidden',
name: 'field[]',
defaultValue: item.name,
}),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
}),
/*#__PURE__*/ _react.default.createElement('input', {
type: 'hidden',
name: 'field[]',
defaultValue: item.name,
})
),
mode === 'fieldgroup' &&
Expand Down Expand Up @@ -112,6 +112,13 @@ function TextInput(props) {
: {}
)
),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
}),
/*#__PURE__*/ _react.default.createElement('input', {
type: 'hidden',
name: 'unit{id}[]',
Expand All @@ -120,26 +127,33 @@ function TextInput(props) {
),
mode === 'unitgroup' &&
/*#__PURE__*/ _react.default.createElement(
'input',
(0, _extends2.default)(
{
type: item.type,
name: ''.concat(item.name, '{id}[]'),
},
isValue && {
value: '{'.concat(item.name, '}'),
},
{
className: (0, _classnames.default)({
'acms-admin-form-width-full': acmscss,
}),
},
item.placeholder
? {
placeholder: item.placeholder,
}
: {}
)
_react.default.Fragment,
null,
/*#__PURE__*/ _react.default.createElement(
'input',
(0, _extends2.default)(
{
type: item.type,
name: ''.concat(item.name, '{id}[]'),
},
isValue && {
value: '{'.concat(item.name, '}'),
},
{
className: (0, _classnames.default)({
'acms-admin-form-width-full': acmscss,
}),
},
item.placeholder
? {
placeholder: item.placeholder,
}
: {}
)
),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
})
)
);
}
21 changes: 15 additions & 6 deletions lib/components/html/Textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var _react = _interopRequireDefault(require('react'));
var _classnames = _interopRequireDefault(require('classnames'));
var _MakerContext = require('../../store/MakerContext');
var _OptionValidator = require('./OptionValidator');
var _OptionNoSearch = require('./OptionNoSearch');
function Textarea(props) {
const { item, id = '', isValue = true } = props;
const {
Expand Down Expand Up @@ -47,13 +48,17 @@ function Textarea(props) {
),
isValue ? '{'.concat(item.name, '}') : ''
),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
}),
/*#__PURE__*/ _react.default.createElement('input', {
type: 'hidden',
name: 'field[]',
defaultValue: item.name,
}),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
})
),
mode === 'fieldgroup' &&
Expand Down Expand Up @@ -100,13 +105,17 @@ function Textarea(props) {
),
isValue ? '{'.concat(item.name, '}') : ''
),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
}),
/*#__PURE__*/ _react.default.createElement(_OptionNoSearch.OptionNoSearch, {
name: item.name,
noSearch: item.noSearch,
}),
/*#__PURE__*/ _react.default.createElement('input', {
type: 'hidden',
name: 'unit{id}[]',
value: ''.concat(item.name, '{id}'),
}),
/*#__PURE__*/ _react.default.createElement(_OptionValidator.OptionValidator, {
item: item,
})
),
mode === 'unitgroup' &&
Expand Down
Loading

0 comments on commit 2ecb6df

Please sign in to comment.