Attachment
Overview
The Attachment component allows the user to upload files by selecting or dragging.
Specification
Property
Here is a list of properties that can be used for modifying the component:
| Name | Type | Default | Description | Remark | 
|---|---|---|---|---|
| className | string | "" | Component class name | |
| error | string | "" | Text to be displayed in error | Error will not be displayed if unspecified or left empty | 
| id | string | "" | Component id name | |
| label | string | "" | Label for the component | Label will not be displayed if unspecified or left empty | 
| language *1 | string | "auto" | Language setting | Available options: "auto", "en", "ja", "zh", "zh-TW" If setting "auto", it will be according to the HTML lang setting (If the lang setting is other than "en"/"zh"/"zh-TW"/"ja", the language setting will be "en") | 
| message | string | "" | Message to display in the component (ex. file type/size restriction) | |
| disabled | boolean | false | Enable/Disable the component | |
| requiredIcon | boolean | false | Show/Hide the required icon | |
| visible | boolean | true | Show/Hide the component | |
| files | Array<File> | [] | List of files | You can specify File object or object contains nameandsizeWill result an error if the value of filesis not an array | 
| File.name | string | "" | File name | |
| File.size | string | "" | File size | There are 4 types to show the size: | 
info
*1: The text of "Browse" button and "Drag & drop zone" will be changed according to the language property.
Event
Here is a list of events that can be specified:
| Name | Type | Description | Remark | 
|---|---|---|---|
| change | function | Event handler when the files have been changed | It will pass the event object as the argument You can receive the following values in event.detail 
 
 | 
Constructor
Attachment(options)
Here is a list of available constructors:
Parameter
| Name | Type | Default | Description | Remark | 
|---|---|---|---|---|
| options | object | {} | Object that includes component properties | 
Sample Code
tip
Please check the package installation method first.
Here is a sample code when all parameters are specified:
const Kuc = Kucs['1.x.x'];
const space = kintone.app.record.getSpaceElement('space');
const attachment = new Kuc.Attachment({
  label: 'Attachment',
  files: [
    { name: 'file.txt', size: '150' },
    new File(['foo'], 'foo.txt', { type: 'text/plain' })
  ],
  language: 'auto',
  message: 'Max size: 50MB',
  error: 'Error occurred!',
  className: 'options-class',
  id: 'options-id',
  visible: true,
  disabled: false,
  requiredIcon: false
});
space.appendChild(attachment);
attachment.addEventListener('change', event => {
  console.log(event);
});