@pallasoft/ps-input-components 1.2.0 → 1.4.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.
- package/dist/components/ps-calendar-header.d.ts +2 -0
- package/dist/components/ps-calendar-header.js +9 -0
- package/dist/components/ps-checkbox.d.ts +13 -0
- package/dist/components/ps-checkbox.js +11 -0
- package/dist/components/ps-date-input.d.ts +4 -2
- package/dist/components/ps-date-input.js +21 -1
- package/dist/components/ps-multi-select-input.d.ts +4 -1
- package/dist/components/ps-multi-select-input.js +16 -3
- package/dist/components/ps-select-input.d.ts +0 -1
- package/dist/components/ps-select-input.js +15 -3
- package/dist/components/ps-select-option-item.d.ts +5 -0
- package/dist/components/ps-select-option-item.js +8 -0
- package/dist/components/ps-text-input.d.ts +0 -1
- package/dist/constants/ps-date-input-config.d.ts +7 -0
- package/dist/constants/ps-date-input-config.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/ps-date-input-service.d.ts +6 -0
- package/dist/services/ps-date-input-service.js +28 -0
- package/package.json +6 -4
|
@@ -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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface PsCheckboxProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
isDisabled?: boolean;
|
|
6
|
+
isIndeterminate?: boolean;
|
|
7
|
+
isSelected: boolean;
|
|
8
|
+
label: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
onChange: (isSelected: boolean) => void;
|
|
11
|
+
value?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const PsCheckbox: ({ children, className, isDisabled, isIndeterminate, isSelected, label, name, onChange, value, }: PsCheckboxProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsCheckbox = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
6
|
+
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
7
|
+
const react_aria_components_1 = require("react-aria-components");
|
|
8
|
+
const PsCheckbox = ({ children, className, isDisabled, isIndeterminate, isSelected, label, name, onChange, value, }) => ((0, jsx_runtime_1.jsx)(react_aria_components_1.Checkbox, { "aria-label": children ? undefined : label, className: ps_design_system_1.PallasoftClassNameService.merge('group inline-flex cursor-pointer items-center gap-3 text-sm text-ink outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-45', className), isDisabled: isDisabled, isIndeterminate: isIndeterminate, isSelected: isSelected, name: name, onChange: onChange, value: value, children: ({ isIndeterminate: showDash, isSelected: showCheck }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: ps_design_system_1.PallasoftClassNameService.merge('flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center rounded-[0.35rem] border transition-colors duration-150 group-data-[focus-visible]:outline group-data-[focus-visible]:outline-2 group-data-[focus-visible]:outline-offset-2 group-data-[focus-visible]:outline-[rgb(var(--ps-color-primary-rgb))]', showCheck || showDash
|
|
9
|
+
? 'border-primary bg-primary text-[color:var(--ps-color-primary-contrast)]'
|
|
10
|
+
: 'border-line bg-surface group-hover:border-primary/60 dark:border-white/20'), children: showDash ? ((0, jsx_runtime_1.jsx)("span", { className: 'block h-0.5 w-2.5 rounded-full bg-current' })) : showCheck ? ((0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-3.5 w-3.5', iconKey: ps_icons_1.PsIconKey.Check, strokeWidth: 3 })) : null }), children] })) }));
|
|
11
|
+
exports.PsCheckbox = PsCheckbox;
|
|
@@ -3,12 +3,14 @@ export interface PsDateInputProps {
|
|
|
3
3
|
defaultValue?: string;
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
helperText?: string;
|
|
6
|
-
/** Keeps the label for screen readers only, for inputs laid out under a shared column header. */
|
|
7
6
|
hideLabel?: boolean;
|
|
8
7
|
label: string;
|
|
8
|
+
max?: string;
|
|
9
|
+
min?: string;
|
|
9
10
|
name?: string;
|
|
10
11
|
onChange?: (value: string) => void;
|
|
12
|
+
placeholder?: string;
|
|
11
13
|
required?: boolean;
|
|
12
14
|
value?: string;
|
|
13
15
|
}
|
|
14
|
-
export declare const PsDateInput: ({ className, defaultValue, disabled, helperText, hideLabel, 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
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
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,7 +8,6 @@ export interface PsSelectInputProps {
|
|
|
8
8
|
defaultValue?: string;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
helperText?: string;
|
|
11
|
-
/** Keeps the label for screen readers only, for inputs laid out under a shared column header. */
|
|
12
11
|
hideLabel?: boolean;
|
|
13
12
|
label: string;
|
|
14
13
|
name?: string;
|
|
@@ -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
|
|
9
|
-
|
|
10
|
-
|
|
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,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,7 +1,6 @@
|
|
|
1
1
|
import type { InputHTMLAttributes } from 'react';
|
|
2
2
|
export interface PsTextInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
3
|
helperText?: string;
|
|
4
|
-
/** Keeps the label for screen readers only, for inputs laid out under a shared column header. */
|
|
5
4
|
hideLabel?: boolean;
|
|
6
5
|
label: string;
|
|
7
6
|
}
|
|
@@ -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
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components/ps-checkbox"), exports);
|
|
17
18
|
__exportStar(require("./components/ps-combobox-input"), exports);
|
|
18
19
|
__exportStar(require("./components/ps-date-input"), exports);
|
|
19
20
|
__exportStar(require("./components/ps-dropdown"), exports);
|
|
@@ -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.
|
|
3
|
+
"version": "1.4.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
|
|
34
|
-
"@pallasoft/ps-icons": "^1.
|
|
35
|
-
"
|
|
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",
|