@inventreedb/ui 0.6.0 → 0.8.0

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 (96) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/.vite/manifest.json +162 -1
  3. package/dist/components/ProgressBar.d.ts +1 -0
  4. package/dist/components/ProgressBar.js +12 -4
  5. package/dist/components/ProgressBar.js.map +1 -1
  6. package/dist/components/RowActions.js +1 -2
  7. package/dist/components/RowActions.js.map +1 -1
  8. package/dist/enums/ApiEndpoints.d.ts +11 -4
  9. package/dist/enums/ApiEndpoints.js +10 -3
  10. package/dist/enums/ApiEndpoints.js.map +1 -1
  11. package/dist/enums/ModelInformation.d.ts +1 -0
  12. package/dist/enums/ModelInformation.js +34 -8
  13. package/dist/enums/ModelInformation.js.map +1 -1
  14. package/dist/enums/ModelType.d.ts +2 -1
  15. package/dist/enums/ModelType.js +2 -1
  16. package/dist/enums/ModelType.js.map +1 -1
  17. package/dist/functions/Conversion.d.ts +1 -0
  18. package/dist/functions/Conversion.js.map +1 -1
  19. package/dist/functions/Events.js +3 -4
  20. package/dist/functions/Events.js.map +1 -1
  21. package/dist/functions/Navigation.d.ts +5 -0
  22. package/dist/functions/Navigation.js +2 -5
  23. package/dist/functions/Navigation.js.map +1 -1
  24. package/dist/functions/Plugins.js +2 -4
  25. package/dist/functions/Plugins.js.map +1 -1
  26. package/dist/hooks/MonitorDataOutput.d.ts +10 -0
  27. package/dist/hooks/MonitorDataOutput.js +112 -0
  28. package/dist/hooks/MonitorDataOutput.js.map +1 -0
  29. package/dist/index.d.ts +3 -1
  30. package/dist/index.js +2 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js +16 -0
  33. package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js.map +1 -0
  34. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +14 -0
  35. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -0
  36. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +14 -0
  37. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -0
  38. package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js +67 -0
  39. package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -0
  40. package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.js +84 -0
  41. package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -0
  42. package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js +57 -0
  43. package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -0
  44. package/dist/node_modules/@tanstack/query-core/build/modern/query.js +16 -0
  45. package/dist/node_modules/@tanstack/query-core/build/modern/query.js.map +1 -0
  46. package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +456 -0
  47. package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -0
  48. package/dist/node_modules/@tanstack/query-core/build/modern/retryer.js +8 -0
  49. package/dist/node_modules/@tanstack/query-core/build/modern/retryer.js.map +1 -0
  50. package/dist/node_modules/@tanstack/query-core/build/modern/subscribable.js +25 -0
  51. package/dist/node_modules/@tanstack/query-core/build/modern/subscribable.js.map +1 -0
  52. package/dist/node_modules/@tanstack/query-core/build/modern/thenable.js +35 -0
  53. package/dist/node_modules/@tanstack/query-core/build/modern/thenable.js.map +1 -0
  54. package/dist/node_modules/@tanstack/query-core/build/modern/utils.js +123 -0
  55. package/dist/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -0
  56. package/dist/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js +8 -0
  57. package/dist/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js.map +1 -0
  58. package/dist/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js +17 -0
  59. package/dist/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js.map +1 -0
  60. package/dist/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js +22 -0
  61. package/dist/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js.map +1 -0
  62. package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +29 -0
  63. package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -0
  64. package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js +26 -0
  65. package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -0
  66. package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +92 -0
  67. package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -0
  68. package/dist/node_modules/@tanstack/react-query/build/modern/useQuery.js +9 -0
  69. package/dist/node_modules/@tanstack/react-query/build/modern/useQuery.js.map +1 -0
  70. package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +15 -19
  71. package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
  72. package/dist/types/Auth.d.ts +13 -1
  73. package/dist/types/Core.d.ts +2 -2
  74. package/dist/types/Filters.d.ts +1 -1
  75. package/dist/types/Forms.d.ts +19 -0
  76. package/dist/types/Plugins.d.ts +13 -1
  77. package/dist/types/Plugins.js +3 -3
  78. package/dist/types/Plugins.js.map +1 -1
  79. package/dist/types/Settings.d.ts +2 -0
  80. package/dist/types/Tables.d.ts +6 -0
  81. package/lib/components/ProgressBar.tsx +8 -4
  82. package/lib/enums/ApiEndpoints.tsx +13 -4
  83. package/lib/enums/ModelInformation.tsx +25 -8
  84. package/lib/enums/ModelType.tsx +2 -1
  85. package/lib/functions/Conversion.tsx +38 -0
  86. package/lib/functions/Navigation.tsx +22 -0
  87. package/lib/hooks/MonitorDataOutput.tsx +122 -0
  88. package/lib/index.ts +14 -1
  89. package/lib/types/Auth.tsx +13 -1
  90. package/lib/types/Core.tsx +2 -2
  91. package/lib/types/Filters.tsx +1 -1
  92. package/lib/types/Forms.tsx +20 -0
  93. package/lib/types/Plugins.tsx +18 -1
  94. package/lib/types/Settings.tsx +2 -0
  95. package/lib/types/Tables.tsx +6 -0
  96. package/package.json +11 -9
@@ -1,5 +1,16 @@
1
1
  export interface AuthContext {
2
2
  status: number;
3
+ user?: {
4
+ id: number;
5
+ display: string;
6
+ has_usable_password: boolean;
7
+ username: string;
8
+ };
9
+ methods?: {
10
+ method: string;
11
+ at: number;
12
+ username: string;
13
+ }[];
3
14
  data: {
4
15
  flows: Flow[];
5
16
  };
@@ -17,7 +28,8 @@ export declare enum FlowEnum {
17
28
  MfaAuthenticate = "mfa_authenticate",
18
29
  Reauthenticate = "reauthenticate",
19
30
  MfaReauthenticate = "mfa_reauthenticate",
20
- MfaTrust = "mfa_trust"
31
+ MfaTrust = "mfa_trust",
32
+ MfaRegister = "mfa_register"
21
33
  }
22
34
  export interface Flow {
23
35
  id: FlowEnum;
@@ -1,10 +1,10 @@
1
- import { MantineSize } from '@mantine/core';
1
+ import { MantineRadius, MantineSize } from '@mantine/core';
2
2
  export type UiSizeType = MantineSize | string | number;
3
3
  export interface UserTheme {
4
4
  primaryColor: string;
5
5
  whiteColor: string;
6
6
  blackColor: string;
7
- radius: UiSizeType;
7
+ radius: MantineRadius;
8
8
  loader: string;
9
9
  }
10
10
  export type PathParams = Record<string, string | number>;
@@ -36,7 +36,7 @@ export type TableFilterType = 'boolean' | 'choice' | 'date' | 'text' | 'api';
36
36
  */
37
37
  export type TableFilter = {
38
38
  name: string;
39
- label: string;
39
+ label?: string;
40
40
  description?: string;
41
41
  type?: TableFilterType;
42
42
  choices?: TableFilterChoice[];
@@ -41,14 +41,19 @@ export type ApiFormFieldHeader = {
41
41
  * @param model : The model to use for related fields
42
42
  * @param filters : Optional API filters to apply to related fields
43
43
  * @param required : Whether the field is required
44
+ * @param allow_null: Whether the field allows null values
45
+ * @param allow_blank: Whether the field allows blank values
44
46
  * @param hidden : Whether the field is hidden
45
47
  * @param disabled : Whether the field is disabled
46
48
  * @param error : Optional error message to display
47
49
  * @param exclude : Whether to exclude the field from the submitted data
48
50
  * @param placeholder : The placeholder text to display
51
+ * @param placeholderAutofill: Whether to allow auto-filling of the placeholder value
49
52
  * @param description : The description to display for the field
50
53
  * @param preFieldContent : Content to render before the field
51
54
  * @param postFieldContent : Content to render after the field
55
+ * @param leftSection : Content to render in the left section of the field
56
+ * @param rightSection : Content to render in the right section of the field
52
57
  * @param autoFill: Whether to automatically fill the field with data from the API
53
58
  * @param autoFillFilters: Optional filters to apply when auto-filling the field
54
59
  * @param onValueChange : Callback function to call when the field value changes
@@ -77,12 +82,19 @@ export type ApiFormFieldType = {
77
82
  choices?: ApiFormFieldChoice[];
78
83
  hidden?: boolean;
79
84
  disabled?: boolean;
85
+ allow_null?: boolean;
86
+ allow_blank?: boolean;
80
87
  exclude?: boolean;
81
88
  read_only?: boolean;
82
89
  placeholder?: string;
90
+ placeholderAutofill?: boolean;
91
+ placeholderWarningCompare?: string | number;
92
+ placeholderWarning?: string;
83
93
  description?: string;
84
94
  preFieldContent?: JSX.Element;
85
95
  postFieldContent?: JSX.Element;
96
+ leftSection?: JSX.Element;
97
+ rightSection?: JSX.Element;
86
98
  autoFill?: boolean;
87
99
  autoFillFilters?: any;
88
100
  adjustValue?: (value: any) => any;
@@ -164,3 +176,10 @@ export interface ApiFormModalProps extends ApiFormProps {
164
176
  export interface BulkEditApiFormModalProps extends ApiFormModalProps {
165
177
  items: number[];
166
178
  }
179
+ export type StockOperationProps = {
180
+ items?: any[];
181
+ pk?: number;
182
+ filters?: any;
183
+ model: ModelType.stockitem | 'location' | ModelType.part;
184
+ refresh: () => void;
185
+ };
@@ -5,7 +5,7 @@ import { AxiosInstance } from 'axios';
5
5
  import { NavigateFunction } from 'react-router-dom';
6
6
  import { ModelDict } from '../enums/ModelInformation';
7
7
  import { ModelType } from '../enums/ModelType';
8
- import { ApiFormModalProps, BulkEditApiFormModalProps } from './Forms';
8
+ import { ApiFormModalProps, BulkEditApiFormModalProps, StockOperationProps } from './Forms';
9
9
  import { UseModalReturn } from './Modals';
10
10
  import { RenderInstanceProps } from './Rendering';
11
11
  import { SettingsStateProps } from './Settings';
@@ -21,11 +21,23 @@ export interface PluginVersion {
21
21
  reactDom: string;
22
22
  mantine: string;
23
23
  }
24
+ export type StockAdjustmentFormsContext = {
25
+ addStock: (props: StockOperationProps) => UseModalReturn;
26
+ assignStock: (props: StockOperationProps) => UseModalReturn;
27
+ changeStatus: (props: StockOperationProps) => UseModalReturn;
28
+ countStock: (props: StockOperationProps) => UseModalReturn;
29
+ deleteStock: (props: StockOperationProps) => UseModalReturn;
30
+ mergeStock: (props: StockOperationProps) => UseModalReturn;
31
+ removeStock: (props: StockOperationProps) => UseModalReturn;
32
+ transferStock: (props: StockOperationProps) => UseModalReturn;
33
+ returnStock: (props: StockOperationProps) => UseModalReturn;
34
+ };
24
35
  export type InvenTreeFormsContext = {
25
36
  bulkEdit: (props: BulkEditApiFormModalProps) => UseModalReturn;
26
37
  create: (props: ApiFormModalProps) => UseModalReturn;
27
38
  delete: (props: ApiFormModalProps) => UseModalReturn;
28
39
  edit: (props: ApiFormModalProps) => UseModalReturn;
40
+ stockActions: StockAdjustmentFormsContext;
29
41
  };
30
42
  /**
31
43
  * A set of properties which are passed to a plugin,
@@ -1,8 +1,8 @@
1
- const INVENTREE_PLUGIN_VERSION = "0.6.0";
2
- const INVENTREE_REACT_VERSION = "19.1.1";
1
+ const INVENTREE_PLUGIN_VERSION = "0.8.0";
2
+ const INVENTREE_REACT_VERSION = "19.1.2";
3
3
  const INVENTREE_REACT_DOM_VERSION = (
4
4
  // @ts-ignore
5
- "19.1.1"
5
+ "19.1.2"
6
6
  );
7
7
  const INVENTREE_MANTINE_VERSION = "8.2.7";
8
8
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"Plugins.js","sources":["../../lib/types/Plugins.tsx"],"sourcesContent":["import type { I18n } from '@lingui/core';\nimport type { MantineColorScheme, MantineTheme } from '@mantine/core';\nimport type { QueryClient } from '@tanstack/react-query';\nimport type { AxiosInstance } from 'axios';\nimport type { NavigateFunction } from 'react-router-dom';\nimport type { ModelDict } from '../enums/ModelInformation';\nimport type { ModelType } from '../enums/ModelType';\nimport type { ApiFormModalProps, BulkEditApiFormModalProps } from './Forms';\nimport type { UseModalReturn } from './Modals';\nimport type { RenderInstanceProps } from './Rendering';\nimport type { SettingsStateProps } from './Settings';\nimport type { UserStateProps } from './User';\n\nexport interface PluginProps {\n name: string;\n slug: string;\n version: null | string;\n}\n\nexport interface PluginVersion {\n inventree: string;\n react: string;\n reactDom: string;\n mantine: string;\n}\n\nexport type InvenTreeFormsContext = {\n bulkEdit: (props: BulkEditApiFormModalProps) => UseModalReturn;\n create: (props: ApiFormModalProps) => UseModalReturn;\n delete: (props: ApiFormModalProps) => UseModalReturn;\n edit: (props: ApiFormModalProps) => UseModalReturn;\n};\n\n/**\n * A set of properties which are passed to a plugin,\n * for rendering an element in the user interface.\n *\n * @param version - The version of the running InvenTree software stack\n * @param api - The Axios API instance (see ../states/ApiState.tsx)\n * @param user - The current user instance (see ../states/UserState.tsx)\n * @param userSettings - The current user settings (see ../states/SettingsState.tsx)\n * @param globalSettings - The global settings (see ../states/SettingsState.tsx)\n * @param navigate - The navigation function (see react-router-dom)\n * @param theme - The current Mantine theme\n * @param colorScheme - The current Mantine color scheme (e.g. 'light' / 'dark')\n * @param host - The current host URL\n * @param i18n - The i18n instance for translations (from @lingui/core)\n * @param locale - The current locale string (e.g. 'en' / 'de')\n * @param model - The model type associated with the rendered component (if applicable)\n * @param modelInformation - A dictionary of available model information\n * @param renderInstance - A component function for rendering a model instance\n * @param id - The ID (primary key) of the model instance for the plugin (if applicable)\n * @param instance - The model instance data (if available)\n * @param reloadContent - A function which can be called to reload the plugin content\n * @param reloadInstance - A function which can be called to reload the model instance\n * @param context - Any additional context data which may be passed to the plugin\n */\nexport type InvenTreePluginContext = {\n version: PluginVersion;\n api: AxiosInstance;\n queryClient: QueryClient;\n user: UserStateProps;\n userSettings: SettingsStateProps;\n globalSettings: SettingsStateProps;\n modelInformation: ModelDict;\n renderInstance: (props: Readonly<RenderInstanceProps>) => React.ReactNode;\n host: string;\n i18n: I18n;\n locale: string;\n navigate: NavigateFunction;\n theme: MantineTheme;\n forms: InvenTreeFormsContext;\n colorScheme: MantineColorScheme;\n model?: ModelType | string;\n id?: string | number | null;\n instance?: any;\n reloadContent?: () => void;\n reloadInstance?: () => void;\n context?: any;\n};\n\n/*\n * The version of the InvenTree plugin context interface.\n * This number should be incremented if the interface changes.\n */\n\n// @ts-ignore\nexport const INVENTREE_PLUGIN_VERSION: string = __INVENTREE_LIB_VERSION__;\n// @ts-ignore\nexport const INVENTREE_REACT_VERSION: string = __INVENTREE_REACT_VERSION__;\n// @ts-ignore\nexport const INVENTREE_REACT_DOM_VERSION: string =\n // @ts-ignore\n __INVENTREE_REACT_DOM_VERSION__;\n// @ts-ignore\nexport const INVENTREE_MANTINE_VERSION: string = __INVENTREE_MANTINE_VERSION__;\n"],"names":["INVENTREE_PLUGIN_VERSION","__INVENTREE_LIB_VERSION__","INVENTREE_REACT_VERSION","__INVENTREE_REACT_VERSION__","INVENTREE_REACT_DOM_VERSION","__INVENTREE_REACT_DOM_VERSION__","INVENTREE_MANTINE_VERSION","__INVENTREE_MANTINE_VERSION__"],"mappings":"AAuFO,MAAMA,2BAAmCC;AAEzC,MAAMC,0BAAkCC;AAExC,MAAMC;AAAAA;AAAAA,EAEXC;AAAAA;AAEK,MAAMC,4BAAoCC;"}
1
+ {"version":3,"file":"Plugins.js","sources":["../../lib/types/Plugins.tsx"],"sourcesContent":["import type { I18n } from '@lingui/core';\nimport type { MantineColorScheme, MantineTheme } from '@mantine/core';\nimport type { QueryClient } from '@tanstack/react-query';\nimport type { AxiosInstance } from 'axios';\nimport type { NavigateFunction } from 'react-router-dom';\nimport type { ModelDict } from '../enums/ModelInformation';\nimport type { ModelType } from '../enums/ModelType';\nimport type {\n ApiFormModalProps,\n BulkEditApiFormModalProps,\n StockOperationProps\n} from './Forms';\nimport type { UseModalReturn } from './Modals';\nimport type { RenderInstanceProps } from './Rendering';\nimport type { SettingsStateProps } from './Settings';\nimport type { UserStateProps } from './User';\n\nexport interface PluginProps {\n name: string;\n slug: string;\n version: null | string;\n}\n\nexport interface PluginVersion {\n inventree: string;\n react: string;\n reactDom: string;\n mantine: string;\n}\n\nexport type StockAdjustmentFormsContext = {\n addStock: (props: StockOperationProps) => UseModalReturn;\n assignStock: (props: StockOperationProps) => UseModalReturn;\n changeStatus: (props: StockOperationProps) => UseModalReturn;\n countStock: (props: StockOperationProps) => UseModalReturn;\n deleteStock: (props: StockOperationProps) => UseModalReturn;\n mergeStock: (props: StockOperationProps) => UseModalReturn;\n removeStock: (props: StockOperationProps) => UseModalReturn;\n transferStock: (props: StockOperationProps) => UseModalReturn;\n returnStock: (props: StockOperationProps) => UseModalReturn;\n};\n\nexport type InvenTreeFormsContext = {\n bulkEdit: (props: BulkEditApiFormModalProps) => UseModalReturn;\n create: (props: ApiFormModalProps) => UseModalReturn;\n delete: (props: ApiFormModalProps) => UseModalReturn;\n edit: (props: ApiFormModalProps) => UseModalReturn;\n stockActions: StockAdjustmentFormsContext;\n};\n\n/**\n * A set of properties which are passed to a plugin,\n * for rendering an element in the user interface.\n *\n * @param version - The version of the running InvenTree software stack\n * @param api - The Axios API instance (see ../states/ApiState.tsx)\n * @param user - The current user instance (see ../states/UserState.tsx)\n * @param userSettings - The current user settings (see ../states/SettingsState.tsx)\n * @param globalSettings - The global settings (see ../states/SettingsState.tsx)\n * @param navigate - The navigation function (see react-router-dom)\n * @param theme - The current Mantine theme\n * @param colorScheme - The current Mantine color scheme (e.g. 'light' / 'dark')\n * @param host - The current host URL\n * @param i18n - The i18n instance for translations (from @lingui/core)\n * @param locale - The current locale string (e.g. 'en' / 'de')\n * @param model - The model type associated with the rendered component (if applicable)\n * @param modelInformation - A dictionary of available model information\n * @param renderInstance - A component function for rendering a model instance\n * @param id - The ID (primary key) of the model instance for the plugin (if applicable)\n * @param instance - The model instance data (if available)\n * @param reloadContent - A function which can be called to reload the plugin content\n * @param reloadInstance - A function which can be called to reload the model instance\n * @param context - Any additional context data which may be passed to the plugin\n */\nexport type InvenTreePluginContext = {\n version: PluginVersion;\n api: AxiosInstance;\n queryClient: QueryClient;\n user: UserStateProps;\n userSettings: SettingsStateProps;\n globalSettings: SettingsStateProps;\n modelInformation: ModelDict;\n renderInstance: (props: Readonly<RenderInstanceProps>) => React.ReactNode;\n host: string;\n i18n: I18n;\n locale: string;\n navigate: NavigateFunction;\n theme: MantineTheme;\n forms: InvenTreeFormsContext;\n colorScheme: MantineColorScheme;\n model?: ModelType | string;\n id?: string | number | null;\n instance?: any;\n reloadContent?: () => void;\n reloadInstance?: () => void;\n context?: any;\n};\n\n/*\n * The version of the InvenTree plugin context interface.\n * This number should be incremented if the interface changes.\n */\n\n// @ts-ignore\nexport const INVENTREE_PLUGIN_VERSION: string = __INVENTREE_LIB_VERSION__;\n// @ts-ignore\nexport const INVENTREE_REACT_VERSION: string = __INVENTREE_REACT_VERSION__;\n// @ts-ignore\nexport const INVENTREE_REACT_DOM_VERSION: string =\n // @ts-ignore\n __INVENTREE_REACT_DOM_VERSION__;\n// @ts-ignore\nexport const INVENTREE_MANTINE_VERSION: string = __INVENTREE_MANTINE_VERSION__;\n"],"names":["INVENTREE_PLUGIN_VERSION","__INVENTREE_LIB_VERSION__","INVENTREE_REACT_VERSION","__INVENTREE_REACT_VERSION__","INVENTREE_REACT_DOM_VERSION","__INVENTREE_REACT_DOM_VERSION__","INVENTREE_MANTINE_VERSION","__INVENTREE_MANTINE_VERSION__"],"mappings":"AAwGO,MAAMA,2BAAmCC;AAEzC,MAAMC,0BAAkCC;AAExC,MAAMC;AAAAA;AAAAA,EAEXC;AAAAA;AAEK,MAAMC,4BAAoCC;"}
@@ -30,6 +30,8 @@ export interface Setting {
30
30
  method?: string;
31
31
  required?: boolean;
32
32
  read_only?: boolean;
33
+ confirm?: boolean;
34
+ confirm_text?: string;
33
35
  }
34
36
  export interface SettingChoice {
35
37
  value: string;
@@ -60,6 +60,8 @@ export type TableState = {
60
60
  * @param cellsStyle - The style of the cells in the column
61
61
  * @param extra - Extra data to pass to the render function
62
62
  * @param noContext - Disable context menu for this column
63
+ * @param copyable - Enable copy button on hover (uses accessor to get value, or custom function)
64
+ * @param copyAccessor - Custom accessor path for copy value (defaults to column accessor)
63
65
  */
64
66
  export type TableColumnProps<T = any> = {
65
67
  accessor?: string;
@@ -84,6 +86,8 @@ export type TableColumnProps<T = any> = {
84
86
  extra?: any;
85
87
  noContext?: boolean;
86
88
  style?: MantineStyleProp;
89
+ copyable?: boolean | ((record: T) => string);
90
+ copyAccessor?: string;
87
91
  };
88
92
  /**
89
93
  * Interface for the table column definition
@@ -128,6 +132,7 @@ export type RowViewProps = RowAction & RowModelProps;
128
132
  * @param barcodeActions : any[] - List of barcode actions
129
133
  * @param tableFilters : TableFilter[] - List of custom filters
130
134
  * @param tableActions : any[] - List of custom action groups
135
+ * @param detailAction: boolean - Enable detail action for each row (default = true)
131
136
  * @param dataFormatter : (data: any) => any - Callback function to reformat data returned by server (if not in default format)
132
137
  * @param rowActions : (record: any) => RowAction[] - Callback function to generate row actions
133
138
  * @param onRowClick : (record: any, index: number, event: any) => void - Callback function when a row is clicked
@@ -159,6 +164,7 @@ export type InvenTreeTableProps<T = any> = {
159
164
  rowExpansion?: DataTableRowExpansionProps<T>;
160
165
  dataFormatter?: (data: any) => any;
161
166
  rowActions?: (record: T) => RowAction[];
167
+ detailAction?: boolean;
162
168
  onRowClick?: (record: T, index: number, event: any) => void;
163
169
  onCellClick?: DataTableCellClickHandler<T>;
164
170
  modelType?: ModelType;
@@ -1,4 +1,4 @@
1
- import { Progress, Stack, Text } from '@mantine/core';
1
+ import { Group, Progress, Stack, Text } from '@mantine/core';
2
2
  import { useMemo } from 'react';
3
3
  import { formatDecimal } from '../functions/Formatting';
4
4
 
@@ -9,6 +9,7 @@ export type ProgressBarProps = {
9
9
  progressLabel?: boolean;
10
10
  animated?: boolean;
11
11
  size?: string;
12
+ units?: string;
12
13
  };
13
14
 
14
15
  /**
@@ -30,9 +31,12 @@ export function ProgressBar(props: Readonly<ProgressBarProps>) {
30
31
  return (
31
32
  <Stack gap={2} style={{ flexGrow: 1, minWidth: '100px' }}>
32
33
  {props.progressLabel && (
33
- <Text ta='center' size='xs'>
34
- {formatDecimal(props.value)} / {formatDecimal(props.maximum)}
35
- </Text>
34
+ <Group gap='xs' justify='center'>
35
+ <Text ta='center' size='xs'>
36
+ {formatDecimal(props.value)} / {formatDecimal(props.maximum)}
37
+ </Text>
38
+ {props.units && <Text size='xs'>[{props.units}]</Text>}
39
+ </Group>
36
40
  )}
37
41
  <Progress
38
42
  value={progress}
@@ -20,6 +20,7 @@ export enum ApiEndpoints {
20
20
  user_simple_login = 'email/generate/',
21
21
 
22
22
  // User auth endpoints
23
+ auth_base = '/auth/',
23
24
  user_reset = 'auth/v1/auth/password/request',
24
25
  user_reset_set = 'auth/v1/auth/password/reset',
25
26
  auth_pwd_change = 'auth/v1/account/password/change',
@@ -32,6 +33,8 @@ export enum ApiEndpoints {
32
33
  auth_mfa_reauthenticate = 'auth/v1/auth/2fa/reauthenticate',
33
34
  auth_totp = 'auth/v1/account/authenticators/totp',
34
35
  auth_trust = 'auth/v1/auth/2fa/trust',
36
+ auth_webauthn = 'auth/v1/account/authenticators/webauthn',
37
+ auth_webauthn_login = 'auth/v1/auth/webauthn/authenticate',
35
38
  auth_reauthenticate = 'auth/v1/auth/reauthenticate',
36
39
  auth_email = 'auth/v1/account/email',
37
40
  auth_email_verify = 'auth/v1/auth/email/verify',
@@ -109,8 +112,6 @@ export enum ApiEndpoints {
109
112
 
110
113
  // Part API endpoints
111
114
  part_list = 'part/',
112
- part_parameter_list = 'part/parameter/',
113
- part_parameter_template_list = 'part/parameter/template/',
114
115
  part_thumbs_list = 'part/thumbs/',
115
116
  part_pricing = 'part/:id/pricing/',
116
117
  part_requirements = 'part/:id/requirements/',
@@ -119,6 +120,7 @@ export enum ApiEndpoints {
119
120
  part_pricing_internal = 'part/internal-price/',
120
121
  part_pricing_sale = 'part/sale-price/',
121
122
  part_stocktake_list = 'part/stocktake/',
123
+ part_stocktake_generate = 'part/stocktake/generate/',
122
124
  category_list = 'part/category/',
123
125
  category_tree = 'part/category/tree/',
124
126
  category_parameter_list = 'part/category/parameters/',
@@ -132,7 +134,6 @@ export enum ApiEndpoints {
132
134
  supplier_part_list = 'company/part/',
133
135
  supplier_part_pricing_list = 'company/price-break/',
134
136
  manufacturer_part_list = 'company/part/manufacturer/',
135
- manufacturer_part_parameter_list = 'company/part/manufacturer/parameter/',
136
137
 
137
138
  // Stock location endpoints
138
139
  stock_location_list = 'stock/location/',
@@ -220,6 +221,9 @@ export enum ApiEndpoints {
220
221
 
221
222
  // Special plugin endpoints
222
223
  plugin_locate_item = 'locate/',
224
+ plugin_supplier_list = 'supplier/list/',
225
+ plugin_supplier_search = 'supplier/search/',
226
+ plugin_supplier_import = 'supplier/import/',
223
227
 
224
228
  // Machine API endpoints
225
229
  machine_types_list = 'machine/types/',
@@ -238,5 +242,10 @@ export enum ApiEndpoints {
238
242
  notes_image_upload = 'notes-image-upload/',
239
243
  email_list = 'admin/email/',
240
244
  email_test = 'admin/email/test/',
241
- config_list = 'admin/config/'
245
+ config_list = 'admin/config/',
246
+ parameter_list = 'parameter/',
247
+ parameter_template_list = 'parameter/template/',
248
+
249
+ // Internal system things
250
+ system_internal_trace_end = 'system-internal/observability/end'
242
251
  }
@@ -10,6 +10,7 @@ export interface ModelInformationInterface {
10
10
  url_detail?: string;
11
11
  api_endpoint: ApiEndpoints;
12
12
  admin_url?: string;
13
+ supports_barcode?: boolean;
13
14
  icon: keyof InvenTreeIconType;
14
15
  }
15
16
 
@@ -31,15 +32,21 @@ export const ModelInformationDict: ModelDict = {
31
32
  url_detail: '/part/:pk/',
32
33
  api_endpoint: ApiEndpoints.part_list,
33
34
  admin_url: '/part/part/',
35
+ supports_barcode: true,
34
36
  icon: 'part'
35
37
  },
36
- partparametertemplate: {
37
- label: () => t`Part Parameter Template`,
38
- label_multiple: () => t`Part Parameter Templates`,
39
- url_overview: '/settings/admin/part-parameters',
40
- url_detail: '/partparametertemplate/:pk/',
41
- api_endpoint: ApiEndpoints.part_parameter_template_list,
42
- icon: 'test_templates'
38
+ parameter: {
39
+ label: () => t`Parameter`,
40
+ label_multiple: () => t`Parameters`,
41
+ api_endpoint: ApiEndpoints.parameter_list,
42
+ icon: 'list_details'
43
+ },
44
+ parametertemplate: {
45
+ label: () => t`Parameter Template`,
46
+ label_multiple: () => t`Parameter Templates`,
47
+ api_endpoint: ApiEndpoints.parameter_template_list,
48
+ admin_url: '/common/parametertemplate/',
49
+ icon: 'list'
43
50
  },
44
51
  parttesttemplate: {
45
52
  label: () => t`Part Test Template`,
@@ -55,6 +62,7 @@ export const ModelInformationDict: ModelDict = {
55
62
  url_detail: '/purchasing/supplier-part/:pk/',
56
63
  api_endpoint: ApiEndpoints.supplier_part_list,
57
64
  admin_url: '/company/supplierpart/',
65
+ supports_barcode: true,
58
66
  icon: 'supplier_part'
59
67
  },
60
68
  manufacturerpart: {
@@ -64,6 +72,7 @@ export const ModelInformationDict: ModelDict = {
64
72
  url_detail: '/purchasing/manufacturer-part/:pk/',
65
73
  api_endpoint: ApiEndpoints.manufacturer_part_list,
66
74
  admin_url: '/company/manufacturerpart/',
75
+ supports_barcode: true,
67
76
  icon: 'manufacturers'
68
77
  },
69
78
  partcategory: {
@@ -82,6 +91,7 @@ export const ModelInformationDict: ModelDict = {
82
91
  url_detail: '/stock/item/:pk/',
83
92
  api_endpoint: ApiEndpoints.stock_item_list,
84
93
  admin_url: '/stock/stockitem/',
94
+ supports_barcode: true,
85
95
  icon: 'stock'
86
96
  },
87
97
  stocklocation: {
@@ -91,6 +101,7 @@ export const ModelInformationDict: ModelDict = {
91
101
  url_detail: '/stock/location/:pk/',
92
102
  api_endpoint: ApiEndpoints.stock_location_list,
93
103
  admin_url: '/stock/stocklocation/',
104
+ supports_barcode: true,
94
105
  icon: 'location'
95
106
  },
96
107
  stocklocationtype: {
@@ -112,6 +123,7 @@ export const ModelInformationDict: ModelDict = {
112
123
  url_detail: '/manufacturing/build-order/:pk/',
113
124
  api_endpoint: ApiEndpoints.build_order_list,
114
125
  admin_url: '/build/build/',
126
+ supports_barcode: true,
115
127
  icon: 'build_order'
116
128
  },
117
129
  buildline: {
@@ -150,6 +162,7 @@ export const ModelInformationDict: ModelDict = {
150
162
  url_detail: '/purchasing/purchase-order/:pk/',
151
163
  api_endpoint: ApiEndpoints.purchase_order_list,
152
164
  admin_url: '/order/purchaseorder/',
165
+ supports_barcode: true,
153
166
  icon: 'purchase_orders'
154
167
  },
155
168
  purchaseorderlineitem: {
@@ -165,14 +178,17 @@ export const ModelInformationDict: ModelDict = {
165
178
  url_detail: '/sales/sales-order/:pk/',
166
179
  api_endpoint: ApiEndpoints.sales_order_list,
167
180
  admin_url: '/order/salesorder/',
181
+ supports_barcode: true,
168
182
  icon: 'sales_orders'
169
183
  },
170
184
  salesordershipment: {
171
185
  label: () => t`Sales Order Shipment`,
172
186
  label_multiple: () => t`Sales Order Shipments`,
187
+ url_overview: '/sales/index/shipments',
173
188
  url_detail: '/sales/shipment/:pk/',
174
189
  api_endpoint: ApiEndpoints.sales_order_shipment_list,
175
- icon: 'sales_orders'
190
+ supports_barcode: true,
191
+ icon: 'shipment'
176
192
  },
177
193
  returnorder: {
178
194
  label: () => t`Return Order`,
@@ -181,6 +197,7 @@ export const ModelInformationDict: ModelDict = {
181
197
  url_detail: '/sales/return-order/:pk/',
182
198
  api_endpoint: ApiEndpoints.return_order_list,
183
199
  admin_url: '/order/returnorder/',
200
+ supports_barcode: true,
184
201
  icon: 'return_orders'
185
202
  },
186
203
  returnorderlineitem: {
@@ -6,7 +6,6 @@ export enum ModelType {
6
6
  supplierpart = 'supplierpart',
7
7
  manufacturerpart = 'manufacturerpart',
8
8
  partcategory = 'partcategory',
9
- partparametertemplate = 'partparametertemplate',
10
9
  parttesttemplate = 'parttesttemplate',
11
10
  projectcode = 'projectcode',
12
11
  stockitem = 'stockitem',
@@ -17,6 +16,8 @@ export enum ModelType {
17
16
  buildline = 'buildline',
18
17
  builditem = 'builditem',
19
18
  company = 'company',
19
+ parameter = 'parameter',
20
+ parametertemplate = 'parametertemplate',
20
21
  purchaseorder = 'purchaseorder',
21
22
  purchaseorderlineitem = 'purchaseorderlineitem',
22
23
  salesorder = 'salesorder',
@@ -29,6 +29,11 @@ export function isTrue(value: any): boolean {
29
29
  * Allows for retrieval of nested items in an object.
30
30
  */
31
31
  export function resolveItem(obj: any, path: string): any {
32
+ // Return the top-level object if no path is provided
33
+ if (path == null || path === '') {
34
+ return obj;
35
+ }
36
+
32
37
  const properties = path.split('.');
33
38
  return properties.reduce((prev, curr) => prev?.[curr], obj);
34
39
  }
@@ -40,3 +45,36 @@ export function identifierString(value: string): string {
40
45
 
41
46
  return value.toLowerCase().replace(/[^a-z0-9]/g, '-');
42
47
  }
48
+
49
+ export function toNumber(
50
+ value: any,
51
+ defaultValue: number | null = 0
52
+ ): number | null {
53
+ // Convert the provided value into a number (if possible)
54
+
55
+ if (value == undefined || value == null || value === '') {
56
+ return defaultValue;
57
+ }
58
+
59
+ // Case 1: numeric already
60
+ if (typeof value === 'number') return value;
61
+
62
+ // Case 2: react-number-format object
63
+ if (typeof value === 'object') {
64
+ if ('floatValue' in value && typeof value.floatValue === 'number') {
65
+ return value.floatValue;
66
+ }
67
+ if ('value' in value) {
68
+ const parsed = Number(value.value);
69
+ return Number.isNaN(parsed) ? Number.NaN : parsed;
70
+ }
71
+ }
72
+
73
+ // Case 3: string
74
+ if (typeof value === 'string') {
75
+ const parsed = Number(value);
76
+ return Number.isNaN(parsed) ? Number.NaN : parsed;
77
+ }
78
+
79
+ return Number.NaN;
80
+ }
@@ -7,6 +7,28 @@ import { cancelEvent } from './Events';
7
7
  export const getBaseUrl = (): string =>
8
8
  (window as any).INVENTREE_SETTINGS?.base_url || 'web';
9
9
 
10
+ /**
11
+ * Returns the overview URL for a given model type.
12
+ * This is the UI URL, not the API URL.
13
+ */
14
+ export function getOverviewUrl(model: ModelType, absolute?: boolean): string {
15
+ const modelInfo = ModelInformationDict[model];
16
+
17
+ if (modelInfo?.url_overview) {
18
+ const url = modelInfo.url_overview;
19
+ const base = getBaseUrl();
20
+
21
+ if (absolute && base) {
22
+ return `/${base}${url}`;
23
+ } else {
24
+ return url;
25
+ }
26
+ }
27
+
28
+ console.error(`No overview URL found for model ${model}`);
29
+ return '';
30
+ }
31
+
10
32
  /**
11
33
  * Returns the detail view URL for a given model type.
12
34
  * This is the UI URL, not the API URL.
@@ -0,0 +1,122 @@
1
+ import { t } from '@lingui/core/macro';
2
+ import { useDocumentVisibility } from '@mantine/hooks';
3
+ import { notifications, showNotification } from '@mantine/notifications';
4
+ import { IconCircleCheck, IconExclamationCircle } from '@tabler/icons-react';
5
+ import { useQuery } from '@tanstack/react-query';
6
+ import type { AxiosInstance } from 'axios';
7
+ import { useEffect, useState } from 'react';
8
+ import { ProgressBar } from '../components/ProgressBar';
9
+ import { ApiEndpoints } from '../enums/ApiEndpoints';
10
+ import { apiUrl } from '../functions/Api';
11
+
12
+ /**
13
+ * Hook for monitoring a data output process running on the server
14
+ */
15
+ export default function monitorDataOutput({
16
+ api,
17
+ title,
18
+ hostname,
19
+ id
20
+ }: {
21
+ api: AxiosInstance;
22
+ title: string;
23
+ hostname?: string;
24
+ id?: number;
25
+ }) {
26
+ const visibility = useDocumentVisibility();
27
+
28
+ const [loading, setLoading] = useState<boolean>(false);
29
+
30
+ useEffect(() => {
31
+ if (!!id) {
32
+ setLoading(true);
33
+ showNotification({
34
+ id: `data-output-${id}`,
35
+ title: title,
36
+ loading: true,
37
+ autoClose: false,
38
+ withCloseButton: false,
39
+ message: <ProgressBar size='lg' value={0} progressLabel />
40
+ });
41
+ } else setLoading(false);
42
+ }, [id, title]);
43
+
44
+ useQuery({
45
+ enabled: !!id && loading && visibility === 'visible',
46
+ refetchInterval: 500,
47
+ queryKey: ['data-output', id, title],
48
+ queryFn: () =>
49
+ api
50
+ .get(apiUrl(ApiEndpoints.data_output, id))
51
+ .then((response) => {
52
+ const data = response?.data ?? {};
53
+
54
+ if (!!data.errors || !!data.error) {
55
+ setLoading(false);
56
+
57
+ const error: string =
58
+ data?.error ?? data?.errors?.error ?? t`Process failed`;
59
+
60
+ notifications.update({
61
+ id: `data-output-${id}`,
62
+ loading: false,
63
+ icon: <IconExclamationCircle />,
64
+ autoClose: 2500,
65
+ title: title,
66
+ message: error,
67
+ color: 'red'
68
+ });
69
+ } else if (data.complete) {
70
+ setLoading(false);
71
+ notifications.update({
72
+ id: `data-output-${id}`,
73
+ loading: false,
74
+ autoClose: 2500,
75
+ title: title,
76
+ message: t`Process completed successfully`,
77
+ color: 'green',
78
+ icon: <IconCircleCheck />
79
+ });
80
+
81
+ if (data.output) {
82
+ const url = data.output;
83
+ const base = hostname ?? window.location.hostname;
84
+
85
+ const downloadUrl = new URL(url, base);
86
+
87
+ window.open(downloadUrl.toString(), '_blank');
88
+ }
89
+ } else {
90
+ notifications.update({
91
+ id: `data-output-${id}`,
92
+ loading: true,
93
+ autoClose: false,
94
+ withCloseButton: false,
95
+ message: (
96
+ <ProgressBar
97
+ size='lg'
98
+ maximum={data.total}
99
+ value={data.progress}
100
+ progressLabel={data.total > 0}
101
+ animated
102
+ />
103
+ )
104
+ });
105
+ }
106
+
107
+ return data;
108
+ })
109
+ .catch(() => {
110
+ setLoading(false);
111
+ notifications.update({
112
+ id: `data-output-${id}`,
113
+ loading: false,
114
+ autoClose: 2500,
115
+ title: title,
116
+ message: t`Process failed`,
117
+ color: 'red'
118
+ });
119
+ return {};
120
+ })
121
+ });
122
+ }
package/lib/index.ts CHANGED
@@ -12,7 +12,12 @@ export { ModelType } from './enums/ModelType';
12
12
  export type { ModelDict } from './enums/ModelInformation';
13
13
  export { UserRoles, UserPermissions } from './enums/Roles';
14
14
 
15
- export type { InvenTreePluginContext } from './types/Plugins';
15
+ export type {
16
+ InvenTreePluginContext,
17
+ InvenTreeFormsContext,
18
+ PluginVersion,
19
+ StockAdjustmentFormsContext
20
+ } from './types/Plugins';
16
21
  export type { RowAction, RowViewProps } from './types/Tables';
17
22
 
18
23
  export type {
@@ -25,6 +30,11 @@ export type {
25
30
  BulkEditApiFormModalProps
26
31
  } from './types/Forms';
27
32
 
33
+ export type {
34
+ UseModalProps,
35
+ UseModalReturn
36
+ } from './types/Modals';
37
+
28
38
  // Common utility functions
29
39
  export { apiUrl } from './functions/Api';
30
40
  export {
@@ -61,3 +71,6 @@ export {
61
71
  RowCancelAction,
62
72
  RowActions
63
73
  } from './components/RowActions';
74
+
75
+ // Shared hooks
76
+ export { default as monitorDataOutput } from './hooks/MonitorDataOutput';