igniteui-grid-lite 0.9.0 → 0.10.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/components/cell.d.ts +8 -0
- package/components/cell.js +12 -1
- package/components/cell.js.map +1 -1
- package/components/column.d.ts +2 -2
- package/components/column.js.map +1 -1
- package/components/filter-row.d.ts +7 -2
- package/components/filter-row.js +87 -52
- package/components/filter-row.js.map +1 -1
- package/components/grid.d.ts +49 -3
- package/components/grid.js +102 -62
- package/components/grid.js.map +1 -1
- package/components/header-row.d.ts +1 -2
- package/components/header-row.js +4 -7
- package/components/header-row.js.map +1 -1
- package/components/header.d.ts +9 -0
- package/components/header.js +36 -23
- package/components/header.js.map +1 -1
- package/components/row.d.ts +4 -1
- package/components/row.js +12 -1
- package/components/row.js.map +1 -1
- package/components/virtualizer.d.ts +3 -1
- package/components/virtualizer.js +36 -7
- package/components/virtualizer.js.map +1 -1
- package/controllers/data-operation.d.ts +0 -4
- package/controllers/data-operation.js +7 -22
- package/controllers/data-operation.js.map +1 -1
- package/controllers/dom.d.ts +28 -9
- package/controllers/dom.js +70 -20
- package/controllers/dom.js.map +1 -1
- package/controllers/filter.d.ts +20 -4
- package/controllers/filter.js +39 -55
- package/controllers/filter.js.map +1 -1
- package/controllers/navigation.d.ts +10 -10
- package/controllers/navigation.js +68 -53
- package/controllers/navigation.js.map +1 -1
- package/controllers/resize.d.ts +8 -8
- package/controllers/resize.js +23 -14
- package/controllers/resize.js.map +1 -1
- package/controllers/sort.d.ts +12 -3
- package/controllers/sort.js +25 -32
- package/controllers/sort.js.map +1 -1
- package/controllers/state.d.ts +28 -18
- package/controllers/state.js +20 -26
- package/controllers/state.js.map +1 -1
- package/custom-elements.json +874 -243
- package/docs/igniteui-grid-lite.json +1339 -818
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/internal/a11y.d.ts +29 -0
- package/internal/a11y.js +24 -0
- package/internal/a11y.js.map +1 -0
- package/internal/constants.d.ts +3 -2
- package/internal/constants.js +1 -4
- package/internal/constants.js.map +1 -1
- package/internal/normalize-case.d.ts +5 -1
- package/internal/normalize-case.js +2 -1
- package/internal/normalize-case.js.map +1 -1
- package/internal/part-map.js +9 -17
- package/internal/part-map.js.map +1 -1
- package/internal/tags.d.ts +2 -2
- package/internal/tags.js +2 -2
- package/internal/tags.js.map +1 -1
- package/internal/types.d.ts +13 -1
- package/internal/types.js.map +1 -1
- package/internal/utils.d.ts +3 -0
- package/internal/utils.js +17 -4
- package/internal/utils.js.map +1 -1
- package/internal/watch.js +8 -9
- package/internal/watch.js.map +1 -1
- package/operations/base.js +2 -1
- package/operations/base.js.map +1 -1
- package/operations/filter/state.js +2 -5
- package/operations/filter/state.js.map +1 -1
- package/operations/filter/tree.d.ts +1 -2
- package/operations/filter/tree.js +2 -7
- package/operations/filter/tree.js.map +1 -1
- package/operations/filter.js +13 -1
- package/operations/filter.js.map +1 -1
- package/operations/sort.d.ts +0 -1
- package/operations/sort.js +7 -9
- package/operations/sort.js.map +1 -1
- package/package.json +2 -2
- package/styles/themes/grid.base.css.js +1 -1
- package/styles/themes/grid.base.css.js.map +1 -1
- package/styles/themes/shared/grid.common.css.js +1 -1
- package/styles/themes/shared/grid.common.css.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { IgcGridLiteColumn } from './components/column.js';
|
|
2
2
|
export type { IgcFilteredEvent, IgcFilteringEvent, IgcGridLiteEventMap, } from './components/grid.js';
|
|
3
3
|
export { IgcGridLite } from './components/grid.js';
|
|
4
|
-
export type { BaseColumnConfiguration, BaseColumnSortConfiguration, BaseIgcCellContext, ColumnConfiguration, ColumnSortConfiguration, DataPipelineConfiguration, DataPipelineHook, DataPipelineParams, DataType, GridLiteSortingOptions, IgcCellContext, IgcHeaderContext, Keys, PropertyType, } from './internal/types.js';
|
|
4
|
+
export type { BaseColumnConfiguration, BaseColumnSortConfiguration, BaseIgcCellContext, ColumnConfiguration, ColumnSortConfiguration, DataPipelineConfiguration, DataPipelineHook, DataPipelineParams, DataType, GridLiteSortingOptions, IgcCellContext, IgcHeaderContext, Keys, NavigateToOptions, PropertyType, } from './internal/types.js';
|
|
5
5
|
export { BooleanOperands } from './operations/filter/operands/boolean.js';
|
|
6
6
|
export { NumberOperands } from './operations/filter/operands/number.js';
|
|
7
7
|
export { StringOperands } from './operations/filter/operands/string.js';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAM3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAM3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAkBnD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export { IgcGridLiteColumn } from './components/column.js';\nexport type {\n IgcFilteredEvent,\n IgcFilteringEvent,\n IgcGridLiteEventMap,\n} from './components/grid.js';\nexport { IgcGridLite } from './components/grid.js';\nexport type {\n BaseColumnConfiguration,\n BaseColumnSortConfiguration,\n BaseIgcCellContext,\n ColumnConfiguration,\n ColumnSortConfiguration,\n DataPipelineConfiguration,\n DataPipelineHook,\n DataPipelineParams,\n DataType,\n GridLiteSortingOptions,\n IgcCellContext,\n IgcHeaderContext,\n Keys,\n NavigateToOptions,\n PropertyType,\n} from './internal/types.js';\nexport { BooleanOperands } from './operations/filter/operands/boolean.js';\nexport { NumberOperands } from './operations/filter/operands/number.js';\nexport { StringOperands } from './operations/filter/operands/string.js';\n\nexport type {\n BaseFilterExpression,\n FilterCriteria,\n FilterExpression,\n FilterOperation,\n FilterOperationLogic,\n OperandKeys,\n} from './operations/filter/types.js';\nexport type {\n BaseSortComparer,\n BaseSortingExpression,\n SortComparer,\n SortingDirection,\n SortingExpression,\n SortState,\n} from './operations/sort/types.js';\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ColumnConfiguration } from './types.js';
|
|
2
|
+
/** The roles the grid parts take in the ARIA grid pattern. */
|
|
3
|
+
type GridRole = 'grid' | 'row' | 'rowgroup' | 'columnheader' | 'gridcell';
|
|
4
|
+
/** ARIA state written on a part. A `null` value removes the property. */
|
|
5
|
+
type AriaState = Partial<Record<keyof ARIAMixin, string | null>>;
|
|
6
|
+
/** `aria-rowindex` of the header row. The grid row index space is 1-based. */
|
|
7
|
+
export declare const HEADER_ROW_INDEX = 1;
|
|
8
|
+
/** `aria-rowindex` of the filter row. It always comes after the header row. */
|
|
9
|
+
export declare const FILTER_ROW_INDEX = 2;
|
|
10
|
+
/**
|
|
11
|
+
* Publishes the ARIA semantics of one grid part through its ElementInternals.
|
|
12
|
+
* Roles and states stay off the observable attributes of the host.
|
|
13
|
+
*/
|
|
14
|
+
declare class A11yController {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(host: HTMLElement, role: GridRole);
|
|
17
|
+
/** Writes ARIA state on the host. */
|
|
18
|
+
set(state: AriaState): void;
|
|
19
|
+
}
|
|
20
|
+
/** Sets the grid pattern role of `host` and returns a handle to its ARIA state. */
|
|
21
|
+
export declare function addA11y(host: HTMLElement, role: GridRole): A11yController;
|
|
22
|
+
/** Returns the ARIA semantics `element` published through its ElementInternals. */
|
|
23
|
+
export declare function ariaOf(element: Element): ARIAMixin | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Number of rows the grid renders above its data: the header row, plus the filter
|
|
26
|
+
* row when a column is filterable. Data rows are indexed after them.
|
|
27
|
+
*/
|
|
28
|
+
export declare function headerRowsFor<T extends object>(columns: ColumnConfiguration<T>[]): number;
|
|
29
|
+
export type { A11yController };
|
package/internal/a11y.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const HEADER_ROW_INDEX = 1;
|
|
2
|
+
export const FILTER_ROW_INDEX = 2;
|
|
3
|
+
const semantics = new WeakMap();
|
|
4
|
+
class A11yController {
|
|
5
|
+
#internals;
|
|
6
|
+
constructor(host, role) {
|
|
7
|
+
this.#internals = host.attachInternals();
|
|
8
|
+
this.#internals.role = role;
|
|
9
|
+
semantics.set(host, this.#internals);
|
|
10
|
+
}
|
|
11
|
+
set(state) {
|
|
12
|
+
Object.assign(this.#internals, state);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function addA11y(host, role) {
|
|
16
|
+
return new A11yController(host, role);
|
|
17
|
+
}
|
|
18
|
+
export function ariaOf(element) {
|
|
19
|
+
return semantics.get(element);
|
|
20
|
+
}
|
|
21
|
+
export function headerRowsFor(columns) {
|
|
22
|
+
return columns.some((column) => column.filterable) ? FILTER_ROW_INDEX : HEADER_ROW_INDEX;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=a11y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.js","sourceRoot":"","sources":["../../src/internal/a11y.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAGlC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAMlC,MAAM,SAAS,GAAG,IAAI,OAAO,EAAsB,CAAC;AAMpD,MAAM,cAAc;IACT,UAAU,CAAmB;IAEtC,YAAY,IAAiB,EAAE,IAAc;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;QAE5B,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAGM,GAAG,CAAC,KAAgB;QACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CACF;AAGD,MAAM,UAAU,OAAO,CAAC,IAAiB,EAAE,IAAc;IACvD,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAGD,MAAM,UAAU,MAAM,CAAC,OAAgB;IACrC,OAAO,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAMD,MAAM,UAAU,aAAa,CAAmB,OAAiC;IAC/E,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC;AAC3F,CAAC","sourcesContent":["import type { ColumnConfiguration } from './types.js';\n\n/** The roles the grid parts take in the ARIA grid pattern. */\ntype GridRole = 'grid' | 'row' | 'rowgroup' | 'columnheader' | 'gridcell';\n\n/** ARIA state written on a part. A `null` value removes the property. */\ntype AriaState = Partial<Record<keyof ARIAMixin, string | null>>;\n\n/** `aria-rowindex` of the header row. The grid row index space is 1-based. */\nexport const HEADER_ROW_INDEX = 1;\n\n/** `aria-rowindex` of the filter row. It always comes after the header row. */\nexport const FILTER_ROW_INDEX = 2;\n\n/**\n * ElementInternals keeps ARIA out of the DOM. Neither `getAttribute` nor\n * `element.role` can read the semantics back. This registry is the only read path.\n */\nconst semantics = new WeakMap<Element, ARIAMixin>();\n\n/**\n * Publishes the ARIA semantics of one grid part through its ElementInternals.\n * Roles and states stay off the observable attributes of the host.\n */\nclass A11yController {\n readonly #internals: ElementInternals;\n\n constructor(host: HTMLElement, role: GridRole) {\n this.#internals = host.attachInternals();\n this.#internals.role = role;\n\n semantics.set(host, this.#internals);\n }\n\n /** Writes ARIA state on the host. */\n public set(state: AriaState): void {\n Object.assign(this.#internals, state);\n }\n}\n\n/** Sets the grid pattern role of `host` and returns a handle to its ARIA state. */\nexport function addA11y(host: HTMLElement, role: GridRole): A11yController {\n return new A11yController(host, role);\n}\n\n/** Returns the ARIA semantics `element` published through its ElementInternals. */\nexport function ariaOf(element: Element): ARIAMixin | undefined {\n return semantics.get(element);\n}\n\n/**\n * Number of rows the grid renders above its data: the header row, plus the filter\n * row when a column is filterable. Data rows are indexed after them.\n */\nexport function headerRowsFor<T extends object>(columns: ColumnConfiguration<T>[]): number {\n return columns.some((column) => column.filterable) ? FILTER_ROW_INDEX : HEADER_ROW_INDEX;\n}\n\nexport type { A11yController };\n"]}
|
package/internal/constants.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ActiveNode, ColumnConfiguration
|
|
1
|
+
import type { ActiveNode, ColumnConfiguration } from './types.js';
|
|
2
2
|
export declare const PIPELINE = "pipeline";
|
|
3
3
|
export declare const SORT_ICON_ASCENDING: "arrow-upward";
|
|
4
4
|
export declare const SORT_ICON_DESCENDING: "arrow-downward";
|
|
5
5
|
export declare const MIN_COL_RESIZE_WIDTH = 80;
|
|
6
|
+
/** CSS pseudo-class that matches an element that has or contains DOM focus. */
|
|
7
|
+
export declare const FOCUS_WITHIN = ":focus-within";
|
|
6
8
|
export declare const SENTINEL_NODE: Readonly<ActiveNode<any>>;
|
|
7
9
|
export declare const DEFAULT_COLUMN_CONFIG: Readonly<ColumnConfiguration<any>>;
|
|
8
|
-
export declare const NAVIGATION_STATE: Map<NavigationState, ActiveNode<any>>;
|
package/internal/constants.js
CHANGED
|
@@ -4,6 +4,7 @@ export const PIPELINE = 'pipeline';
|
|
|
4
4
|
export const SORT_ICON_ASCENDING = 'arrow-upward';
|
|
5
5
|
export const SORT_ICON_DESCENDING = 'arrow-downward';
|
|
6
6
|
export const MIN_COL_RESIZE_WIDTH = 80;
|
|
7
|
+
export const FOCUS_WITHIN = ':focus-within';
|
|
7
8
|
export const SENTINEL_NODE = Object.freeze({
|
|
8
9
|
column: NON_EXISTING_COLUMN,
|
|
9
10
|
row: -1,
|
|
@@ -16,8 +17,4 @@ export const DEFAULT_COLUMN_CONFIG = Object.freeze({
|
|
|
16
17
|
sortable: false,
|
|
17
18
|
filterable: false,
|
|
18
19
|
});
|
|
19
|
-
export const NAVIGATION_STATE = new Map([
|
|
20
|
-
['previous', SENTINEL_NODE],
|
|
21
|
-
['current', SENTINEL_NODE],
|
|
22
|
-
]);
|
|
23
20
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/internal/constants.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;AAC3B,MAAM,mBAAmB,GAAG,MAAM,EAAE,CAAC;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AACnC,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAuB,CAAC;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAyB,CAAC;AAE9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/internal/constants.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;AAC3B,MAAM,mBAAmB,GAAG,MAAM,EAAE,CAAC;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AACnC,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAuB,CAAC;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAyB,CAAC;AAE9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAGvC,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAA8B,MAAM,CAAC,MAAM,CAAC;IACpE,MAAM,EAAE,mBAAmB;IAC3B,GAAG,EAAE,CAAC,CAAC;CACR,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAA2B;IAC3E,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,KAAK;CAClB,CAAC,CAAC","sourcesContent":["import type { ActiveNode, ColumnConfiguration } from './types.js';\n\nconst columnKey = Symbol();\nconst NON_EXISTING_COLUMN = Symbol();\n\nexport const PIPELINE = 'pipeline';\nexport const SORT_ICON_ASCENDING = 'arrow-upward' as const;\nexport const SORT_ICON_DESCENDING = 'arrow-downward' as const;\n\nexport const MIN_COL_RESIZE_WIDTH = 80;\n\n/** CSS pseudo-class that matches an element that has or contains DOM focus. */\nexport const FOCUS_WITHIN = ':focus-within';\n\nexport const SENTINEL_NODE: Readonly<ActiveNode<any>> = Object.freeze({\n column: NON_EXISTING_COLUMN,\n row: -1,\n});\nexport const DEFAULT_COLUMN_CONFIG = Object.freeze<ColumnConfiguration<any>>({\n field: columnKey,\n dataType: 'string',\n resizable: false,\n hidden: false,\n sortable: false,\n filterable: false,\n});\n"]}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Single coercion point for string comparisons: a missing record value is treated
|
|
3
|
+
* as an empty string so operands never dereference null/undefined.
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeCase(string: string | null | undefined, caseSensitive?: boolean): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-case.js","sourceRoot":"","sources":["../../src/internal/normalize-case.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize-case.js","sourceRoot":"","sources":["../../src/internal/normalize-case.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,aAAa,CAAC,MAAiC,EAAE,aAAuB;IACtF,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC;IAC3B,OAAO,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;AACrD,CAAC","sourcesContent":["/**\n * Single coercion point for string comparisons: a missing record value is treated\n * as an empty string so operands never dereference null/undefined.\n */\nexport function normalizeCase(string: string | null | undefined, caseSensitive?: boolean) {\n const value = string ?? '';\n return caseSensitive ? value : value.toLowerCase();\n}\n"]}
|
package/internal/part-map.js
CHANGED
|
@@ -16,30 +16,22 @@ class PartMapDirective extends Directive {
|
|
|
16
16
|
}
|
|
17
17
|
update(part, [partMapInfo]) {
|
|
18
18
|
const partList = part.element.part;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this._previousParts.add(name);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return this.render(partMapInfo);
|
|
28
|
-
}
|
|
29
|
-
for (const name of this._previousParts) {
|
|
30
|
-
if (!(name in partMapInfo) || !partMapInfo[name]) {
|
|
19
|
+
const firstRender = this._previousParts === undefined;
|
|
20
|
+
const previous = this._previousParts ?? new Set();
|
|
21
|
+
this._previousParts = previous;
|
|
22
|
+
for (const name of previous) {
|
|
23
|
+
if (!partMapInfo[name]) {
|
|
31
24
|
partList.remove(name);
|
|
32
|
-
|
|
25
|
+
previous.delete(name);
|
|
33
26
|
}
|
|
34
27
|
}
|
|
35
28
|
for (const name in partMapInfo) {
|
|
36
|
-
|
|
37
|
-
if (value && !this._previousParts.has(name)) {
|
|
29
|
+
if (partMapInfo[name] && !previous.has(name)) {
|
|
38
30
|
partList.add(name);
|
|
39
|
-
|
|
31
|
+
previous.add(name);
|
|
40
32
|
}
|
|
41
33
|
}
|
|
42
|
-
return noChange;
|
|
34
|
+
return firstRender ? this.render(partMapInfo) : noChange;
|
|
43
35
|
}
|
|
44
36
|
}
|
|
45
37
|
export const partMap = directive(PartMapDirective);
|
package/internal/part-map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"part-map.js","sourceRoot":"","sources":["../../src/internal/part-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAEL,SAAS,EAET,SAAS,EAET,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAM1B,MAAM,gBAAiB,SAAQ,SAAS;IAGtC,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IACE,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,SAAS;YACpC,QAAQ,CAAC,IAAI,KAAK,MAAM;YACvB,QAAQ,CAAC,OAAO,EAAE,MAAiB,GAAG,CAAC,EACxC,CAAC;YACD,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;QACJ,CAAC;IACH,CAAC;IAEe,MAAM,CAAC,WAAwB;QAC7C,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;aAC5B,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;aACjC,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAEe,MAAM,CAAC,IAAmB,EAAE,CAAC,WAAW,CAA4B;QAClF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"part-map.js","sourceRoot":"","sources":["../../src/internal/part-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAEL,SAAS,EAET,SAAS,EAET,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAM1B,MAAM,gBAAiB,SAAQ,SAAS;IAGtC,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IACE,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,SAAS;YACpC,QAA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AC,CAAC,QAAQ,CAAC;IAC3D,CAAC;CACF;AAMD,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import { noChange } from 'lit';\nimport {\n type AttributePart,\n Directive,\n type DirectiveParameters,\n directive,\n type PartInfo,\n PartType,\n} from 'lit/directive.js';\n\nexport interface PartMapInfo {\n readonly [name: string]: boolean | null | undefined;\n}\n\nclass PartMapDirective extends Directive {\n private _previousParts?: Set<string>;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n\n if (\n partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'part' ||\n (partInfo.strings?.length as number) > 0\n ) {\n throw new Error(\n '`partMap() can only be used in the `part` attribute and must be the only part in the attribute.'\n );\n }\n }\n\n public override render(partMapInfo: PartMapInfo): string {\n return Object.keys(partMapInfo)\n .filter((key) => partMapInfo[key])\n .join(' ');\n }\n\n public override update(part: AttributePart, [partMapInfo]: DirectiveParameters<this>) {\n const partList = part.element.part;\n const firstRender = this._previousParts === undefined;\n const previous = this._previousParts ?? new Set<string>();\n this._previousParts = previous;\n\n for (const name of previous) {\n if (!partMapInfo[name]) {\n partList.remove(name);\n previous.delete(name);\n }\n }\n\n for (const name in partMapInfo) {\n if (partMapInfo[name] && !previous.has(name)) {\n partList.add(name);\n previous.add(name);\n }\n }\n\n // The first render must produce the attribute value; later ones patch the\n // part list directly.\n return firstRender ? this.render(partMapInfo) : noChange;\n }\n}\n\n/**\n * Similar to Lit's {@link https://lit.dev/docs/templates/directives/#classmap | `classMap`} and\n * {@link https://lit.dev/docs/templates/directives/#stylemap | `styleMap`} but for `part` attributes.\n */\nexport const partMap = directive(PartMapDirective);\nexport type { PartMapDirective };\n"]}
|
package/internal/tags.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const GRID_TAG: "igc-grid-lite";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const GRID_VIRTUALIZER_TAG: "igc-grid-lite-virtualizer";
|
|
3
3
|
export declare const GRID_HEADER_ROW_TAG: "igc-grid-lite-header-row";
|
|
4
4
|
export declare const GRID_HEADER_TAG: "igc-grid-lite-header";
|
|
5
5
|
export declare const GRID_ROW_TAG: "igc-grid-lite-row";
|
|
6
6
|
export declare const GRID_CELL_TAG: "igc-grid-lite-cell";
|
|
7
|
-
export declare const GRID_FILTER_ROW_TAG: "igc-filter-row";
|
|
7
|
+
export declare const GRID_FILTER_ROW_TAG: "igc-grid-lite-filter-row";
|
|
8
8
|
export declare const GRID_COLUMN_TAG: "igc-grid-lite-column";
|
package/internal/tags.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const GRID_TAG = 'igc-grid-lite';
|
|
2
|
-
export const
|
|
2
|
+
export const GRID_VIRTUALIZER_TAG = 'igc-grid-lite-virtualizer';
|
|
3
3
|
export const GRID_HEADER_ROW_TAG = 'igc-grid-lite-header-row';
|
|
4
4
|
export const GRID_HEADER_TAG = 'igc-grid-lite-header';
|
|
5
5
|
export const GRID_ROW_TAG = 'igc-grid-lite-row';
|
|
6
6
|
export const GRID_CELL_TAG = 'igc-grid-lite-cell';
|
|
7
|
-
export const GRID_FILTER_ROW_TAG = 'igc-filter-row';
|
|
7
|
+
export const GRID_FILTER_ROW_TAG = 'igc-grid-lite-filter-row';
|
|
8
8
|
export const GRID_COLUMN_TAG = 'igc-grid-lite-column';
|
|
9
9
|
//# sourceMappingURL=tags.js.map
|
package/internal/tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/internal/tags.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAwB,CAAC;AACjD,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/internal/tags.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAwB,CAAC;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAAoC,CAAC;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAAmC,CAAC;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,sBAA+B,CAAC;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG,mBAA4B,CAAC;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,oBAA6B,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAAmC,CAAC;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,sBAA+B,CAAC","sourcesContent":["export const GRID_TAG = 'igc-grid-lite' as const;\nexport const GRID_VIRTUALIZER_TAG = 'igc-grid-lite-virtualizer' as const;\nexport const GRID_HEADER_ROW_TAG = 'igc-grid-lite-header-row' as const;\nexport const GRID_HEADER_TAG = 'igc-grid-lite-header' as const;\nexport const GRID_ROW_TAG = 'igc-grid-lite-row' as const;\nexport const GRID_CELL_TAG = 'igc-grid-lite-cell' as const;\nexport const GRID_FILTER_ROW_TAG = 'igc-grid-lite-filter-row' as const;\nexport const GRID_COLUMN_TAG = 'igc-grid-lite-column' as const;\n"]}
|
package/internal/types.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type { IgcGridLite } from '../components/grid.js';
|
|
|
5
5
|
import type IgcGridLiteHeader from '../components/header.js';
|
|
6
6
|
import type IgcGridLiteRow from '../components/row.js';
|
|
7
7
|
import type { SortComparer } from '../operations/sort/types.js';
|
|
8
|
-
export type NavigationState = 'previous' | 'current';
|
|
9
8
|
export type GridHost<T extends object> = ReactiveControllerHost & IgcGridLite<T>;
|
|
10
9
|
export type Themes = {
|
|
11
10
|
light: {
|
|
@@ -133,6 +132,19 @@ export interface ActiveNode<T> {
|
|
|
133
132
|
column: Keys<T>;
|
|
134
133
|
row: number;
|
|
135
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Options for the navigateTo API of the grid.
|
|
137
|
+
*/
|
|
138
|
+
export interface NavigateToOptions<T> {
|
|
139
|
+
/**
|
|
140
|
+
* The column field to navigate to. Without it, only the row scrolls into view.
|
|
141
|
+
*/
|
|
142
|
+
column?: Keys<T>;
|
|
143
|
+
/**
|
|
144
|
+
* When true, the navigated cell becomes the active cell.
|
|
145
|
+
*/
|
|
146
|
+
activate?: boolean;
|
|
147
|
+
}
|
|
136
148
|
/**
|
|
137
149
|
* Context object for the column header template callback.
|
|
138
150
|
*/
|
package/internal/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Theme } from 'igniteui-webcomponents';\nimport type { CSSResult, ReactiveControllerHost, TemplateResult } from 'lit';\nimport type IgcGridLiteCell from '../components/cell.js';\nimport type { IgcGridLite } from '../components/grid.js';\nimport type IgcGridLiteHeader from '../components/header.js';\nimport type IgcGridLiteRow from '../components/row.js';\nimport type { SortComparer } from '../operations/sort/types.js';\n\nexport type
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Theme } from 'igniteui-webcomponents';\nimport type { CSSResult, ReactiveControllerHost, TemplateResult } from 'lit';\nimport type IgcGridLiteCell from '../components/cell.js';\nimport type { IgcGridLite } from '../components/grid.js';\nimport type IgcGridLiteHeader from '../components/header.js';\nimport type IgcGridLiteRow from '../components/row.js';\nimport type { SortComparer } from '../operations/sort/types.js';\n\nexport type GridHost<T extends object> = ReactiveControllerHost & IgcGridLite<T>;\n\nexport type Themes = {\n light: {\n [K in Theme | 'shared']?: CSSResult;\n };\n dark: {\n [K in Theme | 'shared']?: CSSResult;\n };\n};\n\ntype FlatKeys<T> = keyof T;\n\ntype NonTraversable =\n | ((...args: never) => unknown)\n | Array<unknown>\n | Date\n | RegExp\n | Map<unknown, unknown>\n | Set<unknown>\n | Promise<unknown>;\ntype Prev = [never, 0, 1, 2, 3, 4];\n\ntype DotPaths<T, Depth extends number = 5> = Depth extends 0\n ? never\n :\n | {\n [K in keyof T & string]: T[K] extends object\n ? T[K] extends NonTraversable\n ? never\n : `${K}.${DotPaths<T[K], Prev[Depth]>}` // Note: resolving `never` will collapse the entire interpolated string to never, leaving only valid paths\n : never;\n }[keyof T & string]\n | (keyof T & string);\n\ntype NestedKeys<T> = Exclude<DotPaths<T>, FlatKeys<T>>;\n\n/**\n * Helper type for resolving keys of type T.\n */\nexport type Keys<T> = FlatKeys<T> | NestedKeys<T>;\n\n/** Recursive T[K] property type resolve with nested dot paths support */\ntype PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}`\n ? K extends keyof T\n ? PathValue<T[K], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n/**\n * Helper type for resolving types of type T.\n */\nexport type PropertyType<T, K extends Keys<T> = Keys<T>> =\n K extends NestedKeys<T>\n ? PathValue<T, K> // nested path\n : K extends keyof T\n ? T[K] // flat key\n : never;\n\n/** The data for the current column. */\nexport type DataType = 'number' | 'string' | 'boolean';\n\n/**\n * Configures the sort behavior for the grid.\n */\nexport interface GridLiteSortingOptions {\n /**\n * The sorting mode - either 'single' or 'multiple' column sorting.\n */\n mode: 'single' | 'multiple';\n}\n\n/**\n * Extended sort configuration for a column.\n */\nexport interface BaseColumnSortConfiguration<T, K extends Keys<T> = Keys<T>> {\n /**\n * Custom comparer function for sort operations for this column.\n */\n comparer?: SortComparer<T, K>;\n}\n\n/**\n * See {@link BaseColumnSortConfiguration} for the full documentation.\n */\nexport type ColumnSortConfiguration<T, K extends Keys<T> = Keys<T>> =\n K extends Keys<T> ? BaseColumnSortConfiguration<T, K> : never;\n\n/** Configuration object for grid columns. */\nexport interface BaseColumnConfiguration<T extends object, K extends Keys<T> = Keys<T>> {\n /**\n * The field from the data for this column.\n */\n field: K;\n /**\n * The type of data this column will reference.\n *\n * Affects the default filter operands if the column is with filtering enabled.\n *\n * @remarks\n * If not passed, `string` is assumed to be the default type.\n *\n */\n dataType?: DataType;\n /**\n * Optional text to display in the column header. By default, the column field is used\n * to render the header text.\n */\n header?: string;\n /**\n * Width for the current column.\n *\n * Accepts most CSS units for controlling width.\n *\n * @remarks\n * If not passed, the column will try to size itself based on the number of other\n * columns and the total width of the grid.\n *\n */\n width?: string;\n /**\n * Whether the column is hidden or not.\n */\n hidden?: boolean;\n /**\n * Whether the the column can be resized or not.\n */\n resizable?: boolean;\n /**\n * Whether the column can be sorted.\n */\n sortable?: boolean;\n /**\n * Whether the sort operations will be case sensitive.\n */\n sortingCaseSensitive?: boolean;\n /**\n * Sort configuration options for the column (e.g., custom comparer).\n */\n sortConfiguration?: ColumnSortConfiguration<T, K>;\n /**\n * Whether the column can be filtered.\n */\n filterable?: boolean;\n /**\n * Whether the filter operations will be case sensitive.\n */\n filteringCaseSensitive?: boolean;\n /**\n * Header template callback.\n */\n headerTemplate?: (params: IgcHeaderContext<T>) => TemplateResult | unknown;\n /**\n * Cell template callback.\n */\n cellTemplate?: (params: IgcCellContext<T, K>) => TemplateResult | unknown;\n}\n\n/**\n * See {@link BaseColumnConfiguration} for the full documentation.\n */\nexport type ColumnConfiguration<T extends object = any, K extends Keys<T> = Keys<T>> =\n K extends Keys<T> ? BaseColumnConfiguration<T, K> : never;\n\nexport interface ActiveNode<T> {\n column: Keys<T>;\n row: number;\n}\n\n/**\n * Options for the navigateTo API of the grid.\n */\nexport interface NavigateToOptions<T> {\n /**\n * The column field to navigate to. Without it, only the row scrolls into view.\n */\n column?: Keys<T>;\n /**\n * When true, the navigated cell becomes the active cell.\n */\n activate?: boolean;\n}\n\n/**\n * Context object for the column header template callback.\n */\nexport interface IgcHeaderContext<T extends object = any> {\n /**\n * The header element parent of the template.\n */\n parent: IgcGridLiteHeader<T>;\n /**\n * The current configuration for the column.\n */\n column: ColumnConfiguration<T>;\n}\n\n/**\n * Context object for the row cell template callback.\n */\nexport interface BaseIgcCellContext<T extends object, K extends Keys<T> = Keys<T>> {\n /**\n * The cell element parent of the template.\n */\n parent: IgcGridLiteCell<T>;\n /**\n * The row element containing the cell.\n */\n row: IgcGridLiteRow<T>;\n /**\n * The current configuration for the column.\n */\n column: ColumnConfiguration<T, K>;\n /**\n * The value from the data source for this cell.\n */\n value: PropertyType<T, K>;\n}\n\n/**\n * See {@link BaseIgcCellContext} for the full documentation.\n */\nexport type IgcCellContext<T extends object = any, K extends Keys<T> = Keys<T>> =\n K extends Keys<T> ? BaseIgcCellContext<T, K> : never;\n\n/**\n * The parameters passed to a {@link DataPipelineHook} callback.\n */\nexport type DataPipelineParams<T extends object> = {\n /**\n * The current data state of the grid.\n */\n data: T[];\n /**\n * The grid component itself.\n */\n grid: IgcGridLite<T>;\n /**\n * The type of data operation being performed.\n */\n type: 'sort' | 'filter';\n};\n\n/**\n * Callback function for customizing data operations in the grid.\n */\nexport type DataPipelineHook<T extends object> = (\n state: DataPipelineParams<T>\n) => T[] | Promise<T[]>;\n\n/**\n * Configuration for customizing the various data operations of the grid.\n */\nexport interface DataPipelineConfiguration<T extends object> {\n /**\n * Hook for customizing sort operations.\n */\n sort?: DataPipelineHook<T>;\n /**\n * Hook for customizing filter operations.\n */\n filter?: DataPipelineHook<T>;\n}\n"]}
|
package/internal/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StyleInfo } from 'lit/directives/style-map.js';
|
|
2
|
+
import type { FilterOperation } from '../operations/filter/types.js';
|
|
2
3
|
import type { ColumnConfiguration, Keys, PropertyType } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Resolves a value from an object using a path string.
|
|
@@ -15,5 +16,7 @@ export declare function isNumber(x: unknown): x is number;
|
|
|
15
16
|
export declare function isString(x: unknown): x is string;
|
|
16
17
|
export declare function asArray<T>(value: T | T[]): T[];
|
|
17
18
|
export declare function getFilterOperandsFor<T extends object>(column: ColumnConfiguration<T>): Readonly<import("../operations/filter/types.js").FilterOperands<number, import("../operations/filter/operands/number.js").NumberKeys>> | Readonly<import("../operations/filter/types.js").FilterOperands<string, import("../operations/filter/operands/string.js").StringKeys>> | Readonly<import("../operations/filter/types.js").FilterOperands<boolean, import("../operations/filter/operands/boolean.js").BooleanKeys>>;
|
|
19
|
+
/** Resolves a raw operand name (e.g. 'contains') to the column's filter operation. */
|
|
20
|
+
export declare function resolveCondition<T extends object>(column: ColumnConfiguration<T>, name: string): FilterOperation<any>;
|
|
18
21
|
export declare function setColumnsFromData<T extends object>(record: T): Array<ColumnConfiguration<T>>;
|
|
19
22
|
export declare function createColumnConfiguration<T extends object>(config: Partial<ColumnConfiguration<T>>): ColumnConfiguration<T>;
|
package/internal/utils.js
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { BooleanOperands } from '../operations/filter/operands/boolean.js';
|
|
2
2
|
import { NumberOperands } from '../operations/filter/operands/number.js';
|
|
3
3
|
import { StringOperands } from '../operations/filter/operands/string.js';
|
|
4
|
+
const DEFAULT_COLUMN_WIDTH = 'minmax(136px, 1fr)';
|
|
4
5
|
function _isObject(entity) {
|
|
5
6
|
return entity != null && typeof entity === 'object';
|
|
6
7
|
}
|
|
8
|
+
const pathSegments = new Map();
|
|
9
|
+
function getPathSegments(path) {
|
|
10
|
+
let segments = pathSegments.get(path);
|
|
11
|
+
if (!segments) {
|
|
12
|
+
segments = path.split('.');
|
|
13
|
+
pathSegments.set(path, segments);
|
|
14
|
+
}
|
|
15
|
+
return segments;
|
|
16
|
+
}
|
|
7
17
|
export function resolveFieldValue(obj, path) {
|
|
8
18
|
if (typeof path === 'string' && path.includes('.')) {
|
|
9
|
-
return path
|
|
19
|
+
return getPathSegments(path).reduce((current, key) => {
|
|
10
20
|
return _isObject(current) && key in current ? current[key] : undefined;
|
|
11
21
|
}, obj);
|
|
12
22
|
}
|
|
13
23
|
return obj[path];
|
|
14
24
|
}
|
|
15
25
|
export function applyColumnWidths(columns) {
|
|
16
|
-
const
|
|
26
|
+
const widths = columns
|
|
17
27
|
.filter((each) => !each.hidden)
|
|
18
|
-
.map((each) => each.width ??
|
|
19
|
-
return { 'grid-template-columns':
|
|
28
|
+
.map((each) => each.width ?? DEFAULT_COLUMN_WIDTH);
|
|
29
|
+
return { 'grid-template-columns': widths.join(' ') };
|
|
20
30
|
}
|
|
21
31
|
export function isBoolean(x) {
|
|
22
32
|
return typeof x === 'boolean';
|
|
@@ -40,6 +50,9 @@ export function getFilterOperandsFor(column) {
|
|
|
40
50
|
return StringOperands;
|
|
41
51
|
}
|
|
42
52
|
}
|
|
53
|
+
export function resolveCondition(column, name) {
|
|
54
|
+
return getFilterOperandsFor(column)[name];
|
|
55
|
+
}
|
|
43
56
|
function getColumnType(value) {
|
|
44
57
|
if (isBoolean(value)) {
|
|
45
58
|
return 'boolean';
|
package/internal/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAIzE,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAElD,SAAS,SAAS,CAAC,MAAe;IAChC,OAAO,MAAM,IAAI,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC;AACtD,CAAC;AAMD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAoB,CAAC;AAEjD,SAAS,eAAe,CAAC,IAAY;IACnC,IAAI,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEtC,IAAI,CAA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EAAE;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,QAAQ;QACrC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK;QAC9B,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,KAAK;QACpC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;QAClC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,IAAI,KAAK;QAC1D,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK;QACtC,sBAAsB,EAAE,MAAM,CAAC,sBAAsB,IAAI,KAAK;QAC9D,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,YAAY,EAAE,MAAM,CAAC,YAAY;KACR,CAAC;AAC9B,CAAC","sourcesContent":["import type { StyleInfo } from 'lit/directives/style-map.js';\nimport { BooleanOperands } from '../operations/filter/operands/boolean.js';\nimport { NumberOperands } from '../operations/filter/operands/number.js';\nimport { StringOperands } from '../operations/filter/operands/string.js';\nimport type { FilterOperation } from '../operations/filter/types.js';\nimport type { ColumnConfiguration, Keys, PropertyType } from './types.js';\n\nconst DEFAULT_COLUMN_WIDTH = 'minmax(136px, 1fr)';\n\nfunction _isObject(entity: unknown): entity is Record<string, unknown> {\n return entity != null && typeof entity === 'object';\n}\n\n/**\n * Dot-path -> segments cache. Filtering and sorting resolve the same handful of paths\n * once per record, so the split is done once per path instead of per lookup.\n */\nconst pathSegments = new Map<string, string[]>();\n\nfunction getPathSegments(path: string): string[] {\n let segments = pathSegments.get(path);\n\n if (!segments) {\n segments = path.split('.');\n pathSegments.set(path, segments);\n }\n\n return segments;\n}\n\n/**\n * Resolves a value from an object using a path string.\n * Supports nested properties using dot notation (e.g., 'prop.nestedProp').\n *\n * @param obj - The object to resolve the value from.\n * @param path - The path to the property, can be a simple key or dot-separated path.\n * @returns The resolved value, or undefined if the path cannot be resolved.\n */\nexport function resolveFieldValue<T>(obj: T, path: Keys<T>): PropertyType<T> {\n if (typeof path === 'string' && path.includes('.')) {\n return getPathSegments(path).reduce<unknown>((current, key) => {\n return _isObject(current) && key in current ? current[key] : undefined;\n }, obj) as PropertyType<T>;\n }\n return obj[path as keyof T] as PropertyType<T>;\n}\n\nexport function applyColumnWidths<T extends object>(\n columns: Array<ColumnConfiguration<T>>\n): StyleInfo {\n const widths = columns\n .filter((each) => !each.hidden)\n .map((each) => each.width ?? DEFAULT_COLUMN_WIDTH);\n\n return { 'grid-template-columns': widths.join(' ') };\n}\n\nexport function isBoolean(x: unknown): x is boolean {\n return typeof x === 'boolean';\n}\n\nexport function isNumber(x: unknown): x is number {\n return typeof x === 'number' && !Number.isNaN(x);\n}\n\nexport function isString(x: unknown): x is string {\n return typeof x === 'string';\n}\n\nexport function asArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\nexport function getFilterOperandsFor<T extends object>(column: ColumnConfiguration<T>) {\n // Check for custom class in the filter config\n switch (column.dataType) {\n case 'boolean':\n return BooleanOperands;\n case 'number':\n return NumberOperands;\n default:\n return StringOperands;\n }\n}\n\n/** Resolves a raw operand name (e.g. 'contains') to the column's filter operation. */\nexport function resolveCondition<T extends object>(\n column: ColumnConfiguration<T>,\n name: string\n): FilterOperation<any> {\n return (getFilterOperandsFor(column) as Record<string, FilterOperation<any>>)[name];\n}\n\nfunction getColumnType(value: unknown): 'boolean' | 'number' | 'string' {\n if (isBoolean(value)) {\n return 'boolean';\n }\n\n if (isNumber(value)) {\n return 'number';\n }\n\n return 'string';\n}\n\nexport function setColumnsFromData<T extends object>(record: T): Array<ColumnConfiguration<T>> {\n return Object.entries(record).map(([key, value]) => {\n return createColumnConfiguration<T>({\n field: key as keyof T,\n dataType: getColumnType(value),\n } as Partial<ColumnConfiguration<T>>);\n });\n}\n\nexport function createColumnConfiguration<T extends object>(\n config: Partial<ColumnConfiguration<T>>\n): ColumnConfiguration<T> {\n return {\n field: config.field ?? '',\n dataType: config.dataType ?? 'string',\n header: config.header,\n width: config.width,\n hidden: config.hidden ?? false,\n resizable: config.resizable ?? false,\n sortable: config.sortable ?? false,\n sortingCaseSensitive: config.sortingCaseSensitive ?? false,\n sortConfiguration: config.sortConfiguration,\n filterable: config.filterable ?? false,\n filteringCaseSensitive: config.filteringCaseSensitive ?? false,\n headerTemplate: config.headerTemplate,\n cellTemplate: config.cellTemplate,\n } as ColumnConfiguration<T>;\n}\n"]}
|
package/internal/watch.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export function watch(propName, options) {
|
|
2
2
|
return (protoOrDescriptor, name) => {
|
|
3
3
|
const { willUpdate } = protoOrDescriptor;
|
|
4
|
-
const
|
|
4
|
+
const waitUntilFirstUpdate = options?.waitUntilFirstUpdate ?? false;
|
|
5
5
|
protoOrDescriptor.willUpdate = function (changedProps) {
|
|
6
6
|
willUpdate.call(this, changedProps);
|
|
7
|
-
if (changedProps.has(propName)) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
7
|
+
if (!changedProps.has(propName)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const oldValue = changedProps.get(propName);
|
|
11
|
+
const newValue = this[propName];
|
|
12
|
+
if (oldValue !== newValue && (!waitUntilFirstUpdate || this.hasUpdated)) {
|
|
13
|
+
this[name].call(this, oldValue, newValue);
|
|
15
14
|
}
|
|
16
15
|
};
|
|
17
16
|
};
|
package/internal/watch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/internal/watch.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,OAAsB;IAC5D,OAAO,CAAC,iBAAsB,EAAE,IAAY,EAAO,EAAE;QACnD,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/internal/watch.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,OAAsB;IAC5D,OAAO,CAAC,iBAAsB,EAAE,IAAY,EAAO,EAAE;QACnD,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC;QACzC,MAAM,oBAAoB,GAAG,OAAO,EAAE,oBAAoB,IAAI,KAAK,CAAC;QAEpE,iBAAiB,CAAC,UAAU,GAAG,UAAU,YAA8B;YACrE,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAEpC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAChC,OAAO;YACT,CAAC;YAED,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEhC,IAAI,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,oBAAoB,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["interface WatchOptions {\n waitUntilFirstUpdate?: boolean;\n}\n\nexport function watch(propName: string, options?: WatchOptions) {\n return (protoOrDescriptor: any, name: string): any => {\n const { willUpdate } = protoOrDescriptor;\n const waitUntilFirstUpdate = options?.waitUntilFirstUpdate ?? false;\n\n protoOrDescriptor.willUpdate = function (changedProps: Map<string, any>) {\n willUpdate.call(this, changedProps);\n\n if (!changedProps.has(propName)) {\n return;\n }\n\n const oldValue = changedProps.get(propName);\n const newValue = this[propName];\n\n if (oldValue !== newValue && (!waitUntilFirstUpdate || this.hasUpdated)) {\n this[name].call(this, oldValue, newValue);\n }\n };\n };\n}\n"]}
|
package/operations/base.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { normalizeCase } from '../internal/normalize-case.js';
|
|
1
2
|
import { resolveFieldValue } from '../internal/utils.js';
|
|
2
3
|
export default class DataOperation {
|
|
3
4
|
resolveValue(record, key) {
|
|
4
5
|
return resolveFieldValue(record, key);
|
|
5
6
|
}
|
|
6
7
|
resolveCase(value, caseSensitive) {
|
|
7
|
-
return typeof value === 'string'
|
|
8
|
+
return typeof value === 'string' ? normalizeCase(value, caseSensitive) : value;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=base.js.map
|
package/operations/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/operations/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/operations/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAgB,aAAa;IAC/B,YAAY,CAAC,MAAS,EAAE,GAAM;QACtC,OAAO,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;IAES,WAAW,CAAyB,KAAQ,EAAE,aAAuB;QAC7E,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,aAAa,CAAC,KAAK,EAAE,aAAa,CAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACxF,CAAC;CAGF","sourcesContent":["import { normalizeCase } from '../internal/normalize-case.js';\nimport type { Keys, PropertyType } from '../internal/types.js';\nimport { resolveFieldValue } from '../internal/utils.js';\n\nexport default abstract class DataOperation<T, K extends Keys<T> = Keys<T>> {\n protected resolveValue(record: T, key: K) {\n return resolveFieldValue(record, key);\n }\n\n protected resolveCase<U = PropertyType<T, K>>(value: U, caseSensitive?: boolean) {\n return typeof value === 'string' ? (normalizeCase(value, caseSensitive) as U) : value;\n }\n\n public abstract apply(...args: unknown[]): T[];\n}\n"]}
|
|
@@ -22,11 +22,8 @@ export class FilterState {
|
|
|
22
22
|
this.state.clear();
|
|
23
23
|
}
|
|
24
24
|
set(expression) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.state.set(expression.key, new FilterExpressionTree(expression.key).add(expression));
|
|
25
|
+
const tree = this.state.get(expression.key) ?? new FilterExpressionTree(expression.key);
|
|
26
|
+
this.state.set(expression.key, tree.add(expression));
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
//# sourceMappingURL=state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/operations/filter/state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,MAAM,OAAO,WAAW;IAAxB;QACY,UAAK,GAA0C,IAAI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/operations/filter/state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,MAAM,OAAO,WAAW;IAAxB;QACY,UAAK,GAA0C,IAAI,GAAG,EAAE,CAAC;IA8BrE,CAAC;IA5BC,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,IAAW,MAAM;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAEM,GAAG,CAAC,GAAY;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAEM,GAAG,CAAC,GAAY;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,GAAY;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAEM,GAAG,CAAC,UAA+B;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,oBAAoB,CAAI,UAAU,CAAC,GAAG,CAAC,CAAC;QAC3F,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IACvD,CAAC;CACF","sourcesContent":["import type { Keys } from '../../internal/types.js';\nimport { FilterExpressionTree } from './tree.js';\nimport type { FilterExpression } from './types.js';\n\nexport class FilterState<T> {\n protected state: Map<Keys<T>, FilterExpressionTree<T>> = new Map();\n\n public get empty() {\n return this.state.size < 1;\n }\n\n public get values() {\n return Array.from(this.state.values());\n }\n\n public has(key: Keys<T>) {\n return this.state.has(key);\n }\n\n public get(key: Keys<T>) {\n return this.state.get(key);\n }\n\n public delete(key: Keys<T>) {\n return this.state.delete(key);\n }\n\n public clear() {\n this.state.clear();\n }\n\n public set(expression: FilterExpression<T>) {\n const tree = this.state.get(expression.key) ?? new FilterExpressionTree<T>(expression.key);\n this.state.set(expression.key, tree.add(expression));\n }\n}\n"]}
|
|
@@ -12,6 +12,5 @@ export declare class FilterExpressionTree<T> {
|
|
|
12
12
|
has(expression: FilterExpression<T>): boolean;
|
|
13
13
|
add(expression: FilterExpression<T>): this;
|
|
14
14
|
remove(expression: FilterExpression<T>): this;
|
|
15
|
-
|
|
16
|
-
[Symbol.iterator](): Generator<FilterExpression<T>, void, unknown>;
|
|
15
|
+
[Symbol.iterator](): ArrayIterator<FilterExpression<T>>;
|
|
17
16
|
}
|
|
@@ -10,7 +10,7 @@ export class FilterExpressionTree {
|
|
|
10
10
|
return this.operands.length;
|
|
11
11
|
}
|
|
12
12
|
get all() {
|
|
13
|
-
return
|
|
13
|
+
return [...this.operands];
|
|
14
14
|
}
|
|
15
15
|
get ands() {
|
|
16
16
|
return this.operands.filter((each) => each.criteria === 'and');
|
|
@@ -34,13 +34,8 @@ export class FilterExpressionTree {
|
|
|
34
34
|
this.operands = this.operands.filter((each) => each !== expression);
|
|
35
35
|
return this;
|
|
36
36
|
}
|
|
37
|
-
*iterator() {
|
|
38
|
-
for (const operand of this.operands) {
|
|
39
|
-
yield operand;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
37
|
[Symbol.iterator]() {
|
|
43
|
-
return this.
|
|
38
|
+
return this.operands.values();
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
41
|
//# sourceMappingURL=tree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/operations/filter/tree.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,oBAAoB;IAG/B,YAAmB,GAAY;QAAZ,QAAG,GAAH,GAAG,CAAS;QAFrB,aAAQ,GAA+B,EAAE,CAAC;IAElB,CAAC;IAEnC,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAW,GAAG;QACZ,OAAO,
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/operations/filter/tree.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,oBAAoB;IAG/B,YAAmB,GAAY;QAAZ,QA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CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;CACF","sourcesContent":["import type { Keys } from '../../internal/types.js';\nimport type { FilterExpression } from './types.js';\n\nexport class FilterExpressionTree<T> {\n protected operands: Array<FilterExpression<T>> = [];\n\n constructor(public key: Keys<T>) {}\n\n public get empty() {\n return this.operands.length < 1;\n }\n\n public get length() {\n return this.operands.length;\n }\n\n public get all() {\n return [...this.operands];\n }\n\n public get ands() {\n return this.operands.filter((each) => each.criteria === 'and');\n }\n\n public get ors() {\n return this.operands.filter((each) => each.criteria === 'or');\n }\n\n public has(expression: FilterExpression<T>) {\n return this.operands.includes(expression);\n }\n\n public add(expression: FilterExpression<T>) {\n if (!expression.criteria) {\n expression.criteria = 'and';\n }\n\n if (!this.has(expression)) {\n this.operands.push(expression);\n }\n\n return this;\n }\n\n public remove(expression: FilterExpression<T>) {\n this.operands = this.operands.filter((each) => each !== expression);\n return this;\n }\n\n public [Symbol.iterator]() {\n return this.operands.values();\n }\n}\n"]}
|
package/operations/filter.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { isString } from '../internal/utils.js';
|
|
1
2
|
import DataOperation from './base.js';
|
|
3
|
+
function isResolved(expression) {
|
|
4
|
+
return !isString(expression.condition);
|
|
5
|
+
}
|
|
2
6
|
export default class FilterDataOperation extends DataOperation {
|
|
3
7
|
resolveFilter(record, expr) {
|
|
4
8
|
const condition = expr.condition;
|
|
@@ -8,12 +12,20 @@ export default class FilterDataOperation extends DataOperation {
|
|
|
8
12
|
if (ors.length > 0 && ors.some((expr) => this.resolveFilter(record, expr))) {
|
|
9
13
|
return true;
|
|
10
14
|
}
|
|
15
|
+
if (ands.length === 0) {
|
|
16
|
+
return ors.length === 0;
|
|
17
|
+
}
|
|
11
18
|
return ands.every((expr) => this.resolveFilter(record, expr));
|
|
12
19
|
}
|
|
13
20
|
apply(data, state) {
|
|
14
21
|
if (state.empty)
|
|
15
22
|
return data;
|
|
16
|
-
const trees = state.values
|
|
23
|
+
const trees = state.values
|
|
24
|
+
.map((tree) => ({ ors: tree.ors.filter(isResolved), ands: tree.ands.filter(isResolved) }))
|
|
25
|
+
.filter(({ ors, ands }) => ors.length > 0 || ands.length > 0);
|
|
26
|
+
if (trees.length === 0) {
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
17
29
|
return data.filter((record) => trees.every(({ ors, ands }) => this.matchTree(record, ors, ands)));
|
|
18
30
|
}
|
|
19
31
|
}
|