@planningcenter/tapestry 4.9.1-rc.1 → 4.9.1-rc.3
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/dist/components/DataTable/collectionFilter.d.ts +2 -2
- package/dist/components/DataTable/collectionFilter.d.ts.map +1 -1
- package/dist/components/DataTable/collectionFilter.js +7 -2
- package/dist/components/DataTable/collectionFilter.js.map +1 -1
- package/dist/components/DataTable/dateFilter.d.ts +42 -16
- package/dist/components/DataTable/dateFilter.d.ts.map +1 -1
- package/dist/components/DataTable/dateFilter.js +26 -11
- package/dist/components/DataTable/dateFilter.js.map +1 -1
- package/dist/components/DataTable/dayFilter.d.ts +34 -0
- package/dist/components/DataTable/dayFilter.d.ts.map +1 -0
- package/dist/components/DataTable/dayFilter.js +108 -0
- package/dist/components/DataTable/dayFilter.js.map +1 -0
- package/dist/components/DataTable/filters.d.ts +1 -0
- package/dist/components/DataTable/filters.d.ts.map +1 -1
- package/dist/components/DataTable/numberFilter.d.ts +43 -4
- package/dist/components/DataTable/numberFilter.d.ts.map +1 -1
- package/dist/components/DataTable/numberFilter.js +24 -4
- package/dist/components/DataTable/numberFilter.js.map +1 -1
- package/dist/components/DataTable/resolveOperators.d.ts +2 -1
- package/dist/components/DataTable/resolveOperators.d.ts.map +1 -1
- package/dist/components/DataTable/resolveOperators.js +3 -3
- package/dist/components/DataTable/resolveOperators.js.map +1 -1
- package/dist/components/DataTable/textFilter.d.ts +2 -2
- package/dist/components/DataTable/textFilter.d.ts.map +1 -1
- package/dist/components/DataTable/textFilter.js +7 -2
- package/dist/components/DataTable/textFilter.js.map +1 -1
- package/dist/index.css +6 -2
- package/dist/index.css.map +1 -1
- package/dist/reactRender.css +1811 -1807
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +1811 -1807
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/unstable.css +6 -2
- package/dist/unstable.css.map +1 -1
- package/dist/unstable.js +1 -0
- package/dist/unstable.js.map +1 -1
- package/package.json +2 -2
|
@@ -19,7 +19,7 @@ export declare const COLLECTION_NOT: {
|
|
|
19
19
|
readonly label: "is not";
|
|
20
20
|
readonly name: "not";
|
|
21
21
|
};
|
|
22
|
-
declare const
|
|
22
|
+
declare const ALL_COLLECTION_OPERATORS: ({
|
|
23
23
|
readonly inputType: {
|
|
24
24
|
readonly type: "collection";
|
|
25
25
|
};
|
|
@@ -32,7 +32,7 @@ declare const COLLECTION_OPERATORS: ({
|
|
|
32
32
|
readonly label: "is not";
|
|
33
33
|
readonly name: "not";
|
|
34
34
|
})[];
|
|
35
|
-
export type CollectionOperatorName = (typeof
|
|
35
|
+
export type CollectionOperatorName = (typeof ALL_COLLECTION_OPERATORS)[number]["name"];
|
|
36
36
|
export type CollectionFilterConfig = FilterItemConfig<CollectionOperatorName> & {
|
|
37
37
|
options: CollectionOptions;
|
|
38
38
|
} & ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/collectionFilter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAGV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAItB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEpE,eAAO,MAAM,aAAa;;;;;;CAIG,CAAA;AAC7B,eAAO,MAAM,cAAc;;;;;;CAIE,CAAA;AAE7B,QAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"collectionFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/collectionFilter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAGV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAItB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEpE,eAAO,MAAM,aAAa;;;;;;CAIG,CAAA;AAC7B,eAAO,MAAM,cAAc;;;;;;CAIE,CAAA;AAE7B,QAAA,MAAM,wBAAwB;;;;;;;;;;;;IAAkC,CAAA;AAGhE,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnD,MAAM,MAAM,sBAAsB,GAChC,gBAAgB,CAAC,sBAAsB,CAAC,GAAG;IACzC,OAAO,EAAE,iBAAiB,CAAA;CAC3B,GAAG,CACE;IAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GACjD;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,CACrE,CAAA;AAEL,wBAAgB,gBAAgB,CAAC,EAC/B,OAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,QAAgB,EAChB,OAAO,EACP,GAAG,MAAM,EACV,EAAE,sBAAsB,GAAG,cAAc,CAmBzC"}
|
|
@@ -14,12 +14,17 @@ const COLLECTION_NOT = {
|
|
|
14
14
|
label: "is not",
|
|
15
15
|
name: "not",
|
|
16
16
|
};
|
|
17
|
-
const
|
|
17
|
+
const ALL_COLLECTION_OPERATORS = [COLLECTION_IS, COLLECTION_NOT];
|
|
18
|
+
const DEFAULT_COLLECTION_OPERATORS = [COLLECTION_IS];
|
|
18
19
|
function collectionFilter({ display = "select", excludes, includes, multiple = false, options, ...config }) {
|
|
19
20
|
const filter = {
|
|
20
21
|
...config,
|
|
21
22
|
createActiveFilterInstance: (activeFilter, operator) => new CollectionActiveFilter(filter, operator, activeFilter.value, activeFilter.label, activeFilter.scope, { display, multiple, options }),
|
|
22
|
-
operators: resolveOperators(
|
|
23
|
+
operators: resolveOperators(ALL_COLLECTION_OPERATORS, {
|
|
24
|
+
default: DEFAULT_COLLECTION_OPERATORS,
|
|
25
|
+
excludes,
|
|
26
|
+
includes,
|
|
27
|
+
}),
|
|
23
28
|
};
|
|
24
29
|
return filter;
|
|
25
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionFilter.js","sources":["../../../src/components/DataTable/collectionFilter.tsx"],"sourcesContent":["import React from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport { CollectionFilterEditorLazy } from \"./CollectionEditorsLazy\"\nimport type {\n CollectionFilterValue,\n CollectionOptions,\n} from \"./CollectionEditorsShared\"\nimport { CollectionFilterEditorStatic } from \"./CollectionEditorsStatic\"\nimport type {\n ActiveFilterLabel,\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\n// A type alias (not an interface) so it satisfies `Select`'s `data-*` index signature.\nexport type CollectionOption = {\n label: string\n value: string\n}\n\nexport type CollectionDisplay = \"checkboxes\" | \"combobox\" | \"select\"\n\nexport const COLLECTION_IS = {\n inputType: { type: \"collection\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const COLLECTION_NOT = {\n inputType: { type: \"collection\" },\n label: \"is not\",\n name: \"not\",\n} as const satisfies Operator\n\nconst
|
|
1
|
+
{"version":3,"file":"collectionFilter.js","sources":["../../../src/components/DataTable/collectionFilter.tsx"],"sourcesContent":["import React from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport { CollectionFilterEditorLazy } from \"./CollectionEditorsLazy\"\nimport type {\n CollectionFilterValue,\n CollectionOptions,\n} from \"./CollectionEditorsShared\"\nimport { CollectionFilterEditorStatic } from \"./CollectionEditorsStatic\"\nimport type {\n ActiveFilterLabel,\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\n// A type alias (not an interface) so it satisfies `Select`'s `data-*` index signature.\nexport type CollectionOption = {\n label: string\n value: string\n}\n\nexport type CollectionDisplay = \"checkboxes\" | \"combobox\" | \"select\"\n\nexport const COLLECTION_IS = {\n inputType: { type: \"collection\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const COLLECTION_NOT = {\n inputType: { type: \"collection\" },\n label: \"is not\",\n name: \"not\",\n} as const satisfies Operator\n\nconst ALL_COLLECTION_OPERATORS = [COLLECTION_IS, COLLECTION_NOT]\nconst DEFAULT_COLLECTION_OPERATORS = [COLLECTION_IS]\n\nexport type CollectionOperatorName =\n (typeof ALL_COLLECTION_OPERATORS)[number][\"name\"]\n\nexport type CollectionFilterConfig =\n FilterItemConfig<CollectionOperatorName> & {\n options: CollectionOptions\n } & (\n | { display?: CollectionDisplay; multiple?: false }\n | { display?: Exclude<CollectionDisplay, \"select\">; multiple: true }\n )\n\nexport function collectionFilter({\n display = \"select\",\n excludes,\n includes,\n multiple = false,\n options,\n ...config\n}: CollectionFilterConfig): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new CollectionActiveFilter(\n filter,\n operator,\n activeFilter.value as CollectionFilterValue,\n activeFilter.label,\n activeFilter.scope,\n { display, multiple, options }\n ),\n operators: resolveOperators(ALL_COLLECTION_OPERATORS, {\n default: DEFAULT_COLLECTION_OPERATORS,\n excludes,\n includes,\n }),\n }\n return filter\n}\n\nclass CollectionActiveFilter extends ActiveFilterInstance<CollectionFilterValue> {\n constructor(\n filter: FilterNodeItem,\n operator: FilterNodeItem[\"operators\"][number],\n value: CollectionFilterValue,\n private readonly label: ActiveFilterLabel,\n private readonly scope: string | undefined,\n private readonly config: {\n display: CollectionDisplay\n multiple: boolean\n options: CollectionOptions\n }\n ) {\n super(filter, operator, value)\n this.label = label\n }\n\n formatValue() {\n if (this.label) return Array.isArray(this.label) ? this.label : [this.label]\n const values = Array.isArray(this.value) ? this.value : [this.value]\n if (typeof this.config.options === \"function\") return [\"\"]\n return values\n .map(\n (value) =>\n (this.config.options as CollectionOption[]).find(\n (option) => option.value === value\n )?.label ?? value\n )\n .join(\", \")\n }\n\n renderEditor(onChange: FilterChange) {\n const hasLazyOptions = typeof this.config.options === \"function\"\n const Editor = hasLazyOptions\n ? CollectionFilterEditorLazy\n : CollectionFilterEditorStatic\n\n return (\n <Editor\n config={this.config}\n onChange={onChange}\n operator={this.operator}\n value={this.value}\n label={this.label}\n filter={this.filter}\n scope={this.scope}\n />\n )\n }\n}\n"],"names":["React"],"mappings":";;;;;;AA0BO,MAAM,aAAa,GAAG;AAC3B,IAAA,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;AACjC,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,IAAI,EAAE,IAAI;;AAEL,MAAM,cAAc,GAAG;AAC5B,IAAA,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;AACjC,IAAA,KAAK,EAAE,QAAQ;AACf,IAAA,IAAI,EAAE,KAAK;;AAGb,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,cAAc,CAAC;AAChE,MAAM,4BAA4B,GAAG,CAAC,aAAa,CAAC;AAa9C,SAAU,gBAAgB,CAAC,EAC/B,OAAO,GAAG,QAAQ,EAClB,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,GAAG,MAAM,EACc,EAAA;AACvB,IAAA,MAAM,MAAM,GAAmB;AAC7B,QAAA,GAAG,MAAM;AACT,QAAA,0BAA0B,EAAE,CAAC,YAAY,EAAE,QAAQ,K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AC9C,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,KAAK,KAAK,CACnC,EAAE,KAAK,IAAI,KAAK;aAEpB,IAAI,CAAC,IAAI,CAAC;IACf;AAEA,IAAA,YAAY,CAAC,QAAsB,EAAA;QACjC,MAAM,cAAc,GAAG,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,UAAU;QAChE,MAAM,MAAM,GAAG;AACb,cAAE;cACA,4BAA4B;QAEhC,QACEA,6BAAC,MAAM,EAAA,EACL,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAA,CACjB;IAEN;AACD;;;;"}
|
|
@@ -8,28 +8,42 @@ export declare const DATE_IS: {
|
|
|
8
8
|
readonly label: "is";
|
|
9
9
|
readonly name: "eq";
|
|
10
10
|
};
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const LT: {
|
|
12
12
|
readonly inputType: {
|
|
13
13
|
readonly type: "date";
|
|
14
14
|
};
|
|
15
|
-
readonly label: "before";
|
|
16
|
-
readonly name: "
|
|
15
|
+
readonly label: "is before";
|
|
16
|
+
readonly name: "lt";
|
|
17
17
|
};
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const GT: {
|
|
19
19
|
readonly inputType: {
|
|
20
20
|
readonly type: "date";
|
|
21
21
|
};
|
|
22
|
-
readonly label: "after";
|
|
23
|
-
readonly name: "
|
|
22
|
+
readonly label: "is after";
|
|
23
|
+
readonly name: "gt";
|
|
24
|
+
};
|
|
25
|
+
export declare const LTE: {
|
|
26
|
+
readonly inputType: {
|
|
27
|
+
readonly type: "date";
|
|
28
|
+
};
|
|
29
|
+
readonly label: "is on or before";
|
|
30
|
+
readonly name: "lte";
|
|
31
|
+
};
|
|
32
|
+
export declare const GTE: {
|
|
33
|
+
readonly inputType: {
|
|
34
|
+
readonly type: "date";
|
|
35
|
+
};
|
|
36
|
+
readonly label: "is on or after";
|
|
37
|
+
readonly name: "gte";
|
|
24
38
|
};
|
|
25
39
|
export declare const DATE_RANGE: {
|
|
26
40
|
readonly inputType: {
|
|
27
41
|
readonly type: "date-range";
|
|
28
42
|
};
|
|
29
|
-
readonly label: "between";
|
|
30
|
-
readonly name: "
|
|
43
|
+
readonly label: "is between";
|
|
44
|
+
readonly name: "between";
|
|
31
45
|
};
|
|
32
|
-
declare const
|
|
46
|
+
declare const ALL_DATE_OPERATORS: ({
|
|
33
47
|
readonly inputType: {
|
|
34
48
|
readonly type: "date";
|
|
35
49
|
};
|
|
@@ -39,22 +53,34 @@ declare const DATE_OPERATORS: ({
|
|
|
39
53
|
readonly inputType: {
|
|
40
54
|
readonly type: "date";
|
|
41
55
|
};
|
|
42
|
-
readonly label: "before";
|
|
43
|
-
readonly name: "
|
|
56
|
+
readonly label: "is before";
|
|
57
|
+
readonly name: "lt";
|
|
58
|
+
} | {
|
|
59
|
+
readonly inputType: {
|
|
60
|
+
readonly type: "date";
|
|
61
|
+
};
|
|
62
|
+
readonly label: "is after";
|
|
63
|
+
readonly name: "gt";
|
|
64
|
+
} | {
|
|
65
|
+
readonly inputType: {
|
|
66
|
+
readonly type: "date";
|
|
67
|
+
};
|
|
68
|
+
readonly label: "is on or before";
|
|
69
|
+
readonly name: "lte";
|
|
44
70
|
} | {
|
|
45
71
|
readonly inputType: {
|
|
46
72
|
readonly type: "date";
|
|
47
73
|
};
|
|
48
|
-
readonly label: "after";
|
|
49
|
-
readonly name: "
|
|
74
|
+
readonly label: "is on or after";
|
|
75
|
+
readonly name: "gte";
|
|
50
76
|
} | {
|
|
51
77
|
readonly inputType: {
|
|
52
78
|
readonly type: "date-range";
|
|
53
79
|
};
|
|
54
|
-
readonly label: "between";
|
|
55
|
-
readonly name: "
|
|
80
|
+
readonly label: "is between";
|
|
81
|
+
readonly name: "between";
|
|
56
82
|
})[];
|
|
57
|
-
export type DateOperatorName = (typeof
|
|
83
|
+
export type DateOperatorName = (typeof ALL_DATE_OPERATORS)[number]["name"];
|
|
58
84
|
export declare function dateFilter({ excludes, includes, ...config }: FilterItemConfig<DateOperatorName>): FilterNodeItem;
|
|
59
85
|
export {};
|
|
60
86
|
//# sourceMappingURL=dateFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/dateFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAGtB,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,OAAO;;;;;;CAIS,CAAA;AAC7B,eAAO,MAAM,MAAM;;;;;;
|
|
1
|
+
{"version":3,"file":"dateFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/dateFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAGtB,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,OAAO;;;;;;CAIS,CAAA;AAC7B,eAAO,MAAM,EAAE;;;;;;CAIc,CAAA;AAC7B,eAAO,MAAM,EAAE;;;;;;CAIc,CAAA;AAC7B,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,UAAU;;;;;;CAIM,CAAA;AAE7B,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAA0C,CAAA;AAGlE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAU1E,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,cAAc,CAgBrD"}
|
|
@@ -12,29 +12,44 @@ const DATE_IS = {
|
|
|
12
12
|
label: "is",
|
|
13
13
|
name: "eq",
|
|
14
14
|
};
|
|
15
|
-
const
|
|
15
|
+
const LT = {
|
|
16
16
|
inputType: { type: "date" },
|
|
17
|
-
label: "before",
|
|
18
|
-
name: "
|
|
17
|
+
label: "is before",
|
|
18
|
+
name: "lt",
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const GT = {
|
|
21
21
|
inputType: { type: "date" },
|
|
22
|
-
label: "after",
|
|
23
|
-
name: "
|
|
22
|
+
label: "is after",
|
|
23
|
+
name: "gt",
|
|
24
|
+
};
|
|
25
|
+
const LTE = {
|
|
26
|
+
inputType: { type: "date" },
|
|
27
|
+
label: "is on or before",
|
|
28
|
+
name: "lte",
|
|
29
|
+
};
|
|
30
|
+
const GTE = {
|
|
31
|
+
inputType: { type: "date" },
|
|
32
|
+
label: "is on or after",
|
|
33
|
+
name: "gte",
|
|
24
34
|
};
|
|
25
35
|
const DATE_RANGE = {
|
|
26
36
|
inputType: { type: "date-range" },
|
|
27
|
-
label: "between",
|
|
28
|
-
name: "
|
|
37
|
+
label: "is between",
|
|
38
|
+
name: "between",
|
|
29
39
|
};
|
|
30
|
-
const
|
|
40
|
+
const ALL_DATE_OPERATORS = [DATE_IS, LT, GT, LTE, GTE, DATE_RANGE];
|
|
41
|
+
const DEFAULT_DATE_OPERATORS = [DATE_IS, LT, GT, DATE_RANGE];
|
|
31
42
|
const formatter = new $12a3c853105e5a70$export$ad991b66133851cf(new Intl.DateTimeFormat().resolvedOptions().locale, { dateStyle: "medium" });
|
|
32
43
|
const formatDate = (iso) => formatter.format($58246871e4652552$export$6b862160d295c8e(iso).toDate($ad063034c8620db8$export$aa8b41735afcabd2()));
|
|
33
44
|
function dateFilter({ excludes, includes, ...config }) {
|
|
34
45
|
const filter = {
|
|
35
46
|
...config,
|
|
36
47
|
createActiveFilterInstance: (activeFilter, operator) => new DateActiveFilter(filter, operator, activeFilter.value),
|
|
37
|
-
operators: resolveOperators(
|
|
48
|
+
operators: resolveOperators(ALL_DATE_OPERATORS, {
|
|
49
|
+
default: DEFAULT_DATE_OPERATORS,
|
|
50
|
+
excludes,
|
|
51
|
+
includes,
|
|
52
|
+
}),
|
|
38
53
|
};
|
|
39
54
|
return filter;
|
|
40
55
|
}
|
|
@@ -79,5 +94,5 @@ function DateRangeEditor({ label, onCommit, value: [start, end], }) {
|
|
|
79
94
|
React__default.createElement(DatePicker, { hideLabel: true, label: `${label} to`, value: end, onChange: (date) => date && onCommit([start, date.toString()]) })));
|
|
80
95
|
}
|
|
81
96
|
|
|
82
|
-
export {
|
|
97
|
+
export { DATE_IS, DATE_RANGE, GT, GTE, LT, LTE, dateFilter };
|
|
83
98
|
//# sourceMappingURL=dateFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateFilter.js","sources":["../../../src/components/DataTable/dateFilter.tsx"],"sourcesContent":["import { DatePicker } from \"@components/date-picker\"\nimport { Flex } from \"@components/flex\"\nimport {\n DateFormatter,\n getLocalTimeZone,\n parseDate,\n} from \"@internationalized/date\"\nimport React from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\n/** ISO `YYYY-MM-DD` strings; a pair for `between`. */\nexport type DateFilterValue = string | [string, string]\n\nexport const DATE_IS = {\n inputType: { type: \"date\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const
|
|
1
|
+
{"version":3,"file":"dateFilter.js","sources":["../../../src/components/DataTable/dateFilter.tsx"],"sourcesContent":["import { DatePicker } from \"@components/date-picker\"\nimport { Flex } from \"@components/flex\"\nimport {\n DateFormatter,\n getLocalTimeZone,\n parseDate,\n} from \"@internationalized/date\"\nimport React from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\n/** ISO `YYYY-MM-DD` strings; a pair for `between`. */\nexport type DateFilterValue = string | [string, string]\n\nexport const DATE_IS = {\n inputType: { type: \"date\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const LT = {\n inputType: { type: \"date\" },\n label: \"is before\",\n name: \"lt\",\n} as const satisfies Operator\nexport const GT = {\n inputType: { type: \"date\" },\n label: \"is after\",\n name: \"gt\",\n} as const satisfies Operator\nexport const LTE = {\n inputType: { type: \"date\" },\n label: \"is on or before\",\n name: \"lte\",\n} as const satisfies Operator\nexport const GTE = {\n inputType: { type: \"date\" },\n label: \"is on or after\",\n name: \"gte\",\n} as const satisfies Operator\nexport const DATE_RANGE = {\n inputType: { type: \"date-range\" },\n label: \"is between\",\n name: \"between\",\n} as const satisfies Operator\n\nconst ALL_DATE_OPERATORS = [DATE_IS, LT, GT, LTE, GTE, DATE_RANGE]\nconst DEFAULT_DATE_OPERATORS = [DATE_IS, LT, GT, DATE_RANGE]\n\nexport type DateOperatorName = (typeof ALL_DATE_OPERATORS)[number][\"name\"]\n\nconst formatter = new DateFormatter(\n new Intl.DateTimeFormat().resolvedOptions().locale,\n { dateStyle: \"medium\" }\n)\n\nconst formatDate = (iso: string) =>\n formatter.format(parseDate(iso).toDate(getLocalTimeZone()))\n\nexport function dateFilter({\n excludes,\n includes,\n ...config\n}: FilterItemConfig<DateOperatorName>): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new DateActiveFilter(\n filter,\n operator,\n activeFilter.value as DateFilterValue\n ),\n operators: resolveOperators(ALL_DATE_OPERATORS, {\n default: DEFAULT_DATE_OPERATORS,\n excludes,\n includes,\n }),\n }\n return filter\n}\n\nclass DateActiveFilter extends ActiveFilterInstance<DateFilterValue> {\n formatValue() {\n if (Array.isArray(this.value)) {\n const [start, end] = this.value\n if (start === undefined || end === undefined) {\n return [start, end].filter((date) => date !== undefined).map(formatDate)\n }\n return [formatDate(start), \"and\", formatDate(end)]\n }\n return this.value === undefined ? \"\" : formatDate(this.value)\n }\n\n renderEditor(onChange: FilterChange) {\n const { label } = this.operator\n\n if (this.operator.inputType.type === \"date-range\") {\n const range: [string, string] = Array.isArray(this.value)\n ? this.value\n : [this.value, this.value]\n return (\n <DateRangeEditor\n label={label}\n value={range}\n onCommit={(value) => {\n const complete =\n value.length === 2 && value.every((v) => v !== undefined)\n onChange({ value }, { complete })\n }}\n />\n )\n }\n const single = Array.isArray(this.value) ? this.value[0] : this.value\n return (\n <DatePicker\n // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices\n autoFocus\n hideLabel\n label={label}\n value={single}\n onChange={(date) => date && onChange({ value: date.toString() })}\n />\n )\n }\n}\n\nfunction DateRangeEditor({\n label,\n onCommit,\n value: [start, end],\n}: {\n label: string\n onCommit: (value: [string, string]) => void\n value: [string, string]\n}) {\n return (\n <Flex gap={1}>\n <DatePicker\n // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices\n autoFocus\n hideLabel\n label={`${label} from`}\n value={start}\n onChange={(date) => date && onCommit([date.toString(), end])}\n />\n <div>and</div>\n <DatePicker\n hideLabel\n label={`${label} to`}\n value={end}\n onChange={(date) => date && onCommit([start, date.toString()])}\n />\n </Flex>\n )\n}\n"],"names":["DateFormatter","parseDate","getLocalTimeZone","React"],"mappings":";;;;;;;;;AAqBO,MA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A,IAAA,EACT,KAAK,EAAE,CAAA,EAAG,KAAK,CAAA,KAAA,CAAO,EACtB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC,EAAA,CAC5D;QACFA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA,EAAA,KAAA,CAAc;AACd,QAAAA,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EACT,SAAS,EAAA,IAAA,EACT,KAAK,EAAE,CAAA,EAAG,KAAK,CAAA,GAAA,CAAK,EACpB,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAA,CAC9D,CACG;AAEX;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FilterItemConfig, FilterNodeItem } from "./FilterTypes";
|
|
2
|
+
/** `MM-DD` strings with no year; a pair for `between`. */
|
|
3
|
+
export type DayFilterValue = string | [string, string];
|
|
4
|
+
export declare const DAY_IS: {
|
|
5
|
+
readonly inputType: {
|
|
6
|
+
readonly type: "day";
|
|
7
|
+
};
|
|
8
|
+
readonly label: "is";
|
|
9
|
+
readonly name: "eq";
|
|
10
|
+
};
|
|
11
|
+
export declare const DAY_RANGE: {
|
|
12
|
+
readonly inputType: {
|
|
13
|
+
readonly type: "day-range";
|
|
14
|
+
};
|
|
15
|
+
readonly label: "is between";
|
|
16
|
+
readonly name: "between";
|
|
17
|
+
};
|
|
18
|
+
declare const DAY_OPERATORS: ({
|
|
19
|
+
readonly inputType: {
|
|
20
|
+
readonly type: "day";
|
|
21
|
+
};
|
|
22
|
+
readonly label: "is";
|
|
23
|
+
readonly name: "eq";
|
|
24
|
+
} | {
|
|
25
|
+
readonly inputType: {
|
|
26
|
+
readonly type: "day-range";
|
|
27
|
+
};
|
|
28
|
+
readonly label: "is between";
|
|
29
|
+
readonly name: "between";
|
|
30
|
+
})[];
|
|
31
|
+
export type DayOperatorName = (typeof DAY_OPERATORS)[number]["name"];
|
|
32
|
+
export declare function dayFilter({ excludes, includes, ...config }: FilterItemConfig<DayOperatorName>): FilterNodeItem;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=dayFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dayFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/dayFilter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAGtB,0DAA0D;AAC1D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEtD,eAAO,MAAM,MAAM;;;;;;CAIU,CAAA;AAC7B,eAAO,MAAM,SAAS;;;;;;CAIO,CAAA;AAE7B,QAAA,MAAM,aAAa;;;;;;;;;;;;IAAsB,CAAA;AAEzC,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AA2CpE,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,gBAAgB,CAAC,eAAe,CAAC,GAAG,cAAc,CAgBpD"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Flex } from '../flex/Flex.js';
|
|
2
|
+
import { Select } from '../select/Select.js';
|
|
3
|
+
import React__default, { useState } from 'react';
|
|
4
|
+
import { ActiveFilterInstance } from './ActiveFilterInstance.js';
|
|
5
|
+
import { resolveOperators } from './resolveOperators.js';
|
|
6
|
+
|
|
7
|
+
const DAY_IS = {
|
|
8
|
+
inputType: { type: "day" },
|
|
9
|
+
label: "is",
|
|
10
|
+
name: "eq",
|
|
11
|
+
};
|
|
12
|
+
const DAY_RANGE = {
|
|
13
|
+
inputType: { type: "day-range" },
|
|
14
|
+
label: "is between",
|
|
15
|
+
name: "between",
|
|
16
|
+
};
|
|
17
|
+
const DAY_OPERATORS = [DAY_IS, DAY_RANGE];
|
|
18
|
+
// A leap year, so Feb 29 is always selectable.
|
|
19
|
+
const REFERENCE_YEAR = 2000;
|
|
20
|
+
const locale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
21
|
+
const dayFormatter = new Intl.DateTimeFormat(locale, {
|
|
22
|
+
calendar: "gregory",
|
|
23
|
+
day: "numeric",
|
|
24
|
+
month: "short",
|
|
25
|
+
});
|
|
26
|
+
const monthFormatter = new Intl.DateTimeFormat(locale, {
|
|
27
|
+
calendar: "gregory",
|
|
28
|
+
month: "long",
|
|
29
|
+
});
|
|
30
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
31
|
+
const daysInMonth = (month) => new Date(REFERENCE_YEAR, month, 0).getDate();
|
|
32
|
+
const parseDay = (value) => {
|
|
33
|
+
const [month, day] = (value ?? "").split("-").map(Number);
|
|
34
|
+
return { day: day || undefined, month: month || undefined };
|
|
35
|
+
};
|
|
36
|
+
const formatDay = (value) => {
|
|
37
|
+
const { day, month } = parseDay(value);
|
|
38
|
+
if (!month || !day)
|
|
39
|
+
return "";
|
|
40
|
+
return dayFormatter.format(new Date(REFERENCE_YEAR, month - 1, day));
|
|
41
|
+
};
|
|
42
|
+
const monthOptions = Array.from({ length: 12 }, (_, index) => ({
|
|
43
|
+
label: monthFormatter.format(new Date(REFERENCE_YEAR, index, 1)),
|
|
44
|
+
value: String(index + 1),
|
|
45
|
+
}));
|
|
46
|
+
const dayOptions = (month) => Array.from({ length: month ? daysInMonth(month) : 31 }, (_, index) => ({
|
|
47
|
+
label: String(index + 1),
|
|
48
|
+
value: String(index + 1),
|
|
49
|
+
}));
|
|
50
|
+
function dayFilter({ excludes, includes, ...config }) {
|
|
51
|
+
const filter = {
|
|
52
|
+
...config,
|
|
53
|
+
createActiveFilterInstance: (activeFilter, operator) => new DayActiveFilter(filter, operator, activeFilter.value),
|
|
54
|
+
operators: resolveOperators(DAY_OPERATORS, {
|
|
55
|
+
default: DAY_OPERATORS,
|
|
56
|
+
excludes,
|
|
57
|
+
includes,
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
return filter;
|
|
61
|
+
}
|
|
62
|
+
class DayActiveFilter extends ActiveFilterInstance {
|
|
63
|
+
formatValue() {
|
|
64
|
+
if (Array.isArray(this.value)) {
|
|
65
|
+
const [start, end] = this.value;
|
|
66
|
+
if (start === undefined || end === undefined) {
|
|
67
|
+
return [start, end].filter((day) => day !== undefined).map(formatDay);
|
|
68
|
+
}
|
|
69
|
+
return [formatDay(start), "and", formatDay(end)];
|
|
70
|
+
}
|
|
71
|
+
return this.value === undefined ? "" : formatDay(this.value);
|
|
72
|
+
}
|
|
73
|
+
renderEditor(onChange) {
|
|
74
|
+
const { label } = this.operator;
|
|
75
|
+
if (this.operator.inputType.type === "day-range") {
|
|
76
|
+
const [start, end] = Array.isArray(this.value)
|
|
77
|
+
? this.value
|
|
78
|
+
: [this.value, this.value];
|
|
79
|
+
return (React__default.createElement(Flex, { gap: 1 },
|
|
80
|
+
React__default.createElement(DayEditor, { focusOnOpen: true, label: `${label} from`, value: start, onCommit: (day) => onChange({ value: [day, end] }, { complete: end !== undefined }) }),
|
|
81
|
+
React__default.createElement("div", null, "and"),
|
|
82
|
+
React__default.createElement(DayEditor, { label: `${label} to`, value: end, onCommit: (day) => onChange({ value: [start, day] }, { complete: start !== undefined }) })));
|
|
83
|
+
}
|
|
84
|
+
const single = Array.isArray(this.value) ? this.value[0] : this.value;
|
|
85
|
+
return (React__default.createElement(DayEditor, { focusOnOpen: true, label: label, value: single, onCommit: (day) => onChange({ value: day }) }));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function DayEditor({ focusOnOpen, label, onCommit, value, }) {
|
|
89
|
+
const [selection, setSelection] = useState(() => parseDay(value));
|
|
90
|
+
const update = (next) => {
|
|
91
|
+
const day = next.month && next.day
|
|
92
|
+
? Math.min(next.day, daysInMonth(next.month))
|
|
93
|
+
: next.day;
|
|
94
|
+
setSelection({ ...next, day });
|
|
95
|
+
if (next.month && day)
|
|
96
|
+
onCommit(`${pad(next.month)}-${pad(day)}`);
|
|
97
|
+
};
|
|
98
|
+
return (React__default.createElement(Flex, { gap: 1 },
|
|
99
|
+
React__default.createElement(Select
|
|
100
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices
|
|
101
|
+
, {
|
|
102
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices
|
|
103
|
+
autoFocus: focusOnOpen, hideLabel: true, label: `${label} month`, options: monthOptions, placeholder: "Month", value: selection.month ? String(selection.month) : "", onChange: (e) => update({ ...selection, month: Number(e.target.value) || undefined }) }),
|
|
104
|
+
React__default.createElement(Select, { hideLabel: true, label: `${label} day`, options: dayOptions(selection.month), placeholder: "Day", value: selection.day ? String(selection.day) : "", onChange: (e) => update({ ...selection, day: Number(e.target.value) || undefined }) })));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { DAY_IS, DAY_RANGE, dayFilter };
|
|
108
|
+
//# sourceMappingURL=dayFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dayFilter.js","sources":["../../../src/components/DataTable/dayFilter.tsx"],"sourcesContent":["import { Flex } from \"@components/flex\"\nimport { Select } from \"@components/select\"\nimport React, { useState } from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\n/** `MM-DD` strings with no year; a pair for `between`. */\nexport type DayFilterValue = string | [string, string]\n\nexport const DAY_IS = {\n inputType: { type: \"day\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const DAY_RANGE = {\n inputType: { type: \"day-range\" },\n label: \"is between\",\n name: \"between\",\n} as const satisfies Operator\n\nconst DAY_OPERATORS = [DAY_IS, DAY_RANGE]\n\nexport type DayOperatorName = (typeof DAY_OPERATORS)[number][\"name\"]\n\n// A leap year, so Feb 29 is always selectable.\nconst REFERENCE_YEAR = 2000\n\nconst locale = new Intl.DateTimeFormat().resolvedOptions().locale\nconst dayFormatter = new Intl.DateTimeFormat(locale, {\n calendar: \"gregory\",\n day: \"numeric\",\n month: \"short\",\n})\nconst monthFormatter = new Intl.DateTimeFormat(locale, {\n calendar: \"gregory\",\n month: \"long\",\n})\n\nconst pad = (n: number) => String(n).padStart(2, \"0\")\n\nconst daysInMonth = (month: number) =>\n new Date(REFERENCE_YEAR, month, 0).getDate()\n\nconst parseDay = (value: string | undefined) => {\n const [month, day] = (value ?? \"\").split(\"-\").map(Number)\n return { day: day || undefined, month: month || undefined }\n}\n\nconst formatDay = (value: string) => {\n const { day, month } = parseDay(value)\n if (!month || !day) return \"\"\n return dayFormatter.format(new Date(REFERENCE_YEAR, month - 1, day))\n}\n\nconst monthOptions = Array.from({ length: 12 }, (_, index) => ({\n label: monthFormatter.format(new Date(REFERENCE_YEAR, index, 1)),\n value: String(index + 1),\n}))\n\nconst dayOptions = (month: number | undefined) =>\n Array.from({ length: month ? daysInMonth(month) : 31 }, (_, index) => ({\n label: String(index + 1),\n value: String(index + 1),\n }))\n\nexport function dayFilter({\n excludes,\n includes,\n ...config\n}: FilterItemConfig<DayOperatorName>): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new DayActiveFilter(\n filter,\n operator,\n activeFilter.value as DayFilterValue\n ),\n operators: resolveOperators(DAY_OPERATORS, {\n default: DAY_OPERATORS,\n excludes,\n includes,\n }),\n }\n return filter\n}\n\nclass DayActiveFilter extends ActiveFilterInstance<DayFilterValue> {\n formatValue() {\n if (Array.isArray(this.value)) {\n const [start, end] = this.value\n if (start === undefined || end === undefined) {\n return [start, end].filter((day) => day !== undefined).map(formatDay)\n }\n return [formatDay(start), \"and\", formatDay(end)]\n }\n return this.value === undefined ? \"\" : formatDay(this.value)\n }\n\n renderEditor(onChange: FilterChange) {\n const { label } = this.operator\n\n if (this.operator.inputType.type === \"day-range\") {\n const [start, end] = Array.isArray(this.value)\n ? this.value\n : [this.value, this.value]\n return (\n <Flex gap={1}>\n <DayEditor\n focusOnOpen\n label={`${label} from`}\n value={start}\n onCommit={(day) =>\n onChange({ value: [day, end] }, { complete: end !== undefined })\n }\n />\n <div>and</div>\n <DayEditor\n label={`${label} to`}\n value={end}\n onCommit={(day) =>\n onChange(\n { value: [start, day] },\n { complete: start !== undefined }\n )\n }\n />\n </Flex>\n )\n }\n const single = Array.isArray(this.value) ? this.value[0] : this.value\n return (\n <DayEditor\n focusOnOpen\n label={label}\n value={single}\n onCommit={(day) => onChange({ value: day })}\n />\n )\n }\n}\n\nfunction DayEditor({\n focusOnOpen,\n label,\n onCommit,\n value,\n}: {\n focusOnOpen?: boolean\n label: string\n onCommit: (value: string) => void\n value: string | undefined\n}) {\n const [selection, setSelection] = useState(() => parseDay(value))\n\n const update = (next: typeof selection) => {\n const day =\n next.month && next.day\n ? Math.min(next.day, daysInMonth(next.month))\n : next.day\n setSelection({ ...next, day })\n if (next.month && day) onCommit(`${pad(next.month)}-${pad(day)}`)\n }\n\n return (\n <Flex gap={1}>\n <Select\n // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices\n autoFocus={focusOnOpen}\n hideLabel\n label={`${label} month`}\n options={monthOptions}\n placeholder=\"Month\"\n value={selection.month ? String(selection.month) : \"\"}\n onChange={(e) =>\n update({ ...selection, month: Number(e.target.value) || undefined })\n }\n />\n <Select\n hideLabel\n label={`${label} day`}\n options={dayOptions(selection.month)}\n placeholder=\"Day\"\n value={selection.day ? String(selection.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OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,EACpC,WAAW,EAAC,KAAK,EACjB,KAAK,EAAE,SAAS,CAAC,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,EACjD,QAAQ,EAAE,CAAC,CAAC,KACV,MAAM,CAAC,EAAE,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,SAAS,EAAE,CAAC,EAAA,CAEpE,CACG;AAEX;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { collectionFilter } from "./collectionFilter";
|
|
2
2
|
export { dateFilter } from "./dateFilter";
|
|
3
|
+
export { dayFilter } from "./dayFilter";
|
|
3
4
|
export { numberFilter } from "./numberFilter";
|
|
4
5
|
export { scopedFilter } from "./scopedFilter";
|
|
5
6
|
export { textFilter } from "./textFilter";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -7,6 +7,27 @@ export declare const GTE: {
|
|
|
7
7
|
readonly label: ">=";
|
|
8
8
|
readonly name: "gte";
|
|
9
9
|
};
|
|
10
|
+
export declare const GT: {
|
|
11
|
+
readonly inputType: {
|
|
12
|
+
readonly type: "number";
|
|
13
|
+
};
|
|
14
|
+
readonly label: ">";
|
|
15
|
+
readonly name: "gt";
|
|
16
|
+
};
|
|
17
|
+
export declare const LT: {
|
|
18
|
+
readonly inputType: {
|
|
19
|
+
readonly type: "number";
|
|
20
|
+
};
|
|
21
|
+
readonly label: "<";
|
|
22
|
+
readonly name: "lt";
|
|
23
|
+
};
|
|
24
|
+
export declare const EQ: {
|
|
25
|
+
readonly inputType: {
|
|
26
|
+
readonly type: "number";
|
|
27
|
+
};
|
|
28
|
+
readonly label: "is";
|
|
29
|
+
readonly name: "eq";
|
|
30
|
+
};
|
|
10
31
|
export declare const LTE: {
|
|
11
32
|
readonly inputType: {
|
|
12
33
|
readonly type: "number";
|
|
@@ -19,14 +40,32 @@ export declare const NUMBER_RANGE: {
|
|
|
19
40
|
readonly type: "number-range";
|
|
20
41
|
};
|
|
21
42
|
readonly label: "between";
|
|
22
|
-
readonly name: "
|
|
43
|
+
readonly name: "between";
|
|
23
44
|
};
|
|
24
|
-
declare const
|
|
45
|
+
declare const ALL_NUMBER_OPERATORS: ({
|
|
25
46
|
readonly inputType: {
|
|
26
47
|
readonly type: "number";
|
|
27
48
|
};
|
|
28
49
|
readonly label: ">=";
|
|
29
50
|
readonly name: "gte";
|
|
51
|
+
} | {
|
|
52
|
+
readonly inputType: {
|
|
53
|
+
readonly type: "number";
|
|
54
|
+
};
|
|
55
|
+
readonly label: ">";
|
|
56
|
+
readonly name: "gt";
|
|
57
|
+
} | {
|
|
58
|
+
readonly inputType: {
|
|
59
|
+
readonly type: "number";
|
|
60
|
+
};
|
|
61
|
+
readonly label: "<";
|
|
62
|
+
readonly name: "lt";
|
|
63
|
+
} | {
|
|
64
|
+
readonly inputType: {
|
|
65
|
+
readonly type: "number";
|
|
66
|
+
};
|
|
67
|
+
readonly label: "is";
|
|
68
|
+
readonly name: "eq";
|
|
30
69
|
} | {
|
|
31
70
|
readonly inputType: {
|
|
32
71
|
readonly type: "number";
|
|
@@ -38,9 +77,9 @@ declare const NUMBER_OPERATORS: ({
|
|
|
38
77
|
readonly type: "number-range";
|
|
39
78
|
};
|
|
40
79
|
readonly label: "between";
|
|
41
|
-
readonly name: "
|
|
80
|
+
readonly name: "between";
|
|
42
81
|
})[];
|
|
43
|
-
export type NumberOperatorName = (typeof
|
|
82
|
+
export type NumberOperatorName = (typeof ALL_NUMBER_OPERATORS)[number]["name"];
|
|
44
83
|
export declare function numberFilter({ excludes, includes, ...config }: FilterItemConfig<NumberOperatorName>): FilterNodeItem;
|
|
45
84
|
export {};
|
|
46
85
|
//# sourceMappingURL=numberFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/numberFilter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAGtB,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEzD,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,YAAY;;;;;;CAII,CAAA;AAE7B,QAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"numberFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/numberFilter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAGtB,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEzD,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,EAAE;;;;;;CAIc,CAAA;AAC7B,eAAO,MAAM,EAAE;;;;;;CAIc,CAAA;AAC7B,eAAO,MAAM,EAAE;;;;;;CAIc,CAAA;AAC7B,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,YAAY;;;;;;CAII,CAAA;AAE7B,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAuC,CAAA;AAGjE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9E,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAgBvD"}
|
|
@@ -9,6 +9,21 @@ const GTE = {
|
|
|
9
9
|
label: ">=",
|
|
10
10
|
name: "gte",
|
|
11
11
|
};
|
|
12
|
+
const GT = {
|
|
13
|
+
inputType: { type: "number" },
|
|
14
|
+
label: ">",
|
|
15
|
+
name: "gt",
|
|
16
|
+
};
|
|
17
|
+
const LT = {
|
|
18
|
+
inputType: { type: "number" },
|
|
19
|
+
label: "<",
|
|
20
|
+
name: "lt",
|
|
21
|
+
};
|
|
22
|
+
const EQ = {
|
|
23
|
+
inputType: { type: "number" },
|
|
24
|
+
label: "is",
|
|
25
|
+
name: "eq",
|
|
26
|
+
};
|
|
12
27
|
const LTE = {
|
|
13
28
|
inputType: { type: "number" },
|
|
14
29
|
label: "<=",
|
|
@@ -17,14 +32,19 @@ const LTE = {
|
|
|
17
32
|
const NUMBER_RANGE = {
|
|
18
33
|
inputType: { type: "number-range" },
|
|
19
34
|
label: "between",
|
|
20
|
-
name: "
|
|
35
|
+
name: "between",
|
|
21
36
|
};
|
|
22
|
-
const
|
|
37
|
+
const ALL_NUMBER_OPERATORS = [EQ, GT, GTE, LT, LTE, NUMBER_RANGE];
|
|
38
|
+
const DEFAULT_NUMBER_OPERATORS = [GTE, LTE, NUMBER_RANGE];
|
|
23
39
|
function numberFilter({ excludes, includes, ...config }) {
|
|
24
40
|
const filter = {
|
|
25
41
|
...config,
|
|
26
42
|
createActiveFilterInstance: (activeFilter, operator) => new NumberActiveFilter(filter, operator, activeFilter.value),
|
|
27
|
-
operators: resolveOperators(
|
|
43
|
+
operators: resolveOperators(ALL_NUMBER_OPERATORS, {
|
|
44
|
+
default: DEFAULT_NUMBER_OPERATORS,
|
|
45
|
+
excludes,
|
|
46
|
+
includes,
|
|
47
|
+
}),
|
|
28
48
|
};
|
|
29
49
|
return filter;
|
|
30
50
|
}
|
|
@@ -88,5 +108,5 @@ function NumberEditor({ labels, onCommit, values: initialValues, }) {
|
|
|
88
108
|
} }))))));
|
|
89
109
|
}
|
|
90
110
|
|
|
91
|
-
export { GTE, LTE, NUMBER_RANGE, numberFilter };
|
|
111
|
+
export { EQ, GT, GTE, LT, LTE, NUMBER_RANGE, numberFilter };
|
|
92
112
|
//# sourceMappingURL=numberFilter.js.map
|