pglejzer / timepicker-ui

timepicker-ui is an easy library with timepicker. Fully wrote with TypeScript. This library is based on Material Design from Google.
MIT License
64 stars 19 forks source link

Can't add multiple disabledTime Intervals ? #44

Open saeed-sikandar opened 1 year ago

saeed-sikandar commented 1 year ago

I want to disabled multiple time slots like

'09:00 AM - 09:30 AM' , '10:00 AM - 10:30 AM' like I want to disable above to time slots from 9 am to 9 30 am and 10 am to 10 30 am , and like above I have just 2 time slots but can have multiple slots how do I add multiple disabledTime intervals as it's the string below is my code


import { TimepickerUI } from "timepicker-ui";

const basic = document.querySelector(".basic");
const options = {
    // currentTime: {
    //     updateInput: true,
    //     locales: "en-US",
    //     preventClockType: false
    // },
    clockType: "12h",
    theme: "basic",
    incrementMinutes: 15,
    disabledTime: {
        interval: '10:00 AM - 10:30 AM',
        interval: '10:00 AM - 10:30 AM',
    },

    // mobile: true,
};
const basicPicker = new TimepickerUI(basic, options);
basicPicker.create();
pglejzer commented 1 year ago

Hello, thank you for you topic, I think it's a bug with these intervals. I will try to fix this and probably I will change logic of properties about that. These intervals strings are not intuitive.

saeed-sikandar commented 1 year ago

Ohh thanks then and let me tell you I also tried another way but then, The first time interval 09:00 AM - 09:30 AM was ignored and it disabled the last time interval from 10:00 AM - 10:30 AM

Just to inform you ....


import { TimepickerUI } from "timepicker-ui";

const basic = document.querySelector(".basic");
const options = {

    clockType: "12h",
    theme: "basic",
    incrementMinutes: 15,
    disabledTime: {
        interval: '09:00 AM - 09:30 AM,10:00 AM - 10:30 AM ',
    },

};
const basicPicker = new TimepickerUI(basic, options);
basicPicker.create();
AustinLinares commented 1 year ago

Good afternoon @pglejzer, I saw that a future feature is "max/min time options" but maybe You could allow an array of strings(formatted as you mention in the readme file) as "interval" value. So We can add as many intervals as we need and that also works as max and min values. Also, is there a way of work with this project locally? If it is, I'll appreciate the info.