@1771technologies/lytenyte-pro 1.0.15 → 1.0.17-dev.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/dist/+types.d.ts +442 -65
- package/dist/__play__/filter-select/filter-select.play.d.ts +4 -0
- package/dist/__play__/filter-select/filter-select.play.js +76 -0
- package/dist/__play__/test-utils/row-handler.js +3 -4
- package/dist/cell-selection/bound-selection-rect.js +1 -1
- package/dist/cell-selection/cell-selection-driver.js +7 -6
- package/dist/column-manager/branch.d.ts +1 -1
- package/dist/column-manager/branch.js +1 -1
- package/dist/column-manager/label.d.ts +1 -1
- package/dist/column-manager/label.js +1 -1
- package/dist/column-manager/leaf.js +1 -1
- package/dist/column-manager/move-handle.d.ts +1 -1
- package/dist/column-manager/move-handle.js +1 -2
- package/dist/column-manager/visibility-checkbox.d.ts +1 -1
- package/dist/column-manager/visibility-checkbox.js +1 -1
- package/dist/filter-selects/apply.d.ts +7 -0
- package/dist/filter-selects/apply.js +22 -0
- package/dist/filter-selects/clear.d.ts +7 -0
- package/dist/filter-selects/clear.js +22 -0
- package/dist/filter-selects/context.d.ts +13 -0
- package/dist/filter-selects/context.js +3 -0
- package/dist/filter-selects/filter-combinator.d.ts +10 -0
- package/dist/filter-selects/filter-combinator.js +19 -0
- package/dist/filter-selects/filter-row-context.d.ts +30 -0
- package/dist/filter-selects/filter-row-context.js +3 -0
- package/dist/filter-selects/filter-row.d.ts +13 -0
- package/dist/filter-selects/filter-row.js +118 -0
- package/dist/filter-selects/index.d.ts +22 -0
- package/dist/filter-selects/index.js +20 -0
- package/dist/filter-selects/is-complete-filter.d.ts +2 -0
- package/dist/filter-selects/is-complete-filter.js +5 -0
- package/dist/filter-selects/operator-select.d.ts +14 -0
- package/dist/filter-selects/operator-select.js +25 -0
- package/dist/filter-selects/options.d.ts +9 -0
- package/dist/filter-selects/options.js +100 -0
- package/dist/filter-selects/reset.d.ts +7 -0
- package/dist/filter-selects/reset.js +22 -0
- package/dist/filter-selects/root.d.ts +14 -0
- package/dist/filter-selects/root.js +5 -0
- package/dist/filter-selects/to-filter-item.d.ts +3 -0
- package/dist/filter-selects/to-filter-item.js +7 -0
- package/dist/filter-selects/use-filter-select.d.ts +38 -0
- package/dist/filter-selects/use-filter-select.js +168 -0
- package/dist/filter-selects/value-input.d.ts +12 -0
- package/dist/filter-selects/value-input.js +27 -0
- package/dist/filter-tree/branch.d.ts +1 -1
- package/dist/filter-tree/branch.js +1 -1
- package/dist/filter-tree/hooks/use-filter-tree.js +1 -1
- package/dist/filter-tree/inclusion-checkbox.d.ts +1 -1
- package/dist/filter-tree/inclusion-checkbox.js +1 -1
- package/dist/filter-tree/label.d.ts +1 -1
- package/dist/filter-tree/label.js +1 -1
- package/dist/filter-tree/root.d.ts +1 -1
- package/dist/filter-tree/root.js +1 -1
- package/dist/grid/header-cell.d.ts +1 -1
- package/dist/grid/header-cell.js +1 -2
- package/dist/grid/header.d.ts +1 -1
- package/dist/grid/row-full-width.d.ts +1 -1
- package/dist/grid/row-full-width.js +1 -2
- package/dist/grid/row.d.ts +1 -1
- package/dist/grid/row.js +0 -1
- package/dist/grid/rows-container.d.ts +1 -1
- package/dist/grid-box/item.d.ts +1 -1
- package/dist/grid-box/item.js +1 -2
- package/dist/grid-box/panel.js +1 -1
- package/dist/grid-box/use-aggregation-box-items.js +1 -1
- package/dist/grid-box/use-column-box-items.js +1 -1
- package/dist/grid-box/use-row-group-box-items.js +1 -1
- package/dist/grid.d.ts +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/license/index.d.ts +1 -0
- package/dist/license/index.js +1 -0
- package/dist/license/license.d.ts +3 -0
- package/dist/license/license.js +215 -0
- package/dist/license/md5-hash.d.ts +9 -0
- package/dist/license/md5-hash.js +167 -0
- package/dist/license.js +1 -1
- package/dist/listbox/item.js +1 -1
- package/dist/listbox/panel.js +2 -2
- package/dist/row-data-source-client/filter/compute-filtered-rows.js +1 -1
- package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.js +1 -1
- package/dist/row-data-source-client/use-client-data-source-paginated.js +3 -2
- package/dist/row-data-source-client/use-client-data-source.js +3 -2
- package/dist/row-data-source-client/use-client-tree-data-source.js +3 -2
- package/dist/row-data-source-server/server-data.d.ts +24 -2
- package/dist/row-data-source-server/server-data.js +173 -30
- package/dist/row-data-source-server/use-server-data-source.d.ts +1 -1
- package/dist/row-data-source-server/use-server-data-source.js +80 -11
- package/dist/sort-manager/hooks/use-sort-manager.js +2 -2
- package/dist/sort-manager/hooks/use-sort-row-item.js +1 -1
- package/dist/sort-manager/sort-add.d.ts +1 -1
- package/dist/sort-manager/sort-add.js +1 -1
- package/dist/sort-manager/sort-apply.d.ts +1 -1
- package/dist/sort-manager/sort-apply.js +2 -2
- package/dist/sort-manager/sort-cancel.d.ts +1 -1
- package/dist/sort-manager/sort-cancel.js +2 -2
- package/dist/sort-manager/sort-clear.d.ts +1 -1
- package/dist/sort-manager/sort-clear.js +1 -1
- package/dist/sort-manager/sort-column-select.d.ts +1 -1
- package/dist/sort-manager/sort-column-select.js +1 -1
- package/dist/sort-manager/sort-direction-select.d.ts +1 -1
- package/dist/sort-manager/sort-direction-select.js +1 -1
- package/dist/sort-manager/sort-remove.d.ts +1 -1
- package/dist/sort-manager/sort-remove.js +1 -1
- package/dist/sort-manager/sort-value-select.d.ts +1 -1
- package/dist/sort-manager/sort-value-select.js +1 -1
- package/dist/state/+types.d.ts +2 -1
- package/dist/state/api/column-field.js +1 -1
- package/dist/state/api/edit-begin.js +1 -1
- package/dist/state/api/focus-cell.js +1 -1
- package/dist/state/api/position-from-element.d.ts +5 -2
- package/dist/state/api/position-from-element.js +3 -3
- package/dist/state/api/row-handle-select.js +1 -1
- package/dist/state/api/use-row-drag.js +3 -2
- package/dist/state/helpers/column-add-row-group.js +1 -1
- package/dist/state/helpers/column-marker.js +1 -1
- package/dist/state/use-lytenyte.js +18 -3
- package/dist/tree-view/branch/branch.d.ts +1 -1
- package/dist/tree-view/branch/branch.js +1 -1
- package/dist/tree-view/branch/use-branch-keys.js +2 -2
- package/dist/tree-view/leaf.js +1 -1
- package/dist/tree-view/panel/make-handle-navigation.js +1 -1
- package/dist/tree-view/panel/make-handle-selection.js +1 -1
- package/dist/tree-view/panel/panel.js +2 -2
- package/dist/tree-view/panel/use-tree-navigation.js +1 -1
- package/dist/tree-view/root.js +1 -1
- package/dist/tree-view/utils/get-focusable-nodes.js +1 -1
- package/dist/tree-view/utils/get-focused-node.js +1 -1
- package/dist/tree-view/utils/get-sibling-branches.js +1 -1
- package/dist/tree-view/virtualized/use-row-start-and-end.d.ts +1 -1
- package/dist/tree-view/virtualized/use-row-start-and-end.js +1 -1
- package/dist/tree-view/virtualized/use-virtualized-tree.js +1 -1
- package/package.json +3 -7
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SelectOption } from "./operator-select";
|
|
2
|
+
export declare const numberOptions: SelectOption[];
|
|
3
|
+
export declare const stringOptions: SelectOption[];
|
|
4
|
+
export declare const dateOptions: SelectOption[];
|
|
5
|
+
export declare const operatorToOption: {
|
|
6
|
+
[k: string]: SelectOption;
|
|
7
|
+
};
|
|
8
|
+
export declare const operatorsThatAreNumbers: Set<string>;
|
|
9
|
+
export declare const filterNeedsValue: Set<string>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export const numberOptions = [
|
|
2
|
+
{ label: "Equals", value: "equals" },
|
|
3
|
+
{ label: "Not Equals", value: "not_equals" },
|
|
4
|
+
{ label: "Less Than", value: "less_than" },
|
|
5
|
+
{ label: "Less Than Or Equals", value: "less_than_or_equals" },
|
|
6
|
+
{ label: "Greater Than", value: "greater_than" },
|
|
7
|
+
{ label: "Greater Than or Equals", value: "greater_than_or_equals" },
|
|
8
|
+
];
|
|
9
|
+
export const stringOptions = [
|
|
10
|
+
{ label: "Equals", value: "equals" },
|
|
11
|
+
{ label: "Not Equals", value: "not_equals" },
|
|
12
|
+
{ label: "Less Than", value: "less_than" },
|
|
13
|
+
{ label: "Less Than Or Equals", value: "less_than_or_equals" },
|
|
14
|
+
{ label: "Greater Than", value: "greater_than" },
|
|
15
|
+
{ label: "Greater Than Or Equals", value: "greater_than_or_equals" },
|
|
16
|
+
{ label: "Begins With", value: "begins_with" },
|
|
17
|
+
{ label: "Not Begins With", value: "not_begins_with" },
|
|
18
|
+
{ label: "Ends With", value: "ends_with" },
|
|
19
|
+
{ label: "Not Ends With", value: "not_ends_with" },
|
|
20
|
+
{ label: "Contains", value: "contains" },
|
|
21
|
+
{ label: "Not Contains", value: "not_contains" },
|
|
22
|
+
{ label: "Length", value: "length" },
|
|
23
|
+
{ label: "Not Length", value: "not_length" },
|
|
24
|
+
{ label: "Matches", value: "matches" },
|
|
25
|
+
{ label: "Length Less Than", value: "length_less_than" },
|
|
26
|
+
{ label: "Length Less Than Or Equals", value: "length_less_than_or_equals" },
|
|
27
|
+
{ label: "Length Greater Than", value: "length_greater_than" },
|
|
28
|
+
{ label: "Length Greater Than Or Equals", value: "length_greater_than_or_equals" },
|
|
29
|
+
];
|
|
30
|
+
export const dateOptions = [
|
|
31
|
+
{ label: "Equals", value: "equals" },
|
|
32
|
+
{ label: "Not Equals", value: "not_equals" },
|
|
33
|
+
{ label: "Before", value: "before" },
|
|
34
|
+
{ label: "Before Or Equals", value: "before_or_equals" },
|
|
35
|
+
{ label: "After", value: "after" },
|
|
36
|
+
{ label: "After Or Equals", value: "after_or_equals" },
|
|
37
|
+
{ label: "Year To Date", value: "year_to_date" },
|
|
38
|
+
{ label: "This Week", value: "this_week" },
|
|
39
|
+
{ label: "This Month", value: "this_month" },
|
|
40
|
+
{ label: "This Year", value: "this_year" },
|
|
41
|
+
{ label: "Last Week", value: "last_week" },
|
|
42
|
+
{ label: "Last Month", value: "last_month" },
|
|
43
|
+
{ label: "Last Year", value: "last_year" },
|
|
44
|
+
{ label: "Next Week", value: "next_week" },
|
|
45
|
+
{ label: "Next Month", value: "next_month" },
|
|
46
|
+
{ label: "Next Year", value: "next_year" },
|
|
47
|
+
{ label: "Today", value: "today" },
|
|
48
|
+
{ label: "Tomorrow", value: "tomorrow" },
|
|
49
|
+
{ label: "Yesterday", value: "yesterday" },
|
|
50
|
+
{ label: "Week Of Year", value: "week_of_year" },
|
|
51
|
+
{ label: "Quarter Of Year", value: "quarter_of_year" },
|
|
52
|
+
{ label: "Is Weekend", value: "is_weekend" },
|
|
53
|
+
{ label: "Is Weekday", value: "is_weekday" },
|
|
54
|
+
{ label: "N Days Ago", value: "n_days_ago" },
|
|
55
|
+
{ label: "N Days Ahead", value: "n_days_ahead" },
|
|
56
|
+
{ label: "N Weeks Ago", value: "n_weeks_ago" },
|
|
57
|
+
{ label: "N Weeks Ahead", value: "n_weeks_ahead" },
|
|
58
|
+
{ label: "N Months Ago", value: "n_months_ago" },
|
|
59
|
+
{ label: "N Months Ahead", value: "n_months_ahead" },
|
|
60
|
+
{ label: "N Years Ago", value: "n_years_ago" },
|
|
61
|
+
{ label: "N Years Ahead", value: "n_years_ahead" },
|
|
62
|
+
];
|
|
63
|
+
export const operatorToOption = Object.fromEntries([...numberOptions, ...stringOptions, ...dateOptions].map((c) => {
|
|
64
|
+
return [c.value, c];
|
|
65
|
+
}));
|
|
66
|
+
export const operatorsThatAreNumbers = new Set([
|
|
67
|
+
"n_days_ago",
|
|
68
|
+
"n_days_ahead",
|
|
69
|
+
"n_weeks_ago",
|
|
70
|
+
"n_weeks_ahead",
|
|
71
|
+
"n_months_ago",
|
|
72
|
+
"n_months_ahead",
|
|
73
|
+
"n_years_ago",
|
|
74
|
+
"n_years_ahead",
|
|
75
|
+
"length",
|
|
76
|
+
"not_length",
|
|
77
|
+
"length_less_than",
|
|
78
|
+
"length_less_than_or_equals",
|
|
79
|
+
"length_greater_than",
|
|
80
|
+
"length_greater_than_or_equals",
|
|
81
|
+
"week_of_year",
|
|
82
|
+
"quarter_of_year",
|
|
83
|
+
]);
|
|
84
|
+
export const filterNeedsValue = new Set([
|
|
85
|
+
"year_to_date",
|
|
86
|
+
"this_week",
|
|
87
|
+
"this_month",
|
|
88
|
+
"this_year",
|
|
89
|
+
"last_week",
|
|
90
|
+
"last_month",
|
|
91
|
+
"last_year",
|
|
92
|
+
"next_week",
|
|
93
|
+
"next_month",
|
|
94
|
+
"next_year",
|
|
95
|
+
"today",
|
|
96
|
+
"tomorrow",
|
|
97
|
+
"yesterday",
|
|
98
|
+
"is_weekend",
|
|
99
|
+
"is_weekday",
|
|
100
|
+
]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SlotComponent } from "@1771technologies/lytenyte-core/yinternal";
|
|
2
|
+
export interface ResetProps {
|
|
3
|
+
readonly as?: SlotComponent<{
|
|
4
|
+
onReset: () => void;
|
|
5
|
+
}>;
|
|
6
|
+
}
|
|
7
|
+
export declare const Reset: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & ResetProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useSlot } from "@1771technologies/lytenyte-core/yinternal";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { useFilterSelectRoot } from "./context.js";
|
|
5
|
+
function ResetImpl({ as, ...props }, ref) {
|
|
6
|
+
const ctx = useFilterSelectRoot();
|
|
7
|
+
const slot = useSlot({
|
|
8
|
+
props: [
|
|
9
|
+
{
|
|
10
|
+
onClick: ctx.reset,
|
|
11
|
+
},
|
|
12
|
+
props,
|
|
13
|
+
],
|
|
14
|
+
ref: ref,
|
|
15
|
+
slot: as ?? _jsx("button", { children: "Reset" }),
|
|
16
|
+
state: {
|
|
17
|
+
onReset: ctx.reset,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return slot;
|
|
21
|
+
}
|
|
22
|
+
export const Reset = forwardRef(ResetImpl);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Dispatch, PropsWithChildren, SetStateAction } from "react";
|
|
2
|
+
import type { FilterSelectFlat } from "./use-filter-select";
|
|
3
|
+
export interface RootProps {
|
|
4
|
+
readonly root: {
|
|
5
|
+
readonly defaultFilter: FilterSelectFlat;
|
|
6
|
+
readonly filters: FilterSelectFlat[];
|
|
7
|
+
readonly setFilters: Dispatch<SetStateAction<FilterSelectFlat[]>>;
|
|
8
|
+
readonly apply: () => void;
|
|
9
|
+
readonly reset: () => void;
|
|
10
|
+
readonly clear: () => void;
|
|
11
|
+
readonly maxCount: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function Root({ root, children }: PropsWithChildren<RootProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FilterCombination } from "../+types";
|
|
2
|
+
import type { FilterSelectFlatDate, FilterSelectFlatNumber, FilterSelectFlatString } from "./use-filter-select";
|
|
3
|
+
export declare function toFilterItem(f: FilterSelectFlatDate | FilterSelectFlatNumber | FilterSelectFlatString): FilterCombination["filters"][number];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function toFilterItem(f) {
|
|
2
|
+
if (f.kind === "number")
|
|
3
|
+
return { kind: "number", operator: f.operator, value: f.value };
|
|
4
|
+
if (f.kind === "date")
|
|
5
|
+
return { kind: "date", value: f.value, operator: f.operator };
|
|
6
|
+
return { kind: "string", value: f.value, operator: f.operator };
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Column, FilterDateOperator, FilterNumberOperator, FilterStringOperator, Grid } from "../+types";
|
|
2
|
+
export interface UseFilterSelectParams<T> {
|
|
3
|
+
readonly grid: Grid<T>;
|
|
4
|
+
readonly column: Column<T>;
|
|
5
|
+
readonly maxCount?: number;
|
|
6
|
+
}
|
|
7
|
+
export type FilterSelectFlatFunc = {
|
|
8
|
+
kind: "function";
|
|
9
|
+
func: any;
|
|
10
|
+
};
|
|
11
|
+
export type FilterSelectFlatNumber = {
|
|
12
|
+
kind: "number";
|
|
13
|
+
operator?: FilterNumberOperator;
|
|
14
|
+
value?: string | number | null;
|
|
15
|
+
nextExtender?: null | "AND" | "OR";
|
|
16
|
+
};
|
|
17
|
+
export type FilterSelectFlatString = {
|
|
18
|
+
kind: "string";
|
|
19
|
+
operator?: FilterStringOperator;
|
|
20
|
+
value?: string | number | null;
|
|
21
|
+
nextExtender?: null | "AND" | "OR";
|
|
22
|
+
};
|
|
23
|
+
export type FilterSelectFlatDate = {
|
|
24
|
+
kind: "date";
|
|
25
|
+
operator?: FilterDateOperator;
|
|
26
|
+
value?: string | number | null;
|
|
27
|
+
nextExtender?: null | "AND" | "OR";
|
|
28
|
+
};
|
|
29
|
+
export type FilterSelectFlat = FilterSelectFlatFunc | FilterSelectFlatNumber | FilterSelectFlatString | FilterSelectFlatDate;
|
|
30
|
+
export declare const useFilterSelect: <T>({ grid, column, maxCount }: UseFilterSelectParams<T>) => {
|
|
31
|
+
reset: () => void;
|
|
32
|
+
apply: () => void;
|
|
33
|
+
clear: () => void;
|
|
34
|
+
defaultFilter: FilterSelectFlat;
|
|
35
|
+
filters: FilterSelectFlat[];
|
|
36
|
+
setFilters: (v: FilterSelectFlat[] | ((v: FilterSelectFlat[]) => FilterSelectFlat[])) => void;
|
|
37
|
+
maxCount: number;
|
|
38
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { useTwoFlowState } from "@1771technologies/lytenyte-core/yinternal";
|
|
3
|
+
import { isCompleteFilter } from "./is-complete-filter.js";
|
|
4
|
+
import { toFilterItem } from "./to-filter-item.js";
|
|
5
|
+
export const useFilterSelect = ({ grid, column, maxCount = 2 }) => {
|
|
6
|
+
const model = grid.state.filterModel.useValue();
|
|
7
|
+
const filterOnModel = model[column.id];
|
|
8
|
+
const defaultFilter = useMemo(() => {
|
|
9
|
+
if (column.type === "date" || column.type === "datetime")
|
|
10
|
+
return { kind: "date", operator: "equals" };
|
|
11
|
+
if (column.type === "number")
|
|
12
|
+
return { kind: "number", operator: "equals" };
|
|
13
|
+
return { kind: "string", operator: "equals" };
|
|
14
|
+
}, [column.type]);
|
|
15
|
+
const filterValue = useMemo(() => {
|
|
16
|
+
if (filterOnModel) {
|
|
17
|
+
if (filterOnModel.kind === "func")
|
|
18
|
+
return [{ kind: "function", func: filterOnModel.func }];
|
|
19
|
+
if (filterOnModel.kind === "number")
|
|
20
|
+
return [{ kind: "number", value: filterOnModel.value, operator: filterOnModel.operator }];
|
|
21
|
+
if (filterOnModel.kind === "string")
|
|
22
|
+
return [{ kind: "string", value: filterOnModel.value, operator: filterOnModel.operator }];
|
|
23
|
+
if (filterOnModel.kind === "date")
|
|
24
|
+
return [{ kind: "date", value: filterOnModel.value, operator: filterOnModel.operator }];
|
|
25
|
+
if (filterOnModel.kind === "combination") {
|
|
26
|
+
const filters = [];
|
|
27
|
+
const stack = [...filterOnModel.filters.map((c) => [filterOnModel.operator, c])];
|
|
28
|
+
while (stack.length) {
|
|
29
|
+
const [nextExtender, f] = stack.shift();
|
|
30
|
+
if (f.kind === "combination") {
|
|
31
|
+
stack.push(...f.filters.map((c) => [f.operator, c]));
|
|
32
|
+
}
|
|
33
|
+
else if (f.kind === "string") {
|
|
34
|
+
filters.push({ kind: "string", operator: f.operator, value: f.value, nextExtender });
|
|
35
|
+
}
|
|
36
|
+
else if (f.kind === "number") {
|
|
37
|
+
filters.push({ kind: "number", operator: f.operator, value: f.value, nextExtender });
|
|
38
|
+
}
|
|
39
|
+
else if (f.kind === "date") {
|
|
40
|
+
filters.push({ kind: "date", operator: f.operator, value: f.value, nextExtender });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return filters;
|
|
44
|
+
}
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return [defaultFilter];
|
|
48
|
+
}, [filterOnModel, defaultFilter]);
|
|
49
|
+
const [filters, setFilters] = useTwoFlowState(filterValue);
|
|
50
|
+
const finalFilters = useMemo(() => {
|
|
51
|
+
if (!filters.length)
|
|
52
|
+
return [defaultFilter];
|
|
53
|
+
const last = filters.at(-1);
|
|
54
|
+
if (last.kind === "function" || filters.length >= maxCount)
|
|
55
|
+
return filters;
|
|
56
|
+
if (last.operator == undefined || last.value == null)
|
|
57
|
+
return filters;
|
|
58
|
+
return [...filters, defaultFilter];
|
|
59
|
+
}, [defaultFilter, filters, maxCount]);
|
|
60
|
+
const reset = useCallback(() => {
|
|
61
|
+
return setFilters([defaultFilter]);
|
|
62
|
+
}, [defaultFilter, setFilters]);
|
|
63
|
+
const apply = useCallback(() => {
|
|
64
|
+
const fn = finalFilters.find((c) => c.kind === "function");
|
|
65
|
+
if (fn) {
|
|
66
|
+
grid.state.filterModel.set((prev) => {
|
|
67
|
+
const next = { ...prev };
|
|
68
|
+
next[column.id] = { kind: "func", func: fn.func };
|
|
69
|
+
return prev;
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const filters = finalFilters.filter((c) => isCompleteFilter(c));
|
|
74
|
+
if (filters.length === 1) {
|
|
75
|
+
const filter = filters[0];
|
|
76
|
+
if (!isCompleteFilter(filter)) {
|
|
77
|
+
grid.state.filterModel.set((prev) => {
|
|
78
|
+
const filters = { ...prev };
|
|
79
|
+
delete filters[column.id];
|
|
80
|
+
return filters;
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
let next = null;
|
|
85
|
+
if (filter.kind === "date")
|
|
86
|
+
next = { kind: "date", value: filter.value, operator: filter.operator };
|
|
87
|
+
else if (filter.kind === "number")
|
|
88
|
+
next = { kind: "number", value: filter.value, operator: filter.operator };
|
|
89
|
+
else if (filter.kind === "string")
|
|
90
|
+
next = { kind: "string", value: filter.value, operator: filter.operator };
|
|
91
|
+
if (next) {
|
|
92
|
+
console.log(next);
|
|
93
|
+
grid.state.filterModel.set((prev) => {
|
|
94
|
+
const filters = { ...prev };
|
|
95
|
+
filters[column.id] = next;
|
|
96
|
+
return filters;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const combinedFilters = [];
|
|
102
|
+
let i = 0;
|
|
103
|
+
while (i < filters.length) {
|
|
104
|
+
const filter = filters[i];
|
|
105
|
+
if ((filter.nextExtender ?? "AND") === "AND") {
|
|
106
|
+
const ors = [filter];
|
|
107
|
+
while (i + 1 < filters.length) {
|
|
108
|
+
const next = filters[i + 1];
|
|
109
|
+
ors.push(next);
|
|
110
|
+
i++;
|
|
111
|
+
if ((next.nextExtender ?? "AND") !== "AND" || i + 1 >= filters.length)
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
if (ors.length > 1) {
|
|
115
|
+
combinedFilters.push({
|
|
116
|
+
kind: "combination",
|
|
117
|
+
filters: ors.map(toFilterItem),
|
|
118
|
+
operator: "AND",
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
combinedFilters.push(toFilterItem(ors[0]));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
combinedFilters.push(toFilterItem(filter));
|
|
127
|
+
}
|
|
128
|
+
i++;
|
|
129
|
+
}
|
|
130
|
+
grid.state.filterModel.set((prev) => {
|
|
131
|
+
if (combinedFilters.length === 0) {
|
|
132
|
+
const filters = { ...prev };
|
|
133
|
+
delete filters[column.id];
|
|
134
|
+
return filters;
|
|
135
|
+
}
|
|
136
|
+
if (combinedFilters.length === 1) {
|
|
137
|
+
const filters = { ...prev };
|
|
138
|
+
filters[column.id] = combinedFilters[0];
|
|
139
|
+
return filters;
|
|
140
|
+
}
|
|
141
|
+
const filters = { ...prev };
|
|
142
|
+
filters[column.id] = { kind: "combination", filters: combinedFilters, operator: "OR" };
|
|
143
|
+
return filters;
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}, [column.id, finalFilters, grid.state.filterModel]);
|
|
147
|
+
const setF = useCallback((v) => {
|
|
148
|
+
const next = typeof v === "function" ? v(finalFilters) : v;
|
|
149
|
+
setFilters(next);
|
|
150
|
+
}, [finalFilters, setFilters]);
|
|
151
|
+
const clear = useCallback(() => {
|
|
152
|
+
setF([]);
|
|
153
|
+
grid.state.filterModel.set((prev) => {
|
|
154
|
+
const filters = { ...prev };
|
|
155
|
+
delete filters[column.id];
|
|
156
|
+
return filters;
|
|
157
|
+
});
|
|
158
|
+
}, [column.id, grid.state.filterModel, setF]);
|
|
159
|
+
return useMemo(() => ({
|
|
160
|
+
reset,
|
|
161
|
+
apply,
|
|
162
|
+
clear,
|
|
163
|
+
defaultFilter,
|
|
164
|
+
filters: finalFilters,
|
|
165
|
+
setFilters: setF,
|
|
166
|
+
maxCount,
|
|
167
|
+
}), [apply, clear, defaultFilter, finalFilters, maxCount, reset, setF]);
|
|
168
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type SlotComponent } from "@1771technologies/lytenyte-core/yinternal";
|
|
2
|
+
export interface ValueInputSlotProps {
|
|
3
|
+
readonly value: string | number | null | undefined;
|
|
4
|
+
readonly onValueChange: (v: string | number | null) => void;
|
|
5
|
+
readonly disabled: boolean;
|
|
6
|
+
readonly isNumberInput: boolean;
|
|
7
|
+
readonly filterNeedsValue: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ValueInputProps {
|
|
10
|
+
readonly as?: SlotComponent<ValueInputSlotProps>;
|
|
11
|
+
}
|
|
12
|
+
export declare const ValueInput: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & ValueInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useSlot } from "@1771technologies/lytenyte-core/yinternal";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { useFilterRow } from "./filter-row-context.js";
|
|
5
|
+
function ValueInputImpl({ as, ...props }, ref) {
|
|
6
|
+
const ctx = useFilterRow();
|
|
7
|
+
const slot = useSlot({
|
|
8
|
+
slot: as ?? (_jsx(_Fragment, { children: !ctx.filterHasNoValue && (_jsx("input", { type: ctx.filter.kind === "number" || ctx.isNumberInput
|
|
9
|
+
? "number"
|
|
10
|
+
: ctx.filter.kind === "date"
|
|
11
|
+
? "date"
|
|
12
|
+
: "text", value: ctx.value ?? "", onChange: (e) => {
|
|
13
|
+
ctx.onValueChange(e.target.value);
|
|
14
|
+
} })) })),
|
|
15
|
+
props: [props],
|
|
16
|
+
ref,
|
|
17
|
+
state: {
|
|
18
|
+
disabled: ctx.valueDisabled,
|
|
19
|
+
filterNeedsValue: ctx.filterHasNoValue,
|
|
20
|
+
isNumberInput: ctx.isNumberInput,
|
|
21
|
+
onValueChange: ctx.onValueChange,
|
|
22
|
+
value: ctx.value,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return slot;
|
|
26
|
+
}
|
|
27
|
+
export const ValueInput = forwardRef(ValueInputImpl);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TreeVirtualBranch } from "../tree-view/virtualized/make-virtual-tree";
|
|
2
2
|
import type { FilterInFilterItem } from "../+types";
|
|
3
|
-
import { type SlotComponent } from "@1771technologies/lytenyte-
|
|
3
|
+
import { type SlotComponent } from "@1771technologies/lytenyte-core/yinternal";
|
|
4
4
|
export interface FilterTreeBranch {
|
|
5
5
|
readonly item: TreeVirtualBranch<FilterInFilterItem>;
|
|
6
6
|
readonly label: SlotComponent;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { TreeBranch } from "../tree-view/branch/branch.js";
|
|
4
|
-
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
5
4
|
import { FilterTreeItemContext } from "./context.js";
|
|
6
5
|
import { useTreeItem } from "./hooks/use-tree-item.js";
|
|
6
|
+
import { useSlot } from "@1771technologies/lytenyte-core/yinternal";
|
|
7
7
|
export const Branch = forwardRef(function Branch({ item, labelWrap, label, ...props }, forwarded) {
|
|
8
8
|
const value = useTreeItem(item);
|
|
9
9
|
const labelSlot = useSlot({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { useVirtualizedTree } from "../../tree-view/virtualized/use-virtualized-tree.js";
|
|
3
|
-
import { useEvent } from "@1771technologies/lytenyte-
|
|
3
|
+
import { useEvent } from "@1771technologies/lytenyte-core/yinternal";
|
|
4
4
|
export function useFilterTree({ grid, column, treeItemHeight = 24, pivotMode, applyChangesImmediately = false, query, }) {
|
|
5
5
|
const [items, setItems] = useState([]);
|
|
6
6
|
const [expansions, onExpansionChange] = useState({});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
2
|
import { forwardRef } from "react";
|
|
4
3
|
import { useTreeItemContext } from "./context.js";
|
|
4
|
+
import { useSlot } from "@1771technologies/lytenyte-core/yinternal";
|
|
5
5
|
export const InclusionCheckbox = forwardRef(function InclusionCheckbox({ as, ...props }, forwarded) {
|
|
6
6
|
const { isChecked, onCheckChange, isIndeterminate } = useTreeItemContext();
|
|
7
7
|
const rendered = useSlot({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
2
|
import { forwardRef, useMemo } from "react";
|
|
4
3
|
import { useTreeItemContext } from "./context.js";
|
|
4
|
+
import { useSlot } from "@1771technologies/lytenyte-core/yinternal";
|
|
5
5
|
export const Label = forwardRef(function Label({ as, ...props }, forwarded) {
|
|
6
6
|
const { item } = useTreeItemContext();
|
|
7
7
|
const label = useMemo(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type PropsWithChildren } from "react";
|
|
2
2
|
import type { Grid } from "../+types";
|
|
3
3
|
import type { UseTreeFilterReturn } from "./hooks/use-filter-tree";
|
|
4
|
-
import { type SlotComponent } from "@1771technologies/lytenyte-
|
|
4
|
+
import { type SlotComponent } from "@1771technologies/lytenyte-core/yinternal";
|
|
5
5
|
export type FilterTreeRootProps<T> = UseTreeFilterReturn<T>["rootProps"] & {
|
|
6
6
|
readonly grid: Grid<T>;
|
|
7
7
|
readonly loadingAs?: SlotComponent;
|
package/dist/filter-tree/root.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useMemo } from "react";
|
|
|
3
3
|
import { GridProvider } from "../grid-provider/provider.js";
|
|
4
4
|
import { TreeRoot } from "../tree-view/root.js";
|
|
5
5
|
import { FilterTreeContext } from "./context.js";
|
|
6
|
-
import { useSlot } from "@1771technologies/lytenyte-
|
|
6
|
+
import { useSlot } from "@1771technologies/lytenyte-core/yinternal";
|
|
7
7
|
export function Root({ grid, treeRef, filterIn, pivotMode, columnId, children, error, loading, errorAs, loadingAs, fetchItems, items, applyChangesImmediately, filterInChange, ...rootProps }) {
|
|
8
8
|
const value = useMemo(() => {
|
|
9
9
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CSSProperties, type JSX, type ReactNode } from "react";
|
|
2
2
|
import type { HeaderCellFloating, HeaderCellLayout } from "../+types";
|
|
3
|
-
import { type SlotComponent } from "@1771technologies/lytenyte-
|
|
3
|
+
import { type SlotComponent } from "@1771technologies/lytenyte-core/yinternal";
|
|
4
4
|
export interface HeaderCellProps<T> {
|
|
5
5
|
readonly cell: HeaderCellLayout<T> | HeaderCellFloating<T>;
|
|
6
6
|
readonly resizerAs?: SlotComponent;
|
package/dist/grid/header-cell.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import {} from "react";
|
|
2
|
-
import {} from "@1771technologies/lytenyte-
|
|
3
|
-
import { HeaderCell as HeaderCellCore } from "@1771technologies/lytenyte-core/yinternal";
|
|
2
|
+
import { HeaderCell as HeaderCellCore, } from "@1771technologies/lytenyte-core/yinternal";
|
|
4
3
|
export const HeaderCell = HeaderCellCore;
|
package/dist/grid/header.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const Header: import("react").
|
|
1
|
+
export declare const Header: import("react").NamedExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type JSX, type ReactNode } from "react";
|
|
2
2
|
import type { RowFullWidthRowLayout } from "../+types";
|
|
3
|
-
import { type DropWrapProps } from "@1771technologies/lytenyte-
|
|
3
|
+
import { type DropWrapProps } from "@1771technologies/lytenyte-core/yinternal";
|
|
4
4
|
export interface RowFullWidthProps extends Omit<DropWrapProps, "accepted"> {
|
|
5
5
|
readonly row: RowFullWidthRowLayout<any>;
|
|
6
6
|
readonly space?: "viewport" | "scroll-width";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import {} from "react";
|
|
2
|
-
import {} from "@1771technologies/lytenyte-
|
|
3
|
-
import { RowFullWidth as RowFullWidthCore } from "@1771technologies/lytenyte-core/yinternal";
|
|
2
|
+
import { RowFullWidth as RowFullWidthCore, } from "@1771technologies/lytenyte-core/yinternal";
|
|
4
3
|
export const RowFullWidth = RowFullWidthCore;
|
package/dist/grid/row.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type JSX, type ReactNode } from "react";
|
|
2
2
|
import type { RowNormalRowLayout } from "../+types";
|
|
3
|
-
import { type DropWrapProps } from "@1771technologies/lytenyte-
|
|
3
|
+
import { type DropWrapProps } from "@1771technologies/lytenyte-core/yinternal";
|
|
4
4
|
export interface RowProps extends Omit<DropWrapProps, "accepted"> {
|
|
5
5
|
readonly row: RowNormalRowLayout<any>;
|
|
6
6
|
readonly accepted?: string[];
|
package/dist/grid/row.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const RowsContainer: import("react").
|
|
1
|
+
export declare const RowsContainer: import("react").NamedExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/grid-box/item.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CSSProperties } from "react";
|
|
2
2
|
import type { GridBoxItem } from "./+types";
|
|
3
|
-
import { type SlotComponent } from "@1771technologies/lytenyte-
|
|
3
|
+
import { type SlotComponent } from "@1771technologies/lytenyte-core/yinternal";
|
|
4
4
|
export interface GridBoxItemProps {
|
|
5
5
|
readonly item: GridBoxItem;
|
|
6
6
|
readonly itemAs?: SlotComponent;
|
package/dist/grid-box/item.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Item } from "../listbox/item.js";
|
|
4
|
-
import { dragState, DropWrap, useDraggable } from "@1771technologies/lytenyte-dragon";
|
|
5
|
-
import { useCombinedRefs, useSlot, } from "@1771technologies/lytenyte-react-hooks";
|
|
6
4
|
import { useGridBoxContext } from "./context.js";
|
|
5
|
+
import { dragState, DropWrap, useCombinedRefs, useDraggable, useSlot, } from "@1771technologies/lytenyte-core/yinternal";
|
|
7
6
|
export const BoxItem = forwardRef(function BoxItem({ item, itemAs, itemClassName, itemStyle, children, ...props }, forwarded) {
|
|
8
7
|
const { accepted } = useGridBoxContext();
|
|
9
8
|
const { dragProps } = useDraggable({
|
package/dist/grid-box/panel.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Panel } from "../listbox/panel.js";
|
|
4
|
-
import { DropWrap } from "@1771technologies/lytenyte-dragon";
|
|
5
4
|
import { useGridBoxContext } from "./context.js";
|
|
5
|
+
import { DropWrap } from "@1771technologies/lytenyte-core/yinternal";
|
|
6
6
|
export const GridBoxPanel = forwardRef(function GridBoxPanel(props, forwarded) {
|
|
7
7
|
const ctx = useGridBoxContext();
|
|
8
8
|
return (_jsx(DropWrap, { ...props, accepted: ctx.accepted, "data-ln-orientation": ctx.orientation, onDrop: ctx.onRootDrop, ref: forwarded, as: _jsx(Panel, {}) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { useEvent } from "@1771technologies/lytenyte-
|
|
2
|
+
import { useEvent } from "@1771technologies/lytenyte-core/yinternal";
|
|
3
3
|
export function useAggregationBoxItems({ grid, orientation }) {
|
|
4
4
|
const model = grid.state.aggModel.useValue();
|
|
5
5
|
const gridId = grid.state.gridId.useValue();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { useEvent } from "@1771technologies/lytenyte-
|
|
2
|
+
import { useEvent } from "@1771technologies/lytenyte-core/yinternal";
|
|
3
3
|
export function useColumnBoxItems({ grid, onRootDrop, onDrop, onDelete, onAction, orientation, draggable = true, itemFilter, placeholder, }) {
|
|
4
4
|
const columns = grid.state.columns.useValue();
|
|
5
5
|
const base = grid.state.columnBase.useValue();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { useEvent } from "@1771technologies/lytenyte-
|
|
2
|
+
import { useEvent } from "@1771technologies/lytenyte-core/yinternal";
|
|
3
3
|
export function useRowGroupBoxItems({ grid, orientation, hideColumnOnGroup = true, includeGroupables = false, placeholder, }) {
|
|
4
4
|
const rowGroupModel = grid.state.rowGroupModel.useValue();
|
|
5
5
|
const gridId = grid.state.gridId.useValue();
|