@applica-software-guru/react-admin 1.3.169 → 1.3.172

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/themes/index.jsx"],"names":[],"mappings":"AAcA;;;4CAgEC;;;;;;;sBArEqB,aAAa;sBACb,aAAa;sBAJb,YAAY"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/themes/index.jsx"],"names":[],"mappings":"AAcA;;;4CAiEC;;;;;;;sBAtEqB,aAAa;sBACb,aAAa;sBAJb,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applica-software-guru/react-admin",
3
- "version": "1.3.169",
3
+ "version": "1.3.172",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,7 +48,7 @@
48
48
  "./style.css": "./dist/style.css"
49
49
  },
50
50
  "dependencies": {
51
- "@ant-design/icons": "^5.1.4",
51
+ "@ant-design/icons": "^5.3.1",
52
52
  "@emotion/react": "^11.4",
53
53
  "@emotion/styled": "^11.3.0",
54
54
  "@mui/base": "5.0.0-beta.19",
@@ -140,6 +140,10 @@ export type ApplicaAdminProps = AdminProps & {
140
140
  * This image must be a component with absolute positioning.
141
141
  */
142
142
  background?: React.ReactNode;
143
+ /**
144
+ * Indicates whether the theme toggler should be displayed.
145
+ */
146
+ enableThemeToggler: boolean;
143
147
  };
144
148
 
145
149
  /**
@@ -172,6 +176,7 @@ const ApplicaAdmin = ({
172
176
  enablePasswordRecover,
173
177
  queryClient,
174
178
  background,
179
+ enableThemeToggler,
175
180
  ...props
176
181
  }: ApplicaAdminProps) => {
177
182
  useErrorEventCatcher({
@@ -222,6 +227,7 @@ const ApplicaAdmin = ({
222
227
  {...props}
223
228
  name={name}
224
229
  copy={copy}
230
+ enableThemeToggler={enableThemeToggler}
225
231
  version={version}
226
232
  logoMain={_logoMain}
227
233
  logoIcon={_logoIcon}
@@ -284,7 +290,8 @@ ApplicaAdmin.defaultProps = {
284
290
  enableRegistration: false,
285
291
  enableForgotPassword: false,
286
292
  loginPage: <LoginPage version="0.0.0" name="Applica" redirectTo="/" />,
287
- queryClient: defaultQueryClient
293
+ queryClient: defaultQueryClient,
294
+ enableThemeToggler: false
288
295
  };
289
296
 
290
297
  ApplicaAdmin.propTypes = {
@@ -304,7 +311,8 @@ ApplicaAdmin.propTypes = {
304
311
  enableNotification: PropTypes.bool,
305
312
  enableRegistration: PropTypes.bool,
306
313
  enableForgotPassword: PropTypes.bool,
307
- queryClient: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
314
+ queryClient: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
315
+ enableThemeToggler: PropTypes.bool
308
316
  };
309
317
 
310
318
  export default ApplicaAdmin;
@@ -10,22 +10,25 @@ import { Navigation } from './Navigation';
10
10
  import { Outlet } from 'react-router-dom';
11
11
  import { useBreadcrumbs } from '../../hooks';
12
12
  import { withLayoutProvider } from './Provider';
13
+ import { ThemeToggler } from './ThemeToggler';
13
14
 
14
15
  type ILayoutProps = React.PropsWithChildren<{
15
16
  name: string;
16
17
  version: string;
17
18
  copy?: string;
18
19
  error?: React.ComponentType<ErrorProps>;
20
+ enableThemeToggler: boolean;
19
21
  }>;
20
22
 
21
23
  const Layout = withLayoutProvider(function Layout(props: ILayoutProps) {
22
- const { name, version } = props,
24
+ const { name, version, enableThemeToggler } = props,
23
25
  { isLoading, navigation, breadcrumbs } = useBreadcrumbs();
24
26
 
25
27
  return (
26
28
  <LayoutWrapper>
27
29
  <Header>
28
30
  <HeaderSpacer />
31
+ {enableThemeToggler && <ThemeToggler />}
29
32
  <LoadingIndicator />
30
33
  <HeaderNotification />
31
34
  <ResponsiveSection>
@@ -0,0 +1,20 @@
1
+ import { SunOutlined, MoonOutlined } from '@ant-design/icons';
2
+ import { useThemeConfig } from '../../hooks';
3
+ import { HeaderToggleButton } from './Header';
4
+
5
+ const ThemeToggler = () => {
6
+ const { mode, setMode } = useThemeConfig();
7
+
8
+ return (
9
+ <HeaderToggleButton
10
+ value="theme-mode"
11
+ aria-label="toggle mode"
12
+ onChange={() => setMode(mode === 'dark' ? 'light' : 'dark')}
13
+ selected={false}
14
+ >
15
+ {mode === 'dark' ? <SunOutlined /> : <MoonOutlined />}
16
+ </HeaderToggleButton>
17
+ );
18
+ };
19
+
20
+ export { ThemeToggler };
@@ -8,4 +8,5 @@ export * from './Navigation';
8
8
  export * from './NavMenu';
9
9
  export * from './Provider';
10
10
  export * from './Wrapper';
11
- export * from './Error'
11
+ export * from './Error';
12
+ export * from './ThemeToggler';
@@ -13,7 +13,8 @@ import { useMemo } from 'react';
13
13
  import { useThemeConfig } from '../hooks';
14
14
 
15
15
  const ThemeCustomization = ({ themeOverrides, children }) => {
16
- const { themeDirection, mode, presetColor, fontFamily } = useThemeConfig();
16
+ const _themeConfig = useThemeConfig(1);
17
+ const { themeDirection, mode, presetColor, fontFamily } = _themeConfig;
17
18
 
18
19
  const theme = useMemo(() => Palette(mode, presetColor), [mode, presetColor]);
19
20