@dragonmastery/zinia-forms-core 0.3.3 → 0.3.5
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 +456 -353
- package/dist/index.js +183 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { provide, ref, computed, unref, inject, getCurrentInstance,
|
|
1
|
+
import { provide, ref, computed, unref, inject, getCurrentInstance, watch, reactive, nextTick, Teleport } from 'vue';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'vue/jsx-runtime';
|
|
4
4
|
|
|
@@ -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
|
{
|
|
@@ -5214,7 +5290,10 @@ var SELECT_FIELD_PROP_NAMES = [
|
|
|
5214
5290
|
"size",
|
|
5215
5291
|
"variant",
|
|
5216
5292
|
"valueToLabel",
|
|
5217
|
-
"useSchemaOptions"
|
|
5293
|
+
"useSchemaOptions",
|
|
5294
|
+
"dependsOn",
|
|
5295
|
+
"optionFilterFn",
|
|
5296
|
+
"autoReset"
|
|
5218
5297
|
];
|
|
5219
5298
|
function createDaisyUISelectField() {
|
|
5220
5299
|
const propsDefinition = [...SELECT_FIELD_PROP_NAMES];
|
|
@@ -5226,7 +5305,13 @@ function createDaisyUISelectField() {
|
|
|
5226
5305
|
}
|
|
5227
5306
|
const fieldMetadata = formState.fieldsMetadata[props.name] || {};
|
|
5228
5307
|
const normalizedProps = normalizePropsFromAttrs(props, propsDefinition, attrs);
|
|
5229
|
-
const
|
|
5308
|
+
const parentValue = computed(() => {
|
|
5309
|
+
if (normalizedProps.dependsOn) {
|
|
5310
|
+
return formState.getValue(normalizedProps.dependsOn);
|
|
5311
|
+
}
|
|
5312
|
+
return null;
|
|
5313
|
+
});
|
|
5314
|
+
const allOptions = computed(() => {
|
|
5230
5315
|
if (normalizedProps.selectOptions) {
|
|
5231
5316
|
return normalizedProps.selectOptions;
|
|
5232
5317
|
}
|
|
@@ -5243,6 +5328,43 @@ function createDaisyUISelectField() {
|
|
|
5243
5328
|
}
|
|
5244
5329
|
return schemaOptions;
|
|
5245
5330
|
});
|
|
5331
|
+
const getOptions = computed(() => {
|
|
5332
|
+
const options = allOptions.value;
|
|
5333
|
+
if (normalizedProps.dependsOn && normalizedProps.optionFilterFn) {
|
|
5334
|
+
const parentVal = parentValue.value;
|
|
5335
|
+
if (parentVal === null || parentVal === void 0 || parentVal === "") {
|
|
5336
|
+
return [];
|
|
5337
|
+
}
|
|
5338
|
+
return normalizedProps.optionFilterFn(parentVal, options);
|
|
5339
|
+
}
|
|
5340
|
+
if (normalizedProps.dependsOn && !normalizedProps.optionFilterFn) {
|
|
5341
|
+
const parentVal = parentValue.value;
|
|
5342
|
+
if (parentVal === null || parentVal === void 0 || parentVal === "") {
|
|
5343
|
+
return [];
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5346
|
+
return options;
|
|
5347
|
+
});
|
|
5348
|
+
if (normalizedProps.dependsOn && normalizedProps.autoReset !== false) {
|
|
5349
|
+
watch(
|
|
5350
|
+
parentValue,
|
|
5351
|
+
(newParentValue, oldParentValue) => {
|
|
5352
|
+
if (oldParentValue !== void 0 && newParentValue !== oldParentValue) {
|
|
5353
|
+
formState.setValue(props.name, "");
|
|
5354
|
+
formState.touchField(props.name);
|
|
5355
|
+
}
|
|
5356
|
+
},
|
|
5357
|
+
{ immediate: false }
|
|
5358
|
+
);
|
|
5359
|
+
}
|
|
5360
|
+
const isDisabled = computed(() => {
|
|
5361
|
+
if (props.disabled) return true;
|
|
5362
|
+
if (normalizedProps.dependsOn) {
|
|
5363
|
+
const parentVal = parentValue.value;
|
|
5364
|
+
return parentVal === null || parentVal === void 0 || parentVal === "";
|
|
5365
|
+
}
|
|
5366
|
+
return false;
|
|
5367
|
+
});
|
|
5246
5368
|
const htmlAttrs = filterComponentPropsFromAttrs(propsDefinition, attrs);
|
|
5247
5369
|
const selectProps = {
|
|
5248
5370
|
value: formState.getValue(props.name),
|
|
@@ -5274,7 +5396,7 @@ function createDaisyUISelectField() {
|
|
|
5274
5396
|
props.label || fieldMetadata.label,
|
|
5275
5397
|
fieldMetadata.isRequired && /* @__PURE__ */ jsx("span", { class: "text-error", children: " *" })
|
|
5276
5398
|
] }),
|
|
5277
|
-
/* @__PURE__ */ jsxs("select", { class: selectClass, disabled:
|
|
5399
|
+
/* @__PURE__ */ jsxs("select", { class: selectClass, disabled: isDisabled.value, "data-testid": `${formState.storeName}-select-field-${String(props.name)}`, ...selectProps, children: [
|
|
5278
5400
|
props.placeholder && /* @__PURE__ */ jsx("option", { value: "", disabled: true, selected: true, children: props.placeholder }),
|
|
5279
5401
|
getOptions.value.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
|
|
5280
5402
|
] }),
|
|
@@ -8391,7 +8513,52 @@ function createPlainSelectField() {
|
|
|
8391
8513
|
propsDefinition,
|
|
8392
8514
|
attrs
|
|
8393
8515
|
);
|
|
8394
|
-
const
|
|
8516
|
+
const parentValue = computed(() => {
|
|
8517
|
+
if (normalizedProps.dependsOn) {
|
|
8518
|
+
return formState.getValue(normalizedProps.dependsOn);
|
|
8519
|
+
}
|
|
8520
|
+
return null;
|
|
8521
|
+
});
|
|
8522
|
+
const allOptions = computed(() => {
|
|
8523
|
+
return normalizedProps.selectOptions || fieldMetadata.options || [];
|
|
8524
|
+
});
|
|
8525
|
+
const options = computed(() => {
|
|
8526
|
+
const opts = allOptions.value;
|
|
8527
|
+
if (normalizedProps.dependsOn && normalizedProps.optionFilterFn) {
|
|
8528
|
+
const parentVal = parentValue.value;
|
|
8529
|
+
if (parentVal === null || parentVal === void 0 || parentVal === "") {
|
|
8530
|
+
return [];
|
|
8531
|
+
}
|
|
8532
|
+
return normalizedProps.optionFilterFn(parentVal, opts);
|
|
8533
|
+
}
|
|
8534
|
+
if (normalizedProps.dependsOn && !normalizedProps.optionFilterFn) {
|
|
8535
|
+
const parentVal = parentValue.value;
|
|
8536
|
+
if (parentVal === null || parentVal === void 0 || parentVal === "") {
|
|
8537
|
+
return [];
|
|
8538
|
+
}
|
|
8539
|
+
}
|
|
8540
|
+
return opts;
|
|
8541
|
+
});
|
|
8542
|
+
if (normalizedProps.dependsOn && normalizedProps.autoReset !== false) {
|
|
8543
|
+
watch(
|
|
8544
|
+
parentValue,
|
|
8545
|
+
(newParentValue, oldParentValue) => {
|
|
8546
|
+
if (oldParentValue !== void 0 && newParentValue !== oldParentValue) {
|
|
8547
|
+
formState.setValue(props.name, "");
|
|
8548
|
+
formState.touchField(props.name);
|
|
8549
|
+
}
|
|
8550
|
+
},
|
|
8551
|
+
{ immediate: false }
|
|
8552
|
+
);
|
|
8553
|
+
}
|
|
8554
|
+
const isDisabled = computed(() => {
|
|
8555
|
+
if (props.disabled) return true;
|
|
8556
|
+
if (normalizedProps.dependsOn) {
|
|
8557
|
+
const parentVal = parentValue.value;
|
|
8558
|
+
return parentVal === null || parentVal === void 0 || parentVal === "";
|
|
8559
|
+
}
|
|
8560
|
+
return false;
|
|
8561
|
+
});
|
|
8395
8562
|
const htmlAttrs = filterComponentPropsFromAttrs(
|
|
8396
8563
|
propsDefinition,
|
|
8397
8564
|
attrs
|
|
@@ -8408,9 +8575,9 @@ function createPlainSelectField() {
|
|
|
8408
8575
|
},
|
|
8409
8576
|
...htmlAttrs
|
|
8410
8577
|
};
|
|
8411
|
-
return /* @__PURE__ */ jsxs("select", { class: props.class, disabled:
|
|
8578
|
+
return /* @__PURE__ */ jsxs("select", { class: props.class, disabled: isDisabled.value, "data-testid": `${formState.storeName}-select-field-${String(props.name)}`, ...selectProps, children: [
|
|
8412
8579
|
props.placeholder && /* @__PURE__ */ jsx("option", { value: "", disabled: true, selected: true, children: props.placeholder }),
|
|
8413
|
-
options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
|
|
8580
|
+
options.value.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
|
|
8414
8581
|
] });
|
|
8415
8582
|
};
|
|
8416
8583
|
PlainSelectField.props = propsDefinition;
|
|
@@ -8967,6 +9134,6 @@ var ActionIcons = {
|
|
|
8967
9134
|
dotsHorizontal: `<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z" /></svg>`
|
|
8968
9135
|
};
|
|
8969
9136
|
|
|
8970
|
-
export { ActionIcons, ErrorDisplay, LoadingDisplay, NoDataDisplay, SCHEMA_ID_SYMBOL, ZINIA_DATA_TABLE_ACTIONS_KEY, ZINIA_DATA_TABLE_COLUMNS_KEY, ZINIA_DATA_TABLE_FILTER_INPUTS_KEY, ZINIA_DATA_TABLE_FILTER_OPERATORS_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_LOADING_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_STATE_KEY, ZINIA_DATA_TABLE_KEY, ZINIA_DATA_TABLE_NAME_KEY, ZINIA_DATA_TABLE_OPTIONS_KEY, ZINIA_DATA_TABLE_SEARCH_INPUT_KEY, ZINIA_DELETE_MODAL_FIELDS_GENERIC_KEY, ZINIA_DELETE_MODAL_FIELDS_KEY, ZINIA_DELETE_MODAL_KEY, ZINIA_DELETE_MODAL_SCHEMA_KEY, ZINIA_DISPLAY_FIELDS_GENERIC_KEY, ZINIA_DISPLAY_FIELDS_KEY, ZINIA_DISPLAY_KEY, ZINIA_DISPLAY_SCHEMA_KEY, ZINIA_FIELDS_GENERIC_KEY, ZINIA_FIELDS_KEY, ZINIA_FORM_KEY, ZINIA_FORM_SCHEMA_KEY, ZiniaPlugin, clearAllMetadata, clearSchemaMetadata, createBaseComponents, createBaseDisplayComponents, createPartialStyle, createStyleTemplate, createTypedArrayField, createTypedSelectField, daisyUIStyle, extendStyle, generateDisplayComponents, generateFieldComponents, getAllSchemaMetadata, getDefaultStyle, getFieldMetadata, getRegisteredStyle, getRegisteredStyleNames, getSchemaId, hasRegisteredStyle, hasSchemaMetadata, mergeStyles, plainStyle, registerSchemaMetadata, registerStyle, setSchemaMetadata, useCursorDataTable, useDataTable, useDeleteModal, useDisplay, useForm, withMetadata };
|
|
9137
|
+
export { ActionIcons, COMBOBOX_FIELD_PROP_NAMES, ErrorDisplay, LoadingDisplay, NoDataDisplay, SCHEMA_ID_SYMBOL, SELECT_FIELD_PROP_NAMES, ZINIA_DATA_TABLE_ACTIONS_KEY, ZINIA_DATA_TABLE_COLUMNS_KEY, ZINIA_DATA_TABLE_FILTER_INPUTS_KEY, ZINIA_DATA_TABLE_FILTER_OPERATORS_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_LOADING_KEY, ZINIA_DATA_TABLE_FILTER_OPTIONS_STATE_KEY, ZINIA_DATA_TABLE_KEY, ZINIA_DATA_TABLE_NAME_KEY, ZINIA_DATA_TABLE_OPTIONS_KEY, ZINIA_DATA_TABLE_SEARCH_INPUT_KEY, ZINIA_DELETE_MODAL_FIELDS_GENERIC_KEY, ZINIA_DELETE_MODAL_FIELDS_KEY, ZINIA_DELETE_MODAL_KEY, ZINIA_DELETE_MODAL_SCHEMA_KEY, ZINIA_DISPLAY_FIELDS_GENERIC_KEY, ZINIA_DISPLAY_FIELDS_KEY, ZINIA_DISPLAY_KEY, ZINIA_DISPLAY_SCHEMA_KEY, ZINIA_FIELDS_GENERIC_KEY, ZINIA_FIELDS_KEY, ZINIA_FORM_KEY, ZINIA_FORM_SCHEMA_KEY, ZiniaPlugin, clearAllMetadata, clearSchemaMetadata, createBaseComponents, createBaseDisplayComponents, createPartialStyle, createStyleTemplate, createTypedArrayField, createTypedSelectField, daisyUIStyle, extendStyle, generateDisplayComponents, generateFieldComponents, getAllSchemaMetadata, getDefaultStyle, getFieldMetadata, getRegisteredStyle, getRegisteredStyleNames, getSchemaId, hasRegisteredStyle, hasSchemaMetadata, mergeStyles, plainStyle, registerSchemaMetadata, registerStyle, setSchemaMetadata, useCursorDataTable, useDataTable, useDeleteModal, useDisplay, useForm, withMetadata };
|
|
8971
9138
|
//# sourceMappingURL=index.js.map
|
|
8972
9139
|
//# sourceMappingURL=index.js.map
|