Skip to content

Commit

Permalink
カスタムフィールドでテキストのオプションチェック
Browse files Browse the repository at this point in the history
  • Loading branch information
1000-x-t30 committed Aug 6, 2024
1 parent 95afb3b commit c9072a9
Show file tree
Hide file tree
Showing 14 changed files with 689 additions and 2,843 deletions.
1,545 changes: 464 additions & 1,081 deletions dist/bundle.js

Large diffs are not rendered by default.

32 changes: 30 additions & 2 deletions lib/components/genelator/FieldGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ exports.FieldGroup = FieldGroup;
var _react = _interopRequireWildcard(require('react'));
var _reactTooltip = _interopRequireDefault(require('react-tooltip'));
var _MakerContext = require('../../store/MakerContext');
var _FieldClear = require('./base/FieldClear');
var _Alert = require('./base/Alert');
var _GroupAlert = require('./base/GroupAlert');
var _DuplicateAlert = require('./base/DuplicateAlert');
Expand Down Expand Up @@ -89,6 +88,35 @@ const defaultProps = {
groupTitle: '',
groupName: '',
};
const crearField = {
title: '',
name: '',
path: '',
normalSize: '',
tiny: '',
tinySize: '',
large: '',
largeSize: '',
square: '',
squareSize: '',
alt: true,
resize: true,
useExpand: true,
useDropArea: true,
dropAreaWidth: 200,
dropAreaHeight: 200,
useFocusImage: false,
focusImageWidth: 400,
focusImageHeight: 400,
startHeadingLevel: 2,
endHeadingLevel: 3,
mediaType: 'image',
openConverter: '',
openValidator: '',
converter: '',
tooltip: '',
placeholder: '',
};
function FieldGroup() {
const [field, setField] = (0, _react.useState)(defaultProps);
const { setGroupTitleName, addGroupItem, clearGroupItem } = (0, _MakerContext.useMakerContext)();
Expand Down Expand Up @@ -128,7 +156,7 @@ function FieldGroup() {
}, [field, setGroupTitleName, addGroupItem]);
const addNewGroup = (0, _react.useCallback)(() => {
clearGroupItem();
(0, _FieldClear.FieldClear)(setField);
setField(crearField);
setField((prevState) => ({
...prevState,
openGroup: false,
Expand Down
32 changes: 30 additions & 2 deletions lib/components/genelator/base/Maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', {
});
exports.Maker = Maker;
var _react = _interopRequireWildcard(require('react'));
var _fieldClear = require('./fieldClear');
function _getRequireWildcardCache(e) {
if ('function' != typeof WeakMap) return null;
var r = new WeakMap(),
Expand All @@ -30,10 +29,39 @@ function _interopRequireWildcard(e, r) {
}
// import stateManger from '../../lib/history';

const crearField = {
title: '',
name: '',
path: '',
normalSize: '',
tiny: '',
tinySize: '',
large: '',
largeSize: '',
square: '',
squareSize: '',
alt: true,
resize: true,
useExpand: true,
useDropArea: true,
dropAreaWidth: 200,
dropAreaHeight: 200,
useFocusImage: false,
focusImageWidth: 400,
focusImageHeight: 400,
startHeadingLevel: 2,
endHeadingLevel: 3,
mediaType: 'image',
openConverter: '',
openValidator: '',
converter: '',
tooltip: '',
placeholder: '',
};
function Maker(props) {
const { setField, onSubmit = () => {} } = props;
const onClear = (0, _react.useCallback)(() => {
(0, _fieldClear.FieldClear)(setField);
setField(crearField);
}, [setField]);

// const onBackState = () => {
Expand Down
77 changes: 39 additions & 38 deletions lib/components/html/OptionValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,47 +59,48 @@ function OptionValidator(props) {
value: validator.value,
id: ''.concat(name, '-v-').concat(validator.option),
}),
!jsValidator &&
/*#__PURE__*/ _react.default.createElement(
_react.default.Fragment,
null,
validator.message &&
/*#__PURE__*/ _react.default.createElement(
_react.default.Fragment,
null,
editMode === 'preview'
? null
: '<!-- BEGIN '.concat(name, ':validator#').concat(validator.option, ' -->'),
/*#__PURE__*/ _react.default.createElement(
'p',
{
className: (0, _classnames.default)({
'acms-admin-text-error': acmscss,
}),
},
validator.message
),
editMode === 'preview' ? null : '<!-- END '.concat(name, ':validator#').concat(validator.option, ' -->')
)
),
!jsValidator &&
/*#__PURE__*/ _react.default.createElement(
'div',
{
'data-validator-label': ''.concat(name, '-v-').concat(validator.option),
className: 'validator-result-{'.concat(name, ':v#').concat(validator.option, '}'),
},
/*#__PURE__*/ _react.default.createElement(
'p',
jsValidator
? /*#__PURE__*/ _react.default.createElement(
'div',
{
className: 'error-text',
'data-validator-label': ''.concat(name, '-v-').concat(validator.option),
className: 'validator-result-{'.concat(name, ':v#').concat(validator.option, '}'),
},
/*#__PURE__*/ _react.default.createElement('span', {
className: 'acms-admin-icon acms-admin-icon-attention',
}),
validator.message
/*#__PURE__*/ _react.default.createElement(
'p',
{
className: 'error-text',
},
/*#__PURE__*/ _react.default.createElement('span', {
className: 'acms-admin-icon acms-admin-icon-attention',
}),
validator.message
)
)
: /*#__PURE__*/ _react.default.createElement(
_react.default.Fragment,
null,
validator.message &&
/*#__PURE__*/ _react.default.createElement(
_react.default.Fragment,
null,
editMode === 'preview'
? null
: '<!-- BEGIN '.concat(name, ':validator#').concat(validator.option, ' -->'),
/*#__PURE__*/ _react.default.createElement(
'p',
{
className: (0, _classnames.default)({
'acms-admin-text-error': acmscss,
}),
},
validator.message
),
editMode === 'preview'
? null
: '<!-- END '.concat(name, ':validator#').concat(validator.option, ' -->')
)
)
)
);
}),
item.converter &&
Expand Down
33 changes: 32 additions & 1 deletion lib/components/layouts/GroupSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var _Heading = require('../html/Heading');
var _TextInput = require('../html/TextInput');
var _Textarea = require('../html/Textarea');
var _Checkbox = require('../html/Checkbox');
var _Selectbox = require('../html/Selectbox');
var _MakerContext = require('../../store/MakerContext');
function GroupSection() {
const {
Expand Down Expand Up @@ -172,7 +173,7 @@ function GroupSection() {
{
className: 'acms-admin-form-item-input',
},
/*#__PURE__*/ _react.default.createElement(_Checkbox.Checkbox, {
/*#__PURE__*/ _react.default.createElement(_Selectbox.Selectbox, {
item: item,
id: ''.concat(item.name).concat(index),
})
Expand Down Expand Up @@ -341,6 +342,36 @@ function GroupSection() {
)
);
}
case 'selectbox': {
return /*#__PURE__*/ _react.default.createElement(
'p',
{
key: index,
className: 'acms-admin-form-item',
},
/*#__PURE__*/ _react.default.createElement(
'label',
{
className: 'acms-admin-form-item-heading',
htmlFor: ''.concat(item.name).concat(index),
},
/*#__PURE__*/ _react.default.createElement(_Heading.Heading, {
item: item,
})
),
/*#__PURE__*/ _react.default.createElement(
'span',
{
className: 'acms-admin-form-item-input',
},
/*#__PURE__*/ _react.default.createElement(_Selectbox.Selectbox, {
item: item,
id: ''.concat(item.name).concat(index),
isValue: false,
})
)
);
}
case 'media': {
return /*#__PURE__*/ _react.default.createElement(
'p',
Expand Down
7 changes: 3 additions & 4 deletions lib/containers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ var _PreviewModeNavigator = require('../components/navigator/PreviewModeNavigato
var _PreviewNavigator = require('../components/navigator/PreviewNavigator');
var _Field = require('../components/genelator/Field');
var _FieldGroup = require('../components/genelator/FieldGroup');
var _Unit = _interopRequireDefault(require('../components/genelator/Unit'));
var _UnitGroup = _interopRequireDefault(require('../components/genelator/UnitGroup'));
var _FieldSource = require('../components/FieldSource');
var _FieldGroupSource = require('../components/FieldGroupSource');
var _Highlighter = require('../components/Highlighter');
var _htmlEntities = require('html-entities');
// import Unit from '../components/genelator/Unit';
// import UnitGroup from '../components/genelator/UnitGroup';

const entities = new _htmlEntities.XmlEntities();
function CustomFieldMaker() {
const {
Expand All @@ -43,8 +44,6 @@ function CustomFieldMaker() {
/*#__PURE__*/ _react.default.createElement(_EditorModeNavigator.EditorModeNavigator, null),
preview.mode === 'normal' && /*#__PURE__*/ _react.default.createElement(_Field.Field, null),
preview.mode === 'group' && /*#__PURE__*/ _react.default.createElement(_FieldGroup.FieldGroup, null),
preview.mode === 'unit' && /*#__PURE__*/ _react.default.createElement(_Unit.default, null),
preview.mode === 'unit-group' && /*#__PURE__*/ _react.default.createElement(_UnitGroup.default, null),
/*#__PURE__*/ _react.default.createElement(
'div',
{
Expand Down
33 changes: 31 additions & 2 deletions src/components/genelator/FieldGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useCallback, useState } from 'react';
import ReactTooltip from 'react-tooltip';
import { useMakerContext } from '../../store/MakerContext';
import { FieldClear } from './base/FieldClear';
import { Alert } from './base/Alert';
import { GroupAlert } from './base/GroupAlert';
import { DuplicateAlert } from './base/DuplicateAlert';
Expand Down Expand Up @@ -62,6 +61,36 @@ const defaultProps = {
groupName: '',
};

const crearField = {
title: '',
name: '',
path: '',
normalSize: '',
tiny: '',
tinySize: '',
large: '',
largeSize: '',
square: '',
squareSize: '',
alt: true,
resize: true,
useExpand: true,
useDropArea: true,
dropAreaWidth: 200,
dropAreaHeight: 200,
useFocusImage: false,
focusImageWidth: 400,
focusImageHeight: 400,
startHeadingLevel: 2,
endHeadingLevel: 3,
mediaType: 'image',
openConverter: '',
openValidator: '',
converter: '',
tooltip: '',
placeholder: '',
};

export function FieldGroup() {
const [field, setField] = useState(defaultProps);
const { setGroupTitleName, addGroupItem, clearGroupItem } = useMakerContext();
Expand Down Expand Up @@ -95,7 +124,7 @@ export function FieldGroup() {

const addNewGroup = useCallback(() => {
clearGroupItem();
FieldClear(setField);
setField(crearField);
setField((prevState) => ({
...prevState,
openGroup: false,
Expand Down
Loading

0 comments on commit c9072a9

Please sign in to comment.