Text
Overview
Text は、単一行のテキストを表示します。
Specification
Property
使用できるプロパティの一覧です。プロパティを指定して値を更新することができます。
| Name | Type | Default | Description | Remark | 
|---|---|---|---|---|
| className | string | "" | コンポーネントの class 名 | |
| error | string | "" | エラーに表示するテキスト | 未指定、あるいは空文字の場合、error は表示されない | 
| id | string | "" | コンポーネントの id 名 | |
| label | string | "" | コンポーネントの説明ラベル | 未指定、あるいは空文字の場合、label は表示されない | 
| placeholder | string | "" | 空欄時に入力例として表示されるテキスト | |
| prefix | string | "" | Text の前に表示されるテキスト | |
| suffix | string | "" | Text の後に表示されるテキスト | |
| textAlign | string | "left" | 表示するテキストの位置 | 以下を指定できる "left" : 左寄せ "right" : 右寄せ | 
| value | string | "" | 表示するテキスト | |
| disabled | boolean | false | コンポーネントの編集可/不可設定 | |
| requiredIcon | boolean | false | コンポーネントの必須アイコン表示/非表示設定 | |
| visible | boolean | true | コンポーネントの表示/非表示設定 | 
Event
指定できるイベントの一覧です。
| Name | Type | Description | Remark | 
|---|---|---|---|
| change | function | 値が変更された時のイベントハンドラ | 引数には Event の event オブジェクトをとる event.detail で以下の値を受け取ることができる event.detail.oldValue : 変更前の value の値 event.detail.value : 変更後の value の値 | 
| focus | function | フォーカスされた時のイベントハンドラ | 引数には Event の event オブジェクトをとる event.detail で以下の値を受け取ることができる event.detail.value : フォーカス時の value の値 | 
| input | function | 値が入力されている時のイベントハンドラ | 引数には Event の event オブジェクトをとる event.detail で以下の値を受け取ることができる event.detail.data : 入力された文字列 event.detail.value : ターゲット要素の value の値 ※ event.detail.data の値についての補足 入力された文字列を指す ペーストやドラッグ&ドロップによって入力した場合は、null になる Enter, Delete, Backspace をクリックした場合は、null になる | 
Constructor
Text(options)
使用できるコンストラクタの一覧です。
Parameter
| Name | Type | Default | Description | Remark | 
|---|---|---|---|---|
| options | object | {} | コンポーネントのプロパティを含むオブジェクト | 
Custom CSS
ヒント
Custom CSS をご確認ください。
コンポーネントのスタイルを変更するために使用できるプロパティの一覧です。
Property
| Name | 
|---|
| --kuc-text-input-width | 
| --kuc-text-input-height | 
| --kuc-text-input-font-size | 
| --kuc-text-input-color | 
Sample Code
ヒント
導入と実装方法 をご確認ください。
全てのパラメータを指定した場合のサンプルコードです。
const Kuc = Kucs['1.x.x'];
const space = kintone.app.record.getSpaceElement('space');
const text = new Kuc.Text({
  label: 'Fruit',
  requiredIcon: true,
  value: 'Apple',
  placeholder: 'Apple',
  prefix: '$',
  suffix: 'yen',
  textAlign: 'left',
  error: 'Error occurred!',
  className: 'options-class',
  id: 'options-id',
  visible: true,
  disabled: false
});
space.appendChild(text);
text.addEventListener('change', event => {
  console.log(event);
});
text.addEventListener('focus', event => {
  console.log(event);
});
text.addEventListener('input', event => {
  console.log(event);
});