@dragonmastery/zinia-forms-core 0.5.5 → 0.5.7
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/index.d.ts +31 -18
- package/dist/index.js +285 -151
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1252,18 +1252,24 @@ function extractFieldMetadata(schema, path = "", parentSchema, schemaId) {
|
|
|
1252
1252
|
metadata.inputType = "textarea";
|
|
1253
1253
|
}
|
|
1254
1254
|
if (customMetadata.valueToLabel && metadata.type === "enum" && metadata.options) {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1255
|
+
const valueType = customMetadata.valueType;
|
|
1256
|
+
metadata.options = metadata.options.map((option) => {
|
|
1257
|
+
const rawValue = option.value;
|
|
1258
|
+
const value = valueType === "number" ? Number(rawValue) : rawValue;
|
|
1259
|
+
return {
|
|
1260
|
+
value,
|
|
1261
|
+
label: String(customMetadata.valueToLabel?.[rawValue] ?? option.label)
|
|
1262
|
+
};
|
|
1263
|
+
});
|
|
1259
1264
|
}
|
|
1260
1265
|
if (customMetadata.inputType === "select") {
|
|
1261
1266
|
metadata.type = "enum";
|
|
1262
1267
|
if (!metadata.options || metadata.options.length === 0) {
|
|
1263
1268
|
if (customMetadata.valueToLabel) {
|
|
1269
|
+
const valueType = customMetadata.valueType;
|
|
1264
1270
|
metadata.options = Object.entries(customMetadata.valueToLabel).map(([value, label]) => ({
|
|
1265
|
-
value,
|
|
1266
|
-
label
|
|
1271
|
+
value: valueType === "number" ? Number(value) : value,
|
|
1272
|
+
label: String(label)
|
|
1267
1273
|
}));
|
|
1268
1274
|
} else if (customMetadata.options) {
|
|
1269
1275
|
metadata.options = customMetadata.options;
|
|
@@ -5053,7 +5059,7 @@ function createDaisyUISelectField() {
|
|
|
5053
5059
|
const valueToLabel = normalizedProps.valueToLabel;
|
|
5054
5060
|
return schemaOptions.map((option) => ({
|
|
5055
5061
|
value: option.value,
|
|
5056
|
-
label: typeof valueToLabel === "function" ? valueToLabel(option.value) : valueToLabel[option.value]
|
|
5062
|
+
label: typeof valueToLabel === "function" ? valueToLabel(option.value) : valueToLabel[option.value] ?? option.value
|
|
5057
5063
|
}));
|
|
5058
5064
|
}
|
|
5059
5065
|
return schemaOptions;
|
|
@@ -5112,7 +5118,9 @@ function createDaisyUISelectField() {
|
|
|
5112
5118
|
value: formState.getValue(props.name),
|
|
5113
5119
|
onChange: (event) => {
|
|
5114
5120
|
const target = event.target;
|
|
5115
|
-
|
|
5121
|
+
const rawValue = target.value;
|
|
5122
|
+
const value = fieldMetadata?.valueType === "number" && rawValue !== "" ? Number(rawValue) : rawValue;
|
|
5123
|
+
formState.setValue(props.name, value);
|
|
5116
5124
|
formState.touchField(props.name);
|
|
5117
5125
|
formState.validateField(props.name);
|
|
5118
5126
|
},
|
|
@@ -8555,6 +8563,9 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8555
8563
|
}
|
|
8556
8564
|
return String(a) === String(b);
|
|
8557
8565
|
};
|
|
8566
|
+
const sanitizeTestId = (value) => {
|
|
8567
|
+
return String(value).replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
8568
|
+
};
|
|
8558
8569
|
const selectedOptions = computed(() => {
|
|
8559
8570
|
return selectedValues.map((val) => {
|
|
8560
8571
|
const option = props.options.find((opt) => valuesEqual(opt.value, val));
|
|
@@ -8562,11 +8573,17 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8562
8573
|
}).filter((opt) => Boolean(opt));
|
|
8563
8574
|
});
|
|
8564
8575
|
const filteredOptions = computed(() => {
|
|
8576
|
+
const uniqueOptions = props.options.filter((opt, index, self) => {
|
|
8577
|
+
return index === self.findIndex((o) => valuesEqual(o.value, opt.value));
|
|
8578
|
+
});
|
|
8579
|
+
if (props.searchable === false) {
|
|
8580
|
+
return uniqueOptions;
|
|
8581
|
+
}
|
|
8565
8582
|
const query = state.searchQuery.trim().toLowerCase();
|
|
8566
8583
|
if (!query) {
|
|
8567
|
-
return
|
|
8584
|
+
return uniqueOptions;
|
|
8568
8585
|
}
|
|
8569
|
-
return
|
|
8586
|
+
return uniqueOptions.filter((opt) => opt.label.toLowerCase().includes(query));
|
|
8570
8587
|
});
|
|
8571
8588
|
const updateDropdownPosition = () => {
|
|
8572
8589
|
const container = document.querySelector(`[data-enum-multiselect-container="${props.field}"]`);
|
|
@@ -8674,8 +8691,11 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8674
8691
|
if (state.cleanupFns.length > 0) return;
|
|
8675
8692
|
window.addEventListener("scroll", handleScrollOrResize, true);
|
|
8676
8693
|
window.addEventListener("resize", handleScrollOrResize);
|
|
8677
|
-
|
|
8694
|
+
const clickTimeout = setTimeout(() => {
|
|
8695
|
+
document.addEventListener("click", handleClickOutside, true);
|
|
8696
|
+
}, 0);
|
|
8678
8697
|
state.cleanupFns.push(() => {
|
|
8698
|
+
clearTimeout(clickTimeout);
|
|
8679
8699
|
window.removeEventListener("scroll", handleScrollOrResize, true);
|
|
8680
8700
|
window.removeEventListener("resize", handleScrollOrResize);
|
|
8681
8701
|
document.removeEventListener("click", handleClickOutside, true);
|
|
@@ -8688,6 +8708,10 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8688
8708
|
}
|
|
8689
8709
|
};
|
|
8690
8710
|
const handleFocus = () => {
|
|
8711
|
+
if (state.blurTimeoutId) {
|
|
8712
|
+
clearTimeout(state.blurTimeoutId);
|
|
8713
|
+
state.blurTimeoutId = void 0;
|
|
8714
|
+
}
|
|
8691
8715
|
if (state.pendingValues === void 0) {
|
|
8692
8716
|
state.pendingValues = Array.isArray(props.value) ? [...props.value] : props.value ? [props.value] : [];
|
|
8693
8717
|
}
|
|
@@ -8696,15 +8720,28 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8696
8720
|
setupEventListeners();
|
|
8697
8721
|
};
|
|
8698
8722
|
const handleBlur = (e) => {
|
|
8699
|
-
|
|
8700
|
-
|
|
8723
|
+
if (state.blurTimeoutId) {
|
|
8724
|
+
clearTimeout(state.blurTimeoutId);
|
|
8725
|
+
}
|
|
8726
|
+
state.blurTimeoutId = setTimeout(() => {
|
|
8727
|
+
state.blurTimeoutId = void 0;
|
|
8728
|
+
const activeElement = document.activeElement;
|
|
8701
8729
|
const container = document.querySelector(
|
|
8702
8730
|
`[data-enum-multiselect-container="${props.field}"]`
|
|
8703
8731
|
);
|
|
8704
8732
|
const dropdown = document.querySelector(`[data-enum-multiselect-dropdown="${props.field}"]`);
|
|
8705
|
-
if (container && container.contains(
|
|
8733
|
+
if (container && container.contains(activeElement)) {
|
|
8734
|
+
return;
|
|
8735
|
+
}
|
|
8736
|
+
if (dropdown && dropdown.contains(activeElement)) {
|
|
8706
8737
|
return;
|
|
8707
8738
|
}
|
|
8739
|
+
const relatedTarget = e.relatedTarget;
|
|
8740
|
+
if (relatedTarget) {
|
|
8741
|
+
if (container && container.contains(relatedTarget) || dropdown && dropdown.contains(relatedTarget)) {
|
|
8742
|
+
return;
|
|
8743
|
+
}
|
|
8744
|
+
}
|
|
8708
8745
|
if (state.isOpen) {
|
|
8709
8746
|
applyPendingFilter();
|
|
8710
8747
|
state.isOpen = false;
|
|
@@ -8712,7 +8749,7 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8712
8749
|
state.selectedIndex = -1;
|
|
8713
8750
|
cleanupEventListeners();
|
|
8714
8751
|
}
|
|
8715
|
-
},
|
|
8752
|
+
}, 150);
|
|
8716
8753
|
};
|
|
8717
8754
|
const handleKeyDown = (e) => {
|
|
8718
8755
|
if (e.key === "Escape") {
|
|
@@ -8805,7 +8842,7 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8805
8842
|
"div",
|
|
8806
8843
|
{
|
|
8807
8844
|
class: "badge badge-primary badge-sm gap-1.5 pr-1 max-w-full",
|
|
8808
|
-
"data-testid": `datatable-filter-${props.field}-chip-${option.value}`,
|
|
8845
|
+
"data-testid": `datatable-filter-${props.field}-chip-${sanitizeTestId(option.value)}`,
|
|
8809
8846
|
children: [
|
|
8810
8847
|
/* @__PURE__ */ jsx("span", { class: "truncate max-w-[120px] sm:max-w-[200px]", title: option.label, children: option.label }),
|
|
8811
8848
|
/* @__PURE__ */ jsx(
|
|
@@ -8842,42 +8879,83 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8842
8879
|
String(option.value)
|
|
8843
8880
|
)) }),
|
|
8844
8881
|
/* @__PURE__ */ jsxs("div", { class: "relative", "data-enum-multiselect-container": props.field, children: [
|
|
8845
|
-
/* @__PURE__ */
|
|
8846
|
-
|
|
8882
|
+
props.searchable !== false ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8883
|
+
/* @__PURE__ */ jsx(
|
|
8884
|
+
"input",
|
|
8885
|
+
{
|
|
8886
|
+
type: "text",
|
|
8887
|
+
value: state.searchQuery,
|
|
8888
|
+
onInput: (e) => {
|
|
8889
|
+
const value = e.target.value;
|
|
8890
|
+
state.searchQuery = value;
|
|
8891
|
+
state.isOpen = true;
|
|
8892
|
+
state.selectedIndex = -1;
|
|
8893
|
+
updateDropdownPosition();
|
|
8894
|
+
if (!state.cleanupFns || state.cleanupFns.length === 0) {
|
|
8895
|
+
setupEventListeners();
|
|
8896
|
+
}
|
|
8897
|
+
},
|
|
8898
|
+
onFocus: handleFocus,
|
|
8899
|
+
onBlur: handleBlur,
|
|
8900
|
+
onKeydown: handleKeyDown,
|
|
8901
|
+
placeholder: props.isOptionsLoading ? "Loading options..." : selectedOptions.value.length > 0 ? `Search ${props.label}...` : `Select ${props.label}...`,
|
|
8902
|
+
class: "input input-bordered input-sm w-full pr-8",
|
|
8903
|
+
disabled: props.isLoading || props.isOptionsLoading,
|
|
8904
|
+
"data-testid": `datatable-filter-${props.field}-input`
|
|
8905
|
+
}
|
|
8906
|
+
),
|
|
8907
|
+
/* @__PURE__ */ jsx("div", { class: "absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none", children: /* @__PURE__ */ jsx(
|
|
8908
|
+
"svg",
|
|
8909
|
+
{
|
|
8910
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8911
|
+
class: `h-4 w-4 text-base-content/50 transition-transform ${state.isOpen ? "rotate-180" : ""}`,
|
|
8912
|
+
fill: "none",
|
|
8913
|
+
viewBox: "0 0 24 24",
|
|
8914
|
+
stroke: "currentColor",
|
|
8915
|
+
"stroke-width": "2",
|
|
8916
|
+
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M19 9l-7 7-7-7" })
|
|
8917
|
+
}
|
|
8918
|
+
) })
|
|
8919
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
8920
|
+
"button",
|
|
8847
8921
|
{
|
|
8848
|
-
type: "
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
state.
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8922
|
+
type: "button",
|
|
8923
|
+
onClick: (e) => {
|
|
8924
|
+
e.preventDefault();
|
|
8925
|
+
e.stopPropagation();
|
|
8926
|
+
if (state.isOpen) {
|
|
8927
|
+
closeDropdown();
|
|
8928
|
+
} else {
|
|
8929
|
+
if (state.pendingValues === void 0) {
|
|
8930
|
+
state.pendingValues = Array.isArray(props.value) ? [...props.value] : props.value ? [props.value] : [];
|
|
8931
|
+
}
|
|
8932
|
+
state.isOpen = true;
|
|
8933
|
+
updateDropdownPosition();
|
|
8857
8934
|
setupEventListeners();
|
|
8858
8935
|
}
|
|
8859
8936
|
},
|
|
8860
|
-
onFocus: handleFocus,
|
|
8861
8937
|
onBlur: handleBlur,
|
|
8862
8938
|
onKeydown: handleKeyDown,
|
|
8863
|
-
|
|
8864
|
-
class: "input input-bordered input-sm w-full pr-8",
|
|
8939
|
+
class: "select select-bordered select-sm w-full pr-8 text-left cursor-pointer",
|
|
8865
8940
|
disabled: props.isLoading || props.isOptionsLoading,
|
|
8866
|
-
"data-testid": `datatable-filter-${props.field}-input
|
|
8941
|
+
"data-testid": `datatable-filter-${props.field}-input`,
|
|
8942
|
+
children: [
|
|
8943
|
+
/* @__PURE__ */ jsx("span", { class: "truncate block", children: props.isOptionsLoading ? "Loading options..." : selectedOptions.value.length > 0 ? `${selectedOptions.value.length} selected` : `Select ${props.label}...` }),
|
|
8944
|
+
/* @__PURE__ */ jsx(
|
|
8945
|
+
"svg",
|
|
8946
|
+
{
|
|
8947
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8948
|
+
class: `absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-base-content/50 transition-transform pointer-events-none ${state.isOpen ? "rotate-180" : ""}`,
|
|
8949
|
+
fill: "none",
|
|
8950
|
+
viewBox: "0 0 24 24",
|
|
8951
|
+
stroke: "currentColor",
|
|
8952
|
+
"stroke-width": "2",
|
|
8953
|
+
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M19 9l-7 7-7-7" })
|
|
8954
|
+
}
|
|
8955
|
+
)
|
|
8956
|
+
]
|
|
8867
8957
|
}
|
|
8868
8958
|
),
|
|
8869
|
-
/* @__PURE__ */ jsx("div", { class: "absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none", children: /* @__PURE__ */ jsx(
|
|
8870
|
-
"svg",
|
|
8871
|
-
{
|
|
8872
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
8873
|
-
class: `h-4 w-4 text-base-content/50 transition-transform ${state.isOpen ? "rotate-180" : ""}`,
|
|
8874
|
-
fill: "none",
|
|
8875
|
-
viewBox: "0 0 24 24",
|
|
8876
|
-
stroke: "currentColor",
|
|
8877
|
-
"stroke-width": "2",
|
|
8878
|
-
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M19 9l-7 7-7-7" })
|
|
8879
|
-
}
|
|
8880
|
-
) }),
|
|
8881
8959
|
state.isOpen && /* @__PURE__ */ jsx(Teleport, { to: "body", children: /* @__PURE__ */ jsxs(
|
|
8882
8960
|
"div",
|
|
8883
8961
|
{
|
|
@@ -8949,7 +9027,7 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8949
9027
|
checked: isSelected,
|
|
8950
9028
|
onChange: () => toggleOption(option),
|
|
8951
9029
|
class: "checkbox checkbox-sm checkbox-primary",
|
|
8952
|
-
"data-testid": `datatable-filter-${props.field}-option-${option.value}`,
|
|
9030
|
+
"data-testid": `datatable-filter-${props.field}-option-${sanitizeTestId(option.value)}`,
|
|
8953
9031
|
tabindex: -1
|
|
8954
9032
|
}
|
|
8955
9033
|
),
|
|
@@ -8969,9 +9047,10 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8969
9047
|
] });
|
|
8970
9048
|
};
|
|
8971
9049
|
var SelectFilter = (props) => {
|
|
8972
|
-
const
|
|
9050
|
+
const defaultOp = props.defaultOperator || OPERATORS.IS_ONE_OF;
|
|
9051
|
+
const currentOperator = props.operator || defaultOp;
|
|
8973
9052
|
const isArrayOperator = currentOperator === OPERATORS.IS_ONE_OF || currentOperator === OPERATORS.IS_NOT_ONE_OF;
|
|
8974
|
-
const isDefaultOperator = currentOperator ===
|
|
9053
|
+
const isDefaultOperator = currentOperator === defaultOp;
|
|
8975
9054
|
const showOperatorSelect = !isDefaultOperator;
|
|
8976
9055
|
const selectedValues = Array.isArray(props.value) ? props.value : props.value ? [props.value] : [];
|
|
8977
9056
|
const handleValueChange = (value) => {
|
|
@@ -9028,6 +9107,7 @@ var SelectFilter = (props) => {
|
|
|
9028
9107
|
isLoading: props.isLoading,
|
|
9029
9108
|
isOptionsLoading: props.isOptionsLoading,
|
|
9030
9109
|
operator: currentOperator,
|
|
9110
|
+
searchable: props.searchable,
|
|
9031
9111
|
onFilterChange: props.onFilterChange,
|
|
9032
9112
|
onClearFilter: props.onClearFilter
|
|
9033
9113
|
}
|
|
@@ -9386,7 +9466,8 @@ var ComboboxFilter = (props) => {
|
|
|
9386
9466
|
comboboxState[props.field] = {
|
|
9387
9467
|
isOpen: false,
|
|
9388
9468
|
selectedIndex: -1,
|
|
9389
|
-
position: { top: 0, left: 0, width: 0, openUpward: false }
|
|
9469
|
+
position: { top: 0, left: 0, width: 0, openUpward: false },
|
|
9470
|
+
isFocused: false
|
|
9390
9471
|
};
|
|
9391
9472
|
}
|
|
9392
9473
|
const state = comboboxState[props.field];
|
|
@@ -9590,6 +9671,7 @@ var ComboboxFilter = (props) => {
|
|
|
9590
9671
|
}
|
|
9591
9672
|
};
|
|
9592
9673
|
const handleFocus = () => {
|
|
9674
|
+
state.isFocused = true;
|
|
9593
9675
|
state.isOpen = true;
|
|
9594
9676
|
updateDropdownPosition();
|
|
9595
9677
|
setupEventListeners();
|
|
@@ -9610,6 +9692,19 @@ var ComboboxFilter = (props) => {
|
|
|
9610
9692
|
container.scrollTop = elementTop + elementHeight - containerHeight;
|
|
9611
9693
|
}
|
|
9612
9694
|
};
|
|
9695
|
+
const handleClear = (e) => {
|
|
9696
|
+
e.preventDefault();
|
|
9697
|
+
e.stopPropagation();
|
|
9698
|
+
props.filterInputValues.value[props.field] = "";
|
|
9699
|
+
state.isOpen = true;
|
|
9700
|
+
updateDropdownPosition();
|
|
9701
|
+
nextTick(() => {
|
|
9702
|
+
const input = document.querySelector(`[data-combobox-input="${props.field}"]`);
|
|
9703
|
+
if (input) {
|
|
9704
|
+
input.focus();
|
|
9705
|
+
}
|
|
9706
|
+
});
|
|
9707
|
+
};
|
|
9613
9708
|
const handleBlur = (e) => {
|
|
9614
9709
|
const relatedTarget = e.relatedTarget || document.activeElement;
|
|
9615
9710
|
const container = document.querySelector(`[data-combobox-container="${props.field}"]`);
|
|
@@ -9617,6 +9712,7 @@ var ComboboxFilter = (props) => {
|
|
|
9617
9712
|
if (container && container.contains(relatedTarget) || dropdown && dropdown.contains(relatedTarget)) {
|
|
9618
9713
|
return;
|
|
9619
9714
|
}
|
|
9715
|
+
state.isFocused = false;
|
|
9620
9716
|
state.isOpen = false;
|
|
9621
9717
|
cleanupEventListeners();
|
|
9622
9718
|
const currentQuery = searchQuery.value.trim();
|
|
@@ -9693,7 +9789,7 @@ var ComboboxFilter = (props) => {
|
|
|
9693
9789
|
onFocus: handleFocus,
|
|
9694
9790
|
onBlur: handleBlur,
|
|
9695
9791
|
placeholder: props.isOptionsLoading ? "Loading options..." : `Search ${props.label}`,
|
|
9696
|
-
class: "input input-bordered input-sm w-full",
|
|
9792
|
+
class: "input input-bordered input-sm w-full pr-8",
|
|
9697
9793
|
disabled: props.isLoading || props.isOptionsLoading,
|
|
9698
9794
|
"data-testid": `datatable-filter-${props.field}-input`,
|
|
9699
9795
|
"data-combobox-input": props.field
|
|
@@ -9711,117 +9807,152 @@ var ComboboxFilter = (props) => {
|
|
|
9711
9807
|
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M8 9l4-4 4 4m0 6l-4 4-4-4" })
|
|
9712
9808
|
}
|
|
9713
9809
|
) }),
|
|
9714
|
-
state.isOpen && /* @__PURE__ */ jsx(Teleport, { to: "body", children: /* @__PURE__ */
|
|
9810
|
+
state.isOpen && /* @__PURE__ */ jsx(Teleport, { to: "body", children: /* @__PURE__ */ jsxs(
|
|
9715
9811
|
"div",
|
|
9716
9812
|
{
|
|
9717
9813
|
"data-combobox-dropdown": props.field,
|
|
9718
|
-
class: "bg-base-100 border border-base-300 rounded-box shadow-lg overflow-auto",
|
|
9814
|
+
class: "bg-base-100 border border-base-300 rounded-box shadow-lg overflow-auto flex flex-col",
|
|
9719
9815
|
style: dropdownStyle.value,
|
|
9720
9816
|
onMousedown: (e) => {
|
|
9721
9817
|
e.preventDefault();
|
|
9722
9818
|
},
|
|
9723
|
-
children:
|
|
9724
|
-
/* @__PURE__ */
|
|
9725
|
-
"
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
{
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9819
|
+
children: [
|
|
9820
|
+
searchQuery.value && /* @__PURE__ */ jsxs("div", { class: "flex items-center justify-between p-2 border-b border-base-300 flex-shrink-0", children: [
|
|
9821
|
+
/* @__PURE__ */ jsx("span", { class: "text-xs font-semibold text-base-content/70", children: props.label }),
|
|
9822
|
+
/* @__PURE__ */ jsx(
|
|
9823
|
+
"button",
|
|
9824
|
+
{
|
|
9825
|
+
type: "button",
|
|
9826
|
+
onClick: (e) => {
|
|
9827
|
+
e.preventDefault();
|
|
9828
|
+
e.stopPropagation();
|
|
9829
|
+
handleClear(e);
|
|
9830
|
+
},
|
|
9831
|
+
onMousedown: (e) => {
|
|
9832
|
+
e.preventDefault();
|
|
9833
|
+
e.stopPropagation();
|
|
9834
|
+
},
|
|
9835
|
+
class: "btn btn-ghost btn-xs p-0 h-5 w-5 min-h-0 rounded hover:bg-base-300",
|
|
9836
|
+
title: "Clear text",
|
|
9837
|
+
"data-testid": `datatable-filter-${props.field}-clear`,
|
|
9838
|
+
children: /* @__PURE__ */ jsx(
|
|
9839
|
+
"svg",
|
|
9840
|
+
{
|
|
9841
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9842
|
+
class: "h-4 w-4",
|
|
9843
|
+
fill: "none",
|
|
9844
|
+
viewBox: "0 0 24 24",
|
|
9845
|
+
stroke: "currentColor",
|
|
9846
|
+
"stroke-width": "2",
|
|
9847
|
+
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18L18 6M6 6l12 12" })
|
|
9848
|
+
}
|
|
9849
|
+
)
|
|
9850
|
+
}
|
|
9851
|
+
)
|
|
9852
|
+
] }),
|
|
9853
|
+
/* @__PURE__ */ jsx("ul", { class: "menu w-full flex-1", role: "listbox", id: `combobox-listbox-${props.field}`, children: props.isOptionsLoading ? /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("span", { class: "text-sm text-base-content/70 p-2", children: "Loading options..." }) }) : filteredOptions.value.length === 0 && !isNewValue.value && !isInvalidValue.value ? /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("span", { class: "text-sm text-base-content/70 p-2", children: "No options available" }) }) : isInvalidValue.value ? /* @__PURE__ */ jsx("li", { class: "bg-error/10 border-l-4 border-error", children: /* @__PURE__ */ jsx("div", { class: "p-2", children: /* @__PURE__ */ jsxs("div", { class: "flex items-center gap-2", children: [
|
|
9854
|
+
/* @__PURE__ */ jsx(
|
|
9855
|
+
"svg",
|
|
9856
|
+
{
|
|
9857
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9858
|
+
class: "h-4 w-4 text-error flex-shrink-0",
|
|
9859
|
+
fill: "none",
|
|
9860
|
+
viewBox: "0 0 24 24",
|
|
9861
|
+
stroke: "currentColor",
|
|
9862
|
+
"stroke-width": "2",
|
|
9863
|
+
children: /* @__PURE__ */ jsx(
|
|
9864
|
+
"path",
|
|
9865
|
+
{
|
|
9866
|
+
"stroke-linecap": "round",
|
|
9867
|
+
"stroke-linejoin": "round",
|
|
9868
|
+
d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
9869
|
+
}
|
|
9870
|
+
)
|
|
9871
|
+
}
|
|
9872
|
+
),
|
|
9873
|
+
/* @__PURE__ */ jsxs("div", { class: "text-sm", children: [
|
|
9874
|
+
/* @__PURE__ */ jsx("p", { class: "font-medium text-error", children: "Invalid value" }),
|
|
9875
|
+
/* @__PURE__ */ jsxs("p", { class: "text-error/80", children: [
|
|
9876
|
+
'"',
|
|
9877
|
+
searchQuery.value,
|
|
9878
|
+
'" is not a valid option. Please select from the list.'
|
|
9879
|
+
] })
|
|
9749
9880
|
] })
|
|
9750
|
-
] })
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9881
|
+
] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9882
|
+
filteredOptions.value.map((option, index) => /* @__PURE__ */ jsx(
|
|
9883
|
+
"li",
|
|
9884
|
+
{
|
|
9885
|
+
id: `option-${index}`,
|
|
9886
|
+
role: "option",
|
|
9887
|
+
"aria-selected": index === state.selectedIndex,
|
|
9888
|
+
class: index === state.selectedIndex ? "bg-base-200" : "",
|
|
9889
|
+
children: /* @__PURE__ */ jsx(
|
|
9890
|
+
"a",
|
|
9891
|
+
{
|
|
9892
|
+
href: "#",
|
|
9893
|
+
tabindex: 0,
|
|
9894
|
+
onClick: (e) => {
|
|
9895
|
+
e.preventDefault();
|
|
9896
|
+
e.stopPropagation();
|
|
9897
|
+
handleSelectOption(option);
|
|
9898
|
+
},
|
|
9899
|
+
onMousedown: (e) => {
|
|
9900
|
+
e.preventDefault();
|
|
9901
|
+
},
|
|
9902
|
+
class: "w-full",
|
|
9903
|
+
children: option.label
|
|
9904
|
+
}
|
|
9905
|
+
)
|
|
9906
|
+
},
|
|
9907
|
+
option.value
|
|
9908
|
+
)),
|
|
9909
|
+
isNewValue.value && props.allowCreate && /* @__PURE__ */ jsx(
|
|
9910
|
+
"li",
|
|
9911
|
+
{
|
|
9912
|
+
id: "option-new",
|
|
9913
|
+
role: "option",
|
|
9914
|
+
"aria-selected": state.selectedIndex === filteredOptions.value.length,
|
|
9915
|
+
class: state.selectedIndex === filteredOptions.value.length ? "bg-base-200" : "",
|
|
9916
|
+
children: /* @__PURE__ */ jsx(
|
|
9917
|
+
"a",
|
|
9918
|
+
{
|
|
9919
|
+
href: "#",
|
|
9920
|
+
tabindex: 0,
|
|
9921
|
+
onClick: (e) => {
|
|
9922
|
+
e.preventDefault();
|
|
9923
|
+
e.stopPropagation();
|
|
9924
|
+
handleSelectNewValue();
|
|
9925
|
+
},
|
|
9926
|
+
onMousedown: (e) => {
|
|
9927
|
+
e.preventDefault();
|
|
9928
|
+
},
|
|
9929
|
+
class: "w-full",
|
|
9930
|
+
children: /* @__PURE__ */ jsxs("div", { class: "flex items-center gap-2", children: [
|
|
9931
|
+
/* @__PURE__ */ jsx(
|
|
9932
|
+
"svg",
|
|
9933
|
+
{
|
|
9934
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9935
|
+
class: "h-4 w-4 text-success",
|
|
9936
|
+
fill: "none",
|
|
9937
|
+
viewBox: "0 0 24 24",
|
|
9938
|
+
stroke: "currentColor",
|
|
9939
|
+
"stroke-width": "2",
|
|
9940
|
+
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M12 4v16m8-8H4" })
|
|
9941
|
+
}
|
|
9942
|
+
),
|
|
9943
|
+
/* @__PURE__ */ jsxs("span", { class: "text-sm", children: [
|
|
9944
|
+
/* @__PURE__ */ jsx("span", { class: "font-medium text-success", children: "New value:" }),
|
|
9945
|
+
' "',
|
|
9946
|
+
searchQuery.value,
|
|
9947
|
+
'"'
|
|
9948
|
+
] })
|
|
9818
9949
|
] })
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
)
|
|
9824
|
-
]
|
|
9950
|
+
}
|
|
9951
|
+
)
|
|
9952
|
+
}
|
|
9953
|
+
)
|
|
9954
|
+
] }) })
|
|
9955
|
+
]
|
|
9825
9956
|
}
|
|
9826
9957
|
) })
|
|
9827
9958
|
] });
|
|
@@ -10237,6 +10368,8 @@ var FilterDrawer = (props) => {
|
|
|
10237
10368
|
isOptionsLoading: filterOptionsLoading?.value?.[field] ?? false,
|
|
10238
10369
|
allOptionText: column.filterAllOptionText,
|
|
10239
10370
|
showAllOption: column.filterShowAllOption,
|
|
10371
|
+
searchable: column.filterSearchable,
|
|
10372
|
+
defaultOperator: column.filterDefaultOperator,
|
|
10240
10373
|
operator: isEnumOperator(currentFilter?.operator) ? currentFilter?.operator : void 0,
|
|
10241
10374
|
fieldType: convertToDataType(props.fieldsMetadata[field]?.type || "enum"),
|
|
10242
10375
|
onFilterChange: props.onFilterChange,
|
|
@@ -10307,7 +10440,8 @@ var FilterDrawer = (props) => {
|
|
|
10307
10440
|
filterOperators: props.filterOperators,
|
|
10308
10441
|
caseSensitive: props.caseSensitive || { value: {} },
|
|
10309
10442
|
fieldType: convertToDataType(props.fieldsMetadata[field]?.type || "string"),
|
|
10310
|
-
onFilterChange: props.onFilterChange
|
|
10443
|
+
onFilterChange: props.onFilterChange,
|
|
10444
|
+
onClearFilter: props.onClearFilter
|
|
10311
10445
|
}
|
|
10312
10446
|
),
|
|
10313
10447
|
filterType === "date" && /* @__PURE__ */ jsx(
|