@ainias42/react-bootstrap-mobile 0.1.32 → 0.2.1

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 (65) hide show
  1. package/bin/updateCopies.js +6 -1
  2. package/bootstrapReactMobile.ts +10 -0
  3. package/dist/bootstrapReactMobile.d.ts +10 -0
  4. package/dist/bootstrapReactMobile.js +1036 -672
  5. package/dist/bootstrapReactMobile.js.map +1 -1
  6. package/dist/src/Components/Clickable/Clickable.d.ts +6 -3
  7. package/dist/src/Components/FormElements/Button/Button.d.ts +4 -1
  8. package/dist/src/Components/FormElements/Controller/HookForm.d.ts +8 -0
  9. package/dist/src/Components/FormElements/Controller/InputController.d.ts +4 -0
  10. package/dist/src/Components/FormElements/Controller/MultipleFileInputController.d.ts +3 -0
  11. package/dist/src/Components/FormElements/Controller/PasswordInputController.d.ts +4 -0
  12. package/dist/src/Components/FormElements/Controller/SelectController.d.ts +3 -0
  13. package/dist/src/Components/FormElements/Controller/SendFormContext.d.ts +3 -0
  14. package/dist/src/Components/FormElements/Controller/TextareaController.d.ts +4 -0
  15. package/dist/src/Components/FormElements/Controller/withHookController.d.ts +4 -0
  16. package/dist/src/Components/FormElements/Input/FileInput/MultipleFileInput.d.ts +2 -1
  17. package/dist/src/Components/FormElements/Input/Input.d.ts +1 -0
  18. package/dist/src/Components/FormElements/Select/Select.d.ts +2 -1
  19. package/dist/src/Components/FormElements/Textarea/Textarea.d.ts +1 -0
  20. package/dist/src/Components/Hooks/useClientLayoutEffect.d.ts +2 -2
  21. package/dist/src/Components/Hooks/useComposedRef.d.ts +1 -1
  22. package/dist/src/Components/Image/Image.d.ts +2 -2
  23. package/dist/src/Components/Toast/ToastContext.d.ts +11 -0
  24. package/dist/src/Size.d.ts +8 -0
  25. package/package.json +5 -3
  26. package/react-bootstrap-mobile.scss +2 -2
  27. package/src/Components/Clickable/Clickable.tsx +41 -6
  28. package/src/Components/Dialog/DialogContainer.tsx +15 -12
  29. package/src/Components/Dialog/DialogContext.ts +4 -1
  30. package/src/Components/FormElements/Button/Button.tsx +14 -8
  31. package/src/Components/FormElements/Button/button.scss +17 -0
  32. package/src/Components/FormElements/Controller/HookForm.tsx +43 -0
  33. package/src/Components/FormElements/Controller/InputController.ts +4 -0
  34. package/src/Components/FormElements/Controller/MultipleFileInputController.ts +4 -0
  35. package/src/Components/FormElements/Controller/PasswordInputController.ts +4 -0
  36. package/src/Components/FormElements/Controller/SelectController.ts +4 -0
  37. package/src/Components/FormElements/Controller/SendFormContext.ts +7 -0
  38. package/src/Components/FormElements/Controller/TextareaController.ts +4 -0
  39. package/src/Components/FormElements/Controller/withHookController.tsx +53 -0
  40. package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +4 -1
  41. package/src/Components/FormElements/Input/FileInput/fileInput.scss +5 -6
  42. package/src/Components/FormElements/Input/Input.tsx +16 -5
  43. package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +1 -1
  44. package/src/Components/FormElements/Input/input.scss +5 -0
  45. package/src/Components/FormElements/Select/Select.tsx +5 -0
  46. package/src/Components/FormElements/Select/select.scss +5 -0
  47. package/src/Components/FormElements/Textarea/Textarea.tsx +9 -4
  48. package/src/Components/FormElements/Textarea/textarea.scss +10 -1
  49. package/src/Components/FormElements/hooks/useOnChangeDone.ts +1 -1
  50. package/src/Components/Hooks/useClientLayoutEffect.ts +3 -3
  51. package/src/Components/Hooks/useComposedRef.ts +13 -16
  52. package/src/Components/Image/Image.tsx +2 -2
  53. package/src/Components/Layout/View.tsx +0 -1
  54. package/src/Components/Layout/ViewWithoutListeners.tsx +0 -1
  55. package/src/Components/Toast/ToastContainer.tsx +59 -3
  56. package/src/Components/Toast/ToastContext.ts +9 -0
  57. package/src/Components/TopBar/TopBarButton.tsx +2 -4
  58. package/src/Components/TopBar/topBar.scss +4 -0
  59. package/src/Size.ts +9 -0
  60. package/src/scss/_baseClasses.scss +5 -9
  61. package/src/scss/_colors.scss +10 -5
  62. package/src/scss/_default.scss +4 -2
  63. package/webpack.config.js +2 -1
  64. package/src/scss/_animations.scss +0 -46
  65. package/src/scss/_mobileMixin.scss +0 -35
@@ -3,7 +3,6 @@ import {RbmComponentProps} from '../../../RbmComponentProps';
3
3
  import {Override} from '../../../../TypeHelpers';
4
4
  import {ChangeEventHandler, DragEvent, InputHTMLAttributes, useCallback, useRef} from 'react';
5
5
  import {Listener, useListenerWithExtractedProps} from '../../../Hooks/useListener';
6
-
7
6
  import styles from './fileInput.scss';
8
7
  import {withMemo} from '../../../../helper/withMemo';
9
8
  import classNames from 'classnames';
@@ -17,6 +16,7 @@ import {Image} from '../../../Image/Image';
17
16
  import {Clickable} from '../../../Clickable/Clickable';
18
17
  import {Inline} from '../../../Layout/Inline';
19
18
  import {FileType} from "./FileType";
19
+ import { InlineBlock } from "../../../Layout/InlineBlock";
20
20
 
21
21
 
22
22
  export type MultipleFileInputProps<OnChangeFilesData> = RbmComponentProps<
@@ -31,6 +31,7 @@ export type MultipleFileInputProps<OnChangeFilesData> = RbmComponentProps<
31
31
  onError?: (error: string) => void;
32
32
  allowOverride?: boolean
33
33
  showDeleteButton?: boolean
34
+ error?: string,
34
35
  } & Listener<'onChangeFiles', OnChangeFilesData, FileType[]>
35
36
  >
36
37
  >;
@@ -46,6 +47,7 @@ export const MultipleFileInput = withMemo(function MultipleImageInput<OnChangeDa
46
47
  allowOverride = maxFiles === 1,
47
48
  onError,
48
49
  showDeleteButton = true,
50
+ error,
49
51
  ...otherProps
50
52
  }: MultipleFileInputProps<OnChangeData>) {
51
53
  // Variables
@@ -275,6 +277,7 @@ export const MultipleFileInput = withMemo(function MultipleImageInput<OnChangeDa
275
277
  </Clickable>
276
278
  </Grow>
277
279
  </Flex>
280
+ {error && <InlineBlock className={styles.error}><Text>{error}</Text></InlineBlock>}
278
281
  </span>
279
282
  );
280
283
  },
@@ -79,11 +79,10 @@
79
79
 
80
80
  .value {
81
81
  display: none;
82
- //position: absolute;
83
- //top: 0;
84
- //left: 0;
85
- //right: 0;
86
- //bottom: 0;
87
- //opacity: 0;
82
+ }
83
+
84
+ .error {
85
+ font-size: 0.7rem;
86
+ --text-primary-default-color: var(--text-error)
88
87
  }
89
88
  }
@@ -16,6 +16,9 @@ import styles from './input.scss';
16
16
  import classNames from 'classnames';
17
17
  import { useComposedRef } from '../../Hooks/useComposedRef';
18
18
  import { useOnChangeDone } from '../hooks/useOnChangeDone';
19
+ import { InlineBlock } from "../../Layout/InlineBlock";
20
+ import { Text } from "../../Text/Text";
21
+ import { useSendFormContext } from "../Controller/SendFormContext";
19
22
 
20
23
  export type InputProps<OnChangeData, OnBlurData, OnChangeDoneData> = RbmComponentProps<
21
24
  Override<
@@ -25,6 +28,7 @@ export type InputProps<OnChangeData, OnBlurData, OnChangeDoneData> = RbmComponen
25
28
  inline?: boolean;
26
29
  onChangeText?: (newText: string) => void;
27
30
  onEnter?: (newText: string) => void;
31
+ error?: string,
28
32
  } & OptionalListener<'onChange', OnChangeData> &
29
33
  OptionalListener<'onBlur', OnBlurData> &
30
34
  OptionalListener<'onChangeDone', OnChangeDoneData>
@@ -39,7 +43,9 @@ export const Input = withForwardRef(function Input<OnChangeData, OnBlurData, OnC
39
43
  onKeyDown,
40
44
  inline = false,
41
45
  value,
46
+ error,
42
47
  onChangeText,
48
+ onEnter,
43
49
  ...otherProps
44
50
  }: InputProps<OnChangeData, OnBlurData, OnChangeDoneData>,
45
51
  ref: MutableRefObject<HTMLInputElement> | null
@@ -77,9 +83,13 @@ export const Input = withForwardRef(function Input<OnChangeData, OnBlurData, OnC
77
83
  return "";
78
84
  }, [value, otherProps.max, otherProps.min, otherProps.type]);
79
85
  // Refs
80
- const innerRef = useComposedRef(ref);
86
+ const innerRef = useRef<HTMLInputElement>(null);
87
+ const refFunction = useComposedRef(ref, innerRef);
81
88
 
82
89
  // Callbacks
90
+ const sendForm = useSendFormContext();
91
+ onEnter ??= sendForm;
92
+
83
93
  const [onChangeWithData, otherPropsWithoutOnchange] = useListenerWithExtractedProps<'onChange', OnChangeData>(
84
94
  'onChange',
85
95
  otherProps
@@ -117,13 +127,13 @@ export const Input = withForwardRef(function Input<OnChangeData, OnBlurData, OnC
117
127
  const realOnKeyDown = useCallback(
118
128
  (e: KeyboardEvent<HTMLInputElement>) => {
119
129
  onKeyDown?.(e);
120
- if (otherProps.onEnter && e.key === 'Enter' && !e.defaultPrevented) {
130
+ if (onEnter && e.key === 'Enter' && !e.defaultPrevented) {
121
131
  if (otherProps.type === "number") {
122
132
  const stringValue = (e.target as HTMLInputElement).value;
123
133
  const val = !Number.isNaN(Number(stringValue)) ? stringValue : !Number.isNaN(parseFloat(stringValue)) ? String(parseFloat(stringValue)) : "";
124
- otherProps.onEnter(val);
134
+ onEnter(val);
125
135
  } else {
126
- otherProps.onEnter((e.target as HTMLInputElement).value);
136
+ onEnter((e.target as HTMLInputElement).value);
127
137
  }
128
138
  }
129
139
 
@@ -177,12 +187,13 @@ export const Input = withForwardRef(function Input<OnChangeData, OnBlurData, OnC
177
187
  {...otherPropsWithoutData}
178
188
  value={usedValue}
179
189
  type={otherProps.type === "number" ? "text" : otherProps.type}
180
- ref={innerRef}
190
+ ref={refFunction}
181
191
  className={styles.text}
182
192
  onBlur={onBlur}
183
193
  onChange={onChange}
184
194
  onKeyDown={realOnKeyDown}
185
195
  />
196
+ {error && <InlineBlock className={styles.error}><Text>{error}</Text></InlineBlock>}
186
197
  </label>
187
198
  );
188
199
  },
@@ -45,7 +45,7 @@ export const PasswordInput = withForwardRef(function PasswordInput<OnChangeData,
45
45
  <Grow>
46
46
  <Input {...props} type={isVisible ? 'text' : 'password'} ref={ref} />
47
47
  </Grow>
48
- <Clickable onClick={toggleVisible} className={styles.showButton}>
48
+ <Clickable onClick={toggleVisible} className={styles.showButton} interactable={false}>
49
49
  <Icon icon={isVisible ? faEye : faEyeSlash} />
50
50
  </Clickable>
51
51
  </Flex>
@@ -75,4 +75,9 @@
75
75
  }
76
76
  }
77
77
  }
78
+
79
+ .error {
80
+ font-size: 0.7rem;
81
+ --text-primary-default-color: var(--text-error)
82
+ }
78
83
  }
@@ -7,6 +7,8 @@ import {OptionalListener, useListenerWithExtractedProps} from '../../Hooks/useLi
7
7
  import styles from './select.scss';
8
8
  import { withMemo } from '../../../helper/withMemo';
9
9
  import classNames from 'classnames';
10
+ import { InlineBlock } from "../../Layout/InlineBlock";
11
+ import { Text } from "../../Text/Text";
10
12
 
11
13
  export type SelectOption = {
12
14
  label: string;
@@ -23,6 +25,7 @@ export type SelectProps<OnChangeData> = RbmComponentProps<
23
25
  onChangeValue?: (newValue: string) => void;
24
26
  inline?: boolean;
25
27
  small?: boolean;
28
+ error?: string;
26
29
  } & OptionalListener<'onChange', OnChangeData>
27
30
  >
28
31
  >;
@@ -35,6 +38,7 @@ export const Select = withMemo(function Select<OnChangeData>({
35
38
  onChangeValue,
36
39
  inline = false,
37
40
  small = false,
41
+ error,
38
42
  ...otherProps
39
43
  }: SelectProps<OnChangeData>) {
40
44
  // Variables
@@ -72,6 +76,7 @@ export const Select = withMemo(function Select<OnChangeData>({
72
76
  </option>
73
77
  ))}
74
78
  </select>
79
+ {error && <InlineBlock className={styles.error}><Text>{error}</Text></InlineBlock>}
75
80
  </label>
76
81
  );
77
82
  },
@@ -53,4 +53,9 @@
53
53
  height: initial;
54
54
  line-height: 1.5rem;
55
55
  }
56
+
57
+ .error {
58
+ font-size: 0.7rem;
59
+ --text-primary-default-color: var(--text-error)
60
+ }
56
61
  }
@@ -7,15 +7,16 @@ import {
7
7
  KeyboardEvent,
8
8
  ChangeEvent,
9
9
  MutableRefObject,
10
- CSSProperties
10
+ CSSProperties, useRef
11
11
  } from 'react';
12
12
  import { OptionalListener, useListenerWithExtractedProps } from '../../Hooks/useListener';
13
-
14
13
  import styles from './textarea.scss';
15
14
  import classNames from 'classnames';
16
15
  import { withForwardRef } from "../../../helper/withForwardRef";
17
16
  import { useOnChangeDone } from "../hooks/useOnChangeDone";
18
17
  import { useComposedRef } from "../../Hooks/useComposedRef";
18
+ import { InlineBlock } from "../../Layout/InlineBlock";
19
+ import { Text } from "../../Text/Text";
19
20
 
20
21
  export type TextareaProps<OnChangeData, OnChangeDoneData> = RbmComponentProps<
21
22
  Override<
@@ -27,6 +28,7 @@ export type TextareaProps<OnChangeData, OnChangeDoneData> = RbmComponentProps<
27
28
  onEscape?: (newText: string) => void;
28
29
  textareaStyles?: CSSProperties & Record<`--${string}`, string | number | undefined>,
29
30
  containerRef?: MutableRefObject<HTMLLabelElement|null>
31
+ error?: string,
30
32
  } & OptionalListener<'onChange', OnChangeData>
31
33
  & OptionalListener<'onChangeDone', OnChangeDoneData>
32
34
  >
@@ -42,10 +44,12 @@ export const Textarea = withForwardRef(function Textarea<OnChangeData, OnChangeD
42
44
  onEscape,
43
45
  textareaStyles,
44
46
  containerRef,
47
+ error,
45
48
  ...otherProps
46
49
  }: TextareaProps<OnChangeData, OnChangeDoneData>, ref: MutableRefObject<HTMLTextAreaElement> | null) {
47
50
  // Refs
48
- const innerRef = useComposedRef(ref);
51
+ const innerRef = useRef<HTMLTextAreaElement>(null);
52
+ const refSetter = useComposedRef(ref, innerRef);
49
53
 
50
54
  // Variables
51
55
 
@@ -98,7 +102,8 @@ export const Textarea = withForwardRef(function Textarea<OnChangeData, OnChangeD
98
102
  <label className={classNames(styles.container, className)} style={style} ref={containerRef}>
99
103
  {label ? <span className={styles.label}>{label}</span> : null}
100
104
  <textarea {...otherPropsWithoutData} style={textareaStyles} onKeyUp={realOnKeyPress}
101
- className={styles.textarea} onChange={onChange} ref={innerRef}/>
105
+ className={styles.textarea} onChange={onChange} ref={refSetter}/>
106
+ {error && <InlineBlock className={styles.error}><Text>{error}</Text></InlineBlock>}
102
107
  </label>
103
108
  );
104
109
  }, styles);
@@ -1,12 +1,16 @@
1
1
  .container {
2
2
  width: 100%;
3
- height: 10rem;
3
+ min-height: 10rem;
4
+ height: 100%;
5
+ display: flex;
6
+ flex-direction: column;
4
7
 
5
8
  .label {
6
9
  display: block;
7
10
  }
8
11
 
9
12
  textarea {
13
+ flex: 1;
10
14
  background-color: #efeff4;
11
15
  color: #1f1f21;
12
16
  box-shadow: none;
@@ -19,4 +23,9 @@
19
23
  border-radius: 4px;
20
24
  border: 1px solid var(--border-light);
21
25
  }
26
+
27
+ .error {
28
+ font-size: 0.7rem;
29
+ --text-primary-default-color: var(--text-error)
30
+ }
22
31
  }
@@ -10,7 +10,7 @@ export function useOnChangeDone(onChangeDone: (ev: any) => void, ref?: MutableRe
10
10
  return () => {
11
11
  elem?.removeEventListener('change', onChangeDone);
12
12
  };
13
- }, [ref, onChangeDone, usedRef]);
13
+ }, [onChangeDone, usedRef]);
14
14
 
15
15
  return usedRef;
16
16
  }
@@ -1,8 +1,8 @@
1
- import { useLayoutEffect } from "react";
1
+ import React from "react";
2
2
 
3
- export function useClientLayoutEffect(...params: Parameters<typeof useLayoutEffect>) {
3
+ export function useClientLayoutEffect(...params: Parameters<typeof React.useLayoutEffect>) {
4
4
  if (typeof window !== 'undefined') {
5
5
  // eslint-disable-next-line react-hooks/exhaustive-deps,react-hooks/rules-of-hooks
6
- useLayoutEffect(...params);
6
+ React.useLayoutEffect(...params);
7
7
  }
8
8
  }
@@ -1,17 +1,14 @@
1
- import { ForwardedRef, useEffect, useRef } from 'react';
2
-
3
- export const useComposedRef = <T>(ref: ForwardedRef<T>, initialValue: T | null = null) => {
4
- const targetRef = useRef<T>(initialValue);
5
-
6
- useEffect(() => {
7
- if (!ref) return;
8
-
9
- if (typeof ref === 'function') {
10
- ref(targetRef.current);
11
- } else {
12
- ref.current = targetRef.current;
1
+ import { ForwardedRef, useCallback, useEffect, useRef } from 'react';
2
+
3
+ export function useComposedRef<RefVal>(...refs: (ForwardedRef<RefVal> | undefined)[]) {
4
+ return useCallback((val: RefVal | null) => {
5
+ for (const ref of refs) {
6
+ if (typeof ref === 'function') {
7
+ ref(val);
8
+ } else if (ref) {
9
+ ref.current = val;
10
+ }
13
11
  }
14
- }, [ref]);
15
-
16
- return targetRef;
17
- };
12
+ // eslint-disable-next-line react-hooks/exhaustive-deps
13
+ }, refs);
14
+ }
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { withMemo } from '../../helper/withMemo';
3
3
  import { RbmComponentProps, WithNoChildren } from '../RbmComponentProps';
4
- import { CSSProperties, DOMAttributes } from 'react';
4
+ import { CSSProperties } from 'react';
5
5
  import { Override } from '../../TypeHelpers';
6
6
 
7
7
  import styles from './image.scss';
@@ -9,7 +9,7 @@ import classNames from 'classnames';
9
9
 
10
10
  export type ImageProps = RbmComponentProps<
11
11
  Override<
12
- Omit<React.ComponentPropsWithoutRef<'img'>, keyof DOMAttributes<'img'>>,
12
+ React.ComponentPropsWithoutRef<'img'>,
13
13
  {
14
14
  src: string;
15
15
  style?: CSSProperties;
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentRef, ForwardedRef, PropsWithChildren } from 'react';
3
3
  import { Override } from '../../TypeHelpers';
4
- import { withMemo } from "../../helper/withMemo";
5
4
  import { withForwardRef } from "../../helper/withForwardRef";
6
5
 
7
6
  export type ViewProps<AsType extends keyof JSX.IntrinsicElements> = PropsWithChildren<
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentRef, DOMAttributes, ForwardedRef } from 'react';
3
3
  import { View, ViewProps } from './View';
4
- import { withMemo } from "../../helper/withMemo";
5
4
  import { withForwardRef } from "../../helper/withForwardRef";
6
5
 
7
6
  export type ViewWithoutListenersProps<AsType extends keyof JSX.IntrinsicElements> = Omit<
@@ -6,17 +6,61 @@ import styles from './toast.scss';
6
6
  import classNames from 'classnames';
7
7
  import { withMemo } from '../../helper/withMemo';
8
8
  import { EmptyProps } from '../../helper/EmptyProps';
9
+ import { useCallback, useRef, useState } from "react";
10
+ import { ObjectHelper, URecord } from "@ainias42/js-helper";
11
+ import { Toast } from "./Toast";
12
+ import { Text } from "../Text/Text";
13
+ import { ToastContext } from "./ToastContext";
9
14
 
10
15
  export type ToastContainerProps = RbmComponentProps<EmptyProps>;
11
16
 
12
- function ToastContainer({ className, children, style }: ToastContainerProps) {
17
+ function ToastContainer({className, children, style}: ToastContainerProps) {
13
18
  // Variables
14
19
 
15
20
  // States
21
+ const lastId = useRef(0);
22
+ const [toasts, setToasts] = useState<URecord<number, {
23
+ id: number,
24
+ text: string,
25
+ duration: number,
26
+ action?: { name: string, onClick: (data?: any) => void, onClickData?: any }
27
+ }>>({});
16
28
 
17
29
  // Refs
18
30
 
19
31
  // Callbacks
32
+ const removeToast = useCallback((id: number) => {
33
+ setToasts((oldToasts) => {
34
+ const newToasts = {...oldToasts};
35
+ delete newToasts[id];
36
+ return newToasts;
37
+ });
38
+ }, []);
39
+
40
+ const addToast = useCallback((
41
+ text: string,
42
+ action?: {
43
+ name: string,
44
+ onClick: (data?: any) => void,
45
+ onClickData?: any
46
+ },
47
+ duration = 2500
48
+ ) => {
49
+ lastId.current++;
50
+ const id = lastId.current;
51
+
52
+ setToasts((oldToasts) => {
53
+ return {
54
+ ...oldToasts,
55
+ [id]: {
56
+ id,
57
+ text,
58
+ duration,
59
+ action
60
+ }
61
+ };
62
+ });
63
+ }, []);
20
64
 
21
65
  // Effects
22
66
 
@@ -25,9 +69,21 @@ function ToastContainer({ className, children, style }: ToastContainerProps) {
25
69
  // Render Functions
26
70
 
27
71
  return (
28
- <Container className={classNames(styles.toastContainer, className)} fluid __allowChildren="all" style={style}>
72
+ <ToastContext.Provider value={addToast}>
29
73
  {children}
30
- </Container>
74
+ <Container className={classNames(styles.toastContainer, className)} fluid __allowChildren="all"
75
+ style={style}>
76
+ {ObjectHelper.values(toasts).map((toast) => <Toast key={toast.id}
77
+ timeToShow={toast.duration}
78
+ onDismissed={removeToast}
79
+ onDismissedData={toast.id} {...(toast.action ? {
80
+ ...toast.action,
81
+ actionName: toast.action.name
82
+ } : {})}>
83
+ <Text>{toast.text}</Text>
84
+ </Toast>)}
85
+ </Container>
86
+ </ToastContext.Provider>
31
87
  );
32
88
  }
33
89
 
@@ -0,0 +1,9 @@
1
+ import { createContext, useContext } from "react";
2
+
3
+ export const ToastContext = createContext<<Data>(text: string, action?: {name: string, onClick: (data?: Data) => void, onClickData?: Data }, duration?: number) => void>(() => {
4
+ console.error("ToastContext not initialized");
5
+ });
6
+
7
+ export function useToast() {
8
+ return useContext(ToastContext);
9
+ }
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import { useCallback } from 'react';
3
2
  import { RbmComponentProps } from '../RbmComponentProps';
4
3
 
5
4
  import styles from './topBar.scss';
@@ -12,13 +11,12 @@ export type TopBarButtonProps = RbmComponentProps<{
12
11
  }>;
13
12
 
14
13
  function TopBarButton({ disabled = false, onClick, className, children, ...rbmProps }: TopBarButtonProps) {
15
- const cb = useCallback(() => (onClick ? onClick() : null), [onClick]);
16
14
  return (
17
15
  <a
18
16
  role="button"
19
17
  {...rbmProps}
20
- onClick={cb}
21
- className={classNames(styles.button, { [styles.disabled]: disabled }, className)}
18
+ onClick={onClick}
19
+ className={classNames(styles.button, { [styles.disabled]: disabled, [styles.active]: !disabled && onClick }, className)}
22
20
  >
23
21
  {children}
24
22
  </a>
@@ -24,6 +24,10 @@
24
24
  }
25
25
 
26
26
  .button {
27
+ &.active {
28
+ cursor: pointer;
29
+ }
30
+
27
31
  display: block;
28
32
  padding: 0.5rem 1rem;
29
33
  color: #0d3efd; // TODO change color
package/src/Size.ts ADDED
@@ -0,0 +1,9 @@
1
+
2
+ export enum Size {
3
+ xSmall,
4
+ small,
5
+ medium,
6
+ large,
7
+ xLarge,
8
+ xxLarge,
9
+ };
@@ -10,18 +10,14 @@
10
10
  overflow-y: auto;
11
11
  }
12
12
 
13
- .full-width {
13
+ :global(.full-width) {
14
14
  width: 100%;
15
15
  }
16
16
 
17
- .flat-hidden {
18
- @include design($flat) {
19
- display: none;
20
- }
17
+ .#{$flat} .#{$flat}-hidden {
18
+ display: none;
21
19
  }
22
20
 
23
- .material-hidden {
24
- @include design($material) {
25
- display: none;
26
- }
21
+ .#{$material} .#{$material}-hidden {
22
+ display: none;
27
23
  }
@@ -1,7 +1,4 @@
1
- @include design($material) {
2
- --flavor-accent: #37474f;
3
- --background-accent: #62727b;
4
- }
1
+
5
2
 
6
3
  :root {
7
4
  --flavor-basic: #000000;
@@ -12,9 +9,17 @@
12
9
  --border-light: #cecece;
13
10
  --border-strong: #717171;
14
11
  --background-destructive: #FECACA; // Red-200
12
+
13
+ --text-error: var(--flavor-destructive);
14
+
15
+ }
16
+
17
+ .#{$material} {
18
+ --flavor-accent: #37474f;
19
+ --background-accent: #62727b;
15
20
  }
16
21
 
17
- @include design($flat) {
22
+ .#{$flat} {
18
23
  --flavor-accent: #0076ff;
19
24
  --background-accent: #adcdfd;
20
25
  }
@@ -1,16 +1,18 @@
1
+ @import "designMixin";
2
+
1
3
  * {
2
4
  box-sizing: border-box;
3
5
  -webkit-font-smoothing: antialiased;
4
6
  font-weight: 400;
5
7
  }
6
8
 
7
- @include design($material) {
9
+ .#{$material} {
8
10
  * {
9
11
  font-family: "Roboto", "Noto", sans-serif;
10
12
  }
11
13
  }
12
14
 
13
- @include design($flat) {
15
+ .#{$flat} {
14
16
  * {
15
17
  font-family: -apple-system, "Helvetica Neue", "Helvetica", "Arial", "Lucida Grande", sans-serif;
16
18
  }
package/webpack.config.js CHANGED
@@ -28,7 +28,7 @@ module.exports = (env) => {
28
28
  output: {
29
29
  filename: 'bootstrapReactMobile.js',
30
30
  path: path.resolve(__dirname, 'dist'),
31
- library: { type: 'umd' },
31
+ library: { type: 'commonjs-static' },
32
32
  clean: true,
33
33
  globalObject: 'this',
34
34
  },
@@ -40,6 +40,7 @@ module.exports = (env) => {
40
40
  '@fortawesome/fontawesome-svg-core': 'commonjs2 @fortawesome/fontawesome-svg-core',
41
41
  '@fortawesome/free-solid-svg-icons': 'commonjs2 @fortawesome/free-solid-svg-icons',
42
42
  'react-beautiful-dnd': 'commonjs2 react-beautiful-dnd',
43
+ 'react-hook-form': 'commonjs2 react-hook-form',
43
44
  },
44
45
  optimization: {
45
46
  minimize: false,
@@ -1,46 +0,0 @@
1
- @keyframes material-new-site {
2
- 0% {
3
- transform: translate(0, 100%);
4
- z-index: 1;
5
- }
6
- 100% {
7
- transform: translate(0, 0);
8
- z-index: 1;
9
- }
10
- }
11
-
12
- @keyframes flat-new-site {
13
- 0% {
14
- transform: translate(100%, 0);
15
- z-index: 1;
16
- }
17
- 100% {
18
- transform: translate(0, 0);
19
- z-index: 1;
20
- }
21
- }
22
-
23
- .animation-new-site {
24
- background: green;
25
- @include design($material) {
26
- animation: material-new-site;
27
- animation-duration: $animationDurationMaterial;
28
- }
29
- @include design($flat) {
30
- animation: flat-new-site;
31
- animation-duration: $animationDurationMaterial;
32
- }
33
- }
34
-
35
- .animation-end-site {
36
- @include design($material) {
37
- animation: material-new-site;
38
- animation-duration: $animationDurationMaterial;
39
- animation-direction: reverse;
40
- }
41
- @include design($flat) {
42
- animation: flat-new-site;
43
- animation-duration: $animationDurationMaterial;
44
- animation-direction: reverse;
45
- }
46
- }