@festo-ui/react-extra 9.0.1 → 10.0.0-dev.827
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/README.md +3 -3
- package/dist/components/color-indicator/ColorIndicator.d.ts +6 -6
- package/dist/components/color-indicator/ColorIndicator.js +38 -42
- package/dist/components/scroll-area/ScrollArea.d.ts +4 -2
- package/dist/components/scroll-area/ScrollArea.js +7 -4
- package/dist/forms/color-picker/ColorHelper.js +6 -2
- package/dist/forms/color-picker/ColorPicker.css +3 -2
- package/dist/forms/color-picker/ColorPicker.d.ts +5 -3
- package/dist/forms/color-picker/ColorPicker.js +16 -7
- package/dist/forms/date-picker/DatePicker.d.ts +10 -11
- package/dist/forms/date-picker/DatePicker.js +69 -55
- package/dist/forms/date-range-picker/DateRangePicker.d.ts +10 -10
- package/dist/forms/date-range-picker/DateRangePicker.js +92 -61
- package/dist/forms/text-editor/TextEditor.d.ts +15 -16
- package/dist/forms/text-editor/TextEditor.js +59 -51
- package/dist/forms/text-editor/TextEditorButton.js +0 -1
- package/dist/index.d.ts +3 -3
- package/package.json +16 -15
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Install the dependencies:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
npm install
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Get started
|
|
@@ -13,11 +13,11 @@ pnpm install
|
|
|
13
13
|
Build the library:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
|
|
16
|
+
npm run build
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Build the library in watch mode:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
|
|
22
|
+
npm run dev
|
|
23
23
|
```
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
import './ColorIndicator.scss';
|
|
3
|
-
export interface ColorIndicatorProps {
|
|
4
|
-
className?: string;
|
|
3
|
+
export interface ColorIndicatorProps extends Omit<ComponentPropsWithoutRef<'div'>, 'color'> {
|
|
5
4
|
text: string;
|
|
6
5
|
label: string;
|
|
7
6
|
color?: string;
|
|
8
|
-
|
|
9
|
-
disabled?: boolean;
|
|
7
|
+
showPopover?: boolean;
|
|
10
8
|
}
|
|
11
|
-
export declare
|
|
9
|
+
export declare const ColorIndicator: (props: ColorIndicatorProps & {
|
|
10
|
+
children?: import("react").ReactNode | undefined;
|
|
11
|
+
} & import("react").RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Popover } from "@festo-ui/react";
|
|
3
3
|
import classnames from "classnames";
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { forwardRef, useState } from "react";
|
|
5
5
|
import "./ColorIndicator.css";
|
|
6
|
-
|
|
7
|
-
const classes = classnames('fwe-color-indicator', className, disabled);
|
|
6
|
+
const ColorIndicator = /*#__PURE__*/ forwardRef(({ text, label, color, className, showPopover = false, children, ...props }, ref)=>{
|
|
8
7
|
const [isEditorOpen, setEditorOpen] = useState(false);
|
|
9
8
|
function getBorderColor() {
|
|
10
9
|
if (!color || '#FFFFFF' === color.toUpperCase() || '#F0F2F3' === color.toUpperCase()) return '#b6bec6';
|
|
@@ -14,7 +13,8 @@ function ColorIndicator({ text, label, color, className, showPopOver = false, ch
|
|
|
14
13
|
className: "fwe-color-box",
|
|
15
14
|
style: {
|
|
16
15
|
background: color,
|
|
17
|
-
borderColor: getBorderColor()
|
|
16
|
+
borderColor: getBorderColor(),
|
|
17
|
+
cursor: showPopover ? 'pointer' : 'default'
|
|
18
18
|
},
|
|
19
19
|
children: !color && /*#__PURE__*/ jsxs("svg", {
|
|
20
20
|
className: "fwe-no-color-pattern",
|
|
@@ -82,42 +82,38 @@ function ColorIndicator({ text, label, color, className, showPopOver = false, ch
|
|
|
82
82
|
]
|
|
83
83
|
})
|
|
84
84
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
stopPropagation: true,
|
|
120
|
-
children: colorBox
|
|
121
|
-
}) : wrapper(colorBox);
|
|
122
|
-
}
|
|
85
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
86
|
+
className: classnames('fwe-color-indicator', className),
|
|
87
|
+
ref: ref,
|
|
88
|
+
...props,
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ jsx("div", {
|
|
91
|
+
style: {
|
|
92
|
+
opacity: isEditorOpen ? 0 : 1
|
|
93
|
+
},
|
|
94
|
+
className: "fwe-color-label",
|
|
95
|
+
children: label
|
|
96
|
+
}),
|
|
97
|
+
/*#__PURE__*/ jsxs("div", {
|
|
98
|
+
className: "fwe-color-container",
|
|
99
|
+
children: [
|
|
100
|
+
showPopover ? /*#__PURE__*/ jsx(Popover, {
|
|
101
|
+
position: "top",
|
|
102
|
+
content: children,
|
|
103
|
+
isOpen: isEditorOpen,
|
|
104
|
+
onChange: setEditorOpen,
|
|
105
|
+
stopPropagation: true,
|
|
106
|
+
children: colorBox
|
|
107
|
+
}) : colorBox,
|
|
108
|
+
text && /*#__PURE__*/ jsx("div", {
|
|
109
|
+
className: "fwe-color-indicator-text",
|
|
110
|
+
children: text
|
|
111
|
+
}),
|
|
112
|
+
' '
|
|
113
|
+
]
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
ColorIndicator.displayName = 'ColorIndicator';
|
|
123
119
|
export { ColorIndicator };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type SimpleBarCore from 'simplebar-core';
|
|
3
|
+
export interface ScrollAreaProps extends ComponentPropsWithoutRef<'div'> {
|
|
2
4
|
readonly scrollbarMinSize?: number;
|
|
3
5
|
}
|
|
4
|
-
export declare
|
|
6
|
+
export declare const ScrollArea: (props: ScrollAreaProps & import("react").RefAttributes<SimpleBarCore | null>) => React.ReactElement | null;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import { forwardRef } from "react";
|
|
2
4
|
import simplebar_react from "simplebar-react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
const ScrollArea = /*#__PURE__*/ forwardRef(({ children, className, scrollbarMinSize = 25, ...props }, ref)=>/*#__PURE__*/ jsx(simplebar_react, {
|
|
6
|
+
ref: ref,
|
|
7
|
+
className: classnames(className),
|
|
5
8
|
...props,
|
|
6
9
|
scrollbarMinSize: scrollbarMinSize,
|
|
7
10
|
children: children
|
|
8
|
-
});
|
|
9
|
-
|
|
11
|
+
}));
|
|
12
|
+
ScrollArea.displayName = 'ScrollArea';
|
|
10
13
|
export { ScrollArea };
|
|
@@ -33,7 +33,9 @@ function rgbToHsv(rgb) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function hsvToRgb(_hsv) {
|
|
36
|
-
const hsv =
|
|
36
|
+
const hsv = {
|
|
37
|
+
..._hsv
|
|
38
|
+
};
|
|
37
39
|
hsv.h = limitToOne(_hsv.h);
|
|
38
40
|
hsv.s = limitToOne(_hsv.s);
|
|
39
41
|
hsv.v = limitToOne(_hsv.v);
|
|
@@ -100,7 +102,9 @@ function numberToHex(rgb) {
|
|
|
100
102
|
return hex.toUpperCase();
|
|
101
103
|
}
|
|
102
104
|
function rgbToHex(_rgb) {
|
|
103
|
-
const rgb =
|
|
105
|
+
const rgb = {
|
|
106
|
+
..._rgb
|
|
107
|
+
};
|
|
104
108
|
rgb.r = limitToByte(rgb.r);
|
|
105
109
|
rgb.g = limitToByte(rgb.g);
|
|
106
110
|
rgb.b = limitToByte(rgb.b);
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
padding: 16px;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
.fwe-popover-menu-trigger
|
|
156
|
+
.fwe-popover-menu-trigger {
|
|
157
157
|
cursor: pointer;
|
|
158
158
|
background: none;
|
|
159
159
|
border: none;
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
display: block;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
.fwe-popover-menu-trigger
|
|
166
|
+
.fwe-popover-menu-trigger:hover {
|
|
167
167
|
color: var(--fwe-hero);
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -358,6 +358,7 @@
|
|
|
358
358
|
align-items: center;
|
|
359
359
|
margin-bottom: 8px;
|
|
360
360
|
margin-right: 8px;
|
|
361
|
+
padding: 0;
|
|
361
362
|
display: flex;
|
|
362
363
|
}
|
|
363
364
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
1
3
|
import './ColorPicker.scss';
|
|
2
|
-
export interface ColorPickerProps {
|
|
3
|
-
readonly
|
|
4
|
+
export interface ColorPickerProps extends Omit<ComponentPropsWithoutRef<'div'>, 'color' | 'onChange'> {
|
|
5
|
+
readonly name?: string;
|
|
4
6
|
readonly palette?: string[];
|
|
5
7
|
readonly useAlpha?: boolean;
|
|
6
8
|
readonly alpha?: number;
|
|
@@ -9,4 +11,4 @@ export interface ColorPickerProps {
|
|
|
9
11
|
readonly onChange?: (color?: string | null) => void;
|
|
10
12
|
readonly onAlphaChange?: (alpha?: number) => void;
|
|
11
13
|
}
|
|
12
|
-
export declare
|
|
14
|
+
export declare const ColorPicker: (props: ColorPickerProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { IconCheckSmall, IconCollapse } from "@festo-ui/react-icons";
|
|
3
3
|
import classnames from "classnames";
|
|
4
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
5
5
|
import react_draggable from "react-draggable";
|
|
6
6
|
import "./ColorPicker.css";
|
|
7
7
|
import { useId } from "../../utils/useId.js";
|
|
@@ -19,7 +19,7 @@ const PREDEFINED_COLORS = [
|
|
|
19
19
|
'#ff9600',
|
|
20
20
|
'#d50000'
|
|
21
21
|
];
|
|
22
|
-
|
|
22
|
+
const ColorPicker = /*#__PURE__*/ forwardRef(({ className, name, palette = PREDEFINED_COLORS, useAlpha = false, alpha = 100, paletteOnly, color = '#FFFFFF', onChange, onAlphaChange, ...props }, ref)=>{
|
|
23
23
|
const baseSize = 184;
|
|
24
24
|
const initialRgb = hexToRgb(color);
|
|
25
25
|
const defaultHsv = {
|
|
@@ -43,6 +43,7 @@ function ColorPicker({ className, palette = PREDEFINED_COLORS, useAlpha = false,
|
|
|
43
43
|
const blueId = useId();
|
|
44
44
|
const hexId = useId();
|
|
45
45
|
const alphaId = useId();
|
|
46
|
+
const patternId = useId();
|
|
46
47
|
const gradientKnobRef = useRef(null);
|
|
47
48
|
const hueKnobRef = useRef(null);
|
|
48
49
|
const alphaKnobRef = useRef(null);
|
|
@@ -210,10 +211,17 @@ function ColorPicker({ className, palette = PREDEFINED_COLORS, useAlpha = false,
|
|
|
210
211
|
else updateColorRgb();
|
|
211
212
|
}
|
|
212
213
|
return /*#__PURE__*/ jsxs("div", {
|
|
214
|
+
ref: ref,
|
|
213
215
|
className: classnames('fwe-color-picker', {
|
|
214
216
|
'fwe-alpha-active': useAlpha
|
|
215
217
|
}, className),
|
|
218
|
+
...props,
|
|
216
219
|
children: [
|
|
220
|
+
name && /*#__PURE__*/ jsx("input", {
|
|
221
|
+
type: "hidden",
|
|
222
|
+
name: name,
|
|
223
|
+
value: innerColor ?? ''
|
|
224
|
+
}),
|
|
217
225
|
!paletteOnly && /*#__PURE__*/ jsxs("div", {
|
|
218
226
|
className: "fwe-d-flex",
|
|
219
227
|
children: [
|
|
@@ -345,7 +353,7 @@ function ColorPicker({ className, palette = PREDEFINED_COLORS, useAlpha = false,
|
|
|
345
353
|
children: [
|
|
346
354
|
/*#__PURE__*/ jsx("defs", {
|
|
347
355
|
children: /*#__PURE__*/ jsxs("pattern", {
|
|
348
|
-
id:
|
|
356
|
+
id: `bwsquare-alpha-${patternId}`,
|
|
349
357
|
width: "4",
|
|
350
358
|
height: "4",
|
|
351
359
|
patternUnits: "userSpaceOnUse",
|
|
@@ -392,7 +400,7 @@ function ColorPicker({ className, palette = PREDEFINED_COLORS, useAlpha = false,
|
|
|
392
400
|
ry: "4",
|
|
393
401
|
width: "8",
|
|
394
402
|
height: "184",
|
|
395
|
-
fill:
|
|
403
|
+
fill: `url(#bwsquare-alpha-${patternId})`,
|
|
396
404
|
strokeWidth: "0"
|
|
397
405
|
})
|
|
398
406
|
]
|
|
@@ -594,7 +602,7 @@ function ColorPicker({ className, palette = PREDEFINED_COLORS, useAlpha = false,
|
|
|
594
602
|
children: [
|
|
595
603
|
/*#__PURE__*/ jsx("defs", {
|
|
596
604
|
children: /*#__PURE__*/ jsxs("pattern", {
|
|
597
|
-
id:
|
|
605
|
+
id: `bwsquare-remove-${patternId}`,
|
|
598
606
|
width: "4",
|
|
599
607
|
height: "4",
|
|
600
608
|
patternUnits: "userSpaceOnUse",
|
|
@@ -641,7 +649,7 @@ function ColorPicker({ className, palette = PREDEFINED_COLORS, useAlpha = false,
|
|
|
641
649
|
ry: "0",
|
|
642
650
|
width: "18",
|
|
643
651
|
height: "18",
|
|
644
|
-
fill:
|
|
652
|
+
fill: `url(#bwsquare-remove-${patternId})`,
|
|
645
653
|
strokeWidth: "0"
|
|
646
654
|
})
|
|
647
655
|
]
|
|
@@ -671,5 +679,6 @@ function ColorPicker({ className, palette = PREDEFINED_COLORS, useAlpha = false,
|
|
|
671
679
|
})
|
|
672
680
|
]
|
|
673
681
|
});
|
|
674
|
-
}
|
|
682
|
+
});
|
|
683
|
+
ColorPicker.displayName = 'ColorPicker';
|
|
675
684
|
export { ColorPicker };
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
import './DatePicker.scss';
|
|
3
|
-
export interface
|
|
4
|
-
minDate?: Date;
|
|
5
|
-
maxDate?: Date;
|
|
6
|
-
keepOpenOnDateChange?: boolean;
|
|
7
|
-
position?: 'auto' | 'above' | 'below' | 'auto left' | 'auto center' | 'auto right' | 'above left' | 'above center' | 'above right' | 'below left' | 'below center' | 'below right';
|
|
8
|
-
}
|
|
9
|
-
export interface DatePickerProps {
|
|
10
|
-
className?: string;
|
|
3
|
+
export interface DatePickerProps extends Omit<ComponentPropsWithoutRef<'button'>, 'onChange' | 'value' | 'defaultValue' | 'disabled' | 'name'> {
|
|
11
4
|
disabled?: boolean;
|
|
12
5
|
required?: boolean;
|
|
6
|
+
name?: string;
|
|
13
7
|
hint?: string;
|
|
14
8
|
error?: string;
|
|
15
9
|
value?: Date;
|
|
16
10
|
defaultValue?: Date;
|
|
17
11
|
formatDate?: (date: Date) => string;
|
|
18
|
-
|
|
12
|
+
minDate?: Date;
|
|
13
|
+
maxDate?: Date;
|
|
14
|
+
keepOpenOnDateChange?: boolean;
|
|
15
|
+
position?: 'auto' | 'above' | 'below' | 'auto left' | 'auto center' | 'auto right' | 'above left' | 'above center' | 'above right' | 'below left' | 'below center' | 'below right';
|
|
19
16
|
onChange?: (date: Date) => void;
|
|
20
17
|
id?: string;
|
|
21
18
|
allowManualInput?: boolean;
|
|
22
19
|
dateFormat?: string;
|
|
23
20
|
openOnInputClick?: boolean;
|
|
24
21
|
}
|
|
25
|
-
export declare
|
|
22
|
+
export declare const DatePicker: (props: DatePickerProps & {
|
|
23
|
+
children?: import("react").ReactNode | undefined;
|
|
24
|
+
} & import("react").RefAttributes<HTMLButtonElement>) => React.ReactElement | null;
|
|
@@ -2,13 +2,14 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { IconCalendar } from "@festo-ui/react-icons";
|
|
3
3
|
import classnames from "classnames";
|
|
4
4
|
import flatpickr from "flatpickr";
|
|
5
|
-
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
6
6
|
import "./DatePicker.css";
|
|
7
7
|
import { useId } from "../../utils/useId.js";
|
|
8
|
-
|
|
8
|
+
const DatePicker = /*#__PURE__*/ forwardRef(({ children, className, disabled, required, error, hint, name, value, defaultValue = new Date(), formatDate = Intl.DateTimeFormat().format, minDate, maxDate, keepOpenOnDateChange, position = 'below center', onChange, id: idProps, allowManualInput = false, dateFormat = 'd/m/Y', openOnInputClick = true, ...props }, ref)=>{
|
|
9
9
|
const id = useId(idProps);
|
|
10
10
|
const [open, setOpen] = useState(false);
|
|
11
11
|
const [calendar, setCalendar] = useState(null);
|
|
12
|
+
const [selectedDate, setSelectedDate] = useState(value || defaultValue);
|
|
12
13
|
const innerDefaultValue = value || defaultValue;
|
|
13
14
|
function toggle() {
|
|
14
15
|
const newOpen = !open;
|
|
@@ -17,9 +18,11 @@ function DatePicker({ children, className, disabled, required, error, hint, valu
|
|
|
17
18
|
else calendar?.close();
|
|
18
19
|
}
|
|
19
20
|
const datePickerRef = useRef(null);
|
|
20
|
-
const { keepOpenOnDateChange, maxDate, minDate, position = 'below center' } = options || {};
|
|
21
21
|
useEffect(()=>{
|
|
22
|
-
if (null !== calendar && void 0 !== value)
|
|
22
|
+
if (null !== calendar && void 0 !== value) {
|
|
23
|
+
calendar.setDate(value);
|
|
24
|
+
setSelectedDate(value);
|
|
25
|
+
}
|
|
23
26
|
}, [
|
|
24
27
|
calendar,
|
|
25
28
|
value
|
|
@@ -27,6 +30,7 @@ function DatePicker({ children, className, disabled, required, error, hint, valu
|
|
|
27
30
|
useEffect(()=>{
|
|
28
31
|
function handleChange(date) {
|
|
29
32
|
datePickerRef.current?.blur();
|
|
33
|
+
setSelectedDate(date);
|
|
30
34
|
if (onChange) onChange(date);
|
|
31
35
|
}
|
|
32
36
|
function handleClose() {
|
|
@@ -78,61 +82,71 @@ function DatePicker({ children, className, disabled, required, error, hint, valu
|
|
|
78
82
|
const handleKeyUp = (event)=>{
|
|
79
83
|
if (' ' === event.key) toggle();
|
|
80
84
|
};
|
|
81
|
-
return /*#__PURE__*/
|
|
82
|
-
|
|
85
|
+
return /*#__PURE__*/ jsxs("button", {
|
|
86
|
+
ref: ref,
|
|
87
|
+
className: classnames('fr-date-picker', className),
|
|
83
88
|
type: "button",
|
|
84
89
|
onClick: toggle,
|
|
85
90
|
onKeyDown: handleKeyDown,
|
|
86
91
|
onKeyUp: handleKeyUp,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
92
|
+
...props,
|
|
93
|
+
children: [
|
|
94
|
+
name && /*#__PURE__*/ jsx("input", {
|
|
95
|
+
type: "hidden",
|
|
96
|
+
name: name,
|
|
97
|
+
value: selectedDate ? selectedDate.toISOString() : ''
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ jsxs("label", {
|
|
100
|
+
className: 'fwe-input-text fwe-input-text-icon',
|
|
101
|
+
htmlFor: id,
|
|
102
|
+
children: [
|
|
103
|
+
/*#__PURE__*/ jsx(IconCalendar, {
|
|
104
|
+
className: classnames({
|
|
105
|
+
'fwe-color-hero': open && !disabled,
|
|
106
|
+
'fwe-color-control-disabled': disabled,
|
|
107
|
+
'icon-hover': allowManualInput && !openOnInputClick
|
|
108
|
+
})
|
|
109
|
+
}),
|
|
110
|
+
/*#__PURE__*/ jsx("input", {
|
|
111
|
+
id: id,
|
|
112
|
+
ref: datePickerRef,
|
|
113
|
+
"aria-label": "picked date",
|
|
114
|
+
type: "text",
|
|
115
|
+
readOnly: !allowManualInput,
|
|
116
|
+
onClick: (e)=>{
|
|
117
|
+
if (allowManualInput && !openOnInputClick) e.stopPropagation();
|
|
118
|
+
},
|
|
119
|
+
onKeyDown: (e)=>{
|
|
120
|
+
if (allowManualInput && !openOnInputClick) e.stopPropagation();
|
|
121
|
+
},
|
|
122
|
+
onBlur: ()=>{
|
|
123
|
+
if (allowManualInput && calendar && datePickerRef.current) {
|
|
124
|
+
const raw = datePickerRef.current.value;
|
|
125
|
+
if (raw) calendar.setDate(raw, true, dateFormat);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
required: required,
|
|
129
|
+
className: classnames({
|
|
130
|
+
'fwe-border-hero': open && !disabled
|
|
131
|
+
}),
|
|
132
|
+
disabled: disabled
|
|
119
133
|
}),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
})
|
|
134
|
+
/*#__PURE__*/ jsx("span", {
|
|
135
|
+
className: "fwe-input-text-label",
|
|
136
|
+
children: children
|
|
137
|
+
}),
|
|
138
|
+
hint && /*#__PURE__*/ jsx("span", {
|
|
139
|
+
className: "fwe-input-text-info",
|
|
140
|
+
children: hint
|
|
141
|
+
}),
|
|
142
|
+
error && /*#__PURE__*/ jsx("span", {
|
|
143
|
+
className: "fwe-input-text-invalid fwe-d-block",
|
|
144
|
+
children: error
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
]
|
|
136
149
|
});
|
|
137
|
-
}
|
|
150
|
+
});
|
|
151
|
+
DatePicker.displayName = 'DatePicker';
|
|
138
152
|
export { DatePicker };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
import './DateRangePicker.scss';
|
|
3
|
-
export interface
|
|
4
|
-
maxDate?: Date;
|
|
5
|
-
minDate?: Date;
|
|
6
|
-
keepOpenOnDateChange?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface DateRangePickerProps {
|
|
9
|
-
className?: string;
|
|
3
|
+
export interface DateRangePickerProps extends Omit<ComponentPropsWithoutRef<'button'>, 'onChange' | 'defaultValue' | 'disabled' | 'name' | 'value'> {
|
|
10
4
|
disabled?: boolean;
|
|
11
5
|
required?: boolean;
|
|
6
|
+
name?: string;
|
|
12
7
|
hint?: string;
|
|
13
8
|
error?: string;
|
|
9
|
+
value?: Date[];
|
|
14
10
|
defaultValue?: Date;
|
|
15
11
|
formatDate?: (date: Date) => string;
|
|
16
|
-
|
|
12
|
+
minDate?: Date;
|
|
13
|
+
maxDate?: Date;
|
|
14
|
+
keepOpenOnDateChange?: boolean;
|
|
17
15
|
onChange?: (dates: Date[]) => void;
|
|
18
16
|
}
|
|
19
|
-
export declare
|
|
17
|
+
export declare const DateRangePicker: (props: DateRangePickerProps & {
|
|
18
|
+
children?: import("react").ReactNode | undefined;
|
|
19
|
+
} & import("react").RefAttributes<HTMLButtonElement>) => React.ReactElement | null;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { IconCalendar } from "@festo-ui/react-icons";
|
|
3
3
|
import classnames from "classnames";
|
|
4
4
|
import flatpickr from "flatpickr";
|
|
5
5
|
import rangePlugin from "flatpickr/dist/plugins/rangePlugin.js";
|
|
6
|
-
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
7
7
|
import "./DateRangePicker.css";
|
|
8
8
|
import { useId } from "../../utils/useId.js";
|
|
9
|
-
|
|
9
|
+
const DateRangePicker = /*#__PURE__*/ forwardRef(({ className, children, disabled, error, formatDate, hint, name, onChange, minDate, maxDate, keepOpenOnDateChange, required, value, defaultValue = new Date(), ...props }, ref)=>{
|
|
10
10
|
const [open, setOpen] = useState(false);
|
|
11
11
|
const [calendar, setCalendar] = useState(null);
|
|
12
|
+
const [selectedDates, setSelectedDates] = useState([]);
|
|
12
13
|
const id = useId();
|
|
13
14
|
function toggle() {
|
|
14
15
|
const newOpen = !open;
|
|
@@ -21,6 +22,7 @@ function DateRangePicker({ className, children, disabled, error, formatDate, hin
|
|
|
21
22
|
const containerRef = useRef(null);
|
|
22
23
|
useEffect(()=>{
|
|
23
24
|
function handleChange(dates) {
|
|
25
|
+
setSelectedDates(dates);
|
|
24
26
|
if (onChange) onChange(dates);
|
|
25
27
|
}
|
|
26
28
|
function handleClose() {
|
|
@@ -39,18 +41,29 @@ function DateRangePicker({ className, children, disabled, error, formatDate, hin
|
|
|
39
41
|
position: 'below center',
|
|
40
42
|
positionElement: containerRef.current,
|
|
41
43
|
formatDate,
|
|
42
|
-
closeOnSelect: !
|
|
44
|
+
closeOnSelect: !keepOpenOnDateChange,
|
|
43
45
|
clickOpens: false,
|
|
44
46
|
onClose: handleClose,
|
|
45
|
-
minDate
|
|
46
|
-
maxDate
|
|
47
|
+
minDate,
|
|
48
|
+
maxDate
|
|
47
49
|
}));
|
|
48
50
|
}, [
|
|
49
51
|
formatDate,
|
|
50
52
|
onChange,
|
|
51
53
|
calendar,
|
|
52
54
|
defaultValue,
|
|
53
|
-
|
|
55
|
+
keepOpenOnDateChange,
|
|
56
|
+
minDate,
|
|
57
|
+
maxDate
|
|
58
|
+
]);
|
|
59
|
+
useEffect(()=>{
|
|
60
|
+
if (null !== calendar && void 0 !== value) {
|
|
61
|
+
calendar.setDate(value);
|
|
62
|
+
setSelectedDates(value);
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
calendar,
|
|
66
|
+
value
|
|
54
67
|
]);
|
|
55
68
|
useEffect(()=>()=>{
|
|
56
69
|
if (null !== calendar) calendar.destroy();
|
|
@@ -63,68 +76,86 @@ function DateRangePicker({ className, children, disabled, error, formatDate, hin
|
|
|
63
76
|
const handleKeyUp = (event)=>{
|
|
64
77
|
if (' ' === event.key) toggle();
|
|
65
78
|
};
|
|
66
|
-
return /*#__PURE__*/
|
|
67
|
-
|
|
79
|
+
return /*#__PURE__*/ jsxs("button", {
|
|
80
|
+
ref: ref,
|
|
68
81
|
type: "button",
|
|
69
82
|
className: classnames('fr-date-range-picker', className),
|
|
70
83
|
onClick: toggle,
|
|
71
84
|
onKeyDown: handleKeyDown,
|
|
72
85
|
onKeyUp: handleKeyUp,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
'
|
|
86
|
+
...props,
|
|
87
|
+
children: [
|
|
88
|
+
name && /*#__PURE__*/ jsxs(Fragment, {
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ jsx("input", {
|
|
91
|
+
type: "hidden",
|
|
92
|
+
name: `${name}-start`,
|
|
93
|
+
value: selectedDates[0] ? selectedDates[0].toISOString() : ''
|
|
94
|
+
}),
|
|
95
|
+
/*#__PURE__*/ jsx("input", {
|
|
96
|
+
type: "hidden",
|
|
97
|
+
name: `${name}-end`,
|
|
98
|
+
value: selectedDates[1] ? selectedDates[1].toISOString() : ''
|
|
81
99
|
})
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
]
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ jsxs("label", {
|
|
103
|
+
className: "fwe-input-text fwe-input-text-icon",
|
|
104
|
+
htmlFor: id,
|
|
105
|
+
children: [
|
|
106
|
+
/*#__PURE__*/ jsx(IconCalendar, {
|
|
107
|
+
className: classnames({
|
|
108
|
+
'fwe-color-hero': open && !disabled,
|
|
109
|
+
'fwe-color-control-disabled': disabled
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ jsxs("div", {
|
|
113
|
+
ref: containerRef,
|
|
114
|
+
className: "fr-date-range-picker-inputs",
|
|
115
|
+
children: [
|
|
116
|
+
/*#__PURE__*/ jsx("input", {
|
|
117
|
+
ref: inputRef,
|
|
118
|
+
"aria-label": "picked start date",
|
|
119
|
+
type: "text",
|
|
120
|
+
readOnly: true,
|
|
121
|
+
required: required,
|
|
122
|
+
className: classnames({
|
|
123
|
+
'fwe-border-hero': open && !disabled
|
|
124
|
+
}),
|
|
125
|
+
disabled: disabled,
|
|
126
|
+
id: id
|
|
95
127
|
}),
|
|
96
|
-
|
|
97
|
-
|
|
128
|
+
/*#__PURE__*/ jsx("input", {
|
|
129
|
+
ref: input2Ref,
|
|
130
|
+
"aria-label": "picked end date",
|
|
131
|
+
type: "text",
|
|
132
|
+
readOnly: true,
|
|
133
|
+
required: required,
|
|
134
|
+
className: classnames({
|
|
135
|
+
'fwe-border-hero': open && !disabled
|
|
136
|
+
}),
|
|
137
|
+
disabled: disabled
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ jsx("span", {
|
|
142
|
+
className: classnames('fwe-input-text-label', {
|
|
143
|
+
'fwe-color-text-disabled': disabled
|
|
98
144
|
}),
|
|
99
|
-
|
|
100
|
-
ref: input2Ref,
|
|
101
|
-
"aria-label": "picked end date",
|
|
102
|
-
type: "text",
|
|
103
|
-
readOnly: true,
|
|
104
|
-
required: required,
|
|
105
|
-
className: classnames({
|
|
106
|
-
'fwe-border-hero': open && !disabled
|
|
107
|
-
}),
|
|
108
|
-
disabled: disabled
|
|
109
|
-
})
|
|
110
|
-
]
|
|
111
|
-
}),
|
|
112
|
-
/*#__PURE__*/ jsx("span", {
|
|
113
|
-
className: classnames('fwe-input-text-label', {
|
|
114
|
-
'fwe-color-text-disabled': disabled
|
|
145
|
+
children: children
|
|
115
146
|
}),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
})
|
|
147
|
+
hint && /*#__PURE__*/ jsx("span", {
|
|
148
|
+
className: "fwe-input-text-info",
|
|
149
|
+
children: hint
|
|
150
|
+
}),
|
|
151
|
+
error && /*#__PURE__*/ jsx("span", {
|
|
152
|
+
className: "fwe-input-text-invalid fwe-d-block",
|
|
153
|
+
children: error
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
})
|
|
157
|
+
]
|
|
128
158
|
});
|
|
129
|
-
}
|
|
159
|
+
});
|
|
160
|
+
DateRangePicker.displayName = 'DateRangePicker';
|
|
130
161
|
export { DateRangePicker };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
1
2
|
import './TextEditor.scss';
|
|
2
|
-
export interface
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
link?: boolean;
|
|
13
|
-
};
|
|
3
|
+
export interface TextEditorToolbarConfig {
|
|
4
|
+
bold?: boolean;
|
|
5
|
+
italic?: boolean;
|
|
6
|
+
underline?: boolean;
|
|
7
|
+
alignCenter?: boolean;
|
|
8
|
+
alignRight?: boolean;
|
|
9
|
+
bulletList?: boolean;
|
|
10
|
+
orderedList?: boolean;
|
|
11
|
+
image?: boolean;
|
|
12
|
+
link?: boolean;
|
|
14
13
|
}
|
|
15
|
-
export interface TextEditorProps {
|
|
14
|
+
export interface TextEditorProps extends Omit<ComponentPropsWithoutRef<'label'>, 'onChange' | 'defaultValue'> {
|
|
16
15
|
readonly disabled?: boolean;
|
|
17
16
|
readonly label: string;
|
|
17
|
+
readonly name?: string;
|
|
18
18
|
readonly maxLength?: number;
|
|
19
19
|
readonly value?: string;
|
|
20
20
|
readonly defaultValue?: string;
|
|
@@ -22,7 +22,6 @@ export interface TextEditorProps {
|
|
|
22
22
|
readonly error?: string;
|
|
23
23
|
readonly readOnly?: boolean;
|
|
24
24
|
readonly onChange?: (value: string | null) => void;
|
|
25
|
-
readonly
|
|
26
|
-
readonly config?: TextEditorConfiguration;
|
|
25
|
+
readonly toolbarConfig?: TextEditorToolbarConfig;
|
|
27
26
|
}
|
|
28
|
-
export declare
|
|
27
|
+
export declare const TextEditor: (props: TextEditorProps & import("react").RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import "./TextEditor.css";
|
|
5
5
|
import { IconAlignCenter, IconAlignRight, IconEnumeration, IconImage, IconLink, IconListView } from "@festo-ui/react-icons";
|
|
6
6
|
import quill from "quill";
|
|
7
7
|
import { filterXSS, whiteList as external_xss_whiteList } from "xss";
|
|
8
8
|
import { useId } from "../../utils/useId.js";
|
|
9
9
|
import { TextEditorButton } from "./TextEditorButton.js";
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
link: true
|
|
21
|
-
}
|
|
10
|
+
const defaultToolbarConfig = {
|
|
11
|
+
bold: true,
|
|
12
|
+
italic: true,
|
|
13
|
+
underline: true,
|
|
14
|
+
alignCenter: false,
|
|
15
|
+
alignRight: false,
|
|
16
|
+
bulletList: true,
|
|
17
|
+
orderedList: true,
|
|
18
|
+
image: true,
|
|
19
|
+
link: true
|
|
22
20
|
};
|
|
23
21
|
function postpone(fn) {
|
|
24
22
|
Promise.resolve().then(fn);
|
|
25
23
|
}
|
|
26
|
-
|
|
24
|
+
const TextEditor = /*#__PURE__*/ forwardRef(({ disabled = false, defaultValue, label, name, maxLength, value, hint, error, readOnly = false, onChange, className, toolbarConfig: toolbarConfigProps, ...props }, ref)=>{
|
|
27
25
|
const editorRef = useRef(null);
|
|
28
26
|
const [editor, setEditor] = useState(null);
|
|
29
27
|
const id = useId();
|
|
30
28
|
const [innerValue, setInnerValue] = useState(null);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...configProps?.toolbar
|
|
35
|
-
}
|
|
29
|
+
const toolbar = {
|
|
30
|
+
...defaultToolbarConfig,
|
|
31
|
+
...toolbarConfigProps
|
|
36
32
|
};
|
|
37
33
|
const setEditorContents = useCallback((e, v)=>{
|
|
38
34
|
if (e) {
|
|
@@ -90,16 +86,22 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
90
86
|
defaultValue
|
|
91
87
|
]);
|
|
92
88
|
useEffect(()=>{
|
|
93
|
-
if (editor)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
if (editor) {
|
|
90
|
+
const handler = ()=>{
|
|
91
|
+
let html = editor.getSemanticHTML();
|
|
92
|
+
if ('<p><br></p>' === html || '<div><br></div>' === html || void 0 === html) html = null;
|
|
93
|
+
if (null !== html) {
|
|
94
|
+
const relativeLinkRegex = /href="(?!https?:\/\/|mailto:|tel:)([^"]+)"/g;
|
|
95
|
+
html = html.replace(relativeLinkRegex, 'href="https://$1"');
|
|
96
|
+
}
|
|
97
|
+
if (onChange) onChange(html);
|
|
98
|
+
setInnerValue(html);
|
|
99
|
+
};
|
|
100
|
+
editor.on('text-change', handler);
|
|
101
|
+
return ()=>{
|
|
102
|
+
editor.off('text-change', handler);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
103
105
|
}, [
|
|
104
106
|
editor,
|
|
105
107
|
onChange
|
|
@@ -116,10 +118,10 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
116
118
|
return innerValue?.length || 0;
|
|
117
119
|
}
|
|
118
120
|
function hideDivider(name) {
|
|
119
|
-
const linkOrImage =
|
|
120
|
-
const lists =
|
|
121
|
-
const typos =
|
|
122
|
-
const textAlign =
|
|
121
|
+
const linkOrImage = toolbar.image || toolbar.link;
|
|
122
|
+
const lists = toolbar.bulletList || toolbar.orderedList;
|
|
123
|
+
const typos = toolbar.bold || toolbar.italic || toolbar.underline;
|
|
124
|
+
const textAlign = toolbar.alignCenter || toolbar.alignRight;
|
|
123
125
|
switch(name){
|
|
124
126
|
case 'typo':
|
|
125
127
|
return !typos || !textAlign && !linkOrImage && !lists;
|
|
@@ -128,39 +130,39 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
128
130
|
case 'lists':
|
|
129
131
|
return !lists || !linkOrImage;
|
|
130
132
|
case 'image':
|
|
131
|
-
return !
|
|
133
|
+
return !toolbar.image || !toolbar.link;
|
|
132
134
|
default:
|
|
133
135
|
break;
|
|
134
136
|
}
|
|
135
137
|
return true;
|
|
136
138
|
}
|
|
137
139
|
return /*#__PURE__*/ jsxs("label", {
|
|
140
|
+
ref: ref,
|
|
138
141
|
className: classnames('fwe-input-text', {
|
|
139
|
-
disabled
|
|
140
|
-
}),
|
|
142
|
+
'fwe-disabled': disabled
|
|
143
|
+
}, className),
|
|
141
144
|
htmlFor: `editor-label-${id}`,
|
|
145
|
+
...props,
|
|
142
146
|
children: [
|
|
143
147
|
/*#__PURE__*/ jsx("div", {
|
|
144
|
-
className:
|
|
145
|
-
[`fwe-editor-toolbar-${className}`]: className
|
|
146
|
-
}),
|
|
148
|
+
className: 'fwe-editor-toolbar',
|
|
147
149
|
id: `editor-toolbar-${id}`,
|
|
148
150
|
children: /*#__PURE__*/ jsxs("span", {
|
|
149
151
|
className: "ql-formats fwe-mr-3",
|
|
150
152
|
children: [
|
|
151
|
-
|
|
153
|
+
toolbar.bold && /*#__PURE__*/ jsx(TextEditorButton, {
|
|
152
154
|
disabled: disabled,
|
|
153
155
|
type: "bold",
|
|
154
156
|
className: "fwe-mr-3",
|
|
155
157
|
label: "B"
|
|
156
158
|
}),
|
|
157
|
-
|
|
159
|
+
toolbar.italic && /*#__PURE__*/ jsx(TextEditorButton, {
|
|
158
160
|
disabled: disabled,
|
|
159
161
|
type: "italic",
|
|
160
162
|
className: "fwe-mr-3",
|
|
161
163
|
label: "I"
|
|
162
164
|
}),
|
|
163
|
-
|
|
165
|
+
toolbar.underline && /*#__PURE__*/ jsx(TextEditorButton, {
|
|
164
166
|
disabled: disabled,
|
|
165
167
|
type: "underline",
|
|
166
168
|
label: "U"
|
|
@@ -168,7 +170,7 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
168
170
|
!hideDivider('typo') && /*#__PURE__*/ jsx("div", {
|
|
169
171
|
className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
|
|
170
172
|
}),
|
|
171
|
-
|
|
173
|
+
toolbar.alignCenter && /*#__PURE__*/ jsx(TextEditorButton, {
|
|
172
174
|
disabled: disabled,
|
|
173
175
|
category: "align",
|
|
174
176
|
type: "align-center",
|
|
@@ -179,10 +181,10 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
179
181
|
}),
|
|
180
182
|
value: "center",
|
|
181
183
|
className: classnames({
|
|
182
|
-
'fwe-mr-3':
|
|
184
|
+
'fwe-mr-3': toolbar.alignRight
|
|
183
185
|
})
|
|
184
186
|
}),
|
|
185
|
-
|
|
187
|
+
toolbar.alignRight && /*#__PURE__*/ jsx(TextEditorButton, {
|
|
186
188
|
disabled: disabled,
|
|
187
189
|
category: "align",
|
|
188
190
|
type: "align-right",
|
|
@@ -196,7 +198,7 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
196
198
|
!hideDivider('text-align') && /*#__PURE__*/ jsx("div", {
|
|
197
199
|
className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
|
|
198
200
|
}),
|
|
199
|
-
|
|
201
|
+
toolbar.bulletList && /*#__PURE__*/ jsx(TextEditorButton, {
|
|
200
202
|
disabled: disabled,
|
|
201
203
|
className: "fwe-mr-3",
|
|
202
204
|
type: "ul",
|
|
@@ -204,14 +206,14 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
204
206
|
icon: /*#__PURE__*/ jsx(IconListView, {}),
|
|
205
207
|
value: "bullet"
|
|
206
208
|
}),
|
|
207
|
-
|
|
209
|
+
toolbar.orderedList && /*#__PURE__*/ jsx(TextEditorButton, {
|
|
208
210
|
disabled: disabled,
|
|
209
211
|
type: "ol",
|
|
210
212
|
list: true,
|
|
211
213
|
icon: /*#__PURE__*/ jsx(IconEnumeration, {}),
|
|
212
214
|
value: "ordered"
|
|
213
215
|
}),
|
|
214
|
-
|
|
216
|
+
toolbar.image && /*#__PURE__*/ jsxs(Fragment, {
|
|
215
217
|
children: [
|
|
216
218
|
/*#__PURE__*/ jsx("div", {
|
|
217
219
|
className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
|
|
@@ -224,7 +226,7 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
224
226
|
})
|
|
225
227
|
]
|
|
226
228
|
}),
|
|
227
|
-
|
|
229
|
+
toolbar.link && /*#__PURE__*/ jsxs(Fragment, {
|
|
228
230
|
children: [
|
|
229
231
|
/*#__PURE__*/ jsx("div", {
|
|
230
232
|
className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
|
|
@@ -254,6 +256,11 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
254
256
|
className: "fwe-input-text-label",
|
|
255
257
|
children: label
|
|
256
258
|
}),
|
|
259
|
+
name && /*#__PURE__*/ jsx("input", {
|
|
260
|
+
type: "hidden",
|
|
261
|
+
name: name,
|
|
262
|
+
value: innerValue ?? ''
|
|
263
|
+
}),
|
|
257
264
|
error && /*#__PURE__*/ jsx("span", {
|
|
258
265
|
className: "fwe-text-editor-invalid",
|
|
259
266
|
children: error
|
|
@@ -262,11 +269,12 @@ function TextEditor({ disabled = false, defaultValue, label, maxLength, value, h
|
|
|
262
269
|
className: "fwe-text-editor-info",
|
|
263
270
|
children: hint
|
|
264
271
|
}),
|
|
265
|
-
maxLength && maxLength > 0 && null != value && /*#__PURE__*/ jsx("span", {
|
|
272
|
+
maxLength && maxLength > 0 && (null != innerValue || null != value) && /*#__PURE__*/ jsx("span", {
|
|
266
273
|
className: "fwe-input-text-count",
|
|
267
274
|
children: `${currentLength()} / ${maxLength}`
|
|
268
275
|
})
|
|
269
276
|
]
|
|
270
277
|
});
|
|
271
|
-
}
|
|
278
|
+
});
|
|
279
|
+
TextEditor.displayName = 'TextEditor';
|
|
272
280
|
export { TextEditor };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ColorIndicator, type ColorIndicatorProps, } from './components/color-indicator/ColorIndicator';
|
|
2
2
|
export { ScrollArea, type ScrollAreaProps, } from './components/scroll-area/ScrollArea';
|
|
3
3
|
export { ColorPicker, type ColorPickerProps, } from './forms/color-picker/ColorPicker';
|
|
4
|
-
export { DatePicker, type
|
|
5
|
-
export { DateRangePicker, type
|
|
6
|
-
export { TextEditor, type
|
|
4
|
+
export { DatePicker, type DatePickerProps, } from './forms/date-picker/DatePicker';
|
|
5
|
+
export { DateRangePicker, type DateRangePickerProps, } from './forms/date-range-picker/DateRangePicker';
|
|
6
|
+
export { TextEditor, type TextEditorProps, type TextEditorToolbarConfig, } from './forms/text-editor/TextEditor';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@festo-ui/react-extra",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-dev.827",
|
|
4
4
|
"license": "apache-2.0",
|
|
5
5
|
"author": "Festo UI (styleguide@festo.com)",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dev": "rslib build --watch",
|
|
26
26
|
"format": "biome check --write",
|
|
27
27
|
"lint": "biome check",
|
|
28
|
-
"storybook": "storybook dev -p
|
|
28
|
+
"storybook": "storybook dev -p 6008",
|
|
29
29
|
"test": "rstest",
|
|
30
30
|
"test:watch": "rstest --watch"
|
|
31
31
|
},
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@biomejs/biome": "2.3.2",
|
|
43
|
-
"@chromatic-com/storybook": "^
|
|
43
|
+
"@chromatic-com/storybook": "^5.0.0",
|
|
44
|
+
"@festo-ui/react": "9.0.1-dev.785",
|
|
44
45
|
"@rsbuild/core": "~1.6.2",
|
|
45
46
|
"@rsbuild/plugin-react": "^1.4.1",
|
|
46
47
|
"@rsbuild/plugin-sass": "^1.4.0",
|
|
@@ -48,25 +49,25 @@
|
|
|
48
49
|
"@rslib/core": "^0.17.1",
|
|
49
50
|
"@rstest/core": "^0.6.5",
|
|
50
51
|
"@rstest/coverage-istanbul": "^0.0.5",
|
|
51
|
-
"@storybook/addon-docs": "^
|
|
52
|
-
"@storybook/react": "^9.1.16",
|
|
52
|
+
"@storybook/addon-docs": "^10.2.3",
|
|
53
53
|
"@testing-library/jest-dom": "^6.9.1",
|
|
54
54
|
"@testing-library/react": "^16.3.0",
|
|
55
|
-
"@types/react": "^
|
|
55
|
+
"@types/react": "^19.2.0",
|
|
56
|
+
"@types/react-dom": "^19.2.0",
|
|
56
57
|
"cross-env": "^10.1.0",
|
|
57
58
|
"jsdom": "^26.1.0",
|
|
58
|
-
"react": "^
|
|
59
|
-
"react-dom": "^
|
|
60
|
-
"storybook": "^
|
|
61
|
-
"storybook-addon-rslib": "^2.
|
|
62
|
-
"storybook-react-rsbuild": "^2.
|
|
59
|
+
"react": "^19.2.0",
|
|
60
|
+
"react-dom": "^19.2.0",
|
|
61
|
+
"storybook": "^10.2.3",
|
|
62
|
+
"storybook-addon-rslib": "^3.2.2",
|
|
63
|
+
"storybook-react-rsbuild": "^3.2.2",
|
|
63
64
|
"typescript": "^5.9.3"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
|
-
"@festo-ui/react": "
|
|
67
|
-
"@festo-ui/web-essentials": "
|
|
68
|
-
"react": ">=
|
|
69
|
-
"react-dom": ">=
|
|
67
|
+
"@festo-ui/react": "*",
|
|
68
|
+
"@festo-ui/web-essentials": "*",
|
|
69
|
+
"react": ">=18.0.0",
|
|
70
|
+
"react-dom": ">=18.0.0"
|
|
70
71
|
},
|
|
71
72
|
"copyright": "Copyright (c) 2025 Festo SE & Co. KG. All rights reserved."
|
|
72
73
|
}
|