• This repository has been archived on 01/Jul/2022
  • Stars
    star
    169
  • Rank 217,489 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

TOAST UI Calendar wrapper for React.js

⚠️ Notice: This repository is deprecated️️️️️

TOAST UI Calendar for React has been managed separately from the TOAST UI Calendar repository. As a result of the distribution of these issues, we decided to deprecate each wrapper repository and manage repository as a mono-repo from the TOAST UI Calendar repository.

From now on, please submit issues or contributions related to TOAST UI Calendar for React to TOAST UI Calendar repository. Thank you 🙂

TOAST UI Calendar for React

This is a React component wrapping TOAST UI Calendar.

github version npm version license PRs welcome code with hearth by NHN Cloud

🚩 Table of Contents

Collect statistics on the use of open source

React Wrapper of TOAST UI Calendar applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Calendar is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. > “ui.toast.com") is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the usageStatistics props like the example below.

<Calendar
  usageStatistics={false}
/>

Or, include tui-code-snippet.js (v1.4.0 or later) and then immediately write the options as follows:

tui.usageStatistics = false;

💾 Install

Using npm

npm install --save @toast-ui/react-calendar

📊 Usage

We provide a simple example and you can start right away.

Import

You can use Toast UI Calendar for React as a ECMAScript module or a CommonJS module. As this module does not contain CSS files, you should import tui-calendar.css from tui-calendar/dist manually.

  • Using ECMAScript module
import Calendar from '@toast-ui/react-calendar';
import 'tui-calendar/dist/tui-calendar.css';

// If you use the default popups, use this.
import 'tui-date-picker/dist/tui-date-picker.css';
import 'tui-time-picker/dist/tui-time-picker.css';
  • Using CommonJS module
var Calendar = require('@toast-ui/react-calendar');
require('tui-calendar/dist/tui-calendar.css');

// If you use the default popups, use this.
require('tui-date-picker/dist/tui-date-picker.css');
require('tui-time-picker/dist/tui-time-picker.css');

Props

We are supported in the form of props for Options of TOAST UI Calendar. Each name of props is same options of Toast UI Calendar except view is for defaultView of option. Additionally you can set schedules using schedules of prop.

const myTheme = {
  // Theme object to extends default dark theme.
};

const MyComponent = () => (
  <Calendar
    height="900px"
    calendars={[
      {
        id: '0',
        name: 'Private',
        bgColor: '#9e5fff',
        borderColor: '#9e5fff'
      },
      {
        id: '1',
        name: 'Company',
        bgColor: '#00a9ff',
        borderColor: '#00a9ff'
      }
    ]}
    disableDblClick={true}
    disableClick={false}
    isReadOnly={false}
    month={{
      startDayOfWeek: 0
    }}
    schedules={[
      {
        id: '1',
        calendarId: '0',
        title: 'TOAST UI Calendar Study',
        category: 'time',
        dueDateClass: '',
        start: today.toISOString(),
        end: getDate('hours', today, 3, '+').toISOString()
      },
      {
        id: '2',
        calendarId: '0',
        title: 'Practice',
        category: 'milestone',
        dueDateClass: '',
        start: getDate('date', today, 1, '+').toISOString(),
        end: getDate('date', today, 1, '+').toISOString(),
        isReadOnly: true
      },
      {
        id: '3',
        calendarId: '0',
        title: 'FE Workshop',
        category: 'allday',
        dueDateClass: '',
        start: getDate('date', today, 2, '-').toISOString(),
        end: getDate('date', today, 1, '-').toISOString(),
        isReadOnly: true
      },
      {
        id: '4',
        calendarId: '0',
        title: 'Report',
        category: 'time',
        dueDateClass: '',
        start: today.toISOString(),
        end: getDate('hours', today, 1, '+').toISOString()
      }
    ]}
    scheduleView
    taskView
    template={{
      milestone(schedule) {
        return `<span style="color:#fff;background-color: ${schedule.bgColor};">${
          schedule.title
        }</span>`;
      },
      milestoneTitle() {
        return 'Milestone';
      },
      allday(schedule) {
        return `${schedule.title}<i class="fa fa-refresh"></i>`;
      },
      alldayTitle() {
        return 'All Day';
      }
    }}
    theme={myTheme}
    timezones={[
      {
        timezoneOffset: 540,
        displayLabel: 'GMT+09:00',
        tooltip: 'Seoul'
      },
      {
        timezoneOffset: -420,
        displayLabel: 'GMT-08:00',
        tooltip: 'Los Angeles'
      }
    ]}
    useDetailPopup
    useCreationPopup
    view={selectedView} // You can also set the `defaultView` option.
    week={{
      showTimezoneCollapseButton: true,
      timezonesCollapsed: true
    }}
  />
);

Theme

You can write your own theme object. Link - See "themeConfig"

⚠️ Note for passing props

The calendar component check deep equality of props when re-rendered. However, for performance and to avoid unnecessary re-rendering, it's recommended to extract props to the outside of the component or memoize them with useMemo when props don't have to be affected by component state changes.

For more information, check this issue.

const calendars = [
  {
    id: '0',
    name: 'Private',
    bgColor: '#9e5fff',
    borderColor: '#9e5fff'
  },
  {
    id: '1',
    name: 'Company',
    bgColor: '#00a9ff',
    borderColor: '#00a9ff'
  }
];

// Especially avoid to declare the `template` prop inside the component.
const template = {
  milestone(schedule) {
    return `<span style="color:#fff;background-color: ${schedule.bgColor};">${
            schedule.title
    }</span>`;
  },
  milestoneTitle() {
    return 'Milestone';
  },
  allday(schedule) {
    return `${schedule.title}<i class="fa fa-refresh"></i>`;
  },
  alldayTitle() {
    return 'All Day';
  }
};

function MyCalendar() {
  // ...
  
  return (
    <Calendar
      // ...
      calendars={calendars}
      template={template}
    />
  )
}

Instance Methods

For using instance methods of TOAST UI Calendar, first thing to do is creating Refs of wrapper component using createRef(). But the wrapper component does not provide a way to call instance methods of TOAST UI Calendar directly. Instead, you can call getInstance() method of the wrapper component to get the instance, and call the methods on it.

const calendarOptions = {
  // sort of option properties.
};

class MyComponent extends React.Component {
  calendarRef = React.createRef();

  handleClickNextButton = () => {
    const calendarInstance = this.calendarRef.current.getInstance();

    calendarInstance.next();
  };

  render() {
    return (
      <>
        <Calendar
          ref={this.calendarRef}
          {...calendarOptions}
        />
        <button onClick={this.handleClickNextButton}>Go next!</button>
      </>
    );
  }
}

Getting the root element

An instance of the wrapper component also provides a handy method for getting the root element. If you want to manipulate the root element directly, you can call getRootElement to get the element.

class MyComponent extends React.Component {
  calendarRef = React.createRef();

  handleClickButton = () => {
    this.calendarRef.current.getRootElement().classList.add('calendar-root');
  };

  render() {
    return (
      <>
        <Calendar
          ref={this.calendarRef}
          {...calendarOptions}
        />
        <button onClick={this.handleClickButton}>Click!</button>
      </>
    );
  }
}

Event

All the events of TOAST UI Calendar are supported in the form of on[EventName] props. The first letter of each event name should be capitalized. For example, for using mousedown event you can use onMousedown prop like the example below.

class MyComponent extends React.Component {
  handleClickDayname = (ev) => {
    // view : week, day
    console.group('onClickDayname');
    console.log(ev.date);
    console.groupEnd();
  };

  render() {
    return (
      <Calendar
        onClickDayname={this.handleClickDayname}
      />
    );
  }
}

🔧 Pull Request Steps

TOAST UI products are open source, so you can create a pull request(PR) after you fix issues. Run npm scripts and develop yourself with the following process.

Setup

Fork develop branch into your personal repository. Clone it to local computer. Install node modules. Before starting development, you should check to haveany errors.

$ git clone https://github.com/{your-personal-repo}/[[repo name]].git
$ cd [[repo name]]
$ npm install

Develop

Let's start development!

Pull Request

Before PR, check to test lastly and then check any errors. If it has no error, commit and then push it!

For more information on PR's step, please see links of Contributing section.

💬 Contributing

📜 License

This software is licensed under the MIT © NHN Cloud.

More Repositories

1

tui.editor

🍞📝 Markdown WYSIWYG Editor. GFM Standard + Chart & UML Extensible.
TypeScript
16,762
star
2

tui.calendar

🍞📅A JavaScript calendar that has everything you need.
TypeScript
11,452
star
3

tui.image-editor

🍞🎨 Full-featured photo image editor using canvas. It is really easy, and it comes with great filters.
JavaScript
6,710
star
4

tui.chart

🍞📊 Beautiful chart for data visualization.
TypeScript
5,302
star
5

tui.grid

🍞🔡 The Powerful Component to Display and Edit Data. Experience the Ultimate Data Transformer!
TypeScript
2,371
star
6

fe.javascript

FE DEV LAB
1,119
star
7

gpm.unity

A brand of NHN providing free services required for game development.
304
star
8

toast-ui.vue-editor

This repository is DEPRECATED! GO TO 👉 https://github.com/nhn/tui.editor/tree/master/apps/vue-editor
JavaScript
230
star
9

toast-ui.vue-calendar

Toast UI Calendar for Vue
Vue
195
star
10

toast-ui.vue-image-editor

Toast UI Image Editor for Vue
Vue
189
star
11

tui.jsdoc-template

TUI JSDoc Template, Demo: https://nhnent.github.io/tui.jsdoc-template/latest/
JavaScript
177
star
12

socket.io-client-unity3d

socket.io-Client for Unity3D, which is compatible with socket.io v1.x
C#
165
star
13

toast-ui.react-image-editor

TOAST UI ImageEditor wrapper for React.js
JavaScript
117
star
14

toast-ui.doc

JavaScript
113
star
15

toast-haste.framework

TOAST Haste framework is a pure java implementation of asynchronous game server framework
Java
95
star
16

tui.date-picker

Component that selects specific date.
JavaScript
93
star
17

tui.code-snippet

Group of utility methods to make ease with developing javascript applications.
JavaScript
93
star
18

tui.tree

Component that displays data hierarchically.
JavaScript
90
star
19

tui.color-picker

Colorpicker component for web services.
JavaScript
57
star
20

tui.time-picker

Component that selects specific time.
JavaScript
57
star
21

toast-ui.vue-chart

Toast UI Chart for Vue
Vue
52
star
22

toast-ui.vue-grid

This repository is DEPRECATED! GO TO 👉
Vue
52
star
23

tui.pagination

Component that automatically calculate and generate page numbers.
JavaScript
49
star
24

toast-ui.react-editor

This repository is DEPRECATED! GO TO 👉 https://github.com/nhn/tui.editor/tree/master/apps/react-editor
JavaScript
47
star
25

tui.context-menu

Component that creates a menu when the right mouse button is clicked.
JavaScript
44
star
26

tui.app-loader

Component that installs a specific app by determining whether an app is installed on mobile devices.
JavaScript
43
star
27

eat

Json based scenario testing tool(which can have test for functional and non-functional)
Java
41
star
28

toast-ui.react-chart

Toast UI Chart for React
JavaScript
27
star
29

tui.ngx-calendar

TypeScript
26
star
30

tui.file-uploader

JavaScript
26
star
31

tui.eslint.config

ESLint Sharable Configuration for TUI Component
JavaScript
24
star
32

tui.auto-complete

TOAST UI Auto Complete
JavaScript
20
star
33

toast-ui.react-grid

This repository is DEPRECATED! GO TO 👉
JavaScript
19
star
34

toast-ui.select-box

Component that selects an option in the drop-down list.
JavaScript
18
star
35

toast-haste.sdk.dotnet

This repo is .NET client for TOAST Haste framework.
C#
16
star
36

tui.rolling

Components that rotates and displays items such as a slideshow.
JavaScript
14
star
37

tui.virtual-keyboard

JavaScript
12
star
38

tui.virtual-scroll

JavaScript
12
star
39

tui.animation

Javascript animation library with ease
JavaScript
11
star
40

tui.layout

JavaScript
10
star
41

toast.gamebase.unity.sample

C#
10
star
42

tui.flicking

JavaScript
7
star
43

tui.placeholder

JavaScript
7
star
44

dooray.scrum

JavaScript
7
star
45

dooray.vote

JavaScript
7
star
46

adlib.android_media_app

Java
6
star
47

tui.gesture-reader

fe.component-gesture-reader
JavaScript
6
star
48

tui.floating-layer

JavaScript
6
star
49

tui.dom

DOM control library for TOAST UI Components
JavaScript
6
star
50

toast-ui.detect-runtime-error-actions

🧐 Detect Runtime Error with browserstack
JavaScript
6
star
51

toastcloud.sdk

Objective-C
4
star
52

gameanvil.sample-game-server

Java
3
star
53

gameanvil.sample-game-test

Java
3
star
54

hands-on-labs.java.spring-boot-custom-starter

Python
3
star
55

nhncloud.ios.sdk

Objective-C
3
star
56

toast-ui.date

JavaScript
2
star
57

hands-on-labs.gamebase.guest-auth-on-js

Python
2
star
58

toast.gamebase.ios.sdk

2
star
59

toast.gamebase.unity.tools.setting-tool

2
star
60

hands-on-labs.java.mybatis-to-jpa

Java
2
star
61

hands-on-labs.toastui.calendar-timetable

Python
2
star
62

adlib.ios_media_app

Objective-C
2
star
63

gameanvil.agent

2
star
64

hands-on-labs.java.spring-boot-actuator

Makefile
1
star
65

hands-on-labs.gamebase.google-setting

Python
1
star
66

toast-ui.release-notes

Publish Github release note from a tag.
JavaScript
1
star
67

hands-on-labs.toastui.chart-dashboard

Python
1
star
68

gameanvil.sample-game-client-unity

HTML
1
star
69

tui.webpack.safe-umd-plugin

Webpack plugin to handle optional dependencies safely when using libraryTarget: umd
JavaScript
1
star
70

hands-on-labs.gamebase.install-with-setting-tool

Python
1
star
71

k8s.oss-helm-packages

JavaScript
1
star
72

hands-on-labs.toastui.grid-account-book

Python
1
star
73

hands-on-labs.java.jvmtop

Python
1
star
74

hands-on-labs.gamebase.guest-auth-on-unity

HTML
1
star
75

tui.component.calendar

JavaScript
1
star
76

terraform-provider-nhncloud

Terraform Provider for NHN Cloud
Go
1
star
77

ace.guide.script

웹로그분석 스크립트 설치가이드
HTML
1
star
78

hands-on-labs.toastui.editor-ext

Python
1
star