@pallasoft/ps-input-components 1.6.0 → 1.7.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.
|
@@ -8,9 +8,9 @@ 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 PsColorInput = ({ className, helperText, label, onChange, swatches = [...ps_color_input_config_1.PsColorInputConfig.swatches], value, }) => {
|
|
10
10
|
const labelId = (0, react_1.useId)();
|
|
11
|
+
const swatchesId = (0, react_1.useId)();
|
|
11
12
|
const [draft, setDraft] = (0, react_1.useState)(value);
|
|
12
13
|
const normalised = value.toUpperCase();
|
|
13
|
-
const isCustom = value !== '' && !swatches.some((swatch) => swatch.toUpperCase() === normalised);
|
|
14
14
|
(0, react_1.useEffect)(() => {
|
|
15
15
|
setDraft(value);
|
|
16
16
|
}, [value]);
|
|
@@ -21,14 +21,14 @@ const PsColorInput = ({ className, helperText, label, onChange, swatches = [...p
|
|
|
21
21
|
else
|
|
22
22
|
setDraft(value);
|
|
23
23
|
};
|
|
24
|
-
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.jsx)("span", { className: 'ps-input-label', id: labelId, children: label }), (0, jsx_runtime_1.jsxs)("div", {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
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.jsx)("span", { className: 'ps-input-label', id: labelId, children: label }), (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.jsxs)("div", { className: 'flex items-center gap-3', children: [(0, jsx_runtime_1.jsx)("label", { className: 'ps-focus-ring relative h-11 w-11 shrink-0 cursor-pointer overflow-hidden rounded-ps-control border border-line ring-offset-2 ring-offset-surface', style: { backgroundColor: value === '' ? 'transparent' : value }, title: 'Pick a colour', children: (0, jsx_runtime_1.jsx)("input", { "aria-label": `${label} picker`, className: 'absolute inset-0 cursor-pointer opacity-0', onChange: (event) => onChange(event.target.value.toUpperCase()), type: 'color', value: value === '' ? '#000000' : value }) }), (0, jsx_runtime_1.jsx)("input", { "aria-label": `${label} hex`, className: 'ps-input-control ps-focus-ring h-11 min-w-0 flex-1 font-mono text-sm uppercase', maxLength: 7, onBlur: (event) => commit(event.target.value), onChange: (event) => setDraft(event.target.value), onKeyDown: (event) => {
|
|
25
|
+
if (event.key === 'Enter') {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
commit(draft);
|
|
28
|
+
}
|
|
29
|
+
}, placeholder: '#000000', value: draft })] }), (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) => {
|
|
30
|
+
const isSelected = swatch.toUpperCase() === normalised;
|
|
31
|
+
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));
|
|
32
|
+
}) })] })] }), helperText ? (0, jsx_runtime_1.jsx)("span", { className: 'ps-input-helper', children: helperText }) : null] }));
|
|
33
33
|
};
|
|
34
34
|
exports.PsColorInput = PsColorInput;
|
|
@@ -23,6 +23,7 @@ const PsDateInput = ({ className, defaultValue, disabled, helperText, hideLabel,
|
|
|
23
23
|
const existing = document.getElementById(portalId);
|
|
24
24
|
const container = existing ? existing : document.createElement('div');
|
|
25
25
|
container.id = portalId;
|
|
26
|
+
container.setAttribute(ps_date_input_config_1.PsDateInputConfig.topLayerAttribute, 'true');
|
|
26
27
|
container.style.position = 'relative';
|
|
27
28
|
container.style.zIndex = String(zIndex);
|
|
28
29
|
if (!existing)
|