@festo-ui/react-extra 9.0.0-dev.726 → 9.0.0-dev.727
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/dist/components/color-indicator/ColorIndicator.css +60 -0
- package/dist/components/color-indicator/ColorIndicator.d.ts +11 -0
- package/dist/components/color-indicator/ColorIndicator.js +125 -0
- package/dist/components/scroll-area/ScrollArea.d.ts +4 -0
- package/dist/components/scroll-area/ScrollArea.js +10 -0
- package/dist/components/scroll-area/ScrollArea.stories.css +9 -0
- package/dist/forms/color-picker/ColorHelper.d.ts +5 -0
- package/dist/forms/color-picker/ColorHelper.js +121 -0
- package/dist/forms/color-picker/ColorPicker.css +377 -0
- package/dist/forms/color-picker/ColorPicker.d.ts +12 -0
- package/dist/forms/color-picker/ColorPicker.js +675 -0
- package/dist/forms/date-picker/DatePicker.css +26 -0
- package/dist/forms/date-picker/DatePicker.d.ts +25 -0
- package/dist/forms/date-picker/DatePicker.js +138 -0
- package/dist/forms/date-range-picker/DateRangePicker.css +21 -0
- package/dist/forms/date-range-picker/DateRangePicker.d.ts +19 -0
- package/dist/forms/date-range-picker/DateRangePicker.js +130 -0
- package/dist/forms/text-editor/TextEditor.css +1532 -0
- package/dist/forms/text-editor/TextEditor.d.ts +28 -0
- package/dist/forms/text-editor/TextEditor.js +272 -0
- package/dist/forms/text-editor/TextEditorButton.d.ts +13 -0
- package/dist/forms/text-editor/TextEditorButton.js +72 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/utils/useId.d.ts +1 -0
- package/dist/utils/useId.js +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
.fwe-color-indicator .fwe-popover-container {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.fwe-color-indicator .fwe-popover-container .fwe-popover {
|
|
6
|
+
background-color: var(--fwe-white);
|
|
7
|
+
font-size: var(--fwe-font-size-md);
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
padding: 8px 16px 16px;
|
|
10
|
+
line-height: 1rem;
|
|
11
|
+
box-shadow: 0 1px 4px #3333;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.fwe-color-indicator .fwe-backdrop {
|
|
15
|
+
background: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.fwe-color-indicator .fwe-color-label {
|
|
19
|
+
height: 18px;
|
|
20
|
+
font-size: var(--fwe-font-size-small);
|
|
21
|
+
font-weight: var(--fwe-font-weight-bold);
|
|
22
|
+
margin-bottom: 4px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.fwe-color-indicator .fwe-color-container {
|
|
26
|
+
display: flex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.fwe-color-indicator .fwe-color-container .fwe-color-box {
|
|
30
|
+
border: 1px solid var(--fwe-control-border);
|
|
31
|
+
background: var(--fwe-white);
|
|
32
|
+
border-radius: 4px;
|
|
33
|
+
width: 24px;
|
|
34
|
+
height: 24px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.fwe-color-indicator .fwe-color-container .fwe-color-box .fwe-no-color-pattern {
|
|
38
|
+
margin: 2px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.fwe-color-indicator .fwe-color-container .fwe-color-indicator-text {
|
|
42
|
+
margin-left: 8px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.fwe-color-indicator.disabled {
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.fwe-color-indicator.disabled .fwe-color-label {
|
|
50
|
+
color: var(--fwe-text-disabled);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.fwe-color-indicator.disabled .fwe-color-container .fwe-color-box {
|
|
54
|
+
opacity: .5;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.fwe-color-indicator.disabled .fwe-color-container .fwe-color-indicator-text {
|
|
58
|
+
color: var(--fwe-text-disabled);
|
|
59
|
+
}
|
|
60
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type JSX, type PropsWithChildren } from 'react';
|
|
2
|
+
import './ColorIndicator.scss';
|
|
3
|
+
export interface ColorIndicatorProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
text: string;
|
|
6
|
+
label: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
showPopOver?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function ColorIndicator({ text, label, color, className, showPopOver, children, disabled, }: PropsWithChildren<ColorIndicatorProps>): JSX.Element;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Popover } from "@festo-ui/react";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import "./ColorIndicator.css";
|
|
6
|
+
function ColorIndicator({ text, label, color, className, showPopOver = false, children, disabled }) {
|
|
7
|
+
const classes = classnames('fwe-color-indicator', className, disabled);
|
|
8
|
+
const [isEditorOpen, setEditorOpen] = useState(false);
|
|
9
|
+
function getBorderColor() {
|
|
10
|
+
if (!color || '#FFFFFF' === color.toUpperCase() || '#F0F2F3' === color.toUpperCase()) return '#b6bec6';
|
|
11
|
+
return color;
|
|
12
|
+
}
|
|
13
|
+
const colorBox = /*#__PURE__*/ jsx("div", {
|
|
14
|
+
className: "fwe-color-box",
|
|
15
|
+
style: {
|
|
16
|
+
background: color,
|
|
17
|
+
borderColor: getBorderColor()
|
|
18
|
+
},
|
|
19
|
+
children: !color && /*#__PURE__*/ jsxs("svg", {
|
|
20
|
+
className: "fwe-no-color-pattern",
|
|
21
|
+
version: "1.1",
|
|
22
|
+
role: "img",
|
|
23
|
+
"aria-label": "No color selected",
|
|
24
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
26
|
+
id: "canvas1",
|
|
27
|
+
width: "18",
|
|
28
|
+
height: "18",
|
|
29
|
+
children: [
|
|
30
|
+
/*#__PURE__*/ jsx("defs", {
|
|
31
|
+
children: /*#__PURE__*/ jsxs("pattern", {
|
|
32
|
+
id: "bwsquare2px",
|
|
33
|
+
width: "4",
|
|
34
|
+
height: "4",
|
|
35
|
+
patternUnits: "userSpaceOnUse",
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ jsx("rect", {
|
|
38
|
+
x: "0",
|
|
39
|
+
y: "0",
|
|
40
|
+
width: "2",
|
|
41
|
+
height: "2",
|
|
42
|
+
stroke: "none",
|
|
43
|
+
fill: "#ffffff"
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ jsx("rect", {
|
|
46
|
+
x: "2",
|
|
47
|
+
y: "0",
|
|
48
|
+
width: "2",
|
|
49
|
+
height: "2",
|
|
50
|
+
stroke: "none",
|
|
51
|
+
fill: "#e2e5e8"
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ jsx("rect", {
|
|
54
|
+
x: "0",
|
|
55
|
+
y: "2",
|
|
56
|
+
width: "2",
|
|
57
|
+
height: "2",
|
|
58
|
+
stroke: "none",
|
|
59
|
+
fill: "#e2e5e8"
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ jsx("rect", {
|
|
62
|
+
x: "2",
|
|
63
|
+
y: "2",
|
|
64
|
+
width: "2",
|
|
65
|
+
height: "2",
|
|
66
|
+
stroke: "none",
|
|
67
|
+
fill: "#ffffff"
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ jsx("rect", {
|
|
73
|
+
x: "0",
|
|
74
|
+
y: "0",
|
|
75
|
+
rx: "0",
|
|
76
|
+
ry: "0",
|
|
77
|
+
width: "18",
|
|
78
|
+
height: "18",
|
|
79
|
+
fill: "url(#bwsquare2px)",
|
|
80
|
+
strokeWidth: "0"
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
const wrapperProperties = showPopOver ? {
|
|
86
|
+
onClick: ()=>setEditorOpen((prevOpen)=>!prevOpen)
|
|
87
|
+
} : {};
|
|
88
|
+
const wrapper = (wrapperChildren)=>/*#__PURE__*/ jsxs("div", {
|
|
89
|
+
className: classes,
|
|
90
|
+
...wrapperProperties,
|
|
91
|
+
children: [
|
|
92
|
+
/*#__PURE__*/ jsx("div", {
|
|
93
|
+
style: {
|
|
94
|
+
opacity: isEditorOpen ? 0 : 1
|
|
95
|
+
},
|
|
96
|
+
className: "fwe-color-label",
|
|
97
|
+
children: label
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ jsxs("div", {
|
|
100
|
+
className: "fwe-color-container",
|
|
101
|
+
children: [
|
|
102
|
+
wrapperChildren,
|
|
103
|
+
' ',
|
|
104
|
+
text && /*#__PURE__*/ jsx("div", {
|
|
105
|
+
className: "fwe-color-indicator-text",
|
|
106
|
+
children: text
|
|
107
|
+
}),
|
|
108
|
+
' '
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
return showPopOver ? /*#__PURE__*/ jsx(Popover, {
|
|
114
|
+
containerClassName: "fwe-popover-container--color-indicator",
|
|
115
|
+
position: "top",
|
|
116
|
+
flip: false,
|
|
117
|
+
wrapper: wrapper,
|
|
118
|
+
popoverContent: children,
|
|
119
|
+
open: isEditorOpen,
|
|
120
|
+
onStatusChange: setEditorOpen,
|
|
121
|
+
stopPropagation: true,
|
|
122
|
+
children: colorBox
|
|
123
|
+
}) : wrapper(colorBox);
|
|
124
|
+
}
|
|
125
|
+
export { ColorIndicator };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import simplebar_react from "simplebar-react";
|
|
3
|
+
function ScrollArea({ children, scrollbarMinSize = 25, ...props }) {
|
|
4
|
+
return /*#__PURE__*/ jsx(simplebar_react, {
|
|
5
|
+
...props,
|
|
6
|
+
scrollbarMinSize: scrollbarMinSize,
|
|
7
|
+
children: children
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export { ScrollArea };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function rgbToHsv(rgb: Record<'r' | 'g' | 'b', number>): Record<'h' | 's' | 'v', number> | undefined;
|
|
2
|
+
export declare function hsvToRgb(_hsv: Record<'h' | 's' | 'v', number>): Record<'r' | 'g' | 'b', number>;
|
|
3
|
+
export declare function numberToHex(rgb: number): string;
|
|
4
|
+
export declare function rgbToHex(_rgb: Record<'r' | 'g' | 'b', number>): string;
|
|
5
|
+
export declare function hexToRgb(hexString: string): Record<'r' | 'g' | 'b', number> | undefined;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
function rgbToHsv(rgb) {
|
|
2
|
+
if (!rgb) return;
|
|
3
|
+
const r = limitToByte(rgb.r) / 255;
|
|
4
|
+
const g = limitToByte(rgb.g) / 255;
|
|
5
|
+
const b = limitToByte(rgb.b) / 255;
|
|
6
|
+
const max = Math.max(r, g, b);
|
|
7
|
+
const min = Math.min(r, g, b);
|
|
8
|
+
let h = max;
|
|
9
|
+
let s = max;
|
|
10
|
+
const v = max;
|
|
11
|
+
const d = max - min;
|
|
12
|
+
s = 0 === max ? 0 : d / max;
|
|
13
|
+
if (max === min) h = 0;
|
|
14
|
+
else {
|
|
15
|
+
switch(max){
|
|
16
|
+
case r:
|
|
17
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
18
|
+
break;
|
|
19
|
+
case g:
|
|
20
|
+
h = (b - r) / d + 2;
|
|
21
|
+
break;
|
|
22
|
+
case b:
|
|
23
|
+
h = (r - g) / d + 4;
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
}
|
|
27
|
+
h /= 6;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
h,
|
|
31
|
+
s,
|
|
32
|
+
v
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function hsvToRgb(_hsv) {
|
|
36
|
+
const hsv = _hsv;
|
|
37
|
+
hsv.h = limitToOne(_hsv.h);
|
|
38
|
+
hsv.s = limitToOne(_hsv.s);
|
|
39
|
+
hsv.v = limitToOne(_hsv.v);
|
|
40
|
+
let r = 0;
|
|
41
|
+
let g = 0;
|
|
42
|
+
let b = 0;
|
|
43
|
+
const i = Math.floor(6 * hsv.h);
|
|
44
|
+
const f = 6 * hsv.h - i;
|
|
45
|
+
const p = hsv.v * (1 - hsv.s);
|
|
46
|
+
const q = hsv.v * (1 - f * hsv.s);
|
|
47
|
+
const t = hsv.v * (1 - (1 - f) * hsv.s);
|
|
48
|
+
switch(i % 6){
|
|
49
|
+
case 0:
|
|
50
|
+
r = hsv.v;
|
|
51
|
+
g = t;
|
|
52
|
+
b = p;
|
|
53
|
+
break;
|
|
54
|
+
case 1:
|
|
55
|
+
r = q;
|
|
56
|
+
g = hsv.v;
|
|
57
|
+
b = p;
|
|
58
|
+
break;
|
|
59
|
+
case 2:
|
|
60
|
+
r = p;
|
|
61
|
+
g = hsv.v;
|
|
62
|
+
b = t;
|
|
63
|
+
break;
|
|
64
|
+
case 3:
|
|
65
|
+
r = p;
|
|
66
|
+
g = q;
|
|
67
|
+
b = hsv.v;
|
|
68
|
+
break;
|
|
69
|
+
case 4:
|
|
70
|
+
r = t;
|
|
71
|
+
g = p;
|
|
72
|
+
b = hsv.v;
|
|
73
|
+
break;
|
|
74
|
+
case 5:
|
|
75
|
+
r = hsv.v;
|
|
76
|
+
g = p;
|
|
77
|
+
b = q;
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
r: limitToByte(255 * r),
|
|
83
|
+
g: limitToByte(255 * g),
|
|
84
|
+
b: limitToByte(255 * b)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function limitToByte(num) {
|
|
88
|
+
if (num <= 0) return 0;
|
|
89
|
+
if (num >= 255) return 255;
|
|
90
|
+
return num;
|
|
91
|
+
}
|
|
92
|
+
function limitToOne(num) {
|
|
93
|
+
if (num <= 0) return 0;
|
|
94
|
+
if (num >= 1) return 1;
|
|
95
|
+
return num;
|
|
96
|
+
}
|
|
97
|
+
function numberToHex(rgb) {
|
|
98
|
+
let hex = Math.round(rgb).toString(16);
|
|
99
|
+
if (hex.length < 2) hex = `0${hex}`;
|
|
100
|
+
return hex.toUpperCase();
|
|
101
|
+
}
|
|
102
|
+
function rgbToHex(_rgb) {
|
|
103
|
+
const rgb = _rgb;
|
|
104
|
+
rgb.r = limitToByte(rgb.r);
|
|
105
|
+
rgb.g = limitToByte(rgb.g);
|
|
106
|
+
rgb.b = limitToByte(rgb.b);
|
|
107
|
+
const red = numberToHex(rgb.r);
|
|
108
|
+
const green = numberToHex(rgb.g);
|
|
109
|
+
const blue = numberToHex(rgb.b);
|
|
110
|
+
return `#${red}${green}${blue}`;
|
|
111
|
+
}
|
|
112
|
+
function hexToRgb(hexString) {
|
|
113
|
+
const numbersOnly = hexString.substring(1);
|
|
114
|
+
const aRgbHex = numbersOnly.match(/.{1,2}/g);
|
|
115
|
+
return aRgbHex ? {
|
|
116
|
+
r: parseInt(aRgbHex[0], 16),
|
|
117
|
+
g: parseInt(aRgbHex[1], 16),
|
|
118
|
+
b: parseInt(aRgbHex[2], 16)
|
|
119
|
+
} : void 0;
|
|
120
|
+
}
|
|
121
|
+
export { hexToRgb, hsvToRgb, numberToHex, rgbToHex, rgbToHsv };
|