@pallasoft/ps-input-components 1.1.1 → 1.2.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-date-input.d.ts +3 -1
- package/dist/components/ps-date-input.js +1 -1
- package/dist/components/ps-select-input.d.ts +3 -1
- package/dist/components/ps-select-input.js +1 -1
- package/dist/components/ps-text-input.d.ts +3 -1
- package/dist/components/ps-text-input.js +3 -3
- package/package.json +1 -1
|
@@ -3,10 +3,12 @@ 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
|
+
hideLabel?: boolean;
|
|
6
8
|
label: string;
|
|
7
9
|
name?: string;
|
|
8
10
|
onChange?: (value: string) => void;
|
|
9
11
|
required?: boolean;
|
|
10
12
|
value?: string;
|
|
11
13
|
}
|
|
12
|
-
export declare const PsDateInput: ({ className, defaultValue, disabled, helperText, label, name, onChange, required, value, }: PsDateInputProps) => import("react").JSX.Element;
|
|
14
|
+
export declare const PsDateInput: ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, required, value, }: PsDateInputProps) => import("react").JSX.Element;
|
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PsDateInput = 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
|
-
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
|
|
6
|
+
const PsDateInput = ({ className, defaultValue, disabled, helperText, hideLabel, 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: hideLabel ? 'sr-only' : 'ps-input-label', children: label }), (0, jsx_runtime_1.jsx)("input", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-input-control ps-focus-ring min-h-11 w-full text-sm font-semibold', hideLabel ? '' : 'mt-2'), 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] }));
|
|
7
7
|
exports.PsDateInput = PsDateInput;
|
|
@@ -8,6 +8,8 @@ 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
|
+
hideLabel?: boolean;
|
|
11
13
|
label: string;
|
|
12
14
|
name?: string;
|
|
13
15
|
onChange?: (value: string) => void;
|
|
@@ -16,4 +18,4 @@ export interface PsSelectInputProps {
|
|
|
16
18
|
required?: boolean;
|
|
17
19
|
value?: string;
|
|
18
20
|
}
|
|
19
|
-
export declare const PsSelectInput: ({ className, defaultValue, disabled, helperText, label, name, onChange, options, placeholder, required, value, }: PsSelectInputProps) => import("react").JSX.Element;
|
|
21
|
+
export declare const PsSelectInput: ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder, required, value, }: PsSelectInputProps) => import("react").JSX.Element;
|
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
6
6
|
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
7
7
|
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
|
|
8
|
+
const PsSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, 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: hideLabel ? 'sr-only' : 'ps-input-label', children: label }), (0, jsx_runtime_1.jsxs)("span", { className: hideLabel ? 'relative block' : '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
9
|
? ps_select_input_service_1.PsSelectInputService.getDefaultValue(defaultValue, options)
|
|
10
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] }));
|
|
11
11
|
exports.PsSelectInput = PsSelectInput;
|
|
@@ -1,6 +1,8 @@
|
|
|
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
|
+
hideLabel?: boolean;
|
|
4
6
|
label: string;
|
|
5
7
|
}
|
|
6
|
-
export declare const PsTextInput: ({ className, defaultValue, disabled, helperText, label, name, onChange, required, type, value, ...props }: PsTextInputProps) => import("react").JSX.Element;
|
|
8
|
+
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;
|