@ainias42/react-bootstrap-mobile 0.2.0 → 0.2.2
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 +3 -2
- package/bootstrapReactMobile.ts +10 -0
- package/dist/bootstrapReactMobile.d.ts +10 -0
- package/dist/bootstrapReactMobile.js +1187 -606
- package/dist/bootstrapReactMobile.js.map +1 -1
- package/dist/src/Components/Clickable/Clickable.d.ts +6 -3
- package/dist/src/Components/Dialog/ButtonDialog.d.ts +5 -1
- package/dist/src/Components/Flavor.d.ts +3 -1
- package/dist/src/Components/FormElements/Button/Button.d.ts +4 -1
- package/dist/src/Components/FormElements/Controller/HookForm.d.ts +8 -0
- package/dist/src/Components/FormElements/Controller/InputController.d.ts +4 -0
- package/dist/src/Components/FormElements/Controller/MultipleFileInputController.d.ts +3 -0
- package/dist/src/Components/FormElements/Controller/PasswordInputController.d.ts +4 -0
- package/dist/src/Components/FormElements/Controller/SelectController.d.ts +3 -0
- package/dist/src/Components/FormElements/Controller/SendFormContext.d.ts +3 -0
- package/dist/src/Components/FormElements/Controller/TextareaController.d.ts +4 -0
- package/dist/src/Components/FormElements/Controller/withHookController.d.ts +4 -0
- package/dist/src/Components/FormElements/Input/FileInput/MultipleFileInput.d.ts +2 -1
- package/dist/src/Components/FormElements/Input/Input.d.ts +1 -0
- package/dist/src/Components/FormElements/Select/Select.d.ts +2 -1
- package/dist/src/Components/FormElements/Textarea/Textarea.d.ts +1 -0
- package/dist/src/Components/Hooks/useComposedRef.d.ts +1 -1
- package/dist/src/Components/Image/Image.d.ts +2 -2
- package/dist/src/Components/Layout/Grid/Grid.d.ts +1 -3
- package/dist/src/Components/List/InfiniteList.d.ts +7 -0
- package/dist/src/Components/List/List.d.ts +4 -2
- package/dist/src/Size.d.ts +8 -0
- package/package.json +5 -3
- package/src/Components/Clickable/Clickable.tsx +41 -6
- package/src/Components/Dialog/ButtonDialog.tsx +19 -10
- package/src/Components/Dialog/ConfirmDialog.tsx +1 -0
- package/src/Components/Dialog/buttonDialog.scss +20 -8
- package/src/Components/Flavor.ts +2 -0
- package/src/Components/FormElements/Button/Button.tsx +14 -8
- package/src/Components/FormElements/Button/button.scss +17 -0
- package/src/Components/FormElements/Controller/HookForm.tsx +43 -0
- package/src/Components/FormElements/Controller/InputController.ts +4 -0
- package/src/Components/FormElements/Controller/MultipleFileInputController.ts +4 -0
- package/src/Components/FormElements/Controller/PasswordInputController.ts +4 -0
- package/src/Components/FormElements/Controller/SelectController.ts +4 -0
- package/src/Components/FormElements/Controller/SendFormContext.ts +7 -0
- package/src/Components/FormElements/Controller/TextareaController.ts +4 -0
- package/src/Components/FormElements/Controller/withHookController.tsx +53 -0
- package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +4 -1
- package/src/Components/FormElements/Input/FileInput/fileInput.scss +5 -6
- package/src/Components/FormElements/Input/Input.tsx +17 -6
- package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +1 -1
- package/src/Components/FormElements/Input/input.scss +5 -0
- package/src/Components/FormElements/Select/Select.tsx +5 -0
- package/src/Components/FormElements/Select/select.scss +5 -0
- package/src/Components/FormElements/Textarea/Textarea.tsx +9 -4
- package/src/Components/FormElements/Textarea/textarea.scss +10 -1
- package/src/Components/FormElements/hooks/useOnChangeDone.ts +1 -1
- package/src/Components/Hooks/useComposedRef.ts +13 -16
- package/src/Components/Image/Image.tsx +2 -2
- package/src/Components/Layout/Grid/Grid.tsx +5 -4
- package/src/Components/List/InfiniteList.tsx +57 -0
- package/src/Components/List/List.tsx +14 -5
- package/src/Size.ts +9 -0
- package/src/scss/_baseClasses.scss +7 -11
- package/src/scss/_colors.scss +10 -5
- package/src/scss/_default.scss +2 -2
- package/src/scss/_flavorMixin.scss +6 -0
- package/src/scss/_variables.scss +2 -2
- package/webpack.config.js +1 -0
|
@@ -6,8 +6,9 @@ type OnPointerDownListener<Data> = OptionalListener<'onPointerDown', Data, Point
|
|
|
6
6
|
type OnPointerUpListener<Data> = OptionalListener<'onPointerUp', Data, PointerEvent>;
|
|
7
7
|
type OnPointerMoveListener<Data> = OptionalListener<'onPointerMove', Data, PointerEvent>;
|
|
8
8
|
type OnDropListener<Data> = OptionalListener<'onDrop', Data>;
|
|
9
|
+
type OnDragStartListener<Data> = OptionalListener<'onDragStart', Data>;
|
|
9
10
|
type OnDragOverListener<Data> = OptionalListener<'onDragOver', Data>;
|
|
10
|
-
export type ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, OnDropData, OnDragOverData, OnMouseEnterData, OnMouseLeaveData, OnDoubleClickData, HrefType extends string | undefined> = RbmComponentProps<{
|
|
11
|
+
export type ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, OnDropData, OnDragStartData, OnDragOverData, OnMouseEnterData, OnMouseLeaveData, OnDoubleClickData, HrefType extends string | undefined> = RbmComponentProps<{
|
|
11
12
|
interactable?: boolean;
|
|
12
13
|
href?: HrefType;
|
|
13
14
|
target?: string;
|
|
@@ -15,6 +16,8 @@ export type ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMous
|
|
|
15
16
|
stopPropagation?: boolean;
|
|
16
17
|
useReactOnMouseLeave?: boolean;
|
|
17
18
|
id?: string;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
tabIndex?: number;
|
|
20
|
+
draggable?: boolean;
|
|
21
|
+
} & OnClickListener<OnClickData> & OnPointerDownListener<OnMouseDownData> & OnPointerMoveListener<OnMouseMoveData> & OnPointerUpListener<OnMouseUpData> & OnDropListener<OnDropData> & OnDragStartListener<OnDragStartData> & OnDragOverListener<OnDragOverData> & OptionalListener<'onClickCapture', OnClickCaptureData> & OptionalListener<'onMouseEnter', OnMouseEnterData> & OptionalListener<'onMouseLeave', OnMouseLeaveData, MouseEvent | ReactMouseEvent> & OptionalListener<'onDoubleClick', OnDoubleClickData>>;
|
|
22
|
+
declare const ClickableMemo: import("../../helper/withForwardRef").RefComponent<ClickableProps<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, string | undefined>, HTMLAnchorElement | HTMLSpanElement>;
|
|
20
23
|
export { ClickableMemo as Clickable };
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
2
3
|
import { RbmComponentProps, WithNoChildren } from '../RbmComponentProps';
|
|
4
|
+
import { Flavor } from "../Flavor";
|
|
3
5
|
export type ButtonDialogProps = RbmComponentProps<{
|
|
4
6
|
title?: string;
|
|
5
7
|
message: string;
|
|
6
8
|
buttons: {
|
|
7
9
|
text: string;
|
|
8
10
|
callback: () => void;
|
|
11
|
+
flavor?: Flavor;
|
|
9
12
|
}[];
|
|
13
|
+
extraContent?: ReactElement | null;
|
|
10
14
|
}, WithNoChildren>;
|
|
11
|
-
declare function ButtonDialog({ title, message, buttons, style, className }: ButtonDialogProps): React.JSX.Element;
|
|
15
|
+
declare function ButtonDialog({ title, message, buttons, style, className, extraContent }: ButtonDialogProps): React.JSX.Element;
|
|
12
16
|
declare const ButtonDialogMemo: typeof ButtonDialog;
|
|
13
17
|
export { ButtonDialogMemo as ButtonDialog };
|
|
@@ -5,9 +5,12 @@ import { HTMLAttributes } from 'react';
|
|
|
5
5
|
import { RbmComponentProps } from '../../RbmComponentProps';
|
|
6
6
|
import { ButtonType } from "./ButtonType";
|
|
7
7
|
import { Flavor } from "../../Flavor";
|
|
8
|
+
import { Size } from "../../../Size";
|
|
8
9
|
export type ButtonProps<ClickData> = RbmComponentProps<Override<HTMLAttributes<HTMLButtonElement>, {
|
|
9
10
|
type?: ButtonType;
|
|
10
11
|
disabled?: boolean;
|
|
11
12
|
flavor?: Flavor;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
size?: Omit<Size, "xxLarge" | "xLarge" | "large" | "xSmall">;
|
|
12
15
|
} & OptionalListener<'onClick', ClickData>>>;
|
|
13
|
-
export declare const Button: <ClickData>({ children, className, disabled, flavor, type, ...props }: ButtonProps<ClickData>) => React.JSX.Element;
|
|
16
|
+
export declare const Button: <ClickData>({ children, className, disabled, size, fullWidth, flavor, type, ...props }: ButtonProps<ClickData>) => React.JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormProviderProps } from "react-hook-form";
|
|
3
|
+
type FieldValues = Record<string, any>;
|
|
4
|
+
export type HookFormProps<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined> = FormProviderProps<TFieldValues, TContext, TTransformedValues> & {
|
|
5
|
+
onSend?: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const HookForm: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined>({ children, onSend, ...methods }: HookFormProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const InputController: import("../../../helper/withForwardRef").RefComponent<Omit<import("../Input/Input").InputProps<unknown, unknown, unknown> & import("react").RefAttributes<HTMLInputElement>, "value" | "ref" | "onBlur" | "name" | "onChangeText"> & {
|
|
3
|
+
name: string;
|
|
4
|
+
}, HTMLInputElement>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const MultipleFileInputController: import("../../../helper/withForwardRef").RefComponent<Omit<import("../Input/FileInput/MultipleFileInput").MultipleFileInputProps<unknown>, "value" | "ref" | "onBlur" | "name" | "onChangeFiles"> & {
|
|
2
|
+
name: string;
|
|
3
|
+
}, never>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const PasswordInputController: import("../../../helper/withForwardRef").RefComponent<Omit<import("../Input/PasswordInput/PasswordInput").PasswordInputProps<unknown, unknown, unknown> & import("react").RefAttributes<HTMLInputElement>, "value" | "ref" | "onBlur" | "name" | "onChangeText"> & {
|
|
3
|
+
name: string;
|
|
4
|
+
}, HTMLInputElement>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const TextareaController: import("../../../helper/withForwardRef").RefComponent<Omit<import("../Textarea/Textarea").TextareaProps<unknown, unknown> & import("react").RefAttributes<HTMLTextAreaElement>, "value" | "ref" | "onBlur" | "name" | "onChangeText"> & {
|
|
3
|
+
name: string;
|
|
4
|
+
}, HTMLTextAreaElement>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React, { ComponentProps, ComponentType } from "react";
|
|
2
|
+
export declare function withHookController<C extends ComponentType<any>, OnChangeProp extends keyof ComponentProps<C>>(Comp: C, onChangeProp: OnChangeProp, emptyValue?: any): import("../../../helper/withForwardRef").RefComponent<Omit<React.ComponentProps<C>, "value" | "ref" | "onBlur" | "name" | OnChangeProp> & {
|
|
3
|
+
name: string;
|
|
4
|
+
}, React.ComponentRef<C>>;
|
|
@@ -13,5 +13,6 @@ export type MultipleFileInputProps<OnChangeFilesData> = RbmComponentProps<Overri
|
|
|
13
13
|
onError?: (error: string) => void;
|
|
14
14
|
allowOverride?: boolean;
|
|
15
15
|
showDeleteButton?: boolean;
|
|
16
|
+
error?: string;
|
|
16
17
|
} & Listener<'onChangeFiles', OnChangeFilesData, FileType[]>>>;
|
|
17
|
-
export declare const MultipleFileInput: <OnChangeData>({ className, style, value, label, mimeTypes, maxFiles, maxSizePerFile, allowOverride, onError, showDeleteButton, ...otherProps }: MultipleFileInputProps<OnChangeData>) => React.JSX.Element;
|
|
18
|
+
export declare const MultipleFileInput: <OnChangeData>({ className, style, value, label, mimeTypes, maxFiles, maxSizePerFile, allowOverride, onError, showDeleteButton, error, ...otherProps }: MultipleFileInputProps<OnChangeData>) => React.JSX.Element;
|
|
@@ -7,5 +7,6 @@ export type InputProps<OnChangeData, OnBlurData, OnChangeDoneData> = RbmComponen
|
|
|
7
7
|
inline?: boolean;
|
|
8
8
|
onChangeText?: (newText: string) => void;
|
|
9
9
|
onEnter?: (newText: string) => void;
|
|
10
|
+
error?: string;
|
|
10
11
|
} & OptionalListener<'onChange', OnChangeData> & OptionalListener<'onBlur', OnBlurData> & OptionalListener<'onChangeDone', OnChangeDoneData>>>;
|
|
11
12
|
export declare const Input: import("../../../helper/withForwardRef").RefComponent<InputProps<unknown, unknown, unknown>, HTMLInputElement>;
|
|
@@ -14,5 +14,6 @@ export type SelectProps<OnChangeData> = RbmComponentProps<Override<SelectHTMLAtt
|
|
|
14
14
|
onChangeValue?: (newValue: string) => void;
|
|
15
15
|
inline?: boolean;
|
|
16
16
|
small?: boolean;
|
|
17
|
+
error?: string;
|
|
17
18
|
} & OptionalListener<'onChange', OnChangeData>>>;
|
|
18
|
-
export declare const Select: <OnChangeData>({ label, options, className, style, onChangeValue, inline, small, ...otherProps }: SelectProps<OnChangeData>) => React.JSX.Element;
|
|
19
|
+
export declare const Select: <OnChangeData>({ label, options, className, style, onChangeValue, inline, small, error, ...otherProps }: SelectProps<OnChangeData>) => React.JSX.Element;
|
|
@@ -9,5 +9,6 @@ export type TextareaProps<OnChangeData, OnChangeDoneData> = RbmComponentProps<Ov
|
|
|
9
9
|
onEscape?: (newText: string) => void;
|
|
10
10
|
textareaStyles?: CSSProperties & Record<`--${string}`, string | number | undefined>;
|
|
11
11
|
containerRef?: MutableRefObject<HTMLLabelElement | null>;
|
|
12
|
+
error?: string;
|
|
12
13
|
} & OptionalListener<'onChange', OnChangeData> & OptionalListener<'onChangeDone', OnChangeDoneData>>>;
|
|
13
14
|
export declare const Textarea: import("../../../helper/withForwardRef").RefComponent<TextareaProps<unknown, unknown>, HTMLTextAreaElement>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ForwardedRef } from 'react';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function useComposedRef<RefVal>(...refs: (ForwardedRef<RefVal> | undefined)[]): (val: RefVal | null) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RbmComponentProps, WithNoChildren } from '../RbmComponentProps';
|
|
3
|
-
import { CSSProperties
|
|
3
|
+
import { CSSProperties } from 'react';
|
|
4
4
|
import { Override } from '../../TypeHelpers';
|
|
5
|
-
export type ImageProps = RbmComponentProps<Override<
|
|
5
|
+
export type ImageProps = RbmComponentProps<Override<React.ComponentPropsWithoutRef<'img'>, {
|
|
6
6
|
src: string;
|
|
7
7
|
style?: CSSProperties;
|
|
8
8
|
alt?: string;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { RbmComponentProps } from '../../RbmComponentProps';
|
|
3
2
|
export type GridProps = RbmComponentProps<{
|
|
4
3
|
columns?: number;
|
|
5
4
|
rows?: number;
|
|
6
5
|
useContainerWidth?: boolean;
|
|
7
6
|
}>;
|
|
8
|
-
declare
|
|
9
|
-
declare const GridMemo: typeof Grid;
|
|
7
|
+
declare const GridMemo: import("../../../helper/withForwardRef").RefComponent<GridProps, HTMLDivElement>;
|
|
10
8
|
export { GridMemo as Grid };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ListProps } from "./List";
|
|
3
|
+
export type InfiniteListProps<ItemType> = ListProps<ItemType> & {
|
|
4
|
+
hasNextPage: boolean;
|
|
5
|
+
loadNextPage: () => unknown | Promise<unknown>;
|
|
6
|
+
};
|
|
7
|
+
export declare const InfiniteList: <ItemType>({ renderItem, itemHeight, items, renderBefore, keyExtractor, hasNextPage, loadNextPage, style, className }: InfiniteListProps<ItemType>) => React.JSX.Element;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
3
2
|
import { RbmComponentProps } from '../RbmComponentProps';
|
|
3
|
+
import { FixedSizeList, FixedSizeListProps } from 'react-window';
|
|
4
4
|
export type ListProps<ItemType> = RbmComponentProps<{
|
|
5
5
|
renderItem: (item: ItemType, style: CSSProperties, index: number) => ReactElement;
|
|
6
6
|
itemHeight?: number;
|
|
7
7
|
items: ItemType[];
|
|
8
8
|
renderBefore?: (item: ItemType, index: number) => ReactNode;
|
|
9
9
|
keyExtractor?: (item: ItemType, index: number) => string;
|
|
10
|
+
onItemsRendered?: FixedSizeListProps<ItemType>['onItemsRendered'];
|
|
11
|
+
autoSizeClassName?: string;
|
|
10
12
|
}>;
|
|
11
|
-
export declare const List: <
|
|
13
|
+
export declare const List: import("../../helper/withForwardRef").RefComponent<ListProps<unknown>, FixedSizeList<unknown>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainias42/react-bootstrap-mobile",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Mobile React Components using Bootstrap",
|
|
5
5
|
"main": "dist/bootstrapReactMobile",
|
|
6
6
|
"scripts": {
|
|
@@ -38,9 +38,11 @@
|
|
|
38
38
|
"@fortawesome/react-fontawesome": "^0.2.2",
|
|
39
39
|
"bootstrap": "^5.3.3",
|
|
40
40
|
"react": ">=18.0.0",
|
|
41
|
-
"react-beautiful-dnd": "^13.1.1"
|
|
41
|
+
"react-beautiful-dnd": "^13.1.1",
|
|
42
|
+
"react-hook-form": "^7.53.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
45
|
+
"react-hook-form": "^7.53.0",
|
|
44
46
|
"ajv": "^8.14.0",
|
|
45
47
|
"bootstrap": "^5.3.3",
|
|
46
48
|
"react": ">=18.0.0",
|
|
@@ -90,7 +92,7 @@
|
|
|
90
92
|
"webpack-dev-server": "^5.0.4"
|
|
91
93
|
},
|
|
92
94
|
"dependencies": {
|
|
93
|
-
"@ainias42/js-helper": ">=0.8.
|
|
95
|
+
"@ainias42/js-helper": ">=0.8.15",
|
|
94
96
|
"@types/react-virtualized-auto-sizer": "^1.0.4",
|
|
95
97
|
"classnames": "^2.5.1",
|
|
96
98
|
"isomorphic-style-loader": "^5.3.2",
|
|
@@ -4,7 +4,15 @@ import {OptionalListener, useListener} from '../Hooks/useListener';
|
|
|
4
4
|
|
|
5
5
|
import styles from './clickable.scss';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useCallback,
|
|
9
|
+
MouseEvent as ReactMouseEvent,
|
|
10
|
+
ForwardedRef,
|
|
11
|
+
useEffect,
|
|
12
|
+
MouseEvent,
|
|
13
|
+
PointerEvent,
|
|
14
|
+
useRef, DragEventHandler
|
|
15
|
+
} from 'react';
|
|
8
16
|
import {withForwardRef} from '../../helper/withForwardRef';
|
|
9
17
|
import {useComposedRef} from "../Hooks/useComposedRef";
|
|
10
18
|
|
|
@@ -13,6 +21,7 @@ type OnPointerDownListener<Data> = OptionalListener<'onPointerDown', Data, Point
|
|
|
13
21
|
type OnPointerUpListener<Data> = OptionalListener<'onPointerUp', Data, PointerEvent>;
|
|
14
22
|
type OnPointerMoveListener<Data> = OptionalListener<'onPointerMove', Data, PointerEvent>;
|
|
15
23
|
type OnDropListener<Data> = OptionalListener<'onDrop', Data>;
|
|
24
|
+
type OnDragStartListener<Data> = OptionalListener<'onDragStart', Data>;
|
|
16
25
|
type OnDragOverListener<Data> = OptionalListener<'onDragOver', Data>;
|
|
17
26
|
|
|
18
27
|
export type ClickableProps<
|
|
@@ -22,6 +31,7 @@ export type ClickableProps<
|
|
|
22
31
|
OnMouseUpData,
|
|
23
32
|
OnClickCaptureData,
|
|
24
33
|
OnDropData,
|
|
34
|
+
OnDragStartData,
|
|
25
35
|
OnDragOverData,
|
|
26
36
|
OnMouseEnterData,
|
|
27
37
|
OnMouseLeaveData,
|
|
@@ -36,11 +46,14 @@ export type ClickableProps<
|
|
|
36
46
|
stopPropagation?: boolean;
|
|
37
47
|
useReactOnMouseLeave?: boolean;
|
|
38
48
|
id?: string;
|
|
49
|
+
tabIndex?: number;
|
|
50
|
+
draggable?: boolean
|
|
39
51
|
} & OnClickListener<OnClickData> &
|
|
40
52
|
OnPointerDownListener<OnMouseDownData> &
|
|
41
53
|
OnPointerMoveListener<OnMouseMoveData> &
|
|
42
54
|
OnPointerUpListener<OnMouseUpData> &
|
|
43
55
|
OnDropListener<OnDropData> &
|
|
56
|
+
OnDragStartListener<OnDragStartData> &
|
|
44
57
|
OnDragOverListener<OnDragOverData> &
|
|
45
58
|
OptionalListener<'onClickCapture', OnClickCaptureData> &
|
|
46
59
|
OptionalListener<'onMouseEnter', OnMouseEnterData> &
|
|
@@ -55,6 +68,7 @@ function Clickable<
|
|
|
55
68
|
OnPointerUpData,
|
|
56
69
|
OnClickCaptureData,
|
|
57
70
|
OnDropData,
|
|
71
|
+
OnDragStartData,
|
|
58
72
|
OnDragOverData,
|
|
59
73
|
OnMouseEnterData,
|
|
60
74
|
OnMouseLeaveData,
|
|
@@ -72,8 +86,10 @@ function Clickable<
|
|
|
72
86
|
preventDefault = false,
|
|
73
87
|
stopPropagation = true,
|
|
74
88
|
useReactOnMouseLeave = false,
|
|
89
|
+
tabIndex,
|
|
90
|
+
draggable,
|
|
75
91
|
...clickData
|
|
76
|
-
}: ClickableProps<OnClickData, OnPointerDownData, OnPointerMoveData, OnPointerUpData, OnClickCaptureData, OnDropData, OnDragOverData,OnMouseEnterData, OnMouseLeaveData, OnDoubleClickData, HrefType>,
|
|
92
|
+
}: ClickableProps<OnClickData, OnPointerDownData, OnPointerMoveData, OnPointerUpData, OnClickCaptureData, OnDropData,OnDragStartData, OnDragOverData,OnMouseEnterData, OnMouseLeaveData, OnDoubleClickData, HrefType>,
|
|
77
93
|
ref: ForwardedRef<HrefType extends string ? HTMLAnchorElement : HTMLSpanElement>
|
|
78
94
|
) {
|
|
79
95
|
// Variables
|
|
@@ -81,7 +97,8 @@ function Clickable<
|
|
|
81
97
|
// States
|
|
82
98
|
|
|
83
99
|
// Refs
|
|
84
|
-
const clickableRef =
|
|
100
|
+
const clickableRef = useRef<HrefType extends string ? HTMLAnchorElement : HTMLSpanElement>(null);
|
|
101
|
+
const refSetter = useComposedRef(ref, clickableRef);
|
|
85
102
|
|
|
86
103
|
// Callbacks
|
|
87
104
|
const onClickInner = useListener<'onClick', OnClickData>('onClick', clickData);
|
|
@@ -196,6 +213,22 @@ function Clickable<
|
|
|
196
213
|
[clickData.onDragOver, onDragOver, preventDefault, stopPropagation]
|
|
197
214
|
);
|
|
198
215
|
|
|
216
|
+
const onDragStartListener = useListener<'onDragStart', OnDragStartData>('onDragStart', clickData);
|
|
217
|
+
const realOnDragStartListener = useCallback(
|
|
218
|
+
(e: ReactMouseEvent) => {
|
|
219
|
+
if (clickData.onDragStart) {
|
|
220
|
+
if (stopPropagation) {
|
|
221
|
+
e.stopPropagation();
|
|
222
|
+
}
|
|
223
|
+
if (preventDefault) {
|
|
224
|
+
e.preventDefault();
|
|
225
|
+
}
|
|
226
|
+
onDragStartListener(e);
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
[clickData.onDragStart, onDragStartListener, preventDefault, stopPropagation]
|
|
230
|
+
);
|
|
231
|
+
|
|
199
232
|
const onMouseEnter = useListener<'onMouseEnter', OnMouseEnterData>('onMouseEnter', clickData);
|
|
200
233
|
const realOnMouseEnter = useCallback(
|
|
201
234
|
(e: ReactMouseEvent) => {
|
|
@@ -276,17 +309,19 @@ function Clickable<
|
|
|
276
309
|
onMouseEnter: realOnMouseEnter,
|
|
277
310
|
onMouseLeave: useReactOnMouseLeave ? realOnMouseLeave : undefined,
|
|
278
311
|
onDoubleClick: realOnDoubleClick,
|
|
279
|
-
tabIndex: interactable ? 0 :
|
|
312
|
+
tabIndex: interactable ? 0 : tabIndex,
|
|
313
|
+
draggable,
|
|
314
|
+
onDragStart: realOnDragStartListener
|
|
280
315
|
};
|
|
281
316
|
if (typeof href === 'string') {
|
|
282
317
|
return (
|
|
283
|
-
<a {...props} href={href} ref={
|
|
318
|
+
<a {...props} href={href} ref={refSetter as ForwardedRef<HTMLAnchorElement>}>
|
|
284
319
|
{children}
|
|
285
320
|
</a>
|
|
286
321
|
);
|
|
287
322
|
}
|
|
288
323
|
return (
|
|
289
|
-
<span {...props} ref={
|
|
324
|
+
<span {...props} ref={refSetter as ForwardedRef<HTMLSpanElement>}>
|
|
290
325
|
{children}
|
|
291
326
|
</span>
|
|
292
327
|
);
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
2
3
|
import { withMemo } from '../../helper/withMemo';
|
|
3
4
|
import { Block } from '../Layout/Block';
|
|
4
|
-
import { Text } from '../Text/Text';
|
|
5
|
+
import { Text, TEXT_SIZE } from '../Text/Text';
|
|
5
6
|
import { Clickable } from '../Clickable/Clickable';
|
|
6
7
|
|
|
7
8
|
import styles from './buttonDialog.scss';
|
|
8
9
|
import { RbmComponentProps, WithNoChildren } from '../RbmComponentProps';
|
|
9
10
|
import classNames from 'classnames';
|
|
11
|
+
import { Flavor } from "../Flavor";
|
|
12
|
+
import { Size } from "../../Size";
|
|
10
13
|
|
|
11
14
|
export type ButtonDialogProps = RbmComponentProps<
|
|
12
|
-
{
|
|
15
|
+
{
|
|
16
|
+
title?: string;
|
|
17
|
+
message: string;
|
|
18
|
+
buttons: { text: string; callback: () => void, flavor?: Flavor }[]
|
|
19
|
+
extraContent?: ReactElement|null
|
|
20
|
+
},
|
|
13
21
|
WithNoChildren
|
|
14
22
|
>;
|
|
15
23
|
|
|
16
|
-
function ButtonDialog({ title, message, buttons, style, className }: ButtonDialogProps) {
|
|
24
|
+
function ButtonDialog({ title, message, buttons, style, className, extraContent }: ButtonDialogProps) {
|
|
17
25
|
// Variables
|
|
18
26
|
|
|
19
27
|
// Refs
|
|
@@ -31,20 +39,21 @@ function ButtonDialog({ title, message, buttons, style, className }: ButtonDialo
|
|
|
31
39
|
// Render Functions
|
|
32
40
|
|
|
33
41
|
return (
|
|
34
|
-
<Block className={classNames(styles.buttonDialog, className)} style={style}>
|
|
42
|
+
<Block className={classNames(styles.buttonDialog, className)} style={style} >
|
|
35
43
|
{!!title && (
|
|
36
|
-
<Block
|
|
37
|
-
<Text>{title}</Text>
|
|
44
|
+
<Block>
|
|
45
|
+
<Text size={TEXT_SIZE.large} className={styles.title}>{title}</Text>
|
|
38
46
|
</Block>
|
|
39
47
|
)}
|
|
40
|
-
<Block
|
|
41
|
-
<Text>{message}</Text>
|
|
48
|
+
<Block>
|
|
49
|
+
<Text className={styles.message}>{message}</Text>
|
|
42
50
|
</Block>
|
|
51
|
+
{extraContent}
|
|
43
52
|
<Block className={styles.buttonContainer}>
|
|
44
53
|
{buttons.map((b, i) => (
|
|
45
54
|
// eslint-disable-next-line react/no-array-index-key
|
|
46
|
-
<Clickable onClick={b.callback} className={styles.button} key={i + b.text}>
|
|
47
|
-
<Text>{b.text}</Text>
|
|
55
|
+
<Clickable onClick={b.callback} className={classNames(styles.button)} key={i + b.text}>
|
|
56
|
+
<Text className={classNames(styles.buttonText, b.flavor ?? Flavor.Accent)}>{b.text}</Text>
|
|
48
57
|
</Clickable>
|
|
49
58
|
))}
|
|
50
59
|
</Block>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@import "../../scss/variables";
|
|
2
2
|
@import "../../scss/designMixin";
|
|
3
|
+
@import "../../scss/flavorMixin";
|
|
3
4
|
|
|
4
5
|
.buttonDialog {
|
|
5
6
|
font-weight: 400;
|
|
@@ -18,8 +19,13 @@
|
|
|
18
19
|
width: 100%;
|
|
19
20
|
|
|
20
21
|
.button {
|
|
21
|
-
color: var(--flavor-accent);
|
|
22
22
|
padding: 0 8px;
|
|
23
|
+
|
|
24
|
+
.buttonText {
|
|
25
|
+
@include flavorSelection(--text-primary-default-color);
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
|
|
@@ -51,15 +57,18 @@
|
|
|
51
57
|
display: block;
|
|
52
58
|
border-left: 1px solid var(--border-light);
|
|
53
59
|
border-top: 1px solid var(--border-light);
|
|
54
|
-
text-overflow: ellipsis;
|
|
55
|
-
letter-spacing: 0;
|
|
56
60
|
vertical-align: middle;
|
|
57
|
-
font-size: 16px;
|
|
58
61
|
text-align: center;
|
|
59
62
|
height: 44px;
|
|
60
|
-
line-height: 44px;
|
|
61
63
|
overflow: hidden;
|
|
62
64
|
|
|
65
|
+
.buttonText {
|
|
66
|
+
line-height: 44px;
|
|
67
|
+
text-overflow: ellipsis;
|
|
68
|
+
letter-spacing: 0;
|
|
69
|
+
font-size: 16px;
|
|
70
|
+
}
|
|
71
|
+
|
|
63
72
|
&:first-child {
|
|
64
73
|
border-left: none;
|
|
65
74
|
}
|
|
@@ -102,12 +111,15 @@
|
|
|
102
111
|
width: auto;
|
|
103
112
|
float: right;
|
|
104
113
|
border-radius: 2px;
|
|
105
|
-
font-size: 14px;
|
|
106
|
-
font-weight: 500;
|
|
107
114
|
height: 36px;
|
|
108
|
-
line-height: 36px;
|
|
109
115
|
margin: 8px 8px 8px 0;
|
|
110
116
|
min-width: 50px;
|
|
117
|
+
|
|
118
|
+
.buttonText {
|
|
119
|
+
line-height: 36px;
|
|
120
|
+
font-size: 14px;
|
|
121
|
+
font-weight: 500;
|
|
122
|
+
}
|
|
111
123
|
}
|
|
112
124
|
}
|
|
113
125
|
}
|
package/src/Components/Flavor.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {Override} from '@ainias42/js-helper';
|
|
3
|
-
import {OptionalListener, useListenerWithExtractedProps} from '../../Hooks/useListener';
|
|
2
|
+
import { Override } from '@ainias42/js-helper';
|
|
3
|
+
import { OptionalListener, useListenerWithExtractedProps } from '../../Hooks/useListener';
|
|
4
4
|
|
|
5
5
|
import styles from './button.scss';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import {withMemo} from '../../../helper/withMemo';
|
|
8
|
-
import {HTMLAttributes} from 'react';
|
|
9
|
-
import {RbmComponentProps} from '../../RbmComponentProps';
|
|
10
|
-
import {ButtonType} from "./ButtonType";
|
|
11
|
-
import {Flavor} from "../../Flavor";
|
|
7
|
+
import { withMemo } from '../../../helper/withMemo';
|
|
8
|
+
import { HTMLAttributes } from 'react';
|
|
9
|
+
import { RbmComponentProps } from '../../RbmComponentProps';
|
|
10
|
+
import { ButtonType } from "./ButtonType";
|
|
11
|
+
import { Flavor } from "../../Flavor";
|
|
12
|
+
import { Size } from "../../../Size";
|
|
12
13
|
|
|
13
14
|
export type ButtonProps<ClickData> = RbmComponentProps<
|
|
14
15
|
Override<HTMLAttributes<HTMLButtonElement>, {
|
|
15
16
|
type?: ButtonType,
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
flavor?: Flavor
|
|
19
|
+
fullWidth?: boolean;
|
|
20
|
+
size?: Omit<Size, "xxLarge" | "xLarge" | "large" | "xSmall">
|
|
18
21
|
} & OptionalListener<'onClick', ClickData>>
|
|
19
22
|
>;
|
|
20
23
|
|
|
@@ -22,6 +25,8 @@ export const Button = withMemo(function Button<ClickData>({
|
|
|
22
25
|
children,
|
|
23
26
|
className,
|
|
24
27
|
disabled,
|
|
28
|
+
size,
|
|
29
|
+
fullWidth = false,
|
|
25
30
|
flavor = Flavor.Accent,
|
|
26
31
|
type = ButtonType.Primary,
|
|
27
32
|
...props
|
|
@@ -32,11 +37,12 @@ export const Button = withMemo(function Button<ClickData>({
|
|
|
32
37
|
[styles.primary]: type === ButtonType.Primary,
|
|
33
38
|
[styles.secondary]: type === ButtonType.Secondary,
|
|
34
39
|
[styles.disabled]: disabled,
|
|
40
|
+
[styles.small]: size === Size.small
|
|
35
41
|
};
|
|
36
42
|
|
|
37
43
|
return (
|
|
38
44
|
<button {...otherProps} disabled={disabled} type="button" onClick={onClick}
|
|
39
|
-
className={classNames(styles.button, classes, flavor, className)}>
|
|
45
|
+
className={classNames(styles.button, {[styles.fullWidth]: fullWidth}, classes, flavor, className)}>
|
|
40
46
|
{children}
|
|
41
47
|
</button>
|
|
42
48
|
);
|
|
@@ -53,4 +53,21 @@
|
|
|
53
53
|
cursor: default;
|
|
54
54
|
pointer-events: none;
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
&.small {
|
|
58
|
+
@include design($material) {
|
|
59
|
+
min-height: 17px;
|
|
60
|
+
line-height: 17px;
|
|
61
|
+
padding: 0 8px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@include design($flat) {
|
|
65
|
+
line-height: 17px;
|
|
66
|
+
padding: 4px 9px;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&.fullWidth {
|
|
71
|
+
width: 100%;
|
|
72
|
+
}
|
|
56
73
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { FormProvider, FormProviderProps } from "react-hook-form";
|
|
3
|
+
import { withMemo } from "../../../helper/withMemo";
|
|
4
|
+
import { LoadingArea } from "../../LoadingArea/LoadingArea";
|
|
5
|
+
import { SendFormContext } from "./SendFormContext";
|
|
6
|
+
|
|
7
|
+
type FieldValues = Record<string, any>;
|
|
8
|
+
export type HookFormProps<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined> =
|
|
9
|
+
FormProviderProps<TFieldValues, TContext, TTransformedValues>
|
|
10
|
+
& {
|
|
11
|
+
onSend?: () => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const HookForm = withMemo(function HookForm<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined>({
|
|
15
|
+
children,
|
|
16
|
+
onSend,
|
|
17
|
+
...methods
|
|
18
|
+
}: HookFormProps<TFieldValues, TContext, TTransformedValues>) {
|
|
19
|
+
// Refs
|
|
20
|
+
|
|
21
|
+
// States/Variables/Selectors
|
|
22
|
+
|
|
23
|
+
// Create an inner, as the onSend may have other attributes
|
|
24
|
+
const innerOnSend = useCallback(() => onSend?.(), [onSend]);
|
|
25
|
+
|
|
26
|
+
// Dispatch
|
|
27
|
+
|
|
28
|
+
// Callbacks
|
|
29
|
+
|
|
30
|
+
// Effects
|
|
31
|
+
|
|
32
|
+
// Other
|
|
33
|
+
|
|
34
|
+
// RenderFunctions
|
|
35
|
+
|
|
36
|
+
return <FormProvider {...methods}>
|
|
37
|
+
<SendFormContext.Provider value={innerOnSend}>
|
|
38
|
+
<LoadingArea loading={methods.formState.isSubmitting} __allowChildren={"all"}>
|
|
39
|
+
{children}
|
|
40
|
+
</LoadingArea>
|
|
41
|
+
</SendFormContext.Provider>
|
|
42
|
+
</FormProvider>;
|
|
43
|
+
});
|