@ainias42/react-bootstrap-mobile 0.1.15 → 0.1.17

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 (81) hide show
  1. package/bin/updateCopies.js +9 -5
  2. package/bootstrapReactMobile.ts +13 -2
  3. package/dist/bootstrapReactMobile.d.ts +13 -2
  4. package/dist/bootstrapReactMobile.js +992 -395
  5. package/dist/bootstrapReactMobile.js.map +1 -1
  6. package/dist/src/Components/Clickable/Clickable.d.ts +7 -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/DragAndDrop/DragItem.d.ts +1 -1
  10. package/dist/src/Components/Flavor.d.ts +4 -0
  11. package/dist/src/Components/FormElements/Button/Button.d.ts +8 -4
  12. package/dist/src/Components/FormElements/Button/ButtonType.d.ts +4 -0
  13. package/dist/src/Components/FormElements/Input/FileInput/FileInput.d.ts +12 -0
  14. package/dist/src/Components/FormElements/Input/FileInput/FileType.d.ts +7 -0
  15. package/dist/src/Components/FormElements/Input/FileInput/MultipleFileInput.d.ts +17 -0
  16. package/dist/src/Components/FormElements/Select/Select.d.ts +2 -1
  17. package/dist/src/Components/FormElements/Switch/Switch.d.ts +4 -4
  18. package/dist/src/Components/Hooks/useMousePosition.d.ts +5 -0
  19. package/dist/src/Components/Hooks/useWindowDimensions.d.ts +4 -0
  20. package/dist/src/Components/Icon/Icon.d.ts +2 -3
  21. package/dist/src/Components/Layout/Grid/Grid.d.ts +2 -1
  22. package/dist/src/Components/Layout/Grid/GridItem.d.ts +4 -1
  23. package/dist/src/Components/Menu/HoverMenu.d.ts +9 -0
  24. package/dist/src/Components/Menu/Menu.d.ts +16 -7
  25. package/dist/src/Components/Menu/MenuCloseContext.d.ts +3 -0
  26. package/dist/src/Components/Menu/MenuDivider.d.ts +2 -0
  27. package/dist/src/Components/Menu/MenuItem.d.ts +23 -0
  28. package/dist/src/Components/Menu/Submenu.d.ts +12 -0
  29. package/dist/src/Components/Menu/useMenu.d.ts +1 -1
  30. package/dist/src/Components/RbmComponentProps.d.ts +4 -0
  31. package/dist/src/Components/Text/Text.d.ts +1 -0
  32. package/dist/src/ListRow/ListRow.d.ts +1 -0
  33. package/package.json +8 -7
  34. package/src/Components/Clickable/Clickable.tsx +135 -19
  35. package/src/Components/Dialog/DialogBackground.tsx +5 -8
  36. package/src/Components/Dialog/DialogContainer.tsx +12 -8
  37. package/src/Components/Dialog/DialogContext.ts +1 -2
  38. package/src/Components/Dialog/dialogBackground.scss +5 -1
  39. package/src/Components/DragAndDrop/DragItem.tsx +7 -7
  40. package/src/Components/DragAndDrop/DropArea.tsx +2 -1
  41. package/src/Components/Flavor.ts +4 -0
  42. package/src/Components/FormElements/Button/Button.tsx +31 -13
  43. package/src/Components/FormElements/Button/ButtonType.ts +4 -0
  44. package/src/Components/FormElements/Button/button.scss +22 -5
  45. package/src/Components/FormElements/Input/FileInput/FileInput.tsx +55 -0
  46. package/src/Components/FormElements/Input/FileInput/FileType.ts +1 -0
  47. package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +281 -0
  48. package/src/Components/FormElements/{ImageInput/imageInput.scss → Input/FileInput/fileInput.scss} +37 -7
  49. package/src/Components/FormElements/Input/input.scss +1 -1
  50. package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +2 -2
  51. package/src/Components/FormElements/SearchSelectInput/seachSelectInput.scss +1 -1
  52. package/src/Components/FormElements/Select/Select.tsx +3 -2
  53. package/src/Components/FormElements/Select/select.scss +5 -0
  54. package/src/Components/FormElements/Switch/Switch.tsx +9 -8
  55. package/src/Components/FormElements/Switch/switch.scss +1 -0
  56. package/src/Components/Hooks/useMousePosition.ts +13 -0
  57. package/src/Components/Hooks/useWindowDimensions.ts +17 -0
  58. package/src/Components/Icon/Icon.tsx +18 -14
  59. package/src/Components/Icon/icon.scss +9 -0
  60. package/src/Components/Layout/Grid/Grid.tsx +3 -2
  61. package/src/Components/Layout/Grid/GridItem.tsx +16 -1
  62. package/src/Components/Layout/Grid/grid.scss +113 -36
  63. package/src/Components/Menu/HoverMenu.tsx +82 -0
  64. package/src/Components/Menu/Menu.tsx +101 -47
  65. package/src/Components/Menu/MenuCloseContext.ts +10 -0
  66. package/src/Components/Menu/MenuDivider.tsx +22 -0
  67. package/src/Components/Menu/MenuItem.tsx +95 -0
  68. package/src/Components/Menu/Submenu.tsx +101 -0
  69. package/src/Components/Menu/menu.scss +99 -10
  70. package/src/Components/Menu/useMenu.ts +1 -1
  71. package/src/Components/RbmComponentProps.ts +6 -0
  72. package/src/Components/Text/Text.tsx +1 -0
  73. package/src/Components/Text/text.scss +13 -5
  74. package/src/ListRow/ListRow.tsx +20 -0
  75. package/src/WrongChildError.ts +0 -2
  76. package/src/scss/_colors.scss +1 -1
  77. package/src/scss/_flavorMixin.scss +10 -0
  78. package/dist/src/Components/FormElements/ImageInput/ImageInput.d.ts +0 -18
  79. package/dist/src/Components/FormElements/ImageInput/MultipleFileInput.d.ts +0 -21
  80. package/src/Components/FormElements/ImageInput/ImageInput.tsx +0 -98
  81. package/src/Components/FormElements/ImageInput/MultipleFileInput.tsx +0 -240
@@ -0,0 +1,101 @@
1
+ import {RbmComponentProps, WithNoStringAndChildrenProps} from "../RbmComponentProps";
2
+ import {Icon, IconSource} from "../Icon/Icon";
3
+ import {Clickable} from "../Clickable/Clickable";
4
+ import classNames from "classnames";
5
+ import styles from "./menu.scss";
6
+ import React, {useCallback, useRef, useState} from "react";
7
+ import {Text} from "../Text/Text";
8
+ import {withMemo} from "../../helper/withMemo";
9
+ import {Block} from "../Layout/Block";
10
+ import {useWindow} from "../../WindowContext/WindowContext";
11
+ import {Flex} from "../Layout/Flex";
12
+ import {Grow} from "../Layout/Grow";
13
+ import {faChevronRight} from "@fortawesome/free-solid-svg-icons";
14
+ import {MenuCloseContextProvider, useMenuClose} from "./MenuCloseContext";
15
+
16
+ export type SubmenuProps = RbmComponentProps<{
17
+ label: string, icon?: IconSource;
18
+ iconColor?: string;
19
+ disabled?: boolean;
20
+ onMouseEnter?: () => void;
21
+ onMouseLeave?: () => void;
22
+ }, WithNoStringAndChildrenProps>;
23
+
24
+ export const Submenu = withMemo(function Submenu({
25
+ children,
26
+ label,
27
+ icon,
28
+ iconColor,
29
+ className,
30
+ style,
31
+ disabled = false,
32
+ onMouseEnter,
33
+ onMouseLeave,
34
+ }: SubmenuProps) {
35
+ // Refs
36
+
37
+ // States/Variables/Selectors
38
+ const window = useWindow();
39
+ const containerRef = useRef<HTMLDivElement>(null);
40
+ const submenuRef = useRef<HTMLDivElement>(null);
41
+
42
+ const [openLeft, setOpenLeft] = useState(false);
43
+ const [openTop, setOpenTop] = useState(false);
44
+ const [isOpen, setIsOpen] = useState(false);
45
+
46
+ // Dispatch
47
+
48
+ // Callbacks
49
+ const recalculateSubmenuPosition = useCallback(() => {
50
+ if (!submenuRef.current || !containerRef.current) {
51
+ return;
52
+ }
53
+ const {width, height} = getComputedStyle(containerRef.current);
54
+ const {right, top} = submenuRef.current.getBoundingClientRect();
55
+
56
+ setOpenLeft(right + parseFloat(width) >= (window?.innerWidth ?? 0));
57
+ setOpenTop(top + parseFloat(height) >= (window?.innerHeight ?? 0));
58
+ setIsOpen(true);
59
+ onMouseEnter?.();
60
+ }, [onMouseEnter, window?.innerHeight, window?.innerWidth]);
61
+
62
+ const closeSubmenu = useCallback(() => {
63
+ setIsOpen(false);
64
+ onMouseLeave?.();
65
+ }, [onMouseLeave]);
66
+
67
+ const closeParent = useMenuClose();
68
+ const closeAllMenus = useCallback(() => {
69
+ closeSubmenu();
70
+ closeParent();
71
+ }, [closeParent, closeSubmenu]);
72
+
73
+ // Effects
74
+
75
+ // Other
76
+
77
+ // RenderFunctions
78
+
79
+ return <MenuCloseContextProvider value={closeAllMenus}>
80
+ <Clickable
81
+ onMouseEnter={recalculateSubmenuPosition}
82
+ onMouseLeave={closeSubmenu}
83
+ className={classNames(styles.item, styles.submenu, {
84
+ [styles.open]: isOpen,
85
+ [styles.openLeft]: openLeft,
86
+ [styles.openTop]: openTop,
87
+ [styles.disabled]: disabled
88
+ }, className)}
89
+ style={style}
90
+ >
91
+ <Flex ref={submenuRef} className={classNames(styles.itemChildren)} horizontal={true}>
92
+ {!!icon && <Icon icon={icon} color={iconColor} className={styles.icon}/>}
93
+ <Grow><Text>{label}</Text></Grow>
94
+ <Icon icon={faChevronRight}/>
95
+ </Flex>
96
+ <Block className={styles.container} __allowChildren="all" ref={containerRef}>
97
+ {children}
98
+ </Block>
99
+ </Clickable>
100
+ </MenuCloseContextProvider>;
101
+ }, styles);
@@ -1,21 +1,110 @@
1
-
2
1
  .menu {
3
2
  position: fixed;
4
3
  background: #ffffff;
5
4
  border: 1px solid var(--border-light);
5
+ border-radius: 2px;
6
+ z-index: 1000;
7
+
8
+ &.hidden {
9
+ visibility: hidden;
10
+ }
11
+ }
12
+
13
+ .divider {
14
+ margin-left: 4px;
15
+ margin-right: 4px;
16
+ padding-top: 1px;
17
+ margin-top: 1px;
18
+ border-top: 1px solid var(--border-light);
19
+ }
20
+
21
+ .item {
22
+ padding: 0 4px;
23
+ display: flex;
24
+ //background: #ffffff;
25
+
26
+ &.active {
27
+ background-color: #e1e1e1;
28
+ }
6
29
 
7
- .item {
8
- display: block;
9
- border-top: 1px solid var(--border-light);
10
- padding: 8px;
11
- margin: 0 4px;
30
+ .itemChildren {
31
+ flex: 1;
32
+ padding: 1px;
33
+ display: flex;
34
+ flex-direction: row;
35
+ align-items: center;
36
+ //border-top: 1px solid var(--border-light);
37
+ white-space: nowrap;
12
38
 
13
- &:hover {
14
- background-color: #f5f5f5;
39
+ .icon {
40
+ margin-right: 4px;
15
41
  }
42
+ }
43
+
44
+ &.disabled {
45
+ pointer-events: none;
46
+ cursor: default;
47
+
48
+ > .itemChildren > * {
49
+ opacity: 0.3;
50
+ }
51
+ }
52
+
53
+ &:hover {
54
+ background-color: #f5f5f5;
55
+ }
56
+
57
+ &:first-child > .itemChildren {
58
+ border-top: none;
59
+ }
60
+ }
61
+
62
+ .hoverMenu {
63
+ padding: 0;
64
+ display: inline;
65
+
66
+ .menu {
67
+ visibility: hidden;
68
+ pointer-events: none;
69
+ }
70
+
71
+ &.open:hover {
72
+ .menu {
73
+ visibility: visible;
74
+ pointer-events: initial;
75
+ }
76
+ }
77
+ }
78
+
79
+ .submenu {
80
+ position: relative;
81
+
82
+ .container {
83
+ visibility: hidden;
84
+ pointer-events: none;
85
+ position: absolute;
86
+ top: 3px;
87
+ left: calc(100% - 3px);
88
+ background: #ffffff;
89
+ border: 1px solid var(--border-light);
90
+ border-radius: 2px;
91
+ z-index: 10;
92
+ }
93
+
94
+ &.openLeft .container {
95
+ left: initial;
96
+ right: calc(100% - 3px);
97
+ }
98
+
99
+ &.openTop .container {
100
+ top: initial;
101
+ bottom: 3px;
102
+ }
16
103
 
17
- &:first-child {
18
- border-top: none;
104
+ &.open:hover {
105
+ .container {
106
+ visibility: visible;
107
+ pointer-events: initial;
19
108
  }
20
109
  }
21
110
  }
@@ -9,7 +9,7 @@ export function useMenu() {
9
9
  setIsOpen(true);
10
10
  }, []);
11
11
 
12
- const props: Omit<MenuProps, 'items'> = {
12
+ const props: Omit<MenuProps, 'items'|"children"> = {
13
13
  isOpen,
14
14
  x: position.x,
15
15
  y: position.y,
@@ -26,6 +26,12 @@ export type WithStringProps = {
26
26
  children?: Recursive<string>;
27
27
  };
28
28
 
29
+ export type WithChildren =
30
+ | {
31
+ children: ReactNode
32
+ __allowChildren?: "text"|"all"|"html";
33
+ };
34
+
29
35
  export type WithStringAndChildrenProps = {
30
36
  children: Recursive<string>;
31
37
  };
@@ -11,6 +11,7 @@ import { ViewProps } from '../Layout/View';
11
11
  export const TEXT_PRIO = {
12
12
  primary: styles.primary,
13
13
  secondary: styles.secondary,
14
+ tertiary: styles.tertiary,
14
15
  heading: styles.heading,
15
16
  };
16
17
 
@@ -1,8 +1,12 @@
1
- $primaryColor: #000000;
2
- $secondaryColor: #717171;
1
+ $primaryColor: #18181B; // Gray-900
2
+ $secondaryColor: #71717a; // Gray-500
3
+ $tertiaryColor: #A1A1AA; // Gray-400
3
4
 
4
5
  :root {
5
- --text-primary-default-color: $primaryColor;
6
+ --text-primary-default-color: #{$primaryColor};
7
+ --text-prmary: #{$primaryColor};
8
+ --text-secondary: #{$secondaryColor};
9
+ --text-tertiary: #{$tertiaryColor};
6
10
  }
7
11
 
8
12
  .text {
@@ -21,11 +25,15 @@ $secondaryColor: #717171;
21
25
  }
22
26
 
23
27
  &.primary {
24
- color: $primaryColor
28
+ color: var(--text-primary)
25
29
  }
26
30
 
27
31
  &.secondary {
28
- color: $secondaryColor;
32
+ color: var(--text-secondary);
33
+ }
34
+
35
+ &.tertiary {
36
+ color: var(--text-tertiary);
29
37
  }
30
38
 
31
39
  &.xsmall {
@@ -0,0 +1,20 @@
1
+ import {withMemo} from "../helper/withMemo";
2
+
3
+
4
+ export const ListRow = withMemo(function ListRow() {
5
+ // Refs
6
+
7
+ // States/Variables/Selectors
8
+
9
+ // Dispatch
10
+
11
+ // Callbacks
12
+
13
+ // Effects
14
+
15
+ // Other
16
+
17
+ // RenderFunctions
18
+
19
+ return null;
20
+ });
@@ -13,7 +13,5 @@ export class WrongChildError extends Error {
13
13
  );
14
14
  this.name = 'WrongChildError';
15
15
  this.childValue = child;
16
-
17
- console.log('LOG-d stack', this.stack);
18
16
  }
19
17
  }
@@ -1,11 +1,11 @@
1
1
  @include design($material) {
2
2
  --flavor-accent: #37474f;
3
- --flavor-focus: var(--flavor-accent);
4
3
  }
5
4
 
6
5
  :root {
7
6
  --border-light: #cecece;
8
7
  --border-strong: #717171;
8
+ --flavor-basic: #000000
9
9
  }
10
10
 
11
11
  @include design($flat) {
@@ -0,0 +1,10 @@
1
+ @use 'sass:selector';
2
+
3
+ @mixin flavorSelection($varName) {
4
+ &:global(.flavor-accent) {
5
+ #{$varName}: var(--flavor-accent);
6
+ }
7
+ &:global(.flavor-basic) {
8
+ #{$varName}: var(--flavor-basic);
9
+ }
10
+ }
@@ -1,18 +0,0 @@
1
- import * as React from 'react';
2
- import { RbmComponentProps } from '../../RbmComponentProps';
3
- import { Override } from '../../../TypeHelpers';
4
- import { InputHTMLAttributes } from 'react';
5
- import { OptionalListener } from '../../Hooks/useListener';
6
- export type ImageType = {
7
- name: string;
8
- url: string;
9
- };
10
- export type ImageInputProps<OnChangeData> = RbmComponentProps<Override<InputHTMLAttributes<HTMLInputElement>, {
11
- defaultValue?: ImageType;
12
- value?: ImageType;
13
- label?: string;
14
- onChangeImage?: (image: ImageType, imageData: File) => void;
15
- } & OptionalListener<'onChange', OnChangeData>>>;
16
- declare function ImageInput<OnChangeData>({ className, style, value, defaultValue, onChangeImage, label, ...otherProps }: ImageInputProps<OnChangeData>): React.JSX.Element;
17
- declare const ImageInputMemo: typeof ImageInput;
18
- export { ImageInputMemo as ImageInput };
@@ -1,21 +0,0 @@
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
- export type FileType = {
7
- name: string;
8
- url: string;
9
- mimeType: string;
10
- uploaded?: boolean;
11
- blob?: Blob;
12
- };
13
- export type MultipleImageInputProps<OnChangeFilesData> = RbmComponentProps<Override<Omit<InputHTMLAttributes<HTMLInputElement>, 'defaultValue' | 'onChange'>, {
14
- value: FileType[];
15
- label?: string;
16
- mimeTypes?: string[];
17
- maxFiles?: number;
18
- maxSizePerFile?: number;
19
- onError?: (error: string) => void;
20
- } & Listener<'onChangeFiles', OnChangeFilesData, FileType[]>>>;
21
- export declare const MultipleFileInput: <OnChangeData>({ className, style, value, label, mimeTypes, maxFiles, maxSizePerFile, onError, ...otherProps }: MultipleImageInputProps<OnChangeData>) => React.JSX.Element;
@@ -1,98 +0,0 @@
1
- import * as React from 'react';
2
- import { RbmComponentProps } from '../../RbmComponentProps';
3
- import { Override } from '../../../TypeHelpers';
4
- import { ChangeEventHandler, InputHTMLAttributes, useCallback, useState } from 'react';
5
- import { OptionalListener, useListener } from '../../Hooks/useListener';
6
- import { Button } from '../Button/Button';
7
-
8
- import styles from './imageInput.scss';
9
- import { withMemo } from '../../../helper/withMemo';
10
- import classNames from 'classnames';
11
-
12
- export type ImageType = { name: string; url: string };
13
-
14
- export type ImageInputProps<OnChangeData> = RbmComponentProps<
15
- Override<
16
- InputHTMLAttributes<HTMLInputElement>,
17
- {
18
- defaultValue?: ImageType;
19
- value?: ImageType;
20
- label?: string;
21
- onChangeImage?: (image: ImageType, imageData: File) => void;
22
- } & OptionalListener<'onChange', OnChangeData>
23
- >
24
- >;
25
-
26
- // TODO use MultipleFileInput internal
27
- function ImageInput<OnChangeData>({
28
- className,
29
- style,
30
- value,
31
- defaultValue,
32
- onChangeImage,
33
- label,
34
- ...otherProps
35
- }: ImageInputProps<OnChangeData>) {
36
- // Variables
37
- const [image, setImage] = useState(defaultValue);
38
-
39
- // Refs
40
-
41
- // States
42
-
43
- // Selectors
44
-
45
- // Callbacks
46
- const onChangeWithData = useListener<'onChange', OnChangeData>('onChange', otherProps);
47
- const getBase64 = useCallback((file: Blob) => {
48
- return new Promise<string>((resolve, reject) => {
49
- const reader = new FileReader();
50
- reader.onload = () => {
51
- resolve(reader.result as string);
52
- };
53
- reader.onerror = reject;
54
- reader.readAsDataURL(file);
55
- });
56
- }, []);
57
- const onChange = useCallback<ChangeEventHandler<HTMLInputElement>>(
58
- async (e) => {
59
- if (!e.target.files || e.target.files.length === 0) {
60
- return;
61
- }
62
-
63
- onChangeWithData(e);
64
- const newUrl = await getBase64(e.target.files[0]);
65
- const newValue = { name: e.target.files[0].name, url: newUrl };
66
- setImage(newValue);
67
-
68
- if (onChangeImage) {
69
- onChangeImage(newValue, e.target.files[0]);
70
- }
71
- },
72
- [onChangeWithData, onChangeImage, getBase64]
73
- );
74
-
75
- // Effects
76
-
77
- // Other
78
-
79
- // Render Functions
80
-
81
- return (
82
- // eslint-disable-next-line jsx-a11y/label-has-associated-control
83
- <label className={classNames(styles.fileInput, className)} style={style}>
84
- {label ? <span>{label}</span> : null}
85
- <img
86
- src={(value ?? image)?.url}
87
- alt={(value ?? image)?.name}
88
- className={classNames(styles.preview, (value ?? image)?.url ? undefined : styles.empty)}
89
- />
90
- <Button __allowChildren="all">{(value ?? image)?.name ?? <i>Select Image</i>}</Button>
91
- <input {...otherProps} className={styles.value} onChange={onChange} type="file" />
92
- </label>
93
- );
94
- }
95
-
96
- // Need ImageInputMemo for autocompletion of phpstorm
97
- const ImageInputMemo = withMemo(ImageInput, styles);
98
- export { ImageInputMemo as ImageInput };