@ainias42/react-bootstrap-mobile 0.1.28 → 0.1.29
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/bin/updateCopies.js +2 -0
- package/dist/bootstrapReactMobile.js +59 -42
- package/dist/bootstrapReactMobile.js.map +1 -1
- package/dist/src/Components/FormElements/Input/Input.d.ts +11 -3
- package/dist/src/Components/FormElements/Input/PasswordInput/PasswordInput.d.ts +4 -1
- package/dist/src/Components/FullScreen/FullScreen.d.ts +1 -3
- package/dist/src/Components/Text/Text.d.ts +2 -1
- package/package.json +1 -1
- package/src/Components/Dialog/dialogBackground.scss +2 -0
- package/src/Components/FormElements/CheckBox/Checkbox.tsx +0 -1
- package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +4 -3
- package/src/Components/FormElements/Input/Input.tsx +121 -73
- package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +5 -6
- package/src/Components/FullScreen/FullScreen.tsx +2 -5
- package/src/Components/Layout/Grid/Grid.tsx +0 -1
- package/src/Components/Text/Text.tsx +3 -2
- package/src/Components/Text/text.scss +4 -0
|
@@ -2,10 +2,18 @@ import { InputHTMLAttributes } from 'react';
|
|
|
2
2
|
import { RbmComponentProps } from '../../RbmComponentProps';
|
|
3
3
|
import { Override } from '../../../TypeHelpers';
|
|
4
4
|
import { OptionalListener } from '../../Hooks/useListener';
|
|
5
|
-
|
|
5
|
+
type InputTypes = 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week';
|
|
6
|
+
export type InputProps<OnChangeData, OnBlurData, OnChangeDoneData> = RbmComponentProps<Override<Omit<InputHTMLAttributes<HTMLInputElement>, 'onInput' | "type">, {
|
|
6
7
|
label?: string;
|
|
8
|
+
inline?: boolean;
|
|
9
|
+
} & OptionalListener<'onChange', OnChangeData> & OptionalListener<'onBlur', OnBlurData> & OptionalListener<'onChangeDone', OnChangeDoneData> & ({
|
|
10
|
+
type?: InputTypes;
|
|
7
11
|
onChangeText?: (newText: string) => void;
|
|
8
12
|
onEnter?: (newText: string) => void;
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
} | {
|
|
14
|
+
type: "number";
|
|
15
|
+
onChangeText?: (newNumber: number) => void;
|
|
16
|
+
onEnter?: (newNumber: number) => void;
|
|
17
|
+
})>>;
|
|
11
18
|
export declare const Input: import("../../../helper/withForwardRef").RefComponent<InputProps<unknown, unknown, unknown>, HTMLInputElement>;
|
|
19
|
+
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { InputProps } from '../Input';
|
|
2
2
|
import { DistributiveOmit } from '../../../../helper/DistributiveOmit';
|
|
3
|
-
export type PasswordInputProps<OnChangeData, OnBlurData, OnChangeEndData> = DistributiveOmit<InputProps<OnChangeData, OnBlurData, OnChangeEndData>, 'type'
|
|
3
|
+
export type PasswordInputProps<OnChangeData, OnBlurData, OnChangeEndData> = DistributiveOmit<InputProps<OnChangeData, OnBlurData, OnChangeEndData>, 'type' | "onChangeText" | "onEnter"> & {
|
|
4
|
+
onChangeText?: (newText: string) => void;
|
|
5
|
+
onEnter?: (newText: string) => void;
|
|
6
|
+
};
|
|
4
7
|
export declare const PasswordInput: import("../../../../helper/withForwardRef").RefComponent<PasswordInputProps<unknown, unknown, unknown>, HTMLInputElement>;
|
|
@@ -8,6 +8,4 @@ export type FullScreenProps<AsType extends keyof JSX.IntrinsicElements> = RbmCom
|
|
|
8
8
|
onEnterFullscreen?: () => void;
|
|
9
9
|
onLeaveFullscreen?: () => void;
|
|
10
10
|
}>>;
|
|
11
|
-
declare
|
|
12
|
-
declare const FullScreenMemo: typeof FullScreen;
|
|
13
|
-
export { FullScreenMemo as FullScreen };
|
|
11
|
+
export declare const FullScreen: <AsTag extends keyof JSX.IntrinsicElements = "span">({ children, as, fullscreenKey, onEnterFullscreen, onLeaveFullscreen, ...otherProps }: FullScreenProps<AsTag>) => React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
@@ -19,9 +19,10 @@ export type TextProps<AsType extends keyof JSX.IntrinsicElements> = {
|
|
|
19
19
|
block?: boolean;
|
|
20
20
|
prio?: ValueOf<typeof TEXT_PRIO>;
|
|
21
21
|
size?: ValueOf<typeof TEXT_SIZE>;
|
|
22
|
+
emphasized?: boolean;
|
|
22
23
|
className?: string;
|
|
23
24
|
children: Recursive<string | undefined | null | number>;
|
|
24
25
|
} & ViewProps<AsType>;
|
|
25
|
-
declare function Text<AsType extends keyof JSX.IntrinsicElements = 'span'>({ className, children, block, prio, size, as, ...props }: TextProps<AsType>): React.JSX.Element;
|
|
26
|
+
declare function Text<AsType extends keyof JSX.IntrinsicElements = 'span'>({ className, children, block, prio, emphasized, size, as, ...props }: TextProps<AsType>): React.JSX.Element;
|
|
26
27
|
declare const tmp: typeof Text;
|
|
27
28
|
export { tmp as Text };
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RbmComponentProps } from '../../RbmComponentProps';
|
|
3
3
|
import { ChangeEventHandler, InputHTMLAttributes, useCallback } from 'react';
|
|
4
|
-
|
|
5
4
|
import styles from './checkbox.scss';
|
|
6
5
|
import { withMemo } from '../../../helper/withMemo';
|
|
7
6
|
import classNames from 'classnames';
|
|
@@ -235,8 +235,9 @@ export const MultipleFileInput = withMemo(function MultipleImageInput<OnChangeDa
|
|
|
235
235
|
)}
|
|
236
236
|
</Flex>
|
|
237
237
|
<Flex horizontal={true} className={styles.previewContainer}>
|
|
238
|
-
{value?.map((file, index) =>
|
|
239
|
-
|
|
238
|
+
{value?.map((file, index) => {
|
|
239
|
+
console.log("LOG-d file", file);
|
|
240
|
+
return <Grow className={styles.preview} center={true} key={file.data}>
|
|
240
241
|
<Clickable
|
|
241
242
|
onDrop={onDrop}
|
|
242
243
|
onDragOver={onDragOver}
|
|
@@ -252,7 +253,7 @@ export const MultipleFileInput = withMemo(function MultipleImageInput<OnChangeDa
|
|
|
252
253
|
</Clickable>}
|
|
253
254
|
</Clickable>
|
|
254
255
|
</Grow>
|
|
255
|
-
)
|
|
256
|
+
})}
|
|
256
257
|
<Grow className={classNames(styles.addFile, {[styles.hidden]: value.length >= maxFiles})} center={true}>
|
|
257
258
|
<Clickable
|
|
258
259
|
className={styles.addFileButton}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ChangeEventHandler, InputHTMLAttributes, KeyboardEvent, MutableRefObject, useCallback } from 'react';
|
|
2
|
+
import { ChangeEventHandler, InputHTMLAttributes, KeyboardEvent, MutableRefObject, useCallback, useRef } from 'react';
|
|
3
3
|
import { RbmComponentProps } from '../../RbmComponentProps';
|
|
4
4
|
import { Override } from '../../../TypeHelpers';
|
|
5
5
|
import { OptionalListener, useListenerWithExtractedProps } from '../../Hooks/useListener';
|
|
@@ -10,95 +10,143 @@ import classNames from 'classnames';
|
|
|
10
10
|
import { useComposedRef } from '../../Hooks/useComposedRef';
|
|
11
11
|
import { useOnChangeDone } from '../hooks/useOnChangeDone';
|
|
12
12
|
|
|
13
|
+
type InputTypes =
|
|
14
|
+
| 'button'
|
|
15
|
+
| 'checkbox'
|
|
16
|
+
| 'color'
|
|
17
|
+
| 'date'
|
|
18
|
+
| 'datetime-local'
|
|
19
|
+
| 'email'
|
|
20
|
+
| 'file'
|
|
21
|
+
| 'hidden'
|
|
22
|
+
| 'image'
|
|
23
|
+
| 'month'
|
|
24
|
+
| 'password'
|
|
25
|
+
| 'radio'
|
|
26
|
+
| 'range'
|
|
27
|
+
| 'reset'
|
|
28
|
+
| 'search'
|
|
29
|
+
| 'submit'
|
|
30
|
+
| 'tel'
|
|
31
|
+
| 'text'
|
|
32
|
+
| 'time'
|
|
33
|
+
| 'url'
|
|
34
|
+
| 'week';
|
|
35
|
+
|
|
13
36
|
export type InputProps<OnChangeData, OnBlurData, OnChangeDoneData> = RbmComponentProps<
|
|
14
37
|
Override<
|
|
15
|
-
Omit<InputHTMLAttributes<HTMLInputElement>, 'onInput'>,
|
|
38
|
+
Omit<InputHTMLAttributes<HTMLInputElement>, 'onInput' | "type">,
|
|
16
39
|
{
|
|
17
40
|
label?: string;
|
|
18
|
-
onChangeText?: (newText: string) => void;
|
|
19
|
-
onEnter?: (newText: string) => void;
|
|
20
41
|
inline?: boolean
|
|
21
42
|
} & OptionalListener<'onChange', OnChangeData> &
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
OptionalListener<'onBlur', OnBlurData> &
|
|
44
|
+
OptionalListener<'onChangeDone', OnChangeDoneData>
|
|
45
|
+
& ({
|
|
46
|
+
type?: InputTypes
|
|
47
|
+
onChangeText?: (newText: string) => void;
|
|
48
|
+
onEnter?: (newText: string) => void;
|
|
49
|
+
} | {
|
|
50
|
+
type: "number"
|
|
51
|
+
onChangeText?: (newNumber: number) => void;
|
|
52
|
+
onEnter?: (newNumber: number) => void;
|
|
53
|
+
})
|
|
24
54
|
>
|
|
25
55
|
>;
|
|
26
56
|
|
|
27
57
|
export const Input = withForwardRef(function Input<OnChangeData, OnBlurData, OnChangeDoneData>(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
{
|
|
59
|
+
label,
|
|
60
|
+
className,
|
|
61
|
+
style,
|
|
62
|
+
onKeyDown,
|
|
63
|
+
inline = false,
|
|
64
|
+
...otherProps
|
|
65
|
+
}: InputProps<OnChangeData, OnBlurData, OnChangeDoneData>,
|
|
66
|
+
ref: MutableRefObject<HTMLInputElement> | null
|
|
67
|
+
) {
|
|
68
|
+
// Variables
|
|
69
|
+
|
|
70
|
+
// States
|
|
41
71
|
|
|
42
|
-
|
|
72
|
+
// Refs
|
|
73
|
+
const innerRef = useComposedRef(ref);
|
|
74
|
+
const lastValueRef = useRef(NaN);
|
|
43
75
|
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
// Callbacks
|
|
77
|
+
const [onChangeWithData, otherPropsWithoutOnchange] = useListenerWithExtractedProps<'onChange', OnChangeData>(
|
|
78
|
+
'onChange',
|
|
79
|
+
otherProps
|
|
80
|
+
);
|
|
81
|
+
const onChange = useCallback<ChangeEventHandler<HTMLInputElement>>(
|
|
82
|
+
(e) => {
|
|
83
|
+
if (otherProps.onChangeText) {
|
|
84
|
+
if (otherProps.type === "number") {
|
|
85
|
+
if (Number.isNaN(e.target.valueAsNumber)){
|
|
86
|
+
otherProps.onChangeText(lastValueRef.current);
|
|
87
|
+
} else {
|
|
88
|
+
otherProps.onChangeText(e.target.valueAsNumber);
|
|
89
|
+
lastValueRef.current = e.target.valueAsNumber;
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
otherProps.onChangeText(e.target.value);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
onChangeWithData(e);
|
|
96
|
+
},
|
|
97
|
+
[onChangeWithData, otherProps.onChangeText, otherProps.type]
|
|
98
|
+
);
|
|
46
99
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
const onChange = useCallback<ChangeEventHandler<HTMLInputElement>>(
|
|
53
|
-
(e) => {
|
|
54
|
-
if (onChangeText) {
|
|
55
|
-
onChangeText(e.target.value);
|
|
56
|
-
}
|
|
57
|
-
onChangeWithData(e);
|
|
58
|
-
},
|
|
59
|
-
[onChangeWithData, onChangeText]
|
|
60
|
-
);
|
|
100
|
+
const [onBlur, otherPropsWithoutBlur] = useListenerWithExtractedProps<'onBlur', OnBlurData>(
|
|
101
|
+
'onBlur',
|
|
102
|
+
otherPropsWithoutOnchange
|
|
103
|
+
);
|
|
61
104
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
105
|
+
const [onChangeDone, otherPropsWithoutData] = useListenerWithExtractedProps<'onChangeDone', OnChangeDoneData>(
|
|
106
|
+
'onChangeDone',
|
|
107
|
+
otherPropsWithoutBlur
|
|
108
|
+
);
|
|
66
109
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
110
|
+
const realOnKeyDown = useCallback(
|
|
111
|
+
(e: KeyboardEvent<HTMLInputElement>) => {
|
|
112
|
+
onKeyDown?.(e);
|
|
113
|
+
if (otherProps.onEnter && e.key === 'Enter' && !e.defaultPrevented) {
|
|
114
|
+
if (otherProps.type === "number") {
|
|
115
|
+
if (Number.isNaN((e.target as HTMLInputElement).valueAsNumber)){
|
|
116
|
+
otherProps.onEnter(lastValueRef.current);
|
|
117
|
+
} else {
|
|
118
|
+
otherProps.onEnter((e.target as HTMLInputElement).valueAsNumber);
|
|
119
|
+
lastValueRef.current = (e.target as HTMLInputElement).valueAsNumber;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
otherProps.onEnter((e.target as HTMLInputElement).value);
|
|
123
|
+
}
|
|
71
124
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onKeyDown
|
|
75
|
-
|
|
76
|
-
onEnter((e.target as HTMLInputElement).value);
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
[onEnter, onKeyDown]
|
|
80
|
-
);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
[otherProps.onEnter, onKeyDown, otherProps.type]
|
|
128
|
+
);
|
|
81
129
|
|
|
82
|
-
|
|
83
|
-
|
|
130
|
+
// Effects
|
|
131
|
+
useOnChangeDone(onChangeDone, innerRef);
|
|
84
132
|
|
|
85
|
-
|
|
133
|
+
// Other
|
|
86
134
|
|
|
87
|
-
|
|
135
|
+
// Render Functions
|
|
88
136
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
styles);
|
|
137
|
+
return (
|
|
138
|
+
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
139
|
+
<label className={classNames(styles.input, {[styles.inline]: inline}, className)} style={style}>
|
|
140
|
+
{label ? <span className={styles.label}>{label}</span> : null}
|
|
141
|
+
<input
|
|
142
|
+
{...otherPropsWithoutData}
|
|
143
|
+
ref={innerRef}
|
|
144
|
+
className={styles.text}
|
|
145
|
+
onBlur={onBlur}
|
|
146
|
+
onChange={onChange}
|
|
147
|
+
onKeyDown={realOnKeyDown}
|
|
148
|
+
/>
|
|
149
|
+
</label>
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
styles);
|
|
@@ -13,8 +13,11 @@ import classNames from 'classnames';
|
|
|
13
13
|
|
|
14
14
|
export type PasswordInputProps<OnChangeData, OnBlurData, OnChangeEndData> = DistributiveOmit<
|
|
15
15
|
InputProps<OnChangeData, OnBlurData, OnChangeEndData>,
|
|
16
|
-
'type'
|
|
17
|
-
|
|
16
|
+
'type'|"onChangeText"|"onEnter"
|
|
17
|
+
> & {
|
|
18
|
+
onChangeText?: (newText: string) => void;
|
|
19
|
+
onEnter?: (newText: string) => void;
|
|
20
|
+
};
|
|
18
21
|
|
|
19
22
|
export const PasswordInput = withForwardRef(function PasswordInput<OnChangeData, OnBlurData, OnChangeEndData>(
|
|
20
23
|
{ className, style, ...props }: PasswordInputProps<OnChangeData, OnBlurData, OnChangeEndData>,
|
|
@@ -49,7 +52,3 @@ export const PasswordInput = withForwardRef(function PasswordInput<OnChangeData,
|
|
|
49
52
|
);
|
|
50
53
|
},
|
|
51
54
|
styles);
|
|
52
|
-
|
|
53
|
-
// // Need PasswordInputMemo for autocompletion of phpstorm
|
|
54
|
-
// const PasswordInputMemo = withMemo(PasswordInput);
|
|
55
|
-
// export { PasswordInputMemo as PasswordInput };
|
|
@@ -12,7 +12,7 @@ export type FullScreenProps<AsType extends keyof JSX.IntrinsicElements> = RbmCom
|
|
|
12
12
|
>
|
|
13
13
|
>;
|
|
14
14
|
|
|
15
|
-
function FullScreen<AsTag extends keyof JSX.IntrinsicElements = 'span'>({
|
|
15
|
+
export const FullScreen = withMemo(function FullScreen<AsTag extends keyof JSX.IntrinsicElements = 'span'>({
|
|
16
16
|
children,
|
|
17
17
|
as,
|
|
18
18
|
fullscreenKey,
|
|
@@ -77,8 +77,5 @@ function FullScreen<AsTag extends keyof JSX.IntrinsicElements = 'span'>({
|
|
|
77
77
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
78
78
|
// @ts-ignore
|
|
79
79
|
return React.createElement(element, props, children);
|
|
80
|
-
}
|
|
80
|
+
})
|
|
81
81
|
|
|
82
|
-
// Need FullScreenMemo for autocompletion of phpstorm
|
|
83
|
-
const FullScreenMemo = withMemo(FullScreen);
|
|
84
|
-
export { FullScreenMemo as FullScreen };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
|
|
4
3
|
import styles from './text.scss';
|
|
5
4
|
import { Recursive, ValueOf } from '../../TypeHelpers';
|
|
6
5
|
import { WrongChildError } from '../../WrongChildError';
|
|
@@ -28,6 +27,7 @@ export type TextProps<AsType extends keyof JSX.IntrinsicElements> = {
|
|
|
28
27
|
block?: boolean;
|
|
29
28
|
prio?: ValueOf<typeof TEXT_PRIO>;
|
|
30
29
|
size?: ValueOf<typeof TEXT_SIZE>;
|
|
30
|
+
emphasized?: boolean;
|
|
31
31
|
className?: string;
|
|
32
32
|
children: Recursive<string | undefined | null | number>;
|
|
33
33
|
} & ViewProps<AsType>;
|
|
@@ -37,6 +37,7 @@ function Text<AsType extends keyof JSX.IntrinsicElements = 'span'>({
|
|
|
37
37
|
children,
|
|
38
38
|
block = false,
|
|
39
39
|
prio,
|
|
40
|
+
emphasized = false,
|
|
40
41
|
size = TEXT_SIZE.medium,
|
|
41
42
|
as = 'span' as AsType,
|
|
42
43
|
...props
|
|
@@ -69,7 +70,7 @@ function Text<AsType extends keyof JSX.IntrinsicElements = 'span'>({
|
|
|
69
70
|
__allowChildren="text"
|
|
70
71
|
as={as}
|
|
71
72
|
{...props as InlineProps<AsType>}
|
|
72
|
-
className={classNames(styles.text, { [styles.block]: block }, prio, size, className)}
|
|
73
|
+
className={classNames(styles.text, { [styles.block]: block, [styles.emphasized]: emphasized }, prio, size, className)}
|
|
73
74
|
>
|
|
74
75
|
{children}
|
|
75
76
|
</Inline>
|