スタイルの設定

本製品ではコントロールの高さや幅などのサイズのほか、背景色や文字色などを含め、コントロールの外観はすべてCSS(Cascading Style Sheet)により設定します。 コントロールで使用されるCSSクラスの詳細については、以下の製品ヘルプをご参照ください。 コントロールの外観設定 入力コントロールのCSS
import '@grapecity/inputman/CSS/gc.inputman-js.css'; import { InputMan } from '@grapecity/inputman'; const gcMultiLineTextBox1 = new InputMan.GcMultiLineTextBox(document.getElementById('gcMultiLineTextBox1'), { text: 'テキスト' }); const gcMultiLineTextBox2 = new InputMan.GcMultiLineTextBox(document.getElementById('gcMultiLineTextBox2'), { text: 'テキスト', enabled: false }); const gcMultiLineTextBox3 = new InputMan.GcMultiLineTextBox(document.getElementById('gcMultiLineTextBox3'), { watermarkDisplayNullText: '氏名', watermarkNullText: '全角で入力してください' }); var styleSheet; const indices = []; const styles = { 'div[ctrl-type="GcMultiLineTextBox"]': { height: '40px !important' }, '.gcim': { backgroundColor: '#ddffdd', borderColor: '#009900', borderWidth: '2px', borderStyle: 'dashed', borderRadius: '12px', boxShadow: '5px 5px 5px rgba(0,0,0,0.5)' }, '.gcim__textarea': { width: '200px', cursor: 'crosshair', fontSize: '20px', fontWeight: 'bold', fontStyle: 'italic', fontFamily: 'serif', textAlign: 'right', textShadow: '1px 1px 1px rgba(0,0,0,0.5)', color: '#009900' }, '.gcim__textarea:disabled': { backgroundColor: '#666666', color: '#cccccc', cursor: 'wait' }, '.gcim_focused': { backgroundColor: '#ddddff', borderColor: '#0000ff', color: '#0000ff' }, '.gcim_watermark_null': { backgroundColor: '#ffdddd', borderColor: '#ff0000', color: '#ff0000' }, '.gcim_focused.gcim_watermark_null': { backgroundColor: '#ffddff', borderColor: '#990099', color: '#990099' }, }; const createInitialStyles = () => { const element = document.createElement('style'); document.head.appendChild(element); styleSheet = element.sheet; var i = 0; for (const styleName in styles) { styleSheet.insertRule(styleName + '{}', i); indices[styleName] = i; i++; } } createInitialStyles(); const updateStyle = (event) => { const element = event.target; if (element.tagName == 'INPUT') { const values = element.value.split(','); const styleName = values[0]; const propertyName = values[1]; var propertyValue = element.checked ? styles[styleName][propertyName] : ''; if (propertyValue.indexOf("!important") > -1) { styleSheet.cssRules[indices[styleName]].style.setProperty(propertyName, propertyValue.replace("!important", ""), "important"); } else { styleSheet.cssRules[indices[styleName]].style[propertyName] = propertyValue; } } 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> System.import('./src/app'); </script> </head> <body> <div class="flexbox"> <div> 通常の状態<br> <textarea id="gcMultiLineTextBox1"></textarea> </div> <div> 無効な状態<br> <textarea id="gcMultiLineTextBox2"></textarea> </div> <div> ウォーターマーク<br> <textarea id="gcMultiLineTextBox3"></textarea> </div> </div> <div class="peoperty-header">コントロール全般のスタイル</div> <div class="peoperty-panel"> <label><input type="checkbox" value=".gcim__textarea,width">コントロールの幅</label><br> <label><input type="checkbox" value='div[ctrl-type="GcMultiLineTextBox"],height'>コントロールの高さ</label><br> <label><input type="checkbox" value=".gcim,backgroundColor">背景色</label><br> <label><input type="checkbox" value=".gcim,borderColor">境界線の色</label><br> <label><input type="checkbox" value=".gcim,borderWidth">境界線の幅</label><br> <label><input type="checkbox" value=".gcim,borderStyle">境界線のスタイル</label><br> <label><input type="checkbox" value=".gcim,borderRadius">境界線の角丸</label><br> <label><input type="checkbox" value=".gcim__textarea,cursor">カーソルの形</label><br> <label><input type="checkbox" value=".gcim,boxShadow">コントロールの影</label><br> </div> <div class="peoperty-header">テキストのスタイル</div> <div class="peoperty-panel"> <label><input type="checkbox" value=".gcim__textarea,color">文字色</label><br> <label><input type="checkbox" value=".gcim__textarea,fontSize">フォントのサイズ</label><br> <label><input type="checkbox" value=".gcim__textarea,fontWeight">フォントの太さ</label><br> <label><input type="checkbox" value=".gcim__textarea,fontStyle">フォントのスタイル</label><br> <label><input type="checkbox" value=".gcim__textarea,fontFamily">フォントの種類</label><br> <label><input type="checkbox" value=".gcim__textarea,textAlign">水平方向の位置</label><br> <label><input type="checkbox" value=".gcim__textarea,textShadow">テキストの影</label><br> </div> <div class="peoperty-header">コントロール無効時のスタイル</div> <div class="peoperty-panel"> <label><input type="checkbox" value=".gcim__textarea:disabled,backgroundColor">背景色</label><br> <label><input type="checkbox" value=".gcim__textarea:disabled,color">文字色</label><br> <label><input type="checkbox" value=".gcim__textarea:disabled,cursor">カーソルの形</label><br> </div> <div class="peoperty-header">フォーカス時のスタイル</div> <div class="peoperty-panel"> <label><input type="checkbox" value=".gcim_focused,backgroundColor">背景色</label><br> <label><input type="checkbox" value=".gcim_focused,borderColor">境界線の色</label><br> <label><input type="checkbox" value=".gcim_focused,color">文字色</label><br> </div> <div class="peoperty-header">ウォーターマークのスタイル</div> <div class="peoperty-panel"> <label><input type="checkbox" value=".gcim_watermark_null,backgroundColor">背景色</label><br> <label><input type="checkbox" value=".gcim_watermark_null,borderColor">境界線の色</label><br> <label><input type="checkbox" value=".gcim_watermark_null,color">文字色</label><br> </div> <div class="peoperty-header">ウォーターマークのフォーカス時のスタイル</div> <div class="peoperty-panel"> <label><input type="checkbox" value=".gcim_focused.gcim_watermark_null,backgroundColor">背景色</label><br> <label><input type="checkbox" value=".gcim_focused.gcim_watermark_null,borderColor">境界線の色</label><br> <label><input type="checkbox" value=".gcim_focused.gcim_watermark_null,color">文字色</label><br> </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: { '@grapecity/inputman': 'npm:@grapecity/inputman/index.js', '@grapecity/inputman/CSS': 'npm:@grapecity/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' }, } });