@ainias42/react-bootstrap-mobile 0.1.14 → 0.1.16

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.
Files changed (71) hide show
  1. package/bin/updateCopies.js +8 -5
  2. package/bootstrapReactMobile.ts +12 -2
  3. package/dist/bootstrapReactMobile.d.ts +12 -2
  4. package/dist/bootstrapReactMobile.js +841 -329
  5. package/dist/bootstrapReactMobile.js.map +1 -1
  6. package/dist/src/Components/Clickable/Clickable.d.ts +5 -3
  7. package/dist/src/Components/Dialog/DialogBackground.d.ts +4 -5
  8. package/dist/src/Components/Dialog/DialogContainer.d.ts +7 -3
  9. package/dist/src/Components/FormElements/Button/Button.d.ts +6 -4
  10. package/dist/src/Components/FormElements/Button/ButtonType.d.ts +4 -0
  11. package/dist/src/Components/FormElements/Input/FileInput/FileInput.d.ts +12 -0
  12. package/dist/src/Components/FormElements/Input/FileInput/FileType.d.ts +7 -0
  13. package/dist/src/Components/FormElements/Input/FileInput/MultipleFileInput.d.ts +17 -0
  14. package/dist/src/Components/FormElements/Select/Select.d.ts +2 -1
  15. package/dist/src/Components/FormElements/Switch/Switch.d.ts +4 -4
  16. package/dist/src/Components/Hooks/useMousePosition.d.ts +5 -0
  17. package/dist/src/Components/Hooks/useWindowDimensions.d.ts +4 -0
  18. package/dist/src/Components/Icon/Icon.d.ts +2 -3
  19. package/dist/src/Components/Layout/Grid/Grid.d.ts +2 -1
  20. package/dist/src/Components/Layout/Grid/GridItem.d.ts +4 -1
  21. package/dist/src/Components/Menu/HoverMenu.d.ts +7 -0
  22. package/dist/src/Components/Menu/Menu.d.ts +15 -7
  23. package/dist/src/Components/Menu/MenuCloseContext.d.ts +3 -0
  24. package/dist/src/Components/Menu/MenuDivider.d.ts +2 -0
  25. package/dist/src/Components/Menu/MenuItem.d.ts +23 -0
  26. package/dist/src/Components/Menu/Submenu.d.ts +10 -0
  27. package/dist/src/Components/Menu/useMenu.d.ts +1 -1
  28. package/dist/src/Components/RbmComponentProps.d.ts +4 -0
  29. package/dist/src/ListRow/ListRow.d.ts +1 -0
  30. package/package.json +8 -7
  31. package/src/Components/Clickable/Clickable.tsx +95 -13
  32. package/src/Components/Dialog/DialogBackground.tsx +5 -8
  33. package/src/Components/Dialog/DialogContainer.tsx +12 -8
  34. package/src/Components/Dialog/DialogContext.ts +1 -2
  35. package/src/Components/Dialog/dialogBackground.scss +5 -1
  36. package/src/Components/DragAndDrop/DropArea.tsx +2 -1
  37. package/src/Components/FormElements/Button/Button.tsx +15 -7
  38. package/src/Components/FormElements/Button/ButtonType.ts +4 -0
  39. package/src/Components/FormElements/Button/button.scss +22 -5
  40. package/src/Components/FormElements/Input/FileInput/FileInput.tsx +55 -0
  41. package/src/Components/FormElements/Input/FileInput/FileType.ts +1 -0
  42. package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +281 -0
  43. package/src/Components/FormElements/{ImageInput/imageInput.scss → Input/FileInput/fileInput.scss} +37 -7
  44. package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +2 -2
  45. package/src/Components/FormElements/Select/Select.tsx +3 -2
  46. package/src/Components/FormElements/Select/select.scss +5 -0
  47. package/src/Components/FormElements/Switch/Switch.tsx +9 -8
  48. package/src/Components/FormElements/Switch/switch.scss +1 -0
  49. package/src/Components/Hooks/useMousePosition.ts +13 -0
  50. package/src/Components/Hooks/useWindowDimensions.ts +17 -0
  51. package/src/Components/Icon/Icon.tsx +8 -7
  52. package/src/Components/Icon/icon.scss +4 -0
  53. package/src/Components/Layout/Grid/Grid.tsx +3 -2
  54. package/src/Components/Layout/Grid/GridItem.tsx +16 -1
  55. package/src/Components/Layout/Grid/grid.scss +88 -17
  56. package/src/Components/Menu/HoverMenu.tsx +71 -0
  57. package/src/Components/Menu/Menu.tsx +78 -47
  58. package/src/Components/Menu/MenuCloseContext.ts +10 -0
  59. package/src/Components/Menu/MenuDivider.tsx +22 -0
  60. package/src/Components/Menu/MenuItem.tsx +95 -0
  61. package/src/Components/Menu/Submenu.tsx +95 -0
  62. package/src/Components/Menu/menu.scss +95 -10
  63. package/src/Components/Menu/useMenu.ts +1 -1
  64. package/src/Components/RbmComponentProps.ts +6 -0
  65. package/src/ListRow/ListRow.tsx +20 -0
  66. package/src/WrongChildError.ts +0 -2
  67. package/src/scss/_flavorMixin.scss +3 -0
  68. package/dist/src/Components/FormElements/ImageInput/ImageInput.d.ts +0 -18
  69. package/dist/src/Components/FormElements/ImageInput/MultipleFileInput.d.ts +0 -21
  70. package/src/Components/FormElements/ImageInput/ImageInput.tsx +0 -98
  71. package/src/Components/FormElements/ImageInput/MultipleFileInput.tsx +0 -240
@@ -4,11 +4,13 @@ type OnClickListener<Data> = OptionalListener<'onClick', Data>;
4
4
  type OnMouseDownListener<Data> = OptionalListener<'onMouseDown', Data>;
5
5
  type OnMouseUpListener<Data> = OptionalListener<'onMouseUp', Data>;
6
6
  type OnMouseMoveListener<Data> = OptionalListener<'onMouseMove', Data>;
7
- export type ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, HrefType extends string | undefined> = RbmComponentProps<{
7
+ type OnDropListener<Data> = OptionalListener<'onDrop', Data>;
8
+ type OnDragOverListener<Data> = OptionalListener<'onDragOver', Data>;
9
+ export type ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, OnDropData, OnDragOverData, OnMouseEnterData, OnMouseLeaveData, HrefType extends string | undefined> = RbmComponentProps<{
8
10
  interactable?: boolean;
9
11
  href?: HrefType;
10
12
  preventDefault?: boolean;
11
13
  stopPropagation?: boolean;
12
- } & OnClickListener<OnClickData> & OnMouseDownListener<OnMouseDownData> & OnMouseMoveListener<OnMouseMoveData> & OnMouseUpListener<OnMouseUpData> & OptionalListener<'onClickCapture', OnClickCaptureData>>;
13
- declare const ClickableMemo: import("../../helper/withForwardRef").RefComponent<ClickableProps<unknown, unknown, unknown, unknown, unknown, string | undefined>, HTMLAnchorElement | HTMLSpanElement>;
14
+ } & OnClickListener<OnClickData> & OnMouseDownListener<OnMouseDownData> & OnMouseMoveListener<OnMouseMoveData> & OnMouseUpListener<OnMouseUpData> & OnDropListener<OnDropData> & OnDragOverListener<OnDragOverData> & OptionalListener<'onClickCapture', OnClickCaptureData> & OptionalListener<'onMouseEnter', OnMouseEnterData> & OptionalListener<'onMouseLeave', OnMouseLeaveData>>;
15
+ declare const ClickableMemo: import("../../helper/withForwardRef").RefComponent<ClickableProps<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, string | undefined>, HTMLAnchorElement | HTMLSpanElement>;
14
16
  export { ClickableMemo as Clickable };
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { RbmComponentProps } from '../RbmComponentProps';
3
- import { EmptyProps } from '../../helper/EmptyProps';
4
- export type DialogBackgroundProps = RbmComponentProps<EmptyProps>;
5
- declare function DialogBackground({ children, className, style }: DialogBackgroundProps): React.JSX.Element;
6
- declare const DialogBackgroundMemo: typeof DialogBackground;
7
- export { DialogBackgroundMemo as DialogBackground };
3
+ export type DialogBackgroundProps = RbmComponentProps<{
4
+ title?: string;
5
+ }>;
6
+ export declare const DialogBackground: ({ children, className, style, title }: DialogBackgroundProps) => React.JSX.Element;
@@ -1,7 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
+ import { ShowDialog } from './DialogContext';
3
4
  import { EmptyProps } from '../../helper/EmptyProps';
4
5
  export type DialogContainerProps = PropsWithChildren<EmptyProps>;
5
- declare function DialogContainer({ children }: DialogContainerProps): React.JSX.Element;
6
- declare const DialogContainerMemo: typeof DialogContainer;
7
- export { DialogContainerMemo as DialogContainer };
6
+ export type DialogContainerRef = {
7
+ showDialog: ShowDialog;
8
+ };
9
+ export declare const DialogContainer: import("../../helper/withForwardRef").RefComponent<{
10
+ children?: React.ReactNode;
11
+ }, DialogContainerRef>;
@@ -3,7 +3,9 @@ import { Override } from '@ainias42/js-helper';
3
3
  import { OptionalListener } from '../../Hooks/useListener';
4
4
  import { HTMLAttributes } from 'react';
5
5
  import { RbmComponentProps } from '../../RbmComponentProps';
6
- export type ButtonProps<ClickData> = RbmComponentProps<Override<HTMLAttributes<HTMLButtonElement>, OptionalListener<'onClick', ClickData>>>;
7
- declare function Button<ClickData>({ children, className, ...props }: ButtonProps<ClickData>): React.JSX.Element;
8
- declare const ButtonMemo: typeof Button;
9
- export { ButtonMemo as Button };
6
+ import { ButtonType } from "./ButtonType";
7
+ export type ButtonProps<ClickData> = RbmComponentProps<Override<HTMLAttributes<HTMLButtonElement>, {
8
+ type?: ButtonType;
9
+ disabled?: boolean;
10
+ } & OptionalListener<'onClick', ClickData>>>;
11
+ export declare const Button: <ClickData>({ children, className, disabled, type, ...props }: ButtonProps<ClickData>) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare enum ButtonType {
2
+ Primary = "primary",
3
+ Secondary = "secondary"
4
+ }
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../../../RbmComponentProps';
3
+ import { Override } from '../../../../TypeHelpers';
4
+ import { Listener } from '../../../Hooks/useListener';
5
+ import { FileType } from "./FileType";
6
+ import { MultipleFileInputProps } from "./MultipleFileInput";
7
+ export type FileInputProps<OnChangeFileData> = RbmComponentProps<Override<Omit<MultipleFileInputProps<unknown>, "onChangeFiles" | "maxFiles" | "onChangeFilesData" | "mimeTypes" | "showDeleteButton">, {
8
+ value?: FileType;
9
+ mimeType?: string;
10
+ required?: boolean;
11
+ } & Listener<'onChangeFile', OnChangeFileData, FileType | undefined>>>;
12
+ export declare const FileInput: <OnChangeData>({ value, mimeType, required, ...otherProps }: FileInputProps<OnChangeData>) => React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ export type FileType = {
2
+ name: string;
3
+ data: string;
4
+ mimeType: string;
5
+ uploaded?: boolean;
6
+ blob?: Blob;
7
+ };
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../../../RbmComponentProps';
3
+ import { Override } from '../../../../TypeHelpers';
4
+ import { InputHTMLAttributes } from 'react';
5
+ import { Listener } from '../../../Hooks/useListener';
6
+ import { FileType } from "./FileType";
7
+ export type MultipleFileInputProps<OnChangeFilesData> = RbmComponentProps<Override<Omit<InputHTMLAttributes<HTMLInputElement>, 'defaultValue' | 'onChange' | 'value'>, {
8
+ value: FileType[];
9
+ label?: string;
10
+ mimeTypes?: string[];
11
+ maxFiles?: number;
12
+ maxSizePerFile?: number;
13
+ onError?: (error: string) => void;
14
+ allowOverride?: boolean;
15
+ showDeleteButton?: boolean;
16
+ } & 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;
@@ -13,5 +13,6 @@ export type SelectProps<OnChangeData> = RbmComponentProps<Override<SelectHTMLAtt
13
13
  options: SelectOption[];
14
14
  onChangeValue?: (newValue: string) => void;
15
15
  inline?: boolean;
16
+ small?: boolean;
16
17
  } & OptionalListener<'onChange', OnChangeData>>>;
17
- export declare const Select: <OnChangeData>({ label, options, className, style, onChangeValue, inline, ...otherProps }: SelectProps<OnChangeData>) => React.JSX.Element;
18
+ export declare const Select: <OnChangeData>({ label, options, className, style, onChangeValue, inline, small, ...otherProps }: SelectProps<OnChangeData>) => React.JSX.Element;
@@ -2,12 +2,12 @@ import * as React from 'react';
2
2
  import { InputHTMLAttributes } from 'react';
3
3
  import { RbmComponentProps } from '../../RbmComponentProps';
4
4
  import { Override } from '../../../TypeHelpers';
5
- export type SwitchProps = RbmComponentProps<Override<InputHTMLAttributes<HTMLInputElement>, {
5
+ import { OptionalListener } from "../../Hooks/useListener";
6
+ export type SwitchProps<OnChangeCheckedData> = RbmComponentProps<Override<InputHTMLAttributes<HTMLInputElement>, {
6
7
  preLabel?: string;
7
8
  label?: string;
8
9
  children?: string;
9
10
  isLabelBeforeSwitch?: boolean;
10
11
  isDual?: boolean;
11
- onChangeChecked?(isChecked: boolean): void;
12
- }>>;
13
- export declare const Switch: ({ children, label, preLabel, isLabelBeforeSwitch, isDual, id, className, style, onChange, onChangeChecked, ...props }: SwitchProps) => React.JSX.Element;
12
+ } & OptionalListener<"onChangeChecked", OnChangeCheckedData, boolean>>>;
13
+ export declare const Switch: <OnChangeCheckedData>({ children, label, preLabel, isLabelBeforeSwitch, isDual, id, className, style, onChange, ...props }: SwitchProps<OnChangeCheckedData>) => React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare function useMousePosition(): import("react").MutableRefObject<{
3
+ x: number;
4
+ y: number;
5
+ }>;
@@ -0,0 +1,4 @@
1
+ export declare function useWindowDimensions(): {
2
+ x: number;
3
+ y: number;
4
+ };
@@ -6,9 +6,8 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core';
6
6
  import { IconDefinition } from '@fortawesome/free-regular-svg-icons';
7
7
  export type IconSource = IconProp | string | IconDefinition;
8
8
  export type IconProps = RbmComponentProps<Override<FontAwesomeIconProps, {
9
+ noMargin?: boolean;
9
10
  icon: IconSource;
10
11
  alt?: string;
11
12
  }>>;
12
- declare function Icon({ icon, alt, className, style, title, ...props }: IconProps): React.JSX.Element;
13
- declare const IconMemo: typeof Icon;
14
- export { IconMemo as Icon };
13
+ export declare const Icon: ({ icon, alt, className, noMargin, style, title, ...props }: IconProps) => React.JSX.Element;
@@ -3,7 +3,8 @@ import { RbmComponentProps } from '../../RbmComponentProps';
3
3
  export type GridProps = RbmComponentProps<{
4
4
  columns?: number;
5
5
  rows?: number;
6
+ useContainerWidth?: boolean;
6
7
  }>;
7
- declare function Grid({ style, children, columns, rows, className, __allowChildren }: GridProps): React.JSX.Element;
8
+ declare function Grid({ style, children, columns, rows, useContainerWidth, className, __allowChildren }: GridProps): React.JSX.Element;
8
9
  declare const GridMemo: typeof Grid;
9
10
  export { GridMemo as Grid };
@@ -2,12 +2,14 @@ import * as React from 'react';
2
2
  import { RbmComponentProps } from '../../RbmComponentProps';
3
3
  export type GridItemProps = RbmComponentProps<{
4
4
  size: number;
5
+ xs?: number;
5
6
  sm?: number;
6
7
  md?: number;
7
8
  lg?: number;
8
9
  xl?: number;
9
10
  xxl?: number;
10
11
  print?: number;
12
+ startXxs?: number;
11
13
  startXs?: number;
12
14
  startSm?: number;
13
15
  startMd?: number;
@@ -15,6 +17,7 @@ export type GridItemProps = RbmComponentProps<{
15
17
  startXl?: number;
16
18
  startXxl?: number;
17
19
  startPrint?: number;
20
+ orderXxs?: number;
18
21
  orderXs?: number;
19
22
  orderSm?: number;
20
23
  orderMd?: number;
@@ -23,6 +26,6 @@ export type GridItemProps = RbmComponentProps<{
23
26
  orderXxl?: number;
24
27
  orderPrint?: number;
25
28
  }>;
26
- declare function GridItem({ style, children, className, __allowChildren, size, sm, md, lg, xl, xxl, print, startXs, startMd, startSm, startLg, startXl, startXxl, startPrint, orderXs, orderSm, orderMd, orderLg, orderXxl, orderXl, orderPrint, }: GridItemProps): React.JSX.Element;
29
+ declare function GridItem({ style, children, className, __allowChildren, size, xs, sm, md, lg, xl, xxl, print, startXxs, startXs, startMd, startSm, startLg, startXl, startXxl, startPrint, orderXxs, orderXs, orderSm, orderMd, orderLg, orderXxl, orderXl, orderPrint, }: GridItemProps): React.JSX.Element;
27
30
  declare const GridItemMemo: typeof GridItem;
28
31
  export { GridItemMemo as GridItem };
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { RbmChildWithoutString, RbmComponentProps, WithNoStringAndChildrenProps } from "../RbmComponentProps";
3
+ export type HoverMenuProps = RbmComponentProps<{
4
+ items: RbmChildWithoutString;
5
+ onClick?: () => void;
6
+ }, WithNoStringAndChildrenProps>;
7
+ export declare const HoverMenu: ({ children, items, className, style, onClick, }: HoverMenuProps) => React.JSX.Element;
@@ -1,17 +1,25 @@
1
1
  import * as React from 'react';
2
- import { RbmComponentProps, WithNoChildren } from '../RbmComponentProps';
2
+ import { RbmComponentProps } from '../RbmComponentProps';
3
3
  import { IconSource } from '../Icon/Icon';
4
- export type MenuItem = {
4
+ export type MenuItemType = {
5
5
  label: string;
6
- callback: () => void;
7
- icon?: IconSource;
6
+ icon?: IconSource | {
7
+ icon: IconSource;
8
+ color: string;
9
+ };
8
10
  key: string;
11
+ className?: string;
12
+ callback: () => void;
13
+ onMouseEnter?: () => void;
14
+ onMouseLeave?: () => void;
9
15
  };
10
16
  export type MenuProps = RbmComponentProps<{
11
- items: MenuItem[];
17
+ items?: MenuItemType[];
12
18
  x: number;
13
19
  y: number;
14
20
  isOpen: boolean;
15
21
  onClose: () => void;
16
- }, WithNoChildren>;
17
- export declare const Menu: ({ className, style, items, y, x, isOpen, onClose }: MenuProps) => React.JSX.Element | null;
22
+ offsetX?: number;
23
+ offsetY?: number;
24
+ }>;
25
+ export declare const Menu: ({ className, style, items, y, x, isOpen, onClose, children, offsetY, offsetX, }: MenuProps) => React.JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ export declare const MenuCloseContextProvider: React.Provider<() => void>;
3
+ export declare function useMenuClose(): () => void;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const MenuDivider: () => React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { IconSource } from "../Icon/Icon";
2
+ import React, { ReactNode } from "react";
3
+ import { RbmComponentProps, WithChildren } from "../RbmComponentProps";
4
+ import Element = React.JSX.Element;
5
+ export type MenuItemProps<Item = undefined> = RbmComponentProps<{
6
+ icon?: IconSource;
7
+ iconColor?: string;
8
+ className?: string;
9
+ children: string | ReactNode;
10
+ disabled?: boolean;
11
+ active?: boolean;
12
+ } & ({
13
+ onClick: (item: Item) => void;
14
+ onMouseEnter?: (item: Item) => void;
15
+ onMouseLeave?: (item: Item) => void;
16
+ item?: undefined;
17
+ } | {
18
+ onClick: (item: Item) => void;
19
+ onMouseEnter?: (item: Item) => void;
20
+ onMouseLeave?: (item: Item) => void;
21
+ item: Item;
22
+ }), WithChildren>;
23
+ export declare const MenuItem: <Item>({ children, icon, iconColor, className, onClick, onMouseEnter, onMouseLeave, active, item, disabled, ...props }: MenuItemProps<Item>) => Element;
@@ -0,0 +1,10 @@
1
+ import { RbmComponentProps, WithNoStringAndChildrenProps } from "../RbmComponentProps";
2
+ import { IconSource } from "../Icon/Icon";
3
+ import React from "react";
4
+ export type SubmenuProps = RbmComponentProps<{
5
+ label: string;
6
+ icon?: IconSource;
7
+ iconColor?: string;
8
+ disabled?: boolean;
9
+ }, WithNoStringAndChildrenProps>;
10
+ export declare const Submenu: ({ children, label, icon, iconColor, className, style, disabled }: SubmenuProps) => React.JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import { MouseEvent } from 'react';
2
2
  import { MenuProps } from './Menu';
3
- export declare function useMenu(): readonly [(e: MouseEvent) => void, Omit<MenuProps, "items">];
3
+ export declare function useMenu(): readonly [(e: MouseEvent) => void, Omit<MenuProps, "children" | "items">];
@@ -18,6 +18,10 @@ export type WithNoStringAndChildrenProps = {
18
18
  export type WithStringProps = {
19
19
  children?: Recursive<string>;
20
20
  };
21
+ export type WithChildren = {
22
+ children: ReactNode;
23
+ __allowChildren?: "text" | "all" | "html";
24
+ };
21
25
  export type WithStringAndChildrenProps = {
22
26
  children: Recursive<string>;
23
27
  };
@@ -0,0 +1 @@
1
+ export declare const ListRow: () => null;
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@ainias42/react-bootstrap-mobile",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Mobile React Components using Bootstrap",
5
5
  "main": "dist/bootstrapReactMobile",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
8
  "build": "node bin/build.js && webpack",
9
9
  "build:production": "node bin/build.js && webpack --env production",
10
- "update packages": "node bin/updateCopies.js"
10
+ "update packages": "node bin/updateCopies.js",
11
+ "typecheck": "tsc --no-emit"
11
12
  },
12
13
  "repository": {
13
14
  "type": "git",
@@ -28,10 +29,10 @@
28
29
  },
29
30
  "homepage": "https://github.com/Ainias/Bootstrap-React-Mobile#readme",
30
31
  "peerDependencies": {
31
- "@fortawesome/fontawesome-svg-core": "^1.3.0",
32
- "@fortawesome/free-regular-svg-icons": "^5.15.4",
33
- "@fortawesome/free-solid-svg-icons": "^5.15.4",
34
- "@fortawesome/react-fontawesome": "^0.1.16",
32
+ "@fortawesome/fontawesome-svg-core": "^6.4.0",
33
+ "@fortawesome/free-regular-svg-icons": "^6.4.0",
34
+ "@fortawesome/free-solid-svg-icons": "^6.4.0",
35
+ "@fortawesome/react-fontawesome": "^0.2.0",
35
36
  "react": ">=17.0.0",
36
37
  "react-beautiful-dnd": "^13.1.1"
37
38
  },
@@ -81,7 +82,7 @@
81
82
  "@types/react-virtualized-auto-sizer": "^1.0.1",
82
83
  "classnames": "^2.3.1",
83
84
  "isomorphic-style-loader": "^5.3.2",
84
- "@ainias42/js-helper": ">=0.8.1",
85
+ "@ainias42/js-helper": ">=0.8.9",
85
86
  "react-color": "^2.19.3",
86
87
  "react-table": "^7.7.0",
87
88
  "react-virtualized-auto-sizer": "^1.0.7",
@@ -1,16 +1,18 @@
1
1
  import * as React from 'react';
2
- import { RbmComponentProps } from '../RbmComponentProps';
3
- import { OptionalListener, useListener } from '../Hooks/useListener';
2
+ import {RbmComponentProps} from '../RbmComponentProps';
3
+ import {OptionalListener, useListener} from '../Hooks/useListener';
4
4
 
5
5
  import styles from './clickable.scss';
6
6
  import classNames from 'classnames';
7
- import { useCallback, MouseEvent, ForwardedRef } from 'react';
8
- import { withForwardRef } from '../../helper/withForwardRef';
7
+ import {useCallback, MouseEvent, ForwardedRef} from 'react';
8
+ import {withForwardRef} from '../../helper/withForwardRef';
9
9
 
10
10
  type OnClickListener<Data> = OptionalListener<'onClick', Data>;
11
11
  type OnMouseDownListener<Data> = OptionalListener<'onMouseDown', Data>;
12
12
  type OnMouseUpListener<Data> = OptionalListener<'onMouseUp', Data>;
13
13
  type OnMouseMoveListener<Data> = OptionalListener<'onMouseMove', Data>;
14
+ type OnDropListener<Data> = OptionalListener<'onDrop', Data>;
15
+ type OnDragOverListener<Data> = OptionalListener<'onDragOver', Data>;
14
16
 
15
17
  export type ClickableProps<
16
18
  OnClickData,
@@ -18,6 +20,10 @@ export type ClickableProps<
18
20
  OnMouseMoveData,
19
21
  OnMouseUpData,
20
22
  OnClickCaptureData,
23
+ OnDropData,
24
+ OnDragOverData,
25
+ OnMouseEnterData,
26
+ OnMouseLeaveData,
21
27
  HrefType extends string | undefined
22
28
  > = RbmComponentProps<
23
29
  {
@@ -26,10 +32,14 @@ export type ClickableProps<
26
32
  preventDefault?: boolean;
27
33
  stopPropagation?: boolean;
28
34
  } & OnClickListener<OnClickData> &
29
- OnMouseDownListener<OnMouseDownData> &
30
- OnMouseMoveListener<OnMouseMoveData> &
31
- OnMouseUpListener<OnMouseUpData> &
32
- OptionalListener<'onClickCapture', OnClickCaptureData>
35
+ OnMouseDownListener<OnMouseDownData> &
36
+ OnMouseMoveListener<OnMouseMoveData> &
37
+ OnMouseUpListener<OnMouseUpData> &
38
+ OnDropListener<OnDropData> &
39
+ OnDragOverListener<OnDragOverData> &
40
+ OptionalListener<'onClickCapture', OnClickCaptureData> &
41
+ OptionalListener<'onMouseEnter', OnMouseEnterData> &
42
+ OptionalListener<'onMouseLeave', OnMouseLeaveData>
33
43
  >;
34
44
 
35
45
  function Clickable<
@@ -38,6 +48,10 @@ function Clickable<
38
48
  OnMouseMoveData,
39
49
  OnMouseUpData,
40
50
  OnClickCaptureData,
51
+ OnDropData,
52
+ OnDragOverData,
53
+ OnMouseEnterData,
54
+ OnMouseLeaveData,
41
55
  HrefType extends string | undefined
42
56
  >(
43
57
  {
@@ -46,10 +60,10 @@ function Clickable<
46
60
  style,
47
61
  href,
48
62
  interactable = true,
49
- preventDefault = true,
63
+ preventDefault = false,
50
64
  stopPropagation = true,
51
65
  ...clickData
52
- }: ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, HrefType>,
66
+ }: ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, OnDropData, OnDragOverData,OnMouseEnterData, OnMouseLeaveData, HrefType>,
53
67
  ref: ForwardedRef<HrefType extends string ? HTMLAnchorElement : HTMLSpanElement>
54
68
  ) {
55
69
  // Variables
@@ -124,7 +138,7 @@ function Clickable<
124
138
  );
125
139
 
126
140
  const onClickCaptureInner = useListener<'onClickCapture', OnClickCaptureData>('onClickCapture', clickData);
127
- const realOnClickCaptureInner = useCallback(
141
+ const realOnClickCapture = useCallback(
128
142
  (e: MouseEvent) => {
129
143
  if (clickData.onClickCapture) {
130
144
  if (stopPropagation) {
@@ -139,6 +153,70 @@ function Clickable<
139
153
  [clickData.onClickCapture, onClickCaptureInner, preventDefault, stopPropagation]
140
154
  );
141
155
 
156
+ const onDropInner = useListener<'onDrop', OnDropData>('onDrop', clickData);
157
+ const realOnDrop = useCallback(
158
+ (e: MouseEvent) => {
159
+ if (clickData.onDrop) {
160
+ if (stopPropagation) {
161
+ e.stopPropagation();
162
+ }
163
+ if (preventDefault) {
164
+ e.preventDefault();
165
+ }
166
+ onDropInner(e);
167
+ }
168
+ },
169
+ [clickData.onDrop, onDropInner, preventDefault, stopPropagation]
170
+ );
171
+
172
+ const onDragOver = useListener<'onDragOver', OnDragOverData>('onDragOver', clickData);
173
+ const realOnDragOver = useCallback(
174
+ (e: MouseEvent) => {
175
+ if (clickData.onDragOver) {
176
+ if (stopPropagation) {
177
+ e.stopPropagation();
178
+ }
179
+ if (preventDefault) {
180
+ e.preventDefault();
181
+ }
182
+ onDragOver(e);
183
+ }
184
+ },
185
+ [clickData.onDragOver, onDragOver, preventDefault, stopPropagation]
186
+ );
187
+
188
+ const onMouseEnter = useListener<'onMouseEnter', OnMouseEnterData>('onMouseEnter', clickData);
189
+ const realOnMouseEnter = useCallback(
190
+ (e: MouseEvent) => {
191
+ if (clickData.onMouseEnter) {
192
+ if (stopPropagation) {
193
+ e.stopPropagation();
194
+ }
195
+ if (preventDefault) {
196
+ e.preventDefault();
197
+ }
198
+ onMouseEnter(e);
199
+ }
200
+ },
201
+ [clickData.onMouseEnter, onMouseEnter, preventDefault, stopPropagation]
202
+ );
203
+
204
+ const onMouseLeave = useListener<'onMouseLeave', OnMouseLeaveData>('onMouseLeave', clickData);
205
+ const realOnMouseLeave = useCallback(
206
+ (e: MouseEvent) => {
207
+ if (clickData.onMouseLeave) {
208
+ if (stopPropagation) {
209
+ e.stopPropagation();
210
+ }
211
+ if (preventDefault) {
212
+ e.preventDefault();
213
+ }
214
+ onMouseLeave(e);
215
+ }
216
+ },
217
+ [clickData.onMouseLeave, onMouseLeave, preventDefault, stopPropagation]
218
+ );
219
+
142
220
  // Effects
143
221
 
144
222
  // Other
@@ -153,7 +231,11 @@ function Clickable<
153
231
  onMouseDown: realOnMouseDown,
154
232
  onMouseMove: realOnMouseMove,
155
233
  onMouseUp: realOnMouseUp,
156
- onClickCapture: realOnClickCaptureInner,
234
+ onClickCapture: realOnClickCapture,
235
+ onDrop: realOnDrop,
236
+ onDragOver: realOnDragOver,
237
+ onMouseEnter: realOnMouseEnter,
238
+ onMouseLeave: realOnMouseLeave,
157
239
  tabIndex: interactable ? 0 : undefined,
158
240
  };
159
241
  if (typeof href === 'string') {
@@ -171,4 +253,4 @@ function Clickable<
171
253
  }
172
254
 
173
255
  const ClickableMemo = withForwardRef(Clickable, styles);
174
- export { ClickableMemo as Clickable };
256
+ export {ClickableMemo as Clickable};
@@ -2,14 +2,14 @@ import * as React from 'react';
2
2
  import { withMemo } from '../../helper/withMemo';
3
3
  import { RbmComponentProps } from '../RbmComponentProps';
4
4
  import { Block } from '../Layout/Block';
5
- import { EmptyProps } from '../../helper/EmptyProps';
6
5
 
7
6
  import styles from './dialogBackground.scss';
8
7
  import classNames from 'classnames';
8
+ import {Heading} from "../Text/Heading";
9
9
 
10
- export type DialogBackgroundProps = RbmComponentProps<EmptyProps>;
10
+ export type DialogBackgroundProps = RbmComponentProps<{title?: string}>;
11
11
 
12
- function DialogBackground({ children, className, style }: DialogBackgroundProps) {
12
+ export const DialogBackground = withMemo(function DialogBackground({ children, className, style, title }: DialogBackgroundProps) {
13
13
  // Variables
14
14
 
15
15
  // Refs
@@ -28,11 +28,8 @@ function DialogBackground({ children, className, style }: DialogBackgroundProps)
28
28
 
29
29
  return (
30
30
  <Block __allowChildren="all" className={classNames(styles.dialogBackground, className)} style={style}>
31
+ {!!title && <Heading className={styles.title}>{title}</Heading>}
31
32
  {children}
32
33
  </Block>
33
34
  );
34
- }
35
-
36
- // Need DialogBackgroundMemo for autocompletion of phpstorm
37
- const DialogBackgroundMemo = withMemo(DialogBackground, styles);
38
- export { DialogBackgroundMemo as DialogBackground };
35
+ }, styles);
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { withMemo } from '../../helper/withMemo';
3
- import { ComponentType, PropsWithChildren, useCallback, useState } from 'react';
2
+ import {ComponentType, ForwardedRef, PropsWithChildren, useCallback, useImperativeHandle, useState} from 'react';
4
3
  import { PromiseWithHandlers } from '@ainias42/js-helper';
5
4
  import { DialogProvider, ShowDialog } from './DialogContext';
6
5
  import { Dialog } from './Dialog';
7
6
  import { EmptyProps } from '../../helper/EmptyProps';
7
+ import {withForwardRef} from "../../helper/withForwardRef";
8
8
 
9
9
  export type DialogContainerProps = PropsWithChildren<EmptyProps>;
10
10
 
@@ -15,7 +15,11 @@ type DialogData = {
15
15
  resultPromise: PromiseWithHandlers<any>;
16
16
  };
17
17
 
18
- function DialogContainer({ children }: DialogContainerProps) {
18
+ export type DialogContainerRef = {
19
+ showDialog: ShowDialog;
20
+ }
21
+
22
+ export const DialogContainer = withForwardRef(function DialogContainer({ children }: DialogContainerProps, ref: ForwardedRef<DialogContainerRef>) {
19
23
  // Variables
20
24
  const [dialogs, setDialogs] = useState<DialogData[]>([]);
21
25
  const [, setLastId] = useState(0);
@@ -52,6 +56,10 @@ function DialogContainer({ children }: DialogContainerProps) {
52
56
  }, []);
53
57
 
54
58
  // Effects
59
+ useImperativeHandle(ref, () => ({
60
+ showDialog
61
+ }), [showDialog]);
62
+
55
63
 
56
64
  // Other
57
65
 
@@ -70,8 +78,4 @@ function DialogContainer({ children }: DialogContainerProps) {
70
78
  })}
71
79
  </DialogProvider>
72
80
  );
73
- }
74
-
75
- // Need DialogContainerMemo for autocompletion of phpstorm
76
- const DialogContainerMemo = withMemo(DialogContainer);
77
- export { DialogContainerMemo as DialogContainer };
81
+ });
@@ -16,6 +16,5 @@ const DialogContext = React.createContext<ShowDialog>(() => Promise.reject());
16
16
  export const DialogProvider = DialogContext.Provider;
17
17
 
18
18
  export function useDialog() {
19
- const showDialog = useContext(DialogContext);
20
- return showDialog as ShowDialog;
19
+ return useContext(DialogContext);
21
20
  }
@@ -1,4 +1,8 @@
1
1
  .dialogBackground {
2
2
  background-color: white;
3
- padding: 0.3rem;
3
+ padding: 0.5rem;
4
+
5
+ .title {
6
+ margin: 0 0 0.8rem;
7
+ }
4
8
  }
@@ -29,9 +29,10 @@ function DropArea({ children, style, className, ...dropProps }: DropAreaProps) {
29
29
 
30
30
  return (
31
31
  <Droppable {...dropProps}>
32
- {({ innerRef, droppableProps }) => (
32
+ {({ innerRef, droppableProps, placeholder }) => (
33
33
  <div {...droppableProps} ref={innerRef} style={style} className={className}>
34
34
  {children}
35
+ {placeholder}
35
36
  </div>
36
37
  )}
37
38
  </Droppable>