Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .github/workflows/module-size-comparison.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- 'latest'
- 'b[0-9][0-9]?.[0-9][0-9]?.[0-9][0-9]?'
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -36,6 +37,7 @@ jobs:
pr-number: ${{ steps.resolve.outputs.pr-number }}
head-sha: ${{ steps.resolve.outputs.head-sha }}
is-draft: ${{ steps.resolve.outputs.is-draft }}
base-ref: ${{ steps.resolve.outputs.base-ref }}
shard-matrix: ${{ steps.resolve.outputs.shard-matrix }}
steps:
- name: Resolve PR details
Expand All @@ -55,6 +57,7 @@ jobs:
core.setOutput('pr-number', pr.number.toString());
core.setOutput('head-sha', pr.head.sha);
core.setOutput('is-draft', pr.draft ? 'true' : 'false');
core.setOutput('base-ref', pr.base.ref);
return;
}

Expand All @@ -79,6 +82,7 @@ jobs:
core.setOutput('pr-number', pr.number.toString());
core.setOutput('head-sha', pr.head.sha);
core.setOutput('is-draft', pr.draft ? 'true' : 'false');
core.setOutput('base-ref', pr.base.ref);

# Check for cached base results
check-base-cache:
Expand All @@ -88,14 +92,15 @@ jobs:
if: needs.prepare.outputs.is-draft != 'true'
outputs:
cache-hit: ${{ steps.cache-check.outputs.cache-hit }}
latest-sha: ${{ steps.get-sha.outputs.sha }}
base-sha: ${{ steps.get-sha.outputs.sha }}
steps:
- name: Get latest branch SHA
- name: Get base branch SHA
id: get-sha
run: |
SHA=$(git ls-remote https://github.com/${{ github.repository }} refs/heads/latest | cut -f1)
BASE_REF="${{ needs.prepare.outputs.base-ref }}"
SHA=$(git ls-remote https://github.com/${{ github.repository }} refs/heads/${BASE_REF} | cut -f1)
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "Latest branch SHA: ${SHA}"
echo "Base branch (${BASE_REF}) SHA: ${SHA}"

- name: Check cache for base results
id: cache-check
Expand Down Expand Up @@ -131,7 +136,7 @@ jobs:
artifact-prefix: module-size-pr
artifact-suffix: ${{ needs.prepare.outputs.pr-number }}

# Build and run module size tests on the latest branch (sharded) - only if cache miss
# Build and run module size tests on the base branch (sharded) - only if cache miss
module-size-base:
name: Module Size Base (${{ matrix.shard }}/${{ strategy.job-total }})
runs-on: ubuntu-latest
Expand All @@ -151,12 +156,12 @@ jobs:
- name: Run module size tests
uses: ./.github/actions/module-size-test
with:
ref: latest
ref: ${{ needs.prepare.outputs.base-ref }}
shard: ${{ matrix.shard }}
total-shards: ${{ strategy.job-total }}
artifact-prefix: module-size-base
artifact-suffix: ${{ needs.prepare.outputs.pr-number }}
base-ref: latest
base-ref: ${{ needs.prepare.outputs.base-ref }}

# Merge base shards and save to cache (only when we had to build)
cache-base-results:
Expand Down Expand Up @@ -191,7 +196,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: ./base-results.json
key: module-size-base-${{ needs.check-base-cache.outputs.latest-sha }}
key: module-size-base-${{ needs.check-base-cache.outputs.base-sha }}

# Compare results and post PR comment
compare-and-report:
Expand All @@ -206,7 +211,7 @@ jobs:
env:
PR_NUMBER: ${{ needs.prepare.outputs.pr-number }}
CACHE_HIT: ${{ needs.check-base-cache.outputs.cache-hit }}
LATEST_SHA: ${{ needs.check-base-cache.outputs.latest-sha }}
BASE_SHA: ${{ needs.check-base-cache.outputs.base-sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -237,7 +242,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ./base-results.json
key: module-size-base-${{ env.LATEST_SHA }}
key: module-size-base-${{ env.BASE_SHA }}
fail-on-cache-miss: true

# If cache miss, download artifacts and merge
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,4 @@ documentation/ag-grid-docs/test-results/.last-run.json
**/WARP.md
**/modular-mcp.json
!.rulesync/.aiignore
/.junie/
3 changes: 1 addition & 2 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .run/Absolute sorting theming test.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Absolute sorting theming test" type="JavascriptDebugType" uri="https://plnkr.co/edit/4CcjQTZTuhoFUke4?open=main.js">
<configuration default="false" name="Absolute sorting theming test" type="JavascriptDebugType" engineId="98ca6316-2f89-46d9-a9e5-fa9e2b0625b3" uri="https://plnkr.co/edit/4CcjQTZTuhoFUke4?open=main.js">
<method v="2" />
</configuration>
</component>
5 changes: 5 additions & 0 deletions .run/Preset date sort testing.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Preset date sort testing" type="JavascriptDebugType" engineId="98ca6316-2f89-46d9-a9e5-fa9e2b0625b3" uri="https://plnkr.co/edit/rwM3Z4GI6iqBdXuC?open=main.js">
<method v="2" />
</configuration>
</component>
5 changes: 5 additions & 0 deletions .run/SSRM Preset date sort testing.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SSRM Preset date sort testing" type="JavascriptDebugType" engineId="98ca6316-2f89-46d9-a9e5-fa9e2b0625b3" uri="https://plnkr.co/edit/o5hEce1vQlv5Fz1c?open=main.js">
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion .run/SSRM basic no cache.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SSRM basic no cache" type="JavascriptDebugType" uri="https://plnkr.co/edit/kQe2Keoql20uL8tk?open=main.js">
<configuration default="false" name="SSRM basic no cache" type="JavascriptDebugType" engineId="98ca6316-2f89-46d9-a9e5-fa9e2b0625b3" uri="https://plnkr.co/edit/kQe2Keoql20uL8tk?open=main.js">
<method v="2" />
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { clickAllButtons, ensureGridReady, test, waitForGridContent } from '@utils/grid/test-utils';

test.agExample(import.meta, () => {
test.eachFramework('Example', async ({ page }) => {
// PLACEHOLDER - MINIMAL TEST TO ENSURE GRID LOADS WITHOUT ERRORS
await ensureGridReady(page);
await waitForGridContent(page);
await clickAllButtons(page);
// END PLACEHOLDER
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id="myGrid" style="height: 100%"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import type { ColDef, GridApi, GridOptions } from 'ag-grid-community';
import {
ClientSideRowModelModule,
DateFilterModule,
ModuleRegistry,
TextFilterModule,
ValidationModule,
createGrid,
} from 'ag-grid-community';

ModuleRegistry.registerModules([
ClientSideRowModelModule,
DateFilterModule,
TextFilterModule,
...(process.env.NODE_ENV !== 'production' ? [ValidationModule] : []),
]);

const columnDefs: ColDef[] = [
{ field: 'athlete' },
{
field: 'date',
filter: 'agDateColumnFilter',
filterParams: {
// Enable built-in named & relative date ranges
filterOptions: [
'empty',
'yesterday',
'today',
'tomorrow',
'last7Days',
'lastWeek',
'thisWeek',
'nextWeek',
'last30Days',
'lastMonth',
'thisMonth',
'nextMonth',
'last90Days',
'lastQuarter',
'thisQuarter',
'nextQuarter',
'lastYear',
'thisYear',
'yearToDate',
'nextYear',
'last6Months',
'last12Months',
'last24Months',
],
},
},
];

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
columnDefs: columnDefs,
defaultColDef: {
flex: 1,
minWidth: 150,
filter: true,
},
};

// Setup the grid after the page has finished loading
document.addEventListener('DOMContentLoaded', function () {
const gridDiv = document.querySelector<HTMLElement>('#myGrid')!;
gridApi = createGrid(gridDiv, gridOptions);
fetch('https://www.ag-grid.com/example-assets/olympic-winners.json')
.then((response) => response.json())
.then((data) =>
gridApi.setGridOption(
'rowData',
data.map((d: IOlympicData) => ({
...d,
date: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000 * (Math.random() * 0.5 - Math.random())),
}))
)
);
});
98 changes: 85 additions & 13 deletions documentation/ag-grid-docs/src/content/docs/filter-date/index.mdoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const gridOptions = {

## Date Filter Parameters

Date Filters are configured though the `filterParams` attribute of the column definition (`IDateFilterParams` interface):
Date Filters are configured through the `filterParams` attribute of the column definition (`IDateFilterParams` interface):

{% interfaceDocumentation interfaceName="IDateFilterParams" overrideSrc="filter-date/date-filter-params.json" config={"description":"", "sortAlphabetically":true} /%}

Expand Down Expand Up @@ -130,7 +130,7 @@ The example below demonstrates configuring a comparator:

The Filter Model describes the current state of the applied Date Filter. The Date Filter Model represents the Date as a string in format `'YYYY-MM-DD'`, however when doing comparisons the date is provided as a JavaScript `Date` object as that's what date pickers typically work with. The model uses string representation to make it easier to save and avoid any timezone issues.

If only one [Filter Condition](./filter-conditions/) is set, this will be a `DateFilterModel`:
If only one [Filter Condition](./filter-conditions/#filter-options) is set, this will be a `DateFilterModel`:

{% interfaceDocumentation interfaceName="DateFilterModel" config={"description":""} /%}

Expand Down Expand Up @@ -180,23 +180,95 @@ The Date Filter presents a list of [Filter Options](./filter-conditions/#filter-

The list of options is as follows:

| Option Name | Option Key | Included by Default |
| ----------------------- | --------------------- | ------------------- |
| Equals | `equals` | Yes |
| Does not equal | `notEqual` | Yes |
| Before | `lessThan` | Yes |
| After | `greaterThan` | Yes |
| Between | `inRange` | Yes |
| Blank | `blank` | Yes |
| Not blank | `notBlank` | Yes |
| Choose one | `empty` | No |
| Option Name | Option Key | Included by Default |
|----------------|---------------|---------------------|
| Equals | `equals` | Yes |
| Does not equal | `notEqual` | Yes |
| Before | `lessThan` | Yes |
| After | `greaterThan` | Yes |
| Between | `inRange` | Yes |
| Blank | `blank` | Yes |
| Not blank | `notBlank` | Yes |
| Choose one | `empty` | No |

Note that the `empty` filter option is primarily used when creating [Custom Filter Options](./filter-conditions/#custom-filter-options). When 'Choose one' is displayed, the filter is not active.

The default option for the Date Filter is `equals`.

When providing filter options, the default filter option (or the first option if no default set) must be an option that displays an input or the `empty` filter option (as a filter option with no inputs would mean the filter is active by default).

## Built-in Named & Relative Date Ranges

Date Filter supports a set of predefined named and relative date ranges to make common filtering tasks easier. These ranges are relative to the browser local time. These are ideal for users who want to filter by familiar time periods like "Last Week", "Year to Date", or "Next 30 Days" without extending a grid with a custom solution.

### Enabling Built-in Date Ranges

To enable the built-in date ranges, add them to the `filterOptions` array in your date filter configuration. The options are not included by default.

#### Example: Enable Built-in Date Ranges

{% gridExampleRunner title="Built-in Date Ranges" name="built-in-date-ranges" /%}

Example above uses following configuration:

```ts
// Enable built-in date ranges
const columnDefs: ColDef[] = [
{
filter: 'agDateColumnFilter',
filterParams: {
// Enable built-in named & relative date ranges
filterOptions: [
'empty', // optional: show 'Choose one' option first
'yesterday',
'today',
'tomorrow',
'last7Days',
'lastWeek',
'thisWeek',
'nextWeek',
'last30Days',
'lastMonth',
// ... All other preset ranges
],
// Other filter settings...
},
},
];
```

### Available Built-in Date Filter Options

| Option Name | Option Key | Time Range Start >= | Time Range End < |
|--------------------|----------------|----------------------------------|:------------------------------|
| Today | `today` | `Start Of Today` | `Start Of Tomorrow` |
| Yesterday | `yesterday` | `Start Of Yesterday` | `Start Of Today` |
| Tomorrow | `tomorrow` | `Start Of Tomorrow` | `Start Of Day After Tomorrow` |
| This Week | `thisWeek` | `Start Of Current Week` | `Start Of Next Week` |
| Last Week | `lastWeek` | `Start Of Previous Week` | `Start Of Current Week` |
| Next Week | `nextWeek` | `Start Of Next Week` | `Start Of Week After Next` |
| This Month | `thisMonth` | `Start Of Current Month` | `Start Of Next Month` |
| Last Month | `lastMonth` | `Start Of Previous Month` | `Start Of Current Month` |
| Next Month | `nextMonth` | `Start Of Next Month` | `Start Of Month After Next` |
| This Quarter | `thisQuarter` | `Start Of Current Quarter` | `Start Of Next Quarter` |
| Last Quarter | `lastQuarter` | `Start Of Previous Quarter` | `Start Of Current Quarter` |
| Next Quarter | `nextQuarter` | `Start Of Next Quarter` | `Start Of Quarter After Next` |
| This Year | `thisYear` | `Start Of Current Year` | `Start Of Next Year` |
| Last Year | `lastYear` | `Start Of Previous Year` | `Start Of Current Year` |
| Next Year | `nextYear` | `Start Of Next Year` | `Start Of Year After Next` |
| Year to Date (YTD) | `yearToDate` | `Start Of Current Year` | `Start Of Tomorrow` |
| Last 7 Days | `last7Days` | `Start Of Today minus 7 days` | `Start Of Tomorrow` |
| Last 30 Days | `last30Days` | `Start Of Today minus 30 days` | `Start Of Tomorrow` |
| Last 90 Days | `last90Days` | `Start Of Today minus 90 days` | `Start Of Tomorrow` |
| Last 6 Months | `last6Months` | `Start Of Today minus 6 months` | `Start Of Tomorrow` |
| Last 12 Months | `last12Months` | `Start Of Today minus 12 months` | `Start Of Tomorrow` |
| Last 24 Months | `last24Months` | `Start Of Today minus 24 months` | `Start Of Tomorrow` |


{% note %}
`Start Of Today`, `Start Of Tomorrow`, `Start Of XXX` point to the beginning of the corresponding day, e.g. `00:00:00.000` in browser local timezone.
{% /note %}

## Range Input Validation and Error States

When using the `inRange` filter type, the grid performs input validation to ensure the bounds of the range produce a valid filter; that is, where the start date is earlier than the end date.
Expand Down Expand Up @@ -268,4 +340,4 @@ The Date Filter is not affected by data changes. When the grid data is updated,

## Next Up

Continue to the next section to learn about [Set Filters](./filter-set/).
Continue to the next section to learn about [Set Filters](./filter-set/).
2 changes: 1 addition & 1 deletion jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
process.env.TZ = 'UTC';
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset, coverageReporters: [] };
Loading
Loading