@pallasoft/ps-input-components 1.12.0 → 1.13.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.
@@ -4,10 +4,11 @@ export interface PsCheckboxProps {
4
4
  className?: string;
5
5
  isDisabled?: boolean;
6
6
  isIndeterminate?: boolean;
7
+ isLoading?: boolean;
7
8
  isSelected: boolean;
8
9
  label: string;
9
10
  name?: string;
10
11
  onChange: (isSelected: boolean) => void;
11
12
  value?: string;
12
13
  }
13
- export declare const PsCheckbox: ({ children, className, isDisabled, isIndeterminate, isSelected, label, name, onChange, value, }: PsCheckboxProps) => import("react").JSX.Element;
14
+ export declare const PsCheckbox: ({ children, className, isDisabled, isIndeterminate, isLoading, isSelected, label, name, onChange, value, }: PsCheckboxProps) => 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 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
8
+ const PsCheckbox = ({ children, className, isDisabled, isIndeterminate, isLoading = false, isSelected, label, name, onChange, value, }) => isLoading ? ((0, jsx_runtime_1.jsx)("span", { "aria-busy": 'true', className: ps_design_system_1.PallasoftClassNameService.merge('ps-skeleton inline-block h-5 w-5 rounded-md', className), role: 'status', children: (0, jsx_runtime_1.jsx)("span", { className: 'sr-only', children: label }) })) : ((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
9
  ? 'border-primary bg-primary text-[color:var(--ps-color-primary-contrast)]'
10
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
11
  exports.PsCheckbox = PsCheckbox;
@@ -1,10 +1,11 @@
1
1
  export interface PsColorInputProps {
2
2
  className?: string;
3
3
  helperText?: string;
4
+ isLoading?: boolean;
4
5
  label: string;
5
6
  onChange: (value: string) => void;
6
7
  required?: boolean;
7
8
  swatches?: string[];
8
9
  value: string;
9
10
  }
10
- export declare const PsColorInput: ({ className, helperText, label, onChange, required, swatches, value, }: PsColorInputProps) => import("react").JSX.Element;
11
+ export declare const PsColorInput: ({ className, helperText, isLoading, label, onChange, required, swatches, value, }: PsColorInputProps) => import("react").JSX.Element;
@@ -7,11 +7,14 @@ 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 ps_field_skeleton_1 = require("./ps-field-skeleton");
10
11
  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, }) => {
12
+ const PsColorInput = ({ className, helperText, isLoading = false, label, onChange, required, swatches = [...ps_color_input_config_1.PsColorInputConfig.swatches], value, }) => {
12
13
  const labelId = (0, react_1.useId)();
13
14
  const swatchesId = (0, react_1.useId)();
14
15
  const normalised = value.toUpperCase();
16
+ if (isLoading)
17
+ return (0, jsx_runtime_1.jsx)(ps_field_skeleton_1.PsFieldSkeleton, { className: className, label: label });
15
18
  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) => {
16
19
  const isSelected = swatch.toUpperCase() === normalised;
17
20
  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));
@@ -4,9 +4,10 @@ export interface PsFilePickerProps {
4
4
  className?: string;
5
5
  disabled?: boolean;
6
6
  dropLabel: string;
7
+ isLoading?: boolean;
7
8
  maxSizeBytes?: number;
8
9
  maxSizeLabel?: string;
9
10
  onError?: (message: string) => void;
10
11
  onFileLoad: (file: File) => void;
11
12
  }
12
- export declare const PsFilePicker: ({ accept, acceptLabel, className, disabled, dropLabel, maxSizeBytes, maxSizeLabel, onError, onFileLoad, }: PsFilePickerProps) => import("react").JSX.Element;
13
+ export declare const PsFilePicker: ({ accept, acceptLabel, className, disabled, dropLabel, isLoading, maxSizeBytes, maxSizeLabel, onError, onFileLoad, }: PsFilePickerProps) => import("react").JSX.Element;
@@ -5,8 +5,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const ps_design_system_1 = require("@pallasoft/ps-design-system");
7
7
  const ps_icons_1 = require("@pallasoft/ps-icons");
8
- const PsFilePicker = ({ accept, acceptLabel, className, disabled, dropLabel, maxSizeBytes, maxSizeLabel, onError, onFileLoad, }) => {
8
+ const PsFilePicker = ({ accept, acceptLabel, className, disabled, dropLabel, isLoading = false, maxSizeBytes, maxSizeLabel, onError, onFileLoad, }) => {
9
9
  const acceptAttr = (0, react_1.useMemo)(() => accept.join(','), [accept]);
10
+ if (isLoading)
11
+ return ((0, jsx_runtime_1.jsx)("span", { "aria-busy": 'true', className: ps_design_system_1.PallasoftClassNameService.merge('ps-skeleton block min-h-32 w-full rounded-ps-panel', className), role: 'status' }));
10
12
  const isAccepted = (candidate) => accept.some((entry) => entry.startsWith('.')
11
13
  ? candidate.name.toLowerCase().endsWith(entry.toLowerCase())
12
14
  : entry === candidate.type);
@@ -5,6 +5,7 @@ export interface PsMultiSelectInputProps {
5
5
  disabled?: boolean;
6
6
  helperText?: string;
7
7
  hideLabel?: boolean;
8
+ isLoading?: boolean;
8
9
  label: string;
9
10
  name?: string;
10
11
  onChange?: (value: string[]) => void;
@@ -13,4 +14,4 @@ export interface PsMultiSelectInputProps {
13
14
  required?: boolean;
14
15
  value?: string[];
15
16
  }
16
- export declare const PsMultiSelectInput: ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder, required, value, }: PsMultiSelectInputProps) => import("react").JSX.Element;
17
+ export declare const PsMultiSelectInput: ({ className, defaultValue, disabled, helperText, hideLabel, isLoading, label, name, onChange, options, placeholder, required, value, }: PsMultiSelectInputProps) => import("react").JSX.Element;
@@ -7,13 +7,16 @@ 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_field_skeleton_1 = require("./ps-field-skeleton");
10
11
  const ps_required_mark_1 = require("./ps-required-mark");
11
12
  const ps_select_option_item_1 = require("./ps-select-option-item");
12
- const PsMultiSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder = 'Select options', required, value, }) => {
13
+ const PsMultiSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, isLoading = false, label, name, onChange, options, placeholder = 'Select options', required, value, }) => {
13
14
  const [uncontrolledValue, setUncontrolledValue] = (0, react_1.useState)(defaultValue === undefined ? [] : defaultValue);
14
15
  const currentValue = value === undefined ? uncontrolledValue : value;
15
16
  const zIndex = (0, ps_core_components_1.usePsLayerZIndex)(ps_design_system_1.PallasoftZIndex.Dropdown);
16
17
  const labelByValue = new Map(options.map((option) => [option.value, option.label]));
18
+ if (isLoading)
19
+ return (0, jsx_runtime_1.jsx)(ps_field_skeleton_1.PsFieldSkeleton, { className: className, hideLabel: hideLabel, label: label });
17
20
  const handleChange = (keys) => {
18
21
  const nextValue = keys.map((key) => String(key));
19
22
  if (value === undefined)
@@ -2,6 +2,6 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
3
3
  import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
4
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
5
+ export const PsCheckbox = ({ children, className, isDisabled, isIndeterminate, isLoading = false, isSelected, label, name, onChange, value, }) => isLoading ? (_jsx("span", { "aria-busy": 'true', className: PallasoftClassNameService.merge('ps-skeleton inline-block h-5 w-5 rounded-md', className), role: 'status', children: _jsx("span", { className: 'sr-only', children: label }) })) : (_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
6
  ? 'border-primary bg-primary text-[color:var(--ps-color-primary-contrast)]'
7
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] })) }));
@@ -4,11 +4,14 @@ import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
4
4
  import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
5
5
  import { PsColorInputConfig } from '../constants/ps-color-input-config';
6
6
  import { PsColorPicker } from './ps-color-picker';
7
+ import { PsFieldSkeleton } from './ps-field-skeleton';
7
8
  import { PsRequiredMark } from './ps-required-mark';
8
- export const PsColorInput = ({ className, helperText, label, onChange, required, swatches = [...PsColorInputConfig.swatches], value, }) => {
9
+ export const PsColorInput = ({ className, helperText, isLoading = false, label, onChange, required, swatches = [...PsColorInputConfig.swatches], value, }) => {
9
10
  const labelId = useId();
10
11
  const swatchesId = useId();
11
12
  const normalised = value.toUpperCase();
13
+ if (isLoading)
14
+ return _jsx(PsFieldSkeleton, { className: className, label: label });
12
15
  return (_jsxs("div", { className: PallasoftClassNameService.merge('flex flex-col gap-2', className), children: [_jsxs("span", { className: 'ps-input-label', id: labelId, children: [label, _jsx(PsRequiredMark, { isRequired: required })] }), _jsxs("div", { className: 'flex flex-col gap-4 rounded-ps-control border border-line bg-surface p-4', children: [_jsx(PsColorPicker, { hideLabel: true, label: `${label} picker`, onChange: onChange, swatches: swatches, value: value }), _jsxs("div", { className: 'flex flex-col gap-2 border-t border-line pt-4', children: [_jsx("span", { className: 'ps-input-helper', id: swatchesId, children: "Presets" }), _jsx("div", { "aria-labelledby": swatchesId, className: 'flex flex-wrap gap-2', role: 'radiogroup', children: swatches.map((swatch) => {
13
16
  const isSelected = swatch.toUpperCase() === normalised;
14
17
  return (_jsx("button", { "aria-checked": isSelected, "aria-label": swatch, className: 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 ? (_jsx(PsIcon, { "aria-hidden": 'true', className: 'block h-4 w-4', iconKey: PsIconKey.Check })) : null }, swatch));
@@ -2,8 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
4
4
  import { PsIcon } from '@pallasoft/ps-icons';
5
- export const PsFilePicker = ({ accept, acceptLabel, className, disabled, dropLabel, maxSizeBytes, maxSizeLabel, onError, onFileLoad, }) => {
5
+ export const PsFilePicker = ({ accept, acceptLabel, className, disabled, dropLabel, isLoading = false, maxSizeBytes, maxSizeLabel, onError, onFileLoad, }) => {
6
6
  const acceptAttr = useMemo(() => accept.join(','), [accept]);
7
+ if (isLoading)
8
+ return (_jsx("span", { "aria-busy": 'true', className: PallasoftClassNameService.merge('ps-skeleton block min-h-32 w-full rounded-ps-panel', className), role: 'status' }));
7
9
  const isAccepted = (candidate) => accept.some((entry) => entry.startsWith('.')
8
10
  ? candidate.name.toLowerCase().endsWith(entry.toLowerCase())
9
11
  : entry === candidate.type);
@@ -4,13 +4,16 @@ import { usePsLayerZIndex } from '@pallasoft/ps-core-components';
4
4
  import { PallasoftClassNameService, PallasoftZIndex } from '@pallasoft/ps-design-system';
5
5
  import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
6
6
  import { Button, Label, ListBox, Popover, Select, SelectValue, Text, } from 'react-aria-components';
7
+ import { PsFieldSkeleton } from './ps-field-skeleton';
7
8
  import { PsRequiredMark } from './ps-required-mark';
8
9
  import { PsSelectOptionItem } from './ps-select-option-item';
9
- export const PsMultiSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, label, name, onChange, options, placeholder = 'Select options', required, value, }) => {
10
+ export const PsMultiSelectInput = ({ className, defaultValue, disabled, helperText, hideLabel, isLoading = false, label, name, onChange, options, placeholder = 'Select options', required, value, }) => {
10
11
  const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue === undefined ? [] : defaultValue);
11
12
  const currentValue = value === undefined ? uncontrolledValue : value;
12
13
  const zIndex = usePsLayerZIndex(PallasoftZIndex.Dropdown);
13
14
  const labelByValue = new Map(options.map((option) => [option.value, option.label]));
15
+ if (isLoading)
16
+ return _jsx(PsFieldSkeleton, { className: className, hideLabel: hideLabel, label: label });
14
17
  const handleChange = (keys) => {
15
18
  const nextValue = keys.map((key) => String(key));
16
19
  if (value === undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-input-components",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.js",