本製品ではコントロールの高さや幅などのサイズのほか、背景色や文字色などを含め、コントロールの外観はすべてCSS(Cascading Style Sheet)により設定します。
コントロールで使用されるCSSクラスの詳細については、以下の製品ヘルプをご参照ください。
コントロールの外観設定
入力コントロールのCSS
新しいスタイルの設定方法
InputManJSは2種類のデザインを提供しています。appearanceStyleプロパティを設定することで、従来のデザインまたは新しいデザインを適用できます。すべてのコントロールを初期化する前に設定する必要があります。
appearanceStyleプロパティの設定できる値は次のとおりで、既定値はClassicです。
値
説明
Classic
従来のデザイン
Modern
新しいデザイン
import '@mescius/inputman/CSS/gc.inputman-js.css';
import { InputMan } from '@mescius/inputman';
InputMan.appearanceStyle = InputMan.AppearanceStyle.Modern;
const gcTextBox1 = new InputMan.GcTextBox(document.getElementById('gcTextBox1'));
const gcTextBox2 = new InputMan.GcTextBox(document.getElementById('gcTextBox2'), {
text: 'テキスト'
});
const validator = new GCIM.GcValidator({
items: [
{
control: gcTextBox1,
ruleSet: [
{
rule: InputMan.ValidateType.Required
}
],
},
{
control: gcTextBox2,
ruleSet: [
{
rule: InputMan.ValidateType.Required
}
],
}
],
defaultNotify: {
fail: {
tip: {
direction: InputMan.TipDirection.Bottom
},
icon: {
direction: InputMan.IconDirection.Inside
},
controlState: true
},
success: {
tip: {
direction: InputMan.TipDirection.Bottom
},
icon: {
direction: InputMan.IconDirection.Inside
},
controlState: true
}
}
});
validator.validate();
var styleSheet;
const indices = {};
const styles = {
'.gcim-notify__tip-content': { width: '200px', height: '40px', borderRadius: '12px', boxShadow: '5px 5px 5px rgba(0,0,0,0.5)', fontWeight: 'bold', fontStyle: 'italic', fontFamily: 'serif', textAlign: 'right', textShadow: '1px 1px 1px rgba(0,0,0,0.5)' },
'.gcim-notify__tip-text': { fontSize: '20px' },
"[gcim-notify__tip-state='fail'] .gcim-notify__tip-content": { backgroundColor: '#ffdddd', color: '#ff0000', borderColor: '#c67600', borderWidth: '2px', borderStyle: 'dashed' },
"[gcim-notify__tip-state='fail'] .gcim-notify__tip-content::before": { backgroundColor: '#ffdddd', borderTopColor: '#c67600', borderRightColor: '#c67600', borderWidth: '2px', borderStyle: 'dashed'},
"[gcim-notify__tip-state='success'] .gcim-notify__tip-content": { backgroundColor: '#ddddff', color: '#0000ff', borderColor: '#0099ff', borderWidth: '2px', borderStyle: 'dashed' },
"[gcim-notify__tip-state='success'] .gcim-notify__tip-content::before": { backgroundColor: '#ddddff', borderTopColor: '#0099ff', borderRightColor: '#0099ff', borderWidth: '2px', borderStyle: 'dashed'},
".gcim-notify__state-container[gcim-notify__control-state='fail']": { borderColor: '#fbbeb9', borderWidth: '2px', borderStyle: 'dashed' },
".gcim-notify__state-container[gcim-notify__control-state='success']": { borderColor: '#99ff99', borderWidth: '2px', borderStyle: 'dashed' },
};
const getRulePrefix = () => {
return InputMan.appearanceStyle === InputMan.AppearanceStyle.Modern ? '[gcim-control-appearance="modern"] ' : '';
}
const createInitialStyles = () => {
const element = document.createElement('style');
document.head.appendChild(element);
styleSheet = element.sheet;
var i = 0;
for (const styleName in styles) {
styleSheet.insertRule(getRulePrefix() + styleName + '{}', i);
indices[styleName] = i;
i++;
}
}
createInitialStyles();
const updateStyle = (event) => {
var element = event.target;
if (element.tagName == 'INPUT') {
element.value.split(';').forEach((v) => {
var values = v.split(',');
var styleName = values[0];
var propertyNames = values[1].split('&');
propertyNames.forEach((propertyName) => {
styleSheet.cssRules[indices[styleName]].style[propertyName] = element.checked ? styles[styleName][propertyName] : '';
});
});
}
var style = '';
for (var i = 0; i < styleSheet.cssRules.length; i++) {
if (styleSheet.cssRules[i].style.length > 0) {
style += styleSheet.cssRules[i].cssText.replace(/{/g, '{\n ').replace(/;/g, ';\n ').replace(/ }/g, '}') + '\n';
}
}
document.getElementById('style').value = style;
}
const copyStyle = () => {
wijmo.Clipboard.copy(document.getElementById('style').value);
document.execCommand('copy');
}
var panels = document.getElementsByClassName('peoperty-panel');
for (var i = 0; i < panels.length; i++) {
panels[i].addEventListener('click', updateStyle);
}
document.getElementById('copyStyle').addEventListener('click', copyStyle);
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>検証コントロール - スタイルの設定</title>
<!-- SystemJS -->
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
window.onload = function() {
System.import('./src/app');
}
</script>
</head>
<body>
<div class="flexbox">
<div>
検証失敗の通知<br>
<input id="gcTextBox1">
</div>
<div>
検証成功の通知<br>
<input id="gcTextBox2">
</div>
</div><br><br><br>
<div class="peoperty-header">ツールチップのスタイル</div>
<div class="peoperty-panel" >
<label><input type="checkbox" value=".gcim-notify__tip-content,width">幅</label>
<label><input type="checkbox" value=".gcim-notify__tip-content,height">高さ</label>
<label><input type="checkbox" value=".gcim-notify__tip-content,borderRadius">境界線の角丸</label>
<label><input type="checkbox" value=".gcim-notify__tip-content,boxShadow">影</label>
<label><input type="checkbox" value=".gcim-notify__tip-text,fontSize">フォントのサイズ</label>
<label><input type="checkbox" value=".gcim-notify__tip-content,fontWeight">フォントの太さ</label>
<label><input type="checkbox" value=".gcim-notify__tip-content,fontStyle">フォントのスタイル</label>
<label><input type="checkbox" value=".gcim-notify__tip-content,fontFamily">フォントの種類</label>
<label><input type="checkbox" value=".gcim-notify__tip-content,textAlign">水平方向の位置</label>
<label><input type="checkbox" value=".gcim-notify__tip-content,textShadow">テキストの影</label>
</div>
<div class="peoperty-header">検証失敗のツールチップのスタイル</div>
<div class="peoperty-panel" >
<label><input type="checkbox" value="[gcim-notify__tip-state='fail'] .gcim-notify__tip-content,backgroundColor;[gcim-notify__tip-state='fail'] .gcim-notify__tip-content::before,backgroundColor">背景色</label>
<label><input type="checkbox" value="[gcim-notify__tip-state='fail'] .gcim-notify__tip-content,color">文字色</label>
<label><input type="checkbox" value="[gcim-notify__tip-state='fail'] .gcim-notify__tip-content,borderColor;[gcim-notify__tip-state='fail'] .gcim-notify__tip-content::before,borderTopColor&borderRightColor">境界線の色</label>
<label><input type="checkbox" value="[gcim-notify__tip-state='fail'] .gcim-notify__tip-content,borderWidth;[gcim-notify__tip-state='fail'] .gcim-notify__tip-content::before,borderWidth">境界線の幅</label>
<label><input type="checkbox" value="[gcim-notify__tip-state='fail'] .gcim-notify__tip-content,borderStyle;[gcim-notify__tip-state='fail'] .gcim-notify__tip-content::before,borderStyle">境界線のスタイル</label>
</div>
<div class="peoperty-header">検証成功のツールチップのスタイル</div>
<div class="peoperty-panel" >
<label><input type="checkbox" value="[gcim-notify__tip-state='success'] .gcim-notify__tip-content,backgroundColor;[gcim-notify__tip-state='success'] .gcim-notify__tip-content::before,backgroundColor">背景色</label>
<label><input type="checkbox" value="[gcim-notify__tip-state='success'] .gcim-notify__tip-content,color">文字色</label>
<label><input type="checkbox" value="[gcim-notify__tip-state='success'] .gcim-notify__tip-content,borderColor;[gcim-notify__tip-state='success'] .gcim-notify__tip-content::before,borderTopColor&borderRightColor">境界線の色</label>
<label><input type="checkbox" value="[gcim-notify__tip-state='success'] .gcim-notify__tip-content,borderWidth;[gcim-notify__tip-state='success'] .gcim-notify__tip-content::before,borderWidth">境界線の幅</label>
<label><input type="checkbox" value="[gcim-notify__tip-state='success'] .gcim-notify__tip-content,borderStyle;[gcim-notify__tip-state='success'] .gcim-notify__tip-content::before,borderStyle">境界線のスタイル</label>
</div>
<div class="peoperty-header">検証失敗のコントロール状態のスタイル</div>
<div class="peoperty-panel" >
<label><input type="checkbox" value=".gcim-notify__state-container[gcim-notify__control-state='fail'],borderColor">境界線の色</label>
<label><input type="checkbox" value=".gcim-notify__state-container[gcim-notify__control-state='fail'],borderWidth">境界線の幅</label>
<label><input type="checkbox" value=".gcim-notify__state-container[gcim-notify__control-state='fail'],borderStyle">境界線のスタイル</label>
</div>
<div class="peoperty-header">検証成功のコントロール状態のスタイル</div>
<div class="peoperty-panel" >
<label><input type="checkbox" value=".gcim-notify__state-container[gcim-notify__control-state='success'],borderColor">境界線の色</label>
<label><input type="checkbox" value=".gcim-notify__state-container[gcim-notify__control-state='success'],borderWidth">境界線の幅</label>
<label><input type="checkbox" value=".gcim-notify__state-container[gcim-notify__control-state='success'],borderStyle">境界線のスタイル</label>
</div>
<button id="copyStyle">CSSコードをコピー</button><br>
<textarea id="style" cols="60" rows="10"></textarea>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
</body>
</html>
System.config({
transpiler: 'plugin-babel',
babelOptions: {
es2015: true
},
meta: {
'*.css': { loader: 'css' }
},
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
'@mescius/inputman': 'npm:@mescius/inputman/index.js',
'@mescius/inputman/CSS': 'npm:@mescius/inputman/CSS',
'css': 'npm:systemjs-plugin-css/css.js',
'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js',
'systemjs-babel-build': 'npm:systemjs-plugin-babel/systemjs-babel-browser.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
src: {
defaultExtension: 'js'
},
"node_modules": {
defaultExtension: 'js'
},
}
});