Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ export const getMobileStyle = (style: DateTimeStyleType) =>

export const dateRefMethods = refMethods<CommonPickerMethods>([focusMethod, blurMethod]);

export const parseInputFormats = (inputFormat?: string): string | string[] =>
inputFormat?.includes(',') ? inputFormat.split(',').map(f => f.trim()) : inputFormat || '';

export const StyledPickerPanel = styled.div<{
$style: ChildrenMultiSelectStyleType
}>`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dayjs from "dayjs";
import type { DateCompViewProps } from "./dateComp";
import { disabledDate, getStyle, StyledPickerPanel } from "comps/comps/dateComp/dateCompUtil";
import { disabledDate, getStyle, StyledPickerPanel, parseInputFormats } from "comps/comps/dateComp/dateCompUtil";
import { useUIView } from "../../utils/useUIView";
import { checkIsMobile } from "util/commonUtils";
import React, { useContext } from "react";
Expand Down Expand Up @@ -68,20 +68,15 @@ export interface DateRangeUIViewProps extends DateCompViewProps {

export const DateRangeUIView = (props: DateRangeUIViewProps) => {
const editorState = useContext(EditorContext);
const placeholders: [string, string] = Array.isArray(props.placeholder)
? props.placeholder
: [props.placeholder || 'Start Date', props.placeholder || 'End Date'];

// Extract or compute the placeholder values
let placeholders: [string, string];
if (Array.isArray(props.placeholder)) {
placeholders = props.placeholder;
} else {
// Use the same placeholder for both start and end if it's a single string
placeholders = [props.placeholder || 'Start Date', props.placeholder || 'End Date'];
}
return useUIView(
<DateRangeMobileUIView {...props} />,
<RangePickerStyled
{...omit(props, "onChange" , "format", "inputFormat", "pickerMode", "$childrenInputFieldStyle")}
format={props.inputFormat}
format={parseInputFormats(props.inputFormat)}
ref={props.viewRef as any}
picker={props.pickerMode as any}
value={[props.start, props.end]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dayjs from "dayjs";
import type { DateCompViewProps } from "./dateComp";
import { disabledDate, getStyle, StyledPickerPanel } from "comps/comps/dateComp/dateCompUtil";
import { disabledDate, getStyle, StyledPickerPanel, parseInputFormats } from "comps/comps/dateComp/dateCompUtil";
import { useUIView } from "../../utils/useUIView";
import { checkIsMobile } from "util/commonUtils";
import React, { useContext } from "react";
Expand Down Expand Up @@ -67,15 +67,15 @@ const DateMobileUIView = React.lazy(() =>

export const DateUIView = (props: DataUIViewProps) => {
const editorState = useContext(EditorContext);

const placeholder = Array.isArray(props.placeholder) ? props.placeholder[0] : props.placeholder;

return useUIView(
<DateMobileUIView {...props} />,
<DatePickerStyled
{...omit(props, "format", "inputFormat", "pickerMode", "$childrenInputFieldStyle")}
$disabledStyle={props.$disabledStyle}
multiple={false}
format={props.inputFormat}
format={parseInputFormats(props.inputFormat)}
ref={props.viewRef as any}
minDate={props.minDate ? dayjs(props.minDate, DateParser) : undefined}
maxDate={props.maxDate ? dayjs(props.maxDate, DateParser) : undefined}
Expand Down
2 changes: 1 addition & 1 deletion client/packages/lowcoder/src/comps/utils/propertyUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const formatPropertyView = (params: {
placeholder: params.placeholder,
tooltip: (
<>
{trans("date.reference")} &nbsp;
{trans("date.inputFormatTip")} &nbsp;
<a
href={`${
language === "zh" ? "https://day.js.org/docs/zh-CN" : "https://day.js.org/docs/en"
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,7 @@ export const en = {
"format": "Format",
"inputFormat": "Input Format",
"formatTip": "Support: 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD', 'Timestamp'",
"inputFormatTip": "Supports multiple formats separated by commas (e.g., 'MM/DD/YYYY, MMDDYYYY, YYYY-MM-DD'). First format is used for display. See",
"reference": "Please Refer to",
"showTime": "Show Time",
"start": "Start Date",
Expand Down
Loading