igniteui-grid-lite 0.10.0 → 0.11.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 +5 -17
- package/components/cell.js +2 -2
- package/components/cell.js.map +1 -1
- package/components/filter-row.d.ts +2 -5
- package/components/filter-row.js +22 -27
- package/components/filter-row.js.map +1 -1
- package/components/grid.d.ts +10 -15
- package/components/grid.js +33 -36
- package/components/grid.js.map +1 -1
- package/components/header-row.js +2 -1
- package/components/header-row.js.map +1 -1
- package/components/header.js +2 -6
- package/components/header.js.map +1 -1
- package/components/row.d.ts +0 -3
- package/components/row.js +3 -3
- package/components/row.js.map +1 -1
- package/controllers/data-operation.d.ts +1 -3
- package/controllers/data-operation.js +0 -2
- package/controllers/data-operation.js.map +1 -1
- package/controllers/dom.d.ts +4 -16
- package/controllers/dom.js +14 -13
- package/controllers/dom.js.map +1 -1
- package/controllers/filter.d.ts +10 -22
- package/controllers/filter.js +14 -8
- package/controllers/filter.js.map +1 -1
- package/controllers/navigation.d.ts +4 -9
- package/controllers/navigation.js +23 -43
- package/controllers/navigation.js.map +1 -1
- package/controllers/resize.d.ts +3 -9
- package/controllers/resize.js +2 -7
- package/controllers/resize.js.map +1 -1
- package/controllers/sort.d.ts +3 -5
- package/controllers/sort.js +19 -14
- package/controllers/sort.js.map +1 -1
- package/controllers/state.d.ts +2 -13
- package/controllers/state.js +12 -10
- package/controllers/state.js.map +1 -1
- package/custom-elements.json +201 -350
- package/docs/igniteui-grid-lite.json +849 -859
- package/internal/a11y.d.ts +2 -5
- package/internal/a11y.js.map +1 -1
- package/internal/body-focus.d.ts +6 -0
- package/internal/body-focus.js +46 -0
- package/internal/body-focus.js.map +1 -0
- package/internal/constants.d.ts +4 -1
- package/internal/constants.js +2 -0
- package/internal/constants.js.map +1 -1
- package/internal/element-from-event-path.d.ts +1 -1
- package/internal/element-from-event-path.js +2 -9
- package/internal/element-from-event-path.js.map +1 -1
- package/internal/tags.d.ts +0 -1
- package/internal/tags.js +0 -1
- package/internal/tags.js.map +1 -1
- package/internal/types.d.ts +6 -7
- package/internal/types.js.map +1 -1
- package/internal/utils.d.ts +4 -8
- package/internal/utils.js +7 -3
- package/internal/utils.js.map +1 -1
- package/operations/base.js +2 -2
- package/operations/base.js.map +1 -1
- package/operations/filter/state.d.ts +0 -1
- package/operations/filter/state.js +0 -3
- package/operations/filter/state.js.map +1 -1
- package/operations/filter/types.d.ts +1 -1
- package/operations/filter/types.js.map +1 -1
- package/operations/filter.js +3 -2
- package/operations/filter.js.map +1 -1
- package/operations/sort/types.d.ts +1 -1
- package/operations/sort/types.js.map +1 -1
- package/operations/sort.js +5 -1
- package/operations/sort.js.map +1 -1
- package/package.json +2 -3
- package/styles/header-cell/header-cell.css.js +1 -1
- package/styles/header-cell/header-cell.css.js.map +1 -1
- package/styles/themes/filtering-row-themes.js +2 -30
- package/styles/themes/filtering-row-themes.js.map +1 -1
- package/styles/themes/grid-header-themes.js +2 -20
- package/styles/themes/grid-header-themes.js.map +1 -1
- package/styles/themes/grid-themes.js +10 -31
- package/styles/themes/grid-themes.js.map +1 -1
- 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/components/virtualizer.d.ts +0 -14
- package/components/virtualizer.js +0 -49
- package/components/virtualizer.js.map +0 -1
- package/internal/virt-flow-layout.d.ts +0 -4
- package/internal/virt-flow-layout.js +0 -15
- package/internal/virt-flow-layout.js.map +0 -1
package/internal/a11y.d.ts
CHANGED
|
@@ -7,10 +7,7 @@ type AriaState = Partial<Record<keyof ARIAMixin, string | null>>;
|
|
|
7
7
|
export declare const HEADER_ROW_INDEX = 1;
|
|
8
8
|
/** `aria-rowindex` of the filter row. It always comes after the header row. */
|
|
9
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
|
-
*/
|
|
10
|
+
/** Writes the ARIA of one grid part through ElementInternals, off the host attributes. */
|
|
14
11
|
declare class A11yController {
|
|
15
12
|
#private;
|
|
16
13
|
constructor(host: HTMLElement, role: GridRole);
|
|
@@ -26,4 +23,4 @@ export declare function ariaOf(element: Element): ARIAMixin | undefined;
|
|
|
26
23
|
* row when a column is filterable. Data rows are indexed after them.
|
|
27
24
|
*/
|
|
28
25
|
export declare function headerRowsFor<T extends object>(columns: ColumnConfiguration<T>[]): number;
|
|
29
|
-
export
|
|
26
|
+
export {};
|
package/internal/a11y.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAGlC,MAAM,SAAS,GAAG,IAAI,OAAO,EAAsB,CAAC;AAGpD,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/** ARIA set through ElementInternals is unreadable from the DOM. This is the read path. */\nconst semantics = new WeakMap<Element, ARIAMixin>();\n\n/** Writes the ARIA of one grid part through ElementInternals, off the host attributes. */\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"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps focus in the body across row recycling. `igc-virtual-scroll` reuses the
|
|
3
|
+
* element of a leaving row, so the focused cell may show another row or drop
|
|
4
|
+
* focus. Listeners live until `signal` aborts.
|
|
5
|
+
*/
|
|
6
|
+
export declare function addBodyFocus(body: HTMLElement, signal: AbortSignal): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FOCUS_WITHIN, NO_SCROLL, SCROLL_STATE_CHANGE } from './constants.js';
|
|
2
|
+
import { getElementFromEventPath } from './element-from-event-path.js';
|
|
3
|
+
import { GRID_CELL_TAG, GRID_ROW_TAG } from './tags.js';
|
|
4
|
+
export function addBodyFocus(body, signal) {
|
|
5
|
+
const options = { signal };
|
|
6
|
+
let ownsFocus = false;
|
|
7
|
+
let focusedCell;
|
|
8
|
+
const focusBody = () => body.focus(NO_SCROLL);
|
|
9
|
+
const reclaim = () => {
|
|
10
|
+
if (ownsFocus && !body.matches(FOCUS_WITHIN)) {
|
|
11
|
+
focusBody();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
body.addEventListener('focusin', (event) => {
|
|
15
|
+
ownsFocus = true;
|
|
16
|
+
focusedCell = getElementFromEventPath(GRID_CELL_TAG, event);
|
|
17
|
+
}, options);
|
|
18
|
+
body.addEventListener('focusout', (event) => {
|
|
19
|
+
const { relatedTarget } = event;
|
|
20
|
+
if (relatedTarget instanceof Node) {
|
|
21
|
+
ownsFocus = body.contains(relatedTarget);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const [origin] = event.composedPath();
|
|
25
|
+
const row = getElementFromEventPath(GRID_ROW_TAG, event);
|
|
26
|
+
const index = row?.index;
|
|
27
|
+
queueMicrotask(() => {
|
|
28
|
+
const recycled = row !== undefined && row.index !== index;
|
|
29
|
+
ownsFocus = recycled || !origin.isConnected;
|
|
30
|
+
reclaim();
|
|
31
|
+
});
|
|
32
|
+
}, options);
|
|
33
|
+
body.addEventListener(SCROLL_STATE_CHANGE, async () => {
|
|
34
|
+
if (!ownsFocus) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const cell = focusedCell;
|
|
38
|
+
await cell?.row.updateComplete;
|
|
39
|
+
if (cell?.matches(':focus') && !cell.active) {
|
|
40
|
+
focusBody();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
reclaim();
|
|
44
|
+
}, options);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=body-focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body-focus.js","sourceRoot":"","sources":["../../src/internal/body-focus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAOxD,MAAM,UAAU,YAAY,CAAC,IAAiB,EAAE,MAAmB;IACjE,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,CAAC;IAC3B,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,WAAgD,CAAC;IAErD,MAAM,SAAS,GAAG,GAAS,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEpD,MAAM,OAAO,GAAG,GAAS,EAAE;QACzB,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAC7C,SAAS,EAAE,CAAC;QACd,CAAC;IACH,CAA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C;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,EACD,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["import type IgcGridLiteCell from '../components/cell.js';\nimport type IgcGridLiteRow from '../components/row.js';\nimport { FOCUS_WITHIN, NO_SCROLL, SCROLL_STATE_CHANGE } from './constants.js';\nimport { getElementFromEventPath } from './element-from-event-path.js';\nimport { GRID_CELL_TAG, GRID_ROW_TAG } from './tags.js';\n\n/**\n * Keeps focus in the body across row recycling. `igc-virtual-scroll` reuses the\n * element of a leaving row, so the focused cell may show another row or drop\n * focus. Listeners live until `signal` aborts.\n */\nexport function addBodyFocus(body: HTMLElement, signal: AbortSignal): void {\n const options = { signal };\n let ownsFocus = false;\n let focusedCell: IgcGridLiteCell<object> | undefined;\n\n const focusBody = (): void => body.focus(NO_SCROLL);\n\n const reclaim = (): void => {\n if (ownsFocus && !body.matches(FOCUS_WITHIN)) {\n focusBody();\n }\n };\n\n body.addEventListener(\n 'focusin',\n (event) => {\n ownsFocus = true;\n focusedCell = getElementFromEventPath(GRID_CELL_TAG, event);\n },\n options\n );\n\n body.addEventListener(\n 'focusout',\n (event: FocusEvent) => {\n const { relatedTarget } = event;\n\n if (relatedTarget instanceof Node) {\n ownsFocus = body.contains(relatedTarget);\n return;\n }\n\n // No new target: a click on empty space, or the focused row was removed or\n // recycled (still connected, new index). Tell them apart after a microtask.\n const [origin] = event.composedPath();\n const row = getElementFromEventPath<IgcGridLiteRow<object>>(GRID_ROW_TAG, event);\n const index = row?.index;\n\n queueMicrotask(() => {\n const recycled = row !== undefined && row.index !== index;\n\n ownsFocus = recycled || !(origin as Node).isConnected;\n reclaim();\n });\n },\n options\n );\n\n // A window change can recycle the focused cell onto another row.\n body.addEventListener(\n SCROLL_STATE_CHANGE,\n async () => {\n if (!ownsFocus) {\n return;\n }\n\n const cell = focusedCell;\n await cell?.row.updateComplete;\n\n if (cell?.matches(':focus') && !cell.active) {\n focusBody();\n return;\n }\n\n reclaim();\n },\n options\n );\n}\n"]}
|
package/internal/constants.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ 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
6
|
export declare const FOCUS_WITHIN = ":focus-within";
|
|
7
|
+
/** Focus without scrolling: the grid scrolls through the virtualizer. */
|
|
8
|
+
export declare const NO_SCROLL: FocusOptions;
|
|
9
|
+
/** `igc-virtual-scroll` event: the rendered window or the scroll size changed. */
|
|
10
|
+
export declare const SCROLL_STATE_CHANGE = "igcStateChange";
|
|
8
11
|
export declare const SENTINEL_NODE: Readonly<ActiveNode<any>>;
|
|
9
12
|
export declare const DEFAULT_COLUMN_CONFIG: Readonly<ColumnConfiguration<any>>;
|
package/internal/constants.js
CHANGED
|
@@ -5,6 +5,8 @@ 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
7
|
export const FOCUS_WITHIN = ':focus-within';
|
|
8
|
+
export const NO_SCROLL = { preventScroll: true };
|
|
9
|
+
export const SCROLL_STATE_CHANGE = 'igcStateChange';
|
|
8
10
|
export const SENTINEL_NODE = Object.freeze({
|
|
9
11
|
column: NON_EXISTING_COLUMN,
|
|
10
12
|
row: -1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/internal/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/internal/constants.ts"],"names":[],"mappings":"AAGA,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;AAEvC,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAG5C,MAAM,CAAC,MAAM,SAAS,GAAiB,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AAG/D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,gBAAkE,CAAC;AAErE,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 { IgcVirtualScrollComponentEventMap } from 'igniteui-webcomponents';\nimport 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\nexport const FOCUS_WITHIN = ':focus-within';\n\n/** Focus without scrolling: the grid scrolls through the virtualizer. */\nexport const NO_SCROLL: FocusOptions = { preventScroll: true };\n\n/** `igc-virtual-scroll` event: the rendered window or the scroll size changed. */\nexport const SCROLL_STATE_CHANGE =\n 'igcStateChange' satisfies keyof IgcVirtualScrollComponentEventMap;\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,2 +1,2 @@
|
|
|
1
|
-
declare function getElementFromEventPath<T extends Element>(
|
|
1
|
+
declare function getElementFromEventPath<T extends Element>(selector: string, event: Event): T | undefined;
|
|
2
2
|
export { getElementFromEventPath };
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return node instanceof Element;
|
|
4
|
-
}
|
|
5
|
-
function getElementFromEventPath(predicate, event) {
|
|
6
|
-
const callback = isString(predicate)
|
|
7
|
-
? (element) => element.matches(predicate)
|
|
8
|
-
: (element) => predicate(element);
|
|
9
|
-
return Iterator.from(event.composedPath()).filter(isElement).find(callback);
|
|
1
|
+
function getElementFromEventPath(selector, event) {
|
|
2
|
+
return Iterator.from(event.composedPath()).find((node) => node instanceof Element && node.matches(selector));
|
|
10
3
|
}
|
|
11
4
|
export { getElementFromEventPath };
|
|
12
5
|
//# sourceMappingURL=element-from-event-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-from-event-path.js","sourceRoot":"","sources":["../../src/internal/element-from-event-path.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"element-from-event-path.js","sourceRoot":"","sources":["../../src/internal/element-from-event-path.ts"],"names":[],"mappings":"AAAA,SAAS,uBAAuB,CAAoB,QAAgB,EAAE,KAAY;IAChF,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAC7C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAC3C,CAAC;AACrB,CAAC;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["function getElementFromEventPath<T extends Element>(selector: string, event: Event): T | undefined {\n return Iterator.from(event.composedPath()).find(\n (node) => node instanceof Element && node.matches(selector)\n ) as T | undefined;\n}\n\nexport { getElementFromEventPath };\n"]}
|
package/internal/tags.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const GRID_TAG: "igc-grid-lite";
|
|
2
|
-
export declare const GRID_VIRTUALIZER_TAG: "igc-grid-lite-virtualizer";
|
|
3
2
|
export declare const GRID_HEADER_ROW_TAG: "igc-grid-lite-header-row";
|
|
4
3
|
export declare const GRID_HEADER_TAG: "igc-grid-lite-header";
|
|
5
4
|
export declare const GRID_ROW_TAG: "igc-grid-lite-row";
|
package/internal/tags.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export const GRID_TAG = 'igc-grid-lite';
|
|
2
|
-
export const GRID_VIRTUALIZER_TAG = 'igc-grid-lite-virtualizer';
|
|
3
2
|
export const GRID_HEADER_ROW_TAG = 'igc-grid-lite-header-row';
|
|
4
3
|
export const GRID_HEADER_TAG = 'igc-grid-lite-header';
|
|
5
4
|
export const GRID_ROW_TAG = 'igc-grid-lite-row';
|
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,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_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
|
@@ -6,13 +6,12 @@ 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
8
|
export type GridHost<T extends object> = ReactiveControllerHost & IgcGridLite<T>;
|
|
9
|
+
type ThemeStyles = {
|
|
10
|
+
[K in Theme | 'shared']?: CSSResult;
|
|
11
|
+
};
|
|
9
12
|
export type Themes = {
|
|
10
|
-
light:
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
dark: {
|
|
14
|
-
[K in Theme | 'shared']?: CSSResult;
|
|
15
|
-
};
|
|
13
|
+
light: ThemeStyles;
|
|
14
|
+
dark: ThemeStyles;
|
|
16
15
|
};
|
|
17
16
|
type FlatKeys<T> = keyof T;
|
|
18
17
|
type NonTraversable = ((...args: never) => unknown) | Array<unknown> | Date | RegExp | Map<unknown, unknown> | Set<unknown> | Promise<unknown>;
|
|
@@ -92,7 +91,7 @@ export interface BaseColumnConfiguration<T extends object, K extends Keys<T> = K
|
|
|
92
91
|
*/
|
|
93
92
|
hidden?: boolean;
|
|
94
93
|
/**
|
|
95
|
-
* Whether the
|
|
94
|
+
* Whether the column can be resized or not.
|
|
96
95
|
*/
|
|
97
96
|
resizable?: boolean;
|
|
98
97
|
/**
|
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 GridHost<T extends object> = ReactiveControllerHost & IgcGridLite<T>;\n\
|
|
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\ntype ThemeStyles = { [K in Theme | 'shared']?: CSSResult };\n\nexport type Themes = { light: ThemeStyles; dark: ThemeStyles };\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]>}` // `never` collapses invalid 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 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,16 +1,12 @@
|
|
|
1
1
|
import type { StyleInfo } from 'lit/directives/style-map.js';
|
|
2
2
|
import type { FilterOperation } from '../operations/filter/types.js';
|
|
3
3
|
import type { ColumnConfiguration, Keys, PropertyType } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Resolves a value from an object using a path string.
|
|
6
|
-
* Supports nested properties using dot notation (e.g., 'prop.nestedProp').
|
|
7
|
-
*
|
|
8
|
-
* @param obj - The object to resolve the value from.
|
|
9
|
-
* @param path - The path to the property, can be a simple key or dot-separated path.
|
|
10
|
-
* @returns The resolved value, or undefined if the path cannot be resolved.
|
|
11
|
-
*/
|
|
4
|
+
/** Resolves `path` on `obj`. Dot paths reach nested props (`'a.b'`). Undefined when unresolvable. */
|
|
12
5
|
export declare function resolveFieldValue<T>(obj: T, path: Keys<T>): PropertyType<T>;
|
|
6
|
+
/** The columns rows render. Navigation, ARIA and track sizes share this sequence. */
|
|
7
|
+
export declare function visibleColumns<T extends object>(columns: ColumnConfiguration<T>[]): ColumnConfiguration<T>[];
|
|
13
8
|
export declare function applyColumnWidths<T extends object>(columns: Array<ColumnConfiguration<T>>): StyleInfo;
|
|
9
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
14
10
|
export declare function isBoolean(x: unknown): x is boolean;
|
|
15
11
|
export declare function isNumber(x: unknown): x is number;
|
|
16
12
|
export declare function isString(x: unknown): x is string;
|
package/internal/utils.js
CHANGED
|
@@ -22,12 +22,16 @@ export function resolveFieldValue(obj, path) {
|
|
|
22
22
|
}
|
|
23
23
|
return obj[path];
|
|
24
24
|
}
|
|
25
|
+
export function visibleColumns(columns) {
|
|
26
|
+
return columns.filter((column) => !column.hidden);
|
|
27
|
+
}
|
|
25
28
|
export function applyColumnWidths(columns) {
|
|
26
|
-
const widths = columns
|
|
27
|
-
.filter((each) => !each.hidden)
|
|
28
|
-
.map((each) => each.width ?? DEFAULT_COLUMN_WIDTH);
|
|
29
|
+
const widths = visibleColumns(columns).map((each) => each.width ?? DEFAULT_COLUMN_WIDTH);
|
|
29
30
|
return { 'grid-template-columns': widths.join(' ') };
|
|
30
31
|
}
|
|
32
|
+
export function clamp(value, min, max) {
|
|
33
|
+
return Math.min(Math.max(value, min), max);
|
|
34
|
+
}
|
|
31
35
|
export function isBoolean(x) {
|
|
32
36
|
return typeof x === 'boolean';
|
|
33
37
|
}
|
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;AAIzE,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAElD,SAAS,SAAS,CAAC,MAAe;IAChC,OAAO,MAAM,IAAI,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC;AACtD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AAU,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, DataType, 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/** Dot-path segment cache: sort and filter resolve the same few paths per record. */\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/** Resolves `path` on `obj`. Dot paths reach nested props (`'a.b'`). Undefined when unresolvable. */\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\n/** The columns rows render. Navigation, ARIA and track sizes share this sequence. */\nexport function visibleColumns<T extends object>(\n columns: ColumnConfiguration<T>[]\n): ColumnConfiguration<T>[] {\n return columns.filter((column) => !column.hidden);\n}\n\nexport function applyColumnWidths<T extends object>(\n columns: Array<ColumnConfiguration<T>>\n): StyleInfo {\n const widths = visibleColumns(columns).map((each) => each.width ?? DEFAULT_COLUMN_WIDTH);\n\n return { 'grid-template-columns': widths.join(' ') };\n}\n\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\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 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): DataType {\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/operations/base.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { normalizeCase } from '../internal/normalize-case.js';
|
|
2
|
-
import { resolveFieldValue } from '../internal/utils.js';
|
|
2
|
+
import { isString, resolveFieldValue } from '../internal/utils.js';
|
|
3
3
|
export default class DataOperation {
|
|
4
4
|
resolveValue(record, key) {
|
|
5
5
|
return resolveFieldValue(record, key);
|
|
6
6
|
}
|
|
7
7
|
resolveCase(value, caseSensitive) {
|
|
8
|
-
return
|
|
8
|
+
return isString(value) ? normalizeCase(value, caseSensitive) : value;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
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":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
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,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEnE,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,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,aAAa,CAAC,KAAK,EAAE,aAAa,CAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9E,CAAC;CAGF","sourcesContent":["import { normalizeCase } from '../internal/normalize-case.js';\nimport type { Keys, PropertyType } from '../internal/types.js';\nimport { isString, 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 isString(value) ? (normalizeCase(value, caseSensitive) as U) : value;\n }\n\n public abstract apply(...args: unknown[]): T[];\n}\n"]}
|
|
@@ -5,7 +5,6 @@ export declare class FilterState<T> {
|
|
|
5
5
|
protected state: Map<Keys<T>, FilterExpressionTree<T>>;
|
|
6
6
|
get empty(): boolean;
|
|
7
7
|
get values(): FilterExpressionTree<T>[];
|
|
8
|
-
has(key: Keys<T>): boolean;
|
|
9
8
|
get(key: Keys<T>): FilterExpressionTree<T> | undefined;
|
|
10
9
|
delete(key: Keys<T>): boolean;
|
|
11
10
|
clear(): void;
|
|
@@ -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;IA0BrE,CAAC;IAxBC,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,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 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"]}
|
|
@@ -43,7 +43,7 @@ export interface BaseFilterExpression<T, K extends Keys<T> = Keys<T>> {
|
|
|
43
43
|
*/
|
|
44
44
|
criteria?: FilterCriteria;
|
|
45
45
|
/**
|
|
46
|
-
* Whether the
|
|
46
|
+
* Whether the filter operation should be case sensitive.
|
|
47
47
|
*
|
|
48
48
|
* @remarks
|
|
49
49
|
* If not provided, the value is resolved based on the column filter configuration (if any).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/operations/filter/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Keys, PropertyType } from '../../internal/types.js';\nimport type { BooleanOperands } from './operands/boolean.js';\nimport type { NumberOperands } from './operands/number.js';\nimport type { StringOperands } from './operands/string.js';\n\n/**\n * Controls how a data record should resolve in a filter operation:\n * - `'and'` - the record must pass all the conditions.\n * - `'or'` - the record must pass at least one condition.\n */\nexport type FilterCriteria = 'and' | 'or';\n\nexport type FilterOperationLogic<T> = (\n target: T,\n searchTerm: T,\n caseSensitive?: boolean\n) => boolean;\n\nexport interface FilterOperation<T> {\n name: string;\n label?: string;\n unary: boolean;\n logic: FilterOperationLogic<T>;\n}\n\nexport type FilterOperands<DataType, Operands extends string> = {\n [key in Operands]: FilterOperation<DataType>;\n};\n\n/**\n * Represents a filter operation for a given column.\n */\nexport interface BaseFilterExpression<T, K extends Keys<T> = Keys<T>> {\n /**\n * The target column for the filter operation.\n */\n key: K;\n /**\n * The filter function which will be executed against the data records.\n */\n condition: FilterOperation<PropertyType<T, K>> | OperandKeys<PropertyType<T, K>>;\n\n /**\n * The filtering value used in the filter condition function.\n *\n * @remarks\n * Optional for unary conditions.\n */\n searchTerm?: PropertyType<T, K>;\n /**\n * Dictates how this expression should resolve in the filter operation in relation to\n * other expressions.\n */\n criteria?: FilterCriteria;\n /**\n * Whether the
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/operations/filter/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Keys, PropertyType } from '../../internal/types.js';\nimport type { BooleanOperands } from './operands/boolean.js';\nimport type { NumberOperands } from './operands/number.js';\nimport type { StringOperands } from './operands/string.js';\n\n/**\n * Controls how a data record should resolve in a filter operation:\n * - `'and'` - the record must pass all the conditions.\n * - `'or'` - the record must pass at least one condition.\n */\nexport type FilterCriteria = 'and' | 'or';\n\nexport type FilterOperationLogic<T> = (\n target: T,\n searchTerm: T,\n caseSensitive?: boolean\n) => boolean;\n\nexport interface FilterOperation<T> {\n name: string;\n label?: string;\n unary: boolean;\n logic: FilterOperationLogic<T>;\n}\n\nexport type FilterOperands<DataType, Operands extends string> = {\n [key in Operands]: FilterOperation<DataType>;\n};\n\n/**\n * Represents a filter operation for a given column.\n */\nexport interface BaseFilterExpression<T, K extends Keys<T> = Keys<T>> {\n /**\n * The target column for the filter operation.\n */\n key: K;\n /**\n * The filter function which will be executed against the data records.\n */\n condition: FilterOperation<PropertyType<T, K>> | OperandKeys<PropertyType<T, K>>;\n\n /**\n * The filtering value used in the filter condition function.\n *\n * @remarks\n * Optional for unary conditions.\n */\n searchTerm?: PropertyType<T, K>;\n /**\n * Dictates how this expression should resolve in the filter operation in relation to\n * other expressions.\n */\n criteria?: FilterCriteria;\n /**\n * Whether the filter operation should be case sensitive.\n *\n * @remarks\n * If not provided, the value is resolved based on the column filter configuration (if any).\n */\n caseSensitive?: boolean;\n}\n\n/**\n * See {@link BaseFilterExpression} for the full documentation.\n */\nexport type FilterExpression<T = any, K extends Keys<T> = Keys<T>> =\n K extends Keys<T> ? BaseFilterExpression<T, K> : never;\n\nexport type OperandKeys<Type> = Type extends number\n ? keyof typeof NumberOperands\n : Type extends string\n ? keyof typeof StringOperands\n : Type extends boolean\n ? keyof typeof BooleanOperands\n : Type;\n"]}
|
package/operations/filter.js
CHANGED
|
@@ -9,7 +9,7 @@ export default class FilterDataOperation extends DataOperation {
|
|
|
9
9
|
return condition.logic(this.resolveValue(record, expr.key), expr.searchTerm, expr.caseSensitive);
|
|
10
10
|
}
|
|
11
11
|
matchTree(record, ors, ands) {
|
|
12
|
-
if (ors.
|
|
12
|
+
if (ors.some((expr) => this.resolveFilter(record, expr))) {
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
15
|
if (ands.length === 0) {
|
|
@@ -18,8 +18,9 @@ export default class FilterDataOperation extends DataOperation {
|
|
|
18
18
|
return ands.every((expr) => this.resolveFilter(record, expr));
|
|
19
19
|
}
|
|
20
20
|
apply(data, state) {
|
|
21
|
-
if (state.empty)
|
|
21
|
+
if (state.empty) {
|
|
22
22
|
return data;
|
|
23
|
+
}
|
|
23
24
|
const trees = state.values
|
|
24
25
|
.map((tree) => ({ ors: tree.ors.filter(isResolved), ands: tree.ands.filter(isResolved) }))
|
|
25
26
|
.filter(({ ors, ands }) => ors.length > 0 || ands.length > 0);
|
package/operations/filter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/operations/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,aAAa,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/operations/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,aAAa,MAAM,WAAW,CAAC;AAKtC,SAAS,UAAU,CAAmB,UAA+B;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,mBAAsC,SAAQ,aAAgB;IACvE,aAAa,CAAC,MAAS,EAAE,IAAyB;QAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,SAA+B,CAAC;QACvD,OAAO,SAAS,CAAC,KAAK,CACpB,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAM,EACxC,IAAI,CAAC,UAAe,EACpB,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;IAES,SAAS,CAAC,MAAS,EAAE,GAA0B,EAAE,IAA2B;QACpF,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;QAGD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;QAC1B,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IAEM,KAAK,CAAC,IAAS,EAAE,KAAqB;QAC3C,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;QAGD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM;aACvB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;aACzF,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEhE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAC5B,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAClE,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { isString } from '../internal/utils.js';\nimport DataOperation from './base.js';\nimport type { FilterState } from './filter/state.js';\nimport type { FilterExpression, FilterOperation } from './filter/types.js';\n\n/** A string condition waits for its column to resolve it. Without one, skip it. */\nfunction isResolved<T extends object>(expression: FilterExpression<T>): boolean {\n return !isString(expression.condition);\n}\n\nexport default class FilterDataOperation<T extends object> extends DataOperation<T> {\n protected resolveFilter(record: T, expr: FilterExpression<T>) {\n const condition = expr.condition as FilterOperation<T>;\n return condition.logic(\n this.resolveValue(record, expr.key) as T,\n expr.searchTerm as T,\n expr.caseSensitive\n );\n }\n\n protected matchTree(record: T, ors: FilterExpression<T>[], ands: FilterExpression<T>[]): boolean {\n if (ors.some((expr) => this.resolveFilter(record, expr))) {\n return true;\n }\n\n // No ANDs: the ORs decide alone (`every([])` is true).\n if (ands.length === 0) {\n return ors.length === 0;\n }\n\n return ands.every((expr) => this.resolveFilter(record, expr));\n }\n\n public apply(data: T[], state: FilterState<T>): T[] {\n if (state.empty) {\n return data;\n }\n\n // Split once per tree, not per record. Drop trees with nothing runnable.\n const trees = state.values\n .map((tree) => ({ ors: tree.ors.filter(isResolved), ands: tree.ands.filter(isResolved) }))\n .filter(({ ors, ands }) => ors.length > 0 || ands.length > 0);\n\n if (trees.length === 0) {\n return data;\n }\n\n return data.filter((record) =>\n trees.every(({ ors, ands }) => this.matchTree(record, ors, ands))\n );\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import type { Keys, PropertyType } from '../../internal/types.js';
|
|
|
3
3
|
* Sort direction for a given sort expression.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* `none`
|
|
6
|
+
* `none` clears the sort of the column.
|
|
7
7
|
*/
|
|
8
8
|
export type SortingDirection = 'ascending' | 'descending' | 'none';
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/operations/sort/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Keys, PropertyType } from '../../internal/types.js';\n\n/**\n * Sort direction for a given sort expression.\n *\n * @remarks\n * `none`
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/operations/sort/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Keys, PropertyType } from '../../internal/types.js';\n\n/**\n * Sort direction for a given sort expression.\n *\n * @remarks\n * `none` clears the sort of the column.\n */\nexport type SortingDirection = 'ascending' | 'descending' | 'none';\n\n/**\n * Custom comparer function for a given column used when sorting is performed.\n */\nexport type BaseSortComparer<T, K extends Keys<T> = Keys<T>> = (\n a: PropertyType<T, K>,\n b: PropertyType<T, K>\n) => number;\n\n/**\n * See {@link BaseSortComparer} for the full documentation.\n */\nexport type SortComparer<T, K extends Keys<T> = Keys<T>> =\n K extends Keys<T> ? BaseSortComparer<T, K> : never;\n\n/**\n * Represents a sort operation for a given column.\n */\nexport interface BaseSortingExpression<T, K extends Keys<T> = Keys<T>> {\n /**\n * The target column.\n */\n key: K;\n /**\n * Sort direction for this operation.\n */\n direction: SortingDirection;\n /**\n * Whether the sort operation should be case sensitive.\n *\n * @remarks\n * If not provided, the value is resolved based on the column sort configuration (if any).\n */\n caseSensitive?: boolean;\n /**\n * Custom comparer function for this operation.\n *\n * @remarks\n * If not provided, the value is resolved based on the column sort configuration (if any).\n */\n comparer?: SortComparer<T, K>;\n}\n\n/**\n * See {@link BaseSortingExpression} for the full documentation.\n */\nexport type SortingExpression<T = any, K extends Keys<T> = Keys<T>> =\n K extends Keys<T> ? BaseSortingExpression<T, K> : never;\n\n/** Represents the sort state of the grid. */\nexport type SortState<T> = Map<Keys<T>, SortingExpression<T>>;\n"]}
|
package/operations/sort.js
CHANGED
|
@@ -12,9 +12,13 @@ export default class SortDataOperation extends DataOperation {
|
|
|
12
12
|
return first > second ? 1 : first < second ? -1 : 0;
|
|
13
13
|
}
|
|
14
14
|
apply(data, state) {
|
|
15
|
+
if (state.size === 0) {
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
15
18
|
const expressions = Array.from(state.values());
|
|
16
19
|
const length = expressions.length;
|
|
17
20
|
const multipliers = expressions.map(({ direction }) => DIRECTION_MULTIPLIERS[direction]);
|
|
21
|
+
const comparers = expressions.map(({ comparer }) => comparer);
|
|
18
22
|
const transformed = data.map((item) => {
|
|
19
23
|
const tuple = new Array(length + 1);
|
|
20
24
|
tuple[0] = item;
|
|
@@ -32,7 +36,7 @@ export default class SortDataOperation extends DataOperation {
|
|
|
32
36
|
const keyB = b[i + 1];
|
|
33
37
|
result =
|
|
34
38
|
multipliers[i] *
|
|
35
|
-
(
|
|
39
|
+
(comparers[i]?.(keyA, keyB) ?? this.compareValues(keyA, keyB));
|
|
36
40
|
i++;
|
|
37
41
|
}
|
|
38
42
|
return result;
|
package/operations/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../src/operations/sort.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,WAAW,CAAC;AAItC,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;AAErC,MAAM,qBAAqB,GAA2B;IACpD,SAAS,EAAE,CAAC;IACZ,UAAU,EAAE,CAAC,CAAC;CACf,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,iBAAqB,SAAQ,aAAgB;IACtD,aAAa,CAAI,KAAQ,EAAE,MAAS;QAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC5D,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IAEM,KAAK,CAAC,IAAS,EAAE,KAAmB;QACzC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;QAGlC,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAA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,EAAE,CAAC,KAAK,CAAC,CAAC,CAAM,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["import DataOperation from './base.js';\nimport type { SortState } from './sort/types.js';\n\n// One shared collator: `localeCompare` builds one per call.\nconst collator = new Intl.Collator();\n\nconst DIRECTION_MULTIPLIERS: Record<string, number> = {\n ascending: 1,\n descending: -1,\n};\n\nexport default class SortDataOperation<T> extends DataOperation<T> {\n protected compareValues<U>(first: U, second: U) {\n if (typeof first === 'string' && typeof second === 'string') {\n return collator.compare(first, second);\n }\n return first > second ? 1 : first < second ? -1 : 0;\n }\n\n public apply(data: T[], state: SortState<T>) {\n if (state.size === 0) {\n return data;\n }\n\n const expressions = Array.from(state.values());\n const length = expressions.length;\n\n // Resolved once, not per comparison.\n const multipliers = expressions.map(({ direction }) => DIRECTION_MULTIPLIERS[direction]);\n const comparers = expressions.map(({ comparer }) => comparer);\n\n // Flat tuples [item, key0, key1, ...]: keys resolve once, no per-row objects.\n const transformed = data.map((item) => {\n const tuple: unknown[] = new Array(length + 1);\n tuple[0] = item;\n for (let i = 0; i < length; i++) {\n const { key, caseSensitive } = expressions[i];\n tuple[i + 1] = this.resolveCase(this.resolveValue(item, key), caseSensitive);\n }\n return tuple;\n });\n\n transformed.sort((a, b) => {\n let i = 0;\n let result = 0;\n\n while (i < length && !result) {\n const keyA = a[i + 1];\n const keyB = b[i + 1];\n result =\n multipliers[i] *\n (comparers[i]?.(keyA as any, keyB as any) ?? this.compareValues(keyA, keyB));\n i++;\n }\n\n return result;\n });\n\n return transformed.map((tuple) => tuple[0] as T);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "igniteui-grid-lite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Web component data grid following open-wc recommendations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit",
|
|
@@ -33,9 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"customElements": "custom-elements.json",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@lit-labs/virtualizer": "~2.1.0",
|
|
37
36
|
"@lit/context": "~1.1.5",
|
|
38
|
-
"igniteui-webcomponents": "~7.
|
|
37
|
+
"igniteui-webcomponents": "~7.4.1",
|
|
39
38
|
"lit": "^3.3.0"
|
|
40
39
|
}
|
|
41
40
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const styles = css `:host{position:relative;box-sizing:border-box;scrollbar-width:var(--ig-scrollbar-size, var(--sb-size));scrollbar-color:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color)) var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar{width:var(--ig-scrollbar-size, var(--sb-size));height:var(--ig-scrollbar-size, var(--sb-size));background:var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar-thumb{background:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color))}:host *,:host *::before,:host *::after{box-sizing:border-box}:host{display:flex;align-items:center;position:relative;border-inline-end:var(--header-border-width) var(--header-border-style) var(--header-border-color);font-size:0.75rem;min-height:var(--header-size)}:host(:last-of-type){border-inline-end:none}[part~=content]{display:flex;align-items:center;justify-content:space-between;width:100%;height:100%;padding:0 max(var(--is-large, 1)*max(1.5rem, -1 * 1.5rem),var(--is-medium, 1)*max(1rem, -1 * 1rem),var(--is-small, 1)*max(0.5rem, -1 * 0.5rem));overflow:hidden;-webkit-user-select:none;-moz-user-select:none;user-select:none}[part~=title]{display:block;position:relative;cursor:initial;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;font-weight:600;min-width:3ch}[part~=actions]{display:flex;gap:.25rem;align-items:center}[part~=action]{cursor:pointer;opacity:.7;transition:opacity .25s ease-in-out}[part~=action]:hover,[part~=action]:focus{opacity:1}[part~=action] igc-icon{--size: 0.9375rem}[part~=action] igc-icon::after{content:attr(data-sortIndex);position:absolute;top:-5px;inset-inline-end:-1px;font-size:.625rem;text-align:end;font-family:sans-serif;line-height:.625rem}[part~=sorted]
|
|
2
|
+
export const styles = css `:host{position:relative;box-sizing:border-box;scrollbar-width:var(--ig-scrollbar-size, var(--sb-size));scrollbar-color:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color)) var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar{width:var(--ig-scrollbar-size, var(--sb-size));height:var(--ig-scrollbar-size, var(--sb-size));background:var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar-thumb{background:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color))}:host *,:host *::before,:host *::after{box-sizing:border-box}:host{display:flex;align-items:center;position:relative;border-inline-end:var(--header-border-width) var(--header-border-style) var(--header-border-color);font-size:0.75rem;min-height:var(--header-size)}:host(:last-of-type){border-inline-end:none}[part~=content]{display:flex;align-items:center;justify-content:space-between;width:100%;height:100%;padding:0 max(var(--is-large, 1)*max(1.5rem, -1 * 1.5rem),var(--is-medium, 1)*max(1rem, -1 * 1rem),var(--is-small, 1)*max(0.5rem, -1 * 0.5rem));overflow:hidden;-webkit-user-select:none;-moz-user-select:none;user-select:none}[part~=title]{display:block;position:relative;cursor:initial;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;font-weight:600;min-width:3ch}[part~=actions]{display:flex;gap:.25rem;align-items:center}[part~=action]{cursor:pointer;opacity:.7;transition:opacity .25s ease-in-out}[part~=action]:hover,[part~=action]:focus{opacity:1}[part~=action] igc-icon{--size: 0.9375rem}[part~=action] igc-icon::after{content:attr(data-sortIndex);position:absolute;top:-5px;inset-inline-end:-1px;font-size:.625rem;text-align:end;font-family:sans-serif;line-height:.625rem}[part~=sorted]{color:var(--sorted-header-icon-color)}[part~=sorted] igc-icon{color:inherit}[part~=resizable]{width:.25rem;height:100%;position:absolute;inset-inline-end:-0.125rem;z-index:var(--z-index-base);cursor:col-resize}`;
|
|
3
3
|
//# sourceMappingURL=header-cell.css.js.map
|