@digital-realty/ix-grid 1.0.6
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/LICENSE +21 -0
- package/README.md +62 -0
- package/demo/columns.js +65 -0
- package/demo/contacts.js +292 -0
- package/demo/index.html +92 -0
- package/dist/IxGrid.d.ts +46 -0
- package/dist/IxGrid.js +227 -0
- package/dist/IxGrid.js.map +1 -0
- package/dist/components/IxGridColumnFilter.d.ts +20 -0
- package/dist/components/IxGridColumnFilter.js +133 -0
- package/dist/components/IxGridColumnFilter.js.map +1 -0
- package/dist/components/IxGridRowFilter.d.ts +37 -0
- package/dist/components/IxGridRowFilter.js +317 -0
- package/dist/components/IxGridRowFilter.js.map +1 -0
- package/dist/components/IxPagination.d.ts +13 -0
- package/dist/components/IxPagination.js +93 -0
- package/dist/components/IxPagination.js.map +1 -0
- package/dist/components/grid-column-filter-styles.d.ts +1 -0
- package/dist/components/grid-column-filter-styles.js +71 -0
- package/dist/components/grid-column-filter-styles.js.map +1 -0
- package/dist/components/grid-row-filter-styles.d.ts +1 -0
- package/dist/components/grid-row-filter-styles.js +414 -0
- package/dist/components/grid-row-filter-styles.js.map +1 -0
- package/dist/components/pagination-styles.d.ts +1 -0
- package/dist/components/pagination-styles.js +33 -0
- package/dist/components/pagination-styles.js.map +1 -0
- package/dist/grid-view-styles.d.ts +1 -0
- package/dist/grid-view-styles.js +265 -0
- package/dist/grid-view-styles.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/ix-grid-copy.d.ts +10 -0
- package/dist/ix-grid-copy.js +11 -0
- package/dist/ix-grid-copy.js.map +1 -0
- package/dist/ix-grid.d.ts +1 -0
- package/dist/ix-grid.js +3 -0
- package/dist/ix-grid.js.map +1 -0
- package/dist/test/ix-grid-column-filter.test.d.ts +1 -0
- package/dist/test/ix-grid-column-filter.test.js +36 -0
- package/dist/test/ix-grid-column-filter.test.js.map +1 -0
- package/dist/test/ix-grid-row-filter.test.d.ts +1 -0
- package/dist/test/ix-grid-row-filter.test.js +37 -0
- package/dist/test/ix-grid-row-filter.test.js.map +1 -0
- package/dist/test/ix-grid.test.d.ts +1 -0
- package/dist/test/ix-grid.test.js +43 -0
- package/dist/test/ix-grid.test.js.map +1 -0
- package/dist/test/ix-pagination.test.d.ts +1 -0
- package/dist/test/ix-pagination.test.js +28 -0
- package/dist/test/ix-pagination.test.js.map +1 -0
- package/package.json +95 -0
- package/src/IxGrid.ts +229 -0
- package/src/components/IxGridColumnFilter.ts +144 -0
- package/src/components/IxGridRowFilter.ts +352 -0
- package/src/components/IxPagination.ts +85 -0
- package/src/components/grid-column-filter-styles.ts +71 -0
- package/src/components/grid-row-filter-styles.ts +414 -0
- package/src/components/pagination-styles.ts +33 -0
- package/src/grid-view-styles.ts +265 -0
- package/src/index.ts +1 -0
- package/src/ix-grid-copy.ts +10 -0
- package/src/ix-grid.ts +3 -0
- package/src/test/ix-grid-column-filter.test.ts +47 -0
- package/src/test/ix-grid-row-filter.test.ts +48 -0
- package/src/test/ix-grid.test.ts +50 -0
- package/src/test/ix-pagination.test.ts +33 -0
- package/tsconfig.json +22 -0
- package/web-dev-server.config.mjs +27 -0
- package/web-test-runner.config.mjs +43 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { fixture, expect, elementUpdated } from '@open-wc/testing';
|
|
3
|
+
import '../components/IxGridColumnFilter.js';
|
|
4
|
+
|
|
5
|
+
const columns = [
|
|
6
|
+
{
|
|
7
|
+
name: 'firstName',
|
|
8
|
+
header: 'First name',
|
|
9
|
+
hidden: false,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'lastName',
|
|
13
|
+
header: 'Last name',
|
|
14
|
+
hidden: true,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'middleName',
|
|
18
|
+
header: 'Middle name',
|
|
19
|
+
hidden: false,
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
describe('IxGridColumnFilter', () => {
|
|
24
|
+
it('renders the grid column filter component', async () => {
|
|
25
|
+
const el = await fixture(
|
|
26
|
+
html`<ix-grid-column-filter></ix-grid-column-filter>`
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(el).to.not.be.null;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders the grid column filters list', async () => {
|
|
33
|
+
const el = await fixture(
|
|
34
|
+
html`<ix-grid-column-filter .columns=${columns}></ix-grid-column-filter>`
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const list = el.shadowRoot?.querySelector('.list') as HTMLInputElement;
|
|
38
|
+
|
|
39
|
+
list.click();
|
|
40
|
+
|
|
41
|
+
await elementUpdated(el);
|
|
42
|
+
|
|
43
|
+
const options = el.shadowRoot?.querySelectorAll('ix-switch');
|
|
44
|
+
|
|
45
|
+
expect(options?.length).to.equal(3);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { fixture, expect, elementUpdated } from '@open-wc/testing';
|
|
3
|
+
import '../components/IxGridRowFilter.js';
|
|
4
|
+
|
|
5
|
+
const columns = [
|
|
6
|
+
{
|
|
7
|
+
name: 'firstName',
|
|
8
|
+
header: 'First name',
|
|
9
|
+
filterable: true,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'lastName',
|
|
13
|
+
header: 'Last name',
|
|
14
|
+
filterable: true,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'middleName',
|
|
18
|
+
header: 'Middle name',
|
|
19
|
+
filterable: false,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'email',
|
|
23
|
+
header: 'Email',
|
|
24
|
+
filterable: true,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
describe('IxGridRowFilter', () => {
|
|
29
|
+
it('renders and popluates the grid row filter', async () => {
|
|
30
|
+
const el = await fixture(
|
|
31
|
+
html`<ix-grid-row-filter .columns=${columns}></ix-grid-row-filter>`
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const openMenu = el.shadowRoot?.querySelector(
|
|
35
|
+
'.filter-button'
|
|
36
|
+
) as HTMLInputElement;
|
|
37
|
+
|
|
38
|
+
openMenu.click();
|
|
39
|
+
|
|
40
|
+
await elementUpdated(el);
|
|
41
|
+
|
|
42
|
+
const options = el.shadowRoot?.querySelectorAll(
|
|
43
|
+
'select[data-v="firstName"] option'
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(options?.length).to.equal(3);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { fixture, expect } from '@open-wc/testing';
|
|
3
|
+
import { IxGrid } from '../IxGrid.js';
|
|
4
|
+
import '../ix-grid.js';
|
|
5
|
+
|
|
6
|
+
const rows = [
|
|
7
|
+
{
|
|
8
|
+
name: 'one',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: 'two',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'three',
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const columns = [
|
|
19
|
+
{
|
|
20
|
+
name: 'one',
|
|
21
|
+
header: 'one',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'two',
|
|
25
|
+
header: 'one',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'three',
|
|
29
|
+
header: 'one',
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
describe('IxGrid', () => {
|
|
34
|
+
it('renders a grid', async () => {
|
|
35
|
+
const el = await fixture<IxGrid>(html`<ix-grid></ix-grid>`);
|
|
36
|
+
|
|
37
|
+
expect(el).to.not.be.null;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('renders the correct number of rows', async () => {
|
|
41
|
+
const el = await fixture<IxGrid>(html`<ix-grid
|
|
42
|
+
columns=${columns}
|
|
43
|
+
rows=${rows}
|
|
44
|
+
></ix-grid>`);
|
|
45
|
+
|
|
46
|
+
expect(rows.length).to.equal(3);
|
|
47
|
+
|
|
48
|
+
expect(el).to.not.be.null;
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { fixture, expect } from '@open-wc/testing';
|
|
3
|
+
import '../components/IxPagination.js';
|
|
4
|
+
|
|
5
|
+
describe('IxPagination', () => {
|
|
6
|
+
it('renders pagination', async () => {
|
|
7
|
+
const el = await fixture(html`<ix-pagination></ix-pagination>`);
|
|
8
|
+
|
|
9
|
+
expect(el).to.not.be.null;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('renders pagination page size select', async () => {
|
|
13
|
+
const el = await fixture(html`<ix-pagination
|
|
14
|
+
.pageSizes=${[1, 2, 3]}
|
|
15
|
+
></ix-pagination>`);
|
|
16
|
+
|
|
17
|
+
const pageSizeSelect = el?.shadowRoot?.querySelectorAll('ix-select-option');
|
|
18
|
+
|
|
19
|
+
expect(pageSizeSelect?.length).to.equal(3);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('renders pagination range info', async () => {
|
|
23
|
+
const el = await fixture(html`<ix-pagination
|
|
24
|
+
pageSize="10"
|
|
25
|
+
page="2"
|
|
26
|
+
recordCount="99"
|
|
27
|
+
></ix-pagination>`);
|
|
28
|
+
|
|
29
|
+
const pageRangeInfo = el?.shadowRoot?.querySelectorAll('p')[1];
|
|
30
|
+
|
|
31
|
+
expect(pageRangeInfo?.innerText).to.equal('11 - 20 of 99');
|
|
32
|
+
});
|
|
33
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": ["es2017", "dom"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"outDir": "dist",
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"inlineSources": true,
|
|
16
|
+
"rootDir": "./src",
|
|
17
|
+
"declaration": true,
|
|
18
|
+
"incremental": false,
|
|
19
|
+
"noImplicitAny": false
|
|
20
|
+
},
|
|
21
|
+
"include": ["src/**/*.ts"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
|
|
2
|
+
|
|
3
|
+
/** Use Hot Module replacement by adding --hmr to the start command */
|
|
4
|
+
const hmr = process.argv.includes('--hmr');
|
|
5
|
+
|
|
6
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
7
|
+
open: '/demo/',
|
|
8
|
+
/** Use regular watch mode if HMR is not enabled. */
|
|
9
|
+
watch: !hmr,
|
|
10
|
+
/** Resolve bare module imports */
|
|
11
|
+
nodeResolve: {
|
|
12
|
+
exportConditions: ['browser', 'development'],
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
16
|
+
// esbuildTarget: 'auto'
|
|
17
|
+
|
|
18
|
+
/** Set appIndex to enable SPA routing */
|
|
19
|
+
// appIndex: 'demo/index.html',
|
|
20
|
+
|
|
21
|
+
plugins: [
|
|
22
|
+
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
23
|
+
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
// See documentation for all available options
|
|
27
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
2
|
+
|
|
3
|
+
const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
|
|
4
|
+
|
|
5
|
+
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
6
|
+
/** Test files to run */
|
|
7
|
+
files: 'dist/test/**/*.test.js',
|
|
8
|
+
|
|
9
|
+
/** Resolve bare module imports */
|
|
10
|
+
nodeResolve: {
|
|
11
|
+
exportConditions: ['browser', 'development'],
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
port: 8028,
|
|
15
|
+
|
|
16
|
+
/** Filter out lit dev mode logs */
|
|
17
|
+
filterBrowserLogs(log) {
|
|
18
|
+
for (const arg of log.args) {
|
|
19
|
+
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
27
|
+
// esbuildTarget: 'auto',
|
|
28
|
+
|
|
29
|
+
/** Amount of browsers to run concurrently */
|
|
30
|
+
// concurrentBrowsers: 2,
|
|
31
|
+
|
|
32
|
+
/** Amount of test files per browser to test concurrently */
|
|
33
|
+
// concurrency: 1,
|
|
34
|
+
|
|
35
|
+
/** Browsers to run tests on */
|
|
36
|
+
// browsers: [
|
|
37
|
+
// playwrightLauncher({ product: 'chromium' }),
|
|
38
|
+
// playwrightLauncher({ product: 'firefox' }),
|
|
39
|
+
// playwrightLauncher({ product: 'webkit' }),
|
|
40
|
+
// ],
|
|
41
|
+
|
|
42
|
+
// See documentation for all available options
|
|
43
|
+
});
|