@mikevar/data-grid 0.1.1 → 0.3.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.
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ARR_IN_STRING_SEPARATOR: () => ARR_IN_STRING_SEPARATOR,
23
24
  COL_DIRECTION_SEPARATOR: () => COL_DIRECTION_SEPARATOR,
24
25
  COL_OPERATOR_SEPARATOR: () => COL_OPERATOR_SEPARATOR,
25
26
  DEFAULT_CURSOR: () => DEFAULT_CURSOR,
@@ -51,8 +52,9 @@ __export(index_exports, {
51
52
  module.exports = __toCommonJS(index_exports);
52
53
 
53
54
  // src/consts.ts
55
+ var ARR_IN_STRING_SEPARATOR = ",";
54
56
  var COL_DIRECTION_SEPARATOR = ":";
55
- var COL_OPERATOR_SEPARATOR = "__";
57
+ var COL_OPERATOR_SEPARATOR = ":";
56
58
  var DEFAULT_FILTER_MODE_KEY = "filterMode";
57
59
  var DEFAULT_SEARCH_KEY = "search";
58
60
  var DEFAULT_PAGINATION_MODE_KEY = "paginationMode";
@@ -68,14 +70,24 @@ var DEFAULT_FILTER_MODE = "search";
68
70
  var DEFAULT_SEARCH = "";
69
71
  var FILTER_OPERATORS = [
70
72
  "eq",
73
+ "ne",
71
74
  "gt",
72
75
  "gte",
73
76
  "lt",
74
77
  "lte",
75
- "between",
76
- "iLike",
77
78
  "isNull",
78
- "inArray"
79
+ "isNotNull",
80
+ "inArray",
81
+ "notInArray",
82
+ "between",
83
+ "notBetween",
84
+ "like",
85
+ "ilike",
86
+ "notILike",
87
+ "not",
88
+ "arrayContains",
89
+ "arrayContained",
90
+ "arrayOverlaps"
79
91
  ];
80
92
 
81
93
  // src/utils.ts
@@ -210,7 +222,7 @@ function normalizeParsedQueryObject({
210
222
  cursor,
211
223
  limit
212
224
  };
213
- const explodedOrders = parsedQuery.sorting.orders?.split(",") || [];
225
+ const explodedOrders = parsedQuery.sorting.orders?.split(ARR_IN_STRING_SEPARATOR) || [];
214
226
  const orders = explodedOrders.map((order) => {
215
227
  const [column, direction] = order.split(COL_DIRECTION_SEPARATOR).map((s) => s.trim());
216
228
  if (!column) return null;
@@ -219,7 +231,8 @@ function normalizeParsedQueryObject({
219
231
  direction: isOrderDirection(direction) ? direction : "asc"
220
232
  };
221
233
  }).filter((item) => item !== null);
222
- const filters = Object.entries(parsedQuery.filtering.filters).map(([colOperator, value]) => {
234
+ const rawFilters = parsedQuery.filtering.filters;
235
+ const filters = Object.entries(rawFilters).map(([colOperator, value]) => {
223
236
  const [col, operator] = colOperator.split(COL_OPERATOR_SEPARATOR);
224
237
  if (!col || !isFilterOperator(operator)) return null;
225
238
  const column = col.trim();
@@ -238,6 +251,7 @@ function normalizeParsedQueryObject({
238
251
  filtering: {
239
252
  mode: isFilterMode(parsedQuery.filtering.mode) ? parsedQuery.filtering.mode : defaultValues.filtering.mode,
240
253
  search: parsedQuery.filtering.search ?? defaultValues.filtering.search,
254
+ rawFilters,
241
255
  filters
242
256
  }
243
257
  };
@@ -263,6 +277,7 @@ function parseAndNormalize(options) {
263
277
  }
264
278
  // Annotate the CommonJS export names for ESM import in node:
265
279
  0 && (module.exports = {
280
+ ARR_IN_STRING_SEPARATOR,
266
281
  COL_DIRECTION_SEPARATOR,
267
282
  COL_OPERATOR_SEPARATOR,
268
283
  DEFAULT_CURSOR,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
+ declare const ARR_IN_STRING_SEPARATOR = ",";
1
2
  declare const COL_DIRECTION_SEPARATOR = ":";
2
- declare const COL_OPERATOR_SEPARATOR = "__";
3
+ declare const COL_OPERATOR_SEPARATOR = ":";
3
4
  declare const DEFAULT_FILTER_MODE_KEY = "filterMode";
4
5
  declare const DEFAULT_SEARCH_KEY = "search";
5
6
  declare const DEFAULT_PAGINATION_MODE_KEY = "paginationMode";
@@ -13,7 +14,7 @@ declare const DEFAULT_LIMIT = 10;
13
14
  declare const DEFAULT_CURSOR = "";
14
15
  declare const DEFAULT_FILTER_MODE: FilterMode;
15
16
  declare const DEFAULT_SEARCH = "";
16
- declare const FILTER_OPERATORS: readonly ["eq", "gt", "gte", "lt", "lte", "between", "iLike", "isNull", "inArray"];
17
+ declare const FILTER_OPERATORS: readonly ["eq", "ne", "gt", "gte", "lt", "lte", "isNull", "isNotNull", "inArray", "notInArray", "between", "notBetween", "like", "ilike", "notILike", "not", "arrayContains", "arrayContained", "arrayOverlaps"];
17
18
 
18
19
  type QueryKeysOptions = {
19
20
  filterMode?: string;
@@ -81,6 +82,7 @@ type NormalizedQueryObject = {
81
82
  filtering: {
82
83
  mode: FilterMode;
83
84
  search: string;
85
+ rawFilters: Record<string, string>;
84
86
  filters: FilterObject[];
85
87
  };
86
88
  };
@@ -159,4 +161,4 @@ declare function parseAndNormalize(options: ParseAndNormalizeQueryObjectOptions)
159
161
  normalized: NormalizedQueryObject;
160
162
  };
161
163
 
162
- export { COL_DIRECTION_SEPARATOR, COL_OPERATOR_SEPARATOR, type CursorPaginationObject, DEFAULT_CURSOR, DEFAULT_CURSOR_KEY, DEFAULT_FILTER_MODE, DEFAULT_FILTER_MODE_KEY, DEFAULT_LIMIT, DEFAULT_LIMIT_KEY, DEFAULT_ORDERS_KEY, DEFAULT_PAGE, DEFAULT_PAGE_KEY, DEFAULT_PAGINATION_MODE, DEFAULT_PAGINATION_MODE_KEY, DEFAULT_SEARCH, DEFAULT_SEARCH_KEY, type DefaultQueryValuesOptions, FILTER_OPERATORS, type FieldSchema, type FieldSchemaColumn, type FieldSchemaObject, type FieldSchemaObjectType, type FilterMode, type FilterObject, type FilterOperator, type NormalizedQueryObject, type OffsetPaginationObject, type OrderDirection, type OrderObject, type PaginationMode, type ParsedQueryObject, type QueryKeysOptions, type QueryPlanObject, isFilterMode, isFilterOperator, isOrderDirection, isPaginationMode, mergeDefaultAndCustomQueryKeys, mergeDefaultQueryValues, normalizeParsedQueryObject, parseAndNormalize, parseAndNormalizeQueryObject, parseQueryObject, toPositiveInt };
164
+ export { ARR_IN_STRING_SEPARATOR, COL_DIRECTION_SEPARATOR, COL_OPERATOR_SEPARATOR, type CursorPaginationObject, DEFAULT_CURSOR, DEFAULT_CURSOR_KEY, DEFAULT_FILTER_MODE, DEFAULT_FILTER_MODE_KEY, DEFAULT_LIMIT, DEFAULT_LIMIT_KEY, DEFAULT_ORDERS_KEY, DEFAULT_PAGE, DEFAULT_PAGE_KEY, DEFAULT_PAGINATION_MODE, DEFAULT_PAGINATION_MODE_KEY, DEFAULT_SEARCH, DEFAULT_SEARCH_KEY, type DefaultQueryValuesOptions, FILTER_OPERATORS, type FieldSchema, type FieldSchemaColumn, type FieldSchemaObject, type FieldSchemaObjectType, type FilterMode, type FilterObject, type FilterOperator, type NormalizedQueryObject, type OffsetPaginationObject, type OrderDirection, type OrderObject, type PaginationMode, type ParsedQueryObject, type QueryKeysOptions, type QueryPlanObject, isFilterMode, isFilterOperator, isOrderDirection, isPaginationMode, mergeDefaultAndCustomQueryKeys, mergeDefaultQueryValues, normalizeParsedQueryObject, parseAndNormalize, parseAndNormalizeQueryObject, parseQueryObject, toPositiveInt };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ declare const ARR_IN_STRING_SEPARATOR = ",";
1
2
  declare const COL_DIRECTION_SEPARATOR = ":";
2
- declare const COL_OPERATOR_SEPARATOR = "__";
3
+ declare const COL_OPERATOR_SEPARATOR = ":";
3
4
  declare const DEFAULT_FILTER_MODE_KEY = "filterMode";
4
5
  declare const DEFAULT_SEARCH_KEY = "search";
5
6
  declare const DEFAULT_PAGINATION_MODE_KEY = "paginationMode";
@@ -13,7 +14,7 @@ declare const DEFAULT_LIMIT = 10;
13
14
  declare const DEFAULT_CURSOR = "";
14
15
  declare const DEFAULT_FILTER_MODE: FilterMode;
15
16
  declare const DEFAULT_SEARCH = "";
16
- declare const FILTER_OPERATORS: readonly ["eq", "gt", "gte", "lt", "lte", "between", "iLike", "isNull", "inArray"];
17
+ declare const FILTER_OPERATORS: readonly ["eq", "ne", "gt", "gte", "lt", "lte", "isNull", "isNotNull", "inArray", "notInArray", "between", "notBetween", "like", "ilike", "notILike", "not", "arrayContains", "arrayContained", "arrayOverlaps"];
17
18
 
18
19
  type QueryKeysOptions = {
19
20
  filterMode?: string;
@@ -81,6 +82,7 @@ type NormalizedQueryObject = {
81
82
  filtering: {
82
83
  mode: FilterMode;
83
84
  search: string;
85
+ rawFilters: Record<string, string>;
84
86
  filters: FilterObject[];
85
87
  };
86
88
  };
@@ -159,4 +161,4 @@ declare function parseAndNormalize(options: ParseAndNormalizeQueryObjectOptions)
159
161
  normalized: NormalizedQueryObject;
160
162
  };
161
163
 
162
- export { COL_DIRECTION_SEPARATOR, COL_OPERATOR_SEPARATOR, type CursorPaginationObject, DEFAULT_CURSOR, DEFAULT_CURSOR_KEY, DEFAULT_FILTER_MODE, DEFAULT_FILTER_MODE_KEY, DEFAULT_LIMIT, DEFAULT_LIMIT_KEY, DEFAULT_ORDERS_KEY, DEFAULT_PAGE, DEFAULT_PAGE_KEY, DEFAULT_PAGINATION_MODE, DEFAULT_PAGINATION_MODE_KEY, DEFAULT_SEARCH, DEFAULT_SEARCH_KEY, type DefaultQueryValuesOptions, FILTER_OPERATORS, type FieldSchema, type FieldSchemaColumn, type FieldSchemaObject, type FieldSchemaObjectType, type FilterMode, type FilterObject, type FilterOperator, type NormalizedQueryObject, type OffsetPaginationObject, type OrderDirection, type OrderObject, type PaginationMode, type ParsedQueryObject, type QueryKeysOptions, type QueryPlanObject, isFilterMode, isFilterOperator, isOrderDirection, isPaginationMode, mergeDefaultAndCustomQueryKeys, mergeDefaultQueryValues, normalizeParsedQueryObject, parseAndNormalize, parseAndNormalizeQueryObject, parseQueryObject, toPositiveInt };
164
+ export { ARR_IN_STRING_SEPARATOR, COL_DIRECTION_SEPARATOR, COL_OPERATOR_SEPARATOR, type CursorPaginationObject, DEFAULT_CURSOR, DEFAULT_CURSOR_KEY, DEFAULT_FILTER_MODE, DEFAULT_FILTER_MODE_KEY, DEFAULT_LIMIT, DEFAULT_LIMIT_KEY, DEFAULT_ORDERS_KEY, DEFAULT_PAGE, DEFAULT_PAGE_KEY, DEFAULT_PAGINATION_MODE, DEFAULT_PAGINATION_MODE_KEY, DEFAULT_SEARCH, DEFAULT_SEARCH_KEY, type DefaultQueryValuesOptions, FILTER_OPERATORS, type FieldSchema, type FieldSchemaColumn, type FieldSchemaObject, type FieldSchemaObjectType, type FilterMode, type FilterObject, type FilterOperator, type NormalizedQueryObject, type OffsetPaginationObject, type OrderDirection, type OrderObject, type PaginationMode, type ParsedQueryObject, type QueryKeysOptions, type QueryPlanObject, isFilterMode, isFilterOperator, isOrderDirection, isPaginationMode, mergeDefaultAndCustomQueryKeys, mergeDefaultQueryValues, normalizeParsedQueryObject, parseAndNormalize, parseAndNormalizeQueryObject, parseQueryObject, toPositiveInt };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/consts.ts
2
+ var ARR_IN_STRING_SEPARATOR = ",";
2
3
  var COL_DIRECTION_SEPARATOR = ":";
3
- var COL_OPERATOR_SEPARATOR = "__";
4
+ var COL_OPERATOR_SEPARATOR = ":";
4
5
  var DEFAULT_FILTER_MODE_KEY = "filterMode";
5
6
  var DEFAULT_SEARCH_KEY = "search";
6
7
  var DEFAULT_PAGINATION_MODE_KEY = "paginationMode";
@@ -16,14 +17,24 @@ var DEFAULT_FILTER_MODE = "search";
16
17
  var DEFAULT_SEARCH = "";
17
18
  var FILTER_OPERATORS = [
18
19
  "eq",
20
+ "ne",
19
21
  "gt",
20
22
  "gte",
21
23
  "lt",
22
24
  "lte",
23
- "between",
24
- "iLike",
25
25
  "isNull",
26
- "inArray"
26
+ "isNotNull",
27
+ "inArray",
28
+ "notInArray",
29
+ "between",
30
+ "notBetween",
31
+ "like",
32
+ "ilike",
33
+ "notILike",
34
+ "not",
35
+ "arrayContains",
36
+ "arrayContained",
37
+ "arrayOverlaps"
27
38
  ];
28
39
 
29
40
  // src/utils.ts
@@ -158,7 +169,7 @@ function normalizeParsedQueryObject({
158
169
  cursor,
159
170
  limit
160
171
  };
161
- const explodedOrders = parsedQuery.sorting.orders?.split(",") || [];
172
+ const explodedOrders = parsedQuery.sorting.orders?.split(ARR_IN_STRING_SEPARATOR) || [];
162
173
  const orders = explodedOrders.map((order) => {
163
174
  const [column, direction] = order.split(COL_DIRECTION_SEPARATOR).map((s) => s.trim());
164
175
  if (!column) return null;
@@ -167,7 +178,8 @@ function normalizeParsedQueryObject({
167
178
  direction: isOrderDirection(direction) ? direction : "asc"
168
179
  };
169
180
  }).filter((item) => item !== null);
170
- const filters = Object.entries(parsedQuery.filtering.filters).map(([colOperator, value]) => {
181
+ const rawFilters = parsedQuery.filtering.filters;
182
+ const filters = Object.entries(rawFilters).map(([colOperator, value]) => {
171
183
  const [col, operator] = colOperator.split(COL_OPERATOR_SEPARATOR);
172
184
  if (!col || !isFilterOperator(operator)) return null;
173
185
  const column = col.trim();
@@ -186,6 +198,7 @@ function normalizeParsedQueryObject({
186
198
  filtering: {
187
199
  mode: isFilterMode(parsedQuery.filtering.mode) ? parsedQuery.filtering.mode : defaultValues.filtering.mode,
188
200
  search: parsedQuery.filtering.search ?? defaultValues.filtering.search,
201
+ rawFilters,
189
202
  filters
190
203
  }
191
204
  };
@@ -210,6 +223,7 @@ function parseAndNormalize(options) {
210
223
  return parseAndNormalizeQueryObject(options);
211
224
  }
212
225
  export {
226
+ ARR_IN_STRING_SEPARATOR,
213
227
  COL_DIRECTION_SEPARATOR,
214
228
  COL_OPERATOR_SEPARATOR,
215
229
  DEFAULT_CURSOR,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikevar/data-grid",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"