@inventreedb/ui 0.11.1 → 0.11.3

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 (55) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/.vite/manifest.json +86 -0
  3. package/dist/components/Boundary.js +16 -7
  4. package/dist/components/Boundary.js.map +1 -1
  5. package/dist/components/StylishText.d.ts +6 -0
  6. package/dist/components/StylishText.js +36 -0
  7. package/dist/components/StylishText.js.map +1 -0
  8. package/dist/components/nav/DetailDrawer.css.d.ts +1 -0
  9. package/dist/components/nav/DetailDrawer.css.js +6 -0
  10. package/dist/components/nav/DetailDrawer.css.js.map +1 -0
  11. package/dist/components/nav/DetailDrawer.d.ts +21 -0
  12. package/dist/components/nav/DetailDrawer.js +65 -0
  13. package/dist/components/nav/DetailDrawer.js.map +1 -0
  14. package/dist/enums/ApiEndpoints.d.ts +1 -0
  15. package/dist/enums/ApiEndpoints.js +1 -0
  16. package/dist/enums/ApiEndpoints.js.map +1 -1
  17. package/dist/enums/ModelType.d.ts +9 -0
  18. package/dist/enums/ModelType.js.map +1 -1
  19. package/dist/enums/Roles.d.ts +1 -0
  20. package/dist/enums/Roles.js +1 -0
  21. package/dist/enums/Roles.js.map +1 -1
  22. package/dist/index.d.ts +4 -1
  23. package/dist/index.js +5 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/node_modules/@remix-run/router/dist/router.js +448 -0
  26. package/dist/node_modules/@remix-run/router/dist/router.js.map +1 -0
  27. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +8 -0
  28. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js.map +1 -0
  29. package/dist/node_modules/react-router/dist/index.js +704 -0
  30. package/dist/node_modules/react-router/dist/index.js.map +1 -0
  31. package/dist/node_modules/react-router-dom/dist/index.js +526 -0
  32. package/dist/node_modules/react-router-dom/dist/index.js.map +1 -0
  33. package/dist/node_modules/zustand/esm/react/shallow.js +13 -0
  34. package/dist/node_modules/zustand/esm/react/shallow.js.map +1 -0
  35. package/dist/node_modules/zustand/esm/vanilla/shallow.js +57 -0
  36. package/dist/node_modules/zustand/esm/vanilla/shallow.js.map +1 -0
  37. package/dist/states/LocalLibState.d.ts +17 -0
  38. package/dist/states/LocalLibState.js +16 -0
  39. package/dist/states/LocalLibState.js.map +1 -0
  40. package/dist/types/Forms.d.ts +11 -6
  41. package/dist/types/Plugins.js +1 -1
  42. package/dist/types/Tables.d.ts +6 -0
  43. package/dist/ui.css +4 -0
  44. package/lib/components/Boundary.tsx +6 -3
  45. package/lib/components/StylishText.tsx +46 -0
  46. package/lib/components/nav/DetailDrawer.css.ts +6 -0
  47. package/lib/components/nav/DetailDrawer.tsx +108 -0
  48. package/lib/enums/ApiEndpoints.tsx +1 -0
  49. package/lib/enums/ModelType.tsx +13 -0
  50. package/lib/enums/Roles.tsx +1 -0
  51. package/lib/index.ts +15 -0
  52. package/lib/states/LocalLibState.tsx +23 -0
  53. package/lib/types/Forms.tsx +11 -6
  54. package/lib/types/Tables.tsx +8 -0
  55. package/package.json +4 -2
package/lib/index.ts CHANGED
@@ -26,10 +26,18 @@ export type {
26
26
  RowViewProps,
27
27
  TableColumn,
28
28
  TableColumnProps,
29
+ TableState,
29
30
  InvenTreeTableProps,
30
31
  InvenTreeTableRenderProps
31
32
  } from './types/Tables';
32
33
 
34
+ export type {
35
+ TableFilterChoice,
36
+ TableFilterType,
37
+ TableFilter,
38
+ FilterSetState
39
+ } from './types/Filters';
40
+
33
41
  export type {
34
42
  ApiFormFieldChoice,
35
43
  ApiFormFieldHeader,
@@ -124,6 +132,13 @@ export {
124
132
  type TableStateExtraProps
125
133
  } from './hooks/UseTable';
126
134
 
135
+ export {
136
+ type DrawerProps,
137
+ DetailDrawer,
138
+ DetailDrawerLink
139
+ } from './components/nav/DetailDrawer';
140
+ export { StylishText } from './components/StylishText';
141
+
127
142
  // State management
128
143
  export {
129
144
  type StoredTableStateProps,
@@ -0,0 +1,23 @@
1
+ import { create } from 'zustand';
2
+ import { persist } from 'zustand/middleware';
3
+
4
+ export const useLocalLibState = create<LocalLibStateProps>()(
5
+ persist(
6
+ (set, get) => ({
7
+ detailDrawerStack: 0,
8
+ addDetailDrawer: (value) => {
9
+ set({
10
+ detailDrawerStack:
11
+ value === false ? 0 : get().detailDrawerStack + value
12
+ });
13
+ }
14
+ }),
15
+ {
16
+ name: 'session-settings-inventreedb_lib'
17
+ }
18
+ )
19
+ );
20
+ export interface LocalLibStateProps {
21
+ detailDrawerStack: number;
22
+ addDetailDrawer: (value: number | false) => void;
23
+ }
@@ -37,7 +37,6 @@ export type ApiFormFieldHeader = {
37
37
  * - All other attributes are optional, and may be provided by the API
38
38
  * - However, they can be overridden by the user
39
39
  *
40
- * @param name : The name of the field
41
40
  * @param label : The label to display for the field
42
41
  * @param value : The value of the field
43
42
  * @param default : The default value of the field
@@ -46,16 +45,21 @@ export type ApiFormFieldHeader = {
46
45
  * @param api_url : The API endpoint to fetch data from (for related fields)
47
46
  * @param pk_field : The primary key field for the related field (default = "pk")
48
47
  * @param model : The model to use for related fields
48
+ * @param modelRenderer : Optional function to render the related model instance (for related fields)
49
49
  * @param filters : Optional API filters to apply to related fields
50
+ * @param child: Optional definition of a child field (for nested objects)
51
+ * @param children: Optional definitions of child fields (for nested objects with multiple fields)
50
52
  * @param required : Whether the field is required
51
- * @param allow_null: Whether the field allows null values
52
- * @param allow_blank: Whether the field allows blank values
53
+ * @param error : Optional error message to display
53
54
  * @param hidden : Whether the field is hidden
54
55
  * @param disabled : Whether the field is disabled
55
- * @param error : Optional error message to display
56
+ * @param allow_null: Whether the field allows null values
57
+ * @param allow_blank: Whether the field allows blank values
56
58
  * @param exclude : Whether to exclude the field from the submitted data
59
+ * @param read_only : Whether the field is read-only
57
60
  * @param placeholder : The placeholder text to display
58
61
  * @param placeholderAutofill: Whether to allow auto-filling of the placeholder value
62
+ * @param addCreateFields : Fields to display when creating a new related object (for related fields)
59
63
  * @param description : The description to display for the field
60
64
  * @param preFieldContent : Content to render before the field
61
65
  * @param postFieldContent : Content to render after the field
@@ -63,11 +67,11 @@ export type ApiFormFieldHeader = {
63
67
  * @param rightSection : Content to render in the right section of the field
64
68
  * @param autoFill: Whether to automatically fill the field with data from the API
65
69
  * @param autoFillFilters: Optional filters to apply when auto-filling the field
70
+ * @param adjustValue : Callback function to adjust the value of the field before it is sent to the API
66
71
  * @param onValueChange : Callback function to call when the field value changes
67
72
  * @param adjustFilters : Callback function to adjust the filters for a related field before a query is made
68
- * @param adjustValue : Callback function to adjust the value of the field before it is sent to the API
69
73
  * @param addRow : Callback function to add a new row to a table field
70
- * @param onKeyDown : Callback function to get which key was pressed in the form to handle submission on enter
74
+ * @param headers : Optional definitions of table headers (for table fields)
71
75
  * @param singleFetchFunction : Optional function to fetch a single value for this field (used for fetching the initial value when editing an existing object)
72
76
  */
73
77
  export type ApiFormFieldType = {
@@ -114,6 +118,7 @@ export type ApiFormFieldType = {
114
118
  placeholderAutofill?: boolean;
115
119
  placeholderWarningCompare?: string | number;
116
120
  placeholderWarning?: string;
121
+ addCreateFields?: ApiFormFieldSet;
117
122
  description?: string;
118
123
  preFieldContent?: JSX.Element;
119
124
  postFieldContent?: JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import type { MantineStyleProp } from '@mantine/core';
2
2
  import type { AxiosInstance } from 'axios';
3
+ import type { ShowContextMenuFunction } from 'mantine-contextmenu';
3
4
  import type {
4
5
  DataTableCellClickHandler,
5
6
  DataTableRowExpansionProps
@@ -178,6 +179,7 @@ export type RowViewProps = RowAction & RowModelProps;
178
179
  * @param onRowClick : (record: any, index: number, event: any) => void - Callback function when a row is clicked
179
180
  * @param onCellClick : (event: any, record: any, index: number, column: any, columnIndex: number) => void - Callback function when a cell is clicked
180
181
  * @param modelType: ModelType - The model type for the table
182
+ * @param height: string | number - Height of the table (default = 'auto')
181
183
  * @param minHeight: number - Minimum height of the table (default 300px)
182
184
  * @param noHeader: boolean - Hide the table header
183
185
  */
@@ -211,6 +213,7 @@ export type InvenTreeTableProps<T = any> = {
211
213
  rowStyle?: (record: T, index: number) => MantineStyleProp | undefined;
212
214
  modelField?: string;
213
215
  onCellContextMenu?: (record: T, event: any) => void;
216
+ height?: string | number;
214
217
  minHeight?: number;
215
218
  noHeader?: boolean;
216
219
  };
@@ -223,4 +226,9 @@ export type InvenTreeTableRenderProps<T extends Record<string, any>> = {
223
226
  props: InvenTreeTableProps<T>;
224
227
  api: AxiosInstance;
225
228
  navigate: NavigateFunction;
229
+
230
+ // The following attributes are for internal use only (plugins should not use these directly)
231
+ showContextMenu?: ShowContextMenuFunction;
232
+ searchParams?: URLSearchParams;
233
+ setSearchParams?: (params: URLSearchParams) => void;
226
234
  };
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.11.1",
4
+ "version": "0.11.3",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -102,6 +102,7 @@
102
102
  "react-window": "1.8.11",
103
103
  "recharts": "^3.1.2",
104
104
  "styled-components": "^6.1.14",
105
+ "undici": "^6.24.0",
105
106
  "zustand": "^5.0.8"
106
107
  },
107
108
  "devDependencies": {
@@ -137,6 +138,7 @@
137
138
  "vite-plugin-istanbul": "^8.0.0"
138
139
  },
139
140
  "resolutions": {
140
- "undici": "^6.24.0"
141
+ "undici": "^6.24.0",
142
+ "vite": "^8.0.5"
141
143
  }
142
144
  }