1.1.11 • Published 5 months ago

calendar-input-r v1.1.11

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
5 months ago

calendar-input-r

📝 Description

CalendarInput is a customizable React component for date selection. It offers an intuitive interface with an input field and a pop-up calendar, allowing users to easily select dates.

✨ Features

  • 📅 Interactive pop-up calendar
  • 🚫 Support for disabled dates
  • 📌 Disabling specific days of the week
  • 🔤 Customizable labels for days of the week
  • 🎨 Highly customizable through styles
  • ⬅️ Navigation between months
  • 🌐 Support for internationalization of days of the week

🛠️ Technologies Used

  • React
  • TypeScript
  • CSS

📦 Installation

npm i calendar-input-r
# or
yarn add calendar-input-r

Usage

To use the CalendarInput, simply import it and pass the desired properties. Example:

import { useState } from "react";
import CalendarInput from "calendar-input-r";

const App = () => {
  const [selectedDate, setSelectedDate] = useState(null);

  const handleDateChange = (date) => {
    console.log("Date changed:", date);
    setSelectedDate(date);
  };

  const handleDateSelect = (date) => {
    console.log("Date selected:", date);
    setSelectedDate(date);
  };

  return (
    <div>
      <CalendarInput
        selectedDate={selectedDate}
        placeholder="Select a date"
        onChange={handleDateChange}
        onSelect={handleDateSelect}
      />
    </div>
  );
};
import { useState } from "react";
import CalendarInput from "calendar-input-r";

function App() {
  const [selectedDate, setSelectedDate] = useState<Date | null>(null);

  const handleDateChange = (date: Date | null) => {
    console.log("Date changed:", date);
    setSelectedDate(date);
  };

  const handleDateSelect = (date: Date) => {
    console.log("Date selected:", date);
    setSelectedDate(date);
  };

  return (
    <CalendarInput
      selectedDate={selectedDate}
      placeholder="Select a date"
      disabledDates={[new Date(2024, 2, 25)]}
      disabledWeekDays={["Saturday", "Sunday"]}
      onChange={handleDateChange}
      onSelect={handleDateSelect}
      daysCustomLabels={{
        sunday: "Sunday",
        monday: "Monday",
        tuesday: "Tuesday",
        wednesday: "Wednesday",
        thursday: "Thursday",
        friday: "Friday",
        saturday: "Saturday",
      }}
      leftButtonLabel="❮"
      rightButtonLabel="❯"
    />
  );
}

📋 Props

PropTypeRequiredDescription
selectedDateDate \| nullYesThe currently selected date. Can be null if no date is selected.
placeholderstringNoPlaceholder text for the input
disabledDatesDate[]NoArray of dates to be disabled
disabledWeekDaysstring[]NoArray of names of days of the week to be disabled
onChange(date: Date \| null) => voidNoFunction called when the date changes. Receives the new selected date
or null if no date is selected.
onSelect(date: Date) => voidNoFunction called when a date is selected. Receives the selected date.
daysCustomLabelsobjectNoObject with custom labels for days of the week
leftButtonLabelstringNoText of the previous month button
rightButtonLabelstringNoText of the next month button

Style Properties

PropTypeDescription
containerStyleReact.CSSPropertiesStyle of the main container
inputContainerStyleReact.CSSPropertiesStyle of the input container
inputStyleReact.CSSPropertiesStyle of the input field
calendarStyleReact.CSSPropertiesStyle of the calendar
headerStyleReact.CSSPropertiesStyle of the calendar header
tittleStyleReact.CSSPropertiesStyle of the calendar title
buttonsStyleReact.CSSPropertiesStyle of the navigation buttons

🎨 Style Customization

The component can be styled through style props or by overriding CSS classes:

.calendar { / Calendar styles / }
.day { / Day styles / }
.day.selected { / Selected day styles / }
.day.disabled { / Disabled day styles / }
.day-name { / Day name styles / }

🇧🇷 Versão em Português

O componente CalendarInput é um componente React customizável para seleção de datas. Ele oferece uma interface intuitiva com um campo de entrada e um calendário pop-up, permitindo aos usuários selecionar datas facilmente.

✨ Funcionalidades

  • 📅 Calendário pop-up interativo
  • 🚫 Suporte para datas desabilitadas
  • 📌 Desabilitação de dias específicos da semana
  • 🔤 Rótulos personalizáveis para dias da semana
  • 🎨 Altamente customizável através de estilos
  • ⬅️ Navegação entre meses
  • 🌐 Suporte para internacionalização dos dias da semana

🛠️ Tecnologias Utilizadas

  • React
  • TypeScript
  • CSS

📦 Instalação

npm i calendar-input-r
# ou
yarn add calendar-input-r

Uso

Para usar o CalendarInput, basta importá-lo e passar as propriedades desejadas. Exemplo:

import { useState } from "react";
import CalendarInput from "calendar-input-r";

const App = () => {
  const [selectedDate, setSelectedDate] = useState(null);

  const handleDateChange = (date) => {
    console.log("Data mudou:", date);
    setSelectedDate(date);
  };

  const handleDateSelect = (date) => {
    console.log("Data selecionada:", date);
    setSelectedDate(date);
  };

  return (
    <div>
      <CalendarInput
        selectedDate={selectedDate}
        placeholder="Selecione uma data"
        onChange={handleDateChange}
        onSelect={handleDateSelect}
      />
    </div>
  );
};
import { useState } from "react";
import CalendarInput from "calendar-input-r";

function App() {
  const [selectedDate, setSelectedDate] = useState<Date | null>(null);

  const handleDateChange = (date: Date | null) => {
    console.log("Date changed:", date);
    setSelectedDate(date);
  };

  const handleDateSelect = (date: Date) => {
    console.log("Date selected:", date);
    setSelectedDate(date);
  };

  return (
    <CalendarInput
      selectedDate={selectedDate}
      placeholder="Selecione uma data"
      disabledDates={[new Date(2024, 2, 25)]}
      disabledWeekDays={["Saturday", "Sunday"]}
      onChange={handleDateChange}
      onSelect={handleDateSelect}
      daysCustomLabels={{
        sunday: "Domingo",
        monday: "Segunda",
        tuesday: "Terça",
        wednesday: "Quarta",
        thursday: "Quinta",
        friday: "Sexta",
        saturday: "Sábado",
      }}
      leftButtonLabel="❮"
      rightButtonLabel="❯"
    />
  );
}

📋 Props

PropTypeObrigatórioDescrição
selectedDateDate \| nullSimA data selecionada atualmente. Pode ser nula se nenhuma data estiver
selecionada.
placeholderstringNãoTexto de espaço reservado para o input
disabledDatesDate[]NãoArray de datas que devem ser desabilitadas
disabledWeekDaysstring[]NãoArray com nomes dos dias da semana a serem desabilitados
onChange(date: Date \| null) => voidNãoFunção chamada quando a data muda. Recebe a nova data selecionada ou
null se nenhuma data estiver selecionada.
onSelect(date: Date) => voidNãoFunção chamada quando uma data é selecionada. Recebe a data
selecionada.
daysCustomLabelsobjectNãoObjeto com rótulos personalizados para os dias da semana
leftButtonLabelstringNãoTexto do botão de mês anterior
rightButtonLabelstringNãoTexto do botão de próximo mês

Propriedades de Estilo

PropTipoDescrição
containerStyleReact.CSSPropertiesEstilo do container principal
inputContainerStyleReact.CSSPropertiesEstilo do container do input
inputStyleReact.CSSPropertiesEstilo do campo de input
calendarStyleReact.CSSPropertiesEstilo do calendário
headerStyleReact.CSSPropertiesEstilo do cabeçalho do calendário
tittleStyleReact.CSSPropertiesEstilo do título do calendário
buttonsStyleReact.CSSPropertiesEstilo dos botões de navegação

🎨 Personalização de Estilos

O componente pode ser estilizado através das props de estilo ou sobrescrevendo as classes CSS:

.calendar { / Estilos do calendário / }
.day { / Estilos dos dias / }
.day.selected { / Estilos do dia selecionado / }
.day.disabled { / Estilos dos dias desabilitados / }
.day-name { / Estilos dos nomes dos dias / }
1.1.9

5 months ago

1.1.11

5 months ago

1.1.8

6 months ago

1.1.7

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.1.6

6 months ago

1.0.7

6 months ago

1.1.5

6 months ago

1.0.6

6 months ago

1.1.4

6 months ago

1.1.3

6 months ago

1.1.2

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago