@vuu-ui/vuu-filters 0.8.0-debug → 0.8.1-debug
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/cjs/index.js +352 -366
- package/cjs/index.js.map +4 -4
- package/esm/index.js +733 -748
- package/esm/index.js.map +4 -4
- package/package.json +5 -5
- package/types/filter-input/useFilterAutoComplete.d.ts +1 -2
package/cjs/index.js
CHANGED
|
@@ -567,52 +567,282 @@ var RangeFilter = ({
|
|
|
567
567
|
] });
|
|
568
568
|
};
|
|
569
569
|
|
|
570
|
-
//
|
|
571
|
-
var
|
|
570
|
+
// src/column-filter/TypeaheadFilter.tsx
|
|
571
|
+
var import_vuu_data_react = require("@vuu-ui/vuu-data-react");
|
|
572
|
+
var import_salt_lab2 = require("@heswell/salt-lab");
|
|
572
573
|
var import_react3 = require("react");
|
|
573
|
-
var
|
|
574
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
575
|
+
var TypeaheadFilter = ({
|
|
576
|
+
defaultTypeaheadParams,
|
|
577
|
+
filterValues = [],
|
|
578
|
+
onChange: onFilterChange
|
|
579
|
+
}) => {
|
|
580
|
+
const [tableName, columnName] = defaultTypeaheadParams;
|
|
581
|
+
const [searchValue, setSearchValue] = (0, import_react3.useState)("");
|
|
582
|
+
const [typeaheadValues, setTypeaheadValues] = (0, import_react3.useState)([]);
|
|
583
|
+
const getSuggestions = (0, import_vuu_data_react.useTypeaheadSuggestions)();
|
|
584
|
+
(0, import_react3.useEffect)(() => {
|
|
585
|
+
const params = searchValue ? [tableName, columnName, searchValue] : defaultTypeaheadParams;
|
|
586
|
+
let isSubscribed = true;
|
|
587
|
+
getSuggestions(params).then((options) => {
|
|
588
|
+
if (!isSubscribed) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (isStartsWithValue(filterValues[0])) {
|
|
592
|
+
options.unshift(filterValues[0]);
|
|
593
|
+
}
|
|
594
|
+
if (searchValue) {
|
|
595
|
+
options.unshift(`${searchValue}...`);
|
|
596
|
+
}
|
|
597
|
+
options.concat(filterValues);
|
|
598
|
+
setTypeaheadValues(options);
|
|
599
|
+
});
|
|
600
|
+
return () => {
|
|
601
|
+
isSubscribed = false;
|
|
602
|
+
};
|
|
603
|
+
}, [
|
|
604
|
+
filterValues,
|
|
605
|
+
searchValue,
|
|
606
|
+
columnName,
|
|
607
|
+
tableName,
|
|
608
|
+
getSuggestions,
|
|
609
|
+
defaultTypeaheadParams
|
|
610
|
+
]);
|
|
611
|
+
const onInputChange = (0, import_react3.useCallback)(
|
|
612
|
+
(evt) => {
|
|
613
|
+
const value = evt.target.value;
|
|
614
|
+
setSearchValue(value);
|
|
615
|
+
},
|
|
616
|
+
[]
|
|
617
|
+
);
|
|
618
|
+
const onSelectionChange = (0, import_react3.useCallback)(
|
|
619
|
+
(_evt, selected) => {
|
|
620
|
+
setSearchValue("");
|
|
621
|
+
if (selected === null)
|
|
622
|
+
return;
|
|
623
|
+
if (selected.some(isStartsWithValue)) {
|
|
624
|
+
selected = selected.filter(isStartsWithValue).slice(-1);
|
|
625
|
+
}
|
|
626
|
+
const filter = getTypeaheadFilter(
|
|
627
|
+
columnName,
|
|
628
|
+
selected,
|
|
629
|
+
isStartsWithValue(selected[0])
|
|
630
|
+
);
|
|
631
|
+
onFilterChange(selected, filter);
|
|
632
|
+
},
|
|
633
|
+
[columnName, onFilterChange]
|
|
634
|
+
);
|
|
635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
636
|
+
import_salt_lab2.ComboBoxDeprecated,
|
|
637
|
+
{
|
|
638
|
+
multiSelect: true,
|
|
639
|
+
onInputChange,
|
|
640
|
+
onChange: onSelectionChange,
|
|
641
|
+
source: typeaheadValues,
|
|
642
|
+
style: { minWidth: 200 },
|
|
643
|
+
inputValue: searchValue,
|
|
644
|
+
selectedItem: filterValues
|
|
645
|
+
},
|
|
646
|
+
columnName
|
|
647
|
+
);
|
|
648
|
+
};
|
|
574
649
|
|
|
575
|
-
//
|
|
650
|
+
// src/column-filter/ColumnListItem.tsx
|
|
576
651
|
var import_react4 = require("react");
|
|
577
|
-
var
|
|
652
|
+
var import_salt_lab3 = require("@heswell/salt-lab");
|
|
653
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
654
|
+
var ColumnListItem = (props) => {
|
|
655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MemoColumnItem, { ...props });
|
|
656
|
+
};
|
|
657
|
+
var MemoColumnItem = (0, import_react4.memo)(function MemoizedItem({
|
|
658
|
+
item,
|
|
659
|
+
itemTextHighlightPattern,
|
|
660
|
+
...restProps
|
|
661
|
+
}) {
|
|
662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_salt_lab3.ListItem, { ...restProps, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { marginLeft: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
663
|
+
import_salt_lab3.Highlighter,
|
|
664
|
+
{
|
|
665
|
+
matchPattern: itemTextHighlightPattern,
|
|
666
|
+
text: item == null ? void 0 : item.name
|
|
667
|
+
}
|
|
668
|
+
) }) });
|
|
669
|
+
});
|
|
578
670
|
|
|
579
|
-
//
|
|
671
|
+
// src/column-filter/useColumnFilterStore.ts
|
|
672
|
+
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
580
673
|
var import_react5 = require("react");
|
|
581
|
-
var
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
};
|
|
608
|
-
const
|
|
609
|
-
|
|
674
|
+
var addOrReplace = (array, newValue, key) => array.filter((oldValue) => oldValue[key] !== newValue[key]).concat(newValue);
|
|
675
|
+
var useColumnFilterStore = (onFilterSubmit) => {
|
|
676
|
+
var _a, _b;
|
|
677
|
+
const [selectedColumnName, setSelectedColumnName] = (0, import_react5.useState)("");
|
|
678
|
+
const [savedFilters, setSavedFilters] = (0, import_react5.useState)([]);
|
|
679
|
+
const [rangeValues, setRangeValues] = (0, import_react5.useState)([]);
|
|
680
|
+
const [typeaheadValues, setTypeaheadValues] = (0, import_react5.useState)([]);
|
|
681
|
+
const clear = () => {
|
|
682
|
+
setSelectedColumnName("");
|
|
683
|
+
setRangeValues([]);
|
|
684
|
+
setTypeaheadValues([]);
|
|
685
|
+
setSavedFilters([]);
|
|
686
|
+
onFilterSubmit({ filter: "" });
|
|
687
|
+
};
|
|
688
|
+
const updateFilters = (0, import_react5.useCallback)(
|
|
689
|
+
(newFilter) => {
|
|
690
|
+
const newSavedFilters = addOrReplace(
|
|
691
|
+
savedFilters,
|
|
692
|
+
{ column: selectedColumnName, filter: newFilter },
|
|
693
|
+
"column"
|
|
694
|
+
);
|
|
695
|
+
setSavedFilters(newSavedFilters);
|
|
696
|
+
const combinedFilter = newSavedFilters.map((x) => x.filter).reduce((prev, filter) => {
|
|
697
|
+
if (filter === void 0)
|
|
698
|
+
return prev;
|
|
699
|
+
return addFilter(prev, filter, { combineWith: AND });
|
|
700
|
+
}, void 0);
|
|
701
|
+
const query = combinedFilter === void 0 ? "" : (0, import_vuu_utils2.filterAsQuery)(combinedFilter);
|
|
702
|
+
onFilterSubmit({ filter: query, filterStruct: combinedFilter });
|
|
703
|
+
},
|
|
704
|
+
[selectedColumnName, onFilterSubmit, savedFilters]
|
|
705
|
+
);
|
|
706
|
+
const onTypeaheadChange = (0, import_react5.useCallback)(
|
|
707
|
+
(newValues, newFilter) => {
|
|
708
|
+
setTypeaheadValues(
|
|
709
|
+
addOrReplace(
|
|
710
|
+
typeaheadValues,
|
|
711
|
+
{ column: selectedColumnName, value: newValues },
|
|
712
|
+
"column"
|
|
713
|
+
)
|
|
714
|
+
);
|
|
715
|
+
updateFilters(newFilter);
|
|
716
|
+
},
|
|
717
|
+
[selectedColumnName, typeaheadValues, updateFilters]
|
|
718
|
+
);
|
|
719
|
+
const onRangeChange = (0, import_react5.useCallback)(
|
|
720
|
+
(newValues, newFilter) => {
|
|
721
|
+
setRangeValues(
|
|
722
|
+
addOrReplace(
|
|
723
|
+
rangeValues,
|
|
724
|
+
{ column: selectedColumnName, value: newValues },
|
|
725
|
+
"column"
|
|
726
|
+
)
|
|
727
|
+
);
|
|
728
|
+
updateFilters(newFilter);
|
|
610
729
|
},
|
|
730
|
+
[selectedColumnName, rangeValues, updateFilters]
|
|
731
|
+
);
|
|
732
|
+
const onSelectedColumnChange = (0, import_react5.useCallback)(
|
|
733
|
+
(column) => setSelectedColumnName((column == null ? void 0 : column.name) || ""),
|
|
611
734
|
[]
|
|
612
735
|
);
|
|
613
|
-
|
|
736
|
+
const rangeValue = (_a = rangeValues.filter(
|
|
737
|
+
(v) => v.column === selectedColumnName
|
|
738
|
+
)[0]) == null ? void 0 : _a.value;
|
|
739
|
+
const typeaheadValue = (_b = typeaheadValues.filter(
|
|
740
|
+
(v) => v.column === selectedColumnName
|
|
741
|
+
)[0]) == null ? void 0 : _b.value;
|
|
742
|
+
return {
|
|
743
|
+
clear,
|
|
744
|
+
selectedColumnName,
|
|
745
|
+
rangeValue,
|
|
746
|
+
typeaheadValue,
|
|
747
|
+
onSelectedColumnChange,
|
|
748
|
+
onRangeChange,
|
|
749
|
+
onTypeaheadChange
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
// src/column-filter/ColumnFilter.tsx
|
|
754
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
755
|
+
var ColumnFilter = ({
|
|
756
|
+
className,
|
|
757
|
+
table,
|
|
758
|
+
columns,
|
|
759
|
+
onFilterSubmit,
|
|
760
|
+
...htmlAttributes
|
|
761
|
+
}) => {
|
|
762
|
+
const {
|
|
763
|
+
clear,
|
|
764
|
+
onTypeaheadChange,
|
|
765
|
+
onRangeChange,
|
|
766
|
+
onSelectedColumnChange,
|
|
767
|
+
selectedColumnName,
|
|
768
|
+
rangeValue,
|
|
769
|
+
typeaheadValue
|
|
770
|
+
} = useColumnFilterStore(onFilterSubmit);
|
|
771
|
+
const getFilterComponent = () => {
|
|
772
|
+
var _a;
|
|
773
|
+
const defaultTypeaheadParams = [table, selectedColumnName];
|
|
774
|
+
const selectedColumnType = (_a = columns.find(
|
|
775
|
+
(column) => column.name === selectedColumnName
|
|
776
|
+
)) == null ? void 0 : _a.serverDataType;
|
|
777
|
+
switch (selectedColumnType) {
|
|
778
|
+
case "string":
|
|
779
|
+
case "char":
|
|
780
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
781
|
+
import_salt_lab4.ToolbarField,
|
|
782
|
+
{
|
|
783
|
+
label: "Start typing to select a filter",
|
|
784
|
+
labelPlacement: "top",
|
|
785
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
786
|
+
TypeaheadFilter,
|
|
787
|
+
{
|
|
788
|
+
defaultTypeaheadParams,
|
|
789
|
+
filterValues: typeaheadValue,
|
|
790
|
+
onChange: onTypeaheadChange
|
|
791
|
+
}
|
|
792
|
+
)
|
|
793
|
+
}
|
|
794
|
+
);
|
|
795
|
+
case "int":
|
|
796
|
+
case "long":
|
|
797
|
+
case "double":
|
|
798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab4.ToolbarField, { label: "Select a range", labelPlacement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
799
|
+
RangeFilter,
|
|
800
|
+
{
|
|
801
|
+
defaultTypeaheadParams,
|
|
802
|
+
filterValues: rangeValue,
|
|
803
|
+
onChange: onRangeChange
|
|
804
|
+
}
|
|
805
|
+
) });
|
|
806
|
+
default:
|
|
807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab4.ToolbarField, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core.Text, { children: "Data type unsupported" }) });
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
811
|
+
import_salt_lab4.Toolbar,
|
|
812
|
+
{
|
|
813
|
+
...htmlAttributes,
|
|
814
|
+
style: { alignItems: "center", height: "36px" },
|
|
815
|
+
children: [
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
817
|
+
import_salt_lab4.ToolbarField,
|
|
818
|
+
{
|
|
819
|
+
label: "Select a column to filter",
|
|
820
|
+
labelPlacement: "top",
|
|
821
|
+
style: { width: 180 },
|
|
822
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
823
|
+
import_salt_lab4.Dropdown,
|
|
824
|
+
{
|
|
825
|
+
source: columns,
|
|
826
|
+
ListItem: ColumnListItem,
|
|
827
|
+
itemToString: (column) => column.name,
|
|
828
|
+
onSelectionChange: (_evt, column) => onSelectedColumnChange(column)
|
|
829
|
+
}
|
|
830
|
+
)
|
|
831
|
+
}
|
|
832
|
+
),
|
|
833
|
+
selectedColumnName && getFilterComponent(),
|
|
834
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab4.ToolbarButton, { onClick: clear, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DeleteIcon, {}) })
|
|
835
|
+
]
|
|
836
|
+
}
|
|
837
|
+
);
|
|
614
838
|
};
|
|
615
839
|
|
|
840
|
+
// src/filter-input/FilterInput.tsx
|
|
841
|
+
var import_core2 = require("@salt-ds/core");
|
|
842
|
+
|
|
843
|
+
// src/filter-input/useCodeMirrorEditor.ts
|
|
844
|
+
var import_vuu_codemirror5 = require("@vuu-ui/vuu-codemirror");
|
|
845
|
+
|
|
616
846
|
// ../../node_modules/@lezer/common/dist/index.js
|
|
617
847
|
var DefaultBufferLength = 1024;
|
|
618
848
|
var nextPropID = 0;
|
|
@@ -2213,26 +2443,58 @@ var Stack = class {
|
|
|
2213
2443
|
// be done.
|
|
2214
2444
|
/// @internal
|
|
2215
2445
|
forceReduce() {
|
|
2216
|
-
let
|
|
2446
|
+
let { parser: parser2 } = this.p;
|
|
2447
|
+
let reduce = parser2.stateSlot(
|
|
2217
2448
|
this.state,
|
|
2218
2449
|
5
|
|
2219
2450
|
/* ParseState.ForcedReduce */
|
|
2220
2451
|
);
|
|
2221
2452
|
if ((reduce & 65536) == 0)
|
|
2222
2453
|
return false;
|
|
2223
|
-
let { parser: parser2 } = this.p;
|
|
2224
2454
|
if (!parser2.validAction(this.state, reduce)) {
|
|
2225
2455
|
let depth = reduce >> 19, term = reduce & 65535;
|
|
2226
2456
|
let target = this.stack.length - depth * 3;
|
|
2227
|
-
if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0)
|
|
2228
|
-
|
|
2229
|
-
|
|
2457
|
+
if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0) {
|
|
2458
|
+
let backup = this.findForcedReduction();
|
|
2459
|
+
if (backup == null)
|
|
2460
|
+
return false;
|
|
2461
|
+
reduce = backup;
|
|
2462
|
+
}
|
|
2463
|
+
this.storeNode(0, this.pos, this.pos, 4, true);
|
|
2230
2464
|
this.score -= 100;
|
|
2231
2465
|
}
|
|
2232
2466
|
this.reducePos = this.pos;
|
|
2233
2467
|
this.reduce(reduce);
|
|
2234
2468
|
return true;
|
|
2235
2469
|
}
|
|
2470
|
+
/// Try to scan through the automaton to find some kind of reduction
|
|
2471
|
+
/// that can be applied. Used when the regular ForcedReduce field
|
|
2472
|
+
/// isn't a valid action. @internal
|
|
2473
|
+
findForcedReduction() {
|
|
2474
|
+
let { parser: parser2 } = this.p, seen = [];
|
|
2475
|
+
let explore = (state, depth) => {
|
|
2476
|
+
if (seen.includes(state))
|
|
2477
|
+
return;
|
|
2478
|
+
seen.push(state);
|
|
2479
|
+
return parser2.allActions(state, (action) => {
|
|
2480
|
+
if (action & (262144 | 131072))
|
|
2481
|
+
;
|
|
2482
|
+
else if (action & 65536) {
|
|
2483
|
+
let rDepth = (action >> 19) - depth;
|
|
2484
|
+
if (rDepth > 1) {
|
|
2485
|
+
let term = action & 65535, target = this.stack.length - rDepth * 3;
|
|
2486
|
+
if (target >= 0 && parser2.getGoto(this.stack[target], term, false) >= 0)
|
|
2487
|
+
return rDepth << 19 | 65536 | term;
|
|
2488
|
+
}
|
|
2489
|
+
} else {
|
|
2490
|
+
let found = explore(action, depth + 1);
|
|
2491
|
+
if (found != null)
|
|
2492
|
+
return found;
|
|
2493
|
+
}
|
|
2494
|
+
});
|
|
2495
|
+
};
|
|
2496
|
+
return explore(this.state, 0);
|
|
2497
|
+
}
|
|
2236
2498
|
/// @internal
|
|
2237
2499
|
forceAll() {
|
|
2238
2500
|
while (!this.p.parser.stateFlag(
|
|
@@ -2301,13 +2563,13 @@ var Stack = class {
|
|
|
2301
2563
|
emitContext() {
|
|
2302
2564
|
let last = this.buffer.length - 1;
|
|
2303
2565
|
if (last < 0 || this.buffer[last] != -3)
|
|
2304
|
-
this.buffer.push(this.curContext.hash, this.
|
|
2566
|
+
this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
|
|
2305
2567
|
}
|
|
2306
2568
|
/// @internal
|
|
2307
2569
|
emitLookAhead() {
|
|
2308
2570
|
let last = this.buffer.length - 1;
|
|
2309
2571
|
if (last < 0 || this.buffer[last] != -4)
|
|
2310
|
-
this.buffer.push(this.lookAhead, this.
|
|
2572
|
+
this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
|
|
2311
2573
|
}
|
|
2312
2574
|
updateContext(context) {
|
|
2313
2575
|
if (context != this.curContext.context) {
|
|
@@ -2664,16 +2926,17 @@ var LocalTokenGroup = class {
|
|
|
2664
2926
|
token(input, stack) {
|
|
2665
2927
|
let start = input.pos, skipped = 0;
|
|
2666
2928
|
for (; ; ) {
|
|
2929
|
+
let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
|
|
2667
2930
|
readToken(this.data, input, stack, 0, this.data, this.precTable);
|
|
2668
2931
|
if (input.token.value > -1)
|
|
2669
2932
|
break;
|
|
2670
2933
|
if (this.elseToken == null)
|
|
2671
2934
|
return;
|
|
2672
|
-
if (
|
|
2935
|
+
if (!atEof)
|
|
2936
|
+
skipped++;
|
|
2937
|
+
if (nextPos == null)
|
|
2673
2938
|
break;
|
|
2674
|
-
input.
|
|
2675
|
-
input.reset(input.pos, input.token);
|
|
2676
|
-
skipped++;
|
|
2939
|
+
input.reset(nextPos, input.token);
|
|
2677
2940
|
}
|
|
2678
2941
|
if (skipped) {
|
|
2679
2942
|
input.reset(start, input.token);
|
|
@@ -3386,26 +3649,30 @@ var LRParser = class extends Parser {
|
|
|
3386
3649
|
}
|
|
3387
3650
|
/// @internal
|
|
3388
3651
|
validAction(state, action) {
|
|
3389
|
-
|
|
3652
|
+
return !!this.allActions(state, (a) => a == action ? true : null);
|
|
3653
|
+
}
|
|
3654
|
+
/// @internal
|
|
3655
|
+
allActions(state, action) {
|
|
3656
|
+
let deflt = this.stateSlot(
|
|
3390
3657
|
state,
|
|
3391
3658
|
4
|
|
3392
3659
|
/* ParseState.DefaultReduce */
|
|
3393
|
-
)
|
|
3394
|
-
|
|
3660
|
+
);
|
|
3661
|
+
let result = deflt ? action(deflt) : void 0;
|
|
3395
3662
|
for (let i = this.stateSlot(
|
|
3396
3663
|
state,
|
|
3397
3664
|
1
|
|
3398
3665
|
/* ParseState.Actions */
|
|
3399
|
-
); ; i += 3) {
|
|
3666
|
+
); result == null; i += 3) {
|
|
3400
3667
|
if (this.data[i] == 65535) {
|
|
3401
3668
|
if (this.data[i + 1] == 1)
|
|
3402
3669
|
i = pair(this.data, i + 2);
|
|
3403
3670
|
else
|
|
3404
|
-
|
|
3671
|
+
break;
|
|
3405
3672
|
}
|
|
3406
|
-
|
|
3407
|
-
return true;
|
|
3673
|
+
result = action(pair(this.data, i + 1));
|
|
3408
3674
|
}
|
|
3675
|
+
return result;
|
|
3409
3676
|
}
|
|
3410
3677
|
/// Get the states that can follow this one through shift actions or
|
|
3411
3678
|
/// goto jumps. @internal
|
|
@@ -3678,291 +3945,9 @@ var walkTree = (tree, source) => {
|
|
|
3678
3945
|
// ../vuu-filter-parser/src/FilterParser.ts
|
|
3679
3946
|
var strictParser = parser.configure({ strict: true });
|
|
3680
3947
|
|
|
3681
|
-
// ../vuu-data-react/src/hooks/useVuuMenuActions.ts
|
|
3682
|
-
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
3683
|
-
var import_react7 = require("react");
|
|
3684
|
-
var { KEY } = import_vuu_utils4.metadataKeys;
|
|
3685
|
-
|
|
3686
|
-
// ../vuu-data-react/src/hooks/useVuuTables.ts
|
|
3687
|
-
var import_react8 = require("react");
|
|
3688
|
-
var import_vuu_data4 = require("@vuu-ui/vuu-data");
|
|
3689
|
-
|
|
3690
|
-
// src/column-filter/TypeaheadFilter.tsx
|
|
3691
|
-
var import_salt_lab2 = require("@heswell/salt-lab");
|
|
3692
|
-
var import_react9 = require("react");
|
|
3693
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
3694
|
-
var TypeaheadFilter = ({
|
|
3695
|
-
defaultTypeaheadParams,
|
|
3696
|
-
filterValues = [],
|
|
3697
|
-
onChange: onFilterChange
|
|
3698
|
-
}) => {
|
|
3699
|
-
const [tableName, columnName] = defaultTypeaheadParams;
|
|
3700
|
-
const [searchValue, setSearchValue] = (0, import_react9.useState)("");
|
|
3701
|
-
const [typeaheadValues, setTypeaheadValues] = (0, import_react9.useState)([]);
|
|
3702
|
-
const getSuggestions = useTypeaheadSuggestions();
|
|
3703
|
-
(0, import_react9.useEffect)(() => {
|
|
3704
|
-
const params = searchValue ? [tableName, columnName, searchValue] : defaultTypeaheadParams;
|
|
3705
|
-
let isSubscribed = true;
|
|
3706
|
-
getSuggestions(params).then((options) => {
|
|
3707
|
-
if (!isSubscribed) {
|
|
3708
|
-
return;
|
|
3709
|
-
}
|
|
3710
|
-
if (isStartsWithValue(filterValues[0])) {
|
|
3711
|
-
options.unshift(filterValues[0]);
|
|
3712
|
-
}
|
|
3713
|
-
if (searchValue) {
|
|
3714
|
-
options.unshift(`${searchValue}...`);
|
|
3715
|
-
}
|
|
3716
|
-
options.concat(filterValues);
|
|
3717
|
-
setTypeaheadValues(options);
|
|
3718
|
-
});
|
|
3719
|
-
return () => {
|
|
3720
|
-
isSubscribed = false;
|
|
3721
|
-
};
|
|
3722
|
-
}, [
|
|
3723
|
-
filterValues,
|
|
3724
|
-
searchValue,
|
|
3725
|
-
columnName,
|
|
3726
|
-
tableName,
|
|
3727
|
-
getSuggestions,
|
|
3728
|
-
defaultTypeaheadParams
|
|
3729
|
-
]);
|
|
3730
|
-
const onInputChange = (0, import_react9.useCallback)(
|
|
3731
|
-
(evt) => {
|
|
3732
|
-
const value = evt.target.value;
|
|
3733
|
-
setSearchValue(value);
|
|
3734
|
-
},
|
|
3735
|
-
[]
|
|
3736
|
-
);
|
|
3737
|
-
const onSelectionChange = (0, import_react9.useCallback)(
|
|
3738
|
-
(_evt, selected) => {
|
|
3739
|
-
setSearchValue("");
|
|
3740
|
-
if (selected === null)
|
|
3741
|
-
return;
|
|
3742
|
-
if (selected.some(isStartsWithValue)) {
|
|
3743
|
-
selected = selected.filter(isStartsWithValue).slice(-1);
|
|
3744
|
-
}
|
|
3745
|
-
const filter = getTypeaheadFilter(
|
|
3746
|
-
columnName,
|
|
3747
|
-
selected,
|
|
3748
|
-
isStartsWithValue(selected[0])
|
|
3749
|
-
);
|
|
3750
|
-
onFilterChange(selected, filter);
|
|
3751
|
-
},
|
|
3752
|
-
[columnName, onFilterChange]
|
|
3753
|
-
);
|
|
3754
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3755
|
-
import_salt_lab2.ComboBoxDeprecated,
|
|
3756
|
-
{
|
|
3757
|
-
multiSelect: true,
|
|
3758
|
-
onInputChange,
|
|
3759
|
-
onChange: onSelectionChange,
|
|
3760
|
-
source: typeaheadValues,
|
|
3761
|
-
style: { minWidth: 200 },
|
|
3762
|
-
inputValue: searchValue,
|
|
3763
|
-
selectedItem: filterValues
|
|
3764
|
-
},
|
|
3765
|
-
columnName
|
|
3766
|
-
);
|
|
3767
|
-
};
|
|
3768
|
-
|
|
3769
|
-
// src/column-filter/ColumnListItem.tsx
|
|
3770
|
-
var import_react10 = require("react");
|
|
3771
|
-
var import_salt_lab3 = require("@heswell/salt-lab");
|
|
3772
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3773
|
-
var ColumnListItem = (props) => {
|
|
3774
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MemoColumnItem, { ...props });
|
|
3775
|
-
};
|
|
3776
|
-
var MemoColumnItem = (0, import_react10.memo)(function MemoizedItem({
|
|
3777
|
-
item,
|
|
3778
|
-
itemTextHighlightPattern,
|
|
3779
|
-
...restProps
|
|
3780
|
-
}) {
|
|
3781
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_salt_lab3.ListItem, { ...restProps, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { marginLeft: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3782
|
-
import_salt_lab3.Highlighter,
|
|
3783
|
-
{
|
|
3784
|
-
matchPattern: itemTextHighlightPattern,
|
|
3785
|
-
text: item == null ? void 0 : item.name
|
|
3786
|
-
}
|
|
3787
|
-
) }) });
|
|
3788
|
-
});
|
|
3789
|
-
|
|
3790
|
-
// src/column-filter/useColumnFilterStore.ts
|
|
3791
|
-
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
3792
|
-
var import_react11 = require("react");
|
|
3793
|
-
var addOrReplace = (array, newValue, key) => array.filter((oldValue) => oldValue[key] !== newValue[key]).concat(newValue);
|
|
3794
|
-
var useColumnFilterStore = (onFilterSubmit) => {
|
|
3795
|
-
var _a, _b;
|
|
3796
|
-
const [selectedColumnName, setSelectedColumnName] = (0, import_react11.useState)("");
|
|
3797
|
-
const [savedFilters, setSavedFilters] = (0, import_react11.useState)([]);
|
|
3798
|
-
const [rangeValues, setRangeValues] = (0, import_react11.useState)([]);
|
|
3799
|
-
const [typeaheadValues, setTypeaheadValues] = (0, import_react11.useState)([]);
|
|
3800
|
-
const clear = () => {
|
|
3801
|
-
setSelectedColumnName("");
|
|
3802
|
-
setRangeValues([]);
|
|
3803
|
-
setTypeaheadValues([]);
|
|
3804
|
-
setSavedFilters([]);
|
|
3805
|
-
onFilterSubmit({ filter: "" });
|
|
3806
|
-
};
|
|
3807
|
-
const updateFilters = (0, import_react11.useCallback)(
|
|
3808
|
-
(newFilter) => {
|
|
3809
|
-
const newSavedFilters = addOrReplace(
|
|
3810
|
-
savedFilters,
|
|
3811
|
-
{ column: selectedColumnName, filter: newFilter },
|
|
3812
|
-
"column"
|
|
3813
|
-
);
|
|
3814
|
-
setSavedFilters(newSavedFilters);
|
|
3815
|
-
const combinedFilter = newSavedFilters.map((x) => x.filter).reduce((prev, filter) => {
|
|
3816
|
-
if (filter === void 0)
|
|
3817
|
-
return prev;
|
|
3818
|
-
return addFilter(prev, filter, { combineWith: AND });
|
|
3819
|
-
}, void 0);
|
|
3820
|
-
const query = combinedFilter === void 0 ? "" : (0, import_vuu_utils5.filterAsQuery)(combinedFilter);
|
|
3821
|
-
onFilterSubmit({ filter: query, filterStruct: combinedFilter });
|
|
3822
|
-
},
|
|
3823
|
-
[selectedColumnName, onFilterSubmit, savedFilters]
|
|
3824
|
-
);
|
|
3825
|
-
const onTypeaheadChange = (0, import_react11.useCallback)(
|
|
3826
|
-
(newValues, newFilter) => {
|
|
3827
|
-
setTypeaheadValues(
|
|
3828
|
-
addOrReplace(
|
|
3829
|
-
typeaheadValues,
|
|
3830
|
-
{ column: selectedColumnName, value: newValues },
|
|
3831
|
-
"column"
|
|
3832
|
-
)
|
|
3833
|
-
);
|
|
3834
|
-
updateFilters(newFilter);
|
|
3835
|
-
},
|
|
3836
|
-
[selectedColumnName, typeaheadValues, updateFilters]
|
|
3837
|
-
);
|
|
3838
|
-
const onRangeChange = (0, import_react11.useCallback)(
|
|
3839
|
-
(newValues, newFilter) => {
|
|
3840
|
-
setRangeValues(
|
|
3841
|
-
addOrReplace(
|
|
3842
|
-
rangeValues,
|
|
3843
|
-
{ column: selectedColumnName, value: newValues },
|
|
3844
|
-
"column"
|
|
3845
|
-
)
|
|
3846
|
-
);
|
|
3847
|
-
updateFilters(newFilter);
|
|
3848
|
-
},
|
|
3849
|
-
[selectedColumnName, rangeValues, updateFilters]
|
|
3850
|
-
);
|
|
3851
|
-
const onSelectedColumnChange = (0, import_react11.useCallback)(
|
|
3852
|
-
(column) => setSelectedColumnName((column == null ? void 0 : column.name) || ""),
|
|
3853
|
-
[]
|
|
3854
|
-
);
|
|
3855
|
-
const rangeValue = (_a = rangeValues.filter(
|
|
3856
|
-
(v) => v.column === selectedColumnName
|
|
3857
|
-
)[0]) == null ? void 0 : _a.value;
|
|
3858
|
-
const typeaheadValue = (_b = typeaheadValues.filter(
|
|
3859
|
-
(v) => v.column === selectedColumnName
|
|
3860
|
-
)[0]) == null ? void 0 : _b.value;
|
|
3861
|
-
return {
|
|
3862
|
-
clear,
|
|
3863
|
-
selectedColumnName,
|
|
3864
|
-
rangeValue,
|
|
3865
|
-
typeaheadValue,
|
|
3866
|
-
onSelectedColumnChange,
|
|
3867
|
-
onRangeChange,
|
|
3868
|
-
onTypeaheadChange
|
|
3869
|
-
};
|
|
3870
|
-
};
|
|
3871
|
-
|
|
3872
|
-
// src/column-filter/ColumnFilter.tsx
|
|
3873
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3874
|
-
var ColumnFilter = ({
|
|
3875
|
-
className,
|
|
3876
|
-
table,
|
|
3877
|
-
columns,
|
|
3878
|
-
onFilterSubmit,
|
|
3879
|
-
...htmlAttributes
|
|
3880
|
-
}) => {
|
|
3881
|
-
const {
|
|
3882
|
-
clear,
|
|
3883
|
-
onTypeaheadChange,
|
|
3884
|
-
onRangeChange,
|
|
3885
|
-
onSelectedColumnChange,
|
|
3886
|
-
selectedColumnName,
|
|
3887
|
-
rangeValue,
|
|
3888
|
-
typeaheadValue
|
|
3889
|
-
} = useColumnFilterStore(onFilterSubmit);
|
|
3890
|
-
const getFilterComponent = () => {
|
|
3891
|
-
var _a;
|
|
3892
|
-
const defaultTypeaheadParams = [table, selectedColumnName];
|
|
3893
|
-
const selectedColumnType = (_a = columns.find(
|
|
3894
|
-
(column) => column.name === selectedColumnName
|
|
3895
|
-
)) == null ? void 0 : _a.serverDataType;
|
|
3896
|
-
switch (selectedColumnType) {
|
|
3897
|
-
case "string":
|
|
3898
|
-
case "char":
|
|
3899
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3900
|
-
import_salt_lab4.ToolbarField,
|
|
3901
|
-
{
|
|
3902
|
-
label: "Start typing to select a filter",
|
|
3903
|
-
labelPlacement: "top",
|
|
3904
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3905
|
-
TypeaheadFilter,
|
|
3906
|
-
{
|
|
3907
|
-
defaultTypeaheadParams,
|
|
3908
|
-
filterValues: typeaheadValue,
|
|
3909
|
-
onChange: onTypeaheadChange
|
|
3910
|
-
}
|
|
3911
|
-
)
|
|
3912
|
-
}
|
|
3913
|
-
);
|
|
3914
|
-
case "int":
|
|
3915
|
-
case "long":
|
|
3916
|
-
case "double":
|
|
3917
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab4.ToolbarField, { label: "Select a range", labelPlacement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3918
|
-
RangeFilter,
|
|
3919
|
-
{
|
|
3920
|
-
defaultTypeaheadParams,
|
|
3921
|
-
filterValues: rangeValue,
|
|
3922
|
-
onChange: onRangeChange
|
|
3923
|
-
}
|
|
3924
|
-
) });
|
|
3925
|
-
default:
|
|
3926
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab4.ToolbarField, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core.Text, { children: "Data type unsupported" }) });
|
|
3927
|
-
}
|
|
3928
|
-
};
|
|
3929
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3930
|
-
import_salt_lab4.Toolbar,
|
|
3931
|
-
{
|
|
3932
|
-
...htmlAttributes,
|
|
3933
|
-
style: { alignItems: "center", height: "36px" },
|
|
3934
|
-
children: [
|
|
3935
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3936
|
-
import_salt_lab4.ToolbarField,
|
|
3937
|
-
{
|
|
3938
|
-
label: "Select a column to filter",
|
|
3939
|
-
labelPlacement: "top",
|
|
3940
|
-
style: { width: 180 },
|
|
3941
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3942
|
-
import_salt_lab4.Dropdown,
|
|
3943
|
-
{
|
|
3944
|
-
source: columns,
|
|
3945
|
-
ListItem: ColumnListItem,
|
|
3946
|
-
itemToString: (column) => column.name,
|
|
3947
|
-
onSelectionChange: (_evt, column) => onSelectedColumnChange(column)
|
|
3948
|
-
}
|
|
3949
|
-
)
|
|
3950
|
-
}
|
|
3951
|
-
),
|
|
3952
|
-
selectedColumnName && getFilterComponent(),
|
|
3953
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab4.ToolbarButton, { onClick: clear, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DeleteIcon, {}) })
|
|
3954
|
-
]
|
|
3955
|
-
}
|
|
3956
|
-
);
|
|
3957
|
-
};
|
|
3958
|
-
|
|
3959
|
-
// src/filter-input/FilterInput.tsx
|
|
3960
|
-
var import_core2 = require("@salt-ds/core");
|
|
3961
|
-
|
|
3962
3948
|
// src/filter-input/useCodeMirrorEditor.ts
|
|
3963
|
-
var import_vuu_codemirror5 = require("@vuu-ui/vuu-codemirror");
|
|
3964
3949
|
var import_classnames = __toESM(require_classnames(), 1);
|
|
3965
|
-
var
|
|
3950
|
+
var import_react7 = require("react");
|
|
3966
3951
|
|
|
3967
3952
|
// src/filter-input/FilterLanguage.ts
|
|
3968
3953
|
var import_vuu_codemirror = require("@vuu-ui/vuu-codemirror");
|
|
@@ -4067,7 +4052,7 @@ var vuuTheme = import_vuu_codemirror3.EditorView.theme(
|
|
|
4067
4052
|
|
|
4068
4053
|
// src/filter-input/useFilterAutoComplete.ts
|
|
4069
4054
|
var import_vuu_codemirror4 = require("@vuu-ui/vuu-codemirror");
|
|
4070
|
-
var
|
|
4055
|
+
var import_react6 = require("react");
|
|
4071
4056
|
var getOperator = (node, state) => {
|
|
4072
4057
|
let maybeColumnNode = node.prevSibling || node.parent;
|
|
4073
4058
|
while (maybeColumnNode && !["Column", "Operator", "In"].includes(maybeColumnNode.name)) {
|
|
@@ -4137,7 +4122,7 @@ var getSetValues = (node, state) => {
|
|
|
4137
4122
|
return values;
|
|
4138
4123
|
};
|
|
4139
4124
|
var useAutoComplete = (suggestionProvider, onSubmit, existingFilter) => {
|
|
4140
|
-
const makeSuggestions = (0,
|
|
4125
|
+
const makeSuggestions = (0, import_react6.useCallback)(
|
|
4141
4126
|
async (context, suggestionType, optionalArgs = {}) => {
|
|
4142
4127
|
const { startsWith = "" } = optionalArgs;
|
|
4143
4128
|
const options = await suggestionProvider.getSuggestions(
|
|
@@ -4148,7 +4133,7 @@ var useAutoComplete = (suggestionProvider, onSubmit, existingFilter) => {
|
|
|
4148
4133
|
},
|
|
4149
4134
|
[suggestionProvider]
|
|
4150
4135
|
);
|
|
4151
|
-
return (0,
|
|
4136
|
+
return (0, import_react6.useCallback)(
|
|
4152
4137
|
async (context) => {
|
|
4153
4138
|
var _a, _b;
|
|
4154
4139
|
const { state, pos } = context;
|
|
@@ -4332,15 +4317,15 @@ var useCodeMirrorEditor = ({
|
|
|
4332
4317
|
onSubmitFilter,
|
|
4333
4318
|
suggestionProvider
|
|
4334
4319
|
}) => {
|
|
4335
|
-
const editorRef = (0,
|
|
4336
|
-
const onSubmit = (0,
|
|
4337
|
-
const viewRef = (0,
|
|
4320
|
+
const editorRef = (0, import_react7.useRef)(null);
|
|
4321
|
+
const onSubmit = (0, import_react7.useRef)(noop);
|
|
4322
|
+
const viewRef = (0, import_react7.useRef)();
|
|
4338
4323
|
const completionFn = useAutoComplete(
|
|
4339
4324
|
suggestionProvider,
|
|
4340
4325
|
onSubmit,
|
|
4341
4326
|
existingFilter
|
|
4342
4327
|
);
|
|
4343
|
-
const [createState, clearInput] = (0,
|
|
4328
|
+
const [createState, clearInput] = (0, import_react7.useMemo)(() => {
|
|
4344
4329
|
const parseFilter2 = () => {
|
|
4345
4330
|
const view = getView(viewRef);
|
|
4346
4331
|
const source = view.state.doc.toString();
|
|
@@ -4415,7 +4400,7 @@ var useCodeMirrorEditor = ({
|
|
|
4415
4400
|
};
|
|
4416
4401
|
return [createState2, clearInput2];
|
|
4417
4402
|
}, [completionFn, onSubmitFilter]);
|
|
4418
|
-
(0,
|
|
4403
|
+
(0, import_react7.useEffect)(() => {
|
|
4419
4404
|
if (!editorRef.current) {
|
|
4420
4405
|
throw Error("editor not in dom");
|
|
4421
4406
|
}
|
|
@@ -4470,16 +4455,17 @@ var FilterInput = ({
|
|
|
4470
4455
|
|
|
4471
4456
|
// src/filter-input/useFilterSuggestionProvider.ts
|
|
4472
4457
|
var import_vuu_codemirror6 = require("@vuu-ui/vuu-codemirror");
|
|
4473
|
-
var
|
|
4458
|
+
var import_vuu_data_react2 = require("@vuu-ui/vuu-data-react");
|
|
4459
|
+
var import_react8 = require("react");
|
|
4474
4460
|
|
|
4475
4461
|
// src/filter-input/filterInfo.ts
|
|
4476
|
-
var
|
|
4462
|
+
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
4477
4463
|
var filterInfo = (filterName, filterQuery) => {
|
|
4478
|
-
const rootElement = (0,
|
|
4479
|
-
const headingElement = (0,
|
|
4480
|
-
const nameElement = (0,
|
|
4464
|
+
const rootElement = (0, import_vuu_utils4.createEl)("div", "vuuFunctionDoc");
|
|
4465
|
+
const headingElement = (0, import_vuu_utils4.createEl)("div", "function-heading");
|
|
4466
|
+
const nameElement = (0, import_vuu_utils4.createEl)("span", "function-name", filterName);
|
|
4481
4467
|
headingElement.appendChild(nameElement);
|
|
4482
|
-
const child2 = (0,
|
|
4468
|
+
const child2 = (0, import_vuu_utils4.createEl)("p", void 0, filterQuery);
|
|
4483
4469
|
rootElement.appendChild(headingElement);
|
|
4484
4470
|
rootElement.appendChild(child2);
|
|
4485
4471
|
return rootElement;
|
|
@@ -4564,11 +4550,11 @@ var useFilterSuggestionProvider = ({
|
|
|
4564
4550
|
namedFilters,
|
|
4565
4551
|
saveOptions = defaultSaveOptions,
|
|
4566
4552
|
table,
|
|
4567
|
-
typeaheadHook: useTypeahead = useTypeaheadSuggestions
|
|
4553
|
+
typeaheadHook: useTypeahead = import_vuu_data_react2.useTypeaheadSuggestions
|
|
4568
4554
|
}) => {
|
|
4569
|
-
const latestSuggestionsRef = (0,
|
|
4555
|
+
const latestSuggestionsRef = (0, import_react8.useRef)();
|
|
4570
4556
|
const getTypeaheadSuggestions = useTypeahead();
|
|
4571
|
-
const getSuggestions = (0,
|
|
4557
|
+
const getSuggestions = (0, import_react8.useCallback)(
|
|
4572
4558
|
async (suggestionType, options = NONE) => {
|
|
4573
4559
|
const {
|
|
4574
4560
|
columnName,
|
|
@@ -4616,7 +4602,7 @@ var useFilterSuggestionProvider = ({
|
|
|
4616
4602
|
);
|
|
4617
4603
|
}
|
|
4618
4604
|
const prefix = Array.isArray(selection) ? selection.length === 0 ? "[" : "," : "";
|
|
4619
|
-
const params = getTypeaheadParams(
|
|
4605
|
+
const params = (0, import_vuu_data_react2.getTypeaheadParams)(
|
|
4620
4606
|
table,
|
|
4621
4607
|
columnName,
|
|
4622
4608
|
startsWith
|
|
@@ -4658,7 +4644,7 @@ var useFilterSuggestionProvider = ({
|
|
|
4658
4644
|
},
|
|
4659
4645
|
[columns, getTypeaheadSuggestions, namedFilters, saveOptions, table]
|
|
4660
4646
|
);
|
|
4661
|
-
const isPartialMatch = (0,
|
|
4647
|
+
const isPartialMatch = (0, import_react8.useCallback)(
|
|
4662
4648
|
async (valueType, columnName, pattern) => {
|
|
4663
4649
|
const suggestions = (
|
|
4664
4650
|
// latestSuggestions && latestSuggestions.length > 0
|
|
@@ -4689,12 +4675,12 @@ var import_salt_lab8 = require("@heswell/salt-lab");
|
|
|
4689
4675
|
var import_classnames2 = __toESM(require_classnames(), 1);
|
|
4690
4676
|
|
|
4691
4677
|
// src/filter-toolbar/useFilterToolbar.tsx
|
|
4692
|
-
var
|
|
4678
|
+
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
4693
4679
|
var import_salt_lab7 = require("@heswell/salt-lab");
|
|
4694
4680
|
|
|
4695
4681
|
// src/filter-toolbar/FilterDropdown.tsx
|
|
4696
4682
|
var import_salt_lab5 = require("@heswell/salt-lab");
|
|
4697
|
-
var
|
|
4683
|
+
var import_react9 = require("react");
|
|
4698
4684
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
4699
4685
|
var isString = (s) => typeof s === "string";
|
|
4700
4686
|
var stripQuotes = (selected) => {
|
|
@@ -4716,9 +4702,9 @@ var FilterDropdown = ({
|
|
|
4716
4702
|
}) => {
|
|
4717
4703
|
const selected = selectedProp != null ? stripQuotes(selectedProp) : void 0;
|
|
4718
4704
|
const initialValues = Array.isArray(selected) ? selected : selected != null ? [selected] : [];
|
|
4719
|
-
const [values, setValues] = (0,
|
|
4705
|
+
const [values, setValues] = (0, import_react9.useState)(initialValues);
|
|
4720
4706
|
console.log({ initialValues });
|
|
4721
|
-
const handleOpenChange = (0,
|
|
4707
|
+
const handleOpenChange = (0, import_react9.useCallback)(
|
|
4722
4708
|
async (isOpen) => {
|
|
4723
4709
|
if (isOpen) {
|
|
4724
4710
|
const values2 = await suggestionProvider.getSuggestions("columnValue", {
|
|
@@ -4743,7 +4729,7 @@ var FilterDropdown = ({
|
|
|
4743
4729
|
|
|
4744
4730
|
// src/filter-toolbar/FilterDropdownMultiSelect.tsx
|
|
4745
4731
|
var import_salt_lab6 = require("@heswell/salt-lab");
|
|
4746
|
-
var
|
|
4732
|
+
var import_react10 = require("react");
|
|
4747
4733
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4748
4734
|
var isString2 = (s) => typeof s === "string";
|
|
4749
4735
|
var stripQuotes2 = (selected) => {
|
|
@@ -4767,8 +4753,8 @@ var FilterDropdownMultiSelect = ({
|
|
|
4767
4753
|
}) => {
|
|
4768
4754
|
const selected = stripQuotes2(selectedProp);
|
|
4769
4755
|
const initialValues = Array.isArray(selected) ? selected : selected != null ? [selected] : [];
|
|
4770
|
-
const [values, setValues] = (0,
|
|
4771
|
-
const handleOpenChange = (0,
|
|
4756
|
+
const [values, setValues] = (0, import_react10.useState)(initialValues);
|
|
4757
|
+
const handleOpenChange = (0, import_react10.useCallback)(
|
|
4772
4758
|
async (isOpen) => {
|
|
4773
4759
|
if (isOpen) {
|
|
4774
4760
|
const values2 = await suggestionProvider.getSuggestions("columnValue", {
|
|
@@ -4795,7 +4781,7 @@ var FilterDropdownMultiSelect = ({
|
|
|
4795
4781
|
// src/filter-toolbar/useFilterToolbar.tsx
|
|
4796
4782
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4797
4783
|
var filterToControl = (filter, suggestionProvider) => {
|
|
4798
|
-
if ((0,
|
|
4784
|
+
if ((0, import_vuu_utils5.isNamedFilter)(filter)) {
|
|
4799
4785
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4800
4786
|
import_salt_lab7.ToggleButton,
|
|
4801
4787
|
{
|
|
@@ -4806,7 +4792,7 @@ var filterToControl = (filter, suggestionProvider) => {
|
|
|
4806
4792
|
}
|
|
4807
4793
|
);
|
|
4808
4794
|
}
|
|
4809
|
-
if ((0,
|
|
4795
|
+
if ((0, import_vuu_utils5.isSingleValueFilter)(filter)) {
|
|
4810
4796
|
const { column, value } = filter;
|
|
4811
4797
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4812
4798
|
import_salt_lab7.ToolbarField,
|
|
@@ -4829,7 +4815,7 @@ var filterToControl = (filter, suggestionProvider) => {
|
|
|
4829
4815
|
column
|
|
4830
4816
|
);
|
|
4831
4817
|
}
|
|
4832
|
-
if ((0,
|
|
4818
|
+
if ((0, import_vuu_utils5.isMultiValueFilter)(filter)) {
|
|
4833
4819
|
const values = filter.values.map((v) => v.toString());
|
|
4834
4820
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4835
4821
|
import_salt_lab7.ToolbarField,
|