loon-bulma-react 2022.3.4 → 2022.3.5
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/dist/components/Form/BaseInputProps.d.ts +9 -9
- package/dist/components/Form/File/FileInput.d.ts +39 -0
- package/dist/components/Form/Form.d.ts +16 -3
- package/dist/components/Form/FormBuilder/FormBuilder.d.ts +9 -0
- package/dist/components/Form/FormBuilder/FormBuilderProps.d.ts +92 -0
- package/dist/components/Form/Others/BasicInput.d.ts +11 -9
- package/dist/index.d.ts +5 -3
- package/dist/index.js +191 -16
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +191 -17
- package/dist/index.modern.js.map +1 -1
- package/example/src/Tabs/FormTab.tsx +56 -48
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DirectionProp, KeyboardTypeProp } from '../../loon-react-bulma-types';
|
|
2
|
-
export declare type BaseInputProps = {
|
|
2
|
+
export declare type BaseInputProps<T extends any = void> = {
|
|
3
3
|
/** is dit veld disabled ? (optioneel) */
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
/** name input: gebruikt voor een <label> als er geen label gedefinieerd is & de name-attribuut <input> */
|
|
@@ -15,13 +15,13 @@ export declare type BaseInputProps = {
|
|
|
15
15
|
/** de input is horizontaal, label & input op 1 lijn. (default = 'horizontal') */
|
|
16
16
|
direction?: DirectionProp;
|
|
17
17
|
/** een object met validatie-regels */
|
|
18
|
-
validation?: FormValidationType
|
|
18
|
+
validation?: FormValidationType<T>;
|
|
19
19
|
/** placeholder in input (optioneel) */
|
|
20
20
|
placeholder?: string;
|
|
21
21
|
/** Welk (virtueel) toetsenbord moet er gebruikt worden? (smartphones, tablets) */
|
|
22
22
|
keyboardType?: KeyboardTypeProp;
|
|
23
23
|
};
|
|
24
|
-
export declare type FormValidationType = {
|
|
24
|
+
export declare type FormValidationType<T extends any = void> = {
|
|
25
25
|
/** is een value required? */
|
|
26
26
|
required?: boolean;
|
|
27
27
|
/**
|
|
@@ -51,9 +51,9 @@ export declare type FormValidationType = {
|
|
|
51
51
|
* @param val de nieuwe te valideren waarde
|
|
52
52
|
* @returns een string met daarin de foutmelding OF een lege string voor een valid waarde.
|
|
53
53
|
*/
|
|
54
|
-
onValidate?: (val: string | string[] | number | number[] | boolean | Date) => string;
|
|
54
|
+
onValidate?: (val: T | string | string[] | number | number[] | boolean | Date | FileList) => string;
|
|
55
55
|
};
|
|
56
|
-
export declare type BaseState = {
|
|
56
|
+
export declare type BaseState<T extends any = void> = {
|
|
57
57
|
/** de naam die in foutmeldingen komt */
|
|
58
58
|
description: string;
|
|
59
59
|
/** de fout-melding, '' voor valid */
|
|
@@ -63,7 +63,7 @@ export declare type BaseState = {
|
|
|
63
63
|
/** is de input aangeraakt */
|
|
64
64
|
touched: boolean;
|
|
65
65
|
/** validatie-object voor deze input */
|
|
66
|
-
validation?: FormValidationType
|
|
66
|
+
validation?: FormValidationType<T>;
|
|
67
67
|
};
|
|
68
68
|
export declare type BaseChangeStateType = {
|
|
69
69
|
type: 'CHANGE';
|
|
@@ -73,12 +73,12 @@ export declare type BaseTouchStateType = {
|
|
|
73
73
|
type: 'TOUCH';
|
|
74
74
|
touched: boolean;
|
|
75
75
|
};
|
|
76
|
-
export declare type BaseSetStateType = {
|
|
76
|
+
export declare type BaseSetStateType<T extends any = void> = {
|
|
77
77
|
type: 'SET';
|
|
78
|
-
validation?: FormValidationType
|
|
78
|
+
validation?: FormValidationType<T>;
|
|
79
79
|
};
|
|
80
80
|
export declare type BaseFocusStateType = {
|
|
81
81
|
type: 'FOCUS';
|
|
82
82
|
focus: boolean;
|
|
83
83
|
};
|
|
84
|
-
export declare type InputTypeProp = 'text' | 'password' | 'number' | 'email' | 'tel' | 'url' | 'range' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color' | 'search' | 'multirange' | 'multiselect' | 'select' | 'textarea';
|
|
84
|
+
export declare type InputTypeProp = 'text' | 'password' | 'number' | 'email' | 'tel' | 'url' | 'range' | 'date' | 'datetime-local' | 'datetime' | 'month' | 'week' | 'time' | 'color' | 'search' | 'multirange' | 'multiselect' | 'select' | 'textarea';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { SizeProp } from '../../../loon-react-bulma-types';
|
|
4
|
+
import { BaseInputProps } from '../BaseInputProps';
|
|
5
|
+
declare type FileInputProps = BaseInputProps & {
|
|
6
|
+
/** file types die een file-input zou moeten accepteren. Komma-gescheiden lijst van unieke file-type-specificaties (zie MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file) */
|
|
7
|
+
accept?: string;
|
|
8
|
+
/** welke camera moet er gebruikt maken voor afbeelding/video data, als dat via de accept-prop is toegestaan */
|
|
9
|
+
capture?: 'user' | 'environment';
|
|
10
|
+
/** toon de input als een block */
|
|
11
|
+
boxed?: boolean;
|
|
12
|
+
/** mag een gebruik meerdere files selecteren */
|
|
13
|
+
multiple?: boolean;
|
|
14
|
+
/** tekst voor op selecteer-file-button. default wordt de 'name'-prop gebruikt */
|
|
15
|
+
kiesLabel?: string;
|
|
16
|
+
/** tekst voor 'er-is-nog-geen-bestand'. default = '' */
|
|
17
|
+
nogGeenBestandLabel?: string;
|
|
18
|
+
/** start value voor deze input (optioneel) */
|
|
19
|
+
value?: string;
|
|
20
|
+
/** grootte input (optioneel) */
|
|
21
|
+
size?: SizeProp;
|
|
22
|
+
/**
|
|
23
|
+
* Wat te doen als de waarde is veranderd
|
|
24
|
+
* @param files: de nieuwe waarde
|
|
25
|
+
* @param valid: is de nieuwe waarde geldig?
|
|
26
|
+
*/
|
|
27
|
+
onValueChanged?(files: FileList, isValid?: boolean): any | void;
|
|
28
|
+
/** formatteer de weergegeven filenaamm volgens een eigen functie */
|
|
29
|
+
filenameFormatter?(val: string, files: FileList): string;
|
|
30
|
+
icon?: string | IconProp;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Maak een file input
|
|
34
|
+
* @param props
|
|
35
|
+
* @returns <input type="text'|'tel'|'url">
|
|
36
|
+
*/
|
|
37
|
+
declare const FileInput: (props: FileInputProps) => JSX.Element;
|
|
38
|
+
export { FileInput };
|
|
39
|
+
export type { FileInputProps };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DirectionProp, SizeProp } from '../../loon-react-bulma-types';
|
|
1
|
+
import { AlignmentProp, DirectionProp, SizeProp } from '../../loon-react-bulma-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { BasicInput } from './Others/BasicInput';
|
|
3
4
|
declare type FormProps = {
|
|
4
5
|
/** de inputs voor dit form */
|
|
5
6
|
children: React.ReactNode;
|
|
@@ -27,7 +28,7 @@ declare type FormProps = {
|
|
|
27
28
|
declare const Form: {
|
|
28
29
|
(props: FormProps): JSX.Element;
|
|
29
30
|
/** een zelf-configureerbare base input */
|
|
30
|
-
Input:
|
|
31
|
+
Input: typeof BasicInput;
|
|
31
32
|
/** input voor type url, text of tel */
|
|
32
33
|
Text: (props: import("./Text/TextInput").TextInputProps) => JSX.Element;
|
|
33
34
|
/** password input */
|
|
@@ -58,12 +59,24 @@ declare const Form: {
|
|
|
58
59
|
Time: (props: import("./Datetimes/TimeInput").TimeInputProps) => JSX.Element;
|
|
59
60
|
/** checkbox input */
|
|
60
61
|
CheckBox: (props: import("./Checkbox/Checkbox").CheckboxInputProps) => JSX.Element;
|
|
62
|
+
/** een file-input */
|
|
63
|
+
File: (props: import("./File/FileInput").FileInputProps) => JSX.Element;
|
|
61
64
|
/** Plaats 2 of meer inputs op een lijn
|
|
62
65
|
* LET OP: je moet zelf instellen of ze horizontaal / verticaal moeten zijn (default = horizontal)
|
|
63
66
|
*/
|
|
64
|
-
Line: (
|
|
67
|
+
Line: ({ children }: {
|
|
65
68
|
children: React.ReactNode;
|
|
66
69
|
}) => JSX.Element;
|
|
70
|
+
/** ruimte om eigen spullen in het form te stoppen. */
|
|
71
|
+
Space: ({ children }: {
|
|
72
|
+
children: React.ReactNode;
|
|
73
|
+
}) => JSX.Element;
|
|
74
|
+
/** container voor de buttons van het form. Grootte van de buttons kan onafhankelijk worden ingesteld */
|
|
75
|
+
Buttons: ({ children, size, alignment, }: {
|
|
76
|
+
children: React.ReactNode;
|
|
77
|
+
size?: "s" | "l" | "m" | "xl" | undefined;
|
|
78
|
+
alignment?: "l" | "c" | "r" | undefined;
|
|
79
|
+
}) => JSX.Element;
|
|
67
80
|
};
|
|
68
81
|
export { Form };
|
|
69
82
|
export type { FormProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormBuilderProps } from './FormBuilderProps';
|
|
3
|
+
/**
|
|
4
|
+
* stel een form samen op basis van een array van fields, met een submit-button en optionele extra buttons.
|
|
5
|
+
* Kan ook in een modal getoont worden.
|
|
6
|
+
* @param props
|
|
7
|
+
* @returns een object voor POST requests OF een URLPARAMS string voor GET requests
|
|
8
|
+
*/
|
|
9
|
+
export declare function FormBuilder(props: FormBuilderProps): JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ColorProp, DirectionProp } from '../../../loon-react-bulma-types';
|
|
2
|
+
import { FormValidationType } from './../BaseInputProps';
|
|
3
|
+
import { SelectOptionType, SelectOptionGroupType } from './../Selects/BaseSelectProps';
|
|
4
|
+
/** Props voor de Form-component */
|
|
5
|
+
export declare type FormBuilderProps = {
|
|
6
|
+
/** definieer een onSubmit voor het form
|
|
7
|
+
* <form onSubmit="onSubmit(e)"
|
|
8
|
+
* @param e: data
|
|
9
|
+
* @returns: het resultaat van het form: GET: URLSearchParams string, POST: key-values van fields
|
|
10
|
+
*/
|
|
11
|
+
onSubmit(e: any | undefined): void;
|
|
12
|
+
/** Moet het form in een modal verschijnen */
|
|
13
|
+
useModal?: boolean;
|
|
14
|
+
/** wat te doen om de modal te sluiten. ALLEEN ALS useModal 'true' IS, IS DEZE NODIG */
|
|
15
|
+
onDismiss?(e: any): void;
|
|
16
|
+
/** buttons voor onderaan het form */
|
|
17
|
+
buttons: {
|
|
18
|
+
/** de tekst voor de (groene) submit button, deze is VERPLICHT */
|
|
19
|
+
submit: string;
|
|
20
|
+
/** 0 of emerdere (blauw) buttons */
|
|
21
|
+
other?: FormBuilderButton[];
|
|
22
|
+
};
|
|
23
|
+
/** Een array van fields voor het form */
|
|
24
|
+
fields: FormBuilderFieldProps[];
|
|
25
|
+
/** autocomplete on or off? */
|
|
26
|
+
autocomplete?: 'on' | 'off' | null;
|
|
27
|
+
/** de form name */
|
|
28
|
+
name: string;
|
|
29
|
+
/** de GET / POST methode voor het form
|
|
30
|
+
* <form method="get"></form>
|
|
31
|
+
*/
|
|
32
|
+
method: 'post' | 'get';
|
|
33
|
+
/** target voor het form */
|
|
34
|
+
target?: '_self' | '_blank' | '_parent' | '_top' | null;
|
|
35
|
+
direction?: DirectionProp;
|
|
36
|
+
};
|
|
37
|
+
/** Props voor de fields in een form van de Form-Component */
|
|
38
|
+
export declare type FormBuilderFieldProps = {
|
|
39
|
+
/** de naam voor het field. gebruikt in input en in <label> als geen label gedefinieerd.
|
|
40
|
+
* <input name="..." /> */
|
|
41
|
+
name: string;
|
|
42
|
+
/** een tooltip voor de button */
|
|
43
|
+
tooltip?: string;
|
|
44
|
+
/** label voor het field, als die afwijkt van de name-attribuut. gebruikt in <label> (optional) */
|
|
45
|
+
label?: string;
|
|
46
|
+
/** is het field gevalideerd en wat is daar de uitkomst van. */
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
/** (optioneel) id van een field. Anders wordt de "name" gebruikt */
|
|
49
|
+
id?: string;
|
|
50
|
+
valid?: boolean;
|
|
51
|
+
/** de waarde van de input.
|
|
52
|
+
* Voor multi-range-inputs: een number[] van twee waarden: [valueA, valueB]
|
|
53
|
+
* Voor Datum/Tijd inputs:
|
|
54
|
+
* - type 'date': YYYY-MM-DD
|
|
55
|
+
* - type 'time': HH:mm
|
|
56
|
+
* - type 'datetime': YYYY-MM-DD HH:mm OF YYYY-MM-DDTHH:mm
|
|
57
|
+
*/
|
|
58
|
+
value?: string | string[] | number | number[] | boolean | null;
|
|
59
|
+
/** object gebruikt voot validatie */
|
|
60
|
+
validation?: FormValidationType;
|
|
61
|
+
/** input type: <input type="..." /> */
|
|
62
|
+
type: 'text' | 'number' | 'email' | 'password' | 'date' | 'datetime' | 'time' | 'textarea' | 'select' | 'multiselect' | 'checkbox' | 'tel' | 'url' | 'range' | 'multirange' | 'hidden';
|
|
63
|
+
/** voor type 'number', 'time', 'range' en 'multirange' kan er een step-grootte worden opgegeven */
|
|
64
|
+
step?: number;
|
|
65
|
+
/** autocomplete voor gebruik met wachtwoorden, usernames & wachtwoordmanagers */
|
|
66
|
+
autocomplete?: 'on' | 'off' | 'current-password' | 'new-password' | 'username' | undefined;
|
|
67
|
+
/** voor een <select> input: welke options moeten er zijn */
|
|
68
|
+
selectOptions?: string[] | SelectOptionType[] | SelectOptionGroupType[];
|
|
69
|
+
};
|
|
70
|
+
/** Props voor het Button-object van de Form-component */
|
|
71
|
+
export declare type FormBuilderButton = {
|
|
72
|
+
/** tekst op de button */
|
|
73
|
+
txt: string;
|
|
74
|
+
/** moet de formdata gevalideert zijn voor je de button kan gebruiken? */
|
|
75
|
+
mustValidate?: boolean;
|
|
76
|
+
/** button type <button type="..." */
|
|
77
|
+
type: 'submit' | 'reset' | 'button';
|
|
78
|
+
/** button color: s: success-button, d: danger-button, n: primarycolor button */
|
|
79
|
+
color?: ColorProp;
|
|
80
|
+
/** wat als er op de button geklikt wordt? (optional) */
|
|
81
|
+
onClick(e: MouseEvent): any | void;
|
|
82
|
+
};
|
|
83
|
+
export declare type ChangedValue = {
|
|
84
|
+
/** nieuwe waarde */
|
|
85
|
+
new: number | number[] | string | string[] | boolean | null | undefined;
|
|
86
|
+
/** oude waarde */
|
|
87
|
+
old: number | number[] | string | string[] | boolean | null | undefined;
|
|
88
|
+
/** is de waarde valid */
|
|
89
|
+
valid: boolean;
|
|
90
|
+
/** wat is de naam van het gewijzigde field */
|
|
91
|
+
name: string;
|
|
92
|
+
};
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
3
3
|
import { SizeProp } from '../../../loon-react-bulma-types';
|
|
4
4
|
import { BaseInputProps, InputTypeProp } from '../BaseInputProps';
|
|
5
|
-
declare type
|
|
5
|
+
declare type InputValueType = string | number | readonly string[] | undefined;
|
|
6
|
+
declare type BasicInputProps<T extends InputValueType> = BaseInputProps<T> & {
|
|
6
7
|
icon?: string | IconProp | any;
|
|
7
8
|
/** type van de tekst input (default = 'text') */
|
|
8
|
-
type
|
|
9
|
+
type: InputTypeProp;
|
|
9
10
|
/** start value voor deze input (optioneel) */
|
|
10
|
-
value?:
|
|
11
|
-
/** speciaal voor password-managers. Wat is de functie van deze input */
|
|
11
|
+
value?: T;
|
|
12
|
+
/** speciaal voor autocomplete-managers, zoals password-managers. Wat is de functie van deze input */
|
|
12
13
|
autocomplete?: 'on' | 'off' | 'current-password' | 'new-password' | 'username' | 'given-name' | 'additional-name' | 'family-name' | 'nickname' | 'email' | 'name' | 'one-time-code' | 'organization' | 'street-address' | 'tel' | 'bday' | 'language' | 'country' | 'postal-code' | string;
|
|
13
14
|
/** grootte input (optioneel) */
|
|
14
15
|
size?: SizeProp;
|
|
@@ -17,13 +18,14 @@ declare type BasicInputProps = BaseInputProps & {
|
|
|
17
18
|
* @param newVal: de nieuwe waarde
|
|
18
19
|
* @param valid: is de nieuwe waarde geldig?
|
|
19
20
|
*/
|
|
20
|
-
onValueChanged?(newVal:
|
|
21
|
+
onValueChanged?(newVal: T, isValid?: boolean): any | void;
|
|
21
22
|
};
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
+
* Input met alle gewone <input> properties zelf in te vullen.
|
|
25
|
+
* LET OP: Voor validatie kan ALLEEN de onValidate() function gebruikt
|
|
24
26
|
* @param props
|
|
25
|
-
* @returns <input type="
|
|
27
|
+
* @returns <input type="...">
|
|
26
28
|
*/
|
|
27
|
-
declare
|
|
29
|
+
declare function BasicInput<T extends InputValueType>(props: BasicInputProps<T>): JSX.Element;
|
|
28
30
|
export { BasicInput };
|
|
29
|
-
export type { BasicInputProps };
|
|
31
|
+
export type { BasicInputProps, InputValueType };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,8 +47,8 @@ export { Link, LinkButton } from './components/Link/Link';
|
|
|
47
47
|
export type { LinkProps, LinkButtonProps } from './components/Link/Link';
|
|
48
48
|
export { Form } from './components/Form/Form';
|
|
49
49
|
export type { FormProps } from './components/Form/Form';
|
|
50
|
-
export { FormBuilder } from './components/Form/FormBuilder';
|
|
51
|
-
export type { FormBuilderProps, FormBuilderFieldProps, FormBuilderButton } from './components/Form/FormBuilderProps';
|
|
50
|
+
export { FormBuilder } from './components/Form/FormBuilder/FormBuilder';
|
|
51
|
+
export type { FormBuilderProps, FormBuilderFieldProps, FormBuilderButton, } from './components/Form/FormBuilder/FormBuilderProps';
|
|
52
52
|
export { CheckBox } from './components/Form/Checkbox/Checkbox';
|
|
53
53
|
export type { CheckboxInputProps } from './components/Form/Checkbox/Checkbox';
|
|
54
54
|
export type { SelectOptionGroupType, SelectOptionType } from './components/Form/Selects/BaseSelectProps';
|
|
@@ -61,7 +61,7 @@ export type { ColorInputProps } from './components/Form/Others/ColorInput';
|
|
|
61
61
|
export { HiddenInput } from './components/Form/Others/HiddenInput';
|
|
62
62
|
export type { HiddenInputProps } from './components/Form/Others/HiddenInput';
|
|
63
63
|
export { BasicInput } from './components/Form/Others/BasicInput';
|
|
64
|
-
export type { BasicInputProps } from './components/Form/Others/BasicInput';
|
|
64
|
+
export type { BasicInputProps, InputValueType } from './components/Form/Others/BasicInput';
|
|
65
65
|
export { EmailInput } from './components/Form/Text/EmailInput';
|
|
66
66
|
export type { EmailInputProps } from './components/Form/Text/EmailInput';
|
|
67
67
|
export { PasswordInput } from './components/Form/Text/PasswordInput';
|
|
@@ -82,6 +82,8 @@ export { DateTimeInput } from './components/Form/Datetimes/DateTimeInput';
|
|
|
82
82
|
export type { DateTimeInputProps } from './components/Form/Datetimes/DateTimeInput';
|
|
83
83
|
export { TimeInput } from './components/Form/Datetimes/TimeInput';
|
|
84
84
|
export type { TimeInputProps } from './components/Form/Datetimes/TimeInput';
|
|
85
|
+
export { FileInput } from './components/Form/File/FileInput';
|
|
86
|
+
export type { FileInputProps } from './components/Form/File/FileInput';
|
|
85
87
|
export { NotifierProvider, useNotifier } from './contexts/Notifier/NotifierProvider';
|
|
86
88
|
export type { NotifierItemProps } from './contexts/Notifier/NotifierProps';
|
|
87
89
|
export { Calendar } from './components/Calendar';
|
package/dist/index.js
CHANGED
|
@@ -3893,7 +3893,7 @@ function validate$d(value, desc, type, validation) {
|
|
|
3893
3893
|
return '';
|
|
3894
3894
|
}
|
|
3895
3895
|
|
|
3896
|
-
|
|
3896
|
+
function reducer$e(state, action) {
|
|
3897
3897
|
switch (action.type) {
|
|
3898
3898
|
case 'SET':
|
|
3899
3899
|
var invalidMsg = validate$e(action.value, action.validation);
|
|
@@ -3917,17 +3917,17 @@ var reducer$e = function reducer(state, action) {
|
|
|
3917
3917
|
touched: action.touched
|
|
3918
3918
|
});
|
|
3919
3919
|
}
|
|
3920
|
-
}
|
|
3920
|
+
}
|
|
3921
3921
|
|
|
3922
|
-
|
|
3923
|
-
var _props$label, _props$value, _props$
|
|
3922
|
+
function BasicInput(props) {
|
|
3923
|
+
var _props$label, _props$value, _props$label2, _props$id, _props$direction, _props$id2, _props$validation, _props$keyboardType;
|
|
3924
3924
|
|
|
3925
3925
|
var _useReducer = React.useReducer(reducer$e, {
|
|
3926
3926
|
description: (_props$label = props.label) != null ? _props$label : props.name,
|
|
3927
3927
|
value: (_props$value = props.value) != null ? _props$value : '',
|
|
3928
3928
|
invalidMsg: '',
|
|
3929
3929
|
valid: false,
|
|
3930
|
-
type:
|
|
3930
|
+
type: props.type == 'datetime' ? 'datetime-local' : props.type,
|
|
3931
3931
|
touched: false,
|
|
3932
3932
|
validation: props.validation
|
|
3933
3933
|
}),
|
|
@@ -3981,7 +3981,7 @@ var BasicInput = function BasicInput(props) {
|
|
|
3981
3981
|
required: (_props$validation = props.validation) === null || _props$validation === void 0 ? void 0 : _props$validation.required,
|
|
3982
3982
|
className: classes,
|
|
3983
3983
|
onBlur: function onBlur() {
|
|
3984
|
-
return
|
|
3984
|
+
return dispatch({
|
|
3985
3985
|
type: 'TOUCH',
|
|
3986
3986
|
touched: true
|
|
3987
3987
|
});
|
|
@@ -4004,17 +4004,156 @@ var BasicInput = function BasicInput(props) {
|
|
|
4004
4004
|
}), state.valid && state.touched && React__default.createElement(reactFontawesome.FontAwesomeIcon, {
|
|
4005
4005
|
icon: freeSolidSvgIcons.faCheck
|
|
4006
4006
|
}))));
|
|
4007
|
-
}
|
|
4007
|
+
}
|
|
4008
4008
|
|
|
4009
4009
|
function validate$e(value, validation) {
|
|
4010
|
-
|
|
4011
|
-
|
|
4010
|
+
if (validation !== null && validation !== void 0 && validation.onValidate) return validation.onValidate(value);
|
|
4011
|
+
return '';
|
|
4012
|
+
}
|
|
4013
|
+
|
|
4014
|
+
var reducer$f = function reducer(state, action) {
|
|
4015
|
+
switch (action.type) {
|
|
4016
|
+
case 'SET':
|
|
4017
|
+
var invalidMsg = validate$f(action.files, state.description, action.validation);
|
|
4018
|
+
return _extends({}, state, {
|
|
4019
|
+
value: action.value,
|
|
4020
|
+
filename: action.filename,
|
|
4021
|
+
files: action.files,
|
|
4022
|
+
validation: action.validation,
|
|
4023
|
+
invalidMsg: invalidMsg,
|
|
4024
|
+
valid: invalidMsg == ''
|
|
4025
|
+
});
|
|
4026
|
+
|
|
4027
|
+
case 'CHANGE':
|
|
4028
|
+
return _extends({}, state, {
|
|
4029
|
+
value: action.value,
|
|
4030
|
+
filename: action.filename,
|
|
4031
|
+
files: action.files,
|
|
4032
|
+
touched: true,
|
|
4033
|
+
invalidMsg: action.invalidMsg,
|
|
4034
|
+
valid: action.invalidMsg == ''
|
|
4035
|
+
});
|
|
4036
|
+
|
|
4037
|
+
case 'TOUCH':
|
|
4038
|
+
return _extends({}, state, {
|
|
4039
|
+
touched: action.touched
|
|
4040
|
+
});
|
|
4041
|
+
}
|
|
4042
|
+
};
|
|
4043
|
+
|
|
4044
|
+
var FileInput = function FileInput(props) {
|
|
4045
|
+
var _props$label, _props$value, _props$label2, _props$id, _props$direction, _props$id2, _props$validation, _props$keyboardType, _props$kiesLabel, _ref, _state$filename;
|
|
4046
|
+
|
|
4047
|
+
var _React$useReducer = React__default.useReducer(reducer$f, {
|
|
4048
|
+
description: (_props$label = props.label) != null ? _props$label : props.name,
|
|
4049
|
+
value: (_props$value = props.value) != null ? _props$value : '',
|
|
4050
|
+
filename: '',
|
|
4051
|
+
invalidMsg: '',
|
|
4052
|
+
files: undefined,
|
|
4053
|
+
valid: false,
|
|
4054
|
+
touched: false,
|
|
4055
|
+
validation: props.validation
|
|
4056
|
+
}),
|
|
4057
|
+
state = _React$useReducer[0],
|
|
4058
|
+
dispatch = _React$useReducer[1];
|
|
4059
|
+
|
|
4060
|
+
var fileClasses = 'file has-name';
|
|
4061
|
+
if (props.boxed) fileClasses += ' is-boxed';else fileClasses += ' is-fullwidth';
|
|
4062
|
+
if (props.size == 's') fileClasses += ' is-small';else if (props.size == 'l') fileClasses += ' is-medium';else if (props.size == 'xl') fileClasses += ' is-large';
|
|
4063
|
+
|
|
4064
|
+
var handleChange = function handleChange(path, files) {
|
|
4065
|
+
if (!props.disabled) {
|
|
4066
|
+
var validationError = validate$f(files, state.description, state.validation);
|
|
4067
|
+
var filename = props.filenameFormatter ? props.filenameFormatter(path, files) : defaultFilenameFormatter(path);
|
|
4068
|
+
props.onValueChanged && props.onValueChanged(files, validationError == '');
|
|
4069
|
+
dispatch({
|
|
4070
|
+
type: 'CHANGE',
|
|
4071
|
+
value: path,
|
|
4072
|
+
filename: filename,
|
|
4073
|
+
files: files,
|
|
4074
|
+
invalidMsg: validationError
|
|
4075
|
+
});
|
|
4076
|
+
}
|
|
4077
|
+
};
|
|
4078
|
+
|
|
4079
|
+
var defaultFilenameFormatter = React__default.useCallback(function (path) {
|
|
4080
|
+
return path.replace(/^.*[\\/]/, '');
|
|
4081
|
+
}, []);
|
|
4082
|
+
React__default.useEffect(function () {
|
|
4083
|
+
var _props$value2;
|
|
4084
|
+
|
|
4085
|
+
dispatch({
|
|
4086
|
+
type: 'SET',
|
|
4087
|
+
value: (_props$value2 = props.value) != null ? _props$value2 : '',
|
|
4088
|
+
filename: '',
|
|
4089
|
+
files: undefined,
|
|
4090
|
+
validation: props.validation
|
|
4091
|
+
});
|
|
4092
|
+
}, [props.value, props.validation]);
|
|
4093
|
+
var label = {
|
|
4094
|
+
txt: (_props$label2 = props.label) != null ? _props$label2 : props.name,
|
|
4095
|
+
id: (_props$id = props.id) != null ? _props$id : props.name
|
|
4096
|
+
};
|
|
4097
|
+
var error = !state.valid && state.touched ? React__default.createElement("p", {
|
|
4098
|
+
className: "help is-danger pl-3"
|
|
4099
|
+
}, state.invalidMsg) : null;
|
|
4100
|
+
return React__default.createElement(InputContainer, {
|
|
4101
|
+
size: props.size,
|
|
4102
|
+
label: label,
|
|
4103
|
+
error: error,
|
|
4104
|
+
direction: (_props$direction = props.direction) != null ? _props$direction : 'horizontal'
|
|
4105
|
+
}, React__default.createElement("div", {
|
|
4106
|
+
className: fileClasses
|
|
4107
|
+
}, React__default.createElement("label", {
|
|
4108
|
+
className: "file-label"
|
|
4109
|
+
}, React__default.createElement("input", {
|
|
4110
|
+
id: (_props$id2 = props.id) != null ? _props$id2 : props.name,
|
|
4111
|
+
accept: props.accept,
|
|
4112
|
+
capture: props.capture,
|
|
4113
|
+
multiple: props.multiple,
|
|
4114
|
+
name: props.name,
|
|
4115
|
+
value: state.value,
|
|
4116
|
+
required: (_props$validation = props.validation) === null || _props$validation === void 0 ? void 0 : _props$validation.required,
|
|
4117
|
+
className: "file-input",
|
|
4118
|
+
onBlur: function onBlur() {
|
|
4119
|
+
return !state.touched && dispatch({
|
|
4120
|
+
type: 'TOUCH',
|
|
4121
|
+
touched: true
|
|
4122
|
+
});
|
|
4123
|
+
},
|
|
4124
|
+
onChange: function onChange(e) {
|
|
4125
|
+
return handleChange(e.target.value, e.target.files);
|
|
4126
|
+
},
|
|
4127
|
+
type: "file",
|
|
4128
|
+
inputMode: (_props$keyboardType = props.keyboardType) != null ? _props$keyboardType : 'text',
|
|
4129
|
+
placeholder: props.placeholder,
|
|
4130
|
+
disabled: props.disabled
|
|
4131
|
+
}), React__default.createElement("span", {
|
|
4132
|
+
className: "file-cta"
|
|
4133
|
+
}, props.icon && typeof props.icon != 'string' && React__default.createElement("span", {
|
|
4134
|
+
className: "file-icon"
|
|
4135
|
+
}, React__default.createElement(reactFontawesome.FontAwesomeIcon, {
|
|
4136
|
+
icon: props.icon
|
|
4137
|
+
})), props.icon && typeof props.icon == 'string' && React__default.createElement("span", {
|
|
4138
|
+
className: "file-icon",
|
|
4139
|
+
role: "icon"
|
|
4140
|
+
}, React__default.createElement("i", {
|
|
4141
|
+
className: props.icon
|
|
4142
|
+
})), React__default.createElement("span", {
|
|
4143
|
+
className: "file-label"
|
|
4144
|
+
}, (_props$kiesLabel = props.kiesLabel) != null ? _props$kiesLabel : props.name)), React__default.createElement("span", {
|
|
4145
|
+
className: "file-name"
|
|
4146
|
+
}, (_ref = (_state$filename = state.filename) != null ? _state$filename : props.nogGeenBestandLabel) != null ? _ref : ''))));
|
|
4147
|
+
};
|
|
4148
|
+
|
|
4149
|
+
function validate$f(value, desc, validation) {
|
|
4150
|
+
if (validation !== null && validation !== void 0 && validation.required && (!value || value.length < 1)) return desc + " is verplicht";else if (validation !== null && validation !== void 0 && validation.onValidate) return validation.onValidate(value);
|
|
4012
4151
|
return '';
|
|
4013
4152
|
}
|
|
4014
4153
|
|
|
4015
4154
|
var Form = function Form(props) {
|
|
4016
4155
|
var allowedContent = React__default.useMemo(function () {
|
|
4017
|
-
return [TextInput, TextArea, PasswordInput, EmailInput, Select, MultiSelect, ColorInput, HiddenInput, NumberInput, RangeInput, MultiRangeInput, DateInput, DateTimeInput, TimeInput, CheckBox, BasicInput];
|
|
4156
|
+
return [TextInput, TextArea, PasswordInput, EmailInput, Select, MultiSelect, ColorInput, HiddenInput, NumberInput, RangeInput, MultiRangeInput, DateInput, DateTimeInput, TimeInput, CheckBox, BasicInput, FileInput];
|
|
4018
4157
|
}, []);
|
|
4019
4158
|
var action = props.action,
|
|
4020
4159
|
method = props.method,
|
|
@@ -4030,10 +4169,17 @@ var Form = function Form(props) {
|
|
|
4030
4169
|
children: child.props.children,
|
|
4031
4170
|
direction: direction,
|
|
4032
4171
|
size: size
|
|
4033
|
-
});else if (
|
|
4172
|
+
});else if (child.type === Buttons) return React__default.createElement(InputContainer, {
|
|
4173
|
+
direction: direction != null ? direction : 'horizontal'
|
|
4174
|
+
}, React__default.createElement(ButtonGroup, Object.assign({
|
|
4175
|
+
size: size
|
|
4176
|
+
}, child.props)));else if (child.type === FreeSpace) return React__default.createElement(InternFreeSpace, Object.assign({}, child.props, {
|
|
4177
|
+
direction: direction,
|
|
4178
|
+
size: size
|
|
4179
|
+
}));else if (allowedContent.includes(child.type)) return React__default.createElement(child.type, Object.assign({}, child.props, {
|
|
4034
4180
|
direction: direction,
|
|
4035
4181
|
size: size
|
|
4036
|
-
}));else if (typeof child == 'string') console.warn("<Form> should only contain children of type: <Form.XXX /> or <...Input> elements. You passed <" + child + "
|
|
4182
|
+
}));else if (typeof child == 'string') console.warn("<Form> should only contain children of type: <Form.XXX /> or <...Input> elements. You passed a string (\"" + child + "\"), which will be ignored");else if (typeof child.type == 'string') console.warn("<Form> should only contain children of type: <Form.XXX /> or <...Input> elements. You passed a HTMLElement (<" + child.type + ">), which will be ignored");else if (typeof child.type.name == 'string') console.warn("<Form> should only contain children of type: <Form.XXX /> or <...Input> elements. You passed a Component (<" + child.type.name + ">), which will be ignored");
|
|
4037
4183
|
return null;
|
|
4038
4184
|
});
|
|
4039
4185
|
return React__default.createElement("form", {
|
|
@@ -4047,8 +4193,9 @@ var Form = function Form(props) {
|
|
|
4047
4193
|
}, children);
|
|
4048
4194
|
};
|
|
4049
4195
|
|
|
4050
|
-
var FormLine = function FormLine(
|
|
4051
|
-
|
|
4196
|
+
var FormLine = function FormLine(_ref) {
|
|
4197
|
+
var children = _ref.children;
|
|
4198
|
+
return React__default.createElement("div", null, children);
|
|
4052
4199
|
};
|
|
4053
4200
|
|
|
4054
4201
|
var InternalFormLine = function InternalFormLine(props) {
|
|
@@ -4069,6 +4216,30 @@ var InternalFormLine = function InternalFormLine(props) {
|
|
|
4069
4216
|
})));
|
|
4070
4217
|
};
|
|
4071
4218
|
|
|
4219
|
+
var FreeSpace = function FreeSpace(_ref2) {
|
|
4220
|
+
var children = _ref2.children;
|
|
4221
|
+
return React__default.createElement("div", null, children);
|
|
4222
|
+
};
|
|
4223
|
+
|
|
4224
|
+
var InternFreeSpace = function InternFreeSpace(_ref3) {
|
|
4225
|
+
var children = _ref3.children,
|
|
4226
|
+
direction = _ref3.direction,
|
|
4227
|
+
size = _ref3.size;
|
|
4228
|
+
return React__default.createElement(InputContainer, {
|
|
4229
|
+
direction: direction,
|
|
4230
|
+
size: size
|
|
4231
|
+
}, children);
|
|
4232
|
+
};
|
|
4233
|
+
|
|
4234
|
+
var Buttons = function Buttons(_ref4) {
|
|
4235
|
+
var children = _ref4.children,
|
|
4236
|
+
size = _ref4.size,
|
|
4237
|
+
alignment = _ref4.alignment;
|
|
4238
|
+
return React__default.createElement("div", {
|
|
4239
|
+
className: "buttons"
|
|
4240
|
+
}, children, size, alignment);
|
|
4241
|
+
};
|
|
4242
|
+
|
|
4072
4243
|
Form.Input = BasicInput;
|
|
4073
4244
|
Form.Text = TextInput;
|
|
4074
4245
|
Form.Password = PasswordInput;
|
|
@@ -4085,9 +4256,12 @@ Form.Date = DateInput;
|
|
|
4085
4256
|
Form.DateTime = DateTimeInput;
|
|
4086
4257
|
Form.Time = TimeInput;
|
|
4087
4258
|
Form.CheckBox = CheckBox;
|
|
4259
|
+
Form.File = FileInput;
|
|
4088
4260
|
Form.Line = FormLine;
|
|
4261
|
+
Form.Space = FreeSpace;
|
|
4262
|
+
Form.Buttons = Buttons;
|
|
4089
4263
|
|
|
4090
|
-
var reducer$
|
|
4264
|
+
var reducer$g = function reducer(state, action) {
|
|
4091
4265
|
switch (action.type) {
|
|
4092
4266
|
case 'SET':
|
|
4093
4267
|
return _extends({}, state, {
|
|
@@ -4113,7 +4287,7 @@ var reducer$f = function reducer(state, action) {
|
|
|
4113
4287
|
};
|
|
4114
4288
|
|
|
4115
4289
|
function FormBuilder(props) {
|
|
4116
|
-
var _useReducer = React.useReducer(reducer$
|
|
4290
|
+
var _useReducer = React.useReducer(reducer$g, {
|
|
4117
4291
|
valid: false,
|
|
4118
4292
|
loading: false,
|
|
4119
4293
|
method: props.method,
|
|
@@ -5448,6 +5622,7 @@ exports.DataTable = DataTable;
|
|
|
5448
5622
|
exports.DateInput = DateInput;
|
|
5449
5623
|
exports.DateTimeInput = DateTimeInput;
|
|
5450
5624
|
exports.EmailInput = EmailInput;
|
|
5625
|
+
exports.FileInput = FileInput;
|
|
5451
5626
|
exports.Footer = Footer;
|
|
5452
5627
|
exports.Form = Form;
|
|
5453
5628
|
exports.FormBuilder = FormBuilder;
|