loon-bulma-react 2023.0.22 → 2023.0.24
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 +27 -16
- package/dist/components/Calendar/CalendarItems/CalendarColoredItem.d.ts +2 -3
- package/dist/components/Calendar/CalendarItems/CalendarItem.d.ts +2 -3
- package/dist/components/Calendar/DayContainer.d.ts +3 -1
- package/dist/components/Calendar/Week/AlldayContainer.d.ts +3 -1
- package/dist/components/Calendar/Week/HourRow.d.ts +3 -1
- package/dist/components/Calendar/base-styles.d.ts +1 -12
- package/dist/components/Tooltip/Tooltip.d.ts +4 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useLocalStoredState.d.ts +3 -6
- package/dist/hooks/useSessionStoredState.d.ts +38 -0
- package/dist/index.js +203 -138
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +204 -140
- package/dist/index.modern.js.map +1 -1
- package/dist/utils/deserialize.function.d.ts +2 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/serialize.function.d.ts +2 -0
- package/package.json +1 -1
- package/styles/tooltip.scss +9 -6
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> ## Aanpassingen
|
|
4
4
|
>
|
|
5
|
+
> - `useSessionStoredState()`-hook gemaakt. Gebruik session-storage in plaats van local-storage om gegevens te verwijderen bij het sluiten van de tab/browser.
|
|
5
6
|
> - `<CB>`-component gemaakt. Een kale checkbox met een label. Geen wrapper, geen direction, geen form.
|
|
6
7
|
> - `<RB>`-component gemaakt. Een Radio-button met een label. Geen wrapper, geen direction, geen form.
|
|
7
8
|
> - `ColorProp` uitgebreid met `"is-${`_string_`}"`-template literal. Als _Bulma_ nog andere kleuren gebruikt dan de standaard-kleuren, kan je die op die manier gebruiken.
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
- [useDebouncedValue](#hooks-use-debounced-value)
|
|
81
82
|
- [useEventListener](#hooks-use-event-listener)
|
|
82
83
|
- [useHotkeys](#hooks-use-hotkeys)
|
|
83
|
-
- [useLocalStoredState](#hooks-use-local-stored-state)
|
|
84
|
+
- [useLocalStoredState & useSessionStoredState](#hooks-use-local-stored-state)
|
|
84
85
|
- [usePagination](#hooks-use-pagination)
|
|
85
86
|
- [useToggle & useBoolToggle](#hooks-use-toggle)
|
|
86
87
|
- [useUncontrolled](#hooks-use-uncontrolled)
|
|
@@ -1934,7 +1935,7 @@ Het resultaat van deze form komt via de `onSubmit()` methode naar buiten. Als de
|
|
|
1934
1935
|
- [useDebouncedValue](#hooks-use-debounced-value)
|
|
1935
1936
|
- [useEventListener](#hooks-use-event-listener)
|
|
1936
1937
|
- [useHotkeys](#hooks-use-hotkeys)
|
|
1937
|
-
- [useLocalStoredState](#hooks-use-local-stored-state)
|
|
1938
|
+
- [useLocalStoredState & useSessionStoredState](#hooks-use-local-stored-state)
|
|
1938
1939
|
- [usePagination](#hooks-use-pagination)
|
|
1939
1940
|
- [useToggle & useBoolToggle](#hooks-use-toggle)
|
|
1940
1941
|
- [useUncontrolled](#hooks-use-uncontrolled)
|
|
@@ -2085,19 +2086,35 @@ function HotkeysExample() {
|
|
|
2085
2086
|
}
|
|
2086
2087
|
```
|
|
2087
2088
|
|
|
2088
|
-
#### useLocalStoredState() <a id="hooks-use-local-stored-state"></a>
|
|
2089
|
+
#### useLocalStoredState() en useSessionStoredState() <a id="hooks-use-local-stored-state"></a>
|
|
2089
2090
|
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
- `value`: de waarde van type `T`
|
|
2093
|
-
- `setValue(val: T)`: een functie die de waarde als parameter ontvangt.
|
|
2094
|
-
- `remove()`: verwijder de waarde (als die nog bestaat) uit _Local Storage_
|
|
2091
|
+
De `useLocalStoredState()`- en de `useSessionStoredState()`-hook werkt hetzelfde als de `React.useState()`-hook. Het enige verschil is dat de state **ook** in _Local Storage_ of de _Session Storage_ wordt opgeslagen, zodat de waarde na een refresh nog steeds beschikbaar is. Data wordt in _Local Storage_ of de _Session Storage_ opgeslagen in JSON-formaat. De return-waarde is een tuple met 3 variabelen: `[value, setValue, remove]`
|
|
2095
2092
|
|
|
2096
2093
|
De hook gebruik je op bijna dezelfde manier als `useState()`:
|
|
2094
|
+
| Property | Type | Description |
|
|
2095
|
+
|----------------|----------------------|-----------------------------------------------------------------------------------------|
|
|
2096
|
+
| `key` | `string` | de key waar de waarde in _Local Storage_ wordt opgeslagen |
|
|
2097
|
+
| `defaultValue` | `T` | de waarde die gebruikt wordt als default |
|
|
2098
|
+
| `serialize` | `(val: T) => string` | (optioneel) de functie die de waarde `T` omzet naar een string om die te kunnen opslaan |
|
|
2099
|
+
| `deserialize` | `(val: string) => T` | (optioneel) de functie die eenstring uit _Local Storage_ omzet naar een waarde `T` |
|
|
2100
|
+
|
|
2101
|
+
Het verschil tussen de _Local Storage_ en de _Session Storage_ is simpel:
|
|
2102
|
+
|
|
2103
|
+
- _Local Storage_:de data blijft bewaard tot deze wordt verwijderd.
|
|
2104
|
+
- _Session Storage_: de data wordt verwijderd als de **browser** of de **tab** wordt gesloten.
|
|
2097
2105
|
|
|
2098
2106
|
```tsx
|
|
2099
2107
|
function UseLocalStoredStateDemo() {
|
|
2100
|
-
const [value, setValue, remove] = useLocalStoredState({ key: 'my-special-key', defaultValue: '' });
|
|
2108
|
+
const [value, setValue, remove] = useLocalStoredState({ key: 'my-special-key-local-storage', defaultValue: '' });
|
|
2109
|
+
return (
|
|
2110
|
+
<>
|
|
2111
|
+
<Input value={value} onChange={(e) => setValue(e.target.value)} />
|
|
2112
|
+
<Button.Primary onClick={() => remove()}>Remove value</Button.Primary>
|
|
2113
|
+
</>
|
|
2114
|
+
);
|
|
2115
|
+
|
|
2116
|
+
function UseSessionStoredStateDemo() {
|
|
2117
|
+
const [value, setValue, remove] = useSessionStoredState({ key: 'my-special-key-session-storage', defaultValue: '' });
|
|
2101
2118
|
return (
|
|
2102
2119
|
<>
|
|
2103
2120
|
<Input value={value} onChange={(e) => setValue(e.target.value)} />
|
|
@@ -2107,13 +2124,7 @@ function UseLocalStoredStateDemo() {
|
|
|
2107
2124
|
}
|
|
2108
2125
|
```
|
|
2109
2126
|
|
|
2110
|
-
Om te zien dat de waarde in
|
|
2111
|
-
| Property | Type | Description |
|
|
2112
|
-
|----------------|----------------------|--------------------------------------------------------------------------|
|
|
2113
|
-
| `key` | `string` | de key waar de waarde in _Local Storage_ wordt opgeslagen |
|
|
2114
|
-
| `defaultValue` | `T` | de waarde die gebruikt wordt als default |
|
|
2115
|
-
| `serialize` | `(val: T) => string` | (optioneel) de functie die de waarde `T` omzet naar een string om die te kunnen opslaan |
|
|
2116
|
-
| `deserialize` | `(val: string) => T` | (optioneel) de functie die eenstring uit _Local Storage_ omzet naar een waarde `T` |
|
|
2127
|
+
Om te zien dat de waarde in de _Storage_ bewaard blijft, moet je de pagina refreshen nadat je de waarde hebt gewijzigd. Dan wordt de waarde uit _Storage_ gevuld. Anders wordt de `defaultValue` gebruikt. Als je de waarde wilt verwijderen, dan kan dat met de `remove()`-functie. Om het verschil tussen _Local_ en _Session_ te zien, moet je de tab of de browser sluiten. De waarde in _Local Storage_ blijft bewaard, de waarde in _Session Storage_ wordt verwijderd.
|
|
2117
2128
|
|
|
2118
2129
|
De functies `serialize` en `deserialize` hoef je alleen te implementeren als je een waarde hebt die geen gebruik van `JSON.stringify()` en `JSON.parse()` kan maken, of als er meer nodig is om dat te kunnen doen.
|
|
2119
2130
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
2
|
import { EventOptions, BaseEventProps } from '../Props';
|
|
3
3
|
declare type CalendarColoredItemProps<T extends BaseEventProps> = {
|
|
4
4
|
/** Het event */
|
|
@@ -8,12 +8,11 @@ declare type CalendarColoredItemProps<T extends BaseEventProps> = {
|
|
|
8
8
|
options?: EventOptions<T>;
|
|
9
9
|
/** Onclick handler voor het event */
|
|
10
10
|
onClick?: (event: T, clickEvent: MouseEvent<HTMLElement>) => void;
|
|
11
|
-
tooltip?: React.ReactNode;
|
|
12
11
|
};
|
|
13
12
|
/**
|
|
14
13
|
* Component voor een event dat de hele dag duurt
|
|
15
14
|
* @param props
|
|
16
15
|
* @returns
|
|
17
16
|
*/
|
|
18
|
-
export declare function CalendarColoredItem<T extends BaseEventProps>({ event, options,
|
|
17
|
+
export declare function CalendarColoredItem<T extends BaseEventProps>({ event, options, onClick, desc, }: CalendarColoredItemProps<T>): JSX.Element;
|
|
19
18
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
2
|
import { EventOptions, BaseEventProps } from '../Props';
|
|
3
3
|
declare type CalendarItemProps<T extends BaseEventProps> = {
|
|
4
4
|
desc: (event: T) => JSX.Element;
|
|
@@ -8,12 +8,11 @@ declare type CalendarItemProps<T extends BaseEventProps> = {
|
|
|
8
8
|
options?: EventOptions<T>;
|
|
9
9
|
/** Onclick handler */
|
|
10
10
|
onClick?: (event: T, clickEvent: MouseEvent<HTMLElement>) => void;
|
|
11
|
-
tooltip?: React.ReactNode;
|
|
12
11
|
};
|
|
13
12
|
/**
|
|
14
13
|
* Component voor een event met een tijdstip en NIET de hele dag duurt
|
|
15
14
|
* @param props
|
|
16
15
|
* @returns
|
|
17
16
|
*/
|
|
18
|
-
export declare function CalendarItem<T extends BaseEventProps>({ event, options,
|
|
17
|
+
export declare function CalendarItem<T extends BaseEventProps>({ event, options, onClick, desc, }: CalendarItemProps<T>): JSX.Element;
|
|
19
18
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BaseEventProps, CalendarOptions } from './Props';
|
|
3
3
|
import { JSDateTime } from '~/utils';
|
|
4
|
+
import { ColorProp } from '~/loon-react-bulma-types';
|
|
4
5
|
declare type DayContainerProps<T extends BaseEventProps> = {
|
|
5
6
|
/** Events op deze dag */
|
|
6
7
|
events: T[];
|
|
@@ -14,11 +15,12 @@ declare type DayContainerProps<T extends BaseEventProps> = {
|
|
|
14
15
|
date: JSDateTime;
|
|
15
16
|
/** Behoort deze dag tot de huidige maand ? */
|
|
16
17
|
isCurrentMonth?: boolean;
|
|
18
|
+
tooltipColor: ColorProp;
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* Component voor de dag-container in de maand-view
|
|
20
22
|
* @param props
|
|
21
23
|
* @returns
|
|
22
24
|
*/
|
|
23
|
-
export declare function DayContainer<T extends BaseEventProps>({ options, date, onDayClick, onEventClick, events, isCurrentMonth, }: DayContainerProps<T>): JSX.Element;
|
|
25
|
+
export declare function DayContainer<T extends BaseEventProps>({ options, date, onDayClick, onEventClick, events, tooltipColor, isCurrentMonth, }: DayContainerProps<T>): JSX.Element;
|
|
24
26
|
export {};
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BaseEventProps, CalendarOptions } from '../Props';
|
|
3
|
+
import { ColorProp } from '~/loon-react-bulma-types';
|
|
3
4
|
declare type AlldayContainerProps<T extends BaseEventProps> = {
|
|
4
5
|
events: T[];
|
|
5
6
|
/** Wat te doen als een event aangeklikt wordt */
|
|
6
7
|
onEventClick?: (event: T, clickEvent: React.MouseEvent<HTMLElement>) => void;
|
|
7
8
|
/** Wat te doen als een dag aangeklikt wordt */
|
|
8
9
|
options?: CalendarOptions<T>;
|
|
10
|
+
tooltipColor: ColorProp;
|
|
9
11
|
};
|
|
10
12
|
/**
|
|
11
13
|
* Component voor allday objects in de calendar
|
|
12
14
|
* @param props
|
|
13
15
|
* @returns
|
|
14
16
|
*/
|
|
15
|
-
export declare function AlldayContainer<T extends BaseEventProps>({ options, events, onEventClick }: AlldayContainerProps<T>): JSX.Element;
|
|
17
|
+
export declare function AlldayContainer<T extends BaseEventProps>({ options, events, onEventClick, tooltipColor, }: AlldayContainerProps<T>): JSX.Element;
|
|
16
18
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ColorProp } from '../../../loon-react-bulma-types';
|
|
2
3
|
import { BaseEventProps, CalendarOptions } from '../Props';
|
|
3
4
|
/**
|
|
4
5
|
* Component om een uur-nummer weer te geven.
|
|
@@ -15,11 +16,12 @@ declare type HourSlotProps<T extends BaseEventProps> = {
|
|
|
15
16
|
onEventClick?: (event: T, clickEvent: React.MouseEvent<HTMLElement>) => void;
|
|
16
17
|
/** Options bij de calendar */
|
|
17
18
|
options?: CalendarOptions<T>;
|
|
19
|
+
tooltipColor?: ColorProp;
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
22
|
* Component voor een uur-slot.
|
|
21
23
|
* @param param0
|
|
22
24
|
* @returns
|
|
23
25
|
*/
|
|
24
|
-
export declare function HourSlot<T extends BaseEventProps>({ events, onEventClick, options }: HourSlotProps<T>): JSX.Element;
|
|
26
|
+
export declare function HourSlot<T extends BaseEventProps>({ events, onEventClick, options, tooltipColor, }: HourSlotProps<T>): JSX.Element;
|
|
25
27
|
export {};
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
/** default style van events */
|
|
3
|
-
export declare const eventStylesBase:
|
|
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
|
-
};
|
|
3
|
+
export declare const eventStylesBase: CSSProperties;
|
|
15
4
|
/** default styling van de header */
|
|
16
5
|
export declare const headerContainerStylesBase: CSSProperties;
|
|
17
6
|
/** default styling van de grid */
|
|
@@ -2,13 +2,16 @@ import React from 'react';
|
|
|
2
2
|
import { ColorProp } from '~/loon-react-bulma-types';
|
|
3
3
|
declare type PositionProp = 'bottom';
|
|
4
4
|
export declare class Tooltip extends React.Component<{
|
|
5
|
-
content
|
|
5
|
+
content?: React.ReactNode;
|
|
6
6
|
color?: ColorProp;
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
+
display?: 'block' | 'inline';
|
|
8
9
|
}> {
|
|
9
10
|
static defaultProps: {
|
|
10
11
|
position: PositionProp;
|
|
11
12
|
color: ColorProp;
|
|
13
|
+
content: React.ReactNode;
|
|
14
|
+
display: 'block' | 'inline';
|
|
12
15
|
};
|
|
13
16
|
state: {
|
|
14
17
|
active: boolean;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/** Default serializer met `JSON.stringify` van de waar `T` naar een `string` */
|
|
2
|
-
declare function serializeJSON<T>(value: T): string;
|
|
3
|
-
/** Default deserializer met `JSON.parse` van een `string` naar de waarde `T` */
|
|
4
|
-
declare function deserializeJSON<T>(value: string): T;
|
|
5
1
|
declare type UseLocalStoredStateFn<T = string> = {
|
|
6
2
|
/** Key to store the value with in Local Storage */
|
|
7
3
|
key: string;
|
|
@@ -15,6 +11,7 @@ declare type UseLocalStoredStateFn<T = string> = {
|
|
|
15
11
|
/**
|
|
16
12
|
* Hook die werkt als `React.useState<T|undefined>()`, maar waarbij de waarde ook wordt opgeslagen in Local Storage.
|
|
17
13
|
* De waarde blijft dan bij het refreshen van de pagina aanwezig. Als de pagina dan ververst wordt, word de al bestaande waarde gebruikt, niet de initialValue.
|
|
14
|
+
* Om de waarde te bewaren bij afsluiten van de browser, gebruik je de hook `{@link useSessionStoredState}`.
|
|
18
15
|
* @param {UseLocalStoredStateFn} params voor de hook
|
|
19
16
|
* @returns {[T, (value: T) => void]} tuple met een value en een setValue-function (net als React.useState)
|
|
20
17
|
* @description
|
|
@@ -23,7 +20,7 @@ declare type UseLocalStoredStateFn<T = string> = {
|
|
|
23
20
|
* | key | `string` | De key waaronder de waarde in Local Storage wordt opgeslagen. |
|
|
24
21
|
* | initialValue | `T` | De initiale waarde. |
|
|
25
22
|
* | serialize | `function` | (optional) functie om de waarde om te zetten naar een string. Implementeer als de waarde __GEEN__ gebruik kan maken van `JSON.stringify()`! |
|
|
26
|
-
* | deserialize | `function` | De functie die een string omzet naar de waarde. Implementeer als de waarde __GEEN__ gebruik kan maken van `JSON.parse()`! |
|
|
23
|
+
* | deserialize | `function` | (optional) De functie die een string omzet naar de waarde. Implementeer als de waarde __GEEN__ gebruik kan maken van `JSON.parse()`! |
|
|
27
24
|
* @example
|
|
28
25
|
* import { useLocalStoredState } from 'loon-bulma-react';
|
|
29
26
|
* const [ value, setValue, removeFromLocalStorage ] = useLocalStoredState({ key: 'myKey', initialValue: 'Oompa Loompa' });
|
|
@@ -34,4 +31,4 @@ declare type UseLocalStoredStateFn<T = string> = {
|
|
|
34
31
|
* // 5. you can also check the value in Local Storage in devtools.
|
|
35
32
|
*/
|
|
36
33
|
declare function useLocalStoredState<T extends unknown>({ key, initialValue, deserialize, serialize }: UseLocalStoredStateFn<T>): readonly [T | undefined, (value: T) => void, () => void];
|
|
37
|
-
export { useLocalStoredState
|
|
34
|
+
export { useLocalStoredState };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare type UseSessionStoredState<T = string> = {
|
|
2
|
+
/** Key to store the value with in Session Storage */
|
|
3
|
+
key: string;
|
|
4
|
+
/** Initial value (if its non-existent in Session Storage) */
|
|
5
|
+
initialValue: T;
|
|
6
|
+
/** Your own serializing-function. Implement when you cannot use `JSON.stringify` */
|
|
7
|
+
serialize?: (value: T, replacer?: (key: string, value: any) => any, space?: string | number) => string;
|
|
8
|
+
/** Your own deserializing-funtion. Implement when you cannot use `JSON.parse` */
|
|
9
|
+
deserialize?: (value: string, reviver?: (key: string, value: any) => any) => T;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Hook die werkt als `React.useState<T|undefined>()`, maar waarbij de waarde ook wordt opgeslagen in Session Storage.
|
|
13
|
+
* De waarde blijft dan bij het refreshen van de pagina aanwezig.
|
|
14
|
+
* Als de pagina dan ververst wordt, word de al bestaande waarde gebruikt, niet de initialValue.
|
|
15
|
+
* Maar als de tab of de browser gesloten wordt, dan wordt de inhoud van de session storage gewist.
|
|
16
|
+
* Om de waarde te bewaren bij afsluiten van de browser, gebruik je de hook `{@link useLocalStoredState}`.
|
|
17
|
+
* @param {UseSessionStoredState} params voor de hook
|
|
18
|
+
* @returns {[T, (value: T) => void]} tuple met een `value` en een `setValue`-function (net als `React.useState`)
|
|
19
|
+
* @description
|
|
20
|
+
* | Property | Type | Description |
|
|
21
|
+
* |--------------|------------|---------------------------------------------------------------|
|
|
22
|
+
* | key | `string` | De key waaronder de waarde in Session Storage wordt opgeslagen. |
|
|
23
|
+
* | initialValue | `T` | De initiale waarde. |
|
|
24
|
+
* | serialize | `function` | (optional) functie om de waarde om te zetten naar een string. Implementeer als de waarde __GEEN__ gebruik kan maken van `JSON.stringify()`! |
|
|
25
|
+
* | deserialize | `function` | (optional) De functie die een string omzet naar de waarde. Implementeer als de waarde __GEEN__ gebruik kan maken van `JSON.parse()`! |
|
|
26
|
+
* @example
|
|
27
|
+
* import { useSessionStoredState } from 'loon-bulma-react';
|
|
28
|
+
* const [ value, setValue, removeFromSessionStorage ] = useSessionStoredState({ key: 'myKey', initialValue: 'Oompa Loompa' });
|
|
29
|
+
* // 1. value is 'Oompa Loompa', put it somewhere on the screen
|
|
30
|
+
* // 2. change the value to something else
|
|
31
|
+
* // 3. refresh the page.
|
|
32
|
+
* // 4. see te new value on the page.
|
|
33
|
+
* // 5. you can also check the value in Local Storage in devtools.
|
|
34
|
+
* // 6. close the browser / tab
|
|
35
|
+
* // 7. check the value in session storage. it should be gone.
|
|
36
|
+
*/
|
|
37
|
+
declare function useSessionStoredState<T extends unknown>({ key, initialValue, deserialize, serialize }: UseSessionStoredState<T>): readonly [T | undefined, (value: T) => void, () => void];
|
|
38
|
+
export { useSessionStoredState };
|