Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: filter relative #1169

Merged
merged 2 commits into from
Dec 17, 2024
Merged
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 @@ -6,6 +6,9 @@ import { DEFAULT_LINK_VALUE_INDEXS } from '../../../20x-link';
export const getDates = () => {
const tz = 'Asia/Singapore';
const dateFieldName = x_20.fields[3].name;
dayjs.locale(dayjs.locale(), {
weekStart: 1,
});
const dates = x_20.records
.filter((r) => r.fields?.[dateFieldName])
.map((r) => {
Expand Down
19 changes: 15 additions & 4 deletions packages/sdk/src/components/editor/number/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ import type { ICellEditor, IEditorRef } from '../type';

export const NumberEditorBase: ForwardRefRenderFunction<
IEditorRef<number>,
ICellEditor<number | null> & { placeholder?: string }
ICellEditor<number | null> & { placeholder?: string; saveOnChange?: boolean }
> = (props, ref) => {
const { value, onChange, className, readonly, style, saveOnBlur = true, placeholder } = props;
const {
value,
onChange,
className,
readonly,
style,
saveOnBlur = true,
saveOnChange = false,
placeholder,
} = props;
const inputRef = useRef<HTMLInputElement | null>(null);
const [str, setStr] = useState<string | null>(value ? value.toString() : '');

Expand All @@ -27,7 +36,9 @@ export const NumberEditorBase: ForwardRefRenderFunction<
};

const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>) => {
setStr(e.target.value);
const newValue = e.target.value;
setStr(newValue);
saveOnChange && onChange?.(parseStringToNumber(newValue));
};

return (
Expand All @@ -37,7 +48,7 @@ export const NumberEditorBase: ForwardRefRenderFunction<
className={cn('h-10 sm:h-8', className)}
value={str || ''}
onChange={onChangeHandler}
onBlur={() => saveOnBlur && saveValue()}
onBlur={() => saveOnBlur && !saveOnChange && saveValue()}
readOnly={readonly}
placeholder={placeholder}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function FilterDatePicker(props: IFilerDatePickerProps) {
<Input
placeholder={t('filter.default.placeholder')}
defaultValue={innerValue?.numberOfDays ?? ''}
className="h-8 w-24 placeholder:text-[13px]"
className="h-8 w-24 placeholder:text-xs"
onInput={(e) => {
// limit the number positive
e.currentTarget.value = e.currentTarget.value?.replace(/\D/g, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function BaseFieldValue(props: IBaseFieldValue) {
return (
<NumberEditor
value={value as number}
saveOnChange={true}
onChange={onSelect as (value?: number | null) => void}
className="min-w-28 max-w-40 placeholder:text-xs"
placeholder={t('filter.default.placeholder')}
Expand All @@ -84,6 +85,7 @@ export function BaseFieldValue(props: IBaseFieldValue) {
return (
<NumberEditor
value={value as number}
saveOnChange={true}
onChange={onSelect as (value?: number | null) => void}
className="min-w-28 max-w-40 placeholder:text-xs"
placeholder={t('filter.default.placeholder')}
Expand Down
Loading