@1771technologies/lytenyte-pro 1.0.14 → 1.0.16

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.
Files changed (225) hide show
  1. package/dist/__play__/cell-selections/cell-selection.play.d.ts +5 -0
  2. package/dist/__play__/{grid-navigation/normal-layout.play.js → cell-selections/cell-selection.play.js} +32 -24
  3. package/dist/__play__/filter-select/filter-select.play.d.ts +4 -0
  4. package/dist/__play__/filter-select/filter-select.play.js +76 -0
  5. package/dist/__play__/test-utils/row-handler.js +6 -7
  6. package/dist/cell-selection/bound-selection-rect.js +1 -1
  7. package/dist/cell-selection/cell-selection-driver.js +12 -8
  8. package/dist/column-manager/branch.d.ts +1 -1
  9. package/dist/column-manager/branch.js +1 -1
  10. package/dist/column-manager/label.d.ts +1 -1
  11. package/dist/column-manager/label.js +1 -1
  12. package/dist/column-manager/leaf.js +1 -1
  13. package/dist/column-manager/move-handle.d.ts +1 -1
  14. package/dist/column-manager/move-handle.js +1 -2
  15. package/dist/column-manager/visibility-checkbox.d.ts +1 -1
  16. package/dist/column-manager/visibility-checkbox.js +1 -1
  17. package/dist/context.d.ts +2 -1
  18. package/dist/context.js +5 -4
  19. package/dist/filter-selects/apply.d.ts +7 -0
  20. package/dist/filter-selects/apply.js +22 -0
  21. package/dist/filter-selects/context.d.ts +12 -0
  22. package/dist/filter-selects/context.js +3 -0
  23. package/dist/filter-selects/filter-combinator.d.ts +10 -0
  24. package/dist/filter-selects/filter-combinator.js +19 -0
  25. package/dist/filter-selects/filter-row-context.d.ts +30 -0
  26. package/dist/filter-selects/filter-row-context.js +3 -0
  27. package/dist/filter-selects/filter-row.d.ts +13 -0
  28. package/dist/filter-selects/filter-row.js +118 -0
  29. package/dist/filter-selects/index.d.ts +20 -0
  30. package/dist/filter-selects/index.js +18 -0
  31. package/dist/filter-selects/is-complete-filter.d.ts +2 -0
  32. package/dist/filter-selects/is-complete-filter.js +5 -0
  33. package/dist/filter-selects/operator-select.d.ts +14 -0
  34. package/dist/filter-selects/operator-select.js +25 -0
  35. package/dist/filter-selects/options.d.ts +9 -0
  36. package/dist/filter-selects/options.js +100 -0
  37. package/dist/filter-selects/reset.d.ts +7 -0
  38. package/dist/filter-selects/reset.js +22 -0
  39. package/dist/filter-selects/root.d.ts +13 -0
  40. package/dist/filter-selects/root.js +5 -0
  41. package/dist/filter-selects/to-filter-item.d.ts +3 -0
  42. package/dist/filter-selects/to-filter-item.js +7 -0
  43. package/dist/filter-selects/use-filter-select.d.ts +37 -0
  44. package/dist/filter-selects/use-filter-select.js +158 -0
  45. package/dist/filter-selects/value-input.d.ts +12 -0
  46. package/dist/filter-selects/value-input.js +27 -0
  47. package/dist/filter-tree/branch.d.ts +1 -1
  48. package/dist/filter-tree/branch.js +1 -1
  49. package/dist/filter-tree/hooks/use-filter-tree.js +1 -1
  50. package/dist/filter-tree/inclusion-checkbox.d.ts +1 -1
  51. package/dist/filter-tree/inclusion-checkbox.js +1 -1
  52. package/dist/filter-tree/label.d.ts +1 -1
  53. package/dist/filter-tree/label.js +1 -1
  54. package/dist/filter-tree/root.d.ts +1 -1
  55. package/dist/filter-tree/root.js +1 -1
  56. package/dist/grid/cell.d.ts +6 -0
  57. package/dist/grid/cell.js +3 -0
  58. package/dist/grid/header-cell.d.ts +10 -0
  59. package/dist/grid/header-cell.js +3 -0
  60. package/dist/grid/header-group-cell.d.ts +6 -0
  61. package/dist/grid/header-group-cell.js +3 -0
  62. package/dist/grid/header-row.d.ts +5 -0
  63. package/dist/grid/header-row.js +2 -0
  64. package/dist/grid/header.d.ts +1 -0
  65. package/dist/grid/header.js +2 -0
  66. package/dist/{root → grid}/root.d.ts +1 -1
  67. package/dist/grid/root.js +37 -0
  68. package/dist/grid/row-full-width.d.ts +9 -0
  69. package/dist/grid/row-full-width.js +3 -0
  70. package/dist/grid/row.d.ts +8 -0
  71. package/dist/grid/row.js +3 -0
  72. package/dist/grid/rows-container.d.ts +1 -0
  73. package/dist/grid/rows-container.js +2 -0
  74. package/dist/grid/rows-sections.js +13 -0
  75. package/dist/grid/viewport.js +9 -0
  76. package/dist/grid-box/item.d.ts +1 -1
  77. package/dist/grid-box/item.js +1 -2
  78. package/dist/grid-box/panel.js +1 -1
  79. package/dist/grid-box/use-aggregation-box-items.js +1 -1
  80. package/dist/grid-box/use-column-box-items.js +1 -1
  81. package/dist/grid-box/use-row-group-box-items.js +1 -1
  82. package/dist/grid.d.ts +9 -9
  83. package/dist/grid.js +11 -11
  84. package/dist/index.d.ts +2 -1
  85. package/dist/index.js +2 -1
  86. package/dist/license/index.d.ts +1 -0
  87. package/dist/license/index.js +1 -0
  88. package/dist/license/license.d.ts +3 -0
  89. package/dist/license/license.js +215 -0
  90. package/dist/license/md5-hash.d.ts +9 -0
  91. package/dist/license/md5-hash.js +167 -0
  92. package/dist/license.js +1 -1
  93. package/dist/listbox/item.js +1 -1
  94. package/dist/listbox/panel.js +2 -2
  95. package/dist/row-data-source-client/filter/compute-filtered-rows.js +1 -1
  96. package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.js +1 -1
  97. package/dist/row-data-source-client/use-client-data-source-paginated.js +3 -2
  98. package/dist/row-data-source-client/use-client-data-source.js +3 -2
  99. package/dist/row-data-source-client/use-client-tree-data-source.js +3 -2
  100. package/dist/row-data-source-server/server-data.js +1 -1
  101. package/dist/row-data-source-server/use-server-data-source.js +2 -2
  102. package/dist/sort-manager/hooks/use-sort-manager.js +2 -2
  103. package/dist/sort-manager/hooks/use-sort-row-item.js +1 -1
  104. package/dist/sort-manager/sort-add.d.ts +1 -1
  105. package/dist/sort-manager/sort-add.js +1 -1
  106. package/dist/sort-manager/sort-apply.d.ts +1 -1
  107. package/dist/sort-manager/sort-apply.js +2 -2
  108. package/dist/sort-manager/sort-cancel.d.ts +1 -1
  109. package/dist/sort-manager/sort-cancel.js +2 -2
  110. package/dist/sort-manager/sort-clear.d.ts +1 -1
  111. package/dist/sort-manager/sort-clear.js +1 -1
  112. package/dist/sort-manager/sort-column-select.d.ts +1 -1
  113. package/dist/sort-manager/sort-column-select.js +1 -1
  114. package/dist/sort-manager/sort-direction-select.d.ts +1 -1
  115. package/dist/sort-manager/sort-direction-select.js +1 -1
  116. package/dist/sort-manager/sort-remove.d.ts +1 -1
  117. package/dist/sort-manager/sort-remove.js +1 -1
  118. package/dist/sort-manager/sort-value-select.d.ts +1 -1
  119. package/dist/sort-manager/sort-value-select.js +1 -1
  120. package/dist/state/+types.d.ts +2 -1
  121. package/dist/state/api/column-field.js +1 -1
  122. package/dist/state/api/edit-begin.js +1 -1
  123. package/dist/state/api/focus-cell.js +1 -1
  124. package/dist/state/api/position-from-element.d.ts +5 -2
  125. package/dist/state/api/position-from-element.js +3 -3
  126. package/dist/state/api/row-handle-select.js +1 -1
  127. package/dist/state/api/use-row-drag.js +3 -2
  128. package/dist/state/helpers/column-add-row-group.js +1 -1
  129. package/dist/state/helpers/column-marker.js +1 -1
  130. package/dist/state/use-lytenyte.js +18 -3
  131. package/dist/tree-view/branch/branch.d.ts +1 -1
  132. package/dist/tree-view/branch/branch.js +1 -1
  133. package/dist/tree-view/branch/use-branch-keys.js +2 -2
  134. package/dist/tree-view/leaf.js +1 -1
  135. package/dist/tree-view/panel/make-handle-navigation.js +1 -1
  136. package/dist/tree-view/panel/make-handle-selection.js +1 -1
  137. package/dist/tree-view/panel/panel.js +2 -2
  138. package/dist/tree-view/panel/use-tree-navigation.js +1 -1
  139. package/dist/tree-view/root.js +1 -1
  140. package/dist/tree-view/utils/get-focusable-nodes.js +1 -1
  141. package/dist/tree-view/utils/get-focused-node.js +1 -1
  142. package/dist/tree-view/utils/get-sibling-branches.js +1 -1
  143. package/dist/tree-view/virtualized/use-row-start-and-end.d.ts +1 -1
  144. package/dist/tree-view/virtualized/use-row-start-and-end.js +1 -1
  145. package/dist/tree-view/virtualized/use-virtualized-tree.js +1 -1
  146. package/dist/types/types.d.ts +6 -6
  147. package/package.json +3 -7
  148. package/dist/__play__/grid-navigation/cell-spans-large.play.d.ts +0 -3
  149. package/dist/__play__/grid-navigation/cell-spans-large.play.js +0 -26
  150. package/dist/__play__/grid-navigation/cell-spans-with-pins.play.d.ts +0 -3
  151. package/dist/__play__/grid-navigation/cell-spans-with-pins.play.js +0 -27
  152. package/dist/__play__/grid-navigation/cell-spans.play.d.ts +0 -3
  153. package/dist/__play__/grid-navigation/cell-spans.play.js +0 -52
  154. package/dist/__play__/grid-navigation/cell-with-tabbables.play.d.ts +0 -3
  155. package/dist/__play__/grid-navigation/cell-with-tabbables.play.js +0 -47
  156. package/dist/__play__/grid-navigation/column-groups.play.d.ts +0 -3
  157. package/dist/__play__/grid-navigation/column-groups.play.js +0 -24
  158. package/dist/__play__/grid-navigation/full-width-rows.play.d.ts +0 -6
  159. package/dist/__play__/grid-navigation/full-width-rows.play.js +0 -67
  160. package/dist/__play__/grid-navigation/horizontal-navigation.pt.d.ts +0 -1
  161. package/dist/__play__/grid-navigation/horizontal-navigation.pt.js +0 -877
  162. package/dist/__play__/grid-navigation/normal-layout.play.d.ts +0 -10
  163. package/dist/__play__/grid-navigation/pinned-gap-layout.play.d.ts +0 -3
  164. package/dist/__play__/grid-navigation/pinned-gap-layout.play.js +0 -11
  165. package/dist/__play__/grid-navigation/row-detail-with-spans.play.d.ts +0 -6
  166. package/dist/__play__/grid-navigation/row-detail-with-spans.play.js +0 -79
  167. package/dist/__play__/grid-navigation/row-detail.play.d.ts +0 -6
  168. package/dist/__play__/grid-navigation/row-detail.play.js +0 -78
  169. package/dist/__play__/grid-navigation/row-detail.pt.d.ts +0 -1
  170. package/dist/__play__/grid-navigation/row-detail.pt.js +0 -68
  171. package/dist/__play__/grid-navigation/vertical-navigation.pt.d.ts +0 -1
  172. package/dist/__play__/grid-navigation/vertical-navigation.pt.js +0 -176
  173. package/dist/cells/+types.cell.d.ts +0 -13
  174. package/dist/cells/+types.cell.js +0 -1
  175. package/dist/cells/cell-default.d.ts +0 -2
  176. package/dist/cells/cell-default.js +0 -8
  177. package/dist/cells/cell-editor.d.ts +0 -6
  178. package/dist/cells/cell-editor.js +0 -110
  179. package/dist/cells/cell-spacer.d.ts +0 -9
  180. package/dist/cells/cell-spacer.js +0 -39
  181. package/dist/cells/cell.d.ts +0 -5
  182. package/dist/cells/cell.js +0 -44
  183. package/dist/cells/use-cell-style.d.ts +0 -3
  184. package/dist/cells/use-cell-style.js +0 -51
  185. package/dist/header/header-cell.d.ts +0 -10
  186. package/dist/header/header-cell.js +0 -22
  187. package/dist/header/header-group-cell.d.ts +0 -5
  188. package/dist/header/header-group-cell.js +0 -16
  189. package/dist/header/header-row.d.ts +0 -4
  190. package/dist/header/header-row.js +0 -10
  191. package/dist/header/header.d.ts +0 -1
  192. package/dist/header/header.js +0 -12
  193. package/dist/header/resize-handler.d.ts +0 -12
  194. package/dist/header/resize-handler.js +0 -136
  195. package/dist/header/use-drag-move.d.ts +0 -14
  196. package/dist/header/use-drag-move.js +0 -97
  197. package/dist/header/use-header-cell-renderer.d.ts +0 -4
  198. package/dist/header/use-header-cell-renderer.js +0 -37
  199. package/dist/root/root.js +0 -108
  200. package/dist/rows/row/context.d.ts +0 -15
  201. package/dist/rows/row/context.js +0 -14
  202. package/dist/rows/row/row.d.ts +0 -7
  203. package/dist/rows/row/row.js +0 -25
  204. package/dist/rows/row/use-row-context-value.d.ts +0 -6
  205. package/dist/rows/row/use-row-context-value.js +0 -45
  206. package/dist/rows/row-detail-row.d.ts +0 -4
  207. package/dist/rows/row-detail-row.js +0 -47
  208. package/dist/rows/row-full-width.d.ts +0 -8
  209. package/dist/rows/row-full-width.js +0 -19
  210. package/dist/rows/rows-container.d.ts +0 -1
  211. package/dist/rows/rows-container.js +0 -9
  212. package/dist/rows/rows-sections.js +0 -27
  213. package/dist/rows/scrollers/native-scroller.d.ts +0 -2
  214. package/dist/rows/scrollers/native-scroller.js +0 -4
  215. package/dist/utils/cycle-sorts.d.ts +0 -2
  216. package/dist/utils/cycle-sorts.js +0 -16
  217. package/dist/viewport/begin-editing.d.ts +0 -5
  218. package/dist/viewport/begin-editing.js +0 -15
  219. package/dist/viewport/viewport.js +0 -85
  220. /package/dist/{root → grid}/dialog-driver.d.ts +0 -0
  221. /package/dist/{root → grid}/dialog-driver.js +0 -0
  222. /package/dist/{root → grid}/popover-driver.d.ts +0 -0
  223. /package/dist/{root → grid}/popover-driver.js +0 -0
  224. /package/dist/{rows → grid}/rows-sections.d.ts +0 -0
  225. /package/dist/{viewport → grid}/viewport.d.ts +0 -0
@@ -0,0 +1,118 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useMemo } from "react";
3
+ import { useFilterSelectRoot } from "./context.js";
4
+ import { context } from "./filter-row-context.js";
5
+ import { dateOptions, filterNeedsValue, numberOptions, operatorsThatAreNumbers, operatorToOption, stringOptions, } from "./options.js";
6
+ function FilterRowImpl({ filter, children }, forwarded) {
7
+ const ctx = useFilterSelectRoot();
8
+ const index = ctx.filters.indexOf(filter);
9
+ const isLast = ctx.filters.at(-1) === filter;
10
+ if (index === -1)
11
+ throw new Error("Filter should be defined among the root filters.");
12
+ const onOperatorChange = useCallback((opt) => {
13
+ ctx.setFilters((prev) => {
14
+ const next = [...prev];
15
+ const filter = next[index];
16
+ if (filter.kind === "function")
17
+ return prev;
18
+ next[index] = {
19
+ ...filter,
20
+ operator: opt.value,
21
+ };
22
+ return next;
23
+ });
24
+ }, [ctx, index]);
25
+ const options = useMemo(() => {
26
+ if (filter.kind === "function")
27
+ return [];
28
+ if (filter.kind === "number")
29
+ return numberOptions;
30
+ if (filter.kind === "date")
31
+ return dateOptions;
32
+ return stringOptions;
33
+ }, [filter.kind]);
34
+ const operatorValue = useMemo(() => {
35
+ if (filter.kind === "function")
36
+ return { value: "-", label: "-" };
37
+ return operatorToOption[filter.operator ?? "equals"];
38
+ }, [filter]);
39
+ const value = useMemo(() => {
40
+ if (filter.kind === "function")
41
+ return null;
42
+ return filter.value;
43
+ }, [filter]);
44
+ const onValueChange = useCallback((v) => {
45
+ if (filter.kind === "function")
46
+ return;
47
+ ctx.setFilters((prev) => {
48
+ const next = [...prev];
49
+ const filter = next[index];
50
+ if (filter.kind === "function")
51
+ return prev;
52
+ if (filter.kind === "number") {
53
+ next[index] = {
54
+ ...filter,
55
+ value: filter.operator === "not_equals" || filter.operator === "equals"
56
+ ? typeof v === "number"
57
+ ? v
58
+ : !v
59
+ ? null
60
+ : Number.parseFloat(v)
61
+ : typeof v === "number"
62
+ ? v
63
+ : Number.parseFloat(v ?? ""),
64
+ };
65
+ return next;
66
+ }
67
+ const isNumber = operatorsThatAreNumbers.has(filter.operator);
68
+ next[index] = {
69
+ ...filter,
70
+ value: isNumber ? (typeof v === "number" ? v : Number.parseFloat(v)) : v,
71
+ };
72
+ return next;
73
+ });
74
+ }, [ctx, filter.kind, index]);
75
+ const extenderValue = useMemo(() => {
76
+ return filter.kind == "function" ? null : (filter.nextExtender ?? "AND");
77
+ }, [filter]);
78
+ const onExtenderChange = useCallback((v) => {
79
+ ctx.setFilters((prev) => {
80
+ const next = [...prev];
81
+ const filter = next[index];
82
+ if (filter.kind === "function")
83
+ return prev;
84
+ next[index] = {
85
+ ...filter,
86
+ nextExtender: v,
87
+ };
88
+ return next;
89
+ });
90
+ }, [ctx, index]);
91
+ const showExtender = useMemo(() => {
92
+ if (filter.kind === "function")
93
+ return false;
94
+ // If the filter isn't the last one then show the extender
95
+ if (!isLast)
96
+ return true;
97
+ if (filter.operator != null && filter.value != null && index + 1 < ctx.maxCount)
98
+ return true;
99
+ return false;
100
+ }, [ctx.maxCount, filter, index, isLast]);
101
+ return (_jsx(context.Provider, { value: {
102
+ filter,
103
+ extender: extenderValue,
104
+ onExtenderChange,
105
+ showExtender: showExtender,
106
+ operatorOnChange: onOperatorChange,
107
+ operatorOptions: options,
108
+ operatorValue: operatorValue,
109
+ value,
110
+ onValueChange,
111
+ isNumberInput: filter.kind === "function"
112
+ ? false
113
+ : filter.kind === "number" || operatorsThatAreNumbers.has(filter.operator),
114
+ filterHasNoValue: filter.kind === "function" || filterNeedsValue.has(filter.operator),
115
+ valueDisabled: filter.kind === "function" || !filter.operator,
116
+ }, children: _jsx("div", { ref: forwarded, children: children }) }));
117
+ }
118
+ export const FilterRow = forwardRef(FilterRowImpl);
@@ -0,0 +1,20 @@
1
+ import { Root } from "./root.js";
2
+ export declare const FilterSelect: {
3
+ useFilterSelect: <T>({ grid, column, maxCount }: import("./use-filter-select.js").UseFilterSelectParams<T>) => {
4
+ reset: () => void;
5
+ apply: () => void;
6
+ defaultFilter: import("./use-filter-select.js").FilterSelectFlat;
7
+ filters: import("./use-filter-select.js").FilterSelectFlat[];
8
+ setFilters: (v: import("./use-filter-select.js").FilterSelectFlat[] | ((v: import("./use-filter-select.js").FilterSelectFlat[]) => import("./use-filter-select.js").FilterSelectFlat[])) => void;
9
+ maxCount: number;
10
+ };
11
+ Root: typeof Root;
12
+ FilterRow: import("react").ForwardRefExoticComponent<import("./filter-row.js").FilterRowProps & {
13
+ children?: import("react").ReactNode | undefined;
14
+ } & import("react").RefAttributes<HTMLDivElement>>;
15
+ OperatorSelect: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLSelectElement> & import("react").SelectHTMLAttributes<HTMLSelectElement> & import("./operator-select.js").OperatorSelectProps, "ref"> & import("react").RefAttributes<HTMLSelectElement>>;
16
+ ValueInput: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & import("./value-input.js").ValueInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
17
+ FilterCombinator: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & import("./filter-combinator.js").FilterCombinatorProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
18
+ Apply: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & import("./apply.js").ApplyProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
19
+ Reset: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & import("./reset.js").ResetProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
20
+ };
@@ -0,0 +1,18 @@
1
+ import { Apply } from "./apply.js";
2
+ import { FilterCombinator } from "./filter-combinator.js";
3
+ import { FilterRow } from "./filter-row.js";
4
+ import { OperatorSelect } from "./operator-select.js";
5
+ import { Reset } from "./reset.js";
6
+ import { Root } from "./root.js";
7
+ import { useFilterSelect } from "./use-filter-select.js";
8
+ import { ValueInput } from "./value-input.js";
9
+ export const FilterSelect = {
10
+ useFilterSelect,
11
+ Root,
12
+ FilterRow,
13
+ OperatorSelect,
14
+ ValueInput,
15
+ FilterCombinator,
16
+ Apply,
17
+ Reset,
18
+ };
@@ -0,0 +1,2 @@
1
+ import type { FilterSelectFlat } from "./use-filter-select";
2
+ export declare function isCompleteFilter(c: FilterSelectFlat): boolean;
@@ -0,0 +1,5 @@
1
+ export function isCompleteFilter(c) {
2
+ if (c.kind === "function")
3
+ return true;
4
+ return c.operator != null && c.value !== undefined;
5
+ }
@@ -0,0 +1,14 @@
1
+ import { type SlotComponent } from "@1771technologies/lytenyte-core/yinternal";
2
+ export type SelectOption = {
3
+ label: string;
4
+ value: string;
5
+ };
6
+ export interface OperatorSelectSlotProps {
7
+ readonly options: SelectOption[];
8
+ readonly value: SelectOption | null;
9
+ readonly onChange: (v: SelectOption) => void;
10
+ }
11
+ export interface OperatorSelectProps {
12
+ readonly as?: SlotComponent<OperatorSelectSlotProps>;
13
+ }
14
+ export declare const OperatorSelect: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLSelectElement> & import("react").SelectHTMLAttributes<HTMLSelectElement> & OperatorSelectProps, "ref"> & import("react").RefAttributes<HTMLSelectElement>>;
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } 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 OperatorSelectImpl({ as, ...props }, ref) {
6
+ const ctx = useFilterRow();
7
+ const slot = useSlot({
8
+ props: [props],
9
+ state: {
10
+ options: ctx.operatorOptions,
11
+ value: ctx.operatorValue,
12
+ onChange: ctx.operatorOnChange,
13
+ },
14
+ ref: ref,
15
+ slot: as ?? (_jsx("select", { value: ctx.operatorValue?.value ?? "", onChange: (c) => {
16
+ const val = c.target.value;
17
+ const opt = ctx.operatorOptions.find((c) => c.value === val);
18
+ ctx.operatorOnChange(opt);
19
+ }, children: ctx.operatorOptions.map((c) => {
20
+ return (_jsx("option", { value: c.value, children: c.label }, c.value));
21
+ }) })),
22
+ });
23
+ return slot;
24
+ }
25
+ export const OperatorSelect = forwardRef(OperatorSelectImpl);
@@ -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,13 @@
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 maxCount: number;
11
+ };
12
+ }
13
+ export declare function Root({ root, children }: PropsWithChildren<RootProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { context } from "./context.js";
3
+ export function Root({ root, children }) {
4
+ return _jsx(context.Provider, { value: root, children: children });
5
+ }
@@ -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,37 @@
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
+ defaultFilter: FilterSelectFlat;
34
+ filters: FilterSelectFlat[];
35
+ setFilters: (v: FilterSelectFlat[] | ((v: FilterSelectFlat[]) => FilterSelectFlat[])) => void;
36
+ maxCount: number;
37
+ };
@@ -0,0 +1,158 @@
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
+ console.log(filters);
44
+ return filters;
45
+ }
46
+ return [];
47
+ }
48
+ return [defaultFilter];
49
+ }, [filterOnModel, defaultFilter]);
50
+ const [filters, setFilters] = useTwoFlowState(filterValue);
51
+ const finalFilters = useMemo(() => {
52
+ const last = filters.at(-1);
53
+ if (last.kind === "function" || filters.length >= maxCount)
54
+ return filters;
55
+ if (last.operator == undefined || last.value == null)
56
+ return filters;
57
+ return [...filters, defaultFilter];
58
+ }, [defaultFilter, filters, maxCount]);
59
+ const reset = useCallback(() => {
60
+ return setFilters([defaultFilter]);
61
+ }, [defaultFilter, setFilters]);
62
+ const apply = useCallback(() => {
63
+ const fn = finalFilters.find((c) => c.kind === "function");
64
+ if (fn) {
65
+ grid.state.filterModel.set((prev) => {
66
+ const next = { ...prev };
67
+ next[column.id] = { kind: "func", func: fn.func };
68
+ return prev;
69
+ });
70
+ return;
71
+ }
72
+ const filters = finalFilters.filter((c) => isCompleteFilter(c));
73
+ if (filters.length === 1) {
74
+ const filter = filters[0];
75
+ if (!isCompleteFilter(filter)) {
76
+ grid.state.filterModel.set((prev) => {
77
+ const filters = { ...prev };
78
+ delete filters[column.id];
79
+ return filters;
80
+ });
81
+ return;
82
+ }
83
+ let next = null;
84
+ if (filter.kind === "date")
85
+ next = { kind: "date", value: filter.value, operator: filter.operator };
86
+ else if (filter.kind === "number")
87
+ next = { kind: "number", value: filter.value, operator: filter.operator };
88
+ else if (filter.kind === "string")
89
+ next = { kind: "string", value: filter.value, operator: filter.operator };
90
+ if (next) {
91
+ console.log(next);
92
+ grid.state.filterModel.set((prev) => {
93
+ const filters = { ...prev };
94
+ filters[column.id] = next;
95
+ return filters;
96
+ });
97
+ }
98
+ return;
99
+ }
100
+ const combinedFilters = [];
101
+ let i = 0;
102
+ while (i < filters.length) {
103
+ const filter = filters[i];
104
+ if ((filter.nextExtender ?? "AND") === "AND") {
105
+ const ors = [filter];
106
+ while (i + 1 < filters.length) {
107
+ const next = filters[i + 1];
108
+ ors.push(next);
109
+ i++;
110
+ if ((next.nextExtender ?? "AND") !== "AND" || i + 1 >= filters.length)
111
+ break;
112
+ }
113
+ if (ors.length > 1) {
114
+ combinedFilters.push({
115
+ kind: "combination",
116
+ filters: ors.map(toFilterItem),
117
+ operator: "AND",
118
+ });
119
+ }
120
+ else {
121
+ combinedFilters.push(toFilterItem(ors[0]));
122
+ }
123
+ }
124
+ else {
125
+ combinedFilters.push(toFilterItem(filter));
126
+ }
127
+ i++;
128
+ }
129
+ grid.state.filterModel.set((prev) => {
130
+ if (combinedFilters.length === 0) {
131
+ const filters = { ...prev };
132
+ delete filters[column.id];
133
+ return filters;
134
+ }
135
+ if (combinedFilters.length === 1) {
136
+ const filters = { ...prev };
137
+ filters[column.id] = combinedFilters[0];
138
+ return filters;
139
+ }
140
+ const filters = { ...prev };
141
+ filters[column.id] = { kind: "combination", filters: combinedFilters, operator: "OR" };
142
+ return filters;
143
+ });
144
+ return;
145
+ }, [column.id, finalFilters, grid.state.filterModel]);
146
+ const setF = useCallback((v) => {
147
+ const next = typeof v === "function" ? v(finalFilters) : v;
148
+ setFilters(next);
149
+ }, [finalFilters, setFilters]);
150
+ return useMemo(() => ({
151
+ reset,
152
+ apply,
153
+ defaultFilter,
154
+ filters: finalFilters,
155
+ setFilters: setF,
156
+ maxCount,
157
+ }), [apply, defaultFilter, finalFilters, maxCount, reset, setF]);
158
+ };
@@ -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-react-hooks";
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-react-hooks";
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({});