@pallasoft/ps-input-components 1.22.0 → 1.23.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-option-card-group.d.ts +8 -0
- package/dist/components/ps-option-card-group.js +12 -0
- package/dist/esm/components/ps-option-card-group.js +8 -0
- package/dist/esm/form/components/ps-form-name-modal.js +16 -0
- package/dist/esm/form/index.js +2 -0
- package/dist/esm/form/models/ps-form-name-data.js +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/interfaces/ps-option-card-data.js +1 -0
- package/dist/form/components/ps-form-name-modal.d.ts +15 -0
- package/dist/form/components/ps-form-name-modal.js +20 -0
- package/dist/form/index.d.ts +2 -0
- package/dist/form/index.js +2 -0
- package/dist/form/models/ps-form-name-data.d.ts +3 -0
- package/dist/form/models/ps-form-name-data.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/interfaces/ps-option-card-data.d.ts +5 -0
- package/dist/interfaces/ps-option-card-data.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PsOptionCardData } from '../interfaces/ps-option-card-data';
|
|
2
|
+
export interface PsOptionCardGroupProps {
|
|
3
|
+
label: string;
|
|
4
|
+
onChange: (value: string) => void;
|
|
5
|
+
options: PsOptionCardData[];
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const PsOptionCardGroup: ({ label, onChange, options, value }: PsOptionCardGroupProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsOptionCardGroup = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
6
|
+
const PsOptionCardGroup = ({ label, onChange, options, value }) => ((0, jsx_runtime_1.jsx)("div", { "aria-label": label, className: 'grid gap-3 sm:grid-cols-2', role: 'radiogroup', children: options.map((option) => {
|
|
7
|
+
const isSelected = option.value === value;
|
|
8
|
+
return ((0, jsx_runtime_1.jsxs)("button", { "aria-checked": isSelected, className: ps_design_system_1.PallasoftClassNameService.merge('ps-focus-ring flex flex-col gap-1 rounded-ps-card border px-4 py-3 text-left transition-colors', isSelected
|
|
9
|
+
? 'border-primary bg-primary/5 ring-2 ring-primary/25'
|
|
10
|
+
: 'border-line hover:border-primary/40'), onClick: () => onChange(option.value), role: 'radio', type: 'button', children: [(0, jsx_runtime_1.jsx)("span", { className: 'text-sm font-semibold text-ink', children: option.label }), (0, jsx_runtime_1.jsx)("span", { className: 'text-xs text-ink/60', children: option.description })] }, option.value));
|
|
11
|
+
}) }));
|
|
12
|
+
exports.PsOptionCardGroup = PsOptionCardGroup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
|
|
3
|
+
export const PsOptionCardGroup = ({ label, onChange, options, value }) => (_jsx("div", { "aria-label": label, className: 'grid gap-3 sm:grid-cols-2', role: 'radiogroup', children: options.map((option) => {
|
|
4
|
+
const isSelected = option.value === value;
|
|
5
|
+
return (_jsxs("button", { "aria-checked": isSelected, className: PallasoftClassNameService.merge('ps-focus-ring flex flex-col gap-1 rounded-ps-card border px-4 py-3 text-left transition-colors', isSelected
|
|
6
|
+
? 'border-primary bg-primary/5 ring-2 ring-primary/25'
|
|
7
|
+
: 'border-line hover:border-primary/40'), onClick: () => onChange(option.value), role: 'radio', type: 'button', children: [_jsx("span", { className: 'text-sm font-semibold text-ink', children: option.label }), _jsx("span", { className: 'text-xs text-ink/60', children: option.description })] }, option.value));
|
|
8
|
+
}) }));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { PsFormModal } from '@pallasoft/ps-popovers';
|
|
4
|
+
import { useForm } from 'react-hook-form';
|
|
5
|
+
import { PsFormTextField } from './ps-form-text-field';
|
|
6
|
+
export const PsFormNameModal = ({ cancelLabel, initialName, isOpen, isSubmitting = false, label, maxLength = 80, onClose, onSave, placeholder, requiredMessage, submitLabel, title, }) => {
|
|
7
|
+
const { control, formState: { isDirty, isValid }, handleSubmit, reset, } = useForm({ mode: 'onChange' });
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (isOpen)
|
|
10
|
+
reset({ name: initialName });
|
|
11
|
+
}, [initialName, isOpen, reset]);
|
|
12
|
+
return (_jsx(PsFormModal, { cancelLabel: cancelLabel, isOpen: isOpen, isSubmitDisabled: !isValid || (initialName !== '' && !isDirty), isSubmitting: isSubmitting, onClose: onClose, onSubmit: handleSubmit((values) => onSave(values.name.trim())), size: 'sm', submitLabel: submitLabel, title: title, children: _jsx(PsFormTextField, { control: control, label: label, maxLength: maxLength, name: 'name', placeholder: placeholder, rules: {
|
|
13
|
+
required: requiredMessage,
|
|
14
|
+
validate: (value) => value.trim() !== '' || requiredMessage,
|
|
15
|
+
} }) }));
|
|
16
|
+
};
|
package/dist/esm/form/index.js
CHANGED
|
@@ -9,3 +9,5 @@ export * from './components/ps-form-year-field';
|
|
|
9
9
|
export * from './constants/ps-form-text-kind';
|
|
10
10
|
export * from './models/ps-form-field-rules';
|
|
11
11
|
export * from './services/ps-form-field-service';
|
|
12
|
+
export * from './components/ps-form-name-modal';
|
|
13
|
+
export * from './models/ps-form-name-data';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -47,3 +47,5 @@ export * from './constants/ps-select-with-create-config';
|
|
|
47
47
|
export * from './interfaces/ps-date-preset-data';
|
|
48
48
|
export * from './components/ps-portable-text-editor';
|
|
49
49
|
export * from './interfaces/ps-portable-text-editor-labels';
|
|
50
|
+
export * from './components/ps-option-card-group';
|
|
51
|
+
export * from './interfaces/ps-option-card-data';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PsFormNameModalProps {
|
|
2
|
+
cancelLabel: string;
|
|
3
|
+
initialName: string;
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
isSubmitting?: boolean;
|
|
6
|
+
label: string;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
onSave: (name: string) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
requiredMessage: string;
|
|
12
|
+
submitLabel: string;
|
|
13
|
+
title: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const PsFormNameModal: ({ cancelLabel, initialName, isOpen, isSubmitting, label, maxLength, onClose, onSave, placeholder, requiredMessage, submitLabel, title, }: PsFormNameModalProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsFormNameModal = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ps_popovers_1 = require("@pallasoft/ps-popovers");
|
|
7
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
8
|
+
const ps_form_text_field_1 = require("./ps-form-text-field");
|
|
9
|
+
const PsFormNameModal = ({ cancelLabel, initialName, isOpen, isSubmitting = false, label, maxLength = 80, onClose, onSave, placeholder, requiredMessage, submitLabel, title, }) => {
|
|
10
|
+
const { control, formState: { isDirty, isValid }, handleSubmit, reset, } = (0, react_hook_form_1.useForm)({ mode: 'onChange' });
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
if (isOpen)
|
|
13
|
+
reset({ name: initialName });
|
|
14
|
+
}, [initialName, isOpen, reset]);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(ps_popovers_1.PsFormModal, { cancelLabel: cancelLabel, isOpen: isOpen, isSubmitDisabled: !isValid || (initialName !== '' && !isDirty), isSubmitting: isSubmitting, onClose: onClose, onSubmit: handleSubmit((values) => onSave(values.name.trim())), size: 'sm', submitLabel: submitLabel, title: title, children: (0, jsx_runtime_1.jsx)(ps_form_text_field_1.PsFormTextField, { control: control, label: label, maxLength: maxLength, name: 'name', placeholder: placeholder, rules: {
|
|
16
|
+
required: requiredMessage,
|
|
17
|
+
validate: (value) => value.trim() !== '' || requiredMessage,
|
|
18
|
+
} }) }));
|
|
19
|
+
};
|
|
20
|
+
exports.PsFormNameModal = PsFormNameModal;
|
package/dist/form/index.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ export * from './components/ps-form-year-field';
|
|
|
9
9
|
export * from './constants/ps-form-text-kind';
|
|
10
10
|
export * from './models/ps-form-field-rules';
|
|
11
11
|
export * from './services/ps-form-field-service';
|
|
12
|
+
export * from './components/ps-form-name-modal';
|
|
13
|
+
export * from './models/ps-form-name-data';
|
package/dist/form/index.js
CHANGED
|
@@ -25,3 +25,5 @@ __exportStar(require("./components/ps-form-year-field"), exports);
|
|
|
25
25
|
__exportStar(require("./constants/ps-form-text-kind"), exports);
|
|
26
26
|
__exportStar(require("./models/ps-form-field-rules"), exports);
|
|
27
27
|
__exportStar(require("./services/ps-form-field-service"), exports);
|
|
28
|
+
__exportStar(require("./components/ps-form-name-modal"), exports);
|
|
29
|
+
__exportStar(require("./models/ps-form-name-data"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -48,3 +48,5 @@ export * from './interfaces/ps-date-preset-data';
|
|
|
48
48
|
export * from './components/ps-portable-text-editor';
|
|
49
49
|
export * from './interfaces/ps-portable-text-editor-labels';
|
|
50
50
|
export type { PortableTextBlock } from '@portabletext/editor';
|
|
51
|
+
export * from './components/ps-option-card-group';
|
|
52
|
+
export * from './interfaces/ps-option-card-data';
|
package/dist/index.js
CHANGED
|
@@ -63,3 +63,5 @@ __exportStar(require("./constants/ps-select-with-create-config"), exports);
|
|
|
63
63
|
__exportStar(require("./interfaces/ps-date-preset-data"), exports);
|
|
64
64
|
__exportStar(require("./components/ps-portable-text-editor"), exports);
|
|
65
65
|
__exportStar(require("./interfaces/ps-portable-text-editor-labels"), exports);
|
|
66
|
+
__exportStar(require("./components/ps-option-card-group"), exports);
|
|
67
|
+
__exportStar(require("./interfaces/ps-option-card-data"), exports);
|