@firecms/core 3.0.0-canary.37 → 3.0.0-canary.39

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.
@@ -94,6 +94,10 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
94
94
  * `subcollection:`. e.g. `subcollection:orders`.
95
95
  * - If you are using a collection group, you will also have an
96
96
  * additional `collectionGroupParent` column.
97
+ * You can use this prop to hide some properties from the table view.
98
+ * Note that if you set this prop, other ways to hide fields, like
99
+ * `hidden` in the property definition,will be ignored.
100
+ * `propertiesOrder` has precedence over `hidden`.
97
101
  */
98
102
  propertiesOrder?: Extract<keyof M, string>[];
99
103
  /**
@@ -445,7 +449,7 @@ export type EntityTableController<M extends Record<string, any> = any> = {
445
449
  filterValues?: FilterValues<Extract<keyof M, string>>;
446
450
  setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string>>) => void;
447
451
  sortBy?: [Extract<keyof M, string>, "asc" | "desc"];
448
- setSortBy?: (sortBy: [Extract<keyof M, string>, "asc" | "desc"]) => void;
452
+ setSortBy?: (sortBy?: [Extract<keyof M, string>, "asc" | "desc"]) => void;
449
453
  searchString?: string;
450
454
  setSearchString?: (searchString?: string) => void;
451
455
  clearFilter?: () => void;
@@ -11,7 +11,7 @@ import { ResolvedProperty } from "./resolved_entities";
11
11
  * NOTE: This is a work in progress and the API is not stable yet.
12
12
  * @group Core
13
13
  */
14
- export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any> = {
14
+ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any, COL_ACTIONS_START__PROPS = any> = {
15
15
  /**
16
16
  * Key of the plugin. This is used to identify the plugin in the CMS.
17
17
  */
@@ -78,6 +78,8 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
78
78
  */
79
79
  CollectionActions?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS>[];
80
80
  collectionActionsProps?: COL_ACTIONS_PROPS;
81
+ CollectionActionsStart?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS>[];
82
+ collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
81
83
  showTextSearchBar?: (props: {
82
84
  context: FireCMSContext;
83
85
  path: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.37",
4
+ "version": "3.0.0-canary.39",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -46,9 +46,9 @@
46
46
  "./package.json": "./package.json"
47
47
  },
48
48
  "dependencies": {
49
- "@firecms/formex": "^3.0.0-canary.37",
50
- "@firecms/ui": "^3.0.0-canary.37",
51
- "@fontsource/ibm-plex-mono": "^5.0.12",
49
+ "@firecms/formex": "^3.0.0-canary.39",
50
+ "@firecms/ui": "^3.0.0-canary.39",
51
+ "@fontsource/jetbrains-mono": "^5.0.19",
52
52
  "@fontsource/roboto": "^5.0.12",
53
53
  "@hello-pangea/dnd": "^16.5.0",
54
54
  "date-fns": "^3.6.0",
@@ -115,7 +115,7 @@
115
115
  "dist",
116
116
  "src"
117
117
  ],
118
- "gitHead": "241b56d35ecc9c8155a2ea0d387974a41a231bb7",
118
+ "gitHead": "8ed816e32d8f66d2bf0dffcbfceb569b48a3cc0d",
119
119
  "publishConfig": {
120
120
  "access": "public"
121
121
  }
@@ -0,0 +1,41 @@
1
+ import { Button, FilterListOffIcon } from "@firecms/ui";
2
+ import { EntityTableController } from "../types";
3
+
4
+ export function ClearFilterSortButton({
5
+ tableController,
6
+ enabled
7
+ }: {
8
+ enabled: boolean;
9
+ tableController: EntityTableController
10
+ }) {
11
+ if (!enabled) {
12
+ return null;
13
+ }
14
+
15
+ const filterIsSet = !!tableController.filterValues && Object.keys(tableController.filterValues).length > 0;
16
+ const sortIsSet = !!tableController.sortBy && tableController.sortBy.length > 0;
17
+
18
+ if ((filterIsSet || sortIsSet) && (tableController.clearFilter || tableController.setSortBy)) {
19
+ let label;
20
+ if (filterIsSet && sortIsSet) {
21
+ label = "Clear filter and sort";
22
+ } else if (filterIsSet) {
23
+ label = "Clear filter";
24
+ } else {
25
+ label = "Clear sort";
26
+ }
27
+ return <Button
28
+ variant={"outlined"}
29
+ className="h-fit-content"
30
+ aria-label="filter clear"
31
+ onClick={() => {
32
+ tableController.clearFilter?.();
33
+ tableController.setSortBy?.(undefined);
34
+ }}
35
+ size={"small"}>
36
+ <FilterListOffIcon/>
37
+ {label}
38
+ </Button>
39
+ }
40
+ return null;
41
+ }
@@ -88,8 +88,6 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
88
88
 
89
89
  const selectedEntityIds = selectedEntities?.map(e => e.id);
90
90
 
91
- const filterIsSet = !!tableController.filterValues && Object.keys(tableController.filterValues).length > 0;
92
-
93
91
  const updateSize = useCallback((size: CollectionSize) => {
94
92
  if (onSizeChanged)
95
93
  onSizeChanged(size);
@@ -291,12 +289,9 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
291
289
  className="h-full w-full flex flex-col bg-white dark:bg-gray-950">
292
290
 
293
291
  <CollectionTableToolbar
294
- forceFilter={disabledFilterChange}
295
- filterIsSet={filterIsSet}
296
292
  onTextSearch={textSearchEnabled ? onTextSearch : undefined}
297
293
  textSearchLoading={textSearchLoading}
298
294
  onTextSearchClick={textSearchEnabled ? onTextSearchClick : undefined}
299
- clearFilter={tableController.clearFilter}
300
295
  size={size}
301
296
  onSizeChanged={updateSize}
302
297
  title={title}
@@ -16,20 +16,27 @@ import { useLargeLayout } from "../../../hooks";
16
16
 
17
17
  interface CollectionTableToolbarProps {
18
18
  size: CollectionSize;
19
- filterIsSet: boolean;
20
19
  loading: boolean;
21
- forceFilter?: boolean;
22
20
  actionsStart?: React.ReactNode;
23
21
  actions?: React.ReactNode;
24
22
  title?: React.ReactNode,
25
23
  onTextSearchClick?: () => void;
26
24
  onTextSearch?: (searchString?: string) => void;
27
25
  onSizeChanged: (size: CollectionSize) => void;
28
- clearFilter?: () => void;
29
26
  textSearchLoading?: boolean;
30
27
  }
31
28
 
32
- export function CollectionTableToolbar(props: CollectionTableToolbarProps) {
29
+ export function CollectionTableToolbar({
30
+ actions,
31
+ actionsStart,
32
+ loading,
33
+ onSizeChanged,
34
+ onTextSearch,
35
+ onTextSearchClick,
36
+ size,
37
+ textSearchLoading,
38
+ title
39
+ }: CollectionTableToolbarProps) {
33
40
 
34
41
  const searchInputRef = React.useRef<HTMLInputElement>(null);
35
42
  const largeLayout = useLargeLayout();
@@ -37,30 +44,20 @@ export function CollectionTableToolbar(props: CollectionTableToolbarProps) {
37
44
  const searchLoading = React.useRef<boolean>(false);
38
45
 
39
46
  useEffect(() => {
40
- if (searchInputRef.current && searchLoading.current && !props.textSearchLoading) {
47
+ if (searchInputRef.current && searchLoading.current && !textSearchLoading) {
41
48
  searchInputRef.current.focus();
42
49
  }
43
- searchLoading.current = props.textSearchLoading ?? false;
44
- }, [props.textSearchLoading]);
45
-
46
- const clearFilterButton = !props.forceFilter && props.filterIsSet && props.clearFilter &&
47
- <Button
48
- variant={"outlined"}
49
- className="h-fit-content"
50
- aria-label="filter clear"
51
- onClick={props.clearFilter}
52
- size={"small"}>
53
- <FilterListOffIcon/>
54
- Clear filter
55
- </Button>;
50
+ searchLoading.current = textSearchLoading ?? false;
51
+ }, [textSearchLoading]);
52
+
56
53
 
57
54
  const sizeSelect = (
58
55
  <Tooltip title={"Table row size"} side={"right"} sideOffset={4}>
59
56
  <Select
60
- value={props.size as string}
57
+ value={size as string}
61
58
  className="w-16 h-10"
62
59
  size={"small"}
63
- onValueChange={(v) => props.onSizeChanged(v as CollectionSize)}
60
+ onValueChange={(v) => onSizeChanged(v as CollectionSize)}
64
61
  renderValue={(v) => <div className={"font-medium"}>{v.toUpperCase()}</div>}
65
62
  >
66
63
  {["xs", "s", "m", "l", "xl"].map((size) => (
@@ -78,36 +75,34 @@ export function CollectionTableToolbar(props: CollectionTableToolbarProps) {
78
75
 
79
76
  <div className="flex items-center gap-2 md:mr-4 mr-2">
80
77
 
81
- {props.title && <div className={"hidden lg:block"}>
82
- {props.title}
78
+ {title && <div className={"hidden lg:block"}>
79
+ {title}
83
80
  </div>}
84
81
 
85
82
  {sizeSelect}
86
83
 
87
- {props.actionsStart}
88
-
89
- {clearFilterButton}
84
+ {actionsStart}
90
85
 
91
86
  </div>
92
87
 
93
88
  <div className="flex items-center gap-2">
94
89
 
95
90
  {largeLayout && <div className="w-[22px]">
96
- {props.loading &&
91
+ {loading &&
97
92
  <CircularProgress size={"small"}/>}
98
93
  </div>}
99
94
 
100
- {(props.onTextSearch || props.onTextSearchClick) &&
95
+ {(onTextSearch || onTextSearchClick) &&
101
96
  <SearchBar
102
97
  key={"search-bar"}
103
98
  inputRef={searchInputRef}
104
- loading={props.textSearchLoading}
105
- disabled={Boolean(props.onTextSearchClick)}
106
- onClick={props.onTextSearchClick}
107
- onTextSearch={props.onTextSearchClick ? undefined : props.onTextSearch}
99
+ loading={textSearchLoading}
100
+ disabled={Boolean(onTextSearchClick)}
101
+ onClick={onTextSearchClick}
102
+ onTextSearch={onTextSearchClick ? undefined : onTextSearch}
108
103
  expandable={true}/>}
109
104
 
110
- {props.actions}
105
+ {actions}
111
106
 
112
107
  </div>
113
108
 
@@ -73,6 +73,8 @@ import {
73
73
  import { DeleteEntityDialog } from "../DeleteEntityDialog";
74
74
  import { useAnalyticsController } from "../../hooks/useAnalyticsController";
75
75
  import { useSelectionController } from "./useSelectionController";
76
+ import { EntityCollectionViewStartActions } from "./EntityCollectionViewStartActions";
77
+ import { ClearFilterSortButton } from "../ClearFilterSortButton";
76
78
 
77
79
  const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
78
80
 
@@ -128,7 +130,6 @@ export const EntityCollectionView = React.memo(
128
130
  const analyticsController = useAnalyticsController();
129
131
  const customizationController = useCustomizationController();
130
132
 
131
-
132
133
  const containerRef = React.useRef<HTMLDivElement>(null);
133
134
 
134
135
  const collection = useMemo(() => {
@@ -606,6 +607,14 @@ export const EntityCollectionView = React.memo(
606
607
  onTextSearchClick={textSearchInitialised ? undefined : onTextSearchClick}
607
608
  textSearchLoading={textSearchLoading}
608
609
  textSearchEnabled={textSearchEnabled}
610
+ actionsStart={<EntityCollectionViewStartActions
611
+ parentCollectionIds={parentCollectionIds ?? []}
612
+ collection={collection}
613
+ tableController={tableController}
614
+ path={fullPath}
615
+ relativePath={collection.path}
616
+ selectionController={usedSelectionController}
617
+ collectionEntitiesCount={docsCount}/>}
609
618
  actions={<EntityCollectionViewActions
610
619
  parentCollectionIds={parentCollectionIds ?? []}
611
620
  collection={collection}
@@ -683,6 +692,8 @@ export const EntityCollectionView = React.memo(
683
692
  equal(a.selectionController, b.selectionController) &&
684
693
  equal(a.Actions, b.Actions) &&
685
694
  equal(a.defaultSize, b.defaultSize) &&
695
+ equal(a.initialFilter, b.initialFilter) &&
696
+ equal(a.initialSort, b.initialSort) &&
686
697
  equal(a.textSearchEnabled, b.textSearchEnabled) &&
687
698
  equal(a.additionalFields, b.additionalFields) &&
688
699
  equal(a.forceFilter, b.forceFilter);
@@ -0,0 +1,68 @@
1
+ import React from "react";
2
+ import { useCustomizationController, useFireCMSContext } from "../../hooks";
3
+ import { CollectionActionsProps, EntityCollection, EntityTableController, SelectionController } from "../../types";
4
+ import { toArray } from "../../util/arrays";
5
+ import { ErrorBoundary } from "../ErrorBoundary";
6
+ import { ClearFilterSortButton } from "../ClearFilterSortButton";
7
+
8
+ export type EntityCollectionViewStartActionsProps<M extends Record<string, any>> = {
9
+ collection: EntityCollection<M>;
10
+ path: string;
11
+ relativePath: string;
12
+ parentCollectionIds: string[];
13
+ selectionController: SelectionController<M>;
14
+ tableController: EntityTableController<M>;
15
+ collectionEntitiesCount: number;
16
+ }
17
+
18
+ export function EntityCollectionViewStartActions<M extends Record<string, any>>({
19
+ collection,
20
+ relativePath,
21
+ parentCollectionIds,
22
+ path,
23
+ selectionController,
24
+ tableController,
25
+ collectionEntitiesCount
26
+ }: EntityCollectionViewStartActionsProps<M>) {
27
+
28
+ const context = useFireCMSContext();
29
+
30
+ const customizationController = useCustomizationController();
31
+ const plugins = customizationController.plugins ?? [];
32
+
33
+ const actionProps: CollectionActionsProps = {
34
+ path,
35
+ relativePath,
36
+ parentCollectionIds,
37
+ collection,
38
+ selectionController,
39
+ context,
40
+ tableController,
41
+ collectionEntitiesCount
42
+ };
43
+ const actions: React.ReactNode[] = [
44
+ <ClearFilterSortButton
45
+ key={"clear_filter"}
46
+ tableController={tableController}
47
+ enabled={!collection.forceFilter}/>
48
+ ];
49
+
50
+ if (plugins) {
51
+ plugins.forEach((plugin, i) => {
52
+ if (plugin.collectionView?.CollectionActionsStart) {
53
+ actions.push(...toArray(plugin.collectionView?.CollectionActionsStart)
54
+ .map((Action, j) => (
55
+ <ErrorBoundary key={`plugin_actions_${i}_${j}`}>
56
+ <Action {...actionProps} {...plugin.collectionView?.collectionActionsStartProps}/>
57
+ </ErrorBoundary>
58
+ )));
59
+ }
60
+ });
61
+ }
62
+
63
+ return (
64
+ <>
65
+ {actions}
66
+ </>
67
+ );
68
+ }
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import { VirtualTableWhereFilterOp } from "../../VirtualTable";
3
- import { DateTimeField, Select, SelectItem } from "@firecms/ui";
3
+ import { Checkbox, DateTimeField, Label, Select, SelectItem } from "@firecms/ui";
4
4
  import { useCustomizationController } from "../../../hooks";
5
5
 
6
6
  interface DateTimeFilterFieldProps {
@@ -43,10 +43,10 @@ export function DateTimeFilterField({
43
43
 
44
44
  const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];
45
45
  const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);
46
- const [internalValue, setInternalValue] = useState<Date | undefined>(fieldValue);
46
+ const [internalValue, setInternalValue] = useState<Date | null | undefined>(fieldValue);
47
47
 
48
- function updateFilter(op: VirtualTableWhereFilterOp, val: Date | undefined) {
49
- let newValue: Date | undefined = val;
48
+ function updateFilter(op: VirtualTableWhereFilterOp, val: Date | undefined | null) {
49
+ let newValue: Date | null | undefined = val;
50
50
  const prevOpIsArray = multipleSelectOperations.includes(operation);
51
51
  const newOpIsArray = multipleSelectOperations.includes(op);
52
52
  if (prevOpIsArray !== newOpIsArray) {
@@ -73,7 +73,7 @@ export function DateTimeFilterField({
73
73
 
74
74
  return (
75
75
 
76
- <div className="flex w-[440px] items-center">
76
+ <div className="flex w-[440px]">
77
77
  <div className="w-[80px]">
78
78
  <Select value={operation}
79
79
  onValueChange={(value) => {
@@ -88,19 +88,34 @@ export function DateTimeFilterField({
88
88
  </Select>
89
89
  </div>
90
90
 
91
- <div className="flex-grow ml-2">
91
+ <div className="flex-grow ml-2 flex flex-col gap-2">
92
92
 
93
93
  <DateTimeField
94
94
  mode={mode}
95
95
  size={"medium"}
96
96
  locale={locale}
97
- value={internalValue}
97
+ value={internalValue ?? undefined}
98
98
  onChange={(dateValue: Date | undefined) => {
99
99
  updateFilter(operation, dateValue === null ? undefined : dateValue);
100
100
  }}
101
101
  clearable={true}
102
102
  />
103
103
 
104
+ <Label
105
+ className="border cursor-pointer rounded-md p-2 flex items-center gap-2 [&:has(:checked)]:bg-gray-100 dark:[&:has(:checked)]:bg-gray-800"
106
+ htmlFor="null-filter"
107
+ >
108
+ <Checkbox id="null-filter"
109
+ checked={internalValue === null}
110
+ size={"small"}
111
+ onCheckedChange={(checked) => {
112
+ if (internalValue !== null)
113
+ updateFilter(operation, null);
114
+ else updateFilter(operation, undefined);
115
+ }}/>
116
+ Filter for null values
117
+ </Label>
118
+
104
119
  </div>
105
120
 
106
121
  </div>
@@ -4,7 +4,7 @@ import { Entity, EntityCollection, EntityReference } from "../../../types";
4
4
  import { ReferencePreview } from "../../../preview";
5
5
  import { getReferenceFrom } from "../../../util";
6
6
  import { useNavigationController, useReferenceDialog } from "../../../hooks";
7
- import { Button, Select, SelectItem } from "@firecms/ui";
7
+ import { Button, Checkbox, Label, Select, SelectItem } from "@firecms/ui";
8
8
 
9
9
  interface ReferenceFilterFieldProps {
10
10
  name: string,
@@ -54,7 +54,7 @@ export function ReferenceFilterField({
54
54
 
55
55
  const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];
56
56
  const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);
57
- const [internalValue, setInternalValue] = useState<EntityReference | EntityReference[] | undefined>(fieldValue);
57
+ const [internalValue, setInternalValue] = useState<EntityReference | EntityReference[] | undefined | null>(fieldValue);
58
58
 
59
59
  const selectedEntityIds = internalValue
60
60
  ? (Array.isArray(internalValue) ? internalValue.map((ref) => {
@@ -65,7 +65,7 @@ export function ReferenceFilterField({
65
65
  }).filter(Boolean) as string[] : [internalValue.id])
66
66
  : [];
67
67
 
68
- function updateFilter(op: VirtualTableWhereFilterOp, val?: EntityReference | EntityReference[]) {
68
+ function updateFilter(op: VirtualTableWhereFilterOp, val?: EntityReference | EntityReference[] | null) {
69
69
 
70
70
  const prevOpIsArray = multipleSelectOperations.includes(operation);
71
71
  const newOpIsArray = multipleSelectOperations.includes(op);
@@ -142,7 +142,7 @@ export function ReferenceFilterField({
142
142
  return (
143
143
 
144
144
  <div className="flex w-[440px] flex-row">
145
- <div className="w-[120px]">
145
+ <div className="w-[140px]">
146
146
  <Select value={operation}
147
147
  onValueChange={(value) => {
148
148
  updateFilter(value as VirtualTableWhereFilterOp, internalValue);
@@ -156,21 +156,40 @@ export function ReferenceFilterField({
156
156
  </Select>
157
157
  </div>
158
158
 
159
- <div className="flex-grow ml-2 h-full">
159
+ <div className="flex-grow ml-2 h-full gap-2 flex flex-col">
160
160
 
161
161
  {internalValue && Array.isArray(internalValue) && <div>
162
162
  {internalValue.map((ref, index) => buildEntry(ref))}
163
163
  </div>}
164
+
164
165
  {internalValue && !Array.isArray(internalValue) && <div>
165
166
  {buildEntry(internalValue)}
166
167
  </div>}
168
+
167
169
  {(!internalValue || (Array.isArray(internalValue) && internalValue.length === 0)) &&
168
170
  <Button onClick={doOpenDialog}
169
171
  variant={"outlined"}
172
+ size={"large"}
170
173
  className="h-full w-full">
171
174
  {multiple ? "Select references" : "Select reference"}
172
175
  </Button>
173
176
  }
177
+
178
+ {!isArray && <Label
179
+ className="border cursor-pointer rounded-md p-2 flex items-center gap-2 [&:has(:checked)]:bg-gray-100 dark:[&:has(:checked)]:bg-gray-800"
180
+ htmlFor="null-filter"
181
+ >
182
+ <Checkbox id="null-filter"
183
+ checked={internalValue === null}
184
+ size={"small"}
185
+ onCheckedChange={(checked) => {
186
+ if (internalValue !== null)
187
+ updateFilter(operation, null);
188
+ else updateFilter(operation, undefined);
189
+ }}/>
190
+ Filter for null values
191
+ </Label>}
192
+
174
193
  </div>
175
194
 
176
195
  </div>
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from "react";
2
2
  import { EnumValuesChip } from "../../../preview";
3
3
  import { VirtualTableWhereFilterOp } from "../../VirtualTable";
4
- import { ClearIcon, IconButton, Select, SelectItem, TextField } from "@firecms/ui";
4
+ import { Checkbox, ClearIcon, IconButton, Label, Select, SelectItem, TextField } from "@firecms/ui";
5
5
  import { EnumValueConfig } from "../../../types";
6
6
 
7
7
  interface StringNumberFilterFieldProps {
@@ -50,15 +50,15 @@ export function StringNumberFilterField({
50
50
 
51
51
  const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];
52
52
  const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);
53
- const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | undefined>(fieldValue);
53
+ const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | null | undefined>(fieldValue);
54
54
 
55
- function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | undefined) {
55
+ function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | null | undefined) {
56
56
  let newValue = val;
57
57
  const prevOpIsArray = multipleSelectOperations.includes(operation);
58
58
  const newOpIsArray = multipleSelectOperations.includes(op);
59
59
  if (prevOpIsArray !== newOpIsArray) {
60
60
  // @ts-ignore
61
- newValue = newOpIsArray ? (typeof val === "string" || typeof val === "number" ? [val] : []) : "";
61
+ newValue = newOpIsArray ? (typeof val === "string" || typeof val === "number" ? [val] : []) : undefined;
62
62
  }
63
63
 
64
64
  if (typeof newValue === "number" && isNaN(newValue))
@@ -84,7 +84,7 @@ export function StringNumberFilterField({
84
84
  const multiple = multipleSelectOperations.includes(operation);
85
85
  return (
86
86
 
87
- <div className="flex w-[440px] items-center">
87
+ <div className="flex w-[440px]">
88
88
  <div className={"w-[80px]"}>
89
89
  <Select value={operation}
90
90
  position={"item-aligned"}
@@ -100,11 +100,11 @@ export function StringNumberFilterField({
100
100
  </Select>
101
101
  </div>
102
102
 
103
- <div className="flex-grow ml-2">
103
+ <div className="flex-grow ml-2 flex flex-col gap-2">
104
104
 
105
105
  {!enumValues && <TextField
106
106
  type={dataType === "number" ? "number" : undefined}
107
- value={internalValue !== undefined ? String(internalValue) : ""}
107
+ value={internalValue !== undefined && internalValue != null ? String(internalValue) : ""}
108
108
  onChange={(evt) => {
109
109
  const val = dataType === "number"
110
110
  ? parseFloat(evt.target.value)
@@ -118,26 +118,31 @@ export function StringNumberFilterField({
118
118
  />}
119
119
 
120
120
  {enumValues &&
121
-
122
121
  <Select
123
122
  position={"item-aligned"}
124
123
  value={internalValue !== undefined
125
124
  ? (Array.isArray(internalValue) ? internalValue.map(e => String(e)) : String(internalValue))
126
125
  : isArray ? [] : ""}
127
126
  onValueChange={(value) => {
128
- updateFilter(operation, dataType === "number" ? parseInt(value as string) : value as string)
127
+ if (value !== "")
128
+ updateFilter(operation, dataType === "number" ? parseInt(value as string) : value as string)
129
129
  }}
130
130
  multiple={multiple}
131
131
  endAdornment={internalValue && <IconButton
132
- className="absolute right-3 top-2"
132
+ className="absolute right-2 top-3"
133
133
  onClick={(e) => updateFilter(operation, undefined)}>
134
134
  <ClearIcon/>
135
135
  </IconButton>}
136
- renderValue={(enumKey) => <EnumValuesChip
137
- key={`select_value_${name}_${enumKey}`}
138
- enumKey={enumKey}
139
- enumValues={enumValues}
140
- size={"small"}/>}>
136
+ renderValue={(enumKey) => {
137
+ if (enumKey === null)
138
+ return "Filter for null values";
139
+
140
+ return <EnumValuesChip
141
+ key={`select_value_${name}_${enumKey}`}
142
+ enumKey={enumKey}
143
+ enumValues={enumValues}
144
+ size={"small"}/>;
145
+ }}>
141
146
  {enumValues.map((enumConfig) => (
142
147
  <SelectItem key={`select_value_${name}_${enumConfig.id}`}
143
148
  value={String(enumConfig.id)}>
@@ -150,6 +155,21 @@ export function StringNumberFilterField({
150
155
  </Select>
151
156
  }
152
157
 
158
+ {!isArray && <Label
159
+ className="border cursor-pointer rounded-md p-2 flex items-center gap-2 [&:has(:checked)]:bg-gray-100 dark:[&:has(:checked)]:bg-gray-800"
160
+ htmlFor="null-filter"
161
+ >
162
+ <Checkbox id="null-filter"
163
+ checked={internalValue === null}
164
+ size={"small"}
165
+ onCheckedChange={(checked) => {
166
+ if (internalValue !== null)
167
+ updateFilter(operation, null);
168
+ else updateFilter(operation, undefined);
169
+ }}/>
170
+ Filter for null values
171
+ </Label>}
172
+
153
173
  </div>
154
174
 
155
175
  </div>
@@ -359,8 +359,7 @@ export function getDefaultFieldId(property: Property | ResolvedProperty) {
359
359
  } else if (property.dataType === "map") {
360
360
  if (property.keyValue)
361
361
  return "key_value";
362
- if (property.properties)
363
- return "group";
362
+ return "group";
364
363
  } else if (property.dataType === "array") {
365
364
  const of = (property as ArrayProperty).of;
366
365
  const oneOf = (property as ArrayProperty).oneOf;