igniteui-grid-lite 0.9.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 +11 -15
- package/components/cell.js +14 -3
- 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 +5 -3
- package/components/filter-row.js +97 -67
- package/components/filter-row.js.map +1 -1
- package/components/grid.d.ts +49 -8
- package/components/grid.js +116 -79
- package/components/grid.js.map +1 -1
- package/components/header-row.d.ts +1 -2
- package/components/header-row.js +6 -8
- package/components/header-row.js.map +1 -1
- package/components/header.d.ts +9 -0
- package/components/header.js +37 -28
- package/components/header.js.map +1 -1
- package/components/row.d.ts +4 -4
- package/components/row.js +15 -4
- package/components/row.js.map +1 -1
- package/controllers/data-operation.d.ts +1 -7
- package/controllers/data-operation.js +7 -24
- package/controllers/data-operation.js.map +1 -1
- package/controllers/dom.d.ts +16 -9
- package/controllers/dom.js +71 -20
- package/controllers/dom.js.map +1 -1
- package/controllers/filter.d.ts +17 -13
- package/controllers/filter.js +51 -61
- package/controllers/filter.js.map +1 -1
- package/controllers/navigation.d.ts +13 -18
- package/controllers/navigation.js +71 -76
- package/controllers/navigation.js.map +1 -1
- package/controllers/resize.d.ts +11 -17
- package/controllers/resize.js +20 -16
- package/controllers/resize.js.map +1 -1
- package/controllers/sort.d.ts +13 -6
- package/controllers/sort.js +39 -41
- package/controllers/sort.js.map +1 -1
- package/controllers/state.d.ts +18 -19
- package/controllers/state.js +31 -35
- package/controllers/state.js.map +1 -1
- package/custom-elements.json +970 -488
- package/docs/igniteui-grid-lite.json +1293 -782
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/internal/a11y.d.ts +26 -0
- package/internal/a11y.js +24 -0
- package/internal/a11y.js.map +1 -0
- 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 +6 -2
- package/internal/constants.js +3 -4
- 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/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 +1 -2
- package/internal/tags.js +1 -2
- package/internal/tags.js.map +1 -1
- package/internal/types.d.ts +19 -8
- package/internal/types.js.map +1 -1
- package/internal/utils.d.ts +7 -8
- package/internal/utils.js +22 -5
- package/internal/utils.js.map +1 -1
- package/internal/watch.js +8 -9
- package/internal/watch.js.map +1 -1
- package/operations/base.js +3 -2
- package/operations/base.js.map +1 -1
- package/operations/filter/state.d.ts +0 -1
- package/operations/filter/state.js +2 -8
- 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/types.d.ts +1 -1
- package/operations/filter/types.js.map +1 -1
- package/operations/filter.js +16 -3
- 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.d.ts +0 -1
- package/operations/sort.js +12 -10
- 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 -12
- package/components/virtualizer.js +0 -20
- 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/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,26 @@
|
|
|
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
|
+
/** Writes the ARIA of one grid part through ElementInternals, off the host attributes. */
|
|
11
|
+
declare class A11yController {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(host: HTMLElement, role: GridRole);
|
|
14
|
+
/** Writes ARIA state on the host. */
|
|
15
|
+
set(state: AriaState): void;
|
|
16
|
+
}
|
|
17
|
+
/** Sets the grid pattern role of `host` and returns a handle to its ARIA state. */
|
|
18
|
+
export declare function addA11y(host: HTMLElement, role: GridRole): A11yController;
|
|
19
|
+
/** Returns the ARIA semantics `element` published through its ElementInternals. */
|
|
20
|
+
export declare function ariaOf(element: Element): ARIAMixin | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Number of rows the grid renders above its data: the header row, plus the filter
|
|
23
|
+
* row when a column is filterable. Data rows are indexed after them.
|
|
24
|
+
*/
|
|
25
|
+
export declare function headerRowsFor<T extends object>(columns: ColumnConfiguration<T>[]): number;
|
|
26
|
+
export {};
|
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;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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AC,CAAC;QACjF,MAAM,KAAK,GAAG,GAAG,EAAE,KAAK,CAAC;QAEzB,cAAc,CAAC,GAAG,EAAE;YAClB,MAAM,QAAQ,GAAG,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC;YAE1D,SAAS,GAAG,QAAQ,IAAI,CAAE,MAAe,CAAC,WAAW,CAAC;YACtD,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,EACD,OAAO,CACR,CAAC;IAGF,IAAI,CAAC,gBAAgB,CACnB,mBAAmB,EACnB,KAAK,IAAI,EAAE;QACT,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,WAAW,CAAC;QACzB,MAAM,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC;QAE/B,IAAI,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5C,SAAS,EAAE,CAAC;YACZ,OAAO;QACT,CAAC;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
|
@@ -1,8 +1,12 @@
|
|
|
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
|
+
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";
|
|
6
11
|
export declare const SENTINEL_NODE: Readonly<ActiveNode<any>>;
|
|
7
12
|
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,9 @@ 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';
|
|
8
|
+
export const NO_SCROLL = { preventScroll: true };
|
|
9
|
+
export const SCROLL_STATE_CHANGE = 'igcStateChange';
|
|
7
10
|
export const SENTINEL_NODE = Object.freeze({
|
|
8
11
|
column: NON_EXISTING_COLUMN,
|
|
9
12
|
row: -1,
|
|
@@ -16,8 +19,4 @@ export const DEFAULT_COLUMN_CONFIG = Object.freeze({
|
|
|
16
19
|
sortable: false,
|
|
17
20
|
filterable: false,
|
|
18
21
|
});
|
|
19
|
-
export const NAVIGATION_STATE = new Map([
|
|
20
|
-
['previous', SENTINEL_NODE],
|
|
21
|
-
['current', SENTINEL_NODE],
|
|
22
|
-
]);
|
|
23
22
|
//# sourceMappingURL=constants.js.map
|
|
@@ -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"]}
|
|
@@ -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,CAA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C;gBACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACtB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;YAC/B,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACnB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAID,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,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,7 @@
|
|
|
1
1
|
export declare const GRID_TAG: "igc-grid-lite";
|
|
2
|
-
export declare const GRID_BODY: "igc-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";
|
|
6
5
|
export declare const GRID_CELL_TAG: "igc-grid-lite-cell";
|
|
7
|
-
export declare const GRID_FILTER_ROW_TAG: "igc-filter-row";
|
|
6
|
+
export declare const GRID_FILTER_ROW_TAG: "igc-grid-lite-filter-row";
|
|
8
7
|
export declare const GRID_COLUMN_TAG: "igc-grid-lite-column";
|
package/internal/tags.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export const GRID_TAG = 'igc-grid-lite';
|
|
2
|
-
export const GRID_BODY = 'igc-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';
|
|
6
5
|
export const GRID_CELL_TAG = 'igc-grid-lite-cell';
|
|
7
|
-
export const GRID_FILTER_ROW_TAG = 'igc-filter-row';
|
|
6
|
+
export const GRID_FILTER_ROW_TAG = 'igc-grid-lite-filter-row';
|
|
8
7
|
export const GRID_COLUMN_TAG = 'igc-grid-lite-column';
|
|
9
8
|
//# 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,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
|
@@ -5,15 +5,13 @@ 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>;
|
|
9
|
+
type ThemeStyles = {
|
|
10
|
+
[K in Theme | 'shared']?: CSSResult;
|
|
11
|
+
};
|
|
10
12
|
export type Themes = {
|
|
11
|
-
light:
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
dark: {
|
|
15
|
-
[K in Theme | 'shared']?: CSSResult;
|
|
16
|
-
};
|
|
13
|
+
light: ThemeStyles;
|
|
14
|
+
dark: ThemeStyles;
|
|
17
15
|
};
|
|
18
16
|
type FlatKeys<T> = keyof T;
|
|
19
17
|
type NonTraversable = ((...args: never) => unknown) | Array<unknown> | Date | RegExp | Map<unknown, unknown> | Set<unknown> | Promise<unknown>;
|
|
@@ -93,7 +91,7 @@ export interface BaseColumnConfiguration<T extends object, K extends Keys<T> = K
|
|
|
93
91
|
*/
|
|
94
92
|
hidden?: boolean;
|
|
95
93
|
/**
|
|
96
|
-
* Whether the
|
|
94
|
+
* Whether the column can be resized or not.
|
|
97
95
|
*/
|
|
98
96
|
resizable?: boolean;
|
|
99
97
|
/**
|
|
@@ -133,6 +131,19 @@ export interface ActiveNode<T> {
|
|
|
133
131
|
column: Keys<T>;
|
|
134
132
|
row: number;
|
|
135
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Options for the navigateTo API of the grid.
|
|
136
|
+
*/
|
|
137
|
+
export interface NavigateToOptions<T> {
|
|
138
|
+
/**
|
|
139
|
+
* The column field to navigate to. Without it, only the row scrolls into view.
|
|
140
|
+
*/
|
|
141
|
+
column?: Keys<T>;
|
|
142
|
+
/**
|
|
143
|
+
* When true, the navigated cell becomes the active cell.
|
|
144
|
+
*/
|
|
145
|
+
activate?: boolean;
|
|
146
|
+
}
|
|
136
147
|
/**
|
|
137
148
|
* Context object for the column header template callback.
|
|
138
149
|
*/
|
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\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,19 +1,18 @@
|
|
|
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
|
-
* Resolves a value from an object using a path string.
|
|
5
|
-
* Supports nested properties using dot notation (e.g., 'prop.nestedProp').
|
|
6
|
-
*
|
|
7
|
-
* @param obj - The object to resolve the value from.
|
|
8
|
-
* @param path - The path to the property, can be a simple key or dot-separated path.
|
|
9
|
-
* @returns The resolved value, or undefined if the path cannot be resolved.
|
|
10
|
-
*/
|
|
4
|
+
/** Resolves `path` on `obj`. Dot paths reach nested props (`'a.b'`). Undefined when unresolvable. */
|
|
11
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>[];
|
|
12
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;
|
|
13
10
|
export declare function isBoolean(x: unknown): x is boolean;
|
|
14
11
|
export declare function isNumber(x: unknown): x is number;
|
|
15
12
|
export declare function isString(x: unknown): x is string;
|
|
16
13
|
export declare function asArray<T>(value: T | T[]): T[];
|
|
17
14
|
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>>;
|
|
15
|
+
/** Resolves a raw operand name (e.g. 'contains') to the column's filter operation. */
|
|
16
|
+
export declare function resolveCondition<T extends object>(column: ColumnConfiguration<T>, name: string): FilterOperation<any>;
|
|
18
17
|
export declare function setColumnsFromData<T extends object>(record: T): Array<ColumnConfiguration<T>>;
|
|
19
18
|
export declare function createColumnConfiguration<T extends object>(config: Partial<ColumnConfiguration<T>>): ColumnConfiguration<T>;
|
package/internal/utils.js
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
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
|
}
|
|
25
|
+
export function visibleColumns(columns) {
|
|
26
|
+
return columns.filter((column) => !column.hidden);
|
|
27
|
+
}
|
|
15
28
|
export function applyColumnWidths(columns) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
const widths = visibleColumns(columns).map((each) => each.width ?? DEFAULT_COLUMN_WIDTH);
|
|
30
|
+
return { 'grid-template-columns': widths.join(' ') };
|
|
31
|
+
}
|
|
32
|
+
export function clamp(value, min, max) {
|
|
33
|
+
return Math.min(Math.max(value, min), max);
|
|
20
34
|
}
|
|
21
35
|
export function isBoolean(x) {
|
|
22
36
|
return typeof x === 'boolean';
|
|
@@ -40,6 +54,9 @@ export function getFilterOperandsFor(column) {
|
|
|
40
54
|
return StringOperands;
|
|
41
55
|
}
|
|
42
56
|
}
|
|
57
|
+
export function resolveCondition(column, name) {
|
|
58
|
+
return getFilterOperandsFor(column)[name];
|
|
59
|
+
}
|
|
43
60
|
function getColumnType(value) {
|
|
44
61
|
if (isBoolean(value)) {
|
|
45
62
|
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,oB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,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAmB,MAAS;IAC5D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACjD,OAAO,yBAAyB,CAAI;YAClC,KAAK,EAAE,GAAc;YACrB,QAAQ,EAAE,aAAa,CAAC,KAAK,CAAC;SACI,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,MAAuC;IAEvC,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,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, 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/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"]}
|