@ainias42/react-bootstrap-mobile 1.0.8 → 1.0.10
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/dist/Components/Clickable/Clickable.d.ts +2 -1
- package/dist/Components/DesignProvider/Design.d.ts +4 -0
- package/dist/Components/DesignProvider/DesignContext.d.ts +3 -0
- package/dist/Components/DesignProvider/DesignProvider.d.ts +9 -0
- package/dist/Components/List/BulletList/BulletList.d.ts +8 -0
- package/dist/Components/List/BulletList/ListItem.d.ts +7 -0
- package/dist/Components/ThemeProvider/ThemeContext.d.ts +2 -0
- package/dist/Components/ThemeProvider/ThemeProvider.d.ts +7 -0
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +156 -12
- package/dist/index.js.map +1 -1
- package/package.json +54 -56
- package/src/Components/Clickable/Clickable.tsx +3 -1
- package/src/Components/Clickable/clickable.module.scss +7 -0
- package/src/Components/DesignProvider/Design.ts +4 -0
- package/src/Components/DesignProvider/DesignContext.ts +8 -0
- package/src/Components/DesignProvider/DesignProvider.tsx +32 -0
- package/src/Components/FormElements/Controller/withHookController.tsx +19 -4
- package/src/Components/FormElements/Switch/switch.module.scss +1 -1
- package/src/Components/Icon/BaseIcon.tsx +1 -2
- package/src/Components/List/BulletList/BulletList.tsx +33 -0
- package/src/Components/List/BulletList/ListItem.tsx +34 -0
- package/src/Components/ThemeProvider/ThemeContext.ts +7 -0
- package/src/Components/ThemeProvider/ThemeProvider.tsx +28 -0
- package/src/index.ts +7 -0
- package/src/scss/_colors.scss +11 -5
package/package.json
CHANGED
|
@@ -1,58 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"vite-tsconfig-paths": "^5.1.4"
|
|
57
|
-
}
|
|
2
|
+
"name": "@ainias42/react-bootstrap-mobile",
|
|
3
|
+
"version": "1.0.10",
|
|
4
|
+
"description": "Mobile React Components",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build-postinstall": "npm run build",
|
|
12
|
+
"build": "ctix build && webpack --env production",
|
|
13
|
+
"lint:noCache": "eslint \"{src,.storybook}/{**/*,*}.{js,jsx,tsx,ts}\" --max-warnings 0",
|
|
14
|
+
"lint": "npm run lint:noCache -- --cache",
|
|
15
|
+
"lint:fix": "npm run lint -- --fix",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"prettier": "npm run prettier:list -- --write",
|
|
18
|
+
"prettier:list": "prettier --list-different \"{src,.storybook}/**/*.{ts,tsx,js,jsx,json}\"",
|
|
19
|
+
"stylelint": "stylelint --allow-empty-input \"{src,.storybook}/**/*.{css,scss}\"",
|
|
20
|
+
"stylelint:fix": "npm run stylelint -- --fix",
|
|
21
|
+
"storybook": "storybook dev -p 6006",
|
|
22
|
+
"build-storybook": "storybook build"
|
|
23
|
+
},
|
|
24
|
+
"author": "",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "gitea@git.silas.link:Ainias/libraries.git"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
|
31
|
+
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
|
32
|
+
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
|
33
|
+
"@fortawesome/react-fontawesome": "^3.0.2",
|
|
34
|
+
"react": "^19.2.3",
|
|
35
|
+
"react-dom": "^19.2.3",
|
|
36
|
+
"react-hook-form": "^7.62.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@ainias42/config": "*",
|
|
40
|
+
"@ainias42/js-helper": ">=0.8.19",
|
|
41
|
+
"@hello-pangea/dnd": "^18.0.1",
|
|
42
|
+
"@uiw/react-color": "^2.5.5",
|
|
43
|
+
"classnames": "^2.5.1",
|
|
44
|
+
"react-table": "^7.8.0",
|
|
45
|
+
"yup": "^1.7.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@ainias42/webpack-config": "*",
|
|
49
|
+
"@storybook/addon-docs": "^9.1.5",
|
|
50
|
+
"@storybook/addon-onboarding": "^9.1.5",
|
|
51
|
+
"@storybook/react-vite": "^9.1.5",
|
|
52
|
+
"@storybook/addon-themes": "^9.1.5",
|
|
53
|
+
"eslint-plugin-storybook": "^9.1.5",
|
|
54
|
+
"storybook": "^9.1.5"
|
|
55
|
+
}
|
|
58
56
|
}
|
|
@@ -43,6 +43,7 @@ export type ClickableProps<
|
|
|
43
43
|
draggable?: boolean;
|
|
44
44
|
title?: string;
|
|
45
45
|
ref?: ForwardedRef<HrefType extends string ? HTMLAnchorElement : HTMLSpanElement>;
|
|
46
|
+
hiddenLink?: boolean;
|
|
46
47
|
} & OnClickListener<OnClickData> &
|
|
47
48
|
OnPointerDownListener<OnMouseDownData> &
|
|
48
49
|
OnPointerMoveListener<OnMouseMoveData> &
|
|
@@ -84,6 +85,7 @@ export const Clickable = withMemo(function Clickable<
|
|
|
84
85
|
draggable,
|
|
85
86
|
title,
|
|
86
87
|
ref,
|
|
88
|
+
hiddenLink,
|
|
87
89
|
...clickData
|
|
88
90
|
}: ClickableProps<
|
|
89
91
|
OnClickData,
|
|
@@ -305,7 +307,7 @@ export const Clickable = withMemo(function Clickable<
|
|
|
305
307
|
id,
|
|
306
308
|
role: interactable ? 'button' : undefined,
|
|
307
309
|
'aria-hidden': interactable ? undefined : true,
|
|
308
|
-
className: classNames(styles.clickable, className),
|
|
310
|
+
className: classNames(styles.clickable, { [styles.hiddenLink]: hiddenLink }, className),
|
|
309
311
|
onClick: realOnClick,
|
|
310
312
|
onPointerDown: realOnPointerDown,
|
|
311
313
|
onPointerMove: realOnPointerMove,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Design } from './Design';
|
|
2
|
+
import { DesignContext } from './DesignContext';
|
|
3
|
+
import { withMemo } from '../../helper/withMemo';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
|
|
8
|
+
export type DesignProviderProps = { design?: Design; children?: ReactNode; className?: string };
|
|
9
|
+
|
|
10
|
+
export const DesignProvider = withMemo(function DesignProvider({
|
|
11
|
+
design = Design.FLAT,
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
}: DesignProviderProps) {
|
|
15
|
+
// Refs
|
|
16
|
+
|
|
17
|
+
// States/Variables/Selectors
|
|
18
|
+
|
|
19
|
+
// Callbacks
|
|
20
|
+
|
|
21
|
+
// Effects
|
|
22
|
+
|
|
23
|
+
// Other
|
|
24
|
+
|
|
25
|
+
// RenderFunctions
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<DesignContext value={design}>
|
|
29
|
+
<div className={classNames(design, className)}>{children}</div>
|
|
30
|
+
</DesignContext>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ObjectHelper } from '@ainias42/js-helper';
|
|
1
2
|
import { useComposedRef } from '../../Hooks/useComposedRef';
|
|
2
3
|
import { useController, useFormContext } from 'react-hook-form';
|
|
3
4
|
import { withMemo } from '../../../helper/withMemo';
|
|
@@ -25,17 +26,31 @@ export function withHookController<C extends ComponentType<any>, OnChangeProp ex
|
|
|
25
26
|
}: Props<Values, Name> & { ref?: ForwardedRef<RefType> }) {
|
|
26
27
|
const children = 'children' in otherProps ? otherProps.children : undefined;
|
|
27
28
|
|
|
28
|
-
const { field, fieldState } = useController({ name });
|
|
29
|
+
const { field, fieldState, formState } = useController({ name });
|
|
29
30
|
const { clearErrors } = useFormContext();
|
|
30
31
|
const composedRef = useComposedRef(ref, field.ref);
|
|
31
|
-
|
|
32
|
+
let errorMessage = fieldState.error?.message;
|
|
33
|
+
if (Array.isArray(fieldState.error)) {
|
|
34
|
+
errorMessage = fieldState.error.map((error) => error?.message).join('\n');
|
|
35
|
+
}
|
|
36
|
+
let clearErrorName: string = name;
|
|
37
|
+
|
|
38
|
+
if (!errorMessage) {
|
|
39
|
+
for (const [key, error] of ObjectHelper.entries(formState.errors)) {
|
|
40
|
+
if (key.startsWith(`${name}.`) || key.startsWith(`${name}[`)) {
|
|
41
|
+
errorMessage = error.message?.toString();
|
|
42
|
+
clearErrorName = key;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
32
47
|
|
|
33
48
|
const internalOnChange = useCallback(
|
|
34
49
|
(arg: any) => {
|
|
35
|
-
clearErrors(
|
|
50
|
+
clearErrors(clearErrorName);
|
|
36
51
|
field.onChange(arg);
|
|
37
52
|
},
|
|
38
|
-
[clearErrors, field
|
|
53
|
+
[clearErrorName, clearErrors, field],
|
|
39
54
|
);
|
|
40
55
|
const onChangeProps = {
|
|
41
56
|
[onChangeProp]: internalOnChange,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
--switch-background: var(--foreground-primary);
|
|
18
18
|
--switch-box-shadow-color: var(--box-shadow-color);
|
|
19
19
|
--switch-handle-color: var(--foreground-primary);
|
|
20
|
-
--switch-handle-box-shadow-color:
|
|
20
|
+
--switch-handle-box-shadow-color: var(--curtain-light);
|
|
21
21
|
--switch-active-background-color: var(--flavor-accent);
|
|
22
22
|
--switch-active-box-shadow-color: var(--flavor-accent);
|
|
23
23
|
--switch-active-handle-color: var(--foreground-primary);
|
|
@@ -9,7 +9,6 @@ import type { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
|
9
9
|
import type { Override } from '../../TypeHelpers';
|
|
10
10
|
import type { RbmComponentProps } from '../RbmComponentProps';
|
|
11
11
|
import type { Ref } from 'react';
|
|
12
|
-
import { Flavor } from '../Flavor';
|
|
13
12
|
import { FlavorWithText } from '../FlavorWithText';
|
|
14
13
|
|
|
15
14
|
export type IconSource = IconProp | string | IconDefinition;
|
|
@@ -23,7 +22,7 @@ export type IconProps = RbmComponentProps<
|
|
|
23
22
|
alt?: string;
|
|
24
23
|
ref?: Ref<HTMLImageElement | null>;
|
|
25
24
|
flavor?: FlavorWithText;
|
|
26
|
-
color?: undefined
|
|
25
|
+
color?: undefined;
|
|
27
26
|
}
|
|
28
27
|
>
|
|
29
28
|
>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { withMemo } from '../../../helper/withMemo';
|
|
3
|
+
import type { RbmComponentProps } from '../../RbmComponentProps';
|
|
4
|
+
|
|
5
|
+
export type BulletListProps = RbmComponentProps<{ numbered?: boolean }>;
|
|
6
|
+
|
|
7
|
+
function BulletList({ numbered = false, className, children, style }: BulletListProps) {
|
|
8
|
+
// Variables
|
|
9
|
+
|
|
10
|
+
// Refs
|
|
11
|
+
|
|
12
|
+
// States
|
|
13
|
+
|
|
14
|
+
// Selectors
|
|
15
|
+
|
|
16
|
+
// Callbacks
|
|
17
|
+
|
|
18
|
+
// Effects
|
|
19
|
+
|
|
20
|
+
// Other
|
|
21
|
+
const props = { className, style };
|
|
22
|
+
|
|
23
|
+
// Render Functions
|
|
24
|
+
if (numbered) {
|
|
25
|
+
return <ol {...props}>{children}</ol>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return <ul {...props}>{children}</ul>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Need BulletListMemo for autocompletion of phpstorm
|
|
32
|
+
const BulletListMemo = withMemo(BulletList);
|
|
33
|
+
export { BulletListMemo as BulletList };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { withMemo } from '../../../helper/withMemo';
|
|
3
|
+
import type { EmptyProps } from '../../../helper/EmptyProps';
|
|
4
|
+
import type { RbmComponentProps } from '../../RbmComponentProps';
|
|
5
|
+
|
|
6
|
+
export type ListItemProps = RbmComponentProps<EmptyProps>;
|
|
7
|
+
|
|
8
|
+
function ListItem({ className, children, style }: ListItemProps) {
|
|
9
|
+
// Variables
|
|
10
|
+
|
|
11
|
+
// Refs
|
|
12
|
+
|
|
13
|
+
// States
|
|
14
|
+
|
|
15
|
+
// Selectors
|
|
16
|
+
|
|
17
|
+
// Callbacks
|
|
18
|
+
|
|
19
|
+
// Effects
|
|
20
|
+
|
|
21
|
+
// Other
|
|
22
|
+
|
|
23
|
+
// Render Functions
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<li className={className} style={style}>
|
|
27
|
+
{children}
|
|
28
|
+
</li>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Need ListItemMemo for autocompletion of phpstorm
|
|
33
|
+
const ListItemMemo = withMemo(ListItem);
|
|
34
|
+
export { ListItemMemo as ListItem };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ThemeContext } from './ThemeContext';
|
|
2
|
+
import { withMemo } from '../../helper/withMemo';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
export type ThemeProviderProps = { theme: string; children: ReactNode };
|
|
7
|
+
|
|
8
|
+
export const ThemeProvider = withMemo(function ThemeProvider({ theme, children }: ThemeProviderProps) {
|
|
9
|
+
// Refs
|
|
10
|
+
|
|
11
|
+
// States/Variables/Selectors
|
|
12
|
+
|
|
13
|
+
// Callbacks
|
|
14
|
+
|
|
15
|
+
// Effects
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
document.body.classList.add(theme);
|
|
18
|
+
return () => {
|
|
19
|
+
document.body.classList.remove(theme);
|
|
20
|
+
};
|
|
21
|
+
}, [theme]);
|
|
22
|
+
|
|
23
|
+
// Other
|
|
24
|
+
|
|
25
|
+
// RenderFunctions
|
|
26
|
+
|
|
27
|
+
return <ThemeContext value={theme}>{children}</ThemeContext>;
|
|
28
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,9 @@ export * from './WindowContext/WindowContext';
|
|
|
19
19
|
export * from './Components/ActionSheet/ActionSheet';
|
|
20
20
|
export * from './Components/Card/Card';
|
|
21
21
|
export * from './Components/Clickable/Clickable';
|
|
22
|
+
export * from './Components/DesignProvider/Design';
|
|
23
|
+
export * from './Components/DesignProvider/DesignContext';
|
|
24
|
+
export * from './Components/DesignProvider/DesignProvider';
|
|
22
25
|
export * from './Components/Dialog/AlertDialog';
|
|
23
26
|
export * from './Components/Dialog/ButtonDialog';
|
|
24
27
|
export * from './Components/Dialog/ConfirmDialog';
|
|
@@ -80,6 +83,8 @@ export * from './Components/TabBar/TabBarButton';
|
|
|
80
83
|
export * from './Components/Table/Table';
|
|
81
84
|
export * from './Components/Text/Heading';
|
|
82
85
|
export * from './Components/Text/Text';
|
|
86
|
+
export * from './Components/ThemeProvider/ThemeContext';
|
|
87
|
+
export * from './Components/ThemeProvider/ThemeProvider';
|
|
83
88
|
export * from './Components/Title/HoverTitle';
|
|
84
89
|
export * from './Components/Title/withTitle';
|
|
85
90
|
export * from './Components/Toast/Toast';
|
|
@@ -117,6 +122,8 @@ export * from './Components/FormElements/Switch/Switch';
|
|
|
117
122
|
export * from './Components/FormElements/Textarea/Textarea';
|
|
118
123
|
export * from './Components/Layout/Grid/Grid';
|
|
119
124
|
export * from './Components/Layout/Grid/GridItem';
|
|
125
|
+
export * from './Components/List/BulletList/BulletList';
|
|
126
|
+
export * from './Components/List/BulletList/ListItem';
|
|
120
127
|
export * from './Components/SpoilerList/Spoiler/Spoiler';
|
|
121
128
|
export * from './Components/FormElements/Input/FileInput/FileInput';
|
|
122
129
|
export * from './Components/FormElements/Input/FileInput/FileType';
|
package/src/scss/_colors.scss
CHANGED
|
@@ -56,10 +56,6 @@
|
|
|
56
56
|
|
|
57
57
|
--flavor-accent: #37474f;
|
|
58
58
|
--box-shadow-color: rgb(0 0 0 / 20%);
|
|
59
|
-
|
|
60
|
-
&.dark {
|
|
61
|
-
@extend %color-vars-dark;
|
|
62
|
-
}
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
.#{$flat} {
|
|
@@ -68,9 +64,19 @@
|
|
|
68
64
|
--flavor-accent: #2563eb; // blue 600
|
|
69
65
|
--flavor-pale-accent: #93c5fd; // blue 300
|
|
70
66
|
--box-shadow-color: rgb(0 0 0 / 12%);
|
|
67
|
+
}
|
|
71
68
|
|
|
72
|
-
|
|
69
|
+
.dark {
|
|
70
|
+
.#{$flat}, &.#{$flat} {
|
|
73
71
|
@extend %color-vars-dark;
|
|
72
|
+
|
|
73
|
+
--box-shadow-color: rgb(255 255 255 / 12%);
|
|
74
74
|
--flavor-pale-accent: #172554; // blue 900
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
.#{$material}, &.#{$material} {
|
|
78
|
+
@extend %color-vars-dark;
|
|
79
|
+
|
|
80
|
+
--box-shadow-color: rgb(255 255 255 / 20%);
|
|
81
|
+
}
|
|
76
82
|
}
|