Giter VIP home page Giter VIP logo

Comments (5)

JosuerBague avatar JosuerBague commented on May 29, 2024 1

Can you provide a stackblitz link please ?

https://stackblitz.com/edit/vitejs-vite-1hvojf?file=src%2FApp.tsx

from primereact.

Rekl0w avatar Rekl0w commented on May 29, 2024

Can you provide a stackblitz link please ?

from primereact.

melloware avatar melloware commented on May 29, 2024

OK so it works for me in TypeScript here: https://stackblitz.com/edit/kd3h15?file=src%2FApp.tsx

i think the issue is the Calendar detects the value and sets the SelectionMode based on whether you pass it a single Date, a Date[] array, etc.

See here:

/**
* Defines valid properties in single Calendar component.
* @group Properties
*/
interface CalendarPropsSingle extends CalendarBaseProps {
/**
* Specifies the selection mode either "single", "range", or "multiple";
* @defaultValue single
*/
selectionMode?: 'single' | undefined;
/**
* Value of the component.
* @defaultValue null
*/
value?: Nullable<Date>;
/**
* Callback to invoke when value changes.
* @param { FormEvent<Date>} event - Custom change event
*/
onChange?(event: FormEvent<Date>): void;
}
/**
* Defines valid properties in range Calendar component.
* @group Properties
*/
interface CalendarPropsRange extends CalendarBaseProps {
/**
* Specifies the selection mode either "single", "range", or "multiple";
* @defaultValue single
*/
selectionMode: 'range';
/**
* Value of the component.
* @defaultValue null
*/
value?: Nullable<(Date | null)[]>;
/**
* Callback to invoke when value changes.
* @param { FormEvent<(Date | null)[]>} event - Custom change event
*/
onChange?(event: FormEvent<(Date | null)[]>): void;
}
/**
* Defines valid properties in multiple Calendar component.
* @group Properties
*/
interface CalendarPropsMultiple extends CalendarBaseProps {
/**
* Specifies the selection mode either "single", "range", or "multiple";
* @defaultValue single
*/
selectionMode: 'multiple';
/**
* Value of the component.
* @defaultValue null
*/
value?: Nullable<Date[]>;
/**
* Callback to invoke when value changes.
* @param {FormEvent<Date[]>} event - Custom change event
*/
onChange?(event: FormEvent<Date[]>): void;
}
/**
* Defines valid properties in Calendar component.
* @group Properties
*/
export type CalendarProps = CalendarPropsRange | CalendarPropsMultiple | CalendarPropsSingle;

from primereact.

JosuerBague avatar JosuerBague commented on May 29, 2024

OK so it works for me in TypeScript here: https://stackblitz.com/edit/kd3h15?file=src%2FApp.tsx

i think the issue is the Calendar detects the value and sets the SelectionMode based on whether you pass it a single Date, a Date[] array, etc.

See here:

/**
* Defines valid properties in single Calendar component.
* @group Properties
*/
interface CalendarPropsSingle extends CalendarBaseProps {
/**
* Specifies the selection mode either "single", "range", or "multiple";
* @defaultValue single
*/
selectionMode?: 'single' | undefined;
/**
* Value of the component.
* @defaultValue null
*/
value?: Nullable<Date>;
/**
* Callback to invoke when value changes.
* @param { FormEvent<Date>} event - Custom change event
*/
onChange?(event: FormEvent<Date>): void;
}
/**
* Defines valid properties in range Calendar component.
* @group Properties
*/
interface CalendarPropsRange extends CalendarBaseProps {
/**
* Specifies the selection mode either "single", "range", or "multiple";
* @defaultValue single
*/
selectionMode: 'range';
/**
* Value of the component.
* @defaultValue null
*/
value?: Nullable<(Date | null)[]>;
/**
* Callback to invoke when value changes.
* @param { FormEvent<(Date | null)[]>} event - Custom change event
*/
onChange?(event: FormEvent<(Date | null)[]>): void;
}
/**
* Defines valid properties in multiple Calendar component.
* @group Properties
*/
interface CalendarPropsMultiple extends CalendarBaseProps {
/**
* Specifies the selection mode either "single", "range", or "multiple";
* @defaultValue single
*/
selectionMode: 'multiple';
/**
* Value of the component.
* @defaultValue null
*/
value?: Nullable<Date[]>;
/**
* Callback to invoke when value changes.
* @param {FormEvent<Date[]>} event - Custom change event
*/
onChange?(event: FormEvent<Date[]>): void;
}
/**
* Defines valid properties in Calendar component.
* @group Properties
*/
export type CalendarProps = CalendarPropsRange | CalendarPropsMultiple | CalendarPropsSingle;

The issue starts when I try to wrap the Calendar with a wrapping component.
https://stackblitz.com/edit/kd3h15-yfszte?file=src%2FApp.tsx

I tried, passing it a value and an onChange to see if it works, but the typing error still persists. Strange behavour, in theory it should work the same whether the component gets wrapper or not, right?

from primereact.

melloware avatar melloware commented on May 29, 2024

It should it might be some TypeScript weirdness or magic that I don't know.

from primereact.

Related Issues (20)

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.