@pallasoft/ps-input-components 1.1.1 → 1.3.0

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.
@@ -0,0 +1,2 @@
1
+ import type { ReactDatePickerCustomHeaderProps } from 'react-datepicker';
2
+ export declare const PsCalendarHeader: ({ decreaseMonth, increaseMonth, monthDate, nextMonthButtonDisabled, prevMonthButtonDisabled, }: ReactDatePickerCustomHeaderProps) => import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsCalendarHeader = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ps_icons_1 = require("@pallasoft/ps-icons");
6
+ const ps_date_input_service_1 = require("../services/ps-date-input-service");
7
+ const navigationButtonClassName = 'ps-focus-ring flex h-8 w-8 items-center justify-center rounded-lg text-ink/60 transition-colors hover:bg-primary/10 hover:text-ink disabled:cursor-not-allowed disabled:opacity-30';
8
+ const PsCalendarHeader = ({ decreaseMonth, increaseMonth, monthDate, nextMonthButtonDisabled, prevMonthButtonDisabled, }) => ((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": 'Previous month', className: navigationButtonClassName, disabled: prevMonthButtonDisabled, onClick: decreaseMonth, 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.jsx)("p", { "aria-live": 'polite', className: 'text-sm font-semibold text-ink', children: ps_date_input_service_1.PsDateInputService.monthLabel(monthDate) }), (0, jsx_runtime_1.jsx)("button", { "aria-label": 'Next month', className: navigationButtonClassName, disabled: nextMonthButtonDisabled, onClick: increaseMonth, 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 }) })] }));
9
+ exports.PsCalendarHeader = PsCalendarHeader;
@@ -3,10 +3,14 @@ export interface PsDateInputProps {
3
3
  defaultValue?: string;
4
4
  disabled?: boolean;
5
5
  helperText?: string;
6
+ hideLabel?: boolean;
6
7
  label: string;
8
+ max?: string;
9
+ min?: string;
7
10
  name?: string;
8
11
  onChange?: (value: string) => void;
12
+ placeholder?: string;
9
13
  required?: boolean;
10
14
  value?: string;
11
15
  }
12
- export declare const PsDateInput: ({ className, defaultValue, disabled, helperText, label, name, onChange, required, value, }: PsDateInputProps) => import("react").JSX.Element;
16
+ export declare const PsDateInput: ({ className, defaultValue, disabled, helperText, hideLabel, label, max, min, name, onChange, placeholder, required, value, }: PsDateInputProps) => import("react").JSX.Element;
@@ -1,7 +1,27 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.PsDateInput = void 0;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("react");
5
9
  const ps_design_system_1 = require("@pallasoft/ps-design-system");
6
- const PsDateInput = ({ className, defaultValue, disabled, helperText, label, name, onChange, required, value, }) => ((0, jsx_runtime_1.jsxs)("label", { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), children: [(0, jsx_runtime_1.jsx)("span", { className: 'ps-input-label', children: label }), (0, jsx_runtime_1.jsx)("input", { className: 'ps-input-control ps-focus-ring mt-2 min-h-11 w-full text-sm font-semibold', defaultValue: value === undefined ? defaultValue : undefined, disabled: disabled, name: name, onChange: (event) => onChange?.(event.target.value), required: required, type: 'date', value: value }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
10
+ const ps_icons_1 = require("@pallasoft/ps-icons");
11
+ const react_datepicker_1 = __importDefault(require("react-datepicker"));
12
+ const ps_date_input_config_1 = require("../constants/ps-date-input-config");
13
+ const ps_date_input_service_1 = require("../services/ps-date-input-service");
14
+ const ps_calendar_header_1 = require("./ps-calendar-header");
15
+ const PsDateInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, max, min, name, onChange, placeholder = ps_date_input_config_1.PsDateInputConfig.placeholder, required, value, }) => {
16
+ const inputId = (0, react_1.useId)();
17
+ const [uncontrolledValue, setUncontrolledValue] = (0, react_1.useState)(defaultValue === undefined ? '' : defaultValue);
18
+ const currentValue = value === undefined ? uncontrolledValue : value;
19
+ const handleChange = (date) => {
20
+ const nextValue = ps_date_input_service_1.PsDateInputService.format(date);
21
+ if (value === undefined)
22
+ setUncontrolledValue(nextValue);
23
+ onChange?.(nextValue);
24
+ };
25
+ return ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), children: [(0, jsx_runtime_1.jsx)("label", { className: hideLabel ? 'sr-only' : 'ps-input-label block', htmlFor: inputId, children: label }), (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', className: 'ps-input-control ps-focus-ring min-h-11 w-full pr-10 text-sm font-semibold', dateFormat: [...ps_date_input_config_1.PsDateInputConfig.inputFormats], disabled: disabled, id: inputId, maxDate: ps_date_input_service_1.PsDateInputService.parseBound(max), minDate: ps_date_input_service_1.PsDateInputService.parseBound(min), onChange: handleChange, placeholderText: placeholder, popperClassName: 'ps-datepicker-popper', popperPlacement: 'bottom-start', portalId: ps_date_input_config_1.PsDateInputConfig.portalId, renderCustomHeader: (headerProps) => (0, jsx_runtime_1.jsx)(ps_calendar_header_1.PsCalendarHeader, { ...headerProps }), required: required, selected: ps_date_input_service_1.PsDateInputService.parse(currentValue), showPopperArrow: false, wrapperClassName: 'block w-full' }), (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'pointer-events-none absolute right-3 top-1/2 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] }));
26
+ };
7
27
  exports.PsDateInput = PsDateInput;
@@ -4,10 +4,13 @@ export interface PsMultiSelectInputProps {
4
4
  defaultValue?: string[];
5
5
  disabled?: boolean;
6
6
  helperText?: string;
7
+ hideLabel?: boolean;
7
8
  label: string;
8
9
  name?: string;
9
10
  onChange?: (value: string[]) => void;
10
11
  options: PsSelectOption[];
12
+ placeholder?: string;
13
+ required?: boolean;
11
14
  value?: string[];
12
15
  }
13
- export declare const PsMultiSelectInput: ({ className, defaultValue, disabled, helperText, label, name, onChange, options, value, }: PsMultiSelectInputProps) => import("react").JSX.Element;
16
+ export declare const PsMultiSelectInput: ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder, required, value, }: PsMultiSelectInputProps) => import("react").JSX.Element;
@@ -2,10 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PsMultiSelectInput = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
5
6
  const ps_design_system_1 = require("@pallasoft/ps-design-system");
7
+ const ps_icons_1 = require("@pallasoft/ps-icons");
6
8
  const react_aria_components_1 = require("react-aria-components");
7
- const PsMultiSelectInput = ({ className, defaultValue, disabled, helperText, label, name, onChange, options, value, }) => {
8
- const selectedProps = value === undefined ? { defaultValue } : { value };
9
- return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.CheckboxGroup, { ...selectedProps, className: ps_design_system_1.PallasoftClassNameService.merge('grid gap-2', className), isDisabled: disabled, onChange: onChange, children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Label, { className: 'ps-input-label', children: label }), (0, jsx_runtime_1.jsx)("div", { className: 'grid gap-2', children: options.map((option) => ((0, jsx_runtime_1.jsxs)(react_aria_components_1.Checkbox, { className: 'ps-focus-ring group flex cursor-pointer items-start gap-3 rounded-2xl border border-line bg-white/62 px-3.5 py-3 text-sm transition selected:border-primary/40 selected:bg-primary-soft/42 hover:border-primary/30 dark:border-white/10 dark:bg-white/6', name: name, value: option.value, children: [(0, jsx_runtime_1.jsx)("span", { className: 'mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border border-line bg-white text-[0.65rem] font-black text-white group-selected:border-primary group-selected:bg-primary dark:border-white/20 dark:bg-white/8', children: "\u2713" }), (0, jsx_runtime_1.jsxs)("span", { className: 'min-w-0', children: [(0, jsx_runtime_1.jsx)("span", { className: 'block font-semibold text-ink', children: option.label }), option.description ? ((0, jsx_runtime_1.jsx)("span", { className: 'mt-1 block text-xs leading-5 text-slate-500', children: option.description })) : null] })] }, option.value))) }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
9
+ const ps_select_option_item_1 = require("./ps-select-option-item");
10
+ const PsMultiSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder = 'Select options', required, value, }) => {
11
+ const [uncontrolledValue, setUncontrolledValue] = (0, react_1.useState)(defaultValue === undefined ? [] : defaultValue);
12
+ const currentValue = value === undefined ? uncontrolledValue : value;
13
+ const labelByValue = new Map(options.map((option) => [option.value, option.label]));
14
+ const handleChange = (keys) => {
15
+ const nextValue = keys.map((key) => String(key));
16
+ if (value === undefined)
17
+ setUncontrolledValue(nextValue);
18
+ onChange?.(nextValue);
19
+ };
20
+ return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.Select, { "aria-label": hideLabel ? label : undefined, className: ps_design_system_1.PallasoftClassNameService.merge('block', className), isDisabled: disabled, isRequired: required, name: name, onChange: handleChange, placeholder: placeholder, selectionMode: 'multiple', value: currentValue.filter((selected) => labelByValue.has(selected)), children: [hideLabel ? null : (0, jsx_runtime_1.jsx)(react_aria_components_1.Label, { className: 'ps-input-label block', children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Button, { className: ps_design_system_1.PallasoftClassNameService.merge('ps-input-control ps-focus-ring relative flex min-h-11 w-full items-center py-1.5 pr-10 text-left text-sm font-semibold disabled:cursor-not-allowed disabled:opacity-60', hideLabel ? '' : 'mt-2'), children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.SelectValue, { className: 'flex min-w-0 flex-1 flex-wrap gap-1.5', children: ({ isPlaceholder }) => isPlaceholder ? ((0, jsx_runtime_1.jsx)("span", { className: 'font-medium text-ink/45', children: placeholder })) : (currentValue
21
+ .filter((selected) => labelByValue.has(selected))
22
+ .map((selected) => ((0, jsx_runtime_1.jsx)("span", { className: 'inline-flex max-w-full items-center rounded-full bg-primary/12 px-2.5 py-0.5 text-xs font-semibold text-ink', children: (0, jsx_runtime_1.jsx)("span", { className: 'truncate', children: labelByValue.get(selected) }) }, selected)))) }), (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-primary', iconKey: ps_icons_1.PsIconKey.Chevron })] }), helperText ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Text, { className: 'ps-input-helper', slot: 'description', children: helperText })) : null, (0, jsx_runtime_1.jsx)(react_aria_components_1.Popover, { className: 'ps-floating-panel ps-scrollbar max-h-72 min-w-[var(--trigger-width)] overflow-y-auto p-1.5 outline-none', offset: 6, placement: 'bottom start', children: (0, jsx_runtime_1.jsx)(react_aria_components_1.ListBox, { className: 'outline-none', items: options.map((option) => ({ ...option, id: option.value })), children: (option) => (0, jsx_runtime_1.jsx)(ps_select_option_item_1.PsSelectOptionItem, { option: option }) }) })] }));
10
23
  };
11
24
  exports.PsMultiSelectInput = PsMultiSelectInput;
@@ -8,6 +8,7 @@ export interface PsSelectInputProps {
8
8
  defaultValue?: string;
9
9
  disabled?: boolean;
10
10
  helperText?: string;
11
+ hideLabel?: boolean;
11
12
  label: string;
12
13
  name?: string;
13
14
  onChange?: (value: string) => void;
@@ -16,4 +17,4 @@ export interface PsSelectInputProps {
16
17
  required?: boolean;
17
18
  value?: string;
18
19
  }
19
- export declare const PsSelectInput: ({ className, defaultValue, disabled, helperText, label, name, onChange, options, placeholder, required, value, }: PsSelectInputProps) => import("react").JSX.Element;
20
+ export declare const PsSelectInput: ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder, required, value, }: PsSelectInputProps) => import("react").JSX.Element;
@@ -2,10 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PsSelectInput = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
5
6
  const ps_design_system_1 = require("@pallasoft/ps-design-system");
6
7
  const ps_icons_1 = require("@pallasoft/ps-icons");
8
+ const react_aria_components_1 = require("react-aria-components");
7
9
  const ps_select_input_service_1 = require("../services/ps-select-input-service");
8
- const PsSelectInput = ({ className, defaultValue, disabled, helperText, label, name, onChange, options, placeholder = 'Select an option', required, value, }) => ((0, jsx_runtime_1.jsxs)("label", { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), children: [(0, jsx_runtime_1.jsx)("span", { className: 'ps-input-label', children: label }), (0, jsx_runtime_1.jsxs)("span", { className: 'relative mt-2 block', children: [(0, jsx_runtime_1.jsxs)("select", { className: 'ps-input-control ps-focus-ring min-h-11 w-full appearance-none pr-10 text-left font-semibold disabled:cursor-not-allowed disabled:opacity-60', defaultValue: value === undefined
9
- ? ps_select_input_service_1.PsSelectInputService.getDefaultValue(defaultValue, options)
10
- : undefined, disabled: disabled, name: name, onChange: (event) => onChange?.(event.target.value), required: required, value: value, children: [options.length === 0 || !defaultValue ? ((0, jsx_runtime_1.jsx)("option", { disabled: true, value: '', children: placeholder })) : null, options.map((option) => ((0, jsx_runtime_1.jsx)("option", { value: option.value, children: option.label }, option.value)))] }), (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', iconKey: ps_icons_1.PsIconKey.Chevron, className: 'pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-primary' })] }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
10
+ const ps_select_option_item_1 = require("./ps-select-option-item");
11
+ const PsSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder = 'Select an option', required, value, }) => {
12
+ const [uncontrolledValue, setUncontrolledValue] = (0, react_1.useState)(() => ps_select_input_service_1.PsSelectInputService.getDefaultValue(defaultValue, options));
13
+ const currentValue = value === undefined ? uncontrolledValue : value;
14
+ const hasOption = options.some((option) => option.value === currentValue);
15
+ const handleChange = (key) => {
16
+ const nextValue = key === null ? '' : String(key);
17
+ if (value === undefined)
18
+ setUncontrolledValue(nextValue);
19
+ onChange?.(nextValue);
20
+ };
21
+ return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.Select, { "aria-label": hideLabel ? label : undefined, className: ps_design_system_1.PallasoftClassNameService.merge('block', className), isDisabled: disabled, isRequired: required, name: name, onChange: handleChange, placeholder: placeholder, value: hasOption ? currentValue : null, children: [hideLabel ? null : (0, jsx_runtime_1.jsx)(react_aria_components_1.Label, { className: 'ps-input-label block', children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Button, { className: ps_design_system_1.PallasoftClassNameService.merge('ps-input-control ps-focus-ring relative flex min-h-11 w-full items-center pr-10 text-left text-sm font-semibold disabled:cursor-not-allowed disabled:opacity-60', hideLabel ? '' : 'mt-2'), children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.SelectValue, { className: 'min-w-0 flex-1 truncate', children: ({ isPlaceholder, selectedText }) => isPlaceholder ? ((0, jsx_runtime_1.jsx)("span", { className: 'font-medium text-ink/45', children: placeholder })) : (selectedText) }), (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-primary', iconKey: ps_icons_1.PsIconKey.Chevron })] }), helperText ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Text, { className: 'ps-input-helper', slot: 'description', children: helperText })) : null, (0, jsx_runtime_1.jsx)(react_aria_components_1.Popover, { className: 'ps-floating-panel ps-scrollbar max-h-72 min-w-[var(--trigger-width)] overflow-y-auto p-1.5 outline-none', offset: 6, placement: 'bottom start', children: (0, jsx_runtime_1.jsx)(react_aria_components_1.ListBox, { className: 'outline-none', items: options.map((option) => ({ ...option, id: option.value })), children: (option) => (0, jsx_runtime_1.jsx)(ps_select_option_item_1.PsSelectOptionItem, { option: option }) }) })] }));
22
+ };
11
23
  exports.PsSelectInput = PsSelectInput;
@@ -0,0 +1,5 @@
1
+ import type { PsSelectOption } from './ps-select-input';
2
+ export interface PsSelectOptionItemProps {
3
+ option: PsSelectOption;
4
+ }
5
+ export declare const PsSelectOptionItem: ({ option }: PsSelectOptionItemProps) => import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsSelectOptionItem = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ps_icons_1 = require("@pallasoft/ps-icons");
6
+ const react_aria_components_1 = require("react-aria-components");
7
+ const PsSelectOptionItem = ({ option }) => ((0, jsx_runtime_1.jsx)(react_aria_components_1.ListBoxItem, { className: 'ps-floating-option text-ink', id: option.value, textValue: option.label, children: ({ isSelected }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: 'flex h-4 w-4 shrink-0 items-center justify-center text-primary', children: isSelected ? ((0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4', iconKey: ps_icons_1.PsIconKey.Check })) : null }), (0, jsx_runtime_1.jsxs)("span", { className: 'min-w-0 flex-1', children: [(0, jsx_runtime_1.jsx)("span", { className: 'block truncate', children: option.label }), option.description ? ((0, jsx_runtime_1.jsx)("span", { className: 'mt-0.5 block text-xs font-normal text-ink/55', children: option.description })) : null] })] })) }));
8
+ exports.PsSelectOptionItem = PsSelectOptionItem;
@@ -1,6 +1,7 @@
1
1
  import type { InputHTMLAttributes } from 'react';
2
2
  export interface PsTextInputProps extends InputHTMLAttributes<HTMLInputElement> {
3
3
  helperText?: string;
4
+ hideLabel?: boolean;
4
5
  label: string;
5
6
  }
6
- export declare const PsTextInput: ({ className, defaultValue, disabled, helperText, label, name, onChange, required, type, value, ...props }: PsTextInputProps) => import("react").JSX.Element;
7
+ export declare const PsTextInput: ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, required, type, value, ...props }: PsTextInputProps) => import("react").JSX.Element;
@@ -4,12 +4,12 @@ exports.PsTextInput = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const ps_design_system_1 = require("@pallasoft/ps-design-system");
6
6
  const ps_date_input_1 = require("./ps-date-input");
7
- const PsTextInput = ({ className, defaultValue, disabled, helperText, label, name, onChange, required, type, value, ...props }) => {
7
+ const PsTextInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, required, type, value, ...props }) => {
8
8
  if (type === 'date') {
9
- return ((0, jsx_runtime_1.jsx)(ps_date_input_1.PsDateInput, { className: className, defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined, disabled: disabled, helperText: helperText, label: label, name: name, onChange: (nextValue) => onChange?.({
9
+ return ((0, jsx_runtime_1.jsx)(ps_date_input_1.PsDateInput, { className: className, defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined, disabled: disabled, helperText: helperText, hideLabel: hideLabel, label: label, name: name, onChange: (nextValue) => onChange?.({
10
10
  target: { name, value: nextValue },
11
11
  }), required: required, value: typeof value === 'string' ? value : undefined }));
12
12
  }
13
- return ((0, jsx_runtime_1.jsxs)("label", { className: 'block', children: [(0, jsx_runtime_1.jsx)("span", { className: 'ps-input-label', children: label }), (0, jsx_runtime_1.jsx)("input", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-input-control mt-2', className), defaultValue: defaultValue, disabled: disabled, name: name, onChange: onChange, required: required, type: type, value: value, ...props }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
13
+ return ((0, jsx_runtime_1.jsxs)("label", { className: 'block', children: [(0, jsx_runtime_1.jsx)("span", { className: hideLabel ? 'sr-only' : 'ps-input-label', children: label }), (0, jsx_runtime_1.jsx)("input", { className: ps_design_system_1.PallasoftClassNameService.merge(hideLabel ? 'ps-input-control' : 'ps-input-control mt-2', className), defaultValue: defaultValue, disabled: disabled, name: name, onChange: onChange, required: required, type: type, value: value, ...props }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
14
14
  };
15
15
  exports.PsTextInput = PsTextInput;
@@ -0,0 +1,7 @@
1
+ export declare const PsDateInputConfig: {
2
+ readonly inputFormats: readonly ["MMM d, yyyy", "yyyy-MM-dd", "MM/dd/yyyy", "d MMM yyyy"];
3
+ readonly monthLabelFormat: "MMMM YYYY";
4
+ readonly valueFormat: "YYYY-MM-DD";
5
+ readonly placeholder: "Select a date";
6
+ readonly portalId: "ps-floating-root";
7
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsDateInputConfig = void 0;
4
+ exports.PsDateInputConfig = {
5
+ inputFormats: ['MMM d, yyyy', 'yyyy-MM-dd', 'MM/dd/yyyy', 'd MMM yyyy'],
6
+ monthLabelFormat: 'MMMM YYYY',
7
+ valueFormat: 'YYYY-MM-DD',
8
+ placeholder: 'Select a date',
9
+ portalId: 'ps-floating-root',
10
+ };
@@ -0,0 +1,6 @@
1
+ export declare class PsDateInputService {
2
+ static parse(value: string | undefined): Date | null;
3
+ static parseBound(value: string | undefined): Date | undefined;
4
+ static format(date: Date | null): string;
5
+ static monthLabel(date: Date): string;
6
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsDateInputService = void 0;
4
+ const ps_utilities_1 = require("@pallasoft/ps-utilities");
5
+ const ps_date_input_config_1 = require("../constants/ps-date-input-config");
6
+ class PsDateInputService {
7
+ static parse(value) {
8
+ if (value === undefined || value === '')
9
+ return null;
10
+ const date = ps_utilities_1.Common.DateService.getDate(value);
11
+ return date.isValid() && date.format(ps_date_input_config_1.PsDateInputConfig.valueFormat) === value
12
+ ? date.toDate()
13
+ : null;
14
+ }
15
+ static parseBound(value) {
16
+ const date = PsDateInputService.parse(value);
17
+ return date === null ? undefined : date;
18
+ }
19
+ static format(date) {
20
+ return date === null
21
+ ? ''
22
+ : ps_utilities_1.Common.DateService.formatDate(date.getTime(), ps_date_input_config_1.PsDateInputConfig.valueFormat);
23
+ }
24
+ static monthLabel(date) {
25
+ return ps_utilities_1.Common.DateService.formatDate(date.getTime(), ps_date_input_config_1.PsDateInputConfig.monthLabelFormat);
26
+ }
27
+ }
28
+ exports.PsDateInputService = PsDateInputService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-input-components",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -30,9 +30,11 @@
30
30
  "dependencies": {
31
31
  "@internationalized/date": "^3.12.2",
32
32
  "@pallasoft/ps-core-components": "^2.0.0",
33
- "@pallasoft/ps-design-system": "^1.1.0",
34
- "@pallasoft/ps-icons": "^1.1.0",
35
- "react-aria-components": "^1.19.0"
33
+ "@pallasoft/ps-design-system": "^1.2.1",
34
+ "@pallasoft/ps-icons": "^1.2.0",
35
+ "@pallasoft/ps-utilities": "^2.0.0",
36
+ "react-aria-components": "^1.19.0",
37
+ "react-datepicker": "^9.1.0"
36
38
  },
37
39
  "peerDependencies": {
38
40
  "react": "^18 || ^19",