@sqrzro/ui 4.0.0-alpha.60 → 4.0.0-alpha.61
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.
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import Assistive from '../../../components/utility/Assistive';
|
|
4
|
-
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import { useClassNames, useIcon } from '../../../styles/context';
|
|
5
5
|
import tw from '../../../styles/classnames/utility/tw';
|
|
6
6
|
function ColorInput({ classNames, classNameProps, hasError, name, onChange, placeholder, value, }) {
|
|
7
7
|
const componentClassNames = useClassNames('colorInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
|
|
8
|
+
const ClearIcon = useIcon('colorInput.clear');
|
|
8
9
|
function handleClear() {
|
|
9
10
|
onChange?.({ target: { name, value: '' } });
|
|
10
11
|
}
|
|
11
|
-
return (_jsxs("div", { className: tw('relative', componentClassNames?.root), children: [_jsx("input", { className: tw('absolute inset-0 h-full w-full cursor-pointer opacity-0', componentClassNames?.input), name: name, onChange: onChange, type: "color", value: value || '' }), _jsx("i", { className: tw(componentClassNames?.icon), style: { backgroundColor: value || 'transparent' } }), value ? (_jsx("span", { className: tw(componentClassNames?.label), children: value.toUpperCase() })) : (_jsx("span", { className: tw(componentClassNames?.placeholder), children: placeholder || 'Select...' })), _jsx("span", { className: "absolute bottom-0 right-0 top-0 flex w-0 items-center justify-end", children: value ? (
|
|
12
|
+
return (_jsxs("div", { className: tw('relative', componentClassNames?.root), children: [_jsx("input", { className: tw('absolute inset-0 h-full w-full cursor-pointer opacity-0', componentClassNames?.input), name: name, onChange: onChange, type: "color", value: value || '' }), _jsx("i", { className: tw(componentClassNames?.icon), style: { backgroundColor: value || 'transparent' } }), value ? (_jsx("span", { className: tw(componentClassNames?.label), children: value.toUpperCase() })) : (_jsx("span", { className: tw(componentClassNames?.placeholder), children: placeholder || 'Select...' })), _jsx("span", { className: "absolute bottom-0 right-0 top-0 flex w-0 items-center justify-end", children: value ? (_jsxs("button", { className: tw('flex-none', componentClassNames?.clear), onClick: handleClear, type: "button", children: [ClearIcon ? _jsx(ClearIcon, {}) : null, _jsx(Assistive, { children: "Clear" })] })) : null })] }));
|
|
12
13
|
}
|
|
13
14
|
export default ColorInput;
|
|
@@ -6,6 +6,7 @@ export interface UIIcons {
|
|
|
6
6
|
'csvInput.upload'?: IconComponent;
|
|
7
7
|
'csvInput.success'?: IconComponent;
|
|
8
8
|
'collection.empty'?: IconComponent;
|
|
9
|
+
'colorInput.clear'?: IconComponent;
|
|
9
10
|
'dropdown.control'?: IconComponent;
|
|
10
11
|
'filter.clear'?: IconComponent;
|
|
11
12
|
'filter.panel'?: IconComponent;
|