npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-scheduler-br

v0.1.12

Published

<div align="center"> <p align="center"> ✨ Brazilian version of @bitnoise/react-scheduler package.✨

Downloads

88

Readme

Installation

# yarn
yarn add react-scheduler-br
# npm
npm i react-scheduler-br

Example usage

  1. import required styles for scheduler
import "react-scheduler-br/dist/style.css";
  1. Import Scheduler component into your project
"use client";
import SchedulerClient from "@/components/myScheduler";
import { Button, Flex } from "@chakra-ui/react";
import dayjs from "dayjs";
import isBetween from "dayjs/plugin/isBetween";
import { useCallback, useMemo, useState } from "react";
import { SchedulerData } from "react-scheduler-br";
export type ParsedDatesRange = {
    startDate: Date;
    endDate: Date;
};
type SchedulerProjectData = {
    /**
     * Unique Id of item
     */
    id: string;
    /**
     * Represents start date of from which tile will render
     */
    startDate: Date;
    /**
     * Represents end date to which tile will render
     */
    endDate: Date;
    /**
     * Indicates how much time is spent per day. Given in seconds and converted by Scheduler to hours/minutes
     */
    occupancy: number;
    /**
     * Title of item
     */
    title: string;
    /**
     * Subtitle of item. Optional
     */
    subtitle?: string;
    /**
     * Short description displayed on tile. Optional
     */
    description?: string;
    /**
     * Background color of the tile, given in rgb color model. If not given, default color (rgb(114, 141,226 )) is set. Optional
     */
    bgColor?: string;
};
export default function App() {
    const [isLoading, setIsLoading] = useState(false);
    const [range, setRange] = useState<ParsedDatesRange>({
        startDate: new Date(),
        endDate: new Date(),
    });
    dayjs.extend(isBetween);

    const filteredData = useMemo(
        () =>
            data.map((person) => ({
                ...person,
                data: person.data.filter(
                    (project) =>
                        dayjs(project.startDate).isBetween(
                            range.startDate,
                            range.endDate
                        ) ||
                        dayjs(project.endDate).isBetween(
                            range.startDate,
                            range.endDate
                        ) ||
                        (dayjs(project.startDate).isBefore(
                            range.startDate,
                            "day"
                        ) &&
                            dayjs(project.endDate).isAfter(
                                range.endDate,
                                "day"
                            ))
                ),
            })),
        [range.endDate, range.startDate]
    );
    const handleFilterData = () => console.log(`Filters button was clicked.`);

    const handleTileClick = (data: SchedulerProjectData) =>
        console.log(
            `Item ${data.title} - ${data.subtitle} was clicked. \n==============\nStart date: ${data.startDate} \n==============\nEnd date: ${data.endDate}\n==============\nOccupancy: ${data.occupancy}`
        );

    const handleRangeChange = useCallback((range: ParsedDatesRange) => {
        setRange(range);
    }, []);
    return (
        <Flex position={"relative"} w="full">
            <SchedulerClient
                onItemClick={(item) => console.log(item)}
                onRangeChange={handleRangeChange}
                data={filteredData}
                isLoading={isLoading}
                onTileClick={handleTileClick}
                onFilterData={handleFilterData}
                config={{
                    zoom: 0,
                    filterButtonState: -1,
                    maxRecordsPerPage: 10,
                    lang: "pt",
                }}
                tooltipChildren={
                    <Flex w="150px">
                        <Button>Botão</Button>
                    </Flex>
                }
            />
        </Flex>
    );
}
const data: SchedulerData = [
    {
        id: "070ac5b5-8369-4cd2-8ba2-0a209130cc60",
        label: {
            icon: "https://picsum.photos/24",
            title: "Joe Doe",
            subtitle: "Frontend Developer",
        },
        data: [
            {
                id: "8b71as8a5-33dd-4fc8-9caa-b4a584ba3762",
                startDate: new Date("2024-01-07T08:16:31.123Z"),
                endDate: new Date("2024-02-26T10:28:22.649Z"),
                occupancy: 100,
                title: "Project A",
                subtitle: "Subtitle A",
                description: "array indexing Salad West Account",
                bgColor: "rgb(136, 5, 22)",
            },
            {
                id: "22fbe2s37-6344-4c8e-affb-64a1750f33bd",
                startDate: new Date("2024-01-07T08:16:31.123Z"),
                endDate: new Date("2024-03-15T21:55:23.582Z"),
                occupancy: 1,
                title: "Project B",
                subtitle: "Subtitle B",
                description: "Tuna Home pascal IP drive",
                bgColor: "rgb(165, 171, 254)",
            },
            {
                id: "3601c1scd-f4b5-46bc-8564-8c983919e3f5",
                startDate: new Date("2024-01-28T10:08:22.986Z"),
                endDate: new Date("2024-02-01T07:20:50.526Z"),
                occupancy: 1800,
                title: "Project C",
                subtitle: "Subtitle C",
                bgColor: "rgb(254,165,177)",
            },
            {
                id: "b088es4ac-9911-426f-aef3-843d75e714c2",
                startDate: new Date("2024-01-28T10:08:22.986Z"),
                endDate: new Date("2024-06-30T12:30:30.150Z"),
                occupancy: 11111,
                title: "Project D",
                subtitle: "Subtitle D",
                description: "Garden heavy an software Metal",
                bgColor: "rgb(233, 79, 99)",
            },
        ],
    },
];

  1. If some problems occur, please see our troubleshooting section below.

Scheduler API

Scheduler Component Props

| Property Name | Type | Arguments | Description | | ----------------- | ---------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | isLoading | boolean | - | shows loading indicators on scheduler | | onRangeChange | function | updated startDate and endDate | runs whenever user reaches end of currently rendered canvas | | onTileClick | function | clicked resource data | detects resource click | | onItemClick | function | clicked left column item data | detects item click on left column | | onFilterData | function | - | callback firing when filter button was clicked | | onClearFilterData | function | - | callback firing when clear filters button was clicked (clearing button is visible only when filterButtonState is set to >0) | | config | Config | - | object with scheduler config properties | | tooltipChildren | ReactNode | undefined | adds a custom tooltip |

Scheduler Config Object

| Property Name | Type | Default | Description | | ------------------------------------ | ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | zoom | 0 or 1 | 0 | 0 - display grid divided into weeks 1 - display grid divided into days | | filterButtonState | number | 0 | < 0 - hides filter button, 0 - state for when filters were not set, > 0 - state for when some filters were set (allows to also handle onClearFilterData event) | | maxRecordsPerPage | number | 50 | number of items from SchedulerData visible per page | | lang | en, pl, fr or pt | en | scheduler's language | | includeTakenHoursOnWeekendsInDayView | boolean | false | show weekends as taken when given resource is longer than a week |

Scheduler Data

array of chart rows with shape of | Property Name | Type | Description | | -------- | --------------------- | -------------------------------- | | id | string | unique row id | | label | string | row's label, e.g person's name | | data | Array<ResourceItem> | array of resources |

Left Colum Item Data

data that is accessible as argument of onItemClick callback | Property Name | Type | Description | | -------- | --------------------- | -------------------------------- | | id | string | unique row id | | label | string | row's label, e.g person's name |

Resource Item

item that will be visible on the grid as tile and that will be accessible as argument of onTileClick event | Property Name | Type | Description | | ----------- | ----------------- | ------------------------------------------------------------------------------------------------------- | | id | string | unique resource id | | title | string | resource title that will be displayed on resource tile | | subtitle | string (optional) | resource subtitle that will be displayed on resource tile | | description | string (optional) | resource description that will be displayed on resource tile | | startDate | Date | date for calculating start position for resource | | endDate | Date | date for calculating end position for resource | | occupancy | number | number of seconds resource takes up for given row that will be visible on resource tooltip when hovered | | bgColor | string (optional) | tile color |

Troubleshooting

  • For using Scheduler with RemixJS make sure to add react-scheduler-br to serverDependenciesToBundle in remix.config.js like so:
// remix.config.js
/** @type  {import('@remix-run/dev').AppConfig} */
module.exports = {
	// ...
	serverDependenciesToBundle: [..., "react-scheduler-br"],
};
  • When using with NextJS (app router) Scheduler needs to be wrapped with component with use client
"use client"
import { Scheduler, SchedulerProps } from "react-scheduler-br";

default export function SchedulerClient(props: SchedulerProps) {
	return <Scheduler {...props} />;
}
  • When using with NextJS (pages router) it needs to be imported using dynamic:
import dynamic from "next/dynamic";
const Scheduler = dynamic(() => import("react-scheduler-br").then((mod) => mod.Scheduler), {
  ssr: false
});

Known Issues

  1. No responsiveness
  2. Slower performance on Firefox when working with big set of data due to Firefox being slower working with canvas

How to contribute

  • Reporting Issues: If you come across any bugs, glitches, or have any suggestions for improvements, please open an issue on our GitHub repository. Provide as much detail as possible, including steps to reproduce the issue.
  • Suggesting Enhancements: If you have ideas for new features or enhancements, we would love to hear them! You can open an issue on our GitHub repository and clearly describe your suggestion.
  • Submitting Pull Requests: If you have developed a fix or a new feature that you would like to contribute, you can submit a pull request. Here's a quick overview of the process:
    • Clone the repository and create your own branch: git checkout -b feat/your-branch-name.
    • Implement your changes, following the code style and guidelines from development.md.
    • Test your changes to ensure they work as expected.
    • Commit your changes and push to your forked repository.
    • Open a pull request against our main repository's master branch.
      • add at least 1 reviewer
      • link correct issue

Contact

If you have any questions or need further assistance, feel free to reach out to us at [email protected]. We appreciate your contributions and thank you for helping us improve this project!

License

MIT Licensed. Copyright (c) Bitnoise 2023.