loon-bulma-react 2022.1.5 → 2022.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,6 +19,8 @@
19
19
  - [Section](#layout-section)
20
20
  - [ScrollArea](#layout-scrollarea)
21
21
  - [Button & ButtonGroup](#component-button)
22
+ - [Calendar](#components-calendar)
23
+ - [MonthView](#components-calendar-monthview)
22
24
  - [DataTable](#component-datatable)
23
25
  - [Footer](#component-footer)
24
26
  - [Icons (FontAwesome)](#component-icons)
@@ -458,6 +460,81 @@ import { ButtonGroup, Bttn, Button, LightButton, InvertedButton, OutlinedButton
458
460
  </ButtonGroup>;
459
461
  ```
460
462
 
463
+ ### Calendar <a id="components-calendar"></a>
464
+
465
+ De Calendar Component toont events in een grid-view. Er zijn 2 verschillende soorten events:
466
+
467
+ - Events met een start-tijd
468
+ - Events zonder starttijd of met allday = true
469
+
470
+ Events hebben het onderstaande type nodig. Daarvan zijn `id`, `title`, `startDateTime` de 3 verplichte properties, de rest is optioneel. De `evtColor` en de `txtColor` hebben de default waarden resp `#ee8000` en `#ffffff`. Voor deze waarden kunnen alleen hex-waarden worden gebruikt.
471
+
472
+ ```ts
473
+ export type BaseEventProps = {
474
+ id: number | string | (() => number | string);
475
+ title: string | (() => string);
476
+ startDateTime: Date;
477
+ endDateTime?: Date;
478
+ allDay?: boolean;
479
+ description?: string | (() => string);
480
+ evtColor?: string | (() => string);
481
+ txtColor?: string | (() => string);
482
+ };
483
+ ```
484
+
485
+ Op dit moment is er alleen nog een `MonthView`-component.
486
+
487
+ De opties voor het instellen van de calendar zijn:
488
+
489
+ ```ts
490
+ export type CalendarOptions<T> = {
491
+ dayNames?: string[]; // default = [Ma Di Wo Do Vr Za Zo]
492
+ monthNames?: string[]; // default = [Jan Feb Mrt Apr Mei Jun Jul Aug Sep Okt Nov Dec]
493
+ visibleDays?: Set<number>; // default = 1,2,3,4,5,6,7 (ma = 1, di = 2,... zo = 7)
494
+ event?: {
495
+ allday?: {
496
+ evtColor?: string | ((e: T) => string); // default = #ee8000dd (with alpha dd)
497
+ evtHoverColor?: string | ((e: T) => string); // #defaul = #ee8000ff (with alpha ff)
498
+ txtColor?: string | ((e: T) => string); // default = #555555
499
+ txtHoverColor?: string | ((e: T) => string); // default = #555555
500
+ };
501
+ timed?: {
502
+ evtColor?: string | ((e: T) => string); // default = #ee8000dd (with alpha dd)
503
+ evtHoverColor?: string | ((e: T) => string); // #defaul = #ee8000ff (with alpha ff)
504
+ txtColor?: string | ((e: T) => string); // default = #555555
505
+ txtHoverColor?: string | ((e: T) => string); // default = #555555
506
+ };
507
+ };
508
+ today?: {
509
+ bgColor?: string | ((d?: Date) => string); // default = #2f47bc
510
+ bgHoverColor?: string | ((d?: Date) => string); // default = #3b59ec
511
+ txtColor?: string | ((d?: Date) => string); // default #ffffff
512
+ txtHoverColor?: string | ((d?: Date) => string); // default = #ffffff
513
+ doNotMarkToday: boolean; // default = false
514
+ };
515
+ };
516
+ ```
517
+
518
+ ##### MonthView <a id="components-calendar-monthview"></a>
519
+
520
+ Deze component toont een maand + de rest van de weken die maar deels in een maand zitten. De maand wordt getoond in een grid-view.
521
+
522
+ - `events`: een array met events.
523
+ - `viewDate`: de datum waarop de maand wordt getoond.
524
+ - `options`: optional settings voor de maand .
525
+ - `onEventClick()`: callback die wordt aangeroepen als er op een event wordt geklikt.
526
+ - `onDayClick()`: callback die wordt aangeroepen als er op een dag-datum wordt geklikt.
527
+
528
+ ```tsx
529
+ <Calendar.MonthView
530
+ events={events}
531
+ viewDate={viewDate}
532
+ options={options}
533
+ onEventClick={(evt, clck) => console.log(evt, clck)}
534
+ onDayClick={(evt, clck) => console.log(evt, clck)}
535
+ />
536
+ ```
537
+
461
538
  ### DataTable <a id="component-datatable"></a>
462
539
 
463
540
  Een DataTable is een tabel met een maximaal aantal rijen waarin je kan zoeken en sorteren. Voor een gewone, saaie, normale tabel kan je de [Table](#component-table) gebruiken. Voor re-renderen van de tabel moet de `data`-prop wel state zijn, anders werkt het rerenderen niet. Hetzelfde geld voor de `columns`-prop.
@@ -0,0 +1,16 @@
1
+ import { MouseEvent } from 'react';
2
+ import { BaseEventProps } from '..';
3
+ import { EventOptions } from '../Props';
4
+ /**
5
+ * Component voor een event dat de hele dag duurt
6
+ * @param props
7
+ * @returns
8
+ */
9
+ export declare function AlldayEvent<T extends BaseEventProps>(props: {
10
+ /** het event */
11
+ event: T;
12
+ /** opties voor events */
13
+ options?: EventOptions<T>;
14
+ /** onclick handler voor het event */
15
+ onClick?: (event: T, clickEvent: MouseEvent<HTMLElement>) => void;
16
+ }): JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { MouseEvent } from 'react';
2
+ import { BaseEventProps } from '..';
3
+ import { EventOptions } from '../Props';
4
+ /**
5
+ * expandable events als er meer dan 5 events op een dag vallen
6
+ * @param props
7
+ * @returns
8
+ */
9
+ export declare function MoreEventsView<T extends BaseEventProps>(props: {
10
+ /** de events op deze dag */
11
+ events: T[];
12
+ /** event-click handling */
13
+ onEventClick?: (event: T, clickEvent: MouseEvent<HTMLElement>) => void;
14
+ /** global event options */
15
+ options?: {
16
+ allday?: EventOptions<T>;
17
+ timed?: EventOptions<T>;
18
+ };
19
+ }): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { MouseEvent } from 'react';
2
+ import { BaseEventProps } from '..';
3
+ import { EventOptions } from '../Props';
4
+ /**
5
+ * Component voor een event met een tijdstip en NIET de hele dag duurt
6
+ * @param props
7
+ * @returns
8
+ */
9
+ export declare function TimedEvent<T extends BaseEventProps>(props: {
10
+ /** het event */
11
+ event: T;
12
+ /** opties voor events */
13
+ options?: EventOptions<T>;
14
+ /** onclick handler */
15
+ onClick?: (event: T, clickEvent: MouseEvent<HTMLElement>) => void;
16
+ }): JSX.Element;
@@ -0,0 +1,13 @@
1
+ /** default style van events */
2
+ export declare const baseEventStyles: {
3
+ transition: string;
4
+ fontSize: string;
5
+ height: string;
6
+ margin: string;
7
+ borderRadius: string;
8
+ textAlign: string;
9
+ paddingLeft: string;
10
+ paddingRight: string;
11
+ overflow: string;
12
+ textOverflow: string;
13
+ };
@@ -0,0 +1,20 @@
1
+ import { BaseEventProps } from "../Props";
2
+ /** default style van events */
3
+ export declare const baseEventStyles: {
4
+ transition: string;
5
+ fontSize: string;
6
+ height: string;
7
+ margin: string;
8
+ borderRadius: string;
9
+ textAlign: string;
10
+ paddingLeft: string;
11
+ paddingRight: string;
12
+ overflow: string;
13
+ textOverflow: string;
14
+ };
15
+ /**
16
+ * Maak een tooltip aan bij dit event als er nog geen tooltip is.
17
+ * @param event het event
18
+ * @returns de tooltip-string
19
+ */
20
+ export declare function createTooltip<T extends BaseEventProps>(event: T): string;
@@ -0,0 +1,8 @@
1
+ export declare type BaseEventProps = {
2
+ id: number | string | (() => number | string);
3
+ title: string | (() => string);
4
+ startDateTime: Date;
5
+ endDateTime?: Date | (() => Date);
6
+ description?: string | (() => string);
7
+ bgColor?: string | (() => string);
8
+ };
@@ -0,0 +1,20 @@
1
+ import { MouseEvent } from 'react';
2
+ import { BaseEventProps, CalendarOptions } from '../Props';
3
+ export declare type MonthViewProps<T> = {
4
+ /** events voor deze view */
5
+ events: T[] | (() => T[]);
6
+ /** opties voor deze view */
7
+ options?: CalendarOptions<T>;
8
+ /** event aangeklikt */
9
+ onEventClick?: (e: T, event: MouseEvent<HTMLElement>) => void;
10
+ /** dag-datum geklikt? */
11
+ onDayClick?: (date: Date, event: MouseEvent<HTMLElement>) => void;
12
+ /** huidige geselecteerde datum */
13
+ viewDate: Date;
14
+ };
15
+ /**
16
+ * maak een maand-view (grid) met events
17
+ * @param props
18
+ * @returns
19
+ */
20
+ export declare function MonthView<T extends BaseEventProps>(props: MonthViewProps<T>): JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { MouseEvent } from 'react';
2
+ import { BaseEventProps } from '..';
3
+ import { CalendarOptions } from '../Props';
4
+ /**
5
+ * Component voor de dag-container in de maand-view
6
+ * @param props
7
+ * @returns
8
+ */
9
+ export declare function DayContainer<T extends BaseEventProps>(props: {
10
+ /** events op deze dag */
11
+ events: T[];
12
+ /** de namen van de maanden */
13
+ monthNames: string[];
14
+ /** wat te doen als een event aangeklikt wordt */
15
+ onEventClick?: (event: T, clickEvent: MouseEvent<HTMLElement>) => void;
16
+ /** wat te doen als een dag aangeklikt wordt */
17
+ onDayClick?: (date: Date, clickEvent: MouseEvent<HTMLElement>) => void;
18
+ /** opties voor deze container */
19
+ options?: CalendarOptions<T>;
20
+ /** de datum voor de container */
21
+ date: Date;
22
+ }): JSX.Element;
@@ -0,0 +1,58 @@
1
+ export declare type BaseEventProps = {
2
+ /** id van een event */
3
+ id: number | string | (() => number | string);
4
+ /** title van een event */
5
+ title: string | (() => string);
6
+ /** start datetime or date event */
7
+ startDateTime: Date;
8
+ /** (optional) end datetime */
9
+ endDateTime?: Date;
10
+ /** is event an allday-event (hide starttime) */
11
+ allDay?: boolean;
12
+ /** event description */
13
+ description?: string | (() => string);
14
+ /** background-color for event (hexColors, default = #ee8000) */
15
+ evtColor?: string | (() => string);
16
+ /** text-color for event (hexColors, default = #ffffff) */
17
+ txtColor?: string | (() => string);
18
+ /** (optionele) tooltip tekst */
19
+ tooltip?: string | (() => string);
20
+ };
21
+ export declare type CalendarOptions<T> = {
22
+ /** dag-namen, default = [Ma Di Wo Do Vr Za Zo] */
23
+ dayNames?: string[];
24
+ /** maand-namen, default = [Jan Feb Mrt Apr Mei Jun Jul Aug Sep Okt Nov Dec] */
25
+ monthNames?: string[];
26
+ /** zichtbare dagen als set (default 1,2,3,4,5,6,7 (ma = 1, di = 2,... zo = 7)) */
27
+ visibleDays?: Set<number>;
28
+ /** settings for events */
29
+ event?: {
30
+ /** settings for allday events */
31
+ allday?: EventOptions<T>;
32
+ /** settings for timed events */
33
+ timed?: EventOptions<T>;
34
+ };
35
+ /** settings for today */
36
+ today?: {
37
+ /** background color for today (HexColors, default = #3b59ec) */
38
+ bgColor?: string | ((d?: Date) => string);
39
+ /** background color for today when hovering (HexColors, default = #3b59ec) */
40
+ bgHoverColor?: string | ((d?: Date) => string);
41
+ /** text color for today (HexColors, default = #ffffff) */
42
+ txtColor?: string | ((d?: Date) => string);
43
+ /** text color for today (HexColors, default = #ffffff) */
44
+ txtHoverColor?: string | ((d?: Date) => string);
45
+ /** do not show which day is today */
46
+ doNotMarkToday: boolean;
47
+ };
48
+ };
49
+ export declare type EventOptions<T> = {
50
+ /** background color for event (HexColors, default = #ee8000dd) */
51
+ evtColor?: string | ((e: T) => string);
52
+ /** background color for today (HexColors, default = #ee8000ff) */
53
+ evtHoverColor?: string | ((e: T) => string);
54
+ /** background color for today (HexColors, default = #555555) */
55
+ txtColor?: string | ((e: T) => string);
56
+ /** background color for today (HexColors, default = #555555) */
57
+ txtHoverColor?: string | ((e: T) => string);
58
+ };
@@ -0,0 +1,94 @@
1
+ /**
2
+ * find the first day of the Month for a given date
3
+ * @param dt date
4
+ * @returns first day of the month
5
+ */
6
+ export declare const startOfMonth: (dt: Date) => Date;
7
+ /**
8
+ * find the last day of the Month for a given date
9
+ * @param dt date
10
+ * @returns last day of the month
11
+ */
12
+ export declare const endOfMonth: (dt: Date) => Date;
13
+ /**
14
+ * find the first day of the Week for a given date
15
+ * @param dt date
16
+ * @returns first day of the week
17
+ */
18
+ export declare const startOfWeek: (dt: Date) => Date;
19
+ /**
20
+ * find the las day of the Week for a given date
21
+ * @param dt date
22
+ * @returns last day of the week
23
+ */
24
+ export declare const endOfWeek: (dt: Date) => Date;
25
+ /**
26
+ * Find start of the day
27
+ * @param dt date
28
+ * @returns new date at start of the day
29
+ */
30
+ export declare const startOfDay: (dt: Date) => Date;
31
+ /**
32
+ * Find end of the day
33
+ * @param dt date
34
+ * @returns new date at end of the day
35
+ */
36
+ export declare const endOfDay: (dt: Date) => Date;
37
+ /**
38
+ * Gets week number for a given date
39
+ * @param dt date
40
+ * @returns week number
41
+ */
42
+ export declare const weekNrForDate: (dt: Date) => number;
43
+ /**
44
+ * Check if date is between 2 other dates
45
+ * @param dt the date to check
46
+ * @param start starting date of period (inclusive)
47
+ * @param end ending date of period (exclusive)
48
+ * @returns boolean
49
+ */
50
+ export declare const isBetween: (dt: Date, start: Date, end: Date) => boolean;
51
+ export declare const isToday: (dt: Date) => boolean;
52
+ /**
53
+ * Adds n days to a date
54
+ * @param dt current date
55
+ * @param n number of days to add
56
+ * @returns date with days added
57
+ */
58
+ export declare const addDays: (dt: Date, n: number) => Date;
59
+ /**
60
+ * Adds n hours to a date
61
+ * @param dt current date
62
+ * @param n number of days to add
63
+ * @returns date with days added
64
+ */
65
+ export declare const addHours: (dt: Date, n: number) => Date;
66
+ /**
67
+ * gets month name for a given Date
68
+ * @param dt date or monthNumber (jan = 1, feb = 2, ..., dec = 12)
69
+ * @param size short version or long(default) version
70
+ * @returns month name string
71
+ */
72
+ export declare const monthName: (dt: Date | number, size?: 'short' | 'long') => string;
73
+ /**
74
+ * gets weekday name for a given Date
75
+ * @param dt date or dayNumber (monday = 1, tue = 2 ... sun = 7)
76
+ * @param size short version or long(default) version
77
+ * @returns month name string
78
+ */
79
+ export declare const dayName: (dt: Date | number, size?: 'short' | 'long') => string;
80
+ /**
81
+ * Formats a date to a string
82
+ * year: yy (22) | yyyy (2022)
83
+ * month: M (1) | MM (01) | MMM (Jan) | MMMM (Januari)
84
+ * day: D (30, 9)| DD (30, 09)
85
+ * weekday: d (3)| dd (03) | ddd (Woe) | dddd (Woensdag)
86
+ * hour: HH (23, 09) | H (23, 9)
87
+ * minute: mm (59, 09) | m (59, 9)
88
+ * second: ss (59, 09)| s (59, 9)
89
+ * millisecond: SSS (999, 099, 009) | S (999, 99, 9)
90
+ * @param dt date
91
+ * @param format format string (default = yyyy-MM-dd HH:mm:ss)
92
+ * @returns formatted date string
93
+ */
94
+ export declare const formatDate: (dt: Date, format?: string) => string;
@@ -0,0 +1,3 @@
1
+ export * from './Month/Cal.Month.View';
2
+ export type { MonthViewProps } from './Month/Cal.Month.View';
3
+ export type { BaseEventProps } from './Props';
@@ -0,0 +1,70 @@
1
+ /**
2
+ * find the first day of the Month for a given date
3
+ * @param dt date
4
+ * @returns first day of the month
5
+ */
6
+ export declare const startOfMonth: (dt: Date) => Date;
7
+ /**
8
+ * find the last day of the Month for a given date
9
+ * @param dt date
10
+ * @returns last day of the month
11
+ */
12
+ export declare const endOfMonth: (dt: Date) => Date;
13
+ /**
14
+ * find the first day of the Week for a given date
15
+ * @param dt date
16
+ * @returns first day of the week
17
+ */
18
+ export declare const startOfWeek: (dt: Date) => Date;
19
+ /**
20
+ * find the las day of the Week for a given date
21
+ * @param dt date
22
+ * @returns last day of the week
23
+ */
24
+ export declare const endOfWeek: (dt: Date) => Date;
25
+ /**
26
+ * Find start of the day
27
+ * @param dt date
28
+ * @returns new date at start of the day
29
+ */
30
+ export declare const startOfDay: (dt: Date) => Date;
31
+ /**
32
+ * Find end of the day
33
+ * @param dt date
34
+ * @returns new date at end of the day
35
+ */
36
+ export declare const endOfDay: (dt: Date) => Date;
37
+ /**
38
+ * Gets week number for a given date
39
+ * @param dt date
40
+ * @returns week number
41
+ */
42
+ export declare const weekNrForDate: (dt: Date) => number;
43
+ /**
44
+ * Adds n days to a date
45
+ * @param dt current date
46
+ * @param n number of days to add
47
+ * @returns date with days added
48
+ */
49
+ export declare const addDays: (dt: Date, n: number) => Date;
50
+ /**
51
+ * Adds n hours to a date
52
+ * @param dt current date
53
+ * @param n number of days to add
54
+ * @returns date with days added
55
+ */
56
+ export declare const addHours: (dt: Date, n: number) => Date;
57
+ /**
58
+ * gets month name for a given Date
59
+ * @param dt date or monthNumber (jan = 1, feb = 2, ..., dec = 12)
60
+ * @param size short version or long(default) version
61
+ * @returns month name string
62
+ */
63
+ export declare const monthName: (dt: Date | number, size?: 'short' | 'long') => string;
64
+ /**
65
+ * gets weekday name for a given Date
66
+ * @param dt date or dayNumber (monday = 1, tue = 2 ... sun = 7)
67
+ * @param size short version or long(default) version
68
+ * @returns month name string
69
+ */
70
+ export declare const dayName: (dt: Date | number, size?: 'short' | 'long') => string;
@@ -14,7 +14,7 @@ export declare type DataTableProps<T extends unknown> = {
14
14
  * - als string: de property die uniek is: obj.<string>
15
15
  * - als function: stel een string samen die uniek is.
16
16
  */
17
- rowIdentifier?: number | string | ((item: T) => number | string);
17
+ rowIdentifier?: string | ((item: T) => string);
18
18
  /** een functie om de classes op een row te zetten, op basis van het object */
19
19
  rowClasses?: (item: T, index?: number) => string;
20
20
  /** moet de tabel zichzelf wat kleiner maken ? */
@@ -21,6 +21,16 @@ export declare function Horizontal(props: {
21
21
  };
22
22
  /** alignment van de items (default = 'l') */
23
23
  alignment?: AlignmentProp;
24
+ /** max width van een item in de horizontal scroll area
25
+ * - number: aantal px
26
+ * - string: '160x', '10em', etc.
27
+ */
28
+ maxItemWidth?: number | string;
29
+ /** max width van een item in de horizontal scroll area
30
+ * - number: aantal px
31
+ * - string: '160x', '10em', etc.
32
+ */
33
+ minItemWidth?: number | string;
24
34
  }): JSX.Element;
25
35
  /** maak een verticale flexbox container om items onder elkaar (default van boven naar beneden) neer te zetten, met of zonder wrappen */
26
36
  export declare function Vertical(props: {
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function ToolTip(): React.ReactPortal;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ declare type ContextProps = {
3
+ show: boolean;
4
+ setShow: (value: boolean) => void;
5
+ top: number;
6
+ setTop: (value: number) => void;
7
+ left: number;
8
+ setLeft: (value: number) => void;
9
+ content: string;
10
+ setContent: (value: string) => void;
11
+ };
12
+ declare type TooltipProviderProps = {
13
+ children: any;
14
+ };
15
+ export declare const TooltipContext: React.Context<ContextProps>;
16
+ export declare function ToolTipProvider({ children }: TooltipProviderProps): JSX.Element;
17
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare function useTooltip(): {
2
+ showTooltip: (top: number, left: number, content: string) => void;
3
+ hideTooltip: () => void;
4
+ isTooltipVisible: boolean;
5
+ top: number;
6
+ left: number;
7
+ content: string;
8
+ };
package/dist/index.d.ts CHANGED
@@ -60,3 +60,6 @@ export * from './components/Form/TimeInput';
60
60
  export * from './components/Form/DateTimeInput';
61
61
  export { NotifierProvider, useNotifier } from './contexts/Notifier/NotifierProvider';
62
62
  export type { NotifierItemProps } from './contexts/Notifier/NotifierProps';
63
+ export * as Calendar from './components/Calendar';
64
+ export type { BaseEventProps, CalendarOptions } from './components/Calendar/Props';
65
+ export type { MonthViewProps } from './components/Calendar/Month/Cal.Month.View';