Code Monkey home page Code Monkey logo

toast-ui.react-calendar's Introduction

⚠️ 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.

toast-ui.react-calendar's People

Contributors

adhrinae avatar awer000 avatar dependabot[bot] avatar dotaitch avatar iamchanii avatar jungeun-cho avatar junghwan-park avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

toast-ui.react-calendar's Issues

display problem

Good evening,

I have a display problem.

image

How to make sure that the calendar does not overflow on the right area (circled in yellow)? because in my case, it supersoses my menu.

thank you

Hi click block to formuls

Hi my formuls 90min/30 = 1 block 30 min.
My design teacher create lesson #1 = 90 minut duration
apprentice choice hower 3 block and add 3 block
1 block calendary - 30 min
how to 3 block dont 1 block.
My Task create 1 event 90 min and new user choice

Calendar next is not working

I try create next button in tui calendar and material-ui-core.
but I applied handleClickNextButton, It shows me TypeError: Cannot read property 'getInstance' of undefined

here's my calendar code.

...

  calendarRef = () => React.createRef();

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

    calendarInstance.next();
  };

...

render(){
return(
 <Button className={classes.changeBtn} onClick={this.handleClickNextButton}>
  <ChevronRightIcon />
 </Button>


 <Calendar
  week={timeLimit}
  month={monthConfig}
  view="month"
  theme={themeConfig}
  taskView={false}
  usageStatistics={false}
  isReadOnly={true}
  schedules={care.flat(1)}
  calendarRef={React.createRef()}
 />
)
}

Does not display calendar schedules

I can't seem to be able to display the schedule on the calendar. I am sure there must be something wrong with how I'm using this. Can someone tell what changes I have to make? Thanks!

This is how the calendar looks like, no schedules show up.
Screen Shot 2021-03-18 at 2 47 49 AM

Here's my code.

import React, { useState, useEffect, useRef } from "react";

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

const moment = require('moment-timezone')

const UserDashboardPage = (props) => {

    const calRef = useRef()

    const start = new Date();
    const end = new Date(new Date().setMinutes(start.getMinutes() + 30));
    const events = [
        {
            calendarId: "1",
            category: "time",
            isVisible: true,
            title: "Study",
            id: "1",
            body: "Test",
            start,
            end
        },
        {
            calendarId: "2",
            category: "time",
            isVisible: true,
            title: "Meeting",
            id: "2",
            body: "Description",
            start: new Date(new Date().setHours(start.getHours() + 1)),
            end: new Date(new Date().setHours(start.getHours() + 2))
        }
    ];

    const calendars = [
        {
            id: "1",
            name: "My Calendar",
            color: "#ffffff",
            bgColor: "#9e5fff",
            dragBgColor: "#9e5fff",
            borderColor: "#9e5fff"
        },
        {
            id: "2",
            name: "Company",
            color: "#ffffff",
            bgColor: "#00a9ff",
            dragBgColor: "#00a9ff",
            borderColor: "#00a9ff"
        }
    ];

    return (
              <Calendar
                    ref={calRef}
                    height={`${window.innerHeight - (12 * 16)}px`}
                    usageStatistics={false}
                    defaultView={'week'}
                    scheduleView
                    taskView={false}
                    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';
                        }
                      }}
                    calendars={calendars}
                    schedule={events}
                />
    )
}

export default UserDashboardPage;

Hope you can guide me @jungeun-cho, since I copied a lot of the code from your CodeSandbox. Thanks!

Problem with 'changeView'

Hello,

I have a problem with function : "this.calendarInst.changeView" :

tempsnip

PS : I am under the reactjs 15 framework

image

Do you have a solution ?

Thanks

Handling calendar events with useState() hook

Version

v1.0.5

Test Environment

Browsers - Firefox, chrome
OS - Windows

Current Behavior

My usecase requires me to update the local state of the application when user clicks on a tile.

By the documentation, clicking on a tile fires the "beforeCreateSchedule" event, so naturally I've tried collecting it (as it contains everything I need) and saving it in the local state by using the setter function returned by useState.

But doing so leads to re-rendering the page, this causes the "guide" to disappear. It also seems to strip the event of some data. While, that stripped data isn't essential for me, the disappearance of the guide isn't what I want.

Here's some code to demonstrate what I'm doing since there might be something wrong in my method:

....
const [selectedTile, setSelectedTile] = useState();
....

<Calendar
    {....calendarOptions}
    onBeforeCreateSchedule={(e) => { setSelectedTile(e) }};
/>

Expected Behavior

What I want to achieve is :

  1. The guide stays where it's been when user clicked the tile
  2. the selectedTile state has at least some basic info about the tile, for example, the date it represents
    as it's needed later down the road

Thank you in advance!

DnD events doesn't work

Version

"@toast-ui/react-calendar": "^1.0.4",

Test Environment

Chrome 77 , Win10

Current Behavior

I can select an event, and move it perfectly, but i can't drop it.
Dragging work perfectly, but drop doesn't work.

import React, { Component } from "react";
import logo from './logo.svg';
import Calendar from '@toast-ui/react-calendar';

// If you use the default popups, use this.
import 'tui-date-picker/dist/tui-date-picker.css';
import 'tui-date-picker/dist/tui-date-picker.css';
import 'tui-time-picker/dist/tui-time-picker.css';
import './App.css';
import 'tui-calendar/dist/tui-calendar.css';

let DateGenerator = require('random-date-generator')

class App extends Component {
  constructor(props, context) {
    super(props, context);
    this.state = {events:[]};
  }



  generateEvents(nbEvents) {
    let startDate = new Date(2019, 9, 6)
    let endDate = new Date(2019, 9, 12)

    let events = [];
    for (let i = 0; i < nbEvents; i++) {
      let start = DateGenerator.getRandomDateInRange(startDate, endDate)
      let end =  start.setHours(start.getHours()+2)
      let event = {
        id: i,
        title: "event " + i,
        calendarId: '0',
        category: 'time',
        start: start,
        end: new Date( end )
      }
      events.push(event)
    }
    this.setState({events:events})
  }

  componentWillMount() {

    this.generateEvents(2000);
  }
  render() {
    return (
      <div>
        <Calendar
          height="900px"
          setDate={new Date(2019, 0, 5)}
          calendars={[
            {
              id: '1',
              name: 'Company',
              bgColor: '#00a9ff',
              borderColor: '#00a9ff'
            }
          ]}
          disableDblClick={true}
          disableClick={true}
          view="week"
          isReadOnly={false}
          month={{
            startDayOfWeek: 0
          }}
          schedules={this.state.events}
          scheduleView="time"
          taskView={false}
          useDetailPopup={true}
          useCreationPopup={true}
          week={{
            showTimezoneCollapseButton: true,
            timezonesCollapsed: true
          }}
        />
      </div>

    );
  }

}



export default App;

Expected Behavior

Drag an event, and drop it where desired


I have another question, is it possible to set a default start date for the calendar ?

Thx

month view not workink

Version

"@toast-ui/react-calendar": "^1.0.1"

Test Environment

Goolgle Chrome Versión 75.0.3770.100 Windows

Current Behavior

When I switch to the month view, it is not displayed correctly. Only the headers are shown.

In others views, it is displayed correctly.

import * as React from 'react';
import Typography from '@material-ui/core/Typography';
import { Link } from 'react-router-dom';
import { linkRoutes } from 'core/router';
import { useTranslation, composeInitialProps } from 'react-i18next';
import { namespaces } from 'core/i18n';
import { keys } from './translations';
import Calendar from '@toast-ui/react-calendar';
import Button from '@material-ui/core/Button';
import { makeStyles } from '@material-ui/core/styles';
import moment from 'moment';

interface Props {
  schedules: any;
}

const useStyles = makeStyles(theme => ({
  button: {
    margin: theme.spacing(1),
  },
  input: {
    display: 'none',
  },
}));

export const HorarioComponent: React.FunctionComponent<Props> = props => {

  const classes = useStyles(props);
  const { t } = useTranslation(namespaces.pods.horario);

  const [view, setView] = React.useState('day');

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

  function handleDiaClick(e) {
    e.preventDefault();
    setView('day');
  }

  function handleSemanaClick(e) {
    e.preventDefault();
    setView('week');
  }

  function handleMesClick(e) {
    e.preventDefault();
    setView('month');
  }



  return (
    <>
      <Typography variant="h4">{t(keys.title)}</Typography>
      <Link to={linkRoutes.base}>
        <Typography variant="body1">{t(keys.link)}</Typography>
      </Link>
      <div id="botones" style={{ width: '100%' }}>
        <Button
          variant="contained"
          className={classes.button}
          onClick={handleDiaClick}
        >
          Dia
        </Button>
        <Button
          variant="contained"
          className={classes.button}
          onClick={handleSemanaClick}
        >
          Semana
        </Button>
        <Button
          variant="contained"
          className={classes.button}
          onClick={handleMesClick}
        >
          Mes
        </Button>
      </div>
      <div id="calendar" style={{ width: '100%' }}>
        <Calendar
          calendars={[
            {
              id: '0',
              name: 'Asignatura 1',
              bgColor: '#9e5fff',
              borderColor: '#9e5fff',
            },
            {
              id: '1',
              name: 'Asignatura 2',
              bgColor: '#00a9ff',
              borderColor: '#00a9ff',
            },
          ]}
          view={view}
          disableDblClick={true}
          disableClick={true}
          height="100%"
          isReadOnly={true}
          month={{
            daynames: ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab'],
            startDayOfWeek: 1,
            visibleWeeksCount: 6,
          }}
          schedules={props.schedules}
          scheduleView={true}
          taskView={false}
          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 'Todo el dia';
            },
          }}
          theme={myTheme}
          /*   timezones={[
            {
              timezoneOffset: 540,
              displayLabel: 'GMT+01:00',
              tooltip: 'Madrid',
            },
          ]} */
          useDetailPopup
          useCreationPopup
          //    view={selectedView}
          week={{
            startDayOfWeek: 1,
            daynames: ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab'],
            showTimezoneCollapseButton: true,
            timezonesCollapsed: true,
            hourStart: 8,
            hourEnd: 18,
          }}
        />
      </div>
    </>
  );
};

2019-07-09_22-28-54

Expected Behavior

I would like to see the month view

캘린더 내 날짜 표시

현재 라이브러리 적용해서 다음/이전 그리고 표시까지는 성공하였으나, 이 달력이 몇월인지 혹은 몇일인지가 표시가 돼지 않아 혼동이 옵니다.
원본 js코드 문서에서는 잘 나오는 듯 하나 리액트에서는 해당 문서는 찾아 볼 수 없는 듯 합니다.
혹시 이 기능은 지원하지 않는 것인지 궁금합니다.

How to set calendar width?

Hello, how to set calendar width?

Using this code I am getting

image

Manually setting width in navigator works, but I don't know how to do it from code.

image

image

there must be something better than this

.tui-full-calendar-layout {
    width: 80vw;
}

Can I change font size of month title option

Can I change font size of month title tag?
I want changing font size but, I think it gives me options for dayname, day only.
if not, can I get answer?
I cannot find at themeconfig official document.

timegridDisplayPrimaryTime is not working. but timegridDisplayPrimayTime is works.

Version

  • @toast-ui/react-calendar: ^1.0.4
  • tui-calendar: ^1.12.5

Test Environment

  • macOS 10.14.6(18G95)
  • chrome 77.0.3865.90 64bit

Current Behavior

I tried to customize time hour text to display 24hours format. I read tui-calendar documentation and according to it, timegridDisplayPrimayTime template is deprecated. but currently, timegridDisplayPrimayTime is only working template to do what I want.

const template: ITemplateConfig = {
    // ...
    timegridDisplayPrimayTime: time => {
        return 'this is deprecated.';
    },
    timegridDisplayPrimaryTime: time => {
        return 'but this is not working.';
    },
   // ...
};

image

Expected Behavior

Display timegridDisplayPrimaryTime function returned. is there what I missed?

Alignment Issue

Version: 1.0.6

<Calendar />

Screenshot 2022-06-11 122818

This line

<div class="tui-full-calendar-layout tui-view-1" style="background-color: white;"></div>

offsets the calendar by 800px by default

Fix

<Calendar height="10px"/>

ref prop is not exist in calendar ==> so i can not use instance method

Version

"@toast-ui/react-calendar": "^1.0.5"
"tui-calendar": "^1.12.13"

Test Environment

"next": "9.3.6
Microsoft Edge 84.0.522.40

Current Behavior

Cannot find ref prop in Calendar

Property 'ref' does not exist on type 'IntrinsicAttributes & IOptions & EventMaps & { height: string; view?: string | undefined; schedules?: ISchedule[] | undefined; } & HTMLAttributes<...> & { ...; }'.

const MonthlyCalendar: FC<MonthlyCalendarProps> = function (props) {
  const ref = useRef()
  return (
    <Box display="flex" flexDirection="column" alignItems="stretch" pt={3} pb={3}>
      <Header />
      <Calendar 
        {...defaultProps} 
        ref={ref}  // ERROR HERE
        view="month" 
        height="800px" 
        {...props} />
    </Box>
  )
}
  )
}

Expected Behavior

ref prop exists

Is the calendar multilingual supported?

Version

"@toast-ui/react-calendar": "^1.0.6",

Test Environment

windows 10
crome

Current Behavior

calendar date
May 10, 2022
Whether multilingual conversion
Is it possible?

// Write example code

Expected Behavior

today is not defined

Am trying to follow the example in example but I get
today is not defiend what am missing ?

<Calendar
                  ref={this.calendarRef}
                  {...calendarOptions}
                  calendars={
                      [
                          {
                              id: '0',
                              name: 'Private',
                              bgColor: '#9e5fff',
                              borderColor: '#9e5fff'
                          },
                          {
                              id: '1',
                              name: 'Company',
                              bgColor: '#00a9ff',
                              borderColor: '#00a9ff'
                          }
                      ]}

                  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()
                      }
                  ]}
                  useCreationPopup={true}
                  useDetailPopup={true}
                  scheduleView
                  taskView
                  view='day'// You can also set the `defaultView` option.
                  week={{
                      showTimezoneCollapseButton: true,
                      timezonesCollapsed: true
                  }}
              />

how can i custoize useDetailPopup useCreationPopup ui templete in ReactJs?

Version

Type definitions for TOAST UI Calendar v1.15.3
TypeScript Version: 3.2.1

  calendarInstRef.current.on("clickSchedule", function (event) {
    alert(JSON.stringify(event.schedule));
    var schedule = event.schedule;
  });

how can I pass html or overtight this ui
I am using react and nextjs now I want to customize this useDetailPopup with different HTML/CSS UI ,

Expected Behavior

image

How to set the time?

Version

Test Environment

chrome

Current Behavior

// Write example code

Expected Behavior

hi .
I want to change the current 30 minute unit to 10 minute unit

(시간이 30분 단위로 되어있는데 10분 단위로 변경하고 싶다)

thanks

How can i set background color on clicked date on month view with onBeforeCreateSchedule and without useCreationPopup

Version

"@toast-ui/react-calendar": "^1.0.5",
"tui-calendar": "^1.12.13"

Test Environment

windows 10 pro 2004
microsoft edge 84

nodejs 12
nextjs 9.3.6
react 16.13.1

Current Behavior

as title, How can i paint background color only clicked Day cell in month view without using useCreationPopup?
because, i dont want to make default creation popup onClick event

using guide param in onBeforeCreateSchedule to achieve this is impossible.
using getRootElement too.

Expected Behavior

adding selectedDate prop in Calendar will be best.
But if there's another way, please share it.
thank you!

ReferenceError: window is not defined

Version

1.0.5

Test Environment

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36

Current Behavior

If I add Calendar component while the project is running so it's work.
import Calendar from "@toast-ui/react-calendar";
but it's can't start with "yarn start"
What is the root cause? Thanks

})(window, function(__WEBPACK_EXTERNAL_MODULE_tui_code_snippet__, __WEBPACK_EXTERNAL_MODULE_tui_date_picker__) {
   ^

ReferenceError: window is not defined
    at Object.<anonymous> (C:\Users\Thao\Documents\Github\App\node_modules\tui-calendar\dist\tui-calendar.js:16:4)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at eval (webpack:///external_%22tui-calendar%22?:1:18)
    at Object.tui-calendar (C:\Users\Thao\Documents\Github\App\build\server.js:21026:1)
    at __webpack_require__ (C:\Users\Thao\Documents\Github\App\build\server.js:21:30)
error Command failed with exit code 1.
import Calendar from "@toast-ui/react-calendar";
import "tui-calendar/dist/tui-calendar.css"

const CalendarComponent = () => {
   return (
      <Calendar height="100vh"/>
   )
}

export default CalendarComponent;

Expected Behavior

How to fix this error? Thanks!

Is there a way to remove the scrollbar

Version

"@toast-ui/react-calendar": "^1.0.6",

Test Environment

windows 10
microsoft edge

Current Behavior

As title suggests, just wanted to ask if there is a way to remove the scrollbar in the calendar?

Expected Behavior

Popup date time picker date end not setting the proper time

toast-ui/react-calendar version 1.0.5

"@toast-ui/react-calendar": "^1.0.5",
"tui-calendar": "1.13.1",
"tui-date-picker": "4.2.2",
"tui-time-picker": "2.1.2"

Current Behavior

I noticed that with the above version of the libraries the date-time picker for the end date provided in the creation popup is picking the same date as the start date.

In your codepen example at https://codesandbox.io/s/toast-uireact-calendar-82fi9 this issue is not repflected as the libs version are much older.

Any ideas how to fix it?

Here is an screenshot of the issue:

ref doesn't exist

Version

"@toast-ui/react-calendar": "^1.0.5",

Test Environment

chrome mac catalina

Current Behavior

nextjs 10 에서 "@toast-ui/react-calendar": "^1.0.5", 를 이용하는데 window is not defined라는 에러가 발생해서

와같이 시도를 하면 달력은 생성되나 ref로 method을 받아올수가 없습니다. console로 확인해보면 아래와같은 값만 확인됩니다.
스크린샷 2021-04-14 오후 2 44 39

Setting react component state from within an event handler breaks guide render

Version

@toast-ui/react-calendar: ^1.0.5

Test Environment

Firefox, Mac OS

Details

Setting state from within the event handler causes the schedule guide to not show up. However... when the calendar and schedule props are not passed in, the calendar functions properly.

I am using react state to keep track of when I should render my custom schedule creation popover. Is this not a pattern I should be using? it seems like the right "React" way to do it - should I be appending my popover element to the DOM from within the handler?

This is a video of with and without the schedules/calendars

screen-recording-2022-01-20-at-100546-pm_bX0oXxMv.mov

Below is some code that should help reproduce the problem.

CODE

import React, {useEffect, useRef, useState} from 'react';
import Cal from '@toast-ui/react-calendar';
import {DateTime} from 'luxon';

const startDate = DateTime.now().minus({hours: 4});
const endDate = startDate.plus({hours: 4});

export function Calendar() {
  const [count, setCount] = useState(0);

  return (
      <Cal
        defaultView="week"
        taskView={false}
        theme={theme}
        height="100%"
        disableDblClick={true}
        disableClick={false}
        isReadOnly={false}
        calendars={[
          {
            id: '0',
            name: 'Private',
            bgColor: '#9e5fff',
            borderColor: '#9e5fff',
          },
        ]}
        schedules={[
          {
            id: '1',
            calendarId: '0',
            title: 'TOAST UI Calendar Study',
            category: 'time',
            dueDateClass: '',
            start: startDate.toISO(),
            end: endDate.toISO(),
          },
        ]}
        onBeforeCreateSchedule={() => {
          setCount(count + 1);
        }}
      />
  );
}

In summary

  • Setting state from within a handler with calendar or schedule = not working
  • Setting state from within a handler without calendar or schedule = working

how can i re-render calendar from state

Version

^1.0.5

Test Environment

widnows10 pro 64bit

Current Behavior

i want to update schedule use state. but its not render new schedule
if call render, can not render new schedule

_insertSchedule = (title:string, body:string, start: Date, end: Date) => {
    const previousSchedule:ISchedule[] = this.state.schedule
    start = new Date(new Date(start.getFullYear(), start.getMonth(), start.getDate()).setHours(12,0,0))
    end = new Date(new Date(end.getFullYear(), end.getMonth(), end.getDate()).setHours(12,0,0))
    let newSchedule:ISchedule = {
      calendarId: "1",
      category: "time",
      title: title,
      id: (this.state.schedule.length+1).toString(),
      body: body,
      start: start,
      end: end
    }
    previousSchedule.push(newSchedule)
    this.setState({schedule: previousSchedule})
  }

Expected Behavior

how can render new schedule from state

Wrong definition

Version

1.0.5

Test Environment

Chrome last version, Windows 10, TypeScript

Current Behavior

I noticed a problem with the types of events. It returns what is written in the documentation, but there is something completely different in the definition files. In the definition files it should return ISchedule, but it return:

{
isAllDay: true
start: TZDate {_date: Mon Jan 27 2020 00:00:00 GMT+0100 (czas środkowoeuropejski standardowy)}
end: TZDate {_date: Tue Jan 28 2020 23:59:59 GMT+0100 (czas środkowoeuropejski standardowy)}
guide: MonthGuide
options: {top: 0, height: "100%", bgColor: "#f7ca88", label: "New event", isResizeMode: false,}
view: Month {__fe_id: 51, id: 51, container: div.tui-full-calendar-month.tui-view-51.tui-view-52.tui-full-calendar-vlayout-container, children: Collection, parent: Layout,}
weeks: (6) [WeekdayInMonth, WeekdayInMonth, WeekdayInMonth, WeekdayInMonth, WeekdayInMonth, WeekdayInMonth]
days: 7
ratio: ƒ ()
startCoord: (2) [0, 0]
guideElements: {0: div.tui-full-calendar-month-guide-block}
grids: (7) [{}, {}, {}, {}, {}, {}, {}]
__proto__: Object
triggerEventName: undefined
__proto__: Object
}

Expected Behavior

Should return type as it in https://nhn.github.io/tui.calendar/latest/Calendar#event-beforeCreateSchedule

defaultView and datepicker in createPopup does not work.

The create popup is not showing the date picker correctly.
Also the defaultView does not do anything when setting that prop to anything other than weekly.

Using the latest version

Test Environment

Win10 nodeJS reactjs

Current Behavior

When I create an event the createPopup shows. but when clicking the date picker the dropdown that is supposed to show it only shows as in the image.

image

When setting the defaultView to month or day it does not change the view. I can however change the view by using an event handler, but not change the default view.

//.............CALENDAR OPTIONS..............
const calendarOptions = ({
    calendars: 
        [{
            id: '0',
            name: 'Jaime',
            bgColor: '#9e5fff',
            borderColor: '#9e5fff'
        }],
    isReadOnly: false,
    defaultView: "month",
    disableDblClick: true,
    height: "650px",
    week: {
        startDayOfWeek: 1,
        showTimezoneCollapseButton: false,
        hourStart: 6,
        hourEnd: 20
      },
    month: {
        startDayOfWeek: 1
      },
    taskView: false,
    scheduleView: true,
    template: {
        allday(schedule) {
          return `${schedule.title}<i class="fa fa-refresh"></i>`;
        },
        alldayTitle() {
          return 'All Day';
        }
      },
    useDetailPopup: true,
    useCreationPopup: true
    
});

//..............CALENDAR RENDER CLASS................

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

    changeViewToDay = () => {
        const calendarInstance = this.calendarRef.current.getInstance();
        calendarInstance.changeView('day', true);
    }

    changeViewToWeek = () => {
        const calendarInstance = this.calendarRef.current.getInstance();
        calendarInstance.changeView('week', true);
    }

    changeViewToMonth = () => {
        const calendarInstance = this.calendarRef.current.getInstance();
        calendarInstance.changeView('month', true);
    }

    handleClickNextButton = () => {
        const calendarInstance = this.calendarRef.current.getInstance();
        calendarInstance.next();
    };
    handleClickPrevButton = () => {
        const calendarInstance = this.calendarRef.current.getInstance();
        calendarInstance.prev();
    };

    render() {
        return (
            <>
            <div className="btn-group">
                <Button className="btn-sm" onClick={this.handleClickPrevButton} text="Prev" />
                <Button className="btn-sm" onClick={this.handleClickNextButton} text="Next" />
            </div>
            <div className="btn-group">
                <Button className="btn-sm" onClick={this.changeViewToDay} text="Day" />
                <Button className="btn-sm" onClick={this.changeViewToWeek} text="Week" />
                <Button className="btn-sm" onClick={this.changeViewToMonth} text="Month" />
            </div>
                <Calendar
                    ref={this.calendarRef}
                    {...calendarOptions}
                />
            </>
        );
    }
}

class Scheduling extends React.Component {
    state = {}

    render() {
        return (
            <Content title="Scheduling" subTitle="" browserTitle="IntelliBook - Manage Users">
                <Row>
                    <Col xs={4}>
                        <Box title="Add Event" type="primary" closable collapsable footer={<Button type="danger" text="Button" />}>
                            Hello World
            </Box>
                    </Col>
                    <Col xs={8}>
                        <Box title="Calendar">
                            <RenderCal />
                        </Box>
                    </Col>
                </Row>
            </Content>
        );
    }
}

Expected Behavior

Expected behavior is to show the datepicker in the create popup. And to show the month/day view on inital render when I set that prop.

getDate is not defined

Version

1.0.5

Test Environment

Chrome

Current Behavior

I have added your example but I receive getDate is not defined.

Expected Behavior

Bundle with Webpack 5 (Create React App 5) resolve warning

Version

1.15.3

Test Environment

Windows 10, Chrome 100

Current Behavior

Bundle with Webpack 5.69.1 (Create React App for example) return warning

WARNING in ./node_modules/.pnpm/[email protected]/node_modules/tui-calendar/dist/tui-calendar.js
Module Warning (from ./node_modules/.pnpm/[email protected][email protected]/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map: 'webpack://tui.Calendar/webpack/universalModuleDefinition' URL is not supported
 @ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@toast-ui/react-calendar/dist/toastui-react-calendar.js 49:14-37

Expected Behavior

No warning message

Could not find a declaration file for module '@toast-ui/react-calendar'

Version

"@toast-ui/react-calendar": "^1.0.2",

Test Environment

SharePoint Framework Extension

Current Behavior

It works but throws a type warning, thought to raise:
Could not find a declaration file for module '@toast-ui/react-calendar'. responsive-calendar/node_modules/@toast-ui/react-calendar/dist/toastui-react-calendar.js' implicitly has an 'any' type.
Try npm install @types/toast-ui__react-calendar if it exists or add a new declaration (.d.ts) file containing declare module '@toast-ui/react-calendar';

// Write example code

Expected Behavior

Support Typescript please, thank you in advance

Show Detail Popup on mouse hover

Version

1.12.5

Test Environment

Chrome 77.0 | Windows 10

Current Behavior

I'm unable to find the way to show the Detail Popup on mouse hover.

Expected Behavior

I would like to ask if there is any way to show the Detail Popup on mouse hover?

Thank you!

How can I edit the popup?

Version

v1.0.5

Test Environment

windows 10, using VSCode as IDE

Current Behavior

I'd like to add an element such as a text box to the pop up when creating schedule. But I have no idea how I should edit the pop up.

Expected Behavior

Edit existing pop up. Add other options to pop up.

Focusing the calendar month view to the specific month

Hey everyone, is there any option when creating an event in the calendar to focus on a specific month. For example, we are today in April, but when I create an event that will be in September, to automatically change the calendar month view in September?

How can I set time limit in calendar?

Hello, I want use this calendar for company management system.
It works on my PC but it shows me full time, I just want show 09:00-17:00 in this calendar.
but It doesn't have options for limit.
this calendar can not set custom limit times in react?

bindEventHandlers is never off event when use useCallback hook.

Version

  • @toast-ui/react-calendar: 1.0.4

Test Environment

  • macOS 10.14.6
  • chrome 76

Current Behavior

  • reproduce: https://codesandbox.io/s/white-moon-xe6zw
  • There is onClickSchedule event handler that wrapped with useCallback hook.
  • Click test schedule. alert is display just once.
  • Click rerender button and click test schedule again. alert is display twice.

Expected Behavior

  • onClickSchedule should called only 1 time.

Please check bindEventHandlers method in index.js. there is a logic what compare event handlers with previous. I think it have to call off() before call on() every event handlers even if equals.

Cannot update option template - time

Version

1.0.4

Test Environment

Browser: Chrome 77.0.3865.120
OS: Windows

Current Behavior

  • Set <Calendar ref={calendarRef} template={{time: getTimeTemplate(calendarView)}} />
  • When user changes calendar view - onChangeCalendarView even calls
calendarRef.current.getInstance().setOptions({
  template: { time: getTimeTemplate(calendarView) }
})
  • Function getTimeTemplate is like
const getTimeTemplate = (calendarView) => (schedule) => {
  return calendarView === 'month' ? 'aaa' : 'bbb';
};
  • The template of time is not changed

Expected Behavior

The template should be changed

defaultView not working

Version

"@toast-ui/react-calendar": "^1.0.1"

Test Environment

MAC OS Mojave 10.14.1

Current Behavior

adding defaultView="month" does not show the month view as expected, it remains with the same view

const AirworkCalendar = () => {
  return (
    <Calendar
      defaultView="month"
      usageStatistics={false}
      calendars={[
        {
          id: "0",
          name: "Private",
          bgColor: "#9e5fff",
          borderColor: "#9e5fff"
        }
      ]}
      disableDblClick={true}
      height="50vh"
      isReadOnly={true}
      month={{
        visibleWeeksCount: 3
      }}
      schedules={[
        {
          id: "1",
          calendarId: "0",
          title: "TOAST UI Calendar Study",
          category: "time",
          dueDateClass: "",
          start: changeTodayDateInDays(0),
          end: changeTodayDateInDays(3)
        }
      ]}
      template={{
        milestone(schedule) {
          return `<span style="color:#fff;background-color: ${
            schedule.bgColor
          };">${schedule.title}</span>`;
        }
      }}
      theme={myTheme}
      timezones={[
        {
          timezoneOffset: -420,
          displayLabel: "GMT-08:00",
          tooltip: "San Francisco"
        }
      ]}
    />
  );
};

This is an screenshot of the current behaviour
image

Expected Behavior

I would like to get the view like in the example https://nhn.github.io/tui.calendar/latest/tutorial-example05-3-weeks

15시 이상일 경우 DB에서는 정상이나, 캘린더에서는 1일 뒤로 미뤄지는 현상

    const care = customers.map((c) => {
      if (c.value.time !== undefined || null) {
        if ((c.value.first && c.value.second !== undefined) || null) {
          return [
            {
              title: `${c.value.name} 1차 ${c.value.time}`,
              category: "time",
              start: c.value.first + "T" + c.value.time,
              end: c.value.first + "T" + c.value.time,
            },
            {
              title: `${c.value.name} 2차 ${c.value.time}`,
              category: "time",
              start: c.value.second + "T" + c.value.time,
              end: c.value.second + "T" + c.value.time,
            },
          ];
        } else {
          return [{}];
        }
      } else {
        return [{}];
      }
    });

Object 방식으로 DB의 json을 변환 한 뒤 출력을 했는데, 데이터 수정 시 15시 이상일 경우 DB에서는 정상이나, 캘린더에서는 1일 뒤로 미뤄지는 현상이 생깁니다.

Apr-30-2020 17-18-03

I cannot specify className when creating the calendar in render function

Version

1.0.3

Test Environment

Chrome on MacOS and Windows
I am using typescript

Current Behavior

// example code
<Calendar
          className="calendarDiv"
          ref={this.calendarRef}
          {...calendarOptions}
/>

className is no longer recognized and it does not compile in 1.0.3

Expected Behavior

Ability to be able to specify a CSS class
This code above works just fine in 1.0.2

Calendar Color not working as specified in the API documentation

Version

"@toast-ui/react-calendar": "1.0.3"

Test Environment

OpenSUSE, 60.8.0esr

Current Behavior

The color of the individual schedules does not change based on the color set in the corresponding calendar. The default greenish color is used all the time.

 render() {
        let calendars = [];
        for (let item of this.props.courses) {
            let calColor = getRandomColor();
            calendars.push({
                id: item.id,
                name: item.subject + item.courseNumber.toString(),
                bgColor: calColor,
                borderColor: calColor
            });
        }

        let schedules = [];
        let currentScheduleId = 0;
        for (let item of this.props.sections) {
            let duration = getScheduleDuration(item);
            for (let timeframe of duration) {
                schedules.push({
                    id: currentScheduleId++,
                    trueId: item.id,
                    calendarId: item.archtype.id,
                    title: item.archtype.subject + item.archtype.courseNumber + "-" + item.section,
                    category: "time",
                    start: timeframe.start.toISOString(),
                    end: timeframe.end.toISOString(),
                    isReadOnly: true
                });
            }
        }

        return (
            <Calendar usageStatistics={false} defaultView={"week"} disableDblClick={true} disableClick={true}
                      isReadOnly={true} taskView={false} scheduleView={true} useDetailPopup={true} calendars={calendars}
                      schedules={schedules}/>
        )
    }

In this screenshot, the COMP 410 and COMP 411 should be colored differently since they are on two different calendars.
alt text

Expected Behavior

I expected the background color of all the schedules under the same calendar to be the randomly generated color as suggested by the example at: https://nhn.github.io/tui.calendar/latest/CalendarProps in the code snippet above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.