@inventreedb/ui 0.2.1 → 0.2.2

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.
@@ -63,14 +63,13 @@
63
63
  "name": "_virtual/index",
64
64
  "src": "/home/inventree/src/frontend/node_modules/unraw/dist/index.js?commonjs-exports"
65
65
  },
66
- "lib/components/StylishText.tsx": {
67
- "file": "components/StylishText.js",
68
- "name": "components/StylishText",
69
- "src": "lib/components/StylishText.tsx",
66
+ "lib/components/InvenTreeStylishText.tsx": {
67
+ "file": "components/InvenTreeStylishText.js",
68
+ "name": "components/InvenTreeStylishText",
69
+ "src": "lib/components/InvenTreeStylishText.tsx",
70
70
  "imports": [
71
71
  "/home/inventree/src/frontend/node_modules/react/jsx-runtime.js?commonjs-es-import",
72
72
  "node_modules/@mantine/core/esm/components/Text/Text.mjs",
73
- "node_modules/@mantine/core/esm/core/MantineProvider/MantineThemeProvider/MantineThemeProvider.mjs",
74
73
  "node_modules/@mantine/core/esm/core/MantineProvider/color-functions/get-theme-color/get-theme-color.mjs",
75
74
  "node_modules/@mantine/core/esm/core/MantineProvider/color-functions/darken/darken.mjs"
76
75
  ]
@@ -139,7 +138,7 @@
139
138
  "lib/functions/Api.tsx",
140
139
  "lib/functions/Navigation.tsx",
141
140
  "lib/functions/Plugins.tsx",
142
- "lib/components/StylishText.tsx"
141
+ "lib/components/InvenTreeStylishText.tsx"
143
142
  ]
144
143
  },
145
144
  "lib/types/Plugins.tsx": {
@@ -0,0 +1,13 @@
1
+ import { MantineSize, MantineTheme } from '@mantine/core';
2
+ import { JSX } from 'react';
3
+ /**
4
+ * A stylish text component that uses the primary color of the theme
5
+ * Note that the "theme" object must be provided by the parent component.
6
+ * - For plugins this theme object is provided.
7
+ * - For the main UI, we have a separate <StylishText> component
8
+ */
9
+ export declare function InvenTreeStylishText({ children, theme, size }: Readonly<{
10
+ children: JSX.Element | string;
11
+ theme: MantineTheme;
12
+ size?: MantineSize;
13
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +1,14 @@
1
1
  import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
2
2
  import { useMemo } from "react";
3
3
  import { Text } from "../node_modules/@mantine/core/esm/components/Text/Text.js";
4
- import { useMantineTheme } from "../node_modules/@mantine/core/esm/core/MantineProvider/MantineThemeProvider/MantineThemeProvider.js";
5
4
  import { getThemeColor } from "../node_modules/@mantine/core/esm/core/MantineProvider/color-functions/get-theme-color/get-theme-color.js";
6
5
  import { darken } from "../node_modules/@mantine/core/esm/core/MantineProvider/color-functions/darken/darken.js";
7
6
  const useThematicGradient = ({
8
7
  suppliedTheme
9
8
  }) => {
10
- const theme = useMemo(() => {
11
- if (suppliedTheme && suppliedTheme != void 0) {
12
- return suppliedTheme;
13
- }
14
- return useMantineTheme();
15
- }, [suppliedTheme, useMantineTheme]);
16
9
  const primary = useMemo(() => {
17
- return getThemeColor(theme.primaryColor, theme);
18
- }, [theme]);
10
+ return getThemeColor(suppliedTheme.primaryColor, suppliedTheme);
11
+ }, [suppliedTheme]);
19
12
  const secondary = useMemo(() => darken(primary, 0.25), [primary]);
20
13
  return useMemo(() => {
21
14
  return {
@@ -24,7 +17,7 @@ const useThematicGradient = ({
24
17
  };
25
18
  }, [primary, secondary]);
26
19
  };
27
- function StylishText({
20
+ function InvenTreeStylishText({
28
21
  children,
29
22
  theme,
30
23
  size
@@ -41,6 +34,6 @@ function StylishText({
41
34
  }, children });
42
35
  }
43
36
  export {
44
- StylishText
37
+ InvenTreeStylishText
45
38
  };
46
- //# sourceMappingURL=StylishText.js.map
39
+ //# sourceMappingURL=InvenTreeStylishText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvenTreeStylishText.js","sources":["../../lib/components/InvenTreeStylishText.tsx"],"sourcesContent":["import {\n type MantineSize,\n type MantineTheme,\n Text,\n darken,\n getThemeColor\n} from '@mantine/core';\nimport { useMemo } from 'react';\nimport type { JSX } from 'react';\n\n// Hook that memoizes the gradient color based on the primary color of the theme\nconst useThematicGradient = ({\n suppliedTheme\n}: {\n suppliedTheme: MantineTheme;\n}) => {\n const primary = useMemo(() => {\n return getThemeColor(suppliedTheme.primaryColor, suppliedTheme);\n }, [suppliedTheme]);\n\n const secondary = useMemo(() => darken(primary, 0.25), [primary]);\n\n return useMemo(() => {\n return { primary, secondary };\n }, [primary, secondary]);\n};\n\n/**\n * A stylish text component that uses the primary color of the theme\n * Note that the \"theme\" object must be provided by the parent component.\n * - For plugins this theme object is provided.\n * - For the main UI, we have a separate <StylishText> component\n */\nexport function InvenTreeStylishText({\n children,\n theme,\n size\n}: Readonly<{\n children: JSX.Element | string;\n theme: MantineTheme;\n size?: MantineSize;\n}>) {\n const { primary, secondary } = useThematicGradient({ suppliedTheme: theme });\n\n return (\n <Text\n fw={700}\n size={size ?? 'xl'}\n variant='gradient'\n gradient={{ from: primary.toString(), to: secondary.toString() }}\n >\n {children}\n </Text>\n );\n}\n"],"names":["useThematicGradient","suppliedTheme","primary","useMemo","getThemeColor","primaryColor","secondary","darken","InvenTreeStylishText","children","theme","size","jsx","from","toString","to"],"mappings":";;;;;AAWA,MAAMA,sBAAsBA,CAAC;AAAA,EAC3BC;AAGF,MAAM;AACEC,QAAAA,UAAUC,QAAQ,MAAM;AACrBC,WAAAA,cAAcH,cAAcI,cAAcJ,aAAa;AAAA,EAAA,GAC7D,CAACA,aAAa,CAAC;AAEZK,QAAAA,YAAYH,QAAQ,MAAMI,OAAOL,SAAS,IAAI,GAAG,CAACA,OAAO,CAAC;AAEhE,SAAOC,QAAQ,MAAM;AACZ,WAAA;AAAA,MAAED;AAAAA,MAASI;AAAAA,IAAU;AAAA,EAAA,GAC3B,CAACJ,SAASI,SAAS,CAAC;AACzB;AAQO,SAASE,qBAAqB;AAAA,EACnCC;AAAAA,EACAC;AAAAA,EACAC;AAKD,GAAG;AACI,QAAA;AAAA,IAAET;AAAAA,IAASI;AAAAA,MAAcN,oBAAoB;AAAA,IAAEC,eAAeS;AAAAA,EAAAA,CAAO;AAGzE,SAAAE,sCAAC,QACC,IAAI,KACJ,MAAMD,QAAQ,MACd,SAAQ,YACR,UAAU;AAAA,IAAEE,MAAMX,QAAQY,SAAS;AAAA,IAAGC,IAAIT,UAAUQ,SAAS;AAAA,KAE5DL,SACH,CAAA;AAEJ;"}
package/dist/index.d.ts CHANGED
@@ -6,4 +6,4 @@ export type { InvenTreePluginContext } from './types/Plugins';
6
6
  export { apiUrl } from './functions/Api';
7
7
  export { getBaseUrl, getDetailUrl, navigateToLink } from './functions/Navigation';
8
8
  export { checkPluginVersion } from './functions/Plugins';
9
- export { StylishText } from './components/StylishText';
9
+ export { InvenTreeStylishText } from './components/InvenTreeStylishText';
package/dist/index.js CHANGED
@@ -5,15 +5,15 @@ import { UserPermissions, UserRoles } from "./enums/Roles.js";
5
5
  import { apiUrl } from "./functions/Api.js";
6
6
  import { getBaseUrl, getDetailUrl, navigateToLink } from "./functions/Navigation.js";
7
7
  import { checkPluginVersion } from "./functions/Plugins.js";
8
- import { StylishText } from "./components/StylishText.js";
8
+ import { InvenTreeStylishText } from "./components/InvenTreeStylishText.js";
9
9
  export {
10
10
  ApiEndpoints,
11
11
  INVENTREE_MANTINE_VERSION,
12
12
  INVENTREE_PLUGIN_VERSION,
13
13
  INVENTREE_REACT_DOM_VERSION,
14
14
  INVENTREE_REACT_VERSION,
15
+ InvenTreeStylishText,
15
16
  ModelType,
16
- StylishText,
17
17
  UserPermissions,
18
18
  UserRoles,
19
19
  apiUrl,
@@ -1,4 +1,4 @@
1
- const INVENTREE_PLUGIN_VERSION = "0.2.1";
1
+ const INVENTREE_PLUGIN_VERSION = "0.2.2";
2
2
  const INVENTREE_REACT_VERSION = "18.3.1";
3
3
  const INVENTREE_REACT_DOM_VERSION = (
4
4
  // @ts-ignore
@@ -3,8 +3,7 @@ import {
3
3
  type MantineTheme,
4
4
  Text,
5
5
  darken,
6
- getThemeColor,
7
- useMantineTheme
6
+ getThemeColor
8
7
  } from '@mantine/core';
9
8
  import { useMemo } from 'react';
10
9
  import type { JSX } from 'react';
@@ -13,19 +12,11 @@ import type { JSX } from 'react';
13
12
  const useThematicGradient = ({
14
13
  suppliedTheme
15
14
  }: {
16
- suppliedTheme?: MantineTheme;
15
+ suppliedTheme: MantineTheme;
17
16
  }) => {
18
- const theme = useMemo(() => {
19
- if (suppliedTheme && suppliedTheme != undefined) {
20
- return suppliedTheme;
21
- }
22
-
23
- return useMantineTheme();
24
- }, [suppliedTheme, useMantineTheme]);
25
-
26
17
  const primary = useMemo(() => {
27
- return getThemeColor(theme.primaryColor, theme);
28
- }, [theme]);
18
+ return getThemeColor(suppliedTheme.primaryColor, suppliedTheme);
19
+ }, [suppliedTheme]);
29
20
 
30
21
  const secondary = useMemo(() => darken(primary, 0.25), [primary]);
31
22
 
@@ -34,14 +25,19 @@ const useThematicGradient = ({
34
25
  }, [primary, secondary]);
35
26
  };
36
27
 
37
- // A stylish text component that uses the primary color of the theme
38
- export function StylishText({
28
+ /**
29
+ * A stylish text component that uses the primary color of the theme
30
+ * Note that the "theme" object must be provided by the parent component.
31
+ * - For plugins this theme object is provided.
32
+ * - For the main UI, we have a separate <StylishText> component
33
+ */
34
+ export function InvenTreeStylishText({
39
35
  children,
40
36
  theme,
41
37
  size
42
38
  }: Readonly<{
43
39
  children: JSX.Element | string;
44
- theme?: MantineTheme;
40
+ theme: MantineTheme;
45
41
  size?: MantineSize;
46
42
  }>) {
47
43
  const { primary, secondary } = useThematicGradient({ suppliedTheme: theme });
package/lib/index.ts CHANGED
@@ -23,4 +23,4 @@ export {
23
23
  export { checkPluginVersion } from './functions/Plugins';
24
24
 
25
25
  // UI components
26
- export { StylishText } from './components/StylishText';
26
+ export { InvenTreeStylishText } from './components/InvenTreeStylishText';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inventreedb/ui",
3
3
  "description": "UI components for the InvenTree project",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -1,7 +0,0 @@
1
- import { MantineSize, MantineTheme } from '@mantine/core';
2
- import { JSX } from 'react';
3
- export declare function StylishText({ children, theme, size }: Readonly<{
4
- children: JSX.Element | string;
5
- theme?: MantineTheme;
6
- size?: MantineSize;
7
- }>): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- {"version":3,"file":"StylishText.js","sources":["../../lib/components/StylishText.tsx"],"sourcesContent":["import {\n type MantineSize,\n MantineTheme,\n Text,\n darken,\n getThemeColor,\n useMantineTheme\n} from '@mantine/core';\nimport { useMemo } from 'react';\nimport type { JSX } from 'react';\n\n// Hook that memoizes the gradient color based on the primary color of the theme\nconst useThematicGradient = ({\n suppliedTheme,\n}: {\n suppliedTheme?: MantineTheme;\n}) => {\n\n const theme = useMemo(() => {\n if (suppliedTheme && suppliedTheme != undefined) {\n return suppliedTheme;\n }\n\n return useMantineTheme();\n }, [suppliedTheme, useMantineTheme]);\n\n const primary = useMemo(() => {\n return getThemeColor(theme.primaryColor, theme);\n }, [theme]);\n\n const secondary = useMemo(() => darken(primary, 0.25), [primary]);\n\n return useMemo(() => {\n return { primary, secondary };\n }, [primary, secondary]);\n};\n\n// A stylish text component that uses the primary color of the theme\nexport function StylishText({\n children,\n theme,\n size\n}: Readonly<{\n children: JSX.Element | string;\n theme?: MantineTheme;\n size?: MantineSize;\n}>) {\n const { primary, secondary } = useThematicGradient({ suppliedTheme: theme });\n\n return (\n <Text\n fw={700}\n size={size ?? 'xl'}\n variant='gradient'\n gradient={{ from: primary.toString(), to: secondary.toString() }}\n >\n {children}\n </Text>\n );\n}\n"],"names":["useThematicGradient","suppliedTheme","theme","useMemo","undefined","useMantineTheme","primary","getThemeColor","primaryColor","secondary","darken","StylishText","children","size","jsx","from","toString","to"],"mappings":";;;;;;AAYA,MAAMA,sBAAsBA,CAAC;AAAA,EAC3BC;AAGF,MAAM;AAEEC,QAAAA,QAAQC,QAAQ,MAAM;AACtBF,QAAAA,iBAAiBA,iBAAiBG,QAAW;AACxCH,aAAAA;AAAAA,IAAAA;AAGT,WAAOI,gBAAgB;AAAA,EAAA,GACtB,CAACJ,eAAeI,eAAe,CAAC;AAE7BC,QAAAA,UAAUH,QAAQ,MAAM;AACrBI,WAAAA,cAAcL,MAAMM,cAAcN,KAAK;AAAA,EAAA,GAC7C,CAACA,KAAK,CAAC;AAEJO,QAAAA,YAAYN,QAAQ,MAAMO,OAAOJ,SAAS,IAAI,GAAG,CAACA,OAAO,CAAC;AAEhE,SAAOH,QAAQ,MAAM;AACZ,WAAA;AAAA,MAAEG;AAAAA,MAASG;AAAAA,IAAU;AAAA,EAAA,GAC3B,CAACH,SAASG,SAAS,CAAC;AACzB;AAGO,SAASE,YAAY;AAAA,EAC1BC;AAAAA,EACAV;AAAAA,EACAW;AAKD,GAAG;AACI,QAAA;AAAA,IAAEP;AAAAA,IAASG;AAAAA,MAAcT,oBAAoB;AAAA,IAAEC,eAAeC;AAAAA,EAAAA,CAAO;AAGzE,SAAAY,sCAAC,QACC,IAAI,KACJ,MAAMD,QAAQ,MACd,SAAQ,YACR,UAAU;AAAA,IAAEE,MAAMT,QAAQU,SAAS;AAAA,IAAGC,IAAIR,UAAUO,SAAS;AAAA,KAE5DJ,SACH,CAAA;AAEJ;"}