@pallasoft/ps-input-components 1.18.1 → 1.18.2
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/components/ps-calendar-header.d.ts +3 -1
- package/dist/components/ps-calendar-header.js +8 -4
- package/dist/components/ps-year-input.js +10 -1
- package/dist/constants/ps-year-input-config.d.ts +0 -1
- package/dist/constants/ps-year-input-config.js +0 -1
- package/dist/esm/components/ps-calendar-header.js +8 -4
- package/dist/esm/components/ps-year-input.js +11 -2
- package/dist/esm/constants/ps-year-input-config.js +0 -1
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ export interface PsCalendarHeaderProps extends ReactDatePickerCustomHeaderProps
|
|
|
4
4
|
maxDate?: Date;
|
|
5
5
|
minDate?: Date;
|
|
6
6
|
onViewChange: (view: PsCalendarView) => void;
|
|
7
|
+
onYearPick?: (year: number) => void;
|
|
8
|
+
selectedYear?: number;
|
|
7
9
|
view: PsCalendarView;
|
|
8
10
|
}
|
|
9
|
-
export declare const PsCalendarHeader: ({ changeMonth, changeYear, decreaseMonth, increaseMonth, maxDate, minDate, monthDate, nextMonthButtonDisabled, onViewChange, prevMonthButtonDisabled, view, }: PsCalendarHeaderProps) => import("react").JSX.Element;
|
|
11
|
+
export declare const PsCalendarHeader: ({ changeMonth, changeYear, decreaseMonth, increaseMonth, maxDate, minDate, monthDate, nextMonthButtonDisabled, onViewChange, onYearPick, prevMonthButtonDisabled, selectedYear, view, }: PsCalendarHeaderProps) => import("react").JSX.Element;
|
|
@@ -12,8 +12,8 @@ const navigationButtonClassName = 'ps-focus-ring flex h-8 w-8 items-center justi
|
|
|
12
12
|
const titleButtonClassName = 'ps-focus-ring flex items-center gap-1 rounded-lg px-2 py-1 text-sm font-semibold text-ink transition-colors hover:bg-primary/10';
|
|
13
13
|
const cellClassName = 'ps-focus-ring flex h-10 items-center justify-center rounded-[0.625rem] text-sm font-medium text-ink transition-colors hover:bg-primary/10 disabled:cursor-not-allowed disabled:opacity-35 disabled:hover:bg-transparent';
|
|
14
14
|
const selectedCellClassName = 'bg-primary font-bold text-[var(--ps-color-primary-contrast)] hover:bg-primary';
|
|
15
|
-
const PsCalendarHeader = ({ changeMonth, changeYear, decreaseMonth, increaseMonth, maxDate, minDate, monthDate, nextMonthButtonDisabled, onViewChange, prevMonthButtonDisabled, view, }) => {
|
|
16
|
-
const year = monthDate.getFullYear();
|
|
15
|
+
const PsCalendarHeader = ({ changeMonth, changeYear, decreaseMonth, increaseMonth, maxDate, minDate, monthDate, nextMonthButtonDisabled, onViewChange, onYearPick, prevMonthButtonDisabled, selectedYear, view, }) => {
|
|
16
|
+
const year = selectedYear === undefined ? monthDate.getFullYear() : selectedYear;
|
|
17
17
|
const [pageYear, setPageYear] = (0, react_1.useState)(year);
|
|
18
18
|
const years = ps_date_input_service_1.PsDateInputService.yearPage(pageYear);
|
|
19
19
|
const navigation = {
|
|
@@ -51,13 +51,17 @@ const PsCalendarHeader = ({ changeMonth, changeYear, decreaseMonth, increaseMont
|
|
|
51
51
|
titleView: ps_calendar_view_1.PsCalendarView.day,
|
|
52
52
|
},
|
|
53
53
|
}[view];
|
|
54
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: 'flex flex-col gap-2', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'flex items-center justify-between gap-2 px-1', children: [(0, jsx_runtime_1.jsx)("button", { "aria-label": navigation.previousLabel, className: navigationButtonClassName, disabled: navigation.isPreviousDisabled, onClick: navigation.previous, type: 'button', children: (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 rotate-180', iconKey: ps_icons_1.PsIconKey.ChevronRight }) }), (0, jsx_runtime_1.jsxs)("button", { "aria-label": navigation.titleLabel, "aria-live": 'polite', className: titleButtonClassName, onClick: () => {
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: 'flex flex-col gap-2', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'flex items-center justify-between gap-2 px-1', children: [(0, jsx_runtime_1.jsx)("button", { "aria-label": navigation.previousLabel, className: navigationButtonClassName, disabled: navigation.isPreviousDisabled, onClick: navigation.previous, type: 'button', children: (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 rotate-180', iconKey: ps_icons_1.PsIconKey.ChevronRight }) }), onYearPick === undefined ? ((0, jsx_runtime_1.jsxs)("button", { "aria-label": navigation.titleLabel, "aria-live": 'polite', className: titleButtonClassName, onClick: () => {
|
|
55
55
|
setPageYear(year);
|
|
56
56
|
onViewChange(navigation.titleView);
|
|
57
|
-
}, type: 'button', children: [navigation.title, (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-3.5 w-3.5 rotate-90 text-ink/50', iconKey: ps_icons_1.PsIconKey.ChevronRight })] }), (0, jsx_runtime_1.jsx)("button", { "aria-label": navigation.nextLabel, className: navigationButtonClassName, disabled: navigation.isNextDisabled, onClick: navigation.next, type: 'button', children: (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4', iconKey: ps_icons_1.PsIconKey.ChevronRight }) })] }), view === ps_calendar_view_1.PsCalendarView.month ? ((0, jsx_runtime_1.jsx)("div", { className: 'grid grid-cols-3 gap-1', children: ps_date_input_service_1.PsDateInputService.monthNames().map((name, month) => ((0, jsx_runtime_1.jsx)("button", { className: ps_design_system_1.PallasoftClassNameService.merge(cellClassName, month === monthDate.getMonth() ? selectedCellClassName : undefined), disabled: ps_date_input_service_1.PsDateInputService.isMonthOutOfRange(year, month, minDate, maxDate), onClick: () => {
|
|
57
|
+
}, type: 'button', children: [navigation.title, (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-3.5 w-3.5 rotate-90 text-ink/50', iconKey: ps_icons_1.PsIconKey.ChevronRight })] })) : ((0, jsx_runtime_1.jsx)("p", { "aria-live": 'polite', className: 'text-sm font-semibold text-ink', children: navigation.title })), (0, jsx_runtime_1.jsx)("button", { "aria-label": navigation.nextLabel, className: navigationButtonClassName, disabled: navigation.isNextDisabled, onClick: navigation.next, type: 'button', children: (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4', iconKey: ps_icons_1.PsIconKey.ChevronRight }) })] }), view === ps_calendar_view_1.PsCalendarView.month ? ((0, jsx_runtime_1.jsx)("div", { className: 'grid grid-cols-3 gap-1', children: ps_date_input_service_1.PsDateInputService.monthNames().map((name, month) => ((0, jsx_runtime_1.jsx)("button", { className: ps_design_system_1.PallasoftClassNameService.merge(cellClassName, month === monthDate.getMonth() ? selectedCellClassName : undefined), disabled: ps_date_input_service_1.PsDateInputService.isMonthOutOfRange(year, month, minDate, maxDate), onClick: () => {
|
|
58
58
|
changeMonth(month);
|
|
59
59
|
onViewChange(ps_calendar_view_1.PsCalendarView.day);
|
|
60
60
|
}, type: 'button', children: name }, name))) })) : null, view === ps_calendar_view_1.PsCalendarView.year ? ((0, jsx_runtime_1.jsx)("div", { className: 'grid grid-cols-3 gap-1', children: years.map((candidate) => ((0, jsx_runtime_1.jsx)("button", { className: ps_design_system_1.PallasoftClassNameService.merge(cellClassName, candidate === year ? selectedCellClassName : undefined), disabled: ps_date_input_service_1.PsDateInputService.isYearOutOfRange(candidate, minDate, maxDate), onClick: () => {
|
|
61
|
+
if (onYearPick !== undefined) {
|
|
62
|
+
onYearPick(candidate);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
61
65
|
changeYear(candidate);
|
|
62
66
|
onViewChange(ps_calendar_view_1.PsCalendarView.month);
|
|
63
67
|
}, type: 'button', children: candidate }, candidate))) })) : null] }));
|
|
@@ -10,9 +10,11 @@ const ps_core_components_1 = require("@pallasoft/ps-core-components");
|
|
|
10
10
|
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
11
11
|
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
12
12
|
const react_datepicker_1 = __importDefault(require("react-datepicker"));
|
|
13
|
+
const ps_calendar_view_1 = require("../constants/ps-calendar-view");
|
|
13
14
|
const ps_date_input_config_1 = require("../constants/ps-date-input-config");
|
|
14
15
|
const ps_year_input_config_1 = require("../constants/ps-year-input-config");
|
|
15
16
|
const ps_year_input_service_1 = require("../services/ps-year-input-service");
|
|
17
|
+
const ps_calendar_header_1 = require("./ps-calendar-header");
|
|
16
18
|
const ps_field_skeleton_1 = require("./ps-field-skeleton");
|
|
17
19
|
const ps_required_mark_1 = require("./ps-required-mark");
|
|
18
20
|
const PsYearInput = ({ className, defaultValue, disabled, helperText, hideLabel, isLoading = false, label, maxYear, minYear, name, onChange, placeholder = ps_year_input_config_1.PsYearInputConfig.placeholder, required, value, }) => {
|
|
@@ -23,6 +25,10 @@ const PsYearInput = ({ className, defaultValue, disabled, helperText, hideLabel,
|
|
|
23
25
|
const zIndex = (0, ps_core_components_1.usePsLayerZIndex)(ps_design_system_1.PallasoftZIndex.Dropdown);
|
|
24
26
|
const [uncontrolledValue, setUncontrolledValue] = (0, react_1.useState)(defaultValue === undefined ? '' : defaultValue);
|
|
25
27
|
const currentValue = value === undefined ? uncontrolledValue : value;
|
|
28
|
+
const pickerRef = (0, react_1.useRef)(null);
|
|
29
|
+
const selected = ps_year_input_service_1.PsYearInputService.parse(currentValue);
|
|
30
|
+
const minDate = ps_year_input_service_1.PsYearInputService.bound(minYear);
|
|
31
|
+
const maxDate = ps_year_input_service_1.PsYearInputService.bound(maxYear);
|
|
26
32
|
(0, react_1.useEffect)(() => {
|
|
27
33
|
const existing = document.getElementById(portalId);
|
|
28
34
|
const container = existing ? existing : document.createElement('div');
|
|
@@ -40,6 +46,9 @@ const PsYearInput = ({ className, defaultValue, disabled, helperText, hideLabel,
|
|
|
40
46
|
setUncontrolledValue(nextValue);
|
|
41
47
|
onChange?.(nextValue);
|
|
42
48
|
};
|
|
43
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), children: [(0, jsx_runtime_1.jsxs)("label", { className: hideLabel ? 'sr-only' : 'ps-input-label block', htmlFor: inputId, children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] }), (0, jsx_runtime_1.jsxs)("div", { className: hideLabel ? 'relative' : 'relative mt-2', children: [(0, jsx_runtime_1.jsx)(react_datepicker_1.default, { autoComplete: 'off', calendarClassName:
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), children: [(0, jsx_runtime_1.jsxs)("label", { className: hideLabel ? 'sr-only' : 'ps-input-label block', htmlFor: inputId, children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] }), (0, jsx_runtime_1.jsxs)("div", { className: hideLabel ? 'relative' : 'relative mt-2', children: [(0, jsx_runtime_1.jsx)(react_datepicker_1.default, { autoComplete: 'off', calendarClassName: `ps-floating-panel ps-datepicker ${ps_date_input_config_1.PsDateInputConfig.pickingClassName}`, className: 'ps-input-control ps-focus-ring min-h-11 w-full pr-10 text-sm font-semibold', dateFormat: ps_year_input_config_1.PsYearInputConfig.format, disabled: disabled, id: inputId, maxDate: maxDate, minDate: minDate, onChange: handleChange, placeholderText: placeholder, popperClassName: 'ps-datepicker-popper', popperPlacement: 'bottom-start', popperProps: { strategy: 'fixed' }, portalId: portalId, ref: pickerRef, renderCustomHeader: (headerProps) => ((0, jsx_runtime_1.jsx)(ps_calendar_header_1.PsCalendarHeader, { ...headerProps, maxDate: maxDate, minDate: minDate, onViewChange: () => undefined, onYearPick: (year) => {
|
|
50
|
+
handleChange(new Date(year, 0, 1));
|
|
51
|
+
pickerRef.current?.setOpen(false);
|
|
52
|
+
}, selectedYear: selected === null ? undefined : selected.getFullYear(), view: ps_calendar_view_1.PsCalendarView.year })), required: required, selected: selected, showPopperArrow: false, wrapperClassName: 'block w-full' }), (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'pointer-events-none absolute top-1/2 right-3 h-4 w-4 -translate-y-1/2 text-ink/50', iconKey: ps_icons_1.PsIconKey.Calendar }), name ? (0, jsx_runtime_1.jsx)("input", { name: name, type: 'hidden', value: currentValue }) : null] }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
|
|
44
53
|
};
|
|
45
54
|
exports.PsYearInput = PsYearInput;
|
|
@@ -9,8 +9,8 @@ const navigationButtonClassName = 'ps-focus-ring flex h-8 w-8 items-center justi
|
|
|
9
9
|
const titleButtonClassName = 'ps-focus-ring flex items-center gap-1 rounded-lg px-2 py-1 text-sm font-semibold text-ink transition-colors hover:bg-primary/10';
|
|
10
10
|
const cellClassName = 'ps-focus-ring flex h-10 items-center justify-center rounded-[0.625rem] text-sm font-medium text-ink transition-colors hover:bg-primary/10 disabled:cursor-not-allowed disabled:opacity-35 disabled:hover:bg-transparent';
|
|
11
11
|
const selectedCellClassName = 'bg-primary font-bold text-[var(--ps-color-primary-contrast)] hover:bg-primary';
|
|
12
|
-
export const PsCalendarHeader = ({ changeMonth, changeYear, decreaseMonth, increaseMonth, maxDate, minDate, monthDate, nextMonthButtonDisabled, onViewChange, prevMonthButtonDisabled, view, }) => {
|
|
13
|
-
const year = monthDate.getFullYear();
|
|
12
|
+
export const PsCalendarHeader = ({ changeMonth, changeYear, decreaseMonth, increaseMonth, maxDate, minDate, monthDate, nextMonthButtonDisabled, onViewChange, onYearPick, prevMonthButtonDisabled, selectedYear, view, }) => {
|
|
13
|
+
const year = selectedYear === undefined ? monthDate.getFullYear() : selectedYear;
|
|
14
14
|
const [pageYear, setPageYear] = useState(year);
|
|
15
15
|
const years = PsDateInputService.yearPage(pageYear);
|
|
16
16
|
const navigation = {
|
|
@@ -48,13 +48,17 @@ export const PsCalendarHeader = ({ changeMonth, changeYear, decreaseMonth, incre
|
|
|
48
48
|
titleView: PsCalendarView.day,
|
|
49
49
|
},
|
|
50
50
|
}[view];
|
|
51
|
-
return (_jsxs("div", { className: 'flex flex-col gap-2', children: [_jsxs("div", { className: 'flex items-center justify-between gap-2 px-1', children: [_jsx("button", { "aria-label": navigation.previousLabel, className: navigationButtonClassName, disabled: navigation.isPreviousDisabled, onClick: navigation.previous, type: 'button', children: _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 rotate-180', iconKey: PsIconKey.ChevronRight }) }), _jsxs("button", { "aria-label": navigation.titleLabel, "aria-live": 'polite', className: titleButtonClassName, onClick: () => {
|
|
51
|
+
return (_jsxs("div", { className: 'flex flex-col gap-2', children: [_jsxs("div", { className: 'flex items-center justify-between gap-2 px-1', children: [_jsx("button", { "aria-label": navigation.previousLabel, className: navigationButtonClassName, disabled: navigation.isPreviousDisabled, onClick: navigation.previous, type: 'button', children: _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 rotate-180', iconKey: PsIconKey.ChevronRight }) }), onYearPick === undefined ? (_jsxs("button", { "aria-label": navigation.titleLabel, "aria-live": 'polite', className: titleButtonClassName, onClick: () => {
|
|
52
52
|
setPageYear(year);
|
|
53
53
|
onViewChange(navigation.titleView);
|
|
54
|
-
}, type: 'button', children: [navigation.title, _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-3.5 w-3.5 rotate-90 text-ink/50', iconKey: PsIconKey.ChevronRight })] }), _jsx("button", { "aria-label": navigation.nextLabel, className: navigationButtonClassName, disabled: navigation.isNextDisabled, onClick: navigation.next, type: 'button', children: _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4', iconKey: PsIconKey.ChevronRight }) })] }), view === PsCalendarView.month ? (_jsx("div", { className: 'grid grid-cols-3 gap-1', children: PsDateInputService.monthNames().map((name, month) => (_jsx("button", { className: PallasoftClassNameService.merge(cellClassName, month === monthDate.getMonth() ? selectedCellClassName : undefined), disabled: PsDateInputService.isMonthOutOfRange(year, month, minDate, maxDate), onClick: () => {
|
|
54
|
+
}, type: 'button', children: [navigation.title, _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-3.5 w-3.5 rotate-90 text-ink/50', iconKey: PsIconKey.ChevronRight })] })) : (_jsx("p", { "aria-live": 'polite', className: 'text-sm font-semibold text-ink', children: navigation.title })), _jsx("button", { "aria-label": navigation.nextLabel, className: navigationButtonClassName, disabled: navigation.isNextDisabled, onClick: navigation.next, type: 'button', children: _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4', iconKey: PsIconKey.ChevronRight }) })] }), view === PsCalendarView.month ? (_jsx("div", { className: 'grid grid-cols-3 gap-1', children: PsDateInputService.monthNames().map((name, month) => (_jsx("button", { className: PallasoftClassNameService.merge(cellClassName, month === monthDate.getMonth() ? selectedCellClassName : undefined), disabled: PsDateInputService.isMonthOutOfRange(year, month, minDate, maxDate), onClick: () => {
|
|
55
55
|
changeMonth(month);
|
|
56
56
|
onViewChange(PsCalendarView.day);
|
|
57
57
|
}, type: 'button', children: name }, name))) })) : null, view === PsCalendarView.year ? (_jsx("div", { className: 'grid grid-cols-3 gap-1', children: years.map((candidate) => (_jsx("button", { className: PallasoftClassNameService.merge(cellClassName, candidate === year ? selectedCellClassName : undefined), disabled: PsDateInputService.isYearOutOfRange(candidate, minDate, maxDate), onClick: () => {
|
|
58
|
+
if (onYearPick !== undefined) {
|
|
59
|
+
onYearPick(candidate);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
58
62
|
changeYear(candidate);
|
|
59
63
|
onViewChange(PsCalendarView.month);
|
|
60
64
|
}, type: 'button', children: candidate }, candidate))) })) : null] }));
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useId, useState } from 'react';
|
|
2
|
+
import { useEffect, useId, useRef, useState } from 'react';
|
|
3
3
|
import { usePsLayerZIndex } from '@pallasoft/ps-core-components';
|
|
4
4
|
import { PallasoftClassNameService, PallasoftZIndex } from '@pallasoft/ps-design-system';
|
|
5
5
|
import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
|
|
6
6
|
import DatePicker from 'react-datepicker';
|
|
7
|
+
import { PsCalendarView } from '../constants/ps-calendar-view';
|
|
7
8
|
import { PsDateInputConfig } from '../constants/ps-date-input-config';
|
|
8
9
|
import { PsYearInputConfig } from '../constants/ps-year-input-config';
|
|
9
10
|
import { PsYearInputService } from '../services/ps-year-input-service';
|
|
11
|
+
import { PsCalendarHeader } from './ps-calendar-header';
|
|
10
12
|
import { PsFieldSkeleton } from './ps-field-skeleton';
|
|
11
13
|
import { PsRequiredMark } from './ps-required-mark';
|
|
12
14
|
export const PsYearInput = ({ className, defaultValue, disabled, helperText, hideLabel, isLoading = false, label, maxYear, minYear, name, onChange, placeholder = PsYearInputConfig.placeholder, required, value, }) => {
|
|
@@ -17,6 +19,10 @@ export const PsYearInput = ({ className, defaultValue, disabled, helperText, hid
|
|
|
17
19
|
const zIndex = usePsLayerZIndex(PallasoftZIndex.Dropdown);
|
|
18
20
|
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue === undefined ? '' : defaultValue);
|
|
19
21
|
const currentValue = value === undefined ? uncontrolledValue : value;
|
|
22
|
+
const pickerRef = useRef(null);
|
|
23
|
+
const selected = PsYearInputService.parse(currentValue);
|
|
24
|
+
const minDate = PsYearInputService.bound(minYear);
|
|
25
|
+
const maxDate = PsYearInputService.bound(maxYear);
|
|
20
26
|
useEffect(() => {
|
|
21
27
|
const existing = document.getElementById(portalId);
|
|
22
28
|
const container = existing ? existing : document.createElement('div');
|
|
@@ -34,5 +40,8 @@ export const PsYearInput = ({ className, defaultValue, disabled, helperText, hid
|
|
|
34
40
|
setUncontrolledValue(nextValue);
|
|
35
41
|
onChange?.(nextValue);
|
|
36
42
|
};
|
|
37
|
-
return (_jsxs("div", { className: PallasoftClassNameService.merge('block', className), children: [_jsxs("label", { className: hideLabel ? 'sr-only' : 'ps-input-label block', htmlFor: inputId, children: [label, _jsx(PsRequiredMark, { isRequired: required })] }), _jsxs("div", { className: hideLabel ? 'relative' : 'relative mt-2', children: [_jsx(DatePicker, { autoComplete: 'off', calendarClassName:
|
|
43
|
+
return (_jsxs("div", { className: PallasoftClassNameService.merge('block', className), children: [_jsxs("label", { className: hideLabel ? 'sr-only' : 'ps-input-label block', htmlFor: inputId, children: [label, _jsx(PsRequiredMark, { isRequired: required })] }), _jsxs("div", { className: hideLabel ? 'relative' : 'relative mt-2', children: [_jsx(DatePicker, { autoComplete: 'off', calendarClassName: `ps-floating-panel ps-datepicker ${PsDateInputConfig.pickingClassName}`, className: 'ps-input-control ps-focus-ring min-h-11 w-full pr-10 text-sm font-semibold', dateFormat: PsYearInputConfig.format, disabled: disabled, id: inputId, maxDate: maxDate, minDate: minDate, onChange: handleChange, placeholderText: placeholder, popperClassName: 'ps-datepicker-popper', popperPlacement: 'bottom-start', popperProps: { strategy: 'fixed' }, portalId: portalId, ref: pickerRef, renderCustomHeader: (headerProps) => (_jsx(PsCalendarHeader, { ...headerProps, maxDate: maxDate, minDate: minDate, onViewChange: () => undefined, onYearPick: (year) => {
|
|
44
|
+
handleChange(new Date(year, 0, 1));
|
|
45
|
+
pickerRef.current?.setOpen(false);
|
|
46
|
+
}, selectedYear: selected === null ? undefined : selected.getFullYear(), view: PsCalendarView.year })), required: required, selected: selected, showPopperArrow: false, wrapperClassName: 'block w-full' }), _jsx(PsIcon, { "aria-hidden": 'true', className: 'pointer-events-none absolute top-1/2 right-3 h-4 w-4 -translate-y-1/2 text-ink/50', iconKey: PsIconKey.Calendar }), name ? _jsx("input", { name: name, type: 'hidden', value: currentValue }) : null] }), helperText ? _jsx("span", { className: 'ps-input-helper', children: helperText }) : null] }));
|
|
38
47
|
};
|