@operato/data-grist 0.2.42 → 0.2.43
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/CHANGELOG.md +14 -0
- package/custom-elements.json +179 -14
- package/demo/index.html +10 -2
- package/dist/src/data-grid/data-grid-header.d.ts +1 -1
- package/dist/src/data-grid/data-grid-header.js +10 -6
- package/dist/src/data-grid/data-grid-header.js.map +1 -1
- package/dist/src/filters/filter-checkbox.d.ts +2 -0
- package/dist/src/filters/filter-checkbox.js +30 -0
- package/dist/src/filters/filter-checkbox.js.map +1 -0
- package/dist/src/filters/filter-input.d.ts +2 -0
- package/dist/src/filters/filter-input.js +7 -0
- package/dist/src/filters/filter-input.js.map +1 -0
- package/dist/src/filters/filter-range-date.d.ts +2 -0
- package/dist/src/filters/filter-range-date.js +10 -0
- package/dist/src/filters/filter-range-date.js.map +1 -0
- package/dist/src/filters/filter-range-number.d.ts +2 -0
- package/dist/src/filters/filter-range-number.js +7 -0
- package/dist/src/filters/filter-range-number.js.map +1 -0
- package/dist/src/filters/filter-select.d.ts +2 -0
- package/dist/src/filters/filter-select.js +9 -0
- package/dist/src/filters/filter-select.js.map +1 -0
- package/dist/src/filters/filter-styles.d.ts +1 -0
- package/dist/src/filters/filter-styles.js +10 -0
- package/dist/src/filters/filter-styles.js.map +1 -0
- package/dist/src/filters/index.d.ts +5 -1
- package/dist/src/filters/index.js +5 -1
- package/dist/src/filters/index.js.map +1 -1
- package/dist/src/filters/registry.js +26 -23
- package/dist/src/filters/registry.js.map +1 -1
- package/dist/src/types.d.ts +4 -4
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/data-grid/data-grid-header.ts +13 -7
- package/src/filters/filter-checkbox.ts +35 -0
- package/src/filters/filter-input.ts +10 -0
- package/src/filters/filter-range-date.ts +13 -0
- package/src/filters/filter-range-number.ts +10 -0
- package/src/filters/filter-select.ts +11 -0
- package/src/filters/filter-styles.ts +10 -0
- package/src/filters/index.ts +5 -1
- package/src/filters/registry.ts +26 -23
- package/src/types.ts +4 -5
- package/dist/src/filters/list-select.d.ts +0 -3
- package/dist/src/filters/list-select.js +0 -12
- package/dist/src/filters/list-select.js.map +0 -1
- package/src/filters/list-select.ts +0 -14
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { html } from 'lit-html'
|
|
2
|
+
|
|
3
|
+
import { FilterSelectRenderer } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FilterCheckbox: FilterSelectRenderer = (column, owner) => {
|
|
6
|
+
const options = typeof column.filter !== 'boolean' && column.filter?.options
|
|
7
|
+
|
|
8
|
+
return html`
|
|
9
|
+
<input
|
|
10
|
+
type="checkbox"
|
|
11
|
+
@click=${(e: MouseEvent) => {
|
|
12
|
+
// e.preventDefault()
|
|
13
|
+
// e.stopPropagation()
|
|
14
|
+
|
|
15
|
+
const checkbox: HTMLInputElement = e.target as HTMLInputElement
|
|
16
|
+
|
|
17
|
+
// if (checkbox.checked === false && checkbox.indeterminate === false) {
|
|
18
|
+
// checkbox.indeterminate = true
|
|
19
|
+
// } else if ((checkbox.checked = true && checkbox.indeterminate === true)) {
|
|
20
|
+
// checkbox.checked = false
|
|
21
|
+
// }
|
|
22
|
+
|
|
23
|
+
// if (checkbox.checked) {
|
|
24
|
+
// checkbox.checked = false
|
|
25
|
+
// } else {
|
|
26
|
+
// if (checkbox.checked === false) {
|
|
27
|
+
// checkbox.indeterminate = true
|
|
28
|
+
// } else {
|
|
29
|
+
// checkbox.checked = true
|
|
30
|
+
// }
|
|
31
|
+
// }
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
`
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { html } from 'lit-html'
|
|
2
|
+
|
|
3
|
+
import { FilterSelectRenderer } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FilterInput: FilterSelectRenderer = (column, owner) => {
|
|
6
|
+
const filter = column.filter
|
|
7
|
+
const type = typeof filter === 'boolean' ? column.type : filter?.type || column.type
|
|
8
|
+
|
|
9
|
+
return html` <input type=${type} /> `
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { html } from 'lit-html'
|
|
2
|
+
|
|
3
|
+
import { FilterSelectRenderer } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FilterRangeDate: FilterSelectRenderer = (column, owner) => {
|
|
6
|
+
const filter = column.filter
|
|
7
|
+
var type = typeof filter === 'boolean' ? column.type : filter?.type || column.type
|
|
8
|
+
if (type === 'datetime') {
|
|
9
|
+
type = 'datetime-local'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return html` <input name="from" type=${type} /> - <input name="to" type=${type} /> `
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { html } from 'lit-html'
|
|
2
|
+
|
|
3
|
+
import { FilterSelectRenderer } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FilterRangeNumber: FilterSelectRenderer = (column, owner) => {
|
|
6
|
+
const filter = column.filter
|
|
7
|
+
const type = typeof filter === 'boolean' ? column.type : filter?.type || column.type
|
|
8
|
+
|
|
9
|
+
return html` <input name="from" type="number" /> - <input name="to" type="number" /> `
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { html } from 'lit-html'
|
|
2
|
+
|
|
3
|
+
import { FilterSelectRenderer } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FilterSelect: FilterSelectRenderer = (column, owner) => {
|
|
6
|
+
const options = (typeof column.filter !== 'boolean' && column.filter?.options) || []
|
|
7
|
+
|
|
8
|
+
return html`
|
|
9
|
+
${options?.map((option: string) => html` <ox-checkbox option value=${option}>${option}</ox-checkbox> `)}
|
|
10
|
+
`
|
|
11
|
+
}
|
package/src/filters/index.ts
CHANGED
package/src/filters/registry.ts
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { FilterSelectRenderer } from '../types'
|
|
2
|
-
import {
|
|
2
|
+
import { FilterCheckbox } from './filter-checkbox'
|
|
3
|
+
import { FilterInput } from './filter-input'
|
|
4
|
+
import { FilterRangeDate } from './filter-range-date'
|
|
5
|
+
import { FilterRangeNumber } from './filter-range-number'
|
|
6
|
+
import { FilterSelect } from './filter-select'
|
|
3
7
|
|
|
4
8
|
var RENDERERS: {
|
|
5
9
|
[name: string]: FilterSelectRenderer
|
|
6
10
|
} = {
|
|
7
|
-
string:
|
|
8
|
-
text:
|
|
9
|
-
email:
|
|
10
|
-
tel:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
json5: ListSelect
|
|
11
|
+
string: FilterInput,
|
|
12
|
+
text: FilterInput,
|
|
13
|
+
email: FilterInput,
|
|
14
|
+
tel: FilterInput,
|
|
15
|
+
integer: FilterRangeNumber,
|
|
16
|
+
float: FilterRangeNumber,
|
|
17
|
+
number: FilterRangeNumber,
|
|
18
|
+
select: FilterSelect,
|
|
19
|
+
boolean: FilterCheckbox,
|
|
20
|
+
checkbox: FilterCheckbox,
|
|
21
|
+
month: FilterRangeDate,
|
|
22
|
+
week: FilterRangeDate,
|
|
23
|
+
date: FilterRangeDate,
|
|
24
|
+
time: FilterRangeDate,
|
|
25
|
+
datetime: FilterRangeDate,
|
|
26
|
+
color: FilterInput,
|
|
27
|
+
progress: FilterRangeNumber,
|
|
28
|
+
link: FilterInput,
|
|
29
|
+
image: FilterInput,
|
|
30
|
+
json5: FilterInput
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
export function registerRenderer(type: string, renderer: FilterSelectRenderer) {
|
|
@@ -44,5 +47,5 @@ export function getRenderer(type: string | FilterSelectRenderer): FilterSelectRe
|
|
|
44
47
|
return type
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
return RENDERERS[type || 'text'] ||
|
|
50
|
+
return RENDERERS[type || 'text'] || FilterSelect
|
|
48
51
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit-html'
|
|
2
|
-
|
|
3
1
|
import { DataCardField } from './data-card/data-card-field'
|
|
4
2
|
import { DataCardGutter } from './data-card/data-card-gutter'
|
|
5
|
-
import { RecordCard } from './data-card/record-card'
|
|
6
3
|
import { DataGridField } from './data-grid/data-grid-field'
|
|
7
4
|
import { DataListField } from './data-list/data-list-field'
|
|
8
5
|
import { DataListGutter } from './data-list/data-list-gutter'
|
|
9
|
-
import { RecordPartial } from './data-list/record-partial'
|
|
10
6
|
import { DataReportField } from './data-report/data-report-field'
|
|
7
|
+
import { RecordCard } from './data-card/record-card'
|
|
8
|
+
import { RecordPartial } from './data-list/record-partial'
|
|
9
|
+
import { TemplateResult } from 'lit-html'
|
|
11
10
|
|
|
12
11
|
export type GristConfig = {
|
|
13
12
|
columns: ColumnConfig[]
|
|
@@ -19,7 +18,7 @@ export type GristConfig = {
|
|
|
19
18
|
|
|
20
19
|
export type SorterConfig = { name: string; desc?: boolean }
|
|
21
20
|
export type SortersConfig = SorterConfig[]
|
|
22
|
-
export type FilterConfig = { type: string; options?: { [key: string]: any } }
|
|
21
|
+
export type FilterConfig = { type: string; options?: { [key: string]: any } } | boolean
|
|
23
22
|
|
|
24
23
|
export type PaginationConfig = {
|
|
25
24
|
page?: number
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import '@operato/popup';
|
|
2
|
-
import { html } from 'lit-html';
|
|
3
|
-
export const ListSelect = (column, owner) => {
|
|
4
|
-
var _a;
|
|
5
|
-
const options = (_a = column.filter) === null || _a === void 0 ? void 0 : _a.options;
|
|
6
|
-
return html `
|
|
7
|
-
<ox-popup-list .config=${column} multiple attr-selected="checked" popup>
|
|
8
|
-
${options === null || options === void 0 ? void 0 : options.map((option) => html ` <ox-checkbox option value="${option}">${option}</ox-checkbox> `)}
|
|
9
|
-
</ox-popup-list>
|
|
10
|
-
`;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=list-select.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-select.js","sourceRoot":"","sources":["../../../src/filters/list-select.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AAGvB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,MAAM,CAAC,MAAM,UAAU,GAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;;IAChE,MAAM,OAAO,GAAG,MAAA,MAAM,CAAC,MAAM,0CAAE,OAAO,CAAA;IAEtC,OAAO,IAAI,CAAA;6BACgB,MAAM;QAC3B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAA,+BAA+B,MAAM,KAAK,MAAM,iBAAiB,CAAC;;GAE5G,CAAA;AACH,CAAC,CAAA","sourcesContent":["import '@operato/popup'\n\nimport { FilterSelectRenderer } from '../types'\nimport { html } from 'lit-html'\n\nexport const ListSelect: FilterSelectRenderer = (column, owner) => {\n const options = column.filter?.options\n\n return html`\n <ox-popup-list .config=${column} multiple attr-selected=\"checked\" popup>\n ${options?.map((option: string) => html` <ox-checkbox option value=\"${option}\">${option}</ox-checkbox> `)}\n </ox-popup-list>\n `\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import '@operato/popup'
|
|
2
|
-
|
|
3
|
-
import { FilterSelectRenderer } from '../types'
|
|
4
|
-
import { html } from 'lit-html'
|
|
5
|
-
|
|
6
|
-
export const ListSelect: FilterSelectRenderer = (column, owner) => {
|
|
7
|
-
const options = column.filter?.options
|
|
8
|
-
|
|
9
|
-
return html`
|
|
10
|
-
<ox-popup-list .config=${column} multiple attr-selected="checked" popup>
|
|
11
|
-
${options?.map((option: string) => html` <ox-checkbox option value="${option}">${option}</ox-checkbox> `)}
|
|
12
|
-
</ox-popup-list>
|
|
13
|
-
`
|
|
14
|
-
}
|