@pallasoft/ps-input-components 1.10.0 → 1.11.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-cascader-input.d.ts +2 -1
- package/dist/components/ps-cascader-input.js +5 -4
- package/dist/components/ps-color-input.d.ts +2 -1
- package/dist/components/ps-color-input.js +3 -2
- package/dist/components/ps-combobox-input.d.ts +2 -1
- package/dist/components/ps-combobox-input.js +3 -2
- package/dist/components/ps-date-input.js +2 -1
- package/dist/components/ps-email-input.d.ts +3 -0
- package/dist/components/ps-email-input.js +17 -0
- package/dist/components/ps-multi-select-input.js +3 -2
- package/dist/components/ps-percent-input.d.ts +3 -0
- package/dist/components/ps-percent-input.js +16 -0
- package/dist/components/ps-phone-input.d.ts +14 -0
- package/dist/components/ps-phone-input.js +55 -0
- package/dist/components/ps-postal-code-input.d.ts +5 -0
- package/dist/components/ps-postal-code-input.js +14 -0
- package/dist/components/ps-required-mark.d.ts +4 -0
- package/dist/components/ps-required-mark.js +6 -0
- package/dist/components/ps-select-input.js +2 -1
- package/dist/components/ps-text-area-input.d.ts +1 -1
- package/dist/components/ps-text-area-input.js +2 -1
- package/dist/components/ps-text-input.js +2 -1
- package/dist/components/ps-url-input.d.ts +3 -0
- package/dist/components/ps-url-input.js +17 -0
- package/dist/constants/ps-phone-input-config.d.ts +10 -0
- package/dist/constants/ps-phone-input-config.js +13 -0
- package/dist/constants/ps-postal-code-formats.d.ts +5 -0
- package/dist/constants/ps-postal-code-formats.js +13 -0
- package/dist/constants/ps-text-format-config.d.ts +6 -0
- package/dist/constants/ps-text-format-config.js +9 -0
- package/dist/esm/components/ps-amount-input.js +10 -0
- package/dist/esm/components/ps-calendar-header.js +5 -0
- package/dist/esm/components/ps-cascader-input.js +45 -0
- package/dist/esm/components/ps-checkbox.js +7 -0
- package/dist/esm/components/ps-color-input.js +16 -0
- package/dist/esm/components/ps-color-picker.js +60 -0
- package/dist/esm/components/ps-combobox-input.js +10 -0
- package/dist/esm/components/ps-date-input.js +35 -0
- package/dist/esm/components/ps-dropdown.js +3 -0
- package/dist/esm/components/ps-email-input.js +13 -0
- package/dist/esm/components/ps-file-picker.js +27 -0
- package/dist/esm/components/ps-form-control.js +3 -0
- package/dist/esm/components/ps-multi-select-input.js +23 -0
- package/dist/esm/components/ps-percent-input.js +12 -0
- package/dist/esm/components/ps-phone-input.js +51 -0
- package/dist/esm/components/ps-postal-code-input.js +10 -0
- package/dist/esm/components/ps-required-mark.js +2 -0
- package/dist/esm/components/ps-select-input.js +22 -0
- package/dist/esm/components/ps-select-option-item.js +4 -0
- package/dist/esm/components/ps-text-area-input.js +4 -0
- package/dist/esm/components/ps-text-input.js +12 -0
- package/dist/esm/components/ps-toggle.js +3 -0
- package/dist/esm/components/ps-url-input.js +13 -0
- package/dist/esm/constants/ps-amount-input-config.js +7 -0
- package/dist/esm/constants/ps-color-input-config.js +13 -0
- package/dist/esm/constants/ps-date-input-config.js +8 -0
- package/dist/esm/constants/ps-phone-input-config.js +10 -0
- package/dist/esm/constants/ps-postal-code-formats.js +10 -0
- package/dist/esm/constants/ps-text-format-config.js +6 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/interfaces/color-hsv.js +1 -0
- package/dist/esm/interfaces/ps-highlight-part.js +1 -0
- package/dist/esm/interfaces/ps-phone-country-option.js +1 -0
- package/dist/esm/interfaces/ps-phone-display-data.js +1 -0
- package/dist/esm/interfaces/ps-postal-code-format.js +1 -0
- package/dist/esm/services/ps-amount-input-service.js +25 -0
- package/dist/esm/services/ps-cascader-service.js +22 -0
- package/dist/esm/services/ps-color-service.js +73 -0
- package/dist/esm/services/ps-combobox-input-service.js +6 -0
- package/dist/esm/services/ps-date-input-service.js +24 -0
- package/dist/esm/services/ps-phone-input-service.js +77 -0
- package/dist/esm/services/ps-postal-code-service.js +28 -0
- package/dist/esm/services/ps-select-input-service.js +8 -0
- package/dist/esm/services/ps-text-format-service.js +12 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/interfaces/ps-highlight-part.d.ts +4 -0
- package/dist/interfaces/ps-highlight-part.js +2 -0
- package/dist/interfaces/ps-phone-country-option.d.ts +5 -0
- package/dist/interfaces/ps-phone-country-option.js +2 -0
- package/dist/interfaces/ps-phone-display-data.d.ts +4 -0
- package/dist/interfaces/ps-phone-display-data.js +2 -0
- package/dist/interfaces/ps-postal-code-format.d.ts +5 -0
- package/dist/interfaces/ps-postal-code-format.js +2 -0
- package/dist/services/ps-phone-input-service.d.ts +15 -0
- package/dist/services/ps-phone-input-service.js +81 -0
- package/dist/services/ps-postal-code-service.d.ts +4 -0
- package/dist/services/ps-postal-code-service.js +32 -0
- package/dist/services/ps-text-format-service.d.ts +4 -0
- package/dist/services/ps-text-format-service.js +16 -0
- package/package.json +6 -2
|
@@ -17,7 +17,8 @@ export interface PsCascaderInputProps {
|
|
|
17
17
|
label: string;
|
|
18
18
|
onChange: (value: string) => void;
|
|
19
19
|
placeholder?: string;
|
|
20
|
+
required?: boolean;
|
|
20
21
|
searchPlaceholder?: string;
|
|
21
22
|
value: string;
|
|
22
23
|
}
|
|
23
|
-
export declare const PsCascaderInput: ({ className, disabled, groups, helperText, hideLabel, label, onChange, placeholder, searchPlaceholder, value, }: PsCascaderInputProps) => import("react").JSX.Element;
|
|
24
|
+
export declare const PsCascaderInput: ({ className, disabled, groups, helperText, hideLabel, label, onChange, placeholder, required, searchPlaceholder, value, }: PsCascaderInputProps) => import("react").JSX.Element;
|
|
@@ -8,7 +8,8 @@ const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
|
8
8
|
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
9
9
|
const react_aria_components_1 = require("react-aria-components");
|
|
10
10
|
const ps_cascader_service_1 = require("../services/ps-cascader-service");
|
|
11
|
-
const
|
|
11
|
+
const ps_required_mark_1 = require("./ps-required-mark");
|
|
12
|
+
const PsCascaderInput = ({ className, disabled, groups, helperText, hideLabel, label, onChange, placeholder = 'Select an option', required, searchPlaceholder = 'Search', value, }) => {
|
|
12
13
|
const zIndex = (0, ps_core_components_1.usePsLayerZIndex)(ps_design_system_1.PallasoftZIndex.Dropdown);
|
|
13
14
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
14
15
|
const [query, setQuery] = (0, react_1.useState)('');
|
|
@@ -39,10 +40,10 @@ const PsCascaderInput = ({ className, disabled, groups, helperText, hideLabel, l
|
|
|
39
40
|
const renderOption = (option, groupLabel, close) => ((0, jsx_runtime_1.jsxs)("button", { "aria-selected": option.value === value, className: ps_design_system_1.PallasoftClassNameService.merge('ps-focus-ring flex w-full items-start gap-2 rounded-ps-control px-3 py-2.5 text-left text-sm font-medium transition-colors', option.value === value
|
|
40
41
|
? 'bg-primary/10 text-ink'
|
|
41
42
|
: 'text-ink/80 hover:bg-mist/60 hover:text-ink'), onClick: () => select(option.value, close), role: 'option', type: 'button', children: [(0, jsx_runtime_1.jsx)("span", { className: 'flex h-5 w-4 shrink-0 items-center justify-center text-primary', children: option.value === value ? ((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 }), groupLabel ? ((0, jsx_runtime_1.jsx)("span", { className: 'mt-0.5 block truncate text-xs font-normal text-ink/50', children: groupLabel })) : null, option.description ? ((0, jsx_runtime_1.jsx)("span", { className: 'mt-0.5 block truncate text-xs font-normal text-ink/55', children: option.description })) : null] })] }, option.value));
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), children: [hideLabel ? null : (0, jsx_runtime_1.
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), children: [hideLabel ? null : ((0, jsx_runtime_1.jsxs)("span", { className: 'ps-input-label block', children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] })), (0, jsx_runtime_1.jsxs)(react_aria_components_1.DialogTrigger, { isOpen: isOpen, onOpenChange: open, children: [(0, jsx_runtime_1.jsxs)(react_aria_components_1.Button, { "aria-label": hideLabel ? label : undefined, 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'), isDisabled: disabled, children: [(0, jsx_runtime_1.jsx)("span", { className: 'min-w-0 flex-1 truncate', children: selected ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: 'truncate', children: selected.option.label }), (0, jsx_runtime_1.jsx)("span", { className: 'ml-2 text-xs font-medium text-ink/45', children: selected.group.label })] })) : ((0, jsx_runtime_1.jsx)("span", { className: 'font-medium text-ink/45', children: placeholder })) }), (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-primary', iconKey: ps_icons_1.PsIconKey.Chevron })] }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Popover, { className: 'ps-floating-panel w-[min(calc(100vw-2rem),32rem)] min-w-[var(--trigger-width)] outline-none', offset: 6, placement: 'bottom start', style: { zIndex }, children: (0, jsx_runtime_1.jsx)(react_aria_components_1.Dialog, { "aria-label": label, className: 'flex flex-col outline-none', children: ({ close }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: 'border-b border-line p-2', children: (0, jsx_runtime_1.jsx)("input", { "aria-label": searchPlaceholder, autoFocus: true, className: 'ps-input-control ps-focus-ring h-10 w-full text-sm', onChange: (event) => setQuery(event.target.value), placeholder: searchPlaceholder, type: 'search', value: query }) }), query.trim() === '' ? ((0, jsx_runtime_1.jsxs)("div", { className: 'grid grid-cols-1 sm:grid-cols-[minmax(0,11rem)_minmax(0,1fr)]', children: [(0, jsx_runtime_1.jsx)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-scrollbar-hidden max-h-72 overflow-y-auto p-1.5 sm:border-r sm:border-line', activeGroupKey && groups.length > 1 ? 'hidden sm:block' : ''), children: groups.map((group) => ((0, jsx_runtime_1.jsxs)("button", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-focus-ring flex w-full items-center gap-2 rounded-ps-control px-3 py-2.5 text-left text-sm font-semibold transition-colors', activeGroup?.key === group.key
|
|
43
44
|
? 'bg-mist text-ink'
|
|
44
|
-
: 'text-ink/70 hover:bg-mist/60 hover:text-ink'), onClick: () => setActiveGroupKey(group.key), type: 'button', children: [(0, jsx_runtime_1.jsx)("span", { className: 'min-w-0 flex-1 truncate', children: group.label }), (0, jsx_runtime_1.jsx)("span", { className: 'text-xs font-medium text-ink/45', children: group.options.length }), (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 shrink-0 -rotate-90 text-ink/35', iconKey: ps_icons_1.PsIconKey.Chevron })] }, group.key))) }), (0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-scrollbar max-h-72 overflow-y-auto p-1.5', activeGroupKey && groups.length > 1 ? '' : 'hidden sm:block'), role: 'listbox', children: [groups.length > 1 ? ((0, jsx_runtime_1.jsxs)("button", { className: 'ps-focus-ring mb-1 flex w-full items-center gap-2 rounded-ps-control px-3 py-2 text-left text-xs font-semibold text-ink/60 hover:text-ink sm:hidden', onClick: () => setActiveGroupKey(null), type: 'button', children: [(0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 rotate-90', iconKey: ps_icons_1.PsIconKey.Chevron }), "All groups"] })) : null, activeGroup
|
|
45
|
+
: 'text-ink/70 hover:bg-mist/60 hover:text-ink'), onClick: () => setActiveGroupKey(group.key), type: 'button', children: [(0, jsx_runtime_1.jsx)("span", { className: 'min-w-0 flex-1 truncate', children: group.label }), (0, jsx_runtime_1.jsx)("span", { className: 'text-xs font-medium text-ink/45', children: group.options.length }), (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 shrink-0 -rotate-90 text-ink/35', iconKey: ps_icons_1.PsIconKey.Chevron })] }, group.key))) }), (0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-scrollbar-hidden max-h-72 overflow-y-auto p-1.5', activeGroupKey && groups.length > 1 ? '' : 'hidden sm:block'), role: 'listbox', children: [groups.length > 1 ? ((0, jsx_runtime_1.jsxs)("button", { className: 'ps-focus-ring mb-1 flex w-full items-center gap-2 rounded-ps-control px-3 py-2 text-left text-xs font-semibold text-ink/60 hover:text-ink sm:hidden', onClick: () => setActiveGroupKey(null), type: 'button', children: [(0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 rotate-90', iconKey: ps_icons_1.PsIconKey.Chevron }), "All groups"] })) : null, activeGroup
|
|
45
46
|
? activeGroup.options.map((option) => renderOption(option, null, close))
|
|
46
|
-
: null] })] })) : ((0, jsx_runtime_1.jsx)("div", { className: 'ps-scrollbar max-h-72 overflow-y-auto p-1.5', role: 'listbox', children: matches.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: 'px-3 py-6 text-center text-sm text-ink/55', children: "No matches." })) : (matches.map((match) => renderOption(match.option, match.group.label, close))) }))] })) }) })] }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper mt-2 block', children: helperText }) : null] }));
|
|
47
|
+
: null] })] })) : ((0, jsx_runtime_1.jsx)("div", { className: 'ps-scrollbar-hidden max-h-72 overflow-y-auto p-1.5', role: 'listbox', children: matches.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: 'px-3 py-6 text-center text-sm text-ink/55', children: "No matches." })) : (matches.map((match) => renderOption(match.option, match.group.label, close))) }))] })) }) })] }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper mt-2 block', children: helperText }) : null] }));
|
|
47
48
|
};
|
|
48
49
|
exports.PsCascaderInput = PsCascaderInput;
|
|
@@ -3,7 +3,8 @@ export interface PsColorInputProps {
|
|
|
3
3
|
helperText?: string;
|
|
4
4
|
label: string;
|
|
5
5
|
onChange: (value: string) => void;
|
|
6
|
+
required?: boolean;
|
|
6
7
|
swatches?: string[];
|
|
7
8
|
value: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const PsColorInput: ({ className, helperText, label, onChange, swatches, value, }: PsColorInputProps) => import("react").JSX.Element;
|
|
10
|
+
export declare const PsColorInput: ({ className, helperText, label, onChange, required, swatches, value, }: PsColorInputProps) => import("react").JSX.Element;
|
|
@@ -7,11 +7,12 @@ const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
|
7
7
|
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
8
8
|
const ps_color_input_config_1 = require("../constants/ps-color-input-config");
|
|
9
9
|
const ps_color_picker_1 = require("./ps-color-picker");
|
|
10
|
-
const
|
|
10
|
+
const ps_required_mark_1 = require("./ps-required-mark");
|
|
11
|
+
const PsColorInput = ({ className, helperText, label, onChange, required, swatches = [...ps_color_input_config_1.PsColorInputConfig.swatches], value, }) => {
|
|
11
12
|
const labelId = (0, react_1.useId)();
|
|
12
13
|
const swatchesId = (0, react_1.useId)();
|
|
13
14
|
const normalised = value.toUpperCase();
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('flex flex-col gap-2', className), children: [(0, jsx_runtime_1.
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('flex flex-col gap-2', className), children: [(0, jsx_runtime_1.jsxs)("span", { className: 'ps-input-label', id: labelId, children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] }), (0, jsx_runtime_1.jsxs)("div", { className: 'flex flex-col gap-4 rounded-ps-control border border-line bg-surface p-4', children: [(0, jsx_runtime_1.jsx)(ps_color_picker_1.PsColorPicker, { hideLabel: true, label: `${label} picker`, onChange: onChange, swatches: swatches, value: value }), (0, jsx_runtime_1.jsxs)("div", { className: 'flex flex-col gap-2 border-t border-line pt-4', children: [(0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', id: swatchesId, children: "Presets" }), (0, jsx_runtime_1.jsx)("div", { "aria-labelledby": swatchesId, className: 'flex flex-wrap gap-2', role: 'radiogroup', children: swatches.map((swatch) => {
|
|
15
16
|
const isSelected = swatch.toUpperCase() === normalised;
|
|
16
17
|
return ((0, jsx_runtime_1.jsx)("button", { "aria-checked": isSelected, "aria-label": swatch, className: ps_design_system_1.PallasoftClassNameService.merge('ps-focus-ring flex h-8 w-8 items-center justify-center rounded-full text-white ring-offset-2 ring-offset-surface transition-shadow', isSelected ? 'ring-2 ring-ink/70' : 'hover:ring-2 hover:ring-ink/25'), onClick: () => onChange(swatch.toUpperCase()), role: 'radio', style: { backgroundColor: swatch }, type: 'button', 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 }, swatch));
|
|
17
18
|
}) })] })] }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
|
|
@@ -10,5 +10,6 @@ export interface PsComboboxInputProps<T> {
|
|
|
10
10
|
onSelectionChange?: (item: T | null) => void;
|
|
11
11
|
placeholder?: string;
|
|
12
12
|
renderItem?: (item: T) => ReactNode;
|
|
13
|
+
required?: boolean;
|
|
13
14
|
}
|
|
14
|
-
export declare const PsComboboxInput: <T>({ className, getItemKey, getItemLabel, isLoading, items, label, onInputChange, onSelectionChange, placeholder, renderItem, }: PsComboboxInputProps<T>) => import("react").JSX.Element;
|
|
15
|
+
export declare const PsComboboxInput: <T>({ className, getItemKey, getItemLabel, isLoading, items, label, onInputChange, onSelectionChange, placeholder, renderItem, required, }: PsComboboxInputProps<T>) => import("react").JSX.Element;
|
|
@@ -6,8 +6,9 @@ const ps_core_components_1 = require("@pallasoft/ps-core-components");
|
|
|
6
6
|
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
7
7
|
const react_aria_components_1 = require("react-aria-components");
|
|
8
8
|
const ps_combobox_input_service_1 = require("../services/ps-combobox-input-service");
|
|
9
|
-
const
|
|
9
|
+
const ps_required_mark_1 = require("./ps-required-mark");
|
|
10
|
+
const PsComboboxInput = ({ className, getItemKey, getItemLabel, isLoading = false, items, label, onInputChange, onSelectionChange, placeholder, renderItem, required, }) => {
|
|
10
11
|
const itemsByKey = new Map(items.map((item) => [getItemKey(item), item]));
|
|
11
|
-
return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ComboBox, { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), defaultFilter: () => true, items: items, onInputChange: onInputChange, onSelectionChange: (key) => onSelectionChange?.(key === null ? null : ps_combobox_input_service_1.PsComboboxInputService.getItem(itemsByKey, key)), children: [label ? (0, jsx_runtime_1.
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ComboBox, { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), defaultFilter: () => true, items: items, onInputChange: onInputChange, onSelectionChange: (key) => onSelectionChange?.(key === null ? null : ps_combobox_input_service_1.PsComboboxInputService.getItem(itemsByKey, key)), children: [label ? ((0, jsx_runtime_1.jsxs)(react_aria_components_1.Label, { className: 'ps-input-label', children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] })) : null, (0, jsx_runtime_1.jsx)("span", { className: 'relative mt-2 block', children: (0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { className: 'ps-input-control ps-focus-ring min-h-11 w-full text-sm font-semibold', placeholder: placeholder }) }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Popover, { className: 'w-[--trigger-width] rounded-2xl border border-line bg-white/95 p-1.5 shadow-lg dark:border-white/10 dark:bg-slate-900/95', children: isLoading ? ((0, jsx_runtime_1.jsx)("div", { className: 'flex items-center justify-center py-4', children: (0, jsx_runtime_1.jsx)(ps_core_components_1.PsSpinner, { label: 'Loading results', size: 'small' }) })) : ((0, jsx_runtime_1.jsx)(react_aria_components_1.ListBox, { className: 'max-h-72 overflow-y-auto outline-none', items: items, children: (item) => ((0, jsx_runtime_1.jsx)(react_aria_components_1.ListBoxItem, { className: 'ps-focus-ring cursor-pointer rounded-xl px-3 py-2 text-sm font-semibold text-ink selected:bg-primary-soft selected:text-primary hover:bg-slate-50 dark:hover:bg-white/6', id: getItemKey(item), textValue: getItemLabel(item), children: renderItem ? renderItem(item) : getItemLabel(item) })) })) })] }));
|
|
12
13
|
};
|
|
13
14
|
exports.PsComboboxInput = PsComboboxInput;
|
|
@@ -13,6 +13,7 @@ const react_datepicker_1 = __importDefault(require("react-datepicker"));
|
|
|
13
13
|
const ps_date_input_config_1 = require("../constants/ps-date-input-config");
|
|
14
14
|
const ps_date_input_service_1 = require("../services/ps-date-input-service");
|
|
15
15
|
const ps_calendar_header_1 = require("./ps-calendar-header");
|
|
16
|
+
const ps_required_mark_1 = require("./ps-required-mark");
|
|
16
17
|
const PsDateInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, max, min, name, onChange, placeholder = ps_date_input_config_1.PsDateInputConfig.placeholder, required, value, }) => {
|
|
17
18
|
const inputId = (0, react_1.useId)();
|
|
18
19
|
const portalId = `${ps_date_input_config_1.PsDateInputConfig.portalId}-${inputId.replace(/:/g, '')}`;
|
|
@@ -36,6 +37,6 @@ const PsDateInput = ({ className, defaultValue, disabled, helperText, hideLabel,
|
|
|
36
37
|
setUncontrolledValue(nextValue);
|
|
37
38
|
onChange?.(nextValue);
|
|
38
39
|
};
|
|
39
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('block', className), children: [(0, jsx_runtime_1.
|
|
40
|
+
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', 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', popperProps: { strategy: 'fixed' }, portalId: 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] }));
|
|
40
41
|
};
|
|
41
42
|
exports.PsDateInput = PsDateInput;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsEmailInput = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_text_format_service_1 = require("../services/ps-text-format-service");
|
|
6
|
+
const ps_text_input_1 = require("./ps-text-input");
|
|
7
|
+
const PsEmailInput = ({ onBlur, onChange, ...props }) => ((0, jsx_runtime_1.jsx)(ps_text_input_1.PsTextInput, { ...props, autoCapitalize: 'none', autoComplete: 'email', inputMode: 'email', onBlur: (event) => {
|
|
8
|
+
const formatted = ps_text_format_service_1.PsTextFormatService.email(event.target.value);
|
|
9
|
+
if (formatted !== event.target.value) {
|
|
10
|
+
event.target.value = formatted;
|
|
11
|
+
if (onChange)
|
|
12
|
+
onChange(event);
|
|
13
|
+
}
|
|
14
|
+
if (onBlur)
|
|
15
|
+
onBlur(event);
|
|
16
|
+
}, onChange: onChange, spellCheck: false, type: 'email' }));
|
|
17
|
+
exports.PsEmailInput = PsEmailInput;
|
|
@@ -7,6 +7,7 @@ const ps_core_components_1 = require("@pallasoft/ps-core-components");
|
|
|
7
7
|
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
8
8
|
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
9
9
|
const react_aria_components_1 = require("react-aria-components");
|
|
10
|
+
const ps_required_mark_1 = require("./ps-required-mark");
|
|
10
11
|
const ps_select_option_item_1 = require("./ps-select-option-item");
|
|
11
12
|
const PsMultiSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder = 'Select options', required, value, }) => {
|
|
12
13
|
const [uncontrolledValue, setUncontrolledValue] = (0, react_1.useState)(defaultValue === undefined ? [] : defaultValue);
|
|
@@ -19,8 +20,8 @@ const PsMultiSelectInput = ({ className, defaultValue, disabled, helperText, hid
|
|
|
19
20
|
setUncontrolledValue(nextValue);
|
|
20
21
|
onChange?.(nextValue);
|
|
21
22
|
};
|
|
22
|
-
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.
|
|
23
|
+
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.jsxs)(react_aria_components_1.Label, { className: 'ps-input-label block', children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] })), (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
|
|
23
24
|
.filter((selected) => labelByValue.has(selected))
|
|
24
|
-
.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', style: { zIndex }, 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 }) }) })] }));
|
|
25
|
+
.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-hidden max-h-72 min-w-[var(--trigger-width)] overflow-y-auto p-1.5 outline-none', offset: 6, placement: 'bottom start', style: { zIndex }, 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 }) }) })] }));
|
|
25
26
|
};
|
|
26
27
|
exports.PsMultiSelectInput = PsMultiSelectInput;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsPercentInput = 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_text_format_config_1 = require("../constants/ps-text-format-config");
|
|
7
|
+
const ps_amount_input_service_1 = require("../services/ps-amount-input-service");
|
|
8
|
+
const ps_text_input_1 = require("./ps-text-input");
|
|
9
|
+
const PsPercentInput = ({ className, onChange, ...props }) => ((0, jsx_runtime_1.jsxs)("div", { className: 'relative', children: [(0, jsx_runtime_1.jsx)(ps_text_input_1.PsTextInput, { ...props, autoComplete: 'off', className: ps_design_system_1.PallasoftClassNameService.merge('pr-8', className), inputMode: 'decimal', onChange: (event) => {
|
|
10
|
+
const normalised = ps_amount_input_service_1.PsAmountInputService.normalise(event.target.value);
|
|
11
|
+
if (normalised !== event.target.value)
|
|
12
|
+
event.target.value = normalised;
|
|
13
|
+
if (onChange)
|
|
14
|
+
onChange(event);
|
|
15
|
+
}, type: 'text' }), (0, jsx_runtime_1.jsx)("span", { "aria-hidden": 'true', className: 'pointer-events-none absolute right-3 bottom-3 text-sm text-ink/50', children: ps_text_format_config_1.PsTextFormatConfig.percentSuffix })] }));
|
|
16
|
+
exports.PsPercentInput = PsPercentInput;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PsPhoneInputProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
defaultCountry?: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
helperText?: string;
|
|
6
|
+
hideLabel?: boolean;
|
|
7
|
+
label: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
onBlur?: () => void;
|
|
10
|
+
onChange: (value: string) => void;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const PsPhoneInput: ({ className, defaultCountry, disabled, helperText, hideLabel, label, name, onBlur, onChange, required, value, }: PsPhoneInputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsPhoneInput = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ps_core_components_1 = require("@pallasoft/ps-core-components");
|
|
7
|
+
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
8
|
+
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
9
|
+
const react_aria_components_1 = require("react-aria-components");
|
|
10
|
+
const ps_phone_input_config_1 = require("../constants/ps-phone-input-config");
|
|
11
|
+
const ps_phone_input_service_1 = require("../services/ps-phone-input-service");
|
|
12
|
+
const ps_required_mark_1 = require("./ps-required-mark");
|
|
13
|
+
const PsPhoneInput = ({ className, defaultCountry = ps_phone_input_config_1.PsPhoneInputConfig.defaultCountry, disabled, helperText, hideLabel, label, name, onBlur, onChange, required, value, }) => {
|
|
14
|
+
const inputId = (0, react_1.useId)();
|
|
15
|
+
const zIndex = (0, ps_core_components_1.usePsLayerZIndex)(ps_design_system_1.PallasoftZIndex.Dropdown);
|
|
16
|
+
const initial = ps_phone_input_service_1.PsPhoneInputService.display(value, defaultCountry);
|
|
17
|
+
const [country, setCountry] = (0, react_1.useState)(initial.country);
|
|
18
|
+
const [national, setNational] = (0, react_1.useState)(initial.national);
|
|
19
|
+
const [isTouched, setIsTouched] = (0, react_1.useState)(false);
|
|
20
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
21
|
+
const [query, setQuery] = (0, react_1.useState)('');
|
|
22
|
+
const countries = (0, react_1.useMemo)(() => ps_phone_input_service_1.PsPhoneInputService.countries(defaultCountry), [defaultCountry]);
|
|
23
|
+
const matches = (0, react_1.useMemo)(() => ps_phone_input_service_1.PsPhoneInputService.search(countries, query), [countries, query]);
|
|
24
|
+
(0, react_1.useEffect)(() => {
|
|
25
|
+
if (ps_phone_input_service_1.PsPhoneInputService.toStored(national, country) === value)
|
|
26
|
+
return;
|
|
27
|
+
const next = ps_phone_input_service_1.PsPhoneInputService.display(value, country);
|
|
28
|
+
setCountry(next.country);
|
|
29
|
+
setNational(next.national);
|
|
30
|
+
}, [value]);
|
|
31
|
+
const emit = (nextNational, nextCountry) => onChange(ps_phone_input_service_1.PsPhoneInputService.toStored(nextNational, nextCountry));
|
|
32
|
+
const isInvalid = isTouched && !ps_phone_input_service_1.PsPhoneInputService.isValid(national, country);
|
|
33
|
+
const choose = (code) => {
|
|
34
|
+
setCountry(code);
|
|
35
|
+
setIsOpen(false);
|
|
36
|
+
setQuery('');
|
|
37
|
+
emit(national, code);
|
|
38
|
+
document.getElementById(inputId)?.focus();
|
|
39
|
+
};
|
|
40
|
+
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', htmlFor: inputId, children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] }), (0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-input-control flex min-h-11 items-stretch overflow-hidden p-0 focus-within:border-primary', hideLabel ? '' : 'mt-2', isInvalid ? 'border-danger bg-danger/5' : '', disabled ? 'opacity-60' : ''), children: [(0, jsx_runtime_1.jsxs)(react_aria_components_1.DialogTrigger, { isOpen: isOpen, onOpenChange: setIsOpen, children: [(0, jsx_runtime_1.jsxs)(react_aria_components_1.Button, { "aria-label": ps_phone_input_config_1.PsPhoneInputConfig.countryLabel, className: 'ps-focus-ring flex shrink-0 items-center gap-1.5 border-r border-line px-3 text-sm font-semibold text-ink', isDisabled: disabled, children: [country, (0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { "aria-hidden": 'true', className: 'block h-3.5 w-3.5 text-ink/45', iconKey: ps_icons_1.PsIconKey.Chevron })] }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Popover, { className: 'ps-floating-panel w-72 outline-none', offset: 6, placement: 'bottom start', style: { zIndex }, children: (0, jsx_runtime_1.jsxs)(react_aria_components_1.Dialog, { "aria-label": ps_phone_input_config_1.PsPhoneInputConfig.countryLabel, className: 'flex flex-col outline-none', children: [(0, jsx_runtime_1.jsx)("div", { className: 'border-b border-line p-2', children: (0, jsx_runtime_1.jsx)("input", { "aria-label": ps_phone_input_config_1.PsPhoneInputConfig.searchPlaceholder, autoFocus: true, className: 'ps-input-control ps-focus-ring h-10 w-full text-sm', onChange: (event) => setQuery(event.target.value), placeholder: ps_phone_input_config_1.PsPhoneInputConfig.searchPlaceholder, type: 'search', value: query }) }), (0, jsx_runtime_1.jsx)("ul", { className: 'ps-scrollbar-hidden max-h-64 overflow-y-auto p-1.5', role: 'listbox', children: matches.length === 0 ? ((0, jsx_runtime_1.jsx)("li", { className: 'px-3 py-2.5 text-sm text-ink/50', children: ps_phone_input_config_1.PsPhoneInputConfig.emptyMessage })) : (matches.map((option) => ((0, jsx_runtime_1.jsx)("li", { role: 'none', children: (0, jsx_runtime_1.jsxs)("button", { "aria-selected": option.code === country, className: ps_design_system_1.PallasoftClassNameService.merge('ps-focus-ring flex w-full items-center justify-between gap-3 rounded-ps-control px-3 py-2.5 text-left text-sm', option.code === country
|
|
41
|
+
? 'bg-primary/10 text-ink'
|
|
42
|
+
: 'text-ink/80 hover:bg-mist/60 hover:text-ink'), onClick: () => choose(option.code), role: 'option', type: 'button', children: [(0, jsx_runtime_1.jsx)("span", { className: 'min-w-0 truncate', children: ps_phone_input_service_1.PsPhoneInputService.highlight(option.label, query).map((part, index) => part.isMatch ? ((0, jsx_runtime_1.jsx)("strong", { className: 'font-semibold text-ink', children: part.text }, index)) : ((0, jsx_runtime_1.jsx)("span", { children: part.text }, index))) }), (0, jsx_runtime_1.jsxs)("span", { className: 'shrink-0 text-xs text-ink/50', children: ["+", option.callingCode] })] }) }, option.code)))) })] }) })] }), (0, jsx_runtime_1.jsxs)("span", { "aria-hidden": 'true', className: 'flex items-center pl-3 text-sm text-ink/45', children: [ps_phone_input_config_1.PsPhoneInputConfig.plus, ps_phone_input_service_1.PsPhoneInputService.callingCode(country)] }), (0, jsx_runtime_1.jsx)("input", { "aria-invalid": isInvalid, autoComplete: 'tel-national', className: 'min-w-0 flex-1 bg-transparent px-2 text-sm text-ink outline-none', disabled: disabled, id: inputId, inputMode: 'tel', name: name, onBlur: () => {
|
|
43
|
+
setIsTouched(true);
|
|
44
|
+
if (onBlur)
|
|
45
|
+
onBlur();
|
|
46
|
+
}, onChange: (event) => {
|
|
47
|
+
const isDeleting = event.target.value.length < national.length;
|
|
48
|
+
const next = isDeleting
|
|
49
|
+
? event.target.value
|
|
50
|
+
: ps_phone_input_service_1.PsPhoneInputService.format(event.target.value, country);
|
|
51
|
+
setNational(next);
|
|
52
|
+
emit(next, country);
|
|
53
|
+
}, required: required, type: 'tel', value: national })] }), isInvalid ? ((0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper text-danger', children: ps_phone_input_config_1.PsPhoneInputConfig.invalidMessage })) : helperText ? ((0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText })) : null] }));
|
|
54
|
+
};
|
|
55
|
+
exports.PsPhoneInput = PsPhoneInput;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PsTextInputProps } from './ps-text-input';
|
|
2
|
+
export interface PsPostalCodeInputProps extends Omit<PsTextInputProps, 'type' | 'maxLength'> {
|
|
3
|
+
country: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const PsPostalCodeInput: ({ country, onChange, ...props }: PsPostalCodeInputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsPostalCodeInput = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_postal_code_service_1 = require("../services/ps-postal-code-service");
|
|
6
|
+
const ps_text_input_1 = require("./ps-text-input");
|
|
7
|
+
const PsPostalCodeInput = ({ country, onChange, ...props }) => ((0, jsx_runtime_1.jsx)(ps_text_input_1.PsTextInput, { ...props, autoComplete: 'postal-code', autoCapitalize: 'characters', maxLength: ps_postal_code_service_1.PsPostalCodeService.maxLength(country), onChange: (event) => {
|
|
8
|
+
const formatted = ps_postal_code_service_1.PsPostalCodeService.format(event.target.value, country);
|
|
9
|
+
if (formatted !== event.target.value)
|
|
10
|
+
event.target.value = formatted;
|
|
11
|
+
if (onChange)
|
|
12
|
+
onChange(event);
|
|
13
|
+
}, type: 'text' }));
|
|
14
|
+
exports.PsPostalCodeInput = PsPostalCodeInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsRequiredMark = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const PsRequiredMark = ({ isRequired }) => isRequired ? ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": 'true', className: 'ml-0.5 text-danger', children: "*" })) : null;
|
|
6
|
+
exports.PsRequiredMark = PsRequiredMark;
|
|
@@ -8,6 +8,7 @@ const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
|
8
8
|
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
9
9
|
const react_aria_components_1 = require("react-aria-components");
|
|
10
10
|
const ps_select_input_service_1 = require("../services/ps-select-input-service");
|
|
11
|
+
const ps_required_mark_1 = require("./ps-required-mark");
|
|
11
12
|
const ps_select_option_item_1 = require("./ps-select-option-item");
|
|
12
13
|
const PsSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder = 'Select an option', required, value, }) => {
|
|
13
14
|
const [uncontrolledValue, setUncontrolledValue] = (0, react_1.useState)(() => ps_select_input_service_1.PsSelectInputService.getDefaultValue(defaultValue, options));
|
|
@@ -20,6 +21,6 @@ const PsSelectInput = ({ className, defaultValue, disabled, helperText, hideLabe
|
|
|
20
21
|
setUncontrolledValue(nextValue);
|
|
21
22
|
onChange?.(nextValue);
|
|
22
23
|
};
|
|
23
|
-
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.
|
|
24
|
+
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.jsxs)(react_aria_components_1.Label, { className: 'ps-input-label block', children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] })), (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-hidden max-h-72 min-w-[var(--trigger-width)] overflow-y-auto p-1.5 outline-none', offset: 6, placement: 'bottom start', style: { zIndex }, 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 }) }) })] }));
|
|
24
25
|
};
|
|
25
26
|
exports.PsSelectInput = PsSelectInput;
|
|
@@ -4,4 +4,4 @@ export interface PsTextAreaInputProps extends TextareaHTMLAttributes<HTMLTextAre
|
|
|
4
4
|
hideLabel?: boolean;
|
|
5
5
|
label: string;
|
|
6
6
|
}
|
|
7
|
-
export declare const PsTextAreaInput: ({ className, helperText, hideLabel, label, rows, ...props }: PsTextAreaInputProps) => import("react").JSX.Element;
|
|
7
|
+
export declare const PsTextAreaInput: ({ className, helperText, hideLabel, label, required, rows, ...props }: PsTextAreaInputProps) => import("react").JSX.Element;
|
|
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PsTextAreaInput = 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
|
|
6
|
+
const ps_required_mark_1 = require("./ps-required-mark");
|
|
7
|
+
const PsTextAreaInput = ({ className, helperText, hideLabel, label, required, rows = 4, ...props }) => ((0, jsx_runtime_1.jsxs)("label", { className: 'block', children: [(0, jsx_runtime_1.jsxs)("span", { className: hideLabel ? 'sr-only' : 'ps-input-label', children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] }), (0, jsx_runtime_1.jsx)("textarea", { className: ps_design_system_1.PallasoftClassNameService.merge(hideLabel ? 'ps-input-control' : 'ps-input-control mt-2', 'min-h-24 resize-y leading-6', className), required: required, rows: rows, ...props }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
|
|
7
8
|
exports.PsTextAreaInput = PsTextAreaInput;
|
|
@@ -4,12 +4,13 @@ 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 ps_required_mark_1 = require("./ps-required-mark");
|
|
7
8
|
const PsTextInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, required, type, value, ...props }) => {
|
|
8
9
|
if (type === 'date') {
|
|
9
10
|
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
11
|
target: { name, value: nextValue },
|
|
11
12
|
}), required: required, value: typeof value === 'string' ? value : undefined }));
|
|
12
13
|
}
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)("label", { className: 'block', children: [(0, jsx_runtime_1.
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("label", { className: 'block', children: [(0, jsx_runtime_1.jsxs)("span", { className: hideLabel ? 'sr-only' : 'ps-input-label', children: [label, (0, jsx_runtime_1.jsx)(ps_required_mark_1.PsRequiredMark, { isRequired: required })] }), (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
15
|
};
|
|
15
16
|
exports.PsTextInput = PsTextInput;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsUrlInput = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_text_format_service_1 = require("../services/ps-text-format-service");
|
|
6
|
+
const ps_text_input_1 = require("./ps-text-input");
|
|
7
|
+
const PsUrlInput = ({ onBlur, onChange, ...props }) => ((0, jsx_runtime_1.jsx)(ps_text_input_1.PsTextInput, { ...props, autoCapitalize: 'none', autoComplete: 'url', inputMode: 'url', onBlur: (event) => {
|
|
8
|
+
const formatted = ps_text_format_service_1.PsTextFormatService.url(event.target.value);
|
|
9
|
+
if (formatted !== event.target.value) {
|
|
10
|
+
event.target.value = formatted;
|
|
11
|
+
if (onChange)
|
|
12
|
+
onChange(event);
|
|
13
|
+
}
|
|
14
|
+
if (onBlur)
|
|
15
|
+
onBlur(event);
|
|
16
|
+
}, onChange: onChange, spellCheck: false, type: 'text' }));
|
|
17
|
+
exports.PsUrlInput = PsUrlInput;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const PsPhoneInputConfig: {
|
|
2
|
+
readonly countryLabel: "Country";
|
|
3
|
+
readonly defaultCountry: "CA";
|
|
4
|
+
readonly displayNamesType: "region";
|
|
5
|
+
readonly emptyMessage: "No country matches that";
|
|
6
|
+
readonly invalidMessage: "Check this number for the country chosen.";
|
|
7
|
+
readonly locale: "en";
|
|
8
|
+
readonly plus: "+";
|
|
9
|
+
readonly searchPlaceholder: "Search for a country";
|
|
10
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsPhoneInputConfig = void 0;
|
|
4
|
+
exports.PsPhoneInputConfig = {
|
|
5
|
+
countryLabel: 'Country',
|
|
6
|
+
defaultCountry: 'CA',
|
|
7
|
+
displayNamesType: 'region',
|
|
8
|
+
emptyMessage: 'No country matches that',
|
|
9
|
+
invalidMessage: 'Check this number for the country chosen.',
|
|
10
|
+
locale: 'en',
|
|
11
|
+
plus: '+',
|
|
12
|
+
searchPlaceholder: 'Search for a country',
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsPostalCodeConfig = exports.PsPostalCodeFormats = void 0;
|
|
4
|
+
exports.PsPostalCodeFormats = {
|
|
5
|
+
CA: { allowed: /[^A-Z0-9]/g, groups: [3, 3], separator: ' ' },
|
|
6
|
+
GB: { allowed: /[^A-Z0-9]/g, groups: [], separator: ' ' },
|
|
7
|
+
IN: { allowed: /[^0-9]/g, groups: [6], separator: '' },
|
|
8
|
+
NL: { allowed: /[^A-Z0-9]/g, groups: [4, 2], separator: ' ' },
|
|
9
|
+
US: { allowed: /[^0-9]/g, groups: [5, 4], separator: '-' },
|
|
10
|
+
};
|
|
11
|
+
exports.PsPostalCodeConfig = {
|
|
12
|
+
fallbackAllowed: /[^A-Z0-9 -]/g,
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsTextFormatConfig = void 0;
|
|
4
|
+
exports.PsTextFormatConfig = {
|
|
5
|
+
httpsPrefix: 'https://',
|
|
6
|
+
percentSuffix: '%',
|
|
7
|
+
schemePattern: /^[a-z][a-z0-9+.-]*:\/\//i,
|
|
8
|
+
whitespace: /\s+/g,
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PsAmountInputService } from '../services/ps-amount-input-service';
|
|
3
|
+
import { PsTextInput } from './ps-text-input';
|
|
4
|
+
export const PsAmountInput = ({ className, onChange, ...props }) => (_jsx(PsTextInput, { ...props, autoComplete: 'off', className: className, inputMode: 'decimal', onChange: (event) => {
|
|
5
|
+
const normalised = PsAmountInputService.normalise(event.target.value);
|
|
6
|
+
if (normalised !== event.target.value)
|
|
7
|
+
event.target.value = normalised;
|
|
8
|
+
if (onChange)
|
|
9
|
+
onChange(event);
|
|
10
|
+
}, type: 'text' }));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
|
|
3
|
+
import { PsDateInputService } from '../services/ps-date-input-service';
|
|
4
|
+
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';
|
|
5
|
+
export const PsCalendarHeader = ({ decreaseMonth, increaseMonth, monthDate, nextMonthButtonDisabled, prevMonthButtonDisabled, }) => (_jsxs("div", { className: 'flex items-center justify-between gap-2 px-1', children: [_jsx("button", { "aria-label": 'Previous month', className: navigationButtonClassName, disabled: prevMonthButtonDisabled, onClick: decreaseMonth, type: 'button', children: _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 rotate-180', iconKey: PsIconKey.ChevronRight }) }), _jsx("p", { "aria-live": 'polite', className: 'text-sm font-semibold text-ink', children: PsDateInputService.monthLabel(monthDate) }), _jsx("button", { "aria-label": 'Next month', className: navigationButtonClassName, disabled: nextMonthButtonDisabled, onClick: increaseMonth, type: 'button', children: _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4', iconKey: PsIconKey.ChevronRight }) })] }));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import { usePsLayerZIndex } from '@pallasoft/ps-core-components';
|
|
4
|
+
import { PallasoftClassNameService, PallasoftZIndex } from '@pallasoft/ps-design-system';
|
|
5
|
+
import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
|
|
6
|
+
import { Button, Dialog, DialogTrigger, Popover } from 'react-aria-components';
|
|
7
|
+
import { PsCascaderService } from '../services/ps-cascader-service';
|
|
8
|
+
import { PsRequiredMark } from './ps-required-mark';
|
|
9
|
+
export const PsCascaderInput = ({ className, disabled, groups, helperText, hideLabel, label, onChange, placeholder = 'Select an option', required, searchPlaceholder = 'Search', value, }) => {
|
|
10
|
+
const zIndex = usePsLayerZIndex(PallasoftZIndex.Dropdown);
|
|
11
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
const [query, setQuery] = useState('');
|
|
13
|
+
const [activeGroupKey, setActiveGroupKey] = useState(null);
|
|
14
|
+
const selected = useMemo(() => PsCascaderService.findSelected(groups, value), [groups, value]);
|
|
15
|
+
const matches = useMemo(() => PsCascaderService.search(groups, query), [groups, query]);
|
|
16
|
+
const activeGroup = useMemo(() => {
|
|
17
|
+
const key = activeGroupKey
|
|
18
|
+
? activeGroupKey
|
|
19
|
+
: selected
|
|
20
|
+
? selected.group.key
|
|
21
|
+
: groups.length > 0
|
|
22
|
+
? groups[0].key
|
|
23
|
+
: null;
|
|
24
|
+
return groups.find((group) => group.key === key) ?? null;
|
|
25
|
+
}, [activeGroupKey, groups, selected]);
|
|
26
|
+
const open = (nextOpen) => {
|
|
27
|
+
setIsOpen(nextOpen);
|
|
28
|
+
if (!nextOpen)
|
|
29
|
+
return;
|
|
30
|
+
setQuery('');
|
|
31
|
+
setActiveGroupKey(selected ? selected.group.key : null);
|
|
32
|
+
};
|
|
33
|
+
const select = (nextValue, close) => {
|
|
34
|
+
onChange(nextValue);
|
|
35
|
+
close();
|
|
36
|
+
};
|
|
37
|
+
const renderOption = (option, groupLabel, close) => (_jsxs("button", { "aria-selected": option.value === value, className: PallasoftClassNameService.merge('ps-focus-ring flex w-full items-start gap-2 rounded-ps-control px-3 py-2.5 text-left text-sm font-medium transition-colors', option.value === value
|
|
38
|
+
? 'bg-primary/10 text-ink'
|
|
39
|
+
: 'text-ink/80 hover:bg-mist/60 hover:text-ink'), onClick: () => select(option.value, close), role: 'option', type: 'button', children: [_jsx("span", { className: 'flex h-5 w-4 shrink-0 items-center justify-center text-primary', children: option.value === value ? (_jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4', iconKey: PsIconKey.Check })) : null }), _jsxs("span", { className: 'min-w-0 flex-1', children: [_jsx("span", { className: 'block truncate', children: option.label }), groupLabel ? (_jsx("span", { className: 'mt-0.5 block truncate text-xs font-normal text-ink/50', children: groupLabel })) : null, option.description ? (_jsx("span", { className: 'mt-0.5 block truncate text-xs font-normal text-ink/55', children: option.description })) : null] })] }, option.value));
|
|
40
|
+
return (_jsxs("div", { className: PallasoftClassNameService.merge('block', className), children: [hideLabel ? null : (_jsxs("span", { className: 'ps-input-label block', children: [label, _jsx(PsRequiredMark, { isRequired: required })] })), _jsxs(DialogTrigger, { isOpen: isOpen, onOpenChange: open, children: [_jsxs(Button, { "aria-label": hideLabel ? label : undefined, className: 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'), isDisabled: disabled, children: [_jsx("span", { className: 'min-w-0 flex-1 truncate', children: selected ? (_jsxs(_Fragment, { children: [_jsx("span", { className: 'truncate', children: selected.option.label }), _jsx("span", { className: 'ml-2 text-xs font-medium text-ink/45', children: selected.group.label })] })) : (_jsx("span", { className: 'font-medium text-ink/45', children: placeholder })) }), _jsx(PsIcon, { "aria-hidden": 'true', className: 'pointer-events-none absolute top-1/2 right-3 h-4 w-4 -translate-y-1/2 text-primary', iconKey: PsIconKey.Chevron })] }), _jsx(Popover, { className: 'ps-floating-panel w-[min(calc(100vw-2rem),32rem)] min-w-[var(--trigger-width)] outline-none', offset: 6, placement: 'bottom start', style: { zIndex }, children: _jsx(Dialog, { "aria-label": label, className: 'flex flex-col outline-none', children: ({ close }) => (_jsxs(_Fragment, { children: [_jsx("div", { className: 'border-b border-line p-2', children: _jsx("input", { "aria-label": searchPlaceholder, autoFocus: true, className: 'ps-input-control ps-focus-ring h-10 w-full text-sm', onChange: (event) => setQuery(event.target.value), placeholder: searchPlaceholder, type: 'search', value: query }) }), query.trim() === '' ? (_jsxs("div", { className: 'grid grid-cols-1 sm:grid-cols-[minmax(0,11rem)_minmax(0,1fr)]', children: [_jsx("div", { className: PallasoftClassNameService.merge('ps-scrollbar-hidden max-h-72 overflow-y-auto p-1.5 sm:border-r sm:border-line', activeGroupKey && groups.length > 1 ? 'hidden sm:block' : ''), children: groups.map((group) => (_jsxs("button", { className: PallasoftClassNameService.merge('ps-focus-ring flex w-full items-center gap-2 rounded-ps-control px-3 py-2.5 text-left text-sm font-semibold transition-colors', activeGroup?.key === group.key
|
|
41
|
+
? 'bg-mist text-ink'
|
|
42
|
+
: 'text-ink/70 hover:bg-mist/60 hover:text-ink'), onClick: () => setActiveGroupKey(group.key), type: 'button', children: [_jsx("span", { className: 'min-w-0 flex-1 truncate', children: group.label }), _jsx("span", { className: 'text-xs font-medium text-ink/45', children: group.options.length }), _jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 shrink-0 -rotate-90 text-ink/35', iconKey: PsIconKey.Chevron })] }, group.key))) }), _jsxs("div", { className: PallasoftClassNameService.merge('ps-scrollbar-hidden max-h-72 overflow-y-auto p-1.5', activeGroupKey && groups.length > 1 ? '' : 'hidden sm:block'), role: 'listbox', children: [groups.length > 1 ? (_jsxs("button", { className: 'ps-focus-ring mb-1 flex w-full items-center gap-2 rounded-ps-control px-3 py-2 text-left text-xs font-semibold text-ink/60 hover:text-ink sm:hidden', onClick: () => setActiveGroupKey(null), type: 'button', children: [_jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4 rotate-90', iconKey: PsIconKey.Chevron }), "All groups"] })) : null, activeGroup
|
|
43
|
+
? activeGroup.options.map((option) => renderOption(option, null, close))
|
|
44
|
+
: null] })] })) : (_jsx("div", { className: 'ps-scrollbar-hidden max-h-72 overflow-y-auto p-1.5', role: 'listbox', children: matches.length === 0 ? (_jsx("p", { className: 'px-3 py-6 text-center text-sm text-ink/55', children: "No matches." })) : (matches.map((match) => renderOption(match.option, match.group.label, close))) }))] })) }) })] }), helperText ? _jsx("span", { className: 'ps-input-helper mt-2 block', children: helperText }) : null] }));
|
|
45
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
|
|
3
|
+
import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
|
|
4
|
+
import { Checkbox } from 'react-aria-components';
|
|
5
|
+
export const PsCheckbox = ({ children, className, isDisabled, isIndeterminate, isSelected, label, name, onChange, value, }) => (_jsx(Checkbox, { "aria-label": children ? undefined : label, className: 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 }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: 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
|
|
6
|
+
? 'border-primary bg-primary text-[color:var(--ps-color-primary-contrast)]'
|
|
7
|
+
: 'border-line bg-surface group-hover:border-primary/60 dark:border-white/20'), children: showDash ? (_jsx("span", { className: 'block h-0.5 w-2.5 rounded-full bg-current' })) : showCheck ? (_jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-3.5 w-3.5', iconKey: PsIconKey.Check, strokeWidth: 3 })) : null }), children] })) }));
|