@dragonmastery/zinia-forms-core 0.3.3 → 0.3.4
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.js +84 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3983,6 +3983,7 @@ function createDaisyUIComboboxField() {
|
|
|
3983
3983
|
const isTouched2 = formState.isTouched(props.name);
|
|
3984
3984
|
const comboboxRoot = ref(null);
|
|
3985
3985
|
const inputElement = ref(null);
|
|
3986
|
+
const dropdownPanel = ref(null);
|
|
3986
3987
|
const selectedIndex = computed({
|
|
3987
3988
|
get: () => formState.getSelectedIndex(props.name),
|
|
3988
3989
|
set: (value) => formState.setSelectedIndex(props.name, value)
|
|
@@ -4036,7 +4037,8 @@ function createDaisyUIComboboxField() {
|
|
|
4036
4037
|
},
|
|
4037
4038
|
onBlur: (event) => {
|
|
4038
4039
|
const relatedTarget = event.relatedTarget;
|
|
4039
|
-
|
|
4040
|
+
const root = comboboxRoot.value || inputElement.value?.closest("label.floating-label");
|
|
4041
|
+
if (root?.contains(relatedTarget)) {
|
|
4040
4042
|
return;
|
|
4041
4043
|
}
|
|
4042
4044
|
const displayValue = String(displayText.value || "").trim();
|
|
@@ -4079,11 +4081,48 @@ function createDaisyUIComboboxField() {
|
|
|
4079
4081
|
const newIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % totalOptions;
|
|
4080
4082
|
selectedIndex.value = newIndex;
|
|
4081
4083
|
nextTick(() => {
|
|
4082
|
-
|
|
4084
|
+
let panel = null;
|
|
4085
|
+
if (dropdownPanel.value) {
|
|
4086
|
+
panel = dropdownPanel.value;
|
|
4087
|
+
} else if (inputElement.value) {
|
|
4088
|
+
const comboboxContainer = inputElement.value.closest('[role="combobox"]');
|
|
4089
|
+
if (comboboxContainer) {
|
|
4090
|
+
panel = comboboxContainer.querySelector("div.absolute.overflow-auto");
|
|
4091
|
+
if (!panel) {
|
|
4092
|
+
const listbox = comboboxContainer.querySelector("#combobox-listbox");
|
|
4093
|
+
if (listbox) {
|
|
4094
|
+
panel = listbox.parentElement;
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
if (!panel) {
|
|
4100
|
+
const listbox = document.querySelector(`#combobox-listbox`);
|
|
4101
|
+
if (listbox) {
|
|
4102
|
+
panel = listbox.parentElement;
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
if (!panel) {
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
4108
|
+
const selectedElement = panel.querySelector(
|
|
4083
4109
|
newIndex === filteredOptions.value.length ? "#option-new" : `#option-${newIndex}`
|
|
4084
4110
|
);
|
|
4085
|
-
if (selectedElement) {
|
|
4086
|
-
|
|
4111
|
+
if (!selectedElement) {
|
|
4112
|
+
return;
|
|
4113
|
+
}
|
|
4114
|
+
const listElement = selectedElement.parentElement;
|
|
4115
|
+
if (!listElement) {
|
|
4116
|
+
return;
|
|
4117
|
+
}
|
|
4118
|
+
const elementTop = selectedElement.offsetTop;
|
|
4119
|
+
const elementHeight = selectedElement.offsetHeight;
|
|
4120
|
+
const containerHeight = panel.clientHeight;
|
|
4121
|
+
const containerScrollTop = panel.scrollTop;
|
|
4122
|
+
if (elementTop < containerScrollTop) {
|
|
4123
|
+
panel.scrollTop = elementTop;
|
|
4124
|
+
} else if (elementTop + elementHeight > containerScrollTop + containerHeight) {
|
|
4125
|
+
panel.scrollTop = elementTop + elementHeight - containerHeight;
|
|
4087
4126
|
}
|
|
4088
4127
|
});
|
|
4089
4128
|
}
|
|
@@ -4098,11 +4137,48 @@ function createDaisyUIComboboxField() {
|
|
|
4098
4137
|
const newIndex = currentIndex < 0 ? totalOptionsUp - 1 : (currentIndex - 1 + totalOptionsUp) % totalOptionsUp;
|
|
4099
4138
|
selectedIndex.value = newIndex;
|
|
4100
4139
|
nextTick(() => {
|
|
4101
|
-
|
|
4140
|
+
let panel = null;
|
|
4141
|
+
if (dropdownPanel.value) {
|
|
4142
|
+
panel = dropdownPanel.value;
|
|
4143
|
+
} else if (inputElement.value) {
|
|
4144
|
+
const comboboxContainer = inputElement.value.closest('[role="combobox"]');
|
|
4145
|
+
if (comboboxContainer) {
|
|
4146
|
+
panel = comboboxContainer.querySelector("div.absolute.overflow-auto");
|
|
4147
|
+
if (!panel) {
|
|
4148
|
+
const listbox = comboboxContainer.querySelector("#combobox-listbox");
|
|
4149
|
+
if (listbox) {
|
|
4150
|
+
panel = listbox.parentElement;
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
if (!panel) {
|
|
4156
|
+
const listbox = document.querySelector(`#combobox-listbox`);
|
|
4157
|
+
if (listbox) {
|
|
4158
|
+
panel = listbox.parentElement;
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4161
|
+
if (!panel) {
|
|
4162
|
+
return;
|
|
4163
|
+
}
|
|
4164
|
+
const selectedElement = panel.querySelector(
|
|
4102
4165
|
newIndex === filteredOptions.value.length ? "#option-new" : `#option-${newIndex}`
|
|
4103
4166
|
);
|
|
4104
|
-
if (selectedElement) {
|
|
4105
|
-
|
|
4167
|
+
if (!selectedElement) {
|
|
4168
|
+
return;
|
|
4169
|
+
}
|
|
4170
|
+
const listElement = selectedElement.parentElement;
|
|
4171
|
+
if (!listElement) {
|
|
4172
|
+
return;
|
|
4173
|
+
}
|
|
4174
|
+
const elementTop = selectedElement.offsetTop;
|
|
4175
|
+
const elementHeight = selectedElement.offsetHeight;
|
|
4176
|
+
const containerHeight = panel.clientHeight;
|
|
4177
|
+
const containerScrollTop = panel.scrollTop;
|
|
4178
|
+
if (elementTop < containerScrollTop) {
|
|
4179
|
+
panel.scrollTop = elementTop;
|
|
4180
|
+
} else if (elementTop + elementHeight > containerScrollTop + containerHeight) {
|
|
4181
|
+
panel.scrollTop = elementTop + elementHeight - containerHeight;
|
|
4106
4182
|
}
|
|
4107
4183
|
});
|
|
4108
4184
|
}
|
|
@@ -4171,7 +4247,7 @@ function createDaisyUIComboboxField() {
|
|
|
4171
4247
|
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M8 9l4-4 4 4m0 6l-4 4-4-4" })
|
|
4172
4248
|
}
|
|
4173
4249
|
) }),
|
|
4174
|
-
showDropdown.value && /* @__PURE__ */ jsx("div", { class: "absolute z-50 mt-1 bg-base-100 border border-base-300 rounded-box shadow-lg max-h-60 overflow-auto", style: "min-width: 100%;", children: filteredOptions.value.length > 0 || isNewValue.value ? /* @__PURE__ */ jsxs("ul", { id: "combobox-listbox", class: "menu w-full", role: "listbox", children: [
|
|
4250
|
+
showDropdown.value && /* @__PURE__ */ jsx("div", { ref: dropdownPanel, class: "absolute z-50 mt-1 bg-base-100 border border-base-300 rounded-box shadow-lg max-h-60 overflow-auto", style: "min-width: 100%;", children: filteredOptions.value.length > 0 || isNewValue.value ? /* @__PURE__ */ jsxs("ul", { id: "combobox-listbox", class: "menu w-full", role: "listbox", children: [
|
|
4175
4251
|
filteredOptions.value.map((option, index) => /* @__PURE__ */ jsx(
|
|
4176
4252
|
"li",
|
|
4177
4253
|
{
|