@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.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, CheckboxCard as CheckboxCard$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, Tooltip as Tooltip$1, Group, InputElement, Icon, EmptyState as EmptyState$2, VStack, List, Table as Table$1, Checkbox as Checkbox$1, Card, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Clipboard, Badge, Link, Tag as Tag$1, Image, Alert, Field as Field$1, Popover, useFilter, useListCollection, Combobox, Tabs, Skeleton, NumberInput,
|
|
2
|
+
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, CheckboxCard as CheckboxCard$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, Tooltip as Tooltip$1, Group, InputElement, Icon, EmptyState as EmptyState$2, VStack, List, Table as Table$1, Checkbox as Checkbox$1, Card, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Clipboard, Badge, Link, Tag as Tag$1, Image, Alert, Field as Field$1, Popover, useFilter, useListCollection, Combobox, Tabs, useCombobox, Show, Skeleton, NumberInput, RadioCard, CheckboxGroup, InputGroup as InputGroup$1, Center, Heading, Stack } from '@chakra-ui/react';
|
|
3
3
|
import { AiOutlineColumnWidth } from 'react-icons/ai';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { createContext, useContext, useState, useMemo, useCallback, useEffect, useRef, forwardRef } from 'react';
|
|
6
6
|
import { LuX, LuCheck, LuChevronRight, LuCopy, LuExternalLink, LuSearch, LuImage, LuFile } from 'react-icons/lu';
|
|
7
7
|
import { MdOutlineSort, MdFilterAlt, MdSearch, MdOutlineChecklist, MdClear, MdOutlineViewColumn, MdFilterListAlt, MdPushPin, MdCancel, MdDateRange } from 'react-icons/md';
|
|
8
8
|
import { FaUpDown, FaGripLinesVertical, FaTrash } from 'react-icons/fa6';
|
|
9
|
-
import { BiDownArrow, BiUpArrow, BiError } from 'react-icons/bi';
|
|
9
|
+
import { BiDownArrow, BiUpArrow, BiX, BiError } from 'react-icons/bi';
|
|
10
10
|
import { CgClose, CgTrash } from 'react-icons/cg';
|
|
11
11
|
import { HiMiniEllipsisHorizontal, HiChevronLeft, HiChevronRight } from 'react-icons/hi2';
|
|
12
12
|
import { IoMdEye, IoMdCheckbox, IoMdClock } from 'react-icons/io';
|
|
@@ -5069,7 +5069,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
5069
5069
|
const watchEnum = watch(colLabel);
|
|
5070
5070
|
const watchEnums = (watch(colLabel) ?? []);
|
|
5071
5071
|
const dataList = schema.enum ?? [];
|
|
5072
|
-
// Helper function to render enum value
|
|
5072
|
+
// Helper function to render enum value (returns ReactNode)
|
|
5073
5073
|
// If renderDisplay is provided, use it; otherwise show the enum string value directly
|
|
5074
5074
|
const renderEnumValue = (value) => {
|
|
5075
5075
|
if (renderDisplay) {
|
|
@@ -5078,6 +5078,35 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
5078
5078
|
// If no renderDisplay provided, show the enum string value directly
|
|
5079
5079
|
return value;
|
|
5080
5080
|
};
|
|
5081
|
+
// Helper function to get string representation for input display
|
|
5082
|
+
// Converts ReactNode to string for combobox input display
|
|
5083
|
+
const getDisplayString = (value) => {
|
|
5084
|
+
if (renderDisplay) {
|
|
5085
|
+
const rendered = renderDisplay(value);
|
|
5086
|
+
// If renderDisplay returns a string, use it directly
|
|
5087
|
+
if (typeof rendered === 'string') {
|
|
5088
|
+
return rendered;
|
|
5089
|
+
}
|
|
5090
|
+
// If it's a React element, try to extract text content
|
|
5091
|
+
// For now, fallback to the raw value if we can't extract text
|
|
5092
|
+
// In most cases, renderDisplay should return a string or simple element
|
|
5093
|
+
if (typeof rendered === 'object' &&
|
|
5094
|
+
rendered !== null &&
|
|
5095
|
+
'props' in rendered) {
|
|
5096
|
+
const props = rendered.props;
|
|
5097
|
+
// Try to extract text from React element props
|
|
5098
|
+
if (props?.children) {
|
|
5099
|
+
const children = props.children;
|
|
5100
|
+
if (typeof children === 'string') {
|
|
5101
|
+
return children;
|
|
5102
|
+
}
|
|
5103
|
+
}
|
|
5104
|
+
}
|
|
5105
|
+
// Fallback: use raw value if we can't extract string
|
|
5106
|
+
return value;
|
|
5107
|
+
}
|
|
5108
|
+
return value;
|
|
5109
|
+
};
|
|
5081
5110
|
// Debug log when renderDisplay is missing
|
|
5082
5111
|
if (!renderDisplay) {
|
|
5083
5112
|
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.`, {
|
|
@@ -5093,19 +5122,29 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
5093
5122
|
: watchEnum
|
|
5094
5123
|
? [watchEnum]
|
|
5095
5124
|
: [];
|
|
5125
|
+
// Track input focus state for single selection
|
|
5126
|
+
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
5127
|
+
// Get the selected value for single selection display
|
|
5128
|
+
const selectedSingleValue = !isMultiple && watchEnum ? watchEnum : null;
|
|
5129
|
+
const selectedSingleRendered = selectedSingleValue
|
|
5130
|
+
? renderEnumValue(selectedSingleValue)
|
|
5131
|
+
: null;
|
|
5132
|
+
const isSelectedSingleValueString = typeof selectedSingleRendered === 'string';
|
|
5096
5133
|
const comboboxItems = useMemo(() => {
|
|
5097
5134
|
return dataList.map((item) => ({
|
|
5098
5135
|
label: item, // Internal: used for search/filtering only
|
|
5099
5136
|
value: item,
|
|
5100
5137
|
raw: item, // Passed to renderEnumValue for UI rendering
|
|
5138
|
+
displayLabel: getDisplayString(item), // Used for input display when selected
|
|
5101
5139
|
}));
|
|
5102
|
-
}, [dataList]);
|
|
5140
|
+
}, [dataList, renderDisplay]);
|
|
5103
5141
|
// Use filter hook for combobox
|
|
5104
5142
|
const { contains } = useFilter({ sensitivity: 'base' });
|
|
5105
5143
|
// Create collection for combobox
|
|
5144
|
+
// itemToString uses displayLabel to show rendered display in input when selected
|
|
5106
5145
|
const { collection, filter } = useListCollection({
|
|
5107
5146
|
initialItems: comboboxItems,
|
|
5108
|
-
itemToString: (item) => item.
|
|
5147
|
+
itemToString: (item) => item.displayLabel, // Use displayLabel for selected value display
|
|
5109
5148
|
itemToValue: (item) => item.value,
|
|
5110
5149
|
filter: contains,
|
|
5111
5150
|
});
|
|
@@ -5143,7 +5182,26 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
5143
5182
|
}, children: renderEnumValue(enumValue) }, enumValue));
|
|
5144
5183
|
}) })), jsxs(Combobox.Root, { collection: collection, value: currentValue, onValueChange: handleValueChange, onInputValueChange: handleInputValueChange, multiple: isMultiple, closeOnSelect: !isMultiple, openOnClick: true, invalid: !!errors[colLabel], width: "100%", positioning: insideDialog
|
|
5145
5184
|
? { strategy: 'fixed', hideWhenDetached: true }
|
|
5146
|
-
: undefined, children: [jsxs(Combobox.Control, {
|
|
5185
|
+
: undefined, children: [jsxs(Combobox.Control, { position: "relative", children: [!isMultiple &&
|
|
5186
|
+
selectedSingleValue &&
|
|
5187
|
+
!isInputFocused &&
|
|
5188
|
+
!isSelectedSingleValueString &&
|
|
5189
|
+
selectedSingleRendered && (jsx(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 })), jsx(Combobox.Input, { placeholder: !isMultiple && selectedSingleValue && !isInputFocused
|
|
5190
|
+
? undefined
|
|
5191
|
+
: enumPickerLabels?.typeToSearch ?? 'Type to search', onFocus: () => setIsInputFocused(true), onBlur: () => setIsInputFocused(false), style: {
|
|
5192
|
+
color: !isMultiple &&
|
|
5193
|
+
selectedSingleValue &&
|
|
5194
|
+
!isInputFocused &&
|
|
5195
|
+
!isSelectedSingleValueString
|
|
5196
|
+
? 'transparent'
|
|
5197
|
+
: undefined,
|
|
5198
|
+
caretColor: !isMultiple &&
|
|
5199
|
+
selectedSingleValue &&
|
|
5200
|
+
!isInputFocused &&
|
|
5201
|
+
!isSelectedSingleValueString
|
|
5202
|
+
? 'transparent'
|
|
5203
|
+
: undefined,
|
|
5204
|
+
} }), jsxs(Combobox.IndicatorGroup, { children: [!isMultiple && currentValue.length > 0 && (jsx(Combobox.ClearTrigger, { onClick: () => {
|
|
5147
5205
|
setValue(colLabel, '');
|
|
5148
5206
|
} })), jsx(Combobox.Trigger, {})] })] }), insideDialog ? (jsx(Combobox.Positioner, { children: jsxs(Combobox.Content, { children: [showTotalAndLimit && (jsx(Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsx(Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [jsx(Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) })) : (jsx(Portal, { children: jsx(Combobox.Positioner, { children: jsxs(Combobox.Content, { children: [showTotalAndLimit && (jsx(Text, { p: 2, fontSize: "sm", color: "fg.muted", children: `${enumPickerLabels?.total ?? 'Total'}: ${collection.items.length}` })), collection.items.length === 0 ? (jsx(Combobox.Empty, { children: enumPickerLabels?.emptySearchResult ?? 'No results found' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [jsx(Combobox.ItemText, { children: renderEnumValue(item.raw) }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) }))] }) }) }))] })] }));
|
|
5149
5207
|
};
|
|
@@ -5887,15 +5945,46 @@ const FormMediaLibraryBrowser = ({ column, schema, prefix, }) => {
|
|
|
5887
5945
|
}) })] }));
|
|
5888
5946
|
};
|
|
5889
5947
|
|
|
5890
|
-
// Default renderDisplay function that
|
|
5948
|
+
// Default renderDisplay function that intelligently displays items
|
|
5949
|
+
// If item is an object, tries to find common display fields (name, title, label, etc.)
|
|
5950
|
+
// Otherwise falls back to JSON.stringify
|
|
5891
5951
|
const defaultRenderDisplay = (item) => {
|
|
5952
|
+
// Check if item is an object (not null, not array, not primitive)
|
|
5953
|
+
if (item !== null &&
|
|
5954
|
+
typeof item === 'object' &&
|
|
5955
|
+
!Array.isArray(item) &&
|
|
5956
|
+
!(item instanceof Date)) {
|
|
5957
|
+
const obj = item;
|
|
5958
|
+
// Try common display fields in order of preference
|
|
5959
|
+
const displayFields = [
|
|
5960
|
+
'name',
|
|
5961
|
+
'title',
|
|
5962
|
+
'label',
|
|
5963
|
+
'displayName',
|
|
5964
|
+
'display_name',
|
|
5965
|
+
'text',
|
|
5966
|
+
'value',
|
|
5967
|
+
];
|
|
5968
|
+
for (const field of displayFields) {
|
|
5969
|
+
if (obj[field] !== undefined && obj[field] !== null) {
|
|
5970
|
+
const value = obj[field];
|
|
5971
|
+
// Return the value if it's a string or number, otherwise stringify it
|
|
5972
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
5973
|
+
return String(value);
|
|
5974
|
+
}
|
|
5975
|
+
}
|
|
5976
|
+
}
|
|
5977
|
+
// If no display field found, fall back to JSON.stringify
|
|
5978
|
+
return JSON.stringify(item);
|
|
5979
|
+
}
|
|
5980
|
+
// For non-objects (primitives, arrays, dates), use JSON.stringify
|
|
5892
5981
|
return JSON.stringify(item);
|
|
5893
5982
|
};
|
|
5894
5983
|
|
|
5895
5984
|
const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
5896
5985
|
const { watch, getValues, formState: { errors }, setValue, } = useFormContext();
|
|
5897
5986
|
const { idMap, setIdMap, idPickerLabels, insideDialog } = useSchemaContext();
|
|
5898
|
-
const { renderDisplay, loadInitialValues, foreign_key, variant } = schema;
|
|
5987
|
+
const { renderDisplay, itemToValue: schemaItemToValue, loadInitialValues, foreign_key, variant, } = schema;
|
|
5899
5988
|
// loadInitialValues should be provided in schema for id-picker fields
|
|
5900
5989
|
// It's used to load the record of the id so the display is human-readable
|
|
5901
5990
|
if (variant === 'id-picker' && !loadInitialValues) {
|
|
@@ -6028,17 +6117,51 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
|
6028
6117
|
// Depend on idMapKey which only changes when items we care about change
|
|
6029
6118
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6030
6119
|
}, [currentValueKey, idMapKey]);
|
|
6120
|
+
// Default itemToValue function: extract value from item using column_ref
|
|
6121
|
+
const defaultItemToValue = (item) => String(item[column_ref]);
|
|
6122
|
+
// Use schema's itemToValue if provided, otherwise use default
|
|
6123
|
+
const itemToValueFn = schemaItemToValue
|
|
6124
|
+
? (item) => schemaItemToValue(item)
|
|
6125
|
+
: defaultItemToValue;
|
|
6126
|
+
// itemToString function: convert item to readable string using renderDisplay
|
|
6127
|
+
// This ensures items can always be displayed as readable strings in the combobox
|
|
6128
|
+
const renderFn = renderDisplay || defaultRenderDisplay;
|
|
6129
|
+
const itemToStringFn = (item) => {
|
|
6130
|
+
const rendered = renderFn(item);
|
|
6131
|
+
// If already a string or number, return it
|
|
6132
|
+
if (typeof rendered === 'string')
|
|
6133
|
+
return rendered;
|
|
6134
|
+
if (typeof rendered === 'number')
|
|
6135
|
+
return String(rendered);
|
|
6136
|
+
// For ReactNode, fall back to defaultRenderDisplay which converts to string
|
|
6137
|
+
return String(defaultRenderDisplay(item));
|
|
6138
|
+
};
|
|
6031
6139
|
// Transform data for combobox collection
|
|
6032
6140
|
// label is used for filtering/searching (must be a string)
|
|
6141
|
+
// displayLabel is used for input display when selected (string representation of rendered display)
|
|
6033
6142
|
// raw item is stored for custom rendering
|
|
6034
6143
|
// Also include items from idMap that match currentValue (for initial values display)
|
|
6035
6144
|
const comboboxItems = useMemo(() => {
|
|
6036
6145
|
const renderFn = renderDisplay || defaultRenderDisplay;
|
|
6146
|
+
// Helper to convert rendered display to string for displayLabel
|
|
6147
|
+
// For ReactNodes (non-string/number), we can't safely stringify due to circular refs
|
|
6148
|
+
// So we use the label (which is already a string) as fallback
|
|
6149
|
+
const getDisplayString = (rendered, fallbackLabel) => {
|
|
6150
|
+
if (typeof rendered === 'string')
|
|
6151
|
+
return rendered;
|
|
6152
|
+
if (typeof rendered === 'number')
|
|
6153
|
+
return String(rendered);
|
|
6154
|
+
// For ReactNode, use the fallback label (which is already a string representation)
|
|
6155
|
+
// The actual ReactNode will be rendered in the overlay, not in the input
|
|
6156
|
+
return fallbackLabel;
|
|
6157
|
+
};
|
|
6037
6158
|
const itemsFromDataList = dataList.map((item) => {
|
|
6038
6159
|
const rendered = renderFn(item);
|
|
6160
|
+
const label = typeof rendered === 'string' ? rendered : JSON.stringify(item); // Use string for filtering
|
|
6039
6161
|
return {
|
|
6040
|
-
label
|
|
6041
|
-
|
|
6162
|
+
label, // Use string for filtering
|
|
6163
|
+
displayLabel: getDisplayString(rendered, label), // String representation for input display
|
|
6164
|
+
value: itemToValueFn(item),
|
|
6042
6165
|
raw: item,
|
|
6043
6166
|
};
|
|
6044
6167
|
});
|
|
@@ -6047,25 +6170,28 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
|
6047
6170
|
const itemsFromIdMap = idMapItems
|
|
6048
6171
|
.map((item) => {
|
|
6049
6172
|
// Check if this item is already in itemsFromDataList
|
|
6050
|
-
const alreadyIncluded = itemsFromDataList.some((i) => i.value ===
|
|
6173
|
+
const alreadyIncluded = itemsFromDataList.some((i) => i.value === itemToValueFn(item));
|
|
6051
6174
|
if (alreadyIncluded)
|
|
6052
6175
|
return null;
|
|
6053
6176
|
const rendered = renderFn(item);
|
|
6177
|
+
const label = typeof rendered === 'string' ? rendered : JSON.stringify(item);
|
|
6054
6178
|
return {
|
|
6055
|
-
label
|
|
6056
|
-
|
|
6179
|
+
label,
|
|
6180
|
+
displayLabel: getDisplayString(rendered, label), // String representation for input display
|
|
6181
|
+
value: itemToValueFn(item),
|
|
6057
6182
|
raw: item,
|
|
6058
6183
|
};
|
|
6059
6184
|
})
|
|
6060
6185
|
.filter((item) => item !== null);
|
|
6061
6186
|
return [...itemsFromIdMap, ...itemsFromDataList];
|
|
6062
|
-
}, [dataList, column_ref, renderDisplay, idMapItems]);
|
|
6187
|
+
}, [dataList, column_ref, renderDisplay, idMapItems, itemToValueFn]);
|
|
6063
6188
|
// Use filter hook for combobox
|
|
6064
6189
|
const { contains } = useFilter({ sensitivity: 'base' });
|
|
6065
6190
|
// Create collection for combobox
|
|
6191
|
+
// itemToString uses displayLabel to show rendered display in input when selected
|
|
6066
6192
|
const { collection, filter, set } = useListCollection({
|
|
6067
6193
|
initialItems: comboboxItems,
|
|
6068
|
-
itemToString: (item) => item.
|
|
6194
|
+
itemToString: (item) => item.displayLabel, // Use displayLabel for selected value display
|
|
6069
6195
|
itemToValue: (item) => item.value,
|
|
6070
6196
|
filter: contains,
|
|
6071
6197
|
});
|
|
@@ -6120,6 +6246,8 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
|
6120
6246
|
idPickerLabels,
|
|
6121
6247
|
insideDialog: insideDialog ?? false,
|
|
6122
6248
|
renderDisplay,
|
|
6249
|
+
itemToValue: itemToValueFn,
|
|
6250
|
+
itemToString: itemToStringFn,
|
|
6123
6251
|
loadInitialValues: loadInitialValues ??
|
|
6124
6252
|
(async () => ({ data: { data: [], count: 0 }, idMap: {} })), // Fallback if not provided
|
|
6125
6253
|
column_ref,
|
|
@@ -6130,60 +6258,69 @@ const useIdPickerData = ({ column, schema, prefix, isMultiple, }) => {
|
|
|
6130
6258
|
|
|
6131
6259
|
const IdPickerSingle = ({ column, schema, prefix, }) => {
|
|
6132
6260
|
const formI18n = useFormI18n(column, prefix, schema);
|
|
6133
|
-
const { required, gridColumn = 'span 12', gridRow = 'span 1'
|
|
6261
|
+
const { required, gridColumn = 'span 12', gridRow = 'span 1' } = schema;
|
|
6134
6262
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
6135
|
-
const { colLabel, currentValue, searchText, setSearchText, isLoading, isFetching, isPending, isError, isSearching,
|
|
6263
|
+
const { colLabel, currentValue, searchText, setSearchText, isLoading, isFetching, isPending, isError, isSearching, collection, filter, idMap, idPickerLabels, insideDialog, renderDisplay: renderDisplayFn, itemToValue, itemToString, errors, setValue, } = useIdPickerData({
|
|
6136
6264
|
column,
|
|
6137
6265
|
schema,
|
|
6138
6266
|
prefix,
|
|
6139
6267
|
isMultiple: false,
|
|
6140
6268
|
});
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
const
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6269
|
+
// Get the selected value for single selection display
|
|
6270
|
+
const selectedId = currentValue.length > 0 ? currentValue[0] : null;
|
|
6271
|
+
const selectedItem = selectedId
|
|
6272
|
+
? idMap[selectedId]
|
|
6273
|
+
: undefined;
|
|
6274
|
+
// Use itemToValue to get the combobox value from the selected item, or use the ID directly
|
|
6275
|
+
const comboboxValue = selectedItem
|
|
6276
|
+
? itemToString(selectedItem)
|
|
6277
|
+
: selectedId || '';
|
|
6278
|
+
// itemToString is available from the hook and can be used to get a readable string
|
|
6279
|
+
// representation of any item. The collection's itemToString is automatically used
|
|
6280
|
+
// by the combobox to display selected values.
|
|
6281
|
+
// Use useCombobox hook to control input value
|
|
6282
|
+
const combobox = useCombobox({
|
|
6283
|
+
collection,
|
|
6284
|
+
value: [comboboxValue],
|
|
6285
|
+
onInputValueChange(e) {
|
|
6286
|
+
setSearchText(e.inputValue);
|
|
6287
|
+
filter(e.inputValue);
|
|
6288
|
+
},
|
|
6289
|
+
onValueChange(e) {
|
|
6290
|
+
setValue(colLabel, e.value[0] || '');
|
|
6291
|
+
// Clear the input value after selection
|
|
6292
|
+
setSearchText('');
|
|
6293
|
+
},
|
|
6294
|
+
multiple: false,
|
|
6295
|
+
closeOnSelect: true,
|
|
6296
|
+
openOnClick: true,
|
|
6297
|
+
invalid: !!errors[colLabel],
|
|
6298
|
+
});
|
|
6299
|
+
// Use renderDisplay from hook (which comes from schema) or fallback to default
|
|
6300
|
+
const renderDisplayFunction = renderDisplayFn || defaultRenderDisplay;
|
|
6301
|
+
// Get the selected value for single selection display (already computed above)
|
|
6302
|
+
const selectedRendered = selectedItem
|
|
6303
|
+
? renderDisplayFunction(selectedItem)
|
|
6304
|
+
: null;
|
|
6305
|
+
return (jsx(Field, { label: formI18n.label(), required: isRequired, alignItems: 'stretch', gridColumn,
|
|
6306
|
+
gridRow, errorText: errors[`${colLabel}`] ? formI18n.required() : undefined, invalid: !!errors[colLabel], children: jsxs(Combobox.RootProvider, { value: combobox, width: "100%", children: [jsx(Show, { when: selectedId && selectedRendered, children: jsxs(HStack, { justifyContent: 'space-between', children: [jsx(Box, { children: selectedRendered }), currentValue.length > 0 && (jsx(Button$1, { variant: "ghost", size: "sm", onClick: () => {
|
|
6307
|
+
setValue(colLabel, '');
|
|
6308
|
+
}, children: jsx(Icon, { children: jsx(BiX, {}) }) }))] }) }), jsx(Show, { when: !selectedId || !selectedRendered, children: jsxs(Combobox.Control, { position: "relative", children: [jsx(Combobox.Input, { placeholder: idPickerLabels?.typeToSearch ?? 'Type to search' }), jsxs(Combobox.IndicatorGroup, { children: [(isFetching || isLoading || isPending) && jsx(Spinner, { size: "xs" }), isError && (jsx(Icon, { color: "fg.error", children: jsx(BiError, {}) })), jsx(Combobox.Trigger, {})] })] }) }), insideDialog ? (jsx(Combobox.Positioner, { children: jsx(Combobox.Content, { children: isError ? (jsx(Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6309
|
+
// Show skeleton items to prevent UI shift
|
|
6310
|
+
jsx(Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsx(Flex, { p: 2, align: "center", gap: 2, children: jsx(Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsx(Combobox.Empty, { children: searchText
|
|
6311
|
+
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6312
|
+
: idPickerLabels?.initialResults ??
|
|
6313
|
+
'Start typing to search' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [renderDisplayFunction(item.raw), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) })) : (jsx(Portal, { children: jsx(Combobox.Positioner, { children: jsx(Combobox.Content, { children: isError ? (jsx(Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6168
6314
|
// Show skeleton items to prevent UI shift
|
|
6169
6315
|
jsx(Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsx(Flex, { p: 2, align: "center", gap: 2, children: jsx(Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsx(Combobox.Empty, { children: searchText
|
|
6170
6316
|
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6171
6317
|
: idPickerLabels?.initialResults ??
|
|
6172
|
-
'Start typing to search' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (
|
|
6173
|
-
? renderDisplayFunction(item.raw)
|
|
6174
|
-
: item.label }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) })) : (jsx(Portal, { children: jsx(Combobox.Positioner, { children: jsx(Combobox.Content, { children: isError ? (jsx(Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6175
|
-
// Show skeleton items to prevent UI shift
|
|
6176
|
-
jsx(Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsx(Flex, { p: 2, align: "center", gap: 2, children: jsx(Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsx(Combobox.Empty, { children: searchText
|
|
6177
|
-
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6178
|
-
: idPickerLabels?.initialResults ??
|
|
6179
|
-
'Start typing to search' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [jsx(Combobox.ItemText, { children: !!renderDisplayFunction === true
|
|
6180
|
-
? renderDisplayFunction(item.raw)
|
|
6181
|
-
: item.label }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) }) }))] })] }));
|
|
6318
|
+
'Start typing to search' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsx(Combobox.Item, { item: item, children: renderDisplayFunction(item.raw) }, item.value ?? `item-${index}`))) })) }) }) }))] }) }));
|
|
6182
6319
|
};
|
|
6183
6320
|
|
|
6184
6321
|
const IdPickerMultiple = ({ column, schema, prefix, }) => {
|
|
6185
6322
|
const formI18n = useFormI18n(column, prefix, schema);
|
|
6186
|
-
const { required, gridColumn = 'span 12', gridRow = 'span 1'
|
|
6323
|
+
const { required, gridColumn = 'span 12', gridRow = 'span 1' } = schema;
|
|
6187
6324
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
6188
6325
|
const { colLabel, currentValue, searchText, setSearchText, isLoading, isFetching, isPending, isError, isSearching, isLoadingInitialValues, isFetchingInitialValues, missingIds, collection, idMap, idPickerLabels, insideDialog, renderDisplay: renderDisplayFn, errors, setValue, } = useIdPickerData({
|
|
6189
6326
|
column,
|
|
@@ -6197,7 +6334,8 @@ const IdPickerMultiple = ({ column, schema, prefix, }) => {
|
|
|
6197
6334
|
const handleValueChange = (details) => {
|
|
6198
6335
|
setValue(colLabel, details.value);
|
|
6199
6336
|
};
|
|
6200
|
-
|
|
6337
|
+
// Use renderDisplay from hook (which comes from schema) or fallback to default
|
|
6338
|
+
const renderDisplayFunction = renderDisplayFn || defaultRenderDisplay;
|
|
6201
6339
|
return (jsxs(Field, { label: formI18n.label(), required: isRequired, alignItems: 'stretch', gridColumn,
|
|
6202
6340
|
gridRow, errorText: errors[`${colLabel}`] ? formI18n.required() : undefined, invalid: !!errors[colLabel], children: [currentValue.length > 0 && (jsx(Flex, { flexFlow: 'wrap', gap: 1, mb: 2, children: currentValue.map((id) => {
|
|
6203
6341
|
const item = idMap[id];
|
|
@@ -6222,16 +6360,12 @@ const IdPickerMultiple = ({ column, schema, prefix, }) => {
|
|
|
6222
6360
|
jsx(Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsx(Flex, { p: 2, align: "center", gap: 2, children: jsx(Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsx(Combobox.Empty, { children: searchText
|
|
6223
6361
|
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6224
6362
|
: idPickerLabels?.initialResults ??
|
|
6225
|
-
'Start typing to search' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [jsx(Combobox.
|
|
6226
|
-
? renderDisplayFunction(item.raw)
|
|
6227
|
-
: item.label }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) })) : (jsx(Portal, { children: jsx(Combobox.Positioner, { children: jsx(Combobox.Content, { children: isError ? (jsx(Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6363
|
+
'Start typing to search' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [renderDisplayFunction(item.raw), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) })) : (jsx(Portal, { children: jsx(Combobox.Positioner, { children: jsx(Combobox.Content, { children: isError ? (jsx(Text, { p: 2, color: "fg.error", fontSize: "sm", children: idPickerLabels?.emptySearchResult ?? 'Loading failed' })) : isFetching || isLoading || isPending || isSearching ? (
|
|
6228
6364
|
// Show skeleton items to prevent UI shift
|
|
6229
6365
|
jsx(Fragment, { children: Array.from({ length: 5 }).map((_, index) => (jsx(Flex, { p: 2, align: "center", gap: 2, children: jsx(Skeleton, { height: "20px", flex: "1" }) }, `skeleton-${index}`))) })) : collection.items.length === 0 ? (jsx(Combobox.Empty, { children: searchText
|
|
6230
6366
|
? idPickerLabels?.emptySearchResult ?? 'No results found'
|
|
6231
6367
|
: idPickerLabels?.initialResults ??
|
|
6232
|
-
'Start typing to search' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [jsx(Combobox.
|
|
6233
|
-
? renderDisplayFunction(item.raw)
|
|
6234
|
-
: item.label }), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) }) }))] })] }));
|
|
6368
|
+
'Start typing to search' })) : (jsx(Fragment, { children: collection.items.map((item, index) => (jsxs(Combobox.Item, { item: item, children: [renderDisplayFunction(item.raw), jsx(Combobox.ItemIndicator, {})] }, item.value ?? `item-${index}`))) })) }) }) }))] })] }));
|
|
6235
6369
|
};
|
|
6236
6370
|
|
|
6237
6371
|
const NumberInputRoot = React.forwardRef(function NumberInput$1(props, ref) {
|
|
@@ -7368,7 +7502,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7368
7502
|
backButtonLabel: 'Back',
|
|
7369
7503
|
forwardButtonLabel: 'Next',
|
|
7370
7504
|
}, timePickerLabels, timezone = 'Asia/Hong_Kong', startTime, minDate, maxDate, portalled = false, defaultDate, defaultTime, }) {
|
|
7371
|
-
console.
|
|
7505
|
+
console.debug('[DateTimePicker] Component initialized with props:', {
|
|
7372
7506
|
value,
|
|
7373
7507
|
format,
|
|
7374
7508
|
showSeconds,
|
|
@@ -7387,13 +7521,13 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7387
7521
|
const [selectedDate, setSelectedDate] = useState(getDateString(value));
|
|
7388
7522
|
// Helper to get time values from value prop with timezone
|
|
7389
7523
|
const getTimeFromValue = useCallback((val) => {
|
|
7390
|
-
console.
|
|
7524
|
+
console.debug('[DateTimePicker] getTimeFromValue called:', {
|
|
7391
7525
|
val,
|
|
7392
7526
|
timezone,
|
|
7393
7527
|
showSeconds,
|
|
7394
7528
|
});
|
|
7395
7529
|
if (!val) {
|
|
7396
|
-
console.
|
|
7530
|
+
console.debug('[DateTimePicker] No value provided, returning nulls');
|
|
7397
7531
|
return {
|
|
7398
7532
|
hour12: null,
|
|
7399
7533
|
minute: null,
|
|
@@ -7403,7 +7537,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7403
7537
|
};
|
|
7404
7538
|
}
|
|
7405
7539
|
const dateObj = dayjs(val).tz(timezone);
|
|
7406
|
-
console.
|
|
7540
|
+
console.debug('[DateTimePicker] Parsed date object:', {
|
|
7407
7541
|
original: val,
|
|
7408
7542
|
timezone,
|
|
7409
7543
|
isValid: dateObj.isValid(),
|
|
@@ -7413,7 +7547,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7413
7547
|
second: dateObj.second(),
|
|
7414
7548
|
});
|
|
7415
7549
|
if (!dateObj.isValid()) {
|
|
7416
|
-
console.
|
|
7550
|
+
console.debug('[DateTimePicker] Invalid date object, returning nulls');
|
|
7417
7551
|
return {
|
|
7418
7552
|
hour12: null,
|
|
7419
7553
|
minute: null,
|
|
@@ -7434,11 +7568,11 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7434
7568
|
hour24: hour24Value,
|
|
7435
7569
|
second: secondValue,
|
|
7436
7570
|
};
|
|
7437
|
-
console.
|
|
7571
|
+
console.debug('[DateTimePicker] Extracted time values:', result);
|
|
7438
7572
|
return result;
|
|
7439
7573
|
}, [timezone, showSeconds]);
|
|
7440
7574
|
const initialTime = getTimeFromValue(value);
|
|
7441
|
-
console.
|
|
7575
|
+
console.debug('[DateTimePicker] Initial time from value:', {
|
|
7442
7576
|
value,
|
|
7443
7577
|
initialTime,
|
|
7444
7578
|
});
|
|
@@ -7515,14 +7649,14 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7515
7649
|
const [second, setSecond] = useState(initialTimeValues.second);
|
|
7516
7650
|
// Sync selectedDate and time states when value prop changes
|
|
7517
7651
|
useEffect(() => {
|
|
7518
|
-
console.
|
|
7652
|
+
console.debug('[DateTimePicker] useEffect triggered - value changed:', {
|
|
7519
7653
|
value,
|
|
7520
7654
|
timezone,
|
|
7521
7655
|
format,
|
|
7522
7656
|
});
|
|
7523
7657
|
// If value is null, undefined, or invalid, clear date but keep default time values
|
|
7524
7658
|
if (!value || value === null || value === undefined) {
|
|
7525
|
-
console.
|
|
7659
|
+
console.debug('[DateTimePicker] Value is null/undefined, clearing date but keeping default time');
|
|
7526
7660
|
setSelectedDate('');
|
|
7527
7661
|
// Keep default time values instead of clearing them
|
|
7528
7662
|
if (format === 'iso-date-time') {
|
|
@@ -7544,7 +7678,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7544
7678
|
// Check if value is valid
|
|
7545
7679
|
const dateObj = dayjs(value).tz(timezone);
|
|
7546
7680
|
if (!dateObj.isValid()) {
|
|
7547
|
-
console.
|
|
7681
|
+
console.debug('[DateTimePicker] Invalid value, clearing date but keeping default time');
|
|
7548
7682
|
setSelectedDate('');
|
|
7549
7683
|
// Keep default time values instead of clearing them
|
|
7550
7684
|
if (format === 'iso-date-time') {
|
|
@@ -7564,10 +7698,10 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7564
7698
|
return;
|
|
7565
7699
|
}
|
|
7566
7700
|
const dateString = getDateString(value);
|
|
7567
|
-
console.
|
|
7701
|
+
console.debug('[DateTimePicker] Setting selectedDate:', dateString);
|
|
7568
7702
|
setSelectedDate(dateString);
|
|
7569
7703
|
const timeData = getTimeFromValue(value);
|
|
7570
|
-
console.
|
|
7704
|
+
console.debug('[DateTimePicker] Updating time states:', {
|
|
7571
7705
|
timeData,
|
|
7572
7706
|
});
|
|
7573
7707
|
setHour12(timeData.hour12);
|
|
@@ -7577,7 +7711,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7577
7711
|
setSecond(timeData.second);
|
|
7578
7712
|
}, [value, getTimeFromValue, getDateString, timezone]);
|
|
7579
7713
|
const handleDateChange = (date) => {
|
|
7580
|
-
console.
|
|
7714
|
+
console.debug('[DateTimePicker] handleDateChange called:', {
|
|
7581
7715
|
date,
|
|
7582
7716
|
timezone,
|
|
7583
7717
|
showSeconds,
|
|
@@ -7585,7 +7719,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7585
7719
|
});
|
|
7586
7720
|
// If date is empty or invalid, clear all fields
|
|
7587
7721
|
if (!date || date === '') {
|
|
7588
|
-
console.
|
|
7722
|
+
console.debug('[DateTimePicker] Empty date, clearing all fields');
|
|
7589
7723
|
setSelectedDate('');
|
|
7590
7724
|
setHour12(null);
|
|
7591
7725
|
setMinute(null);
|
|
@@ -7598,7 +7732,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7598
7732
|
setSelectedDate(date);
|
|
7599
7733
|
// Parse the date string (YYYY-MM-DD) in the specified timezone
|
|
7600
7734
|
const dateObj = dayjs.tz(date, timezone);
|
|
7601
|
-
console.
|
|
7735
|
+
console.debug('[DateTimePicker] Parsed date object:', {
|
|
7602
7736
|
date,
|
|
7603
7737
|
timezone,
|
|
7604
7738
|
isValid: dateObj.isValid(),
|
|
@@ -7624,7 +7758,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7624
7758
|
if (!hasTimeValues) {
|
|
7625
7759
|
// Use defaultTime if provided, otherwise default to 00:00
|
|
7626
7760
|
if (defaultTime) {
|
|
7627
|
-
console.
|
|
7761
|
+
console.debug('[DateTimePicker] No time values set, using defaultTime');
|
|
7628
7762
|
if (format === 'iso-date-time') {
|
|
7629
7763
|
const defaultTime24 = defaultTime;
|
|
7630
7764
|
setHour24(defaultTime24.hour ?? 0);
|
|
@@ -7651,7 +7785,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7651
7785
|
}
|
|
7652
7786
|
}
|
|
7653
7787
|
else {
|
|
7654
|
-
console.
|
|
7788
|
+
console.debug('[DateTimePicker] No time values set, defaulting to 00:00');
|
|
7655
7789
|
if (format === 'iso-date-time') {
|
|
7656
7790
|
setHour24(0);
|
|
7657
7791
|
setMinute(0);
|
|
@@ -7679,17 +7813,17 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7679
7813
|
// When showSeconds is false, ignore seconds from the date
|
|
7680
7814
|
if (!showSeconds) {
|
|
7681
7815
|
const dateWithoutSeconds = dateObj.second(0).millisecond(0).toISOString();
|
|
7682
|
-
console.
|
|
7816
|
+
console.debug('[DateTimePicker] Updating date without seconds:', dateWithoutSeconds);
|
|
7683
7817
|
updateDateTime(dateWithoutSeconds, timeDataToUse);
|
|
7684
7818
|
}
|
|
7685
7819
|
else {
|
|
7686
7820
|
const dateWithSeconds = dateObj.toISOString();
|
|
7687
|
-
console.
|
|
7821
|
+
console.debug('[DateTimePicker] Updating date with seconds:', dateWithSeconds);
|
|
7688
7822
|
updateDateTime(dateWithSeconds, timeDataToUse);
|
|
7689
7823
|
}
|
|
7690
7824
|
};
|
|
7691
7825
|
const handleTimeChange = (timeData) => {
|
|
7692
|
-
console.
|
|
7826
|
+
console.debug('[DateTimePicker] handleTimeChange called:', {
|
|
7693
7827
|
timeData,
|
|
7694
7828
|
format,
|
|
7695
7829
|
selectedDate,
|
|
@@ -7697,7 +7831,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7697
7831
|
});
|
|
7698
7832
|
if (format === 'iso-date-time') {
|
|
7699
7833
|
const data = timeData;
|
|
7700
|
-
console.
|
|
7834
|
+
console.debug('[DateTimePicker] ISO format - setting 24-hour time:', data);
|
|
7701
7835
|
setHour24(data.hour);
|
|
7702
7836
|
setMinute(data.minute);
|
|
7703
7837
|
if (showSeconds) {
|
|
@@ -7710,7 +7844,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7710
7844
|
}
|
|
7711
7845
|
else {
|
|
7712
7846
|
const data = timeData;
|
|
7713
|
-
console.
|
|
7847
|
+
console.debug('[DateTimePicker] 12-hour format - setting time:', data);
|
|
7714
7848
|
setHour12(data.hour);
|
|
7715
7849
|
setMinute(data.minute);
|
|
7716
7850
|
setMeridiem(data.meridiem);
|
|
@@ -7719,7 +7853,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7719
7853
|
if (!selectedDate || !dayjs(selectedDate).isValid()) {
|
|
7720
7854
|
// If effectiveDefaultDate is available, use it instead of clearing
|
|
7721
7855
|
if (effectiveDefaultDate && dayjs(effectiveDefaultDate).isValid()) {
|
|
7722
|
-
console.
|
|
7856
|
+
console.debug('[DateTimePicker] No valid selectedDate, using effectiveDefaultDate:', effectiveDefaultDate);
|
|
7723
7857
|
setSelectedDate(effectiveDefaultDate);
|
|
7724
7858
|
const dateObj = dayjs(effectiveDefaultDate).tz(timezone);
|
|
7725
7859
|
if (dateObj.isValid()) {
|
|
@@ -7738,7 +7872,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7738
7872
|
return;
|
|
7739
7873
|
}
|
|
7740
7874
|
else {
|
|
7741
|
-
console.
|
|
7875
|
+
console.debug('[DateTimePicker] No valid selectedDate and no effectiveDefaultDate, keeping time values but no date');
|
|
7742
7876
|
// Keep the time values that were just set, but don't set a date
|
|
7743
7877
|
// This should rarely happen as effectiveDefaultDate always defaults to today
|
|
7744
7878
|
setSelectedDate('');
|
|
@@ -7762,14 +7896,14 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7762
7896
|
}
|
|
7763
7897
|
};
|
|
7764
7898
|
const updateDateTime = (date, timeData) => {
|
|
7765
|
-
console.
|
|
7899
|
+
console.debug('[DateTimePicker] updateDateTime called:', {
|
|
7766
7900
|
date,
|
|
7767
7901
|
timeData,
|
|
7768
7902
|
format,
|
|
7769
7903
|
currentStates: { hour12, minute, meridiem, hour24, second },
|
|
7770
7904
|
});
|
|
7771
7905
|
if (!date || date === null || date === undefined) {
|
|
7772
|
-
console.
|
|
7906
|
+
console.debug('[DateTimePicker] No date provided, clearing all fields and calling onChange(undefined)');
|
|
7773
7907
|
setSelectedDate('');
|
|
7774
7908
|
setHour12(null);
|
|
7775
7909
|
setMinute(null);
|
|
@@ -7807,11 +7941,11 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7807
7941
|
: 0;
|
|
7808
7942
|
// If all time values are null, clear the value
|
|
7809
7943
|
if (h === null && m === null && (showSeconds ? s === null : true)) {
|
|
7810
|
-
console.
|
|
7944
|
+
console.debug('[DateTimePicker] All time values are null, clearing value');
|
|
7811
7945
|
onChange?.(undefined);
|
|
7812
7946
|
return;
|
|
7813
7947
|
}
|
|
7814
|
-
console.
|
|
7948
|
+
console.debug('[DateTimePicker] ISO format - setting time on date:', {
|
|
7815
7949
|
h,
|
|
7816
7950
|
m,
|
|
7817
7951
|
s,
|
|
@@ -7825,7 +7959,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7825
7959
|
}
|
|
7826
7960
|
else {
|
|
7827
7961
|
const data = timeData;
|
|
7828
|
-
console.
|
|
7962
|
+
console.debug('[DateTimePicker] Processing 12-hour format:', {
|
|
7829
7963
|
'data !== undefined': data !== undefined,
|
|
7830
7964
|
'data?.hour': data?.hour,
|
|
7831
7965
|
'data?.minute': data?.minute,
|
|
@@ -7838,14 +7972,14 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7838
7972
|
const h = data !== undefined ? data.hour : hour12;
|
|
7839
7973
|
const m = data !== undefined ? data.minute : minute;
|
|
7840
7974
|
const mer = data !== undefined ? data.meridiem : meridiem;
|
|
7841
|
-
console.
|
|
7975
|
+
console.debug('[DateTimePicker] Resolved time values:', { h, m, mer });
|
|
7842
7976
|
// If all time values are null, clear the value
|
|
7843
7977
|
if (h === null && m === null && mer === null) {
|
|
7844
|
-
console.
|
|
7978
|
+
console.debug('[DateTimePicker] All time values are null, clearing value');
|
|
7845
7979
|
onChange?.(undefined);
|
|
7846
7980
|
return;
|
|
7847
7981
|
}
|
|
7848
|
-
console.
|
|
7982
|
+
console.debug('[DateTimePicker] 12-hour format - converting time:', {
|
|
7849
7983
|
h,
|
|
7850
7984
|
m,
|
|
7851
7985
|
mer,
|
|
@@ -7856,7 +7990,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7856
7990
|
hour24 = 0;
|
|
7857
7991
|
else if (mer === 'pm' && h < 12)
|
|
7858
7992
|
hour24 = h + 12;
|
|
7859
|
-
console.
|
|
7993
|
+
console.debug('[DateTimePicker] Converted to 24-hour:', {
|
|
7860
7994
|
h,
|
|
7861
7995
|
mer,
|
|
7862
7996
|
hour24,
|
|
@@ -7864,7 +7998,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7864
7998
|
newDate.setHours(hour24);
|
|
7865
7999
|
}
|
|
7866
8000
|
else {
|
|
7867
|
-
console.
|
|
8001
|
+
console.debug('[DateTimePicker] Skipping hour update - h or mer is null:', {
|
|
7868
8002
|
h,
|
|
7869
8003
|
mer,
|
|
7870
8004
|
});
|
|
@@ -7873,12 +8007,12 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7873
8007
|
newDate.setMinutes(m);
|
|
7874
8008
|
}
|
|
7875
8009
|
else {
|
|
7876
|
-
console.
|
|
8010
|
+
console.debug('[DateTimePicker] Skipping minute update - m is null');
|
|
7877
8011
|
}
|
|
7878
8012
|
newDate.setSeconds(0);
|
|
7879
8013
|
}
|
|
7880
8014
|
const finalISO = dayjs(newDate).tz(timezone).toISOString();
|
|
7881
|
-
console.
|
|
8015
|
+
console.debug('[DateTimePicker] Final ISO string to emit:', {
|
|
7882
8016
|
newDate: newDate.toISOString(),
|
|
7883
8017
|
timezone,
|
|
7884
8018
|
finalISO,
|
|
@@ -7913,7 +8047,7 @@ function DateTimePicker$1({ value, onChange, format = 'date-time', showSeconds =
|
|
|
7913
8047
|
: undefined;
|
|
7914
8048
|
// Log current state before render
|
|
7915
8049
|
useEffect(() => {
|
|
7916
|
-
console.
|
|
8050
|
+
console.debug('[DateTimePicker] Current state before render:', {
|
|
7917
8051
|
isISO,
|
|
7918
8052
|
hour12,
|
|
7919
8053
|
minute,
|