@dragonmastery/zinia-forms-core 0.3.13 → 0.3.15
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 +121 -0
- package/dist/index.js +705 -277
- 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 { watch, provide, ref, computed, unref, inject, getCurrentInstance, reactive, nextTick, Teleport } from 'vue';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'vue/jsx-runtime';
|
|
4
4
|
|
|
@@ -1612,7 +1612,16 @@ function useFormState(initialData, options) {
|
|
|
1612
1612
|
isReady: !options?.hasFetchData,
|
|
1613
1613
|
isLoading: !!options?.hasFetchData,
|
|
1614
1614
|
loadError: null,
|
|
1615
|
-
extraData: options?.extraData || {}
|
|
1615
|
+
extraData: options?.extraData || {},
|
|
1616
|
+
// Async cascading selection state
|
|
1617
|
+
fetchedOptions: {},
|
|
1618
|
+
loadingOptions: {},
|
|
1619
|
+
asyncCascadingParents: {},
|
|
1620
|
+
// Track child → parent relationships
|
|
1621
|
+
// Auto-population loading state
|
|
1622
|
+
loadingAutoPopulate: {},
|
|
1623
|
+
populatingFields: {}
|
|
1624
|
+
// Track which target fields are being populated
|
|
1616
1625
|
});
|
|
1617
1626
|
if (options?.calculationFn) {
|
|
1618
1627
|
const reactiveUpdater = ReactiveUpdater.getInstance(options.storeName, options.debug || false);
|
|
@@ -2000,6 +2009,8 @@ function useForm(schema, options) {
|
|
|
2000
2009
|
storeName: options.storeName,
|
|
2001
2010
|
// Direct access to the reactive form data
|
|
2002
2011
|
values: formState.state.data,
|
|
2012
|
+
// Direct access to full state (for async cascading selects and advanced features)
|
|
2013
|
+
state: formState.state,
|
|
2003
2014
|
// Access to calculated values (now a computed property)
|
|
2004
2015
|
get calculatedValues() {
|
|
2005
2016
|
return formState.calculatedValues.value;
|
|
@@ -2094,6 +2105,137 @@ function useForm(schema, options) {
|
|
|
2094
2105
|
swapArrayItemIds: (path, indexA, indexB) => swapArrayItemIds(formState.state, path, indexA, indexB),
|
|
2095
2106
|
syncArrayItemIds: (path) => syncArrayItemIds(formState.state, path)
|
|
2096
2107
|
};
|
|
2108
|
+
const getNestedValue = (obj, path) => {
|
|
2109
|
+
return path.split(".").reduce((current, key) => current?.[key], obj);
|
|
2110
|
+
};
|
|
2111
|
+
if (options.asyncCascadingSelects) {
|
|
2112
|
+
Object.entries(options.asyncCascadingSelects).forEach(([_key, config]) => {
|
|
2113
|
+
const { parentField, childField, fetchOptionsFn, clearOnParentChange = true } = config;
|
|
2114
|
+
formState.state.asyncCascadingParents[childField] = parentField;
|
|
2115
|
+
let abortController = null;
|
|
2116
|
+
const fetchOptions = async (parentValue) => {
|
|
2117
|
+
if (abortController) abortController.abort();
|
|
2118
|
+
if (!parentValue) {
|
|
2119
|
+
formState.state.fetchedOptions[childField] = [];
|
|
2120
|
+
formState.state.loadingOptions[childField] = false;
|
|
2121
|
+
return;
|
|
2122
|
+
}
|
|
2123
|
+
formState.state.loadingOptions[childField] = true;
|
|
2124
|
+
abortController = new AbortController();
|
|
2125
|
+
try {
|
|
2126
|
+
const options2 = await fetchOptionsFn(parentValue);
|
|
2127
|
+
if (!abortController.signal.aborted) {
|
|
2128
|
+
formState.state.fetchedOptions[childField] = options2 || [];
|
|
2129
|
+
}
|
|
2130
|
+
} catch (error) {
|
|
2131
|
+
if (error.name !== "AbortError" && !abortController.signal.aborted) {
|
|
2132
|
+
formState.state.fetchedOptions[childField] = [];
|
|
2133
|
+
}
|
|
2134
|
+
} finally {
|
|
2135
|
+
if (!abortController.signal.aborted) {
|
|
2136
|
+
formState.state.loadingOptions[childField] = false;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
};
|
|
2140
|
+
const initialParent = getFieldValue(formState.state, parentField);
|
|
2141
|
+
if (initialParent) {
|
|
2142
|
+
fetchOptions(initialParent);
|
|
2143
|
+
}
|
|
2144
|
+
watch(
|
|
2145
|
+
() => getFieldValue(formState.state, parentField),
|
|
2146
|
+
(newVal, oldVal) => {
|
|
2147
|
+
if (oldVal === void 0) return;
|
|
2148
|
+
if (newVal === oldVal) return;
|
|
2149
|
+
fetchOptions(newVal);
|
|
2150
|
+
if (clearOnParentChange) {
|
|
2151
|
+
setFieldValue(formState.state, initialFormData, childField, "", schema, schemaCache);
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
);
|
|
2155
|
+
});
|
|
2156
|
+
}
|
|
2157
|
+
if (options.autoPopulate) {
|
|
2158
|
+
Object.entries(options.autoPopulate).forEach(([sourceField, config]) => {
|
|
2159
|
+
if (!config) return;
|
|
2160
|
+
const autoPopulateConfig = config;
|
|
2161
|
+
if (!autoPopulateConfig || !autoPopulateConfig.fields) return;
|
|
2162
|
+
watch(
|
|
2163
|
+
() => getFieldValue(formState.state, sourceField),
|
|
2164
|
+
async (newValue, oldValue) => {
|
|
2165
|
+
if (oldValue === void 0) return;
|
|
2166
|
+
if (newValue === oldValue) return;
|
|
2167
|
+
if (!newValue) {
|
|
2168
|
+
if (autoPopulateConfig.fields) {
|
|
2169
|
+
const targetFields2 = Object.keys(autoPopulateConfig.fields);
|
|
2170
|
+
targetFields2.forEach((fieldName) => {
|
|
2171
|
+
setFieldValue(formState.state, initialFormData, fieldName, "", schema, schemaCache);
|
|
2172
|
+
formState.state.populatingFields[fieldName] = false;
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
const fetchedOptions = formState.state.fetchedOptions[sourceField] || [];
|
|
2178
|
+
const fetchedOption = fetchedOptions.find((opt) => opt.value === newValue);
|
|
2179
|
+
const fieldMetadata = fieldsMetadata[sourceField];
|
|
2180
|
+
const schemaOption = fieldMetadata?.options?.find((opt) => opt.value === newValue);
|
|
2181
|
+
const isValueFromOption = !!fetchedOption || !!schemaOption;
|
|
2182
|
+
if (!isValueFromOption) {
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2185
|
+
let optionData = null;
|
|
2186
|
+
const targetFields = autoPopulateConfig.fields ? Object.keys(autoPopulateConfig.fields) : [];
|
|
2187
|
+
if (autoPopulateConfig.fetchDataFn) {
|
|
2188
|
+
formState.state.loadingAutoPopulate[sourceField] = true;
|
|
2189
|
+
targetFields.forEach((fieldName) => {
|
|
2190
|
+
formState.state.populatingFields[fieldName] = true;
|
|
2191
|
+
});
|
|
2192
|
+
try {
|
|
2193
|
+
optionData = await autoPopulateConfig.fetchDataFn(newValue);
|
|
2194
|
+
} catch (error) {
|
|
2195
|
+
console.error(`Error fetching auto-populate data for ${sourceField}:`, error);
|
|
2196
|
+
formState.state.loadingAutoPopulate[sourceField] = false;
|
|
2197
|
+
targetFields.forEach((fieldName) => {
|
|
2198
|
+
formState.state.populatingFields[fieldName] = false;
|
|
2199
|
+
});
|
|
2200
|
+
return;
|
|
2201
|
+
} finally {
|
|
2202
|
+
formState.state.loadingAutoPopulate[sourceField] = false;
|
|
2203
|
+
}
|
|
2204
|
+
} else {
|
|
2205
|
+
if (fetchedOption?.data) {
|
|
2206
|
+
optionData = fetchedOption.data;
|
|
2207
|
+
} else if (schemaOption && "data" in schemaOption && schemaOption.data) {
|
|
2208
|
+
optionData = schemaOption.data;
|
|
2209
|
+
}
|
|
2210
|
+
targetFields.forEach((fieldName) => {
|
|
2211
|
+
formState.state.populatingFields[fieldName] = true;
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
if (optionData && autoPopulateConfig.fields) {
|
|
2215
|
+
Object.entries(autoPopulateConfig.fields).forEach(([fieldName, mapping]) => {
|
|
2216
|
+
let value;
|
|
2217
|
+
if (typeof mapping === "function") {
|
|
2218
|
+
try {
|
|
2219
|
+
value = mapping(optionData);
|
|
2220
|
+
} catch (error) {
|
|
2221
|
+
console.warn(`Auto-populate transform error for ${fieldName}:`, error);
|
|
2222
|
+
value = "";
|
|
2223
|
+
}
|
|
2224
|
+
} else {
|
|
2225
|
+
value = getNestedValue(optionData, mapping) || "";
|
|
2226
|
+
}
|
|
2227
|
+
setFieldValue(formState.state, initialFormData, fieldName, value, schema, schemaCache);
|
|
2228
|
+
formState.state.populatingFields[fieldName] = false;
|
|
2229
|
+
});
|
|
2230
|
+
} else {
|
|
2231
|
+
targetFields.forEach((fieldName) => {
|
|
2232
|
+
formState.state.populatingFields[fieldName] = false;
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
);
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2097
2239
|
if (options.autoProvide !== false) {
|
|
2098
2240
|
provide(ZINIA_FORM_SCHEMA_KEY, schema);
|
|
2099
2241
|
provide(ZINIA_FORM_KEY, form);
|
|
@@ -2579,6 +2721,7 @@ function useDataTableState(initialData = [], options = {}) {
|
|
|
2579
2721
|
totalRows: 0
|
|
2580
2722
|
});
|
|
2581
2723
|
const sortDrawerOpen = ref(false);
|
|
2724
|
+
const filterDrawerOpen = ref(false);
|
|
2582
2725
|
const sorting = reactive({
|
|
2583
2726
|
field: null,
|
|
2584
2727
|
direction: "asc"
|
|
@@ -2705,6 +2848,7 @@ function useDataTableState(initialData = [], options = {}) {
|
|
|
2705
2848
|
selection,
|
|
2706
2849
|
// UI state
|
|
2707
2850
|
sortDrawerOpen,
|
|
2851
|
+
filterDrawerOpen,
|
|
2708
2852
|
// Computed properties
|
|
2709
2853
|
hasData,
|
|
2710
2854
|
isEmpty,
|
|
@@ -3062,7 +3206,10 @@ function useDataTable(schema, options) {
|
|
|
3062
3206
|
ui: {
|
|
3063
3207
|
sortDrawerOpen: tableState.state.sortDrawerOpen,
|
|
3064
3208
|
openSortDrawer: () => tableState.state.sortDrawerOpen.value = true,
|
|
3065
|
-
closeSortDrawer: () => tableState.state.sortDrawerOpen.value = false
|
|
3209
|
+
closeSortDrawer: () => tableState.state.sortDrawerOpen.value = false,
|
|
3210
|
+
filterDrawerOpen: tableState.state.filterDrawerOpen,
|
|
3211
|
+
openFilterDrawer: () => tableState.state.filterDrawerOpen.value = true,
|
|
3212
|
+
closeFilterDrawer: () => tableState.state.filterDrawerOpen.value = false
|
|
3066
3213
|
},
|
|
3067
3214
|
// Metadata
|
|
3068
3215
|
fieldsMetadata,
|
|
@@ -3136,6 +3283,7 @@ function useCursorDataTableState(initialData = [], options = {}) {
|
|
|
3136
3283
|
// Track which page we're conceptually on
|
|
3137
3284
|
});
|
|
3138
3285
|
const sortDrawerOpen = ref(false);
|
|
3286
|
+
const filterDrawerOpen = ref(false);
|
|
3139
3287
|
const sorting = reactive({
|
|
3140
3288
|
field: null,
|
|
3141
3289
|
direction: "asc"
|
|
@@ -3279,6 +3427,7 @@ function useCursorDataTableState(initialData = [], options = {}) {
|
|
|
3279
3427
|
selection,
|
|
3280
3428
|
// UI state
|
|
3281
3429
|
sortDrawerOpen,
|
|
3430
|
+
filterDrawerOpen,
|
|
3282
3431
|
// Computed properties
|
|
3283
3432
|
hasData,
|
|
3284
3433
|
isEmpty,
|
|
@@ -3637,7 +3786,10 @@ function useCursorDataTable(schema, options) {
|
|
|
3637
3786
|
ui: {
|
|
3638
3787
|
sortDrawerOpen: tableState.state.sortDrawerOpen,
|
|
3639
3788
|
openSortDrawer: () => tableState.state.sortDrawerOpen.value = true,
|
|
3640
|
-
closeSortDrawer: () => tableState.state.sortDrawerOpen.value = false
|
|
3789
|
+
closeSortDrawer: () => tableState.state.sortDrawerOpen.value = false,
|
|
3790
|
+
filterDrawerOpen: tableState.state.filterDrawerOpen,
|
|
3791
|
+
openFilterDrawer: () => tableState.state.filterDrawerOpen.value = true,
|
|
3792
|
+
closeFilterDrawer: () => tableState.state.filterDrawerOpen.value = false
|
|
3641
3793
|
},
|
|
3642
3794
|
// Metadata
|
|
3643
3795
|
fieldsMetadata,
|
|
@@ -4637,6 +4789,7 @@ function createDaisyUICheckboxField() {
|
|
|
4637
4789
|
};
|
|
4638
4790
|
const hasErrors = formState.hasError(props.name);
|
|
4639
4791
|
const isTouched2 = formState.isTouched(props.name);
|
|
4792
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
4640
4793
|
const inputClass = [
|
|
4641
4794
|
"checkbox",
|
|
4642
4795
|
props.size ? `checkbox-${props.size}` : "",
|
|
@@ -4645,15 +4798,17 @@ function createDaisyUICheckboxField() {
|
|
|
4645
4798
|
isTouched2 && hasErrors ? "checkbox-error" : "",
|
|
4646
4799
|
props.class
|
|
4647
4800
|
].filter(Boolean).join(" ");
|
|
4801
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
4802
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
4648
4803
|
return /* @__PURE__ */ jsxs("div", { class: "form-control", children: [
|
|
4649
4804
|
/* @__PURE__ */ jsxs("label", { class: "label cursor-pointer justify-start gap-2", children: [
|
|
4650
|
-
/* @__PURE__ */ jsx("input", { class: inputClass, disabled:
|
|
4805
|
+
/* @__PURE__ */ jsx("input", { class: inputClass, disabled: isDisabled, readonly: props.readonly, "data-testid": `${formState.storeName}-checkbox-field-${String(props.name)}`, ...inputProps }),
|
|
4651
4806
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { class: "label-text", children: [
|
|
4652
4807
|
props.label || fieldMetadata.label,
|
|
4653
4808
|
fieldMetadata.isRequired && /* @__PURE__ */ jsx("span", { class: "text-error", children: " *" })
|
|
4654
4809
|
] })
|
|
4655
4810
|
] }),
|
|
4656
|
-
|
|
4811
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "text-sm mt-1", children: descriptionText }),
|
|
4657
4812
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-sm text-error mt-1", children: formState.getError(props.name) })
|
|
4658
4813
|
] });
|
|
4659
4814
|
};
|
|
@@ -4748,7 +4903,31 @@ function createDaisyUIComboboxField() {
|
|
|
4748
4903
|
const fieldMetadata = formState.fieldsMetadata[props.name] || {};
|
|
4749
4904
|
const normalizedProps = normalizePropsFromAttrs(props, propsDefinition, attrs);
|
|
4750
4905
|
const allowCreate = computed(() => normalizedProps.allowCreate === true);
|
|
4906
|
+
const fetchedOptions = computed(() => formState.state?.fetchedOptions?.[props.name] || []);
|
|
4907
|
+
const isLoadingOptions = computed(() => formState.state?.loadingOptions?.[props.name] || false);
|
|
4908
|
+
const isBeingPopulated = computed(() => formState.state?.populatingFields?.[props.name] || false);
|
|
4909
|
+
const asyncCascadingParent = computed(() => formState.state?.asyncCascadingParents?.[props.name]);
|
|
4910
|
+
const parentFieldName = computed(() => normalizedProps.dependsOn || asyncCascadingParent.value);
|
|
4911
|
+
const parentValue = computed(() => {
|
|
4912
|
+
if (parentFieldName.value) {
|
|
4913
|
+
return formState.getValue(parentFieldName.value);
|
|
4914
|
+
}
|
|
4915
|
+
return null;
|
|
4916
|
+
});
|
|
4917
|
+
const isDisabled = computed(() => {
|
|
4918
|
+
if (props.disabled) return true;
|
|
4919
|
+
if (isLoadingOptions.value) return true;
|
|
4920
|
+
if (isBeingPopulated.value) return true;
|
|
4921
|
+
if (parentFieldName.value) {
|
|
4922
|
+
const parentVal = parentValue.value;
|
|
4923
|
+
return parentVal === null || parentVal === void 0 || parentVal === "";
|
|
4924
|
+
}
|
|
4925
|
+
return false;
|
|
4926
|
+
});
|
|
4751
4927
|
const getOptions = computed(() => {
|
|
4928
|
+
if (fetchedOptions.value.length > 0) {
|
|
4929
|
+
return fetchedOptions.value;
|
|
4930
|
+
}
|
|
4752
4931
|
if (normalizedProps.selectOptions) {
|
|
4753
4932
|
return normalizedProps.selectOptions;
|
|
4754
4933
|
}
|
|
@@ -5080,8 +5259,8 @@ function createDaisyUIComboboxField() {
|
|
|
5080
5259
|
{
|
|
5081
5260
|
ref: inputElement,
|
|
5082
5261
|
class: inputClass,
|
|
5083
|
-
placeholder: props.placeholder || "Search or type new value",
|
|
5084
|
-
disabled:
|
|
5262
|
+
placeholder: isBeingPopulated.value ? "Loading..." : isLoadingOptions.value ? "Loading options..." : parentFieldName.value && !parentValue.value ? "Select parent field first" : props.placeholder || "Search or type new value",
|
|
5263
|
+
disabled: isDisabled.value,
|
|
5085
5264
|
autocomplete: "off",
|
|
5086
5265
|
"data-testid": `${formState.storeName}-combobox-field-${String(props.name)}`,
|
|
5087
5266
|
...inputProps
|
|
@@ -5192,7 +5371,7 @@ function createDaisyUIComboboxField() {
|
|
|
5192
5371
|
]
|
|
5193
5372
|
}
|
|
5194
5373
|
),
|
|
5195
|
-
props.description && /* @__PURE__ */ jsx("p", { class: "text-sm mt-1", children: props.description }),
|
|
5374
|
+
(isBeingPopulated.value ? "Loading..." : props.description) && /* @__PURE__ */ jsx("p", { class: "text-sm mt-1", children: isBeingPopulated.value ? "Loading..." : props.description }),
|
|
5196
5375
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) }),
|
|
5197
5376
|
isNewValue.value && displayText.value && !hasErrors && /* @__PURE__ */ jsxs("p", { class: "text-success text-xs", children: [
|
|
5198
5377
|
'\u2713 New value "',
|
|
@@ -5234,6 +5413,7 @@ function createDaisyUICurrencyField() {
|
|
|
5234
5413
|
};
|
|
5235
5414
|
const hasErrors = formState.hasError(props.name);
|
|
5236
5415
|
const isTouched2 = formState.isTouched(props.name);
|
|
5416
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
5237
5417
|
const inputClass = [
|
|
5238
5418
|
"input",
|
|
5239
5419
|
props.size ? `input-${props.size}` : "",
|
|
@@ -5242,6 +5422,8 @@ function createDaisyUICurrencyField() {
|
|
|
5242
5422
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
5243
5423
|
props.class
|
|
5244
5424
|
].filter(Boolean).join(" ");
|
|
5425
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
5426
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
5245
5427
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
5246
5428
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
5247
5429
|
props.label || fieldMetadata.label,
|
|
@@ -5252,7 +5434,7 @@ function createDaisyUICurrencyField() {
|
|
|
5252
5434
|
{
|
|
5253
5435
|
class: inputClass,
|
|
5254
5436
|
placeholder: props.placeholder,
|
|
5255
|
-
disabled:
|
|
5437
|
+
disabled: isDisabled,
|
|
5256
5438
|
readonly: props.readonly,
|
|
5257
5439
|
min: fieldMetadata.min,
|
|
5258
5440
|
max: fieldMetadata.max,
|
|
@@ -5261,7 +5443,7 @@ function createDaisyUICurrencyField() {
|
|
|
5261
5443
|
...inputProps
|
|
5262
5444
|
}
|
|
5263
5445
|
),
|
|
5264
|
-
|
|
5446
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
5265
5447
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
5266
5448
|
] });
|
|
5267
5449
|
};
|
|
@@ -5330,6 +5512,7 @@ function createDaisyUIDateField() {
|
|
|
5330
5512
|
};
|
|
5331
5513
|
const hasErrors = formState.hasError(props.name);
|
|
5332
5514
|
const isTouched2 = formState.isTouched(props.name);
|
|
5515
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
5333
5516
|
const inputClass = [
|
|
5334
5517
|
"input",
|
|
5335
5518
|
props.size ? `input-${props.size}` : "",
|
|
@@ -5338,6 +5521,8 @@ function createDaisyUIDateField() {
|
|
|
5338
5521
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
5339
5522
|
props.class
|
|
5340
5523
|
].filter(Boolean).join(" ");
|
|
5524
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
5525
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
5341
5526
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
5342
5527
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
5343
5528
|
props.label || fieldMetadata.label,
|
|
@@ -5348,7 +5533,7 @@ function createDaisyUIDateField() {
|
|
|
5348
5533
|
{
|
|
5349
5534
|
class: inputClass,
|
|
5350
5535
|
placeholder: props.placeholder,
|
|
5351
|
-
disabled:
|
|
5536
|
+
disabled: isDisabled,
|
|
5352
5537
|
readonly: props.readonly,
|
|
5353
5538
|
min: props.min,
|
|
5354
5539
|
max: props.max,
|
|
@@ -5356,7 +5541,7 @@ function createDaisyUIDateField() {
|
|
|
5356
5541
|
...inputProps
|
|
5357
5542
|
}
|
|
5358
5543
|
),
|
|
5359
|
-
|
|
5544
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
5360
5545
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
5361
5546
|
] });
|
|
5362
5547
|
};
|
|
@@ -5425,6 +5610,7 @@ function createDaisyUIDateTimeLocalField() {
|
|
|
5425
5610
|
};
|
|
5426
5611
|
const hasErrors = formState.hasError(props.name);
|
|
5427
5612
|
const isTouched2 = formState.isTouched(props.name);
|
|
5613
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
5428
5614
|
const inputClass = [
|
|
5429
5615
|
"input",
|
|
5430
5616
|
props.size ? `input-${props.size}` : "",
|
|
@@ -5433,6 +5619,8 @@ function createDaisyUIDateTimeLocalField() {
|
|
|
5433
5619
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
5434
5620
|
props.class
|
|
5435
5621
|
].filter(Boolean).join(" ");
|
|
5622
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
5623
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
5436
5624
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
5437
5625
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
5438
5626
|
props.label || fieldMetadata.label,
|
|
@@ -5443,13 +5631,13 @@ function createDaisyUIDateTimeLocalField() {
|
|
|
5443
5631
|
{
|
|
5444
5632
|
class: inputClass,
|
|
5445
5633
|
placeholder: props.placeholder,
|
|
5446
|
-
disabled:
|
|
5634
|
+
disabled: isDisabled,
|
|
5447
5635
|
readonly: props.readonly,
|
|
5448
5636
|
"data-testid": `${formState.storeName}-datetime-local-field-${String(props.name)}`,
|
|
5449
5637
|
...inputProps
|
|
5450
5638
|
}
|
|
5451
5639
|
),
|
|
5452
|
-
|
|
5640
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
5453
5641
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
5454
5642
|
] });
|
|
5455
5643
|
};
|
|
@@ -5497,6 +5685,7 @@ function createDaisyUIEmailField() {
|
|
|
5497
5685
|
};
|
|
5498
5686
|
const hasErrors = formState.hasError(props.name);
|
|
5499
5687
|
const isTouched2 = formState.isTouched(props.name);
|
|
5688
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
5500
5689
|
const inputClass = [
|
|
5501
5690
|
"input",
|
|
5502
5691
|
props.size ? `input-${props.size}` : "",
|
|
@@ -5505,6 +5694,8 @@ function createDaisyUIEmailField() {
|
|
|
5505
5694
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
5506
5695
|
props.class
|
|
5507
5696
|
].filter(Boolean).join(" ");
|
|
5697
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
5698
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
5508
5699
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
5509
5700
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
5510
5701
|
props.label || fieldMetadata.label,
|
|
@@ -5515,13 +5706,13 @@ function createDaisyUIEmailField() {
|
|
|
5515
5706
|
{
|
|
5516
5707
|
class: inputClass,
|
|
5517
5708
|
placeholder: props.placeholder,
|
|
5518
|
-
disabled:
|
|
5709
|
+
disabled: isDisabled,
|
|
5519
5710
|
readonly: props.readonly,
|
|
5520
5711
|
"data-testid": `${formState.storeName}-email-field-${String(props.name)}`,
|
|
5521
5712
|
...inputProps
|
|
5522
5713
|
}
|
|
5523
5714
|
),
|
|
5524
|
-
|
|
5715
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
5525
5716
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
5526
5717
|
] });
|
|
5527
5718
|
};
|
|
@@ -5566,6 +5757,7 @@ function createDaisyUIFileField() {
|
|
|
5566
5757
|
};
|
|
5567
5758
|
const hasErrors = formState.hasError(props.name);
|
|
5568
5759
|
const isTouched2 = formState.isTouched(props.name);
|
|
5760
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
5569
5761
|
const inputClass = [
|
|
5570
5762
|
"file-input",
|
|
5571
5763
|
props.size ? `file-input-${props.size}` : "",
|
|
@@ -5574,13 +5766,15 @@ function createDaisyUIFileField() {
|
|
|
5574
5766
|
isTouched2 && hasErrors ? "file-input-error" : "",
|
|
5575
5767
|
props.class
|
|
5576
5768
|
].filter(Boolean).join(" ");
|
|
5769
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
5770
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
5577
5771
|
return /* @__PURE__ */ jsxs("div", { class: "form-control", children: [
|
|
5578
5772
|
!props.hideLabel && /* @__PURE__ */ jsx("label", { class: "label", children: /* @__PURE__ */ jsxs("span", { class: "label-text", children: [
|
|
5579
5773
|
props.label || fieldMetadata.label,
|
|
5580
5774
|
fieldMetadata.isRequired && /* @__PURE__ */ jsx("span", { class: "text-error", children: " *" })
|
|
5581
5775
|
] }) }),
|
|
5582
|
-
/* @__PURE__ */ jsx("input", { class: inputClass, disabled:
|
|
5583
|
-
|
|
5776
|
+
/* @__PURE__ */ jsx("input", { class: inputClass, disabled: isDisabled, readonly: props.readonly, "data-testid": `${formState.storeName}-file-field-${String(props.name)}`, ...inputProps }),
|
|
5777
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "text-sm mt-1", children: descriptionText }),
|
|
5584
5778
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-sm text-error mt-1", children: formState.getError(props.name) })
|
|
5585
5779
|
] });
|
|
5586
5780
|
};
|
|
@@ -5777,6 +5971,7 @@ function createDaisyUINumberField() {
|
|
|
5777
5971
|
};
|
|
5778
5972
|
const hasErrors = formState.hasError(props.name);
|
|
5779
5973
|
const isTouched2 = formState.isTouched(props.name);
|
|
5974
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
5780
5975
|
const inputClass = [
|
|
5781
5976
|
"input",
|
|
5782
5977
|
props.size ? `input-${props.size}` : "",
|
|
@@ -5785,6 +5980,8 @@ function createDaisyUINumberField() {
|
|
|
5785
5980
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
5786
5981
|
props.class
|
|
5787
5982
|
].filter(Boolean).join(" ");
|
|
5983
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
5984
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
5788
5985
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
5789
5986
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
5790
5987
|
props.label || fieldMetadata.label,
|
|
@@ -5795,7 +5992,7 @@ function createDaisyUINumberField() {
|
|
|
5795
5992
|
{
|
|
5796
5993
|
class: inputClass,
|
|
5797
5994
|
placeholder: props.placeholder,
|
|
5798
|
-
disabled:
|
|
5995
|
+
disabled: isDisabled,
|
|
5799
5996
|
readonly: props.readonly,
|
|
5800
5997
|
min: fieldMetadata.min,
|
|
5801
5998
|
max: fieldMetadata.max,
|
|
@@ -5804,7 +6001,7 @@ function createDaisyUINumberField() {
|
|
|
5804
6001
|
...inputProps
|
|
5805
6002
|
}
|
|
5806
6003
|
),
|
|
5807
|
-
|
|
6004
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
5808
6005
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
5809
6006
|
] });
|
|
5810
6007
|
};
|
|
@@ -5851,6 +6048,7 @@ function createDaisyUIPasswordField() {
|
|
|
5851
6048
|
};
|
|
5852
6049
|
const hasErrors = formState.hasError(props.name);
|
|
5853
6050
|
const isTouched2 = formState.isTouched(props.name);
|
|
6051
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
5854
6052
|
const inputClass = [
|
|
5855
6053
|
"input",
|
|
5856
6054
|
props.size ? `input-${props.size}` : "",
|
|
@@ -5859,6 +6057,8 @@ function createDaisyUIPasswordField() {
|
|
|
5859
6057
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
5860
6058
|
props.class
|
|
5861
6059
|
].filter(Boolean).join(" ");
|
|
6060
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
6061
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
5862
6062
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
5863
6063
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
5864
6064
|
props.label || fieldMetadata.label,
|
|
@@ -5869,13 +6069,13 @@ function createDaisyUIPasswordField() {
|
|
|
5869
6069
|
{
|
|
5870
6070
|
class: inputClass,
|
|
5871
6071
|
placeholder: props.placeholder,
|
|
5872
|
-
disabled:
|
|
6072
|
+
disabled: isDisabled,
|
|
5873
6073
|
readonly: props.readonly,
|
|
5874
6074
|
"data-testid": `${formState.storeName}-password-field-${String(props.name)}`,
|
|
5875
6075
|
...inputProps
|
|
5876
6076
|
}
|
|
5877
6077
|
),
|
|
5878
|
-
|
|
6078
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
5879
6079
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
5880
6080
|
] });
|
|
5881
6081
|
};
|
|
@@ -5907,6 +6107,7 @@ function createDaisyUIRadioField() {
|
|
|
5907
6107
|
const currentValue = formState.getValue(props.name);
|
|
5908
6108
|
const hasErrors = formState.hasError(props.name);
|
|
5909
6109
|
const isTouched2 = formState.isTouched(props.name);
|
|
6110
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
5910
6111
|
const radioClass = [
|
|
5911
6112
|
"radio",
|
|
5912
6113
|
props.size ? `radio-${props.size}` : "",
|
|
@@ -5914,6 +6115,8 @@ function createDaisyUIRadioField() {
|
|
|
5914
6115
|
isTouched2 && !hasErrors ? "radio-success" : "",
|
|
5915
6116
|
isTouched2 && hasErrors ? "radio-error" : ""
|
|
5916
6117
|
].filter(Boolean).join(" ");
|
|
6118
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
6119
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
5917
6120
|
const handleChange = (value) => {
|
|
5918
6121
|
formState.setValue(props.name, value);
|
|
5919
6122
|
formState.touchField(props.name);
|
|
@@ -5945,7 +6148,7 @@ function createDaisyUIRadioField() {
|
|
|
5945
6148
|
checked: currentValue === option.value,
|
|
5946
6149
|
onChange: () => handleChange(option.value),
|
|
5947
6150
|
onBlur: handleBlur,
|
|
5948
|
-
disabled:
|
|
6151
|
+
disabled: isDisabled,
|
|
5949
6152
|
readonly: props.readonly,
|
|
5950
6153
|
name: props.name,
|
|
5951
6154
|
"data-testid": `${formState.storeName}-radio-field-${String(props.name)}-${option.value}`,
|
|
@@ -5956,7 +6159,7 @@ function createDaisyUIRadioField() {
|
|
|
5956
6159
|
]
|
|
5957
6160
|
}
|
|
5958
6161
|
) }, option.value)) }),
|
|
5959
|
-
|
|
6162
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "label mt-2 text-sm text-base-content/70", children: descriptionText }),
|
|
5960
6163
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-sm text-error mt-2", children: formState.getError(props.name) })
|
|
5961
6164
|
] }) });
|
|
5962
6165
|
};
|
|
@@ -6005,6 +6208,7 @@ function createDaisyUIRangeField() {
|
|
|
6005
6208
|
};
|
|
6006
6209
|
const hasErrors = formState.hasError(props.name);
|
|
6007
6210
|
const isTouched2 = formState.isTouched(props.name);
|
|
6211
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
6008
6212
|
const inputClass = [
|
|
6009
6213
|
"range",
|
|
6010
6214
|
props.size ? `range-${props.size}` : "",
|
|
@@ -6013,6 +6217,8 @@ function createDaisyUIRangeField() {
|
|
|
6013
6217
|
isTouched2 && hasErrors ? "range-error" : "",
|
|
6014
6218
|
props.class
|
|
6015
6219
|
].filter(Boolean).join(" ");
|
|
6220
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
6221
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
6016
6222
|
return /* @__PURE__ */ jsxs("div", { class: "form-control", children: [
|
|
6017
6223
|
!props.hideLabel && /* @__PURE__ */ jsxs("label", { class: "label", children: [
|
|
6018
6224
|
/* @__PURE__ */ jsxs("span", { class: "label-text", children: [
|
|
@@ -6021,8 +6227,8 @@ function createDaisyUIRangeField() {
|
|
|
6021
6227
|
] }),
|
|
6022
6228
|
props.showValue && /* @__PURE__ */ jsx("span", { class: "label-text-alt", children: currentValue })
|
|
6023
6229
|
] }),
|
|
6024
|
-
/* @__PURE__ */ jsx("input", { class: inputClass, disabled:
|
|
6025
|
-
|
|
6230
|
+
/* @__PURE__ */ jsx("input", { class: inputClass, disabled: isDisabled, readonly: props.readonly, "data-testid": `${formState.storeName}-range-field-${String(props.name)}`, ...inputProps }),
|
|
6231
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "text-sm mt-1", children: descriptionText }),
|
|
6026
6232
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-sm text-error mt-1", children: formState.getError(props.name) })
|
|
6027
6233
|
] });
|
|
6028
6234
|
};
|
|
@@ -6099,6 +6305,7 @@ function createDaisyUISearchField() {
|
|
|
6099
6305
|
};
|
|
6100
6306
|
const hasErrors = formState.hasError(props.name);
|
|
6101
6307
|
const isTouched2 = formState.isTouched(props.name);
|
|
6308
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
6102
6309
|
const inputClass = [
|
|
6103
6310
|
"input",
|
|
6104
6311
|
props.size ? `input-${props.size}` : "",
|
|
@@ -6107,6 +6314,8 @@ function createDaisyUISearchField() {
|
|
|
6107
6314
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
6108
6315
|
props.class
|
|
6109
6316
|
].filter(Boolean).join(" ");
|
|
6317
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
6318
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
6110
6319
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
6111
6320
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
6112
6321
|
props.label || fieldMetadata.label,
|
|
@@ -6117,13 +6326,13 @@ function createDaisyUISearchField() {
|
|
|
6117
6326
|
{
|
|
6118
6327
|
class: inputClass,
|
|
6119
6328
|
placeholder: props.placeholder,
|
|
6120
|
-
disabled:
|
|
6329
|
+
disabled: isDisabled,
|
|
6121
6330
|
readonly: props.readonly,
|
|
6122
6331
|
"data-testid": `${formState.storeName}-search-field-${String(props.name)}`,
|
|
6123
6332
|
...inputProps
|
|
6124
6333
|
}
|
|
6125
6334
|
),
|
|
6126
|
-
|
|
6335
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
6127
6336
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
6128
6337
|
] });
|
|
6129
6338
|
};
|
|
@@ -6174,13 +6383,20 @@ function createDaisyUISelectField() {
|
|
|
6174
6383
|
}
|
|
6175
6384
|
const fieldMetadata = formState.fieldsMetadata[props.name] || {};
|
|
6176
6385
|
const normalizedProps = normalizePropsFromAttrs(props, propsDefinition, attrs);
|
|
6386
|
+
const asyncCascadingParent = computed(() => formState.state?.asyncCascadingParents?.[props.name]);
|
|
6387
|
+
const parentFieldName = computed(() => normalizedProps.dependsOn || asyncCascadingParent.value);
|
|
6177
6388
|
const parentValue = computed(() => {
|
|
6178
|
-
if (
|
|
6179
|
-
return formState.getValue(
|
|
6389
|
+
if (parentFieldName.value) {
|
|
6390
|
+
return formState.getValue(parentFieldName.value);
|
|
6180
6391
|
}
|
|
6181
6392
|
return null;
|
|
6182
6393
|
});
|
|
6394
|
+
const fetchedOptions = computed(() => formState.state?.fetchedOptions?.[props.name] || []);
|
|
6395
|
+
const isLoadingOptions = computed(() => formState.state?.loadingOptions?.[props.name] || false);
|
|
6183
6396
|
const allOptions = computed(() => {
|
|
6397
|
+
if (fetchedOptions.value.length > 0) {
|
|
6398
|
+
return fetchedOptions.value;
|
|
6399
|
+
}
|
|
6184
6400
|
if (normalizedProps.selectOptions) {
|
|
6185
6401
|
return normalizedProps.selectOptions;
|
|
6186
6402
|
}
|
|
@@ -6226,14 +6442,26 @@ function createDaisyUISelectField() {
|
|
|
6226
6442
|
{ immediate: false }
|
|
6227
6443
|
);
|
|
6228
6444
|
}
|
|
6445
|
+
const isBeingPopulated = computed(() => formState.state?.populatingFields?.[props.name] || false);
|
|
6229
6446
|
const isDisabled = computed(() => {
|
|
6230
6447
|
if (props.disabled) return true;
|
|
6231
|
-
if (
|
|
6448
|
+
if (isLoadingOptions.value) return true;
|
|
6449
|
+
if (isBeingPopulated.value) return true;
|
|
6450
|
+
if (parentFieldName.value) {
|
|
6232
6451
|
const parentVal = parentValue.value;
|
|
6233
6452
|
return parentVal === null || parentVal === void 0 || parentVal === "";
|
|
6234
6453
|
}
|
|
6235
6454
|
return false;
|
|
6236
6455
|
});
|
|
6456
|
+
const placeholderText = computed(() => {
|
|
6457
|
+
if (isLoadingOptions.value) {
|
|
6458
|
+
return props.placeholder ? `${props.placeholder} (Loading...)` : "Loading...";
|
|
6459
|
+
}
|
|
6460
|
+
if (isBeingPopulated.value) {
|
|
6461
|
+
return props.placeholder ? `${props.placeholder} (Loading...)` : "Loading...";
|
|
6462
|
+
}
|
|
6463
|
+
return props.placeholder;
|
|
6464
|
+
});
|
|
6237
6465
|
const htmlAttrs = filterComponentPropsFromAttrs(propsDefinition, attrs);
|
|
6238
6466
|
const selectProps = {
|
|
6239
6467
|
value: formState.getValue(props.name),
|
|
@@ -6265,11 +6493,20 @@ function createDaisyUISelectField() {
|
|
|
6265
6493
|
props.label || fieldMetadata.label,
|
|
6266
6494
|
fieldMetadata.isRequired && /* @__PURE__ */ jsx("span", { class: "text-error", children: " *" })
|
|
6267
6495
|
] }),
|
|
6268
|
-
/* @__PURE__ */ jsxs(
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6496
|
+
/* @__PURE__ */ jsxs(
|
|
6497
|
+
"select",
|
|
6498
|
+
{
|
|
6499
|
+
class: selectClass,
|
|
6500
|
+
disabled: isDisabled.value,
|
|
6501
|
+
"data-testid": `${formState.storeName}-select-field-${String(props.name)}`,
|
|
6502
|
+
...selectProps,
|
|
6503
|
+
children: [
|
|
6504
|
+
placeholderText.value && /* @__PURE__ */ jsx("option", { value: "", disabled: true, selected: true, children: placeholderText.value }),
|
|
6505
|
+
getOptions.value.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
|
|
6506
|
+
]
|
|
6507
|
+
}
|
|
6508
|
+
),
|
|
6509
|
+
(isBeingPopulated.value ? "Loading..." : props.description) && /* @__PURE__ */ jsx("p", { class: "", children: isBeingPopulated.value ? "Loading..." : props.description }),
|
|
6273
6510
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
6274
6511
|
] });
|
|
6275
6512
|
};
|
|
@@ -6318,6 +6555,7 @@ function createDaisyUITelField() {
|
|
|
6318
6555
|
};
|
|
6319
6556
|
const hasErrors = formState.hasError(props.name);
|
|
6320
6557
|
const isTouched2 = formState.isTouched(props.name);
|
|
6558
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
6321
6559
|
const inputClass = [
|
|
6322
6560
|
"input",
|
|
6323
6561
|
props.size ? `input-${props.size}` : "",
|
|
@@ -6326,6 +6564,8 @@ function createDaisyUITelField() {
|
|
|
6326
6564
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
6327
6565
|
props.class
|
|
6328
6566
|
].filter(Boolean).join(" ");
|
|
6567
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
6568
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
6329
6569
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
6330
6570
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
6331
6571
|
props.label || fieldMetadata.label,
|
|
@@ -6336,13 +6576,13 @@ function createDaisyUITelField() {
|
|
|
6336
6576
|
{
|
|
6337
6577
|
class: inputClass,
|
|
6338
6578
|
placeholder: props.placeholder,
|
|
6339
|
-
disabled:
|
|
6579
|
+
disabled: isDisabled,
|
|
6340
6580
|
readonly: props.readonly,
|
|
6341
6581
|
"data-testid": `${formState.storeName}-tel-field-${String(props.name)}`,
|
|
6342
6582
|
...inputProps
|
|
6343
6583
|
}
|
|
6344
6584
|
),
|
|
6345
|
-
|
|
6585
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
6346
6586
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
6347
6587
|
] });
|
|
6348
6588
|
};
|
|
@@ -6422,6 +6662,7 @@ function createDaisyUITextareaField() {
|
|
|
6422
6662
|
};
|
|
6423
6663
|
const hasErrors = formState.hasError(props.name);
|
|
6424
6664
|
const isTouched2 = formState.isTouched(props.name);
|
|
6665
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
6425
6666
|
const textareaClass = [
|
|
6426
6667
|
"textarea",
|
|
6427
6668
|
props.size ? `textarea-${props.size}` : "",
|
|
@@ -6430,6 +6671,8 @@ function createDaisyUITextareaField() {
|
|
|
6430
6671
|
isTouched2 && hasErrors ? "textarea-error" : "",
|
|
6431
6672
|
props.class
|
|
6432
6673
|
].filter(Boolean).join(" ");
|
|
6674
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
6675
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
6433
6676
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
6434
6677
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
6435
6678
|
props.label || fieldMetadata.label,
|
|
@@ -6441,14 +6684,14 @@ function createDaisyUITextareaField() {
|
|
|
6441
6684
|
ref: setTextareaRef,
|
|
6442
6685
|
class: textareaClass,
|
|
6443
6686
|
placeholder: props.placeholder,
|
|
6444
|
-
disabled:
|
|
6687
|
+
disabled: isDisabled,
|
|
6445
6688
|
readonly: props.readonly,
|
|
6446
6689
|
rows: props.rows || 3,
|
|
6447
6690
|
"data-testid": `${formState.storeName}-textarea-field-${String(props.name)}`,
|
|
6448
6691
|
...textareaProps
|
|
6449
6692
|
}
|
|
6450
6693
|
),
|
|
6451
|
-
|
|
6694
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
6452
6695
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
6453
6696
|
] });
|
|
6454
6697
|
};
|
|
@@ -6496,6 +6739,7 @@ function createDaisyUITextField() {
|
|
|
6496
6739
|
};
|
|
6497
6740
|
const hasErrors = formState.hasError(props.name);
|
|
6498
6741
|
const isTouched2 = formState.isTouched(props.name);
|
|
6742
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
6499
6743
|
const inputClass = [
|
|
6500
6744
|
"input",
|
|
6501
6745
|
props.size ? `input-${props.size}` : "",
|
|
@@ -6504,6 +6748,8 @@ function createDaisyUITextField() {
|
|
|
6504
6748
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
6505
6749
|
props.class
|
|
6506
6750
|
].filter(Boolean).join(" ");
|
|
6751
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
6752
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
6507
6753
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
6508
6754
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
6509
6755
|
props.label || fieldMetadata.label,
|
|
@@ -6514,13 +6760,13 @@ function createDaisyUITextField() {
|
|
|
6514
6760
|
{
|
|
6515
6761
|
class: inputClass,
|
|
6516
6762
|
placeholder: props.placeholder,
|
|
6517
|
-
disabled:
|
|
6763
|
+
disabled: isDisabled,
|
|
6518
6764
|
readonly: props.readonly,
|
|
6519
6765
|
"data-testid": `${formState.storeName}-text-field-${String(props.name)}`,
|
|
6520
6766
|
...inputProps
|
|
6521
6767
|
}
|
|
6522
6768
|
),
|
|
6523
|
-
|
|
6769
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
6524
6770
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
6525
6771
|
] });
|
|
6526
6772
|
};
|
|
@@ -6567,6 +6813,7 @@ function createDaisyUITimeField() {
|
|
|
6567
6813
|
};
|
|
6568
6814
|
const hasErrors = formState.hasError(props.name);
|
|
6569
6815
|
const isTouched2 = formState.isTouched(props.name);
|
|
6816
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
6570
6817
|
const inputClass = [
|
|
6571
6818
|
"input",
|
|
6572
6819
|
props.size ? `input-${props.size}` : "",
|
|
@@ -6575,6 +6822,8 @@ function createDaisyUITimeField() {
|
|
|
6575
6822
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
6576
6823
|
props.class
|
|
6577
6824
|
].filter(Boolean).join(" ");
|
|
6825
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
6826
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
6578
6827
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
6579
6828
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
6580
6829
|
props.label || fieldMetadata.label,
|
|
@@ -6585,13 +6834,13 @@ function createDaisyUITimeField() {
|
|
|
6585
6834
|
{
|
|
6586
6835
|
class: inputClass,
|
|
6587
6836
|
placeholder: props.placeholder,
|
|
6588
|
-
disabled:
|
|
6837
|
+
disabled: isDisabled,
|
|
6589
6838
|
readonly: props.readonly,
|
|
6590
6839
|
"data-testid": `${formState.storeName}-time-field-${String(props.name)}`,
|
|
6591
6840
|
...inputProps
|
|
6592
6841
|
}
|
|
6593
6842
|
),
|
|
6594
|
-
|
|
6843
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
6595
6844
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
6596
6845
|
] });
|
|
6597
6846
|
};
|
|
@@ -7127,6 +7376,7 @@ function createDaisyUIUrlField() {
|
|
|
7127
7376
|
};
|
|
7128
7377
|
const hasErrors = formState.hasError(props.name);
|
|
7129
7378
|
const isTouched2 = formState.isTouched(props.name);
|
|
7379
|
+
const isBeingPopulated = formState.state?.populatingFields?.[props.name] || false;
|
|
7130
7380
|
const inputClass = [
|
|
7131
7381
|
"input",
|
|
7132
7382
|
props.size ? `input-${props.size}` : "",
|
|
@@ -7135,6 +7385,8 @@ function createDaisyUIUrlField() {
|
|
|
7135
7385
|
isTouched2 && hasErrors ? "input-error" : "",
|
|
7136
7386
|
props.class
|
|
7137
7387
|
].filter(Boolean).join(" ");
|
|
7388
|
+
const isDisabled = props.disabled || isBeingPopulated;
|
|
7389
|
+
const descriptionText = isBeingPopulated ? "Loading..." : props.description;
|
|
7138
7390
|
return /* @__PURE__ */ jsxs("label", { class: "floating-label", children: [
|
|
7139
7391
|
!props.hideLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
7140
7392
|
props.label || fieldMetadata.label,
|
|
@@ -7145,13 +7397,13 @@ function createDaisyUIUrlField() {
|
|
|
7145
7397
|
{
|
|
7146
7398
|
class: inputClass,
|
|
7147
7399
|
placeholder: props.placeholder,
|
|
7148
|
-
disabled:
|
|
7400
|
+
disabled: isDisabled,
|
|
7149
7401
|
readonly: props.readonly,
|
|
7150
7402
|
"data-testid": `${formState.storeName}-url-field-${String(props.name)}`,
|
|
7151
7403
|
...inputProps
|
|
7152
7404
|
}
|
|
7153
7405
|
),
|
|
7154
|
-
|
|
7406
|
+
descriptionText && /* @__PURE__ */ jsx("p", { class: "", children: descriptionText }),
|
|
7155
7407
|
isTouched2 && hasErrors && /* @__PURE__ */ jsx("p", { class: "text-error text-xs", children: formState.getError(props.name) })
|
|
7156
7408
|
] });
|
|
7157
7409
|
};
|
|
@@ -7833,20 +8085,19 @@ var SelectFilter = (props) => {
|
|
|
7833
8085
|
return /* @__PURE__ */ jsxs(
|
|
7834
8086
|
"select",
|
|
7835
8087
|
{
|
|
7836
|
-
value: props.value,
|
|
8088
|
+
value: props.value || "",
|
|
7837
8089
|
onChange: (e) => {
|
|
7838
8090
|
const value = e.target.value;
|
|
7839
8091
|
props.onFilterChange(props.field, value, "eq");
|
|
7840
8092
|
},
|
|
7841
|
-
class: "select select-bordered
|
|
8093
|
+
class: "select select-bordered select-sm w-full",
|
|
7842
8094
|
disabled: props.isLoading || props.isOptionsLoading,
|
|
7843
8095
|
"data-testid": `datatable-filter-${props.field}-input`,
|
|
7844
8096
|
children: [
|
|
7845
8097
|
/* @__PURE__ */ jsx("option", { value: "", children: props.isOptionsLoading ? "Loading options..." : `All ${props.label}` }),
|
|
7846
8098
|
props.options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
|
|
7847
8099
|
]
|
|
7848
|
-
}
|
|
7849
|
-
props.field
|
|
8100
|
+
}
|
|
7850
8101
|
);
|
|
7851
8102
|
};
|
|
7852
8103
|
|
|
@@ -7865,7 +8116,7 @@ function debounce(key, callback, delay = 300) {
|
|
|
7865
8116
|
}
|
|
7866
8117
|
var TextFilter = (props) => {
|
|
7867
8118
|
const currentOperator = props.filterOperators.value[props.field] || "contains";
|
|
7868
|
-
return /* @__PURE__ */ jsxs("div", { class: "flex gap-2
|
|
8119
|
+
return /* @__PURE__ */ jsxs("div", { class: "flex gap-1.5 md:gap-2 w-full items-center", children: [
|
|
7869
8120
|
/* @__PURE__ */ jsxs(
|
|
7870
8121
|
"select",
|
|
7871
8122
|
{
|
|
@@ -7878,7 +8129,7 @@ var TextFilter = (props) => {
|
|
|
7878
8129
|
props.onFilterChange(props.field, currentValue, newOperator);
|
|
7879
8130
|
}
|
|
7880
8131
|
},
|
|
7881
|
-
class: "select select-bordered select-sm w-
|
|
8132
|
+
class: "select select-bordered select-sm w-24 md:w-32 flex-shrink-0 text-xs",
|
|
7882
8133
|
"data-testid": `datatable-filter-${props.field}-operator`,
|
|
7883
8134
|
children: [
|
|
7884
8135
|
/* @__PURE__ */ jsx("option", { value: "contains", children: "Contains" }),
|
|
@@ -7910,16 +8161,15 @@ var TextFilter = (props) => {
|
|
|
7910
8161
|
}
|
|
7911
8162
|
},
|
|
7912
8163
|
placeholder: `Filter by ${props.label}`,
|
|
7913
|
-
class: "input input-bordered input-sm flex-1",
|
|
8164
|
+
class: "input input-bordered input-sm flex-1 min-w-0",
|
|
7914
8165
|
"data-testid": `datatable-filter-${props.field}-input`
|
|
7915
|
-
}
|
|
7916
|
-
props.field
|
|
8166
|
+
}
|
|
7917
8167
|
)
|
|
7918
8168
|
] });
|
|
7919
8169
|
};
|
|
7920
8170
|
var NumberFilter = (props) => {
|
|
7921
8171
|
const currentOperator = props.filterOperators.value[props.field] || "eq";
|
|
7922
|
-
return /* @__PURE__ */ jsxs("div", { class: "flex gap-2
|
|
8172
|
+
return /* @__PURE__ */ jsxs("div", { class: "flex gap-1.5 md:gap-2 w-full items-center", children: [
|
|
7923
8173
|
/* @__PURE__ */ jsxs(
|
|
7924
8174
|
"select",
|
|
7925
8175
|
{
|
|
@@ -7932,7 +8182,7 @@ var NumberFilter = (props) => {
|
|
|
7932
8182
|
props.onFilterChange(props.field, currentValue, newOperator);
|
|
7933
8183
|
}
|
|
7934
8184
|
},
|
|
7935
|
-
class: "select select-bordered select-sm w-16",
|
|
8185
|
+
class: "select select-bordered select-sm w-16 md:w-20 flex-shrink-0 text-xs font-medium",
|
|
7936
8186
|
"data-testid": `datatable-filter-${props.field}-operator`,
|
|
7937
8187
|
children: [
|
|
7938
8188
|
/* @__PURE__ */ jsx("option", { value: "eq", children: "=" }),
|
|
@@ -7965,10 +8215,9 @@ var NumberFilter = (props) => {
|
|
|
7965
8215
|
}
|
|
7966
8216
|
},
|
|
7967
8217
|
placeholder: `Filter by ${props.label}`,
|
|
7968
|
-
class: "input input-bordered input-sm flex-1",
|
|
8218
|
+
class: "input input-bordered input-sm flex-1 min-w-0",
|
|
7969
8219
|
"data-testid": `datatable-filter-${props.field}-input`
|
|
7970
|
-
}
|
|
7971
|
-
props.field
|
|
8220
|
+
}
|
|
7972
8221
|
)
|
|
7973
8222
|
] });
|
|
7974
8223
|
};
|
|
@@ -7976,13 +8225,13 @@ var BooleanFilter = (props) => {
|
|
|
7976
8225
|
return /* @__PURE__ */ jsxs(
|
|
7977
8226
|
"select",
|
|
7978
8227
|
{
|
|
7979
|
-
value: props.value,
|
|
8228
|
+
value: props.value || "",
|
|
7980
8229
|
onChange: (e) => {
|
|
7981
8230
|
const stringValue = e.target.value;
|
|
7982
8231
|
const value = stringValue === "true" ? true : stringValue === "false" ? false : stringValue;
|
|
7983
8232
|
props.onFilterChange(props.field, value, "eq");
|
|
7984
8233
|
},
|
|
7985
|
-
class: "select select-bordered
|
|
8234
|
+
class: "select select-bordered select-sm w-full",
|
|
7986
8235
|
disabled: props.isLoading,
|
|
7987
8236
|
"data-testid": `datatable-filter-${props.field}-input`,
|
|
7988
8237
|
children: [
|
|
@@ -7990,89 +8239,262 @@ var BooleanFilter = (props) => {
|
|
|
7990
8239
|
/* @__PURE__ */ jsx("option", { value: "true", children: "Yes" }),
|
|
7991
8240
|
/* @__PURE__ */ jsx("option", { value: "false", children: "No" })
|
|
7992
8241
|
]
|
|
7993
|
-
}
|
|
7994
|
-
props.field
|
|
8242
|
+
}
|
|
7995
8243
|
);
|
|
7996
8244
|
};
|
|
7997
|
-
var
|
|
7998
|
-
const
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
onFilterChange: props.onFilterChange
|
|
8018
|
-
},
|
|
8019
|
-
field
|
|
8020
|
-
);
|
|
8021
|
-
}
|
|
8022
|
-
if (filterType === "text") {
|
|
8023
|
-
return /* @__PURE__ */ jsx(
|
|
8024
|
-
TextFilter,
|
|
8025
|
-
{
|
|
8026
|
-
field,
|
|
8027
|
-
value: currentValue,
|
|
8028
|
-
label: column.label,
|
|
8029
|
-
filterInputValues: props.filterInputValues,
|
|
8030
|
-
filterOperators: props.filterOperators,
|
|
8031
|
-
onFilterChange: props.onFilterChange
|
|
8032
|
-
},
|
|
8033
|
-
field
|
|
8034
|
-
);
|
|
8035
|
-
}
|
|
8036
|
-
if (filterType === "number") {
|
|
8037
|
-
return /* @__PURE__ */ jsx(
|
|
8038
|
-
NumberFilter,
|
|
8245
|
+
var FilterDrawer = (props) => {
|
|
8246
|
+
const injectedFilterOptionsState = inject(
|
|
8247
|
+
ZINIA_DATA_TABLE_FILTER_OPTIONS_STATE_KEY,
|
|
8248
|
+
void 0
|
|
8249
|
+
);
|
|
8250
|
+
const injectedFilterOptionsLoading = inject(
|
|
8251
|
+
ZINIA_DATA_TABLE_FILTER_OPTIONS_LOADING_KEY,
|
|
8252
|
+
void 0
|
|
8253
|
+
);
|
|
8254
|
+
const filterOptionsState = props.filterOptionsState || injectedFilterOptionsState;
|
|
8255
|
+
const filterOptionsLoading = props.filterOptionsLoading || injectedFilterOptionsLoading;
|
|
8256
|
+
const filterableColumns = Object.entries(props.columns).filter(([_, column]) => column?.filterable);
|
|
8257
|
+
return /* @__PURE__ */ jsxs(
|
|
8258
|
+
"div",
|
|
8259
|
+
{
|
|
8260
|
+
class: `absolute inset-0 z-50 pointer-events-none ${props.isOpen ? "" : "hidden"}`,
|
|
8261
|
+
style: { display: props.isOpen ? "block" : "none" },
|
|
8262
|
+
children: [
|
|
8263
|
+
/* @__PURE__ */ jsx(
|
|
8264
|
+
"div",
|
|
8039
8265
|
{
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
},
|
|
8047
|
-
field
|
|
8048
|
-
);
|
|
8049
|
-
}
|
|
8050
|
-
if (filterType === "boolean") {
|
|
8051
|
-
return /* @__PURE__ */ jsx(
|
|
8052
|
-
BooleanFilter,
|
|
8266
|
+
class: "absolute inset-0 bg-black/50 transition-opacity opacity-100 pointer-events-auto",
|
|
8267
|
+
onClick: () => props.onClose()
|
|
8268
|
+
}
|
|
8269
|
+
),
|
|
8270
|
+
/* @__PURE__ */ jsxs(
|
|
8271
|
+
"aside",
|
|
8053
8272
|
{
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8273
|
+
class: "absolute top-0 left-0 h-full w-full md:w-80 bg-base-100 flex flex-col shadow-xl transform transition-transform duration-300 ease-out translate-x-0 pointer-events-auto",
|
|
8274
|
+
style: { maxHeight: "100%" },
|
|
8275
|
+
onClick: (e) => e.stopPropagation(),
|
|
8276
|
+
"data-testid": `${props.tableName || "datatable"}-filter-drawer`,
|
|
8277
|
+
children: [
|
|
8278
|
+
/* @__PURE__ */ jsxs("div", { class: "flex items-center justify-between p-2 md:p-3 border-b border-base-300 bg-base-200/50 flex-shrink-0", children: [
|
|
8279
|
+
/* @__PURE__ */ jsxs("div", { class: "flex items-center gap-2", children: [
|
|
8280
|
+
/* @__PURE__ */ jsx("h3", { class: "text-sm md:text-base font-semibold", children: "Filters" }),
|
|
8281
|
+
Object.keys(props.activeFilters).length > 0 && /* @__PURE__ */ jsx("span", { class: "badge badge-primary badge-sm", children: Object.keys(props.activeFilters).length })
|
|
8282
|
+
] }),
|
|
8283
|
+
/* @__PURE__ */ jsxs("div", { class: "flex items-center gap-2", children: [
|
|
8284
|
+
Object.keys(props.activeFilters).length > 0 && /* @__PURE__ */ jsxs(
|
|
8285
|
+
"button",
|
|
8286
|
+
{
|
|
8287
|
+
onClick: () => props.onClearAllFilters(),
|
|
8288
|
+
class: "btn btn-ghost btn-sm",
|
|
8289
|
+
disabled: props.isLoading,
|
|
8290
|
+
title: "Clear all filters",
|
|
8291
|
+
"data-testid": `${props.tableName || "datatable"}-filter-drawer-clear-all`,
|
|
8292
|
+
children: [
|
|
8293
|
+
/* @__PURE__ */ jsx(
|
|
8294
|
+
"svg",
|
|
8295
|
+
{
|
|
8296
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8297
|
+
class: "h-4 w-4 mr-1",
|
|
8298
|
+
fill: "none",
|
|
8299
|
+
viewBox: "0 0 24 24",
|
|
8300
|
+
stroke: "currentColor",
|
|
8301
|
+
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M6 18L18 6M6 6l12 12" })
|
|
8302
|
+
}
|
|
8303
|
+
),
|
|
8304
|
+
"Clear All"
|
|
8305
|
+
]
|
|
8306
|
+
}
|
|
8307
|
+
),
|
|
8308
|
+
/* @__PURE__ */ jsx(
|
|
8309
|
+
"button",
|
|
8310
|
+
{
|
|
8311
|
+
class: "btn btn-ghost btn-sm btn-circle hover:bg-base-300",
|
|
8312
|
+
onClick: () => props.onClose(),
|
|
8313
|
+
"aria-label": "Close filters",
|
|
8314
|
+
children: /* @__PURE__ */ jsx(
|
|
8315
|
+
"svg",
|
|
8316
|
+
{
|
|
8317
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8318
|
+
class: "h-5 w-5",
|
|
8319
|
+
fill: "none",
|
|
8320
|
+
viewBox: "0 0 24 24",
|
|
8321
|
+
stroke: "currentColor",
|
|
8322
|
+
children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M6 18L18 6M6 6l12 12" })
|
|
8323
|
+
}
|
|
8324
|
+
)
|
|
8325
|
+
}
|
|
8326
|
+
)
|
|
8327
|
+
] })
|
|
8328
|
+
] }),
|
|
8329
|
+
/* @__PURE__ */ jsx("div", { class: "p-2 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { class: "space-y-2", children: filterableColumns.map(([field, column]) => {
|
|
8330
|
+
const currentFilter = props.activeFilters[field];
|
|
8331
|
+
const currentValue = currentFilter?.value ?? "";
|
|
8332
|
+
const filterType = getFilterType(field, column, props.fieldsMetadata);
|
|
8333
|
+
const hasValue = currentValue !== "" && currentValue !== null && currentValue !== void 0;
|
|
8334
|
+
return /* @__PURE__ */ jsxs(
|
|
8335
|
+
"div",
|
|
8336
|
+
{
|
|
8337
|
+
class: `space-y-1.5 md:space-y-2 p-2 md:p-2.5 rounded-lg transition-colors ${hasValue ? "bg-primary/10 border border-primary/20" : "bg-base-200/30 border border-base-300/50"}`,
|
|
8338
|
+
children: [
|
|
8339
|
+
/* @__PURE__ */ jsxs("label", { class: "text-xs md:text-sm font-semibold text-base-content flex items-center gap-1.5", children: [
|
|
8340
|
+
/* @__PURE__ */ jsx("span", { children: column.label }),
|
|
8341
|
+
hasValue && /* @__PURE__ */ jsx("span", { class: "badge badge-primary badge-xs", children: "Active" })
|
|
8342
|
+
] }),
|
|
8343
|
+
filterType === "select" && /* @__PURE__ */ jsx(
|
|
8344
|
+
SelectFilter,
|
|
8345
|
+
{
|
|
8346
|
+
field,
|
|
8347
|
+
value: currentValue,
|
|
8348
|
+
options: getFilterOptions(
|
|
8349
|
+
field,
|
|
8350
|
+
column,
|
|
8351
|
+
props.fieldsMetadata,
|
|
8352
|
+
filterOptionsState?.value || {}
|
|
8353
|
+
),
|
|
8354
|
+
label: column.label,
|
|
8355
|
+
isLoading: props.isLoading,
|
|
8356
|
+
isOptionsLoading: filterOptionsLoading?.value?.[field] ?? false,
|
|
8357
|
+
onFilterChange: props.onFilterChange
|
|
8358
|
+
}
|
|
8359
|
+
),
|
|
8360
|
+
filterType === "text" && /* @__PURE__ */ jsx(
|
|
8361
|
+
TextFilter,
|
|
8362
|
+
{
|
|
8363
|
+
field,
|
|
8364
|
+
value: currentValue,
|
|
8365
|
+
label: column.label,
|
|
8366
|
+
filterInputValues: props.filterInputValues,
|
|
8367
|
+
filterOperators: props.filterOperators,
|
|
8368
|
+
onFilterChange: props.onFilterChange
|
|
8369
|
+
}
|
|
8370
|
+
),
|
|
8371
|
+
filterType === "number" && /* @__PURE__ */ jsx(
|
|
8372
|
+
NumberFilter,
|
|
8373
|
+
{
|
|
8374
|
+
field,
|
|
8375
|
+
value: currentValue,
|
|
8376
|
+
label: column.label,
|
|
8377
|
+
filterInputValues: props.filterInputValues,
|
|
8378
|
+
filterOperators: props.filterOperators,
|
|
8379
|
+
onFilterChange: props.onFilterChange
|
|
8380
|
+
}
|
|
8381
|
+
),
|
|
8382
|
+
filterType === "boolean" && /* @__PURE__ */ jsx(
|
|
8383
|
+
BooleanFilter,
|
|
8384
|
+
{
|
|
8385
|
+
field,
|
|
8386
|
+
value: currentValue,
|
|
8387
|
+
label: column.label,
|
|
8388
|
+
isLoading: props.isLoading,
|
|
8389
|
+
onFilterChange: props.onFilterChange
|
|
8390
|
+
}
|
|
8391
|
+
)
|
|
8392
|
+
]
|
|
8393
|
+
},
|
|
8394
|
+
field
|
|
8395
|
+
);
|
|
8396
|
+
}) }) }),
|
|
8397
|
+
/* @__PURE__ */ jsx("div", { class: "p-2 md:p-3 border-t border-base-300 bg-base-200/50 flex-shrink-0", children: /* @__PURE__ */ jsx(
|
|
8398
|
+
"button",
|
|
8399
|
+
{
|
|
8400
|
+
class: "btn btn-primary w-full btn-sm text-xs md:text-sm",
|
|
8401
|
+
onClick: () => props.onClose(),
|
|
8402
|
+
"data-testid": `${props.tableName || "datatable"}-filter-drawer-apply`,
|
|
8403
|
+
children: "Done"
|
|
8404
|
+
}
|
|
8405
|
+
) })
|
|
8406
|
+
]
|
|
8407
|
+
}
|
|
8408
|
+
)
|
|
8409
|
+
]
|
|
8410
|
+
}
|
|
8411
|
+
);
|
|
8412
|
+
};
|
|
8413
|
+
function formatFilterValue(field, value, column, fieldsMetadata, filterOptionsState) {
|
|
8414
|
+
if (value === "" || value === null || value === void 0) return "";
|
|
8415
|
+
if (typeof value === "boolean") {
|
|
8416
|
+
return value ? "Yes" : "No";
|
|
8417
|
+
}
|
|
8418
|
+
const options = getFilterOptions(field, column, fieldsMetadata, filterOptionsState);
|
|
8419
|
+
if (options.length > 0) {
|
|
8420
|
+
const option = options.find((opt) => opt.value === value);
|
|
8421
|
+
if (option) return option.label;
|
|
8422
|
+
}
|
|
8423
|
+
if (value instanceof Date) {
|
|
8424
|
+
return value.toLocaleDateString();
|
|
8425
|
+
}
|
|
8426
|
+
const strValue = String(value);
|
|
8427
|
+
return strValue.length > 20 ? strValue.substring(0, 20) + "..." : strValue;
|
|
8428
|
+
}
|
|
8429
|
+
function getOperatorLabel(operator) {
|
|
8430
|
+
const labels = {
|
|
8431
|
+
eq: "=",
|
|
8432
|
+
contains: "contains",
|
|
8433
|
+
gt: ">",
|
|
8434
|
+
lt: "<",
|
|
8435
|
+
in: "in",
|
|
8436
|
+
between: "between"
|
|
8437
|
+
};
|
|
8438
|
+
return labels[operator] || operator;
|
|
8439
|
+
}
|
|
8440
|
+
var FiltersRow = (props) => {
|
|
8441
|
+
const filterableColumns = Object.entries(props.columns).filter(([_, column]) => column?.filterable);
|
|
8442
|
+
const activeFilterBadges = filterableColumns.map(([field, column]) => {
|
|
8443
|
+
const filter = props.activeFilters[field];
|
|
8444
|
+
if (!filter || filter.value === "" || filter.value === null || filter.value === void 0) {
|
|
8063
8445
|
return null;
|
|
8064
|
-
}
|
|
8065
|
-
|
|
8446
|
+
}
|
|
8447
|
+
const displayValue = formatFilterValue(
|
|
8448
|
+
field,
|
|
8449
|
+
filter.value,
|
|
8450
|
+
column,
|
|
8451
|
+
props.fieldsMetadata,
|
|
8452
|
+
props.filterOptionsState?.value
|
|
8453
|
+
);
|
|
8454
|
+
const operator = filter.operator || "eq";
|
|
8455
|
+
const operatorLabel = getOperatorLabel(operator);
|
|
8456
|
+
return {
|
|
8457
|
+
field,
|
|
8458
|
+
label: column.label,
|
|
8459
|
+
value: filter.value,
|
|
8460
|
+
displayValue,
|
|
8461
|
+
operator,
|
|
8462
|
+
operatorLabel
|
|
8463
|
+
};
|
|
8464
|
+
}).filter((badge) => badge !== null);
|
|
8465
|
+
const handleRemoveFilter = (field) => {
|
|
8466
|
+
props.filterInputValues.value[field] = "";
|
|
8467
|
+
if (props.filterOperators.value[field]) {
|
|
8468
|
+
delete props.filterOperators.value[field];
|
|
8469
|
+
}
|
|
8470
|
+
props.onFilterChange(field, "", "eq");
|
|
8471
|
+
};
|
|
8472
|
+
return /* @__PURE__ */ jsxs("div", { class: "mb-4 space-y-2", children: [
|
|
8473
|
+
/* @__PURE__ */ jsxs("div", { class: "flex items-center gap-2", children: [
|
|
8066
8474
|
/* @__PURE__ */ jsxs(
|
|
8067
8475
|
"button",
|
|
8068
8476
|
{
|
|
8069
|
-
onClick: () =>
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8477
|
+
onClick: () => {
|
|
8478
|
+
if (props.filterDrawerOpen.value) {
|
|
8479
|
+
props.onCloseFilterDrawer();
|
|
8480
|
+
} else {
|
|
8481
|
+
props.onOpenFilterDrawer();
|
|
8482
|
+
}
|
|
8483
|
+
},
|
|
8484
|
+
class: "btn btn-outline btn-sm",
|
|
8485
|
+
"data-testid": `${props.tableName || "datatable"}-filters-toggle`,
|
|
8073
8486
|
children: [
|
|
8074
|
-
/* @__PURE__ */ jsx("
|
|
8075
|
-
|
|
8487
|
+
/* @__PURE__ */ jsx("svg", { class: "w-4 h-4 mr-1", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
|
|
8488
|
+
"path",
|
|
8489
|
+
{
|
|
8490
|
+
"stroke-linecap": "round",
|
|
8491
|
+
"stroke-linejoin": "round",
|
|
8492
|
+
"stroke-width": "2",
|
|
8493
|
+
d: "M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"
|
|
8494
|
+
}
|
|
8495
|
+
) }),
|
|
8496
|
+
"Filters",
|
|
8497
|
+
props.filterCount > 0 && /* @__PURE__ */ jsx("span", { class: "badge badge-primary badge-sm ml-1", children: props.filterCount })
|
|
8076
8498
|
]
|
|
8077
8499
|
}
|
|
8078
8500
|
),
|
|
@@ -8080,55 +8502,43 @@ var FiltersRow = (props) => {
|
|
|
8080
8502
|
"button",
|
|
8081
8503
|
{
|
|
8082
8504
|
onClick: () => props.onRefresh(),
|
|
8083
|
-
class: "btn btn-primary
|
|
8505
|
+
class: "btn btn-primary btn-sm ml-auto",
|
|
8084
8506
|
disabled: props.isLoading,
|
|
8085
8507
|
"data-testid": `${props.tableName || "datatable"}-refresh`,
|
|
8086
8508
|
children: [
|
|
8087
|
-
props.isLoading && /* @__PURE__ */
|
|
8088
|
-
|
|
8089
|
-
{
|
|
8090
|
-
class: "animate-spin -ml-1 mr-2 h-4 w-4",
|
|
8091
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
8092
|
-
fill: "none",
|
|
8093
|
-
viewBox: "0 0 24 24",
|
|
8094
|
-
children: [
|
|
8095
|
-
/* @__PURE__ */ jsx(
|
|
8096
|
-
"circle",
|
|
8097
|
-
{
|
|
8098
|
-
class: "opacity-25",
|
|
8099
|
-
cx: "12",
|
|
8100
|
-
cy: "12",
|
|
8101
|
-
r: "10",
|
|
8102
|
-
stroke: "currentColor",
|
|
8103
|
-
"stroke-width": "4"
|
|
8104
|
-
}
|
|
8105
|
-
),
|
|
8106
|
-
/* @__PURE__ */ jsx(
|
|
8107
|
-
"path",
|
|
8108
|
-
{
|
|
8109
|
-
class: "opacity-75",
|
|
8110
|
-
fill: "currentColor",
|
|
8111
|
-
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
8112
|
-
}
|
|
8113
|
-
)
|
|
8114
|
-
]
|
|
8115
|
-
}
|
|
8116
|
-
),
|
|
8117
|
-
/* @__PURE__ */ jsx("span", { class: "hidden sm:inline", children: props.isLoading ? "Loading..." : "Refresh" }),
|
|
8118
|
-
/* @__PURE__ */ jsx("span", { class: "sm:hidden", children: !props.isLoading && /* @__PURE__ */ jsx("svg", { class: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
|
|
8119
|
-
"path",
|
|
8120
|
-
{
|
|
8121
|
-
"stroke-linecap": "round",
|
|
8122
|
-
"stroke-linejoin": "round",
|
|
8123
|
-
"stroke-width": "2",
|
|
8124
|
-
d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
|
8125
|
-
}
|
|
8126
|
-
) }) })
|
|
8509
|
+
props.isLoading && /* @__PURE__ */ jsx("span", { class: "loading loading-spinner loading-xs mr-2" }),
|
|
8510
|
+
props.isLoading ? "Loading..." : "Refresh"
|
|
8127
8511
|
]
|
|
8128
8512
|
}
|
|
8129
8513
|
)
|
|
8130
|
-
] })
|
|
8131
|
-
|
|
8514
|
+
] }),
|
|
8515
|
+
activeFilterBadges.length > 0 && /* @__PURE__ */ jsx("div", { class: "flex flex-wrap items-center gap-2", children: activeFilterBadges.map((badge) => /* @__PURE__ */ jsxs(
|
|
8516
|
+
"div",
|
|
8517
|
+
{
|
|
8518
|
+
class: "badge badge-primary badge-lg gap-1.5 px-3 py-2",
|
|
8519
|
+
"data-testid": `${props.tableName || "datatable"}-filter-badge-${badge.field}`,
|
|
8520
|
+
children: [
|
|
8521
|
+
/* @__PURE__ */ jsxs("span", { class: "font-medium", children: [
|
|
8522
|
+
badge.label,
|
|
8523
|
+
":"
|
|
8524
|
+
] }),
|
|
8525
|
+
badge.operator !== "eq" && badge.operator !== "contains" && /* @__PURE__ */ jsx("span", { class: "opacity-70", children: badge.operatorLabel }),
|
|
8526
|
+
/* @__PURE__ */ jsx("span", { children: badge.displayValue }),
|
|
8527
|
+
/* @__PURE__ */ jsx(
|
|
8528
|
+
"button",
|
|
8529
|
+
{
|
|
8530
|
+
class: "btn btn-ghost btn-xs btn-circle h-4 w-4 min-h-0 p-0 ml-1",
|
|
8531
|
+
onClick: () => handleRemoveFilter(badge.field),
|
|
8532
|
+
title: `Remove ${badge.label} filter`,
|
|
8533
|
+
"data-testid": `${props.tableName || "datatable"}-filter-badge-${badge.field}-remove`,
|
|
8534
|
+
children: /* @__PURE__ */ jsx("svg", { class: "w-3 h-3", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M6 18L18 6M6 6l12 12" }) })
|
|
8535
|
+
}
|
|
8536
|
+
)
|
|
8537
|
+
]
|
|
8538
|
+
},
|
|
8539
|
+
badge.field
|
|
8540
|
+
)) })
|
|
8541
|
+
] });
|
|
8132
8542
|
};
|
|
8133
8543
|
var LoadingSkeletons = (props) => {
|
|
8134
8544
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -8575,7 +8985,9 @@ function createDaisyUIDataTable() {
|
|
|
8575
8985
|
const actions = inject(ZINIA_DATA_TABLE_ACTIONS_KEY);
|
|
8576
8986
|
const searchInputValue = inject(ZINIA_DATA_TABLE_SEARCH_INPUT_KEY);
|
|
8577
8987
|
const filterInputValues = inject(ZINIA_DATA_TABLE_FILTER_INPUTS_KEY);
|
|
8578
|
-
const filterOperators = inject(
|
|
8988
|
+
const filterOperators = inject(
|
|
8989
|
+
ZINIA_DATA_TABLE_FILTER_OPERATORS_KEY
|
|
8990
|
+
);
|
|
8579
8991
|
const filterOptionsState = inject(ZINIA_DATA_TABLE_FILTER_OPTIONS_STATE_KEY);
|
|
8580
8992
|
const filterOptionsLoading = inject(ZINIA_DATA_TABLE_FILTER_OPTIONS_LOADING_KEY);
|
|
8581
8993
|
const tableName = inject(ZINIA_DATA_TABLE_NAME_KEY);
|
|
@@ -8627,7 +9039,7 @@ function createDaisyUIDataTable() {
|
|
|
8627
9039
|
table.sort(field);
|
|
8628
9040
|
}
|
|
8629
9041
|
};
|
|
8630
|
-
return /* @__PURE__ */ jsxs("div", { class: props.class
|
|
9042
|
+
return /* @__PURE__ */ jsxs("div", { class: `relative ${props.class || ""}`, children: [
|
|
8631
9043
|
options.search?.searchableFields && options.search.searchableFields.length > 0 && searchInputValue && /* @__PURE__ */ jsx(
|
|
8632
9044
|
SearchInput,
|
|
8633
9045
|
{
|
|
@@ -8642,23 +9054,6 @@ function createDaisyUIDataTable() {
|
|
|
8642
9054
|
}
|
|
8643
9055
|
}
|
|
8644
9056
|
),
|
|
8645
|
-
Object.values(columns).some((col) => col?.filterable) && filterInputValues && filterOperators && /* @__PURE__ */ jsx(
|
|
8646
|
-
FiltersRow,
|
|
8647
|
-
{
|
|
8648
|
-
columns,
|
|
8649
|
-
activeFilters: table.filters.active,
|
|
8650
|
-
filterInputValues,
|
|
8651
|
-
filterOperators,
|
|
8652
|
-
filterOptionsState,
|
|
8653
|
-
filterOptionsLoading,
|
|
8654
|
-
fieldsMetadata: table.fieldsMetadata,
|
|
8655
|
-
isLoading: table.isLoading,
|
|
8656
|
-
filterCount: table.filters.count,
|
|
8657
|
-
onFilterChange: (field, value, operator) => table.setFilter(field, value, operator),
|
|
8658
|
-
onClearAllFilters: () => table.clearAllFilters(),
|
|
8659
|
-
onRefresh: () => table.refresh()
|
|
8660
|
-
}
|
|
8661
|
-
),
|
|
8662
9057
|
hasSelection.value && slots["selection-actions"] && /* @__PURE__ */ jsx(
|
|
8663
9058
|
SelectionActions,
|
|
8664
9059
|
{
|
|
@@ -8670,92 +9065,107 @@ function createDaisyUIDataTable() {
|
|
|
8670
9065
|
triggerBulkAction: table.triggerBulkAction
|
|
8671
9066
|
}
|
|
8672
9067
|
),
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
pageSize: table.pagination.pageSize,
|
|
8677
|
-
columnKeys: columnKeys.value,
|
|
8678
|
-
hasSelection: hasSelection.value
|
|
8679
|
-
}
|
|
8680
|
-
) : table.hasError ? (
|
|
8681
|
-
/* Show error state */
|
|
8682
|
-
/* @__PURE__ */ jsxs("div", { class: "mt-4", children: [
|
|
8683
|
-
/* @__PURE__ */ jsx(ErrorDisplay, { error: table.error || "An error occurred while loading data" }),
|
|
8684
|
-
/* @__PURE__ */ jsx("div", { class: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxs(
|
|
8685
|
-
"button",
|
|
8686
|
-
{
|
|
8687
|
-
onClick: () => table.refresh(),
|
|
8688
|
-
class: "btn btn-primary",
|
|
8689
|
-
children: [
|
|
8690
|
-
/* @__PURE__ */ jsx("svg", { class: "w-4 h-4 mr-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
|
|
8691
|
-
"path",
|
|
8692
|
-
{
|
|
8693
|
-
"stroke-linecap": "round",
|
|
8694
|
-
"stroke-linejoin": "round",
|
|
8695
|
-
"stroke-width": "2",
|
|
8696
|
-
d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
|
8697
|
-
}
|
|
8698
|
-
) }),
|
|
8699
|
-
"Try Again"
|
|
8700
|
-
]
|
|
8701
|
-
}
|
|
8702
|
-
) })
|
|
8703
|
-
] })
|
|
8704
|
-
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8705
|
-
/* @__PURE__ */ jsx(
|
|
8706
|
-
MobileCards,
|
|
9068
|
+
/* @__PURE__ */ jsxs("div", { class: "relative h-[600px] max-h-[90vh] flex flex-col", children: [
|
|
9069
|
+
Object.values(columns).some((col) => col?.filterable) && filterInputValues && filterOperators && /* @__PURE__ */ jsx(
|
|
9070
|
+
FiltersRow,
|
|
8707
9071
|
{
|
|
8708
|
-
data: table.data,
|
|
8709
9072
|
columns,
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
hasData: table.hasData,
|
|
8716
|
-
isLoading: table.isLoading,
|
|
8717
|
-
isEmpty: table.isEmpty,
|
|
8718
|
-
sortingField: table.sorting.field,
|
|
8719
|
-
sortingDirection: table.sorting.direction,
|
|
8720
|
-
sortDrawerOpen: table.ui.sortDrawerOpen.value,
|
|
9073
|
+
activeFilters: table.filters.active,
|
|
9074
|
+
filterInputValues,
|
|
9075
|
+
filterOperators,
|
|
9076
|
+
filterOptionsState,
|
|
9077
|
+
filterOptionsLoading,
|
|
8721
9078
|
fieldsMetadata: table.fieldsMetadata,
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
onClearSort: () => table.clearSort(),
|
|
8731
|
-
onSort: (field, direction) => table.sort(field, direction)
|
|
9079
|
+
isLoading: table.isLoading,
|
|
9080
|
+
filterCount: table.filters.count,
|
|
9081
|
+
filterDrawerOpen: table.ui.filterDrawerOpen,
|
|
9082
|
+
onFilterChange: (field, value, operator) => table.setFilter(field, value, operator),
|
|
9083
|
+
onClearAllFilters: () => table.clearAllFilters(),
|
|
9084
|
+
onRefresh: () => table.refresh(),
|
|
9085
|
+
onOpenFilterDrawer: () => table.ui.openFilterDrawer(),
|
|
9086
|
+
onCloseFilterDrawer: () => table.ui.closeFilterDrawer()
|
|
8732
9087
|
}
|
|
8733
9088
|
),
|
|
8734
|
-
/* @__PURE__ */ jsx(
|
|
8735
|
-
|
|
9089
|
+
/* @__PURE__ */ jsx("div", { class: "w-full overflow-auto", style: { maxHeight: "calc(100% - 80px)" }, children: table.isLoading ? /* @__PURE__ */ jsx(
|
|
9090
|
+
LoadingSkeletons,
|
|
8736
9091
|
{
|
|
8737
|
-
|
|
8738
|
-
columns,
|
|
9092
|
+
pageSize: table.pagination.pageSize,
|
|
8739
9093
|
columnKeys: columnKeys.value,
|
|
8740
|
-
|
|
8741
|
-
hasSelection: hasSelection.value,
|
|
8742
|
-
selectionMode: selectionMode.value,
|
|
8743
|
-
isAllSelected: table.selection.isAllSelected,
|
|
8744
|
-
hasData: table.hasData,
|
|
8745
|
-
isLoading: table.isLoading,
|
|
8746
|
-
isEmpty: table.isEmpty,
|
|
8747
|
-
sortingField: table.sorting.field,
|
|
8748
|
-
sortingDirection: table.sorting.direction,
|
|
8749
|
-
slots,
|
|
8750
|
-
tableName,
|
|
8751
|
-
isRowSelected: (row) => table.isRowSelected(row),
|
|
8752
|
-
onSelectAll: () => table.selectAll(),
|
|
8753
|
-
onClearSelection: () => table.clearSelection(),
|
|
8754
|
-
onSelectRow: (row) => table.selectRow(row),
|
|
8755
|
-
onSort: (field) => handleSort(field)
|
|
9094
|
+
hasSelection: hasSelection.value
|
|
8756
9095
|
}
|
|
8757
|
-
)
|
|
8758
|
-
|
|
9096
|
+
) : table.hasError ? (
|
|
9097
|
+
/* Show error state */
|
|
9098
|
+
/* @__PURE__ */ jsxs("div", { class: "mt-4", children: [
|
|
9099
|
+
/* @__PURE__ */ jsx(ErrorDisplay, { error: table.error || "An error occurred while loading data" }),
|
|
9100
|
+
/* @__PURE__ */ jsx("div", { class: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxs("button", { onClick: () => table.refresh(), class: "btn btn-primary", children: [
|
|
9101
|
+
/* @__PURE__ */ jsx("svg", { class: "w-4 h-4 mr-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
|
|
9102
|
+
"path",
|
|
9103
|
+
{
|
|
9104
|
+
"stroke-linecap": "round",
|
|
9105
|
+
"stroke-linejoin": "round",
|
|
9106
|
+
"stroke-width": "2",
|
|
9107
|
+
d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
|
9108
|
+
}
|
|
9109
|
+
) }),
|
|
9110
|
+
"Try Again"
|
|
9111
|
+
] }) })
|
|
9112
|
+
] })
|
|
9113
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9114
|
+
/* @__PURE__ */ jsx(
|
|
9115
|
+
MobileCards,
|
|
9116
|
+
{
|
|
9117
|
+
data: table.data,
|
|
9118
|
+
columns,
|
|
9119
|
+
columnKeys: columnKeys.value,
|
|
9120
|
+
actions,
|
|
9121
|
+
hasSelection: hasSelection.value,
|
|
9122
|
+
selectionMode: selectionMode.value,
|
|
9123
|
+
isAllSelected: table.selection.isAllSelected,
|
|
9124
|
+
hasData: table.hasData,
|
|
9125
|
+
isLoading: table.isLoading,
|
|
9126
|
+
isEmpty: table.isEmpty,
|
|
9127
|
+
sortingField: table.sorting.field,
|
|
9128
|
+
sortingDirection: table.sorting.direction,
|
|
9129
|
+
sortDrawerOpen: table.ui.sortDrawerOpen.value,
|
|
9130
|
+
fieldsMetadata: table.fieldsMetadata,
|
|
9131
|
+
slots,
|
|
9132
|
+
tableName,
|
|
9133
|
+
isRowSelected: (row) => table.isRowSelected(row),
|
|
9134
|
+
onSelectAll: () => table.selectAll(),
|
|
9135
|
+
onClearSelection: () => table.clearSelection(),
|
|
9136
|
+
onSelectRow: (row) => table.selectRow(row),
|
|
9137
|
+
onOpenSortDrawer: () => table.ui.openSortDrawer(),
|
|
9138
|
+
onCloseSortDrawer: () => table.ui.closeSortDrawer(),
|
|
9139
|
+
onClearSort: () => table.clearSort(),
|
|
9140
|
+
onSort: (field, direction) => table.sort(field, direction)
|
|
9141
|
+
}
|
|
9142
|
+
),
|
|
9143
|
+
/* @__PURE__ */ jsx(
|
|
9144
|
+
DesktopTable,
|
|
9145
|
+
{
|
|
9146
|
+
data: table.data,
|
|
9147
|
+
columns,
|
|
9148
|
+
columnKeys: columnKeys.value,
|
|
9149
|
+
actions,
|
|
9150
|
+
hasSelection: hasSelection.value,
|
|
9151
|
+
selectionMode: selectionMode.value,
|
|
9152
|
+
isAllSelected: table.selection.isAllSelected,
|
|
9153
|
+
hasData: table.hasData,
|
|
9154
|
+
isLoading: table.isLoading,
|
|
9155
|
+
isEmpty: table.isEmpty,
|
|
9156
|
+
sortingField: table.sorting.field,
|
|
9157
|
+
sortingDirection: table.sorting.direction,
|
|
9158
|
+
slots,
|
|
9159
|
+
tableName,
|
|
9160
|
+
isRowSelected: (row) => table.isRowSelected(row),
|
|
9161
|
+
onSelectAll: () => table.selectAll(),
|
|
9162
|
+
onClearSelection: () => table.clearSelection(),
|
|
9163
|
+
onSelectRow: (row) => table.selectRow(row),
|
|
9164
|
+
onSort: (field) => handleSort(field)
|
|
9165
|
+
}
|
|
9166
|
+
)
|
|
9167
|
+
] }) }),
|
|
9168
|
+
table.hasData && !table.isLoading && /* @__PURE__ */ jsx("div", { class: "flex-shrink-0 mt-4", children: /* @__PURE__ */ jsx(
|
|
8759
9169
|
Pagination,
|
|
8760
9170
|
{
|
|
8761
9171
|
currentPage: table.pagination.currentPage,
|
|
@@ -8774,6 +9184,24 @@ function createDaisyUIDataTable() {
|
|
|
8774
9184
|
onNextPage: () => table.nextPage(),
|
|
8775
9185
|
onSetPageSize: (size) => table.setPageSize(size)
|
|
8776
9186
|
}
|
|
9187
|
+
) }),
|
|
9188
|
+
Object.values(columns).some((col) => col?.filterable) && filterInputValues && filterOperators && /* @__PURE__ */ jsx(
|
|
9189
|
+
FilterDrawer,
|
|
9190
|
+
{
|
|
9191
|
+
isOpen: table.ui.filterDrawerOpen.value,
|
|
9192
|
+
columns,
|
|
9193
|
+
activeFilters: table.filters.active,
|
|
9194
|
+
filterInputValues,
|
|
9195
|
+
filterOperators,
|
|
9196
|
+
filterOptionsState,
|
|
9197
|
+
filterOptionsLoading,
|
|
9198
|
+
fieldsMetadata: table.fieldsMetadata,
|
|
9199
|
+
isLoading: table.isLoading,
|
|
9200
|
+
tableName,
|
|
9201
|
+
onClose: () => table.ui.closeFilterDrawer(),
|
|
9202
|
+
onFilterChange: (field, value, operator) => table.setFilter(field, value, operator),
|
|
9203
|
+
onClearAllFilters: () => table.clearAllFilters()
|
|
9204
|
+
}
|
|
8777
9205
|
)
|
|
8778
9206
|
] })
|
|
8779
9207
|
] });
|