@scaleflex/ui-tw 0.0.64 → 0.0.67
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/color-palette/color-palette.component.d.ts +4 -0
- package/color-palette/color-palette.component.js +53 -0
- package/color-palette/color-palette.constants.d.ts +5 -0
- package/color-palette/color-palette.constants.js +3 -0
- package/color-palette/color-palette.types.d.ts +9 -0
- package/color-palette/color-palette.types.js +1 -0
- package/color-palette/color-palette.utils.d.ts +1 -0
- package/color-palette/color-palette.utils.js +8 -0
- package/color-palette/index.d.ts +1 -0
- package/color-palette/index.js +1 -0
- package/color-picker/color-picker.component.d.ts +4 -0
- package/color-picker/color-picker.component.js +80 -0
- package/color-picker/color-picker.types.d.ts +11 -0
- package/color-picker/color-picker.types.js +1 -0
- package/color-picker/index.d.ts +1 -0
- package/color-picker/index.js +1 -0
- package/combobox/combobox.component.js +1 -1
- package/package.json +3 -2
- package/search/search.component.d.ts +1 -1
- package/search/search.component.js +4 -5
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ColorPaletteProps } from '@scaleflex/ui-tw/color-palette/color-palette.types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare function ColorPalette({ colors, value, onSelect, className, size, colorBoxClassName, }: ColorPaletteProps): React.JSX.Element;
|
|
4
|
+
export { ColorPalette };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
2
|
+
import { colorBoxSizeOptions } from '@scaleflex/ui-tw/color-palette/color-palette.constants';
|
|
3
|
+
import { isLightColor } from '@scaleflex/ui-tw/color-palette/color-palette.utils';
|
|
4
|
+
import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
5
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
6
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
7
|
+
import { cva } from 'class-variance-authority';
|
|
8
|
+
import { CheckIcon } from 'lucide-react';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
var colorBoxVariants = cva('', {
|
|
11
|
+
variants: {
|
|
12
|
+
size: colorBoxSizeOptions
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
size: FormSize.Md
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
function ColorPalette(_ref) {
|
|
19
|
+
var colors = _ref.colors,
|
|
20
|
+
value = _ref.value,
|
|
21
|
+
onSelect = _ref.onSelect,
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
_ref$size = _ref.size,
|
|
24
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
25
|
+
colorBoxClassName = _ref.colorBoxClassName;
|
|
26
|
+
return /*#__PURE__*/React.createElement(RadioGroupPrimitive.Root, {
|
|
27
|
+
"data-slot": "color-palette",
|
|
28
|
+
className: cn('flex flex-wrap gap-2', className),
|
|
29
|
+
value: value,
|
|
30
|
+
onValueChange: function onValueChange(val) {
|
|
31
|
+
return onSelect(val);
|
|
32
|
+
},
|
|
33
|
+
role: "radiogroup"
|
|
34
|
+
}, colors.map(function (color) {
|
|
35
|
+
return /*#__PURE__*/React.createElement(RadioGroupPrimitive.Item, {
|
|
36
|
+
key: color,
|
|
37
|
+
value: color,
|
|
38
|
+
"data-slot": "color-palette-item",
|
|
39
|
+
className: cn('border-border inline-block rounded-lg border-1 p-0.5 hover:opacity-80', focusRingClassNames, colorBoxVariants({
|
|
40
|
+
size: size
|
|
41
|
+
}), colorBoxClassName, value === color && 'border-primary'),
|
|
42
|
+
"aria-label": "Color ".concat(color)
|
|
43
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
style: {
|
|
45
|
+
backgroundColor: color
|
|
46
|
+
},
|
|
47
|
+
className: cn('relative h-full w-full cursor-pointer rounded-md shadow-xs transition-all')
|
|
48
|
+
}, value === color && /*#__PURE__*/React.createElement(CheckIcon, {
|
|
49
|
+
className: cn('absolute inset-0 m-auto h-4 w-4', isLightColor(color) ? 'text-dark' : 'text-white')
|
|
50
|
+
})));
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
export { ColorPalette };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
3
|
+
export var colorBoxSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-6'), FormSize.Md, 'size-8'), FormSize.Lg, 'size-10');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isLightColor: (hex: string) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var isLightColor = function isLightColor(hex) {
|
|
2
|
+
var parsed = hex.replace('#', '');
|
|
3
|
+
var r = parseInt(parsed.substring(0, 2), 16);
|
|
4
|
+
var g = parseInt(parsed.substring(2, 4), 16);
|
|
5
|
+
var b = parseInt(parsed.substring(4, 6), 16);
|
|
6
|
+
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
7
|
+
return brightness >= 200;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPalette } from './color-palette.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPalette } from './color-palette.component';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColorPickerProps } from '@scaleflex/ui-tw/color-picker/color-picker.types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare function ColorPicker({ value, placeholder, onChange, onCancel, onSelect, className, children, presetColors, }: ColorPickerProps): React.JSX.Element;
|
|
4
|
+
export { ColorPicker };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import { Button } from '@scaleflex/ui-tw/button';
|
|
4
|
+
import { ColorPalette } from '@scaleflex/ui-tw/color-palette';
|
|
5
|
+
import { Dialog, DialogFormBody, DialogFormContent, DialogFormFooter, DialogFormHeader, DialogFormIcon, DialogFormTitle, DialogTrigger } from '@scaleflex/ui-tw/dialog';
|
|
6
|
+
import { inputVariants } from '@scaleflex/ui-tw/input';
|
|
7
|
+
import { getBaseInputClasses, readOnlyClassNames, selectionHighlightClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
8
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
9
|
+
import { PaletteIcon } from 'lucide-react';
|
|
10
|
+
import React, { useState } from 'react';
|
|
11
|
+
import { HexColorInput, HexColorPicker } from 'react-colorful';
|
|
12
|
+
function ColorPicker(_ref) {
|
|
13
|
+
var value = _ref.value,
|
|
14
|
+
placeholder = _ref.placeholder,
|
|
15
|
+
_onChange = _ref.onChange,
|
|
16
|
+
onCancel = _ref.onCancel,
|
|
17
|
+
onSelect = _ref.onSelect,
|
|
18
|
+
className = _ref.className,
|
|
19
|
+
children = _ref.children,
|
|
20
|
+
presetColors = _ref.presetColors;
|
|
21
|
+
var _useState = useState(value),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
tempValue = _useState2[0],
|
|
24
|
+
setTempValue = _useState2[1];
|
|
25
|
+
var handleSelect = function handleSelect() {
|
|
26
|
+
onSelect === null || onSelect === void 0 || onSelect(tempValue);
|
|
27
|
+
};
|
|
28
|
+
var handleCancel = function handleCancel() {
|
|
29
|
+
onCancel === null || onCancel === void 0 || onCancel();
|
|
30
|
+
setTempValue(value);
|
|
31
|
+
};
|
|
32
|
+
return /*#__PURE__*/React.createElement(Dialog, null, /*#__PURE__*/React.createElement(DialogTrigger, {
|
|
33
|
+
asChild: true
|
|
34
|
+
}, children || /*#__PURE__*/React.createElement("button", {
|
|
35
|
+
type: "button",
|
|
36
|
+
className: "border-muted h-8 w-8 rounded border shadow-inner",
|
|
37
|
+
style: {
|
|
38
|
+
backgroundColor: value
|
|
39
|
+
},
|
|
40
|
+
"aria-label": "Open color picker"
|
|
41
|
+
})), /*#__PURE__*/React.createElement(DialogFormContent, {
|
|
42
|
+
className: cn('w-[316px]', className)
|
|
43
|
+
}, /*#__PURE__*/React.createElement(DialogFormHeader, null, /*#__PURE__*/React.createElement(DialogFormIcon, null, /*#__PURE__*/React.createElement(PaletteIcon, null)), /*#__PURE__*/React.createElement(DialogFormTitle, null, "Pick color")), /*#__PURE__*/React.createElement(DialogFormBody, {
|
|
44
|
+
className: "space-y-4"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(HexColorPicker, {
|
|
46
|
+
color: tempValue,
|
|
47
|
+
onChange: function onChange(color) {
|
|
48
|
+
setTempValue(color);
|
|
49
|
+
_onChange === null || _onChange === void 0 || _onChange(color);
|
|
50
|
+
},
|
|
51
|
+
className: "!w-full"
|
|
52
|
+
}), /*#__PURE__*/React.createElement(HexColorInput, {
|
|
53
|
+
id: "colorv2",
|
|
54
|
+
color: tempValue,
|
|
55
|
+
onChange: function onChange(color) {
|
|
56
|
+
setTempValue(color);
|
|
57
|
+
_onChange === null || _onChange === void 0 || _onChange(color);
|
|
58
|
+
},
|
|
59
|
+
placeholder: placeholder || 'Enter hex color',
|
|
60
|
+
className: cn.apply(void 0, ['flex w-full min-w-0 font-mono'].concat(_toConsumableArray(getBaseInputClasses()), [readOnlyClassNames, selectionHighlightClassNames, inputVariants()]))
|
|
61
|
+
}), presetColors && /*#__PURE__*/React.createElement(ColorPalette, {
|
|
62
|
+
className: "gap-1.75",
|
|
63
|
+
colorBoxClassName: "p-0.5",
|
|
64
|
+
value: tempValue,
|
|
65
|
+
colors: presetColors,
|
|
66
|
+
onSelect: setTempValue
|
|
67
|
+
})), /*#__PURE__*/React.createElement(DialogFormFooter, null, /*#__PURE__*/React.createElement(DialogTrigger, {
|
|
68
|
+
asChild: true
|
|
69
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
70
|
+
variant: "outline",
|
|
71
|
+
className: "flex-1",
|
|
72
|
+
onClick: handleCancel
|
|
73
|
+
}, "Cancel")), /*#__PURE__*/React.createElement(DialogTrigger, {
|
|
74
|
+
asChild: true
|
|
75
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
76
|
+
className: "flex-1",
|
|
77
|
+
onClick: handleSelect
|
|
78
|
+
}, "Select")))));
|
|
79
|
+
}
|
|
80
|
+
export { ColorPicker };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type ColorPickerProps = {
|
|
3
|
+
value: string;
|
|
4
|
+
onSelect: (value: string) => void;
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
onCancel?: () => void;
|
|
7
|
+
className?: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
placeholder?: ReactElement | string;
|
|
10
|
+
presetColors?: string[];
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPicker } from './color-picker.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPicker } from './color-picker.component';
|
|
@@ -170,7 +170,7 @@ export function ComboboxCheckboxTrigger(_ref3) {
|
|
|
170
170
|
}, label || children), displayCount && selectedLength > 0 && optionsLength > 1 && /*#__PURE__*/React.createElement("span", {
|
|
171
171
|
className: "text-muted-foreground text-sm"
|
|
172
172
|
}, selectedLength, "/", optionsLength)), /*#__PURE__*/React.createElement("div", {
|
|
173
|
-
className: "
|
|
173
|
+
className: "flex items-center gap-1"
|
|
174
174
|
}, showClear && !!onClearAll && selected && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
175
175
|
role: "button",
|
|
176
176
|
tabIndex: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.67",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@radix-ui/react-slot": "^1.1.2",
|
|
24
24
|
"@radix-ui/react-switch": "^1.0.1",
|
|
25
25
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
26
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
26
|
+
"@scaleflex/icons-tw": "^0.0.67",
|
|
27
27
|
"@tanstack/react-table": "^8.21.3",
|
|
28
28
|
"@types/lodash.merge": "^4.6.9",
|
|
29
29
|
"class-variance-authority": "^0.7.1",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"lodash.merge": "^4.6.2",
|
|
33
33
|
"lucide-react": "^0.487.0",
|
|
34
34
|
"prop-types": "^15.7.2",
|
|
35
|
+
"react-colorful": "^5.6.1",
|
|
35
36
|
"react-day-picker": "^9.7.0",
|
|
36
37
|
"sonner": "^2.0.3",
|
|
37
38
|
"tailwind-scrollbar": "^4.0.2",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { InputProps } from '@scaleflex/ui-tw/input';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare function Search({ className, size, disabled, readOnly, ...rest }: InputProps): React.JSX.Element;
|
|
3
|
+
export declare function Search({ className, size, disabled, readOnly, onChange, ...rest }: InputProps): React.JSX.Element;
|
|
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["className", "size", "disabled", "readOnly"];
|
|
5
|
+
var _excluded = ["className", "size", "disabled", "readOnly", "onChange"];
|
|
6
6
|
import { buttonVariants } from '@scaleflex/ui-tw/button';
|
|
7
7
|
import { ButtonVariant, buttonBaseClassNames } from '@scaleflex/ui-tw/button/button.constants';
|
|
8
8
|
import { Input } from '@scaleflex/ui-tw/input';
|
|
@@ -19,6 +19,7 @@ export function Search(_ref) {
|
|
|
19
19
|
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
20
20
|
disabled = _ref.disabled,
|
|
21
21
|
readOnly = _ref.readOnly,
|
|
22
|
+
_onChange = _ref.onChange,
|
|
22
23
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
23
24
|
var padding = searchPaddingMap[size];
|
|
24
25
|
var iconSize = iconSizeOptions[size];
|
|
@@ -28,14 +29,13 @@ export function Search(_ref) {
|
|
|
28
29
|
value = _useState2[0],
|
|
29
30
|
setValue = _useState2[1];
|
|
30
31
|
var handleClear = function handleClear() {
|
|
31
|
-
var _rest$onChange;
|
|
32
32
|
var syntheticEvent = {
|
|
33
33
|
target: {
|
|
34
34
|
value: ''
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
setValue('');
|
|
38
|
-
|
|
38
|
+
_onChange === null || _onChange === void 0 || _onChange(syntheticEvent);
|
|
39
39
|
};
|
|
40
40
|
return /*#__PURE__*/React.createElement("div", {
|
|
41
41
|
className: "relative w-full"
|
|
@@ -44,9 +44,8 @@ export function Search(_ref) {
|
|
|
44
44
|
}), /*#__PURE__*/React.createElement(Input, _extends({
|
|
45
45
|
value: value,
|
|
46
46
|
onChange: function onChange(e) {
|
|
47
|
-
var _rest$onChange2;
|
|
48
47
|
setValue(e.target.value);
|
|
49
|
-
|
|
48
|
+
_onChange === null || _onChange === void 0 || _onChange(e);
|
|
50
49
|
},
|
|
51
50
|
type: "search",
|
|
52
51
|
size: size,
|