How to use bpk-component-calendar - 10 common examples

To help you get started, we’ve selected a few bpk-component-calendar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Skyscanner / backpack / packages / bpk-component-scrollable-calendar / stories.js View on Github external
.add('Scrollable Calendar - with focused date', () => (
    
  ))
  .add('Scrollable Calendar in a tall container', () => (
github Skyscanner / backpack / packages / bpk-component-scrollable-calendar / src / BpkScrollableCalendarGridList.js View on Github external
constructor(props) {
    super(props);

    this.outerDiv = null;

    const startDate = startOfDay(startOfMonth(this.props.minDate));
    const endDate = startOfDay(startOfMonth(this.props.maxDate));
    const monthsCount = DateUtils.differenceInCalendarMonths(
      endDate,
      startDate,
    );
    const months = getMonthsArray(startDate, monthsCount);
    // Here we calculate the height of each calendar grid item in pixels, as the `react-window` API
    // requires that these are provided so that they can be efficiently rendered.
    const monthItemHeights = months.map(month => {
      const firstDayOffset = (month.getDay() + 7 - props.weekStartsOn) % 7;
      const monthLength = DateUtils.daysInMonth(
        month.getYear(),
        month.getMonth(),
      );
      const calendarGridSpaces = firstDayOffset + monthLength;
      const rowCount = Math.ceil(calendarGridSpaces / COLUMN_COUNT);
      return BASE_MONTH_ITEM_HEIGHT + ROW_HEIGHT * rowCount;
    });
github Skyscanner / backpack / packages / bpk-component-scrollable-calendar / src / BpkScrollableCalendar.js View on Github external
* See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* @flow strict */

import {
  BpkCalendarGridHeader,
  withCalendarState,
  composeCalendar,
} from 'bpk-component-calendar';

import BpkscrollableCalendarDate from './BpkScrollableCalendarDate';
import BpkScrollableCalendarGridList from './BpkScrollableCalendarGridList';

export default withCalendarState(
  composeCalendar(
    null,
    BpkCalendarGridHeader,
    BpkScrollableCalendarGridList,
    BpkscrollableCalendarDate,
  ),
);
github Skyscanner / backpack / packages / bpk-component-scrollable-calendar / src / BpkScrollableCalendar.js View on Github external
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* @flow strict */

import {
  BpkCalendarGridHeader,
  withCalendarState,
  composeCalendar,
} from 'bpk-component-calendar';

import BpkscrollableCalendarDate from './BpkScrollableCalendarDate';
import BpkScrollableCalendarGridList from './BpkScrollableCalendarGridList';

export default withCalendarState(
  composeCalendar(
    null,
    BpkCalendarGridHeader,
    BpkScrollableCalendarGridList,
    BpkscrollableCalendarDate,
  ),
);
github Skyscanner / backpack / packages / bpk-component-datepicker / src / BpkDatepicker.js View on Github external
BpkDatepicker.propTypes = {
  // Required
  changeMonthLabel: PropTypes.string.isRequired,
  closeButtonText: PropTypes.string.isRequired,
  daysOfWeek: CustomPropTypes.DaysOfWeek.isRequired,
  formatDate: PropTypes.func.isRequired,
  formatDateFull: PropTypes.func.isRequired,
  formatMonth: PropTypes.func.isRequired,
  id: PropTypes.string.isRequired,
  title: PropTypes.string.isRequired,
  getApplicationElement: PropTypes.func.isRequired,
  weekStartsOn: PropTypes.number.isRequired,
  // Optional
  calendarComponent: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
  date: PropTypes.instanceOf(Date),
  dateModifiers: CustomPropTypes.DateModifiers,
  inputProps: PropTypes.object, // eslint-disable-line react/forbid-prop-types
  markOutsideDays: PropTypes.bool,
  markToday: PropTypes.bool,
  maxDate: PropTypes.instanceOf(Date),
  minDate: PropTypes.instanceOf(Date),
  onDateSelect: PropTypes.func,
  onMonthChange: PropTypes.func,
  showWeekendSeparator: PropTypes.bool,
  initiallyFocusedDate: PropTypes.instanceOf(Date),
  renderTarget: PropTypes.func,
  isOpen: PropTypes.bool,
};

BpkDatepicker.defaultProps = {
  calendarComponent: BpkCalendar,
  date: null,
github Skyscanner / backpack / packages / bpk-component-datepicker / src / BpkDatepicker.js View on Github external
{...rest}
            >
              {calendar}
            
          )
        }
      
    );
  }
}

BpkDatepicker.propTypes = {
  // Required
  changeMonthLabel: PropTypes.string.isRequired,
  closeButtonText: PropTypes.string.isRequired,
  daysOfWeek: CustomPropTypes.DaysOfWeek.isRequired,
  formatDate: PropTypes.func.isRequired,
  formatDateFull: PropTypes.func.isRequired,
  formatMonth: PropTypes.func.isRequired,
  id: PropTypes.string.isRequired,
  title: PropTypes.string.isRequired,
  getApplicationElement: PropTypes.func.isRequired,
  weekStartsOn: PropTypes.number.isRequired,
  // Optional
  calendarComponent: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
  date: PropTypes.instanceOf(Date),
  dateModifiers: CustomPropTypes.DateModifiers,
  inputProps: PropTypes.object, // eslint-disable-line react/forbid-prop-types
  markOutsideDays: PropTypes.bool,
  markToday: PropTypes.bool,
  maxDate: PropTypes.instanceOf(Date),
  minDate: PropTypes.instanceOf(Date),
github Skyscanner / backpack / packages / bpk-component-scrollable-calendar / src / utils.js View on Github external
const getMonthsArray = (startDate, count) => {
  const months = [];

  for (let i = 0; i < count + 1; i += 1) {
    months.push(DateUtils.addMonths(startDate, i));
  }

  return months;
};
export default getMonthsArray;
github Skyscanner / backpack / packages / bpk-docs / src / pages / WebScrollableCalendarPage / WebScrollableCalendarPage.js View on Github external
],
  },
  {
    id: 'localised',
    title: 'Localised scrollable calendar',
    examples: [
      ,
    ],
  },
  {
    id: 'grid',
    title: 'Scrollable calendar grid',
    examples: [
github Skyscanner / backpack / packages / bpk-component-datepicker / stories.js View on Github external
constructor() {
    super();

    this.minDate = startOfDay(new Date());
    this.maxDate = startOfDay(addMonths(new Date(), 12));
    this.state = {
      departDate: startOfDay(addDays(new Date(), 1)),
      returnDate: startOfDay(addDays(new Date(), 4)),
    };
  }