@inventreedb/ui 0.2.0 → 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,15 +1,15 @@
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
- const useThematicGradient = () => {
8
- const theme = useMantineTheme();
6
+ const useThematicGradient = ({
7
+ suppliedTheme
8
+ }) => {
9
9
  const primary = useMemo(() => {
10
- return getThemeColor(theme.primaryColor, theme);
11
- }, [theme]);
12
- const secondary = useMemo(() => darken(primary, 0.9), [primary]);
10
+ return getThemeColor(suppliedTheme.primaryColor, suppliedTheme);
11
+ }, [suppliedTheme]);
12
+ const secondary = useMemo(() => darken(primary, 0.25), [primary]);
13
13
  return useMemo(() => {
14
14
  return {
15
15
  primary,
@@ -17,20 +17,23 @@ const useThematicGradient = () => {
17
17
  };
18
18
  }, [primary, secondary]);
19
19
  };
20
- function StylishText({
20
+ function InvenTreeStylishText({
21
21
  children,
22
+ theme,
22
23
  size
23
24
  }) {
24
25
  const {
25
26
  primary,
26
27
  secondary
27
- } = useThematicGradient();
28
+ } = useThematicGradient({
29
+ suppliedTheme: theme
30
+ });
28
31
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fw: 700, size: size ?? "xl", variant: "gradient", gradient: {
29
32
  from: primary.toString(),
30
33
  to: secondary.toString()
31
34
  }, children });
32
35
  }
33
36
  export {
34
- StylishText
37
+ InvenTreeStylishText
35
38
  };
36
- //# 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.1.0";
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
@@ -0,0 +1,55 @@
1
+ import {
2
+ type MantineSize,
3
+ type MantineTheme,
4
+ Text,
5
+ darken,
6
+ getThemeColor
7
+ } from '@mantine/core';
8
+ import { useMemo } from 'react';
9
+ import type { JSX } from 'react';
10
+
11
+ // Hook that memoizes the gradient color based on the primary color of the theme
12
+ const useThematicGradient = ({
13
+ suppliedTheme
14
+ }: {
15
+ suppliedTheme: MantineTheme;
16
+ }) => {
17
+ const primary = useMemo(() => {
18
+ return getThemeColor(suppliedTheme.primaryColor, suppliedTheme);
19
+ }, [suppliedTheme]);
20
+
21
+ const secondary = useMemo(() => darken(primary, 0.25), [primary]);
22
+
23
+ return useMemo(() => {
24
+ return { primary, secondary };
25
+ }, [primary, secondary]);
26
+ };
27
+
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({
35
+ children,
36
+ theme,
37
+ size
38
+ }: Readonly<{
39
+ children: JSX.Element | string;
40
+ theme: MantineTheme;
41
+ size?: MantineSize;
42
+ }>) {
43
+ const { primary, secondary } = useThematicGradient({ suppliedTheme: theme });
44
+
45
+ return (
46
+ <Text
47
+ fw={700}
48
+ size={size ?? 'xl'}
49
+ variant='gradient'
50
+ gradient={{ from: primary.toString(), to: secondary.toString() }}
51
+ >
52
+ {children}
53
+ </Text>
54
+ );
55
+ }
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.0",
4
+ "version": "0.2.2",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -1,6 +0,0 @@
1
- import { MantineSize } from '@mantine/core';
2
- import { JSX } from 'react';
3
- export declare function StylishText({ children, size }: Readonly<{
4
- children: JSX.Element | string;
5
- size?: MantineSize;
6
- }>): 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 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 const theme = useMantineTheme();\n\n const primary = useMemo(() => {\n return getThemeColor(theme.primaryColor, theme);\n }, [theme]);\n\n const secondary = useMemo(() => darken(primary, 0.9), [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 size\n}: Readonly<{\n children: JSX.Element | string;\n size?: MantineSize;\n}>) {\n const { primary, secondary } = useThematicGradient();\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","theme","useMantineTheme","primary","useMemo","getThemeColor","primaryColor","secondary","darken","StylishText","children","size","jsx","from","toString","to"],"mappings":";;;;;;AAWA,MAAMA,sBAAsBA,MAAM;AAChC,QAAMC,QAAQC,gBAAgB;AAExBC,QAAAA,UAAUC,QAAQ,MAAM;AACrBC,WAAAA,cAAcJ,MAAMK,cAAcL,KAAK;AAAA,EAAA,GAC7C,CAACA,KAAK,CAAC;AAEJM,QAAAA,YAAYH,QAAQ,MAAMI,OAAOL,SAAS,GAAG,GAAG,CAACA,OAAO,CAAC;AAE/D,SAAOC,QAAQ,MAAM;AACZ,WAAA;AAAA,MAAED;AAAAA,MAASI;AAAAA,IAAU;AAAA,EAAA,GAC3B,CAACJ,SAASI,SAAS,CAAC;AACzB;AAGO,SAASE,YAAY;AAAA,EAC1BC;AAAAA,EACAC;AAID,GAAG;AACI,QAAA;AAAA,IAAER;AAAAA,IAASI;AAAAA,MAAcP,oBAAoB;AAGjD,SAAAY,sCAAC,QACC,IAAI,KACJ,MAAMD,QAAQ,MACd,SAAQ,YACR,UAAU;AAAA,IAAEE,MAAMV,QAAQW,SAAS;AAAA,IAAGC,IAAIR,UAAUO,SAAS;AAAA,KAE5DJ,SACH,CAAA;AAEJ;"}
@@ -1,46 +0,0 @@
1
- import {
2
- type MantineSize,
3
- Text,
4
- darken,
5
- getThemeColor,
6
- useMantineTheme
7
- } from '@mantine/core';
8
- import { useMemo } from 'react';
9
- import type { JSX } from 'react';
10
-
11
- // Hook that memoizes the gradient color based on the primary color of the theme
12
- const useThematicGradient = () => {
13
- const theme = useMantineTheme();
14
-
15
- const primary = useMemo(() => {
16
- return getThemeColor(theme.primaryColor, theme);
17
- }, [theme]);
18
-
19
- const secondary = useMemo(() => darken(primary, 0.9), [primary]);
20
-
21
- return useMemo(() => {
22
- return { primary, secondary };
23
- }, [primary, secondary]);
24
- };
25
-
26
- // A stylish text component that uses the primary color of the theme
27
- export function StylishText({
28
- children,
29
- size
30
- }: Readonly<{
31
- children: JSX.Element | string;
32
- size?: MantineSize;
33
- }>) {
34
- const { primary, secondary } = useThematicGradient();
35
-
36
- return (
37
- <Text
38
- fw={700}
39
- size={size ?? 'xl'}
40
- variant='gradient'
41
- gradient={{ from: primary.toString(), to: secondary.toString() }}
42
- >
43
- {children}
44
- </Text>
45
- );
46
- }