@scaleflex/ui-tw 0.0.63 → 0.0.66
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 +3 -3
- package/package.json +3 -2
|
@@ -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,
|
|
@@ -266,7 +266,7 @@ export function ComboboxContent(_ref4) {
|
|
|
266
266
|
}), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
|
|
267
267
|
}
|
|
268
268
|
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
269
|
-
key:
|
|
269
|
+
key: groupIndex
|
|
270
270
|
}, /*#__PURE__*/React.createElement(CommandItem, {
|
|
271
271
|
size: size,
|
|
272
272
|
multiple: multiple,
|
|
@@ -356,7 +356,7 @@ export function ComboboxCheckboxContent(_ref6) {
|
|
|
356
356
|
}), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
|
|
357
357
|
}
|
|
358
358
|
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
359
|
-
key:
|
|
359
|
+
key: groupIndex
|
|
360
360
|
}, /*#__PURE__*/React.createElement(CommandCheckboxItem, {
|
|
361
361
|
size: size,
|
|
362
362
|
disabled: option.disabled,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66",
|
|
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.66",
|
|
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",
|