@bsol-oss/react-datatable5 13.0.1-beta.7 → 13.0.1-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -5089,7 +5089,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
5089
5089
|
const watchEnum = watch(colLabel);
|
|
5090
5090
|
const watchEnums = (watch(colLabel) ?? []);
|
|
5091
5091
|
const dataList = schema.enum ?? [];
|
|
5092
|
-
// Helper function to render enum value
|
|
5092
|
+
// Helper function to render enum value (returns ReactNode)
|
|
5093
5093
|
// If renderDisplay is provided, use it; otherwise show the enum string value directly
|
|
5094
5094
|
const renderEnumValue = (value) => {
|
|
5095
5095
|
if (renderDisplay) {
|
|
@@ -5098,6 +5098,35 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
5098
5098
|
// If no renderDisplay provided, show the enum string value directly
|
|
5099
5099
|
return value;
|
|
5100
5100
|
};
|
|
5101
|
+
// Helper function to get string representation for input display
|
|
5102
|
+
// Converts ReactNode to string for combobox input display
|
|
5103
|
+
const getDisplayString = (value) => {
|
|
5104
|
+
if (renderDisplay) {
|
|
5105
|
+
const rendered = renderDisplay(value);
|
|
5106
|
+
// If renderDisplay returns a string, use it directly
|
|
5107
|
+
if (typeof rendered === 'string') {
|
|
5108
|
+
return rendered;
|
|
5109
|
+
}
|
|
5110
|
+
// If it's a React element, try to extract text content
|
|
5111
|
+
// For now, fallback to the raw value if we can't extract text
|
|
5112
|
+
// In most cases, renderDisplay should return a string or simple element
|
|
5113
|
+
if (typeof rendered === 'object' &&
|
|
5114
|
+
rendered !== null &&
|
|
5115
|
+
'props' in rendered) {
|
|
5116
|
+
const props = rendered.props;
|
|
5117
|
+
// Try to extract text from React element props
|
|
5118
|
+
if (props?.children) {
|
|
5119
|
+
const children = props.children;
|
|
5120
|
+
if (typeof children === 'string') {
|
|
5121
|
+
return children;
|
|
5122
|
+
}
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
// Fallback: use raw value if we can't extract string
|
|
5126
|
+
return value;
|
|
5127
|
+
}
|
|
5128
|
+
return value;
|
|
5129
|
+
};
|
|
5101
5130
|
// Debug log when renderDisplay is missing
|
|
5102
5131
|
if (!renderDisplay) {
|
|
5103
5132
|
console.debug(`[EnumPicker] Missing renderDisplay for field '${colLabel}'. Add renderDisplay function to schema for field '${colLabel}' to provide custom UI rendering. Currently showing enum string values directly.`, {
|
|
@@ -5113,19 +5142,29 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
5113
5142
|
: watchEnum
|
|
5114
5143
|
? [watchEnum]
|
|
5115
5144
|
: [];
|
|
5145
|
+
// Track input focus state for single selection
|
|
5146
|
+
const [isInputFocused, setIsInputFocused] = React.useState(false);
|
|
5147
|
+
// Get the selected value for single selection display
|
|
5148
|
+
const selectedSingleValue = !isMultiple && watchEnum ? watchEnum : null;
|
|
5149
|
+
const selectedSingleRendered = selectedSingleValue
|
|
5150
|
+
? renderEnumValue(selectedSingleValue)
|
|
5151
|
+
: null;
|
|
5152
|
+
const isSelectedSingleValueString = typeof selectedSingleRendered === 'string';
|
|
5116
5153
|
const comboboxItems = React.useMemo(() => {
|
|
5117
5154
|
return dataList.map((item) => ({
|
|
5118
5155
|
label: item, // Internal: used for search/filtering only
|
|
5119
5156
|
value: item,
|
|
5120
5157
|
raw: item, // Passed to renderEnumValue for UI rendering
|
|
5158
|
+
displayLabel: getDisplayString(item), // Used for input display when selected
|
|
5121
5159
|
}));
|
|
5122
|
-
}, [dataList]);
|
|
5160
|
+
}, [dataList, renderDisplay]);
|
|
5123
5161
|
// Use filter hook for combobox
|
|
5124
5162
|
const { contains } = react.useFilter({ sensitivity: 'base' });
|
|
5125
5163
|
// Create collection for combobox
|
|
5164
|
+
// itemToString uses displayLabel to show rendered display in input when selected
|
|
5126
5165
|
const { collection, filter } = react.useListCollection({
|
|
5127
5166
|
initialItems: comboboxItems,
|
|
5128
|
-
itemToString: (item) => item.
|
|
5167
|
+
itemToString: (item) => item.displayLabel, // Use displayLabel for selected value display
|
|
5129
5168
|
itemToValue: (item) => item.value,
|
|
5130
5169
|
filter: contains,
|
|
5131
5170
|
});
|
|
@@ -5163,7 +5202,26 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
5163
5202
|
}, children: renderEnumValue(enumValue) }, enumValue));
|
|
5164
5203
|
}) })), jsxRuntime.jsxs(react.Combobox.Root, { collection: collection, value: currentValue, onValueChange: handleValueChange, onInputValueChange: handleInputValueChange, multiple: isMultiple, closeOnSelect: !isMultiple, openOnClick: true, invalid: !!errors[colLabel], width: "100%", positioning: insideDialog
|
|
5165
5204
|
? { strategy: 'fixed', hideWhenDetached: true }
|
|
5166
|
-
: undefined, children: [jsxRuntime.jsxs(react.Combobox.Control, {
|
|
5205
|
+
: undefined, children: [jsxRuntime.jsxs(react.Combobox.Control, { position: "relative", children: [!isMultiple &&
|
|
5206
|
+
selectedSingleValue &&
|
|
5207
|
+
!isInputFocused &&
|
|
5208
|
+
!isSelectedSingleValueString &&
|
|
5209
|
+
selectedSingleRendered && (jsxRuntime.jsx(react.Box, { position: "absolute", left: 3, top: "50%", transform: "translateY(-50%)", pointerEvents: "none", zIndex: 1, maxWidth: "calc(100% - 60px)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", children: selectedSingleRendered })), jsxRuntime.jsx(react.Combobox.Input, { placeholder: !isMultiple && selectedSingleValue && !isInputFocused
|
|
5210
|
+
? undefined
|
|
5211
|
+
: enumPickerLabels?.typeToSearch ?? 'Type to search', onFocus: () => setIsInputFocused(true), onBlur: () => setIsInputFocused(false), style: {
|
|
5212
|
+
color: !isMultiple &&
|
|
5213
|
+
selectedSingleValue &&
|
|
5214
|
+
!isInputFocused &&
|
|
5215
|
+
!isSelectedSingleValueString
|
|
5216
|
+
? 'transparent'
|
|
5217
|
+
: undefined,
|
|
5218
|
+
caretColor: !isMultiple &&
|
|
5219
|
+
selectedSingleValue &&
|
|
5220
|
+
!isInputFocused &&
|
|
5221
|
+
!isSelectedSingleValueString
|
|
5222
|
+
? 'transparent'
|
|
5223
|
+
: undefined,
|
|
5224
|
+
} }), jsxRuntime.jsxs(react.Combobox.IndicatorGroup, { children: [!isMultiple && currentValue.length > 0 && (jsxRuntime.jsx(react.Combobox.ClearTrigger, { onClick: () => {
|
|
5167
5225
|
setValue(colLabel, '');
|
|
5168
5226
|
} })), jsxRuntime.jsx(react.Combobox.Trigger, {})] })] }), insideDialog ? (jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsxs(react.Combobox.Content, { children: [showTotalAndLimit && (jsxRuntime.jsx(react.Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [jsxRuntime.jsx(react.Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) })) : (jsxRuntime.jsx(react.Portal, { children: jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsxs(react.Combobox.Content, { children: [showTotalAndLimit && (jsxRuntime.jsx(react.Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [jsxRuntime.jsx(react.Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) }) }))] })] }));
|
|
5169
5227
|
};
|
|
@@ -5907,15 +5965,46 @@ const FormMediaLibraryBrowser = ({ column, schema, prefix, }) => {
|
|
|
5907
5965
|
}) })] }));
|
|
5908
5966
|
};
|
|
5909
5967
|
|
|
5910
|
-
// Default renderDisplay function that
|
|
5968
|
+
// Default renderDisplay function that intelligently displays items
|
|
5969
|
+
// If item is an object, tries to find common display fields (name, title, label, etc.)
|
|
5970
|
+
// Otherwise falls back to JSON.stringify
|
|
5911
5971
|
const defaultRenderDisplay = (item) => {
|
|
5972
|
+
// Check if item is an object (not null, not array, not primitive)
|
|
5973
|
+
if (item !== null &&
|
|
5974
|
+
typeof item === 'object' &&
|
|
5975
|
+
!Array.isArray(item) &&
|
|
5976
|
+
!(item instanceof Date)) {
|
|
5977
|
+
const obj = item;
|
|
5978
|
+
// Try common display fields in order of preference
|
|
5979
|
+
const displayFields = [
|
|
5980
|
+
'name',
|
|
5981
|
+
'title',
|
|
5982
|
+
'label',
|
|
5983
|
+
'displayName',
|
|
5984
|
+
'display_name',
|
|
5985
|
+
'text',
|
|
5986
|
+
'value',
|
|
5987
|
+
];
|
|
5988
|
+
for (const field of displayFields) {
|
|
5989
|
+
if (obj[field] !== undefined && obj[field] !== null) {
|
|
5990
|
+
const value = obj[field];
|
|
5991
|
+
// Return the value if it's a string or number, otherwise stringify it
|
|
5992
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
5993
|
+
return String(value);
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
// If no display field found, fall back to JSON.stringify
|
|
5998
|
+
return JSON.stringify(item);
|
|
5999
|
+
}
|
|
6000
|
+
// For non-objects (primitives, arrays, dates), use JSON.stringify
|
|
5912
6001
|
return JSON.stringify(item);
|
|
5913
6002
|
};
|
|
5914
6003
|
|
|
5915
6004
|
const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
5916
6005
|
const { watch, getValues, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
5917
6006
|
const { idMap, setIdMap, idPickerLabels, insideDialog } = useSchemaContext();
|
|
5918
|
-
const { renderDisplay, loadInitialValues, foreign_key, variant } = schema;
|
|
6007
|
+
const { renderDisplay, itemToValue: schemaItemToValue, loadInitialValues, foreign_key, variant, } = schema;
|
|
5919
6008
|
// loadInitialValues should be provided in schema for id-picker fields
|
|
5920
6009
|
// It's used to load the record of the id so the display is human-readable
|
|
5921
6010
|
if (variant === 'id-picker' && !loadInitialValues) {
|
|
@@ -6048,17 +6137,51 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
|
6048
6137
|
// Depend on idMapKey which only changes when items we care about change
|
|
6049
6138
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6050
6139
|
}, [currentValueKey, idMapKey]);
|
|
6140
|
+
// Default itemToValue function: extract value from item using column_ref
|
|
6141
|
+
const defaultItemToValue = (item) => String(item[column_ref]);
|
|
6142
|
+
// Use schema's itemToValue if provided, otherwise use default
|
|
6143
|
+
const itemToValueFn = schemaItemToValue
|
|
6144
|
+
? (item) => schemaItemToValue(item)
|
|
6145
|
+
: defaultItemToValue;
|
|
6146
|
+
// itemToString function: convert item to readable string using renderDisplay
|
|
6147
|
+
// This ensures items can always be displayed as readable strings in the combobox
|
|
6148
|
+
const renderFn = renderDisplay || defaultRenderDisplay;
|
|
6149
|
+
const itemToStringFn = (item) => {
|
|
6150
|
+
const rendered = renderFn(item);
|
|
6151
|
+
// If already a string or number, return it
|
|
6152
|
+
if (typeof rendered === 'string')
|
|
6153
|
+
return rendered;
|
|
6154
|
+
if (typeof rendered === 'number')
|
|
6155
|
+
return String(rendered);
|
|
6156
|
+
// For ReactNode, fall back to defaultRenderDisplay which converts to string
|
|
6157
|
+
return String(defaultRenderDisplay(item));
|
|
6158
|
+
};
|
|
6051
6159
|
// Transform data for combobox collection
|
|
6052
6160
|
// label is used for filtering/searching (must be a string)
|
|
6161
|
+
// displayLabel is used for input display when selected (string representation of rendered display)
|
|
6053
6162
|
// raw item is stored for custom rendering
|
|
6054
6163
|
// Also include items from idMap that match currentValue (for initial values display)
|
|
6055
6164
|
const comboboxItems = React.useMemo(() => {
|
|
6056
6165
|
const renderFn = renderDisplay || defaultRenderDisplay;
|
|
6166
|
+
// Helper to convert rendered display to string for displayLabel
|
|
6167
|
+
// For ReactNodes (non-string/number), we can't safely stringify due to circular refs
|
|
6168
|
+
// So we use the label (which is already a string) as fallback
|
|
6169
|
+
const getDisplayString = (rendered, fallbackLabel) => {
|
|
6170
|
+
if (typeof rendered === 'string')
|
|
6171
|
+
return rendered;
|
|
6172
|
+
if (typeof rendered === 'number')
|
|
6173
|
+
return String(rendered);
|
|
6174
|
+
// For ReactNode, use the fallback label (which is already a string representation)
|
|
6175
|
+
// The actual ReactNode will be rendered in the overlay, not in the input
|
|
6176
|
+
return fallbackLabel;
|
|
6177
|
+
};
|
|
6057
6178
|
const itemsFromDataList = dataList.map((item) => {
|
|
6058
6179
|
const rendered = renderFn(item);
|
|
6180
|
+
const label = typeof rendered === 'string' ? rendered : JSON.stringify(item); // Use string for filtering
|
|
6059
6181
|
return {
|
|
6060
|
-
label
|
|
6061
|
-
|
|
6182
|
+
label, // Use string for filtering
|
|
6183
|
+
displayLabel: getDisplayString(rendered, label), // String representation for input display
|
|
6184
|
+
value: itemToValueFn(item),
|
|
6062
6185
|
raw: item,
|
|
6063
6186
|
};
|
|
6064
6187
|
});
|
|
@@ -6067,25 +6190,28 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
|
6067
6190
|
const itemsFromIdMap = idMapItems
|
|
6068
6191
|
.map((item) => {
|
|
6069
6192
|
// Check if this item is already in itemsFromDataList
|
|
6070
|
-
const alreadyIncluded = itemsFromDataList.some((i) => i.value ===
|
|
6193
|
+
const alreadyIncluded = itemsFromDataList.some((i) => i.value === itemToValueFn(item));
|
|
6071
6194
|
if (alreadyIncluded)
|
|
6072
6195
|
return null;
|
|
6073
6196
|
const rendered = renderFn(item);
|
|
6197
|
+
const label = typeof rendered === 'string' ? rendered : JSON.stringify(item);
|
|
6074
6198
|
return {
|
|
6075
|
-
label
|
|
6076
|
-
|
|
6199
|
+
label,
|
|
6200
|
+
displayLabel: getDisplayString(rendered, label), // String representation for input display
|
|
6201
|
+
value: itemToValueFn(item),
|
|
6077
6202
|
raw: item,
|
|
6078
6203
|
};
|
|
6079
6204
|
})
|
|
6080
6205
|
.filter((item) => item !== null);
|
|
6081
6206
|
return [...itemsFromIdMap, ...itemsFromDataList];
|
|
6082
|
-
}, [dataList, column_ref, renderDisplay, idMapItems]);
|
|
6207
|
+
}, [dataList, column_ref, renderDisplay, idMapItems, itemToValueFn]);
|
|
6083
6208
|
// Use filter hook for combobox
|
|
6084
6209
|
const { contains } = react.useFilter({ sensitivity: 'base' });
|
|
6085
6210
|
// Create collection for combobox
|
|
6211
|
+
// itemToString uses displayLabel to show rendered display in input when selected
|
|
6086
6212
|
const { collection, filter, set } = react.useListCollection({
|
|
6087
6213
|
initialItems: comboboxItems,
|
|
6088
|
-
itemToString: (item) => item.
|
|
6214
|
+
itemToString: (item) => item.displayLabel, // Use displayLabel for selected value display
|
|
6089
6215
|
itemToValue: (item) => item.value,
|
|
6090
6216
|
filter: contains,
|
|
6091
6217
|
});
|
|
@@ -6140,6 +6266,8 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
|
6140
6266
|
idPickerLabels,
|
|
6141
6267
|
insideDialog: insideDialog ?? false,
|
|
6142
6268
|
renderDisplay,
|
|
6269
|
+
itemToValue: itemToValueFn,
|
|
6270
|
+
itemToString: itemToStringFn,
|
|
6143
6271
|
loadInitialValues: loadInitialValues ??
|
|
6144
6272
|
(async () => ({ data: { data: [], count: 0 }, idMap: {} })), // Fallback if not provided
|
|
6145
6273
|
column_ref,
|
|
@@ -6150,60 +6278,69 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
|
6150
6278
|
|
|
6151
6279
|
const IdPickerSingle = ({ column, schema, prefix, }) => {
|
|
6152
6280
|
const formI18n = useFormI18n(column, prefix, schema);
|
|
6153
|
-
const { required, gridColumn = 'span 12', gridRow = 'span 1'
|
|
6281
|
+
const { required, gridColumn = 'span 12', gridRow = 'span 1' } = schema;
|
|
6154
6282
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
6155
|
-
const { colLabel, currentValue, searchText, setSearchText, isLoading, isFetching, isPending, isError, isSearching,
|
|
6283
|
+
const { colLabel, currentValue, searchText, setSearchText, isLoading, isFetching, isPending, isError, isSearching, collection, filter, idMap, idPickerLabels, insideDialog, renderDisplay: renderDisplayFn, itemToValue, itemToString, errors, setValue, } = useIdPickerData({
|
|
6156
6284
|
column,
|
|
6157
6285
|
schema,
|
|
6158
6286
|
prefix,
|
|
6159
6287
|
isMultiple: false,
|
|
6160
6288
|
});
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
const
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6289
|
+
// Get the selected value for single selection display
|
|
6290
|
+
const selectedId = currentValue.length > 0 ? currentValue[0] : null;
|
|
6291
|
+
const selectedItem = selectedId
|
|
6292
|
+
? idMap[selectedId]
|
|
6293
|
+
: undefined;
|
|
6294
|
+
// Use itemToValue to get the combobox value from the selected item, or use the ID directly
|
|
6295
|
+
const comboboxValue = selectedItem
|
|
6296
|
+
? itemToString(selectedItem)
|
|
6297
|
+
: selectedId || '';
|
|
6298
|
+
// itemToString is available from the hook and can be used to get a readable string
|
|
6299
|
+
// representation of any item. The collection's itemToString is automatically used
|
|
6300
|
+
// by the combobox to display selected values.
|
|
6301
|
+
// Use useCombobox hook to control input value
|
|
6302
|
+
const combobox = react.useCombobox({
|
|
6303
|
+
collection,
|
|
6304
|
+
value: [comboboxValue],
|
|
6305
|
+
onInputValueChange(e) {
|
|
6306
|
+
setSearchText(e.inputValue);
|
|
6307
|
+
filter(e.inputValue);
|
|
6308
|
+
},
|
|
6309
|
+
onValueChange(e) {
|
|
6310
|
+
setValue(colLabel, e.value[0] || '');
|
|
6311
|
+
// Clear the input value after selection
|
|
6312
|
+
setSearchText('');
|
|
6313
|
+
},
|
|
6314
|
+
multiple: false,
|
|
6315
|
+
closeOnSelect: true,
|
|
6316
|
+
openOnClick: true,
|
|
6317
|
+
invalid: !!errors[colLabel],
|
|
6318
|
+
});
|
|
6319
|
+
// Use renderDisplay from hook (which comes from schema) or fallback to default
|
|
6320
|
+
const renderDisplayFunction = renderDisplayFn || defaultRenderDisplay;
|
|
6321
|
+
// Get the selected value for single selection display (already computed above)
|
|
6322
|
+
const selectedRendered = selectedItem
|
|
6323
|
+
? renderDisplayFunction(selectedItem)
|
|
6324
|
+
: null;
|
|
6325
|
+
return (jsxRuntime.jsx(Field, { label: formI18n.label(), required: isRequired, alignItems: 'stretch', gridColumn,
|
|
6326
|
+
gridRow, errorText: errors[`${colLabel}`] ? formI18n.required() : undefined, invalid: !!errors[colLabel], children: jsxRuntime.jsxs(react.Combobox.RootProvider, { value: combobox, width: "100%", children: [jsxRuntime.jsx(react.Show, { when: selectedId && selectedRendered, children: jsxRuntime.jsxs(react.HStack, { justifyContent: 'space-between', children: [jsxRuntime.jsx(react.Box, { children: selectedRendered }), currentValue.length > 0 && (jsxRuntime.jsx(react.Button, { variant: "ghost", size: "sm", onClick: () => {
|
|
6327
|
+
setValue(colLabel, '');
|
|
6328
|
+
}, children: jsxRuntime.jsx(react.Icon, { children: jsxRuntime.jsx(bi.BiX, {}) }) }))] }) }), jsxRuntime.jsx(react.Show, { when: !selectedId || !selectedRendered, children: jsxRuntime.jsxs(react.Combobox.Control, { position: "relative", children: [jsxRuntime.jsx(react.Combobox.Input, { placeholder: idPickerLabels?.typeToSearch ?? 'Type to search' }), jsxRuntime.jsxs(react.Combobox.IndicatorGroup, { children: [(isFetching || isLoading || isPending) && jsxRuntime.jsx(react.Spinner, { size: "xs" }), isError && (jsxRuntime.jsx(react.Icon, { color: "fg.error", children: jsxRuntime.jsx(bi.BiError, {}) })), jsxRuntime.jsx(react.Combobox.Trigger, {})] })] }) }), insideDialog ? (jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsx(react.Combobox.Content, { children: isError ? (jsxRuntime.jsx(react.Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6329
|
+
// Show skeleton items to prevent UI shift
|
|
6330
|
+
jsxRuntime.jsx(jsxRuntime.Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsxRuntime.jsx(react.Flex, { p: 2, align: "center", gap: 2, children: jsxRuntime.jsx(react.Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: searchText
|
|
6331
|
+
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6332
|
+
: idPickerLabels?.initialResults ??
|
|
6333
|
+
'Start typing to search' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [renderDisplayFunction(item.raw), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) })) : (jsxRuntime.jsx(react.Portal, { children: jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsx(react.Combobox.Content, { children: isError ? (jsxRuntime.jsx(react.Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6188
6334
|
// Show skeleton items to prevent UI shift
|
|
6189
6335
|
jsxRuntime.jsx(jsxRuntime.Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsxRuntime.jsx(react.Flex, { p: 2, align: "center", gap: 2, children: jsxRuntime.jsx(react.Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: searchText
|
|
6190
6336
|
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6191
6337
|
: idPickerLabels?.initialResults ??
|
|
6192
|
-
'Start typing to search' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.
|
|
6193
|
-
? renderDisplayFunction(item.raw)
|
|
6194
|
-
: item.label }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) })) : (jsxRuntime.jsx(react.Portal, { children: jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsx(react.Combobox.Content, { children: isError ? (jsxRuntime.jsx(react.Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6195
|
-
// Show skeleton items to prevent UI shift
|
|
6196
|
-
jsxRuntime.jsx(jsxRuntime.Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsxRuntime.jsx(react.Flex, { p: 2, align: "center", gap: 2, children: jsxRuntime.jsx(react.Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: searchText
|
|
6197
|
-
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6198
|
-
: idPickerLabels?.initialResults ??
|
|
6199
|
-
'Start typing to search' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [jsxRuntime.jsx(react.Combobox.ItemText, { children: !!renderDisplayFunction === true
|
|
6200
|
-
? renderDisplayFunction(item.raw)
|
|
6201
|
-
: item.label }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) }) }))] })] }));
|
|
6338
|
+
'Start typing to search' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsx(react.Combobox.Item, { item: item, children: renderDisplayFunction(item.raw) }, item.value ?? `item-${index}`))) })) }) }) }))] }) }));
|
|
6202
6339
|
};
|
|
6203
6340
|
|
|
6204
6341
|
const IdPickerMultiple = ({ column, schema, prefix, }) => {
|
|
6205
6342
|
const formI18n = useFormI18n(column, prefix, schema);
|
|
6206
|
-
const { required, gridColumn = 'span 12', gridRow = 'span 1'
|
|
6343
|
+
const { required, gridColumn = 'span 12', gridRow = 'span 1' } = schema;
|
|
6207
6344
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
6208
6345
|
const { colLabel, currentValue, searchText, setSearchText, isLoading, isFetching, isPending, isError, isSearching, isLoadingInitialValues, isFetchingInitialValues, missingIds, collection, idMap, idPickerLabels, insideDialog, renderDisplay: renderDisplayFn, errors, setValue, } = useIdPickerData({
|
|
6209
6346
|
column,
|
|
@@ -6217,7 +6354,8 @@ const IdPickerMultiple = ({ column, schema, prefix, }) => {
|
|
|
6217
6354
|
const handleValueChange = (details) => {
|
|
6218
6355
|
setValue(colLabel, details.value);
|
|
6219
6356
|
};
|
|
6220
|
-
|
|
6357
|
+
// Use renderDisplay from hook (which comes from schema) or fallback to default
|
|
6358
|
+
const renderDisplayFunction = renderDisplayFn || defaultRenderDisplay;
|
|
6221
6359
|
return (jsxRuntime.jsxs(Field, { label: formI18n.label(), required: isRequired, alignItems: 'stretch', gridColumn,
|
|
6222
6360
|
gridRow, errorText: errors[`${colLabel}`] ? formI18n.required() : undefined, invalid: !!errors[colLabel], children: [currentValue.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: 'wrap', gap: 1, mb: 2, children: currentValue.map((id) => {
|
|
6223
6361
|
const item = idMap[id];
|
|
@@ -6242,16 +6380,12 @@ const IdPickerMultiple = ({ column, schema, prefix, }) => {
|
|
|
6242
6380
|
jsxRuntime.jsx(jsxRuntime.Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsxRuntime.jsx(react.Flex, { p: 2, align: "center", gap: 2, children: jsxRuntime.jsx(react.Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: searchText
|
|
6243
6381
|
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6244
6382
|
: idPickerLabels?.initialResults ??
|
|
6245
|
-
'Start typing to search' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [jsxRuntime.jsx(react.Combobox.
|
|
6246
|
-
? renderDisplayFunction(item.raw)
|
|
6247
|
-
: item.label }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) })) : (jsxRuntime.jsx(react.Portal, { children: jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsx(react.Combobox.Content, { children: isError ? (jsxRuntime.jsx(react.Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6383
|
+
'Start typing to search' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [renderDisplayFunction(item.raw), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) })) : (jsxRuntime.jsx(react.Portal, { children: jsxRuntime.jsx(react.Combobox.Positioner, { children: jsxRuntime.jsx(react.Combobox.Content, { children: isError ? (jsxRuntime.jsx(react.Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6248
6384
|
// Show skeleton items to prevent UI shift
|
|
6249
6385
|
jsxRuntime.jsx(jsxRuntime.Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsxRuntime.jsx(react.Flex, { p: 2, align: "center", gap: 2, children: jsxRuntime.jsx(react.Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsxRuntime.jsx(react.Combobox.Empty, { children: searchText
|
|
6250
6386
|
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6251
6387
|
: idPickerLabels?.initialResults ??
|
|
6252
|
-
'Start typing to search' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [jsxRuntime.jsx(react.Combobox.
|
|
6253
|
-
? renderDisplayFunction(item.raw)
|
|
6254
|
-
: item.label }), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) }) }))] })] }));
|
|
6388
|
+
'Start typing to search' })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: collection.items.map((item, index) => (jsxRuntime.jsxs(react.Combobox.Item, { item: item, children: [renderDisplayFunction(item.raw), jsxRuntime.jsx(react.Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) }) }))] })] }));
|
|
6255
6389
|
};
|
|
6256
6390
|
|
|
6257
6391
|
const NumberInputRoot = React__namespace.forwardRef(function NumberInput(props, ref) {
|
|
@@ -7388,7 +7522,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7388
7522
|
backButtonLabel: 'Back',
|
|
7389
7523
|
forwardButtonLabel: 'Next',
|
|
7390
7524
|
}, timePickerLabels, timezone = 'Asia/Hong_Kong', startTime, minDate, maxDate, portalled = false, defaultDate, defaultTime, }) {
|
|
7391
|
-
console.
|
|
7525
|
+
console.debug('[DateTimePicker] Component initialized with props:', {
|
|
7392
7526
|
value,
|
|
7393
7527
|
format,
|
|
7394
7528
|
showSeconds,
|
|
@@ -7407,13 +7541,13 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7407
7541
|
const [selectedDate, setSelectedDate] = React.useState(getDateString(value));
|
|
7408
7542
|
// Helper to get time values from value prop with timezone
|
|
7409
7543
|
const getTimeFromValue = React.useCallback((val) => {
|
|
7410
|
-
console.
|
|
7544
|
+
console.debug('[DateTimePicker] getTimeFromValue called:', {
|
|
7411
7545
|
val,
|
|
7412
7546
|
timezone,
|
|
7413
7547
|
showSeconds,
|
|
7414
7548
|
});
|
|
7415
7549
|
if (!val) {
|
|
7416
|
-
console.
|
|
7550
|
+
console.debug('[DateTimePicker] No value provided, returning nulls');
|
|
7417
7551
|
return {
|
|
7418
7552
|
hour12: null,
|
|
7419
7553
|
minute: null,
|
|
@@ -7423,7 +7557,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7423
7557
|
};
|
|
7424
7558
|
}
|
|
7425
7559
|
const dateObj = dayjs(val).tz(timezone);
|
|
7426
|
-
console.
|
|
7560
|
+
console.debug('[DateTimePicker] Parsed date object:', {
|
|
7427
7561
|
original: val,
|
|
7428
7562
|
timezone,
|
|
7429
7563
|
isValid: dateObj.isValid(),
|
|
@@ -7433,7 +7567,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7433
7567
|
second: dateObj.second(),
|
|
7434
7568
|
});
|
|
7435
7569
|
if (!dateObj.isValid()) {
|
|
7436
|
-
console.
|
|
7570
|
+
console.debug('[DateTimePicker] Invalid date object, returning nulls');
|
|
7437
7571
|
return {
|
|
7438
7572
|
hour12: null,
|
|
7439
7573
|
minute: null,
|
|
@@ -7454,11 +7588,11 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7454
7588
|
hour24: hour24Value,
|
|
7455
7589
|
second: secondValue,
|
|
7456
7590
|
};
|
|
7457
|
-
console.
|
|
7591
|
+
console.debug('[DateTimePicker] Extracted time values:', result);
|
|
7458
7592
|
return result;
|
|
7459
7593
|
}, [timezone, showSeconds]);
|
|
7460
7594
|
const initialTime = getTimeFromValue(value);
|
|
7461
|
-
console.
|
|
7595
|
+
console.debug('[DateTimePicker] Initial time from value:', {
|
|
7462
7596
|
value,
|
|
7463
7597
|
initialTime,
|
|
7464
7598
|
});
|
|
@@ -7535,14 +7669,14 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7535
7669
|
const [second, setSecond] = React.useState(initialTimeValues.second);
|
|
7536
7670
|
// Sync selectedDate and time states when value prop changes
|
|
7537
7671
|
React.useEffect(() => {
|
|
7538
|
-
console.
|
|
7672
|
+
console.debug('[DateTimePicker] useEffect triggered - value changed:', {
|
|
7539
7673
|
value,
|
|
7540
7674
|
timezone,
|
|
7541
7675
|
format,
|
|
7542
7676
|
});
|
|
7543
7677
|
// If value is null, undefined, or invalid, clear date but keep default time values
|
|
7544
7678
|
if (!value || value === null || value === undefined) {
|
|
7545
|
-
console.
|
|
7679
|
+
console.debug('[DateTimePicker] Value is null/undefined, clearing date but keeping default time');
|
|
7546
7680
|
setSelectedDate('');
|
|
7547
7681
|
// Keep default time values instead of clearing them
|
|
7548
7682
|
if (format === 'iso-date-time') {
|
|
@@ -7564,7 +7698,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7564
7698
|
// Check if value is valid
|
|
7565
7699
|
const dateObj = dayjs(value).tz(timezone);
|
|
7566
7700
|
if (!dateObj.isValid()) {
|
|
7567
|
-
console.
|
|
7701
|
+
console.debug('[DateTimePicker] Invalid value, clearing date but keeping default time');
|
|
7568
7702
|
setSelectedDate('');
|
|
7569
7703
|
// Keep default time values instead of clearing them
|
|
7570
7704
|
if (format === 'iso-date-time') {
|
|
@@ -7584,10 +7718,10 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7584
7718
|
return;
|
|
7585
7719
|
}
|
|
7586
7720
|
const dateString = getDateString(value);
|
|
7587
|
-
console.
|
|
7721
|
+
console.debug('[DateTimePicker] Setting selectedDate:', dateString);
|
|
7588
7722
|
setSelectedDate(dateString);
|
|
7589
7723
|
const timeData = getTimeFromValue(value);
|
|
7590
|
-
console.
|
|
7724
|
+
console.debug('[DateTimePicker] Updating time states:', {
|
|
7591
7725
|
timeData,
|
|
7592
7726
|
});
|
|
7593
7727
|
setHour12(timeData.hour12);
|
|
@@ -7597,7 +7731,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7597
7731
|
setSecond(timeData.second);
|
|
7598
7732
|
}, [value, getTimeFromValue, getDateString, timezone]);
|
|
7599
7733
|
const handleDateChange = (date) => {
|
|
7600
|
-
console.
|
|
7734
|
+
console.debug('[DateTimePicker] handleDateChange called:', {
|
|
7601
7735
|
date,
|
|
7602
7736
|
timezone,
|
|
7603
7737
|
showSeconds,
|
|
@@ -7605,7 +7739,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7605
7739
|
});
|
|
7606
7740
|
// If date is empty or invalid, clear all fields
|
|
7607
7741
|
if (!date || date === '') {
|
|
7608
|
-
console.
|
|
7742
|
+
console.debug('[DateTimePicker] Empty date, clearing all fields');
|
|
7609
7743
|
setSelectedDate('');
|
|
7610
7744
|
setHour12(null);
|
|
7611
7745
|
setMinute(null);
|
|
@@ -7618,7 +7752,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7618
7752
|
setSelectedDate(date);
|
|
7619
7753
|
// Parse the date string (YYYY-MM-DD) in the specified timezone
|
|
7620
7754
|
const dateObj = dayjs.tz(date, timezone);
|
|
7621
|
-
console.
|
|
7755
|
+
console.debug('[DateTimePicker] Parsed date object:', {
|
|
7622
7756
|
date,
|
|
7623
7757
|
timezone,
|
|
7624
7758
|
isValid: dateObj.isValid(),
|
|
@@ -7644,7 +7778,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7644
7778
|
if (!hasTimeValues) {
|
|
7645
7779
|
// Use defaultTime if provided, otherwise default to 00:00
|
|
7646
7780
|
if (defaultTime) {
|
|
7647
|
-
console.
|
|
7781
|
+
console.debug('[DateTimePicker] No time values set, using defaultTime');
|
|
7648
7782
|
if (format === 'iso-date-time') {
|
|
7649
7783
|
const defaultTime24 = defaultTime;
|
|
7650
7784
|
setHour24(defaultTime24.hour ?? 0);
|
|
@@ -7671,7 +7805,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7671
7805
|
}
|
|
7672
7806
|
}
|
|
7673
7807
|
else {
|
|
7674
|
-
console.
|
|
7808
|
+
console.debug('[DateTimePicker] No time values set, defaulting to 00:00');
|
|
7675
7809
|
if (format === 'iso-date-time') {
|
|
7676
7810
|
setHour24(0);
|
|
7677
7811
|
setMinute(0);
|
|
@@ -7699,17 +7833,17 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7699
7833
|
// When showSeconds is false, ignore seconds from the date
|
|
7700
7834
|
if (!showSeconds) {
|
|
7701
7835
|
const dateWithoutSeconds = dateObj.second(0).millisecond(0).toISOString();
|
|
7702
|
-
console.
|
|
7836
|
+
console.debug('[DateTimePicker] Updating date without seconds:', dateWithoutSeconds);
|
|
7703
7837
|
updateDateTime(dateWithoutSeconds, timeDataToUse);
|
|
7704
7838
|
}
|
|
7705
7839
|
else {
|
|
7706
7840
|
const dateWithSeconds = dateObj.toISOString();
|
|
7707
|
-
console.
|
|
7841
|
+
console.debug('[DateTimePicker] Updating date with seconds:', dateWithSeconds);
|
|
7708
7842
|
updateDateTime(dateWithSeconds, timeDataToUse);
|
|
7709
7843
|
}
|
|
7710
7844
|
};
|
|
7711
7845
|
const handleTimeChange = (timeData) => {
|
|
7712
|
-
console.
|
|
7846
|
+
console.debug('[DateTimePicker] handleTimeChange called:', {
|
|
7713
7847
|
timeData,
|
|
7714
7848
|
format,
|
|
7715
7849
|
selectedDate,
|
|
@@ -7717,7 +7851,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7717
7851
|
});
|
|
7718
7852
|
if (format === 'iso-date-time') {
|
|
7719
7853
|
const data = timeData;
|
|
7720
|
-
console.
|
|
7854
|
+
console.debug('[DateTimePicker] ISO format - setting 24-hour time:', data);
|
|
7721
7855
|
setHour24(data.hour);
|
|
7722
7856
|
setMinute(data.minute);
|
|
7723
7857
|
if (showSeconds) {
|
|
@@ -7730,7 +7864,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7730
7864
|
}
|
|
7731
7865
|
else {
|
|
7732
7866
|
const data = timeData;
|
|
7733
|
-
console.
|
|
7867
|
+
console.debug('[DateTimePicker] 12-hour format - setting time:', data);
|
|
7734
7868
|
setHour12(data.hour);
|
|
7735
7869
|
setMinute(data.minute);
|
|
7736
7870
|
setMeridiem(data.meridiem);
|
|
@@ -7739,7 +7873,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7739
7873
|
if (!selectedDate || !dayjs(selectedDate).isValid()) {
|
|
7740
7874
|
// If effectiveDefaultDate is available, use it instead of clearing
|
|
7741
7875
|
if (effectiveDefaultDate && dayjs(effectiveDefaultDate).isValid()) {
|
|
7742
|
-
console.
|
|
7876
|
+
console.debug('[DateTimePicker] No valid selectedDate, using effectiveDefaultDate:', effectiveDefaultDate);
|
|
7743
7877
|
setSelectedDate(effectiveDefaultDate);
|
|
7744
7878
|
const dateObj = dayjs(effectiveDefaultDate).tz(timezone);
|
|
7745
7879
|
if (dateObj.isValid()) {
|
|
@@ -7758,7 +7892,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7758
7892
|
return;
|
|
7759
7893
|
}
|
|
7760
7894
|
else {
|
|
7761
|
-
console.
|
|
7895
|
+
console.debug('[DateTimePicker] No valid selectedDate and no effectiveDefaultDate, keeping time values but no date');
|
|
7762
7896
|
// Keep the time values that were just set, but don't set a date
|
|
7763
7897
|
// This should rarely happen as effectiveDefaultDate always defaults to today
|
|
7764
7898
|
setSelectedDate('');
|
|
@@ -7782,14 +7916,14 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7782
7916
|
}
|
|
7783
7917
|
};
|
|
7784
7918
|
const updateDateTime = (date, timeData) => {
|
|
7785
|
-
console.
|
|
7919
|
+
console.debug('[DateTimePicker] updateDateTime called:', {
|
|
7786
7920
|
date,
|
|
7787
7921
|
timeData,
|
|
7788
7922
|
format,
|
|
7789
7923
|
currentStates: { hour12, minute, meridiem, hour24, second },
|
|
7790
7924
|
});
|
|
7791
7925
|
if (!date || date === null || date === undefined) {
|
|
7792
|
-
console.
|
|
7926
|
+
console.debug('[DateTimePicker] No date provided, clearing all fields and calling onChange(undefined)');
|
|
7793
7927
|
setSelectedDate('');
|
|
7794
7928
|
setHour12(null);
|
|
7795
7929
|
setMinute(null);
|
|
@@ -7827,11 +7961,11 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7827
7961
|
: 0;
|
|
7828
7962
|
// If all time values are null, clear the value
|
|
7829
7963
|
if (h === null && m === null && (showSeconds ? s === null : true)) {
|
|
7830
|
-
console.
|
|
7964
|
+
console.debug('[DateTimePicker] All time values are null, clearing value');
|
|
7831
7965
|
onChange?.(undefined);
|
|
7832
7966
|
return;
|
|
7833
7967
|
}
|
|
7834
|
-
console.
|
|
7968
|
+
console.debug('[DateTimePicker] ISO format - setting time on date:', {
|
|
7835
7969
|
h,
|
|
7836
7970
|
m,
|
|
7837
7971
|
s,
|
|
@@ -7845,7 +7979,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7845
7979
|
}
|
|
7846
7980
|
else {
|
|
7847
7981
|
const data = timeData;
|
|
7848
|
-
console.
|
|
7982
|
+
console.debug('[DateTimePicker] Processing 12-hour format:', {
|
|
7849
7983
|
'data !== undefined': data !== undefined,
|
|
7850
7984
|
'data?.hour': data?.hour,
|
|
7851
7985
|
'data?.minute': data?.minute,
|
|
@@ -7858,14 +7992,14 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7858
7992
|
const h = data !== undefined ? data.hour : hour12;
|
|
7859
7993
|
const m = data !== undefined ? data.minute : minute;
|
|
7860
7994
|
const mer = data !== undefined ? data.meridiem : meridiem;
|
|
7861
|
-
console.
|
|
7995
|
+
console.debug('[DateTimePicker] Resolved time values:', { h, m, mer });
|
|
7862
7996
|
// If all time values are null, clear the value
|
|
7863
7997
|
if (h === null && m === null && mer === null) {
|
|
7864
|
-
console.
|
|
7998
|
+
console.debug('[DateTimePicker] All time values are null, clearing value');
|
|
7865
7999
|
onChange?.(undefined);
|
|
7866
8000
|
return;
|
|
7867
8001
|
}
|
|
7868
|
-
console.
|
|
8002
|
+
console.debug('[DateTimePicker] 12-hour format - converting time:', {
|
|
7869
8003
|
h,
|
|
7870
8004
|
m,
|
|
7871
8005
|
mer,
|
|
@@ -7876,7 +8010,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7876
8010
|
hour24 = 0;
|
|
7877
8011
|
else if (mer === 'pm' && h < 12)
|
|
7878
8012
|
hour24 = h + 12;
|
|
7879
|
-
console.
|
|
8013
|
+
console.debug('[DateTimePicker] Converted to 24-hour:', {
|
|
7880
8014
|
h,
|
|
7881
8015
|
mer,
|
|
7882
8016
|
hour24,
|
|
@@ -7884,7 +8018,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7884
8018
|
newDate.setHours(hour24);
|
|
7885
8019
|
}
|
|
7886
8020
|
else {
|
|
7887
|
-
console.
|
|
8021
|
+
console.debug('[DateTimePicker] Skipping hour update - h or mer is null:', {
|
|
7888
8022
|
h,
|
|
7889
8023
|
mer,
|
|
7890
8024
|
});
|
|
@@ -7893,12 +8027,12 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7893
8027
|
newDate.setMinutes(m);
|
|
7894
8028
|
}
|
|
7895
8029
|
else {
|
|
7896
|
-
console.
|
|
8030
|
+
console.debug('[DateTimePicker] Skipping minute update - m is null');
|
|
7897
8031
|
}
|
|
7898
8032
|
newDate.setSeconds(0);
|
|
7899
8033
|
}
|
|
7900
8034
|
const finalISO = dayjs(newDate).tz(timezone).toISOString();
|
|
7901
|
-
console.
|
|
8035
|
+
console.debug('[DateTimePicker] Final ISO string to emit:', {
|
|
7902
8036
|
newDate: newDate.toISOString(),
|
|
7903
8037
|
timezone,
|
|
7904
8038
|
finalISO,
|
|
@@ -7933,7 +8067,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7933
8067
|
: undefined;
|
|
7934
8068
|
// Log current state before render
|
|
7935
8069
|
React.useEffect(() => {
|
|
7936
|
-
console.
|
|
8070
|
+
console.debug('[DateTimePicker] Current state before render:', {
|
|
7937
8071
|
isISO,
|
|
7938
8072
|
hour12,
|
|
7939
8073
|
minute,
|