GithubHelp home page GithubHelp logo

fafruch / react-rrule-generator Goto Github PK

View Code? Open in Web Editor NEW
106.0 4.0 111.0 5.54 MB

[NO LONGER MAINTAINED] Recurrence rules generator form built with React

Home Page: https://fafruch.github.io/react-rrule-generator/

License: MIT License

HTML 0.31% JavaScript 95.90% CSS 3.79%
rrule recurrence recurrence-rules recurring-events calendar icalendar-rfc rfc react reactjs

react-rrule-generator's Introduction

React RRule Generator

Recurrence rules generator form built with React

LICENSE npm

This project is no longer maintained by me. Thank you for all your past contributions. Let the forks rock it for you.

Screenshot

Description

This is ReactJS project based on Create React Library and using Bootstrap styling. It's built with the help of a great rrule.js library.

It also uses:

Demo

https://fafruch.github.io/react-rrule-generator

Installation

npm install --save react-rrule-generator

Usage

In your CSS index file don't forget to import styles:

@import '~bootstrap/dist/css/bootstrap.css';       // this lib uses boostrap (v. 4.0.0-beta.2)
@import '~react-rrule-generator/build/styles.css'; // react-rrule-generator's custom CSS

Then you're good to go.
Just use it:

import RRuleGenerator from 'react-rrule-generator';

// render it as it is

const SimpleRender = () => (
  <RRuleGenerator onChange={(rrule) => console.log(`RRule changed, now it's ${rrule}`)} />
);


// or with your own forms configuration

import MyCustomCalendar from './MyCustomCalendar';

const CustomizedRender = () => (
  <RRuleGenerator
    onChange={(rrule) => console.log(`RRule changed, now it's ${rrule}`)}
    config={{
      repeat: ['Monthly', 'Weekly'],
      yearly: 'on the',
      monthly: 'on',
      end: ['Never', 'On date'],
      weekStartsOnSunday: true,
      hideError: true,
    }}
    customCalendar={MyCustomCalendar}
  />
);


// you can also use it as controlled input component and feed it with your own RRule!

class ControlledRender extends Component {
  state = {
    rrule: 'SOME REALLY COOL RRULE'
  };

  render() {
    return (
      <RRuleGenerator
        onChange={(rrule) => this.setState({ rrule })}
        value={this.state.rrule}
      />
    );
  }
}

API

Props

Name Type Description
onChange function REQUIRED. Callback trigger when the RRule changes. The callback receives newly generated RRule string.
value string You can pass your own RRule value to RRuleGenerator and use it like controlled input component.
config object Accepts object of what options will be rendered. This object's structure is described in #config
translations function or object Accepts a function or an object with translations for all labels in the component. By default all labels are in English. You can pass your own translation object or function, which has the following signature: (key: string, replacements: object) => string. It receives key of the label in form of 'repeat.yearly.on_the' and an object for placeholder replacements, e.g., { value: error.value }. Example translation objects are placed in /src/lib/translations/.
customCalendar React Component or stateless function This accepts custom calendar / datepicker for choosing a date in EndOnDate view. It receives following props by default:
  • 'aria-label' with value 'Datetime picker for end on date',
  • value - date value consumed by app logic,
  • dateFormat - by default 'YYYY-MM-DD',
  • locale - 'en/ca' or 'en/gb' depending on if weekStartsOnSunday in config is set to true or false

config

config is an object which accepts following:

Name Type Description
frequency array of string You can optionally choose if you want to show repeating options 'Yearly', 'Monthly', 'Weekly', 'Daily', 'Hourly'. You can pass for example ['Monthly', 'Weekly'] if you want to show only options for repeating monthly and weekly.
yearly string If 'on' provided, only choosing a particular day of a month is available, if 'on the' is provided, you have ability to choose for example 'fourth Wednesday of February'
monthly string If 'on' provided, only choosing a particular day of a month is available, if 'on the' is provided, you have ability to choose for example 'fourth Wednesday'
end array of string You can optionally choose if you want to show ending options 'Never', 'After', 'On date'. You can pass for example ['Never', 'On date'] if you want to show only options for ending never or on a particular date without showint 'After' option.
hideStart boolean If true start date form is not rendered. Default: true
hideEnd boolean If true ending form is not rendered. Default: false
hideError boolean If true error alert is not rendered. Default: false
weekStartsOnSunday boolean If set to true, weeks starts on Sunday (both for views and RRule string). Default: false

License

MIT

react-rrule-generator's People

Contributors

fafruch avatar tn3rb 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

react-rrule-generator's Issues

RRule parsing bug in current git master branch?

Hello,

I cloned the code from the current master branch of the GitHub repository because I wanted to extend the component with translatable labels for different languages. But I can't get the demo to run. I get the following error message on the demo page:

RangeError: Invalid array length
RepeatYearlyOn
src/lib/components/Repeat/Yearly/On.js:63
  60 |   disabled={!isActive}
  61 |   onChange={numericalFieldHandler(handleChange)}
  62 | >
> 63 |   {[...new Array(daysInMonth)].map((day, i) => (
  64 |     <option key={i} value={i + 1}>{i + 1}</option>
  65 |   ))}
  66 | </select>

The daysInMonth variable seems to be set to undefined because the input rrule is not parsed correctly. The latest version published on npm(1.1.1) does not seem to have this bug. I haven't found any tagged version in this repository so I'm not sure which version on npm corresponds to which revision on GitHub.

Greetings

Marcel

config.frequency option is not working

After examining the code I found that component looks for config.repeat instead of config.frequency. Maybe it makes sense to replace frequency with repeat in README.md ?

Missing files after installing with `npm install`

Hi everyone,

I've just did npm install --save react-rrule-generator.

It generates the following package.json dependency:

"react-rrule-generator": "^0.1.5",

Seems like this installation is corrupted by missing some files. After installation, in node_modules/react-rrule-generator/package.json there is: "main": "build/index.js", but the build folder is missing. This causes package is not working with webpack etc.

The temporary fix is to use the following in package.json dependencies:
"react-rrule-generator": "github:fafruch/react-rrule-generator",

Can you please look into it? I bet everyone just do npm install react-rrule-generator which is not working well.

Thanks,
Daniel

Bootstrap override

Hi,

This packages overrides my bootstrap (v3) with newer version. It corrupts all styles on my site. I think bootstrap shouldn't be included in this package (user should be able to choose by installing it manually).

Thanks,
Daniel

Component not updating when controlled

I'm using RRuleGenerator as a full controlled component within a Redux Field:

const RecurrenceInput = ({ input: { value, onChange }}) => (
  <div>
    <RRuleGenerator value={value} onChange={onChange} />
    <div>VALUE: {value}</div>
  </div>
);

Using React 16.5.1, the component initially renders correctly but then never rerenders, so clicking the interface updates the displayed value but doesn't actually update the interface.

Stepping through the code, when you change something in the interface, componentWillReceiveProps gets called with the updated value and it calls setState to store the new rrule. Then shouldComponentUpdate is called with the updated value, but it ends up comparing the new value to the ALREADY UPDATED this.state.rrule, which at that point is the same, so the function returns false and then component is never re-rendered.

As a quick workaround, I'm just removing shouldComponentUpdate entirely and marking the component as a PureComponent, but not sure if that's a valid fix...

Package size reduction, it's currently 871 KB

I was amazed to find that adding rrule generator to our library added over 850kb to the build size of our application. Considering the library folder only contains 258kb of code the overall larger size was a shock.

The vast majority of which looks to be the moment locale files. Importing moment/locale/all accounts for over 380kb (See https://github.com/moment/moment/blob/develop/min/locales.js). Moment is a popular library and is likely already included in many projects. It would make sense to give users to ability to include the localisation support they require instead of bundling them all. Perhaps moving moment to a peer dependancy would reduce the size of this library and providing documentation on how to support more locales would improve usage and reduce file size.

Feature request: hide output

Hi,

A feature request: it would be great, if there will be an option to hide the output (raw rrules).

I want to use it, as an input in my event creation form, and I don't want to show technical details (rrules) to my users (it's enough I had possibility to capture rrules in onChange event).

Thanks,
Daniel

Not able to import the <RRuleGenerator />

Hi! I'm with an error when trying to import the component into my React Project.

When I import the component and try to render it into the page, it throws an error to my component:
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in. Check the render method of 'Scheduler'.

But when I try to console.log(RRuleGenerator) it sends an empty object, instead the React Component with the proptypes and the other things.

Could you help me with that? I just installed the package and imported as in the documentation.

Thanks.

Day of week selection does not trigger RRule change on Bootstrap v4.1.3

When using this component with the Bootstrap v4.1.3 JavaScript, the day of the week selection for weekly RRules does not trigger the onChange callback. This appear to be Bootstrap's JS interfering with the btn-group surrounding the day of the week labels and checkboxes.

Removing the data-toggle="buttons" from this (disabling Bootstrap's JS) seems to work around the issue.

Cannot add multiple day for Monthly by day frequency

For example, 1st and 3rd Monday of every month.

FREQ=MONTHLY;INTERVAL=1;BYDAY=1MO,3MO

I guess I can somewhat mitigate by using every other Monday instead although that's not quite exactly the same.

Happy to create PR for this but I'll be able to get to it in a couple of week time at best.

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.