@festo-ui/react 4.0.3-pre-20221124.8 → 5.0.0-dev.46

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.
Files changed (228) hide show
  1. package/index.css +3 -3202
  2. package/index.d.ts +50 -48
  3. package/index.js +50 -4797
  4. package/lib/components/accordion/Accordion.d.ts +9 -9
  5. package/lib/components/accordion/Accordion.js +38 -0
  6. package/lib/components/accordion/AccordionContext.d.ts +11 -11
  7. package/lib/components/accordion/AccordionContext.js +3 -0
  8. package/lib/components/accordion/accordion-header/AccordionHeader.d.ts +4 -4
  9. package/lib/components/accordion/accordion-header/AccordionHeader.js +17 -0
  10. package/lib/components/accordion/accordion-item/AccordionItem.d.ts +9 -9
  11. package/lib/components/accordion/accordion-item/AccordionItem.js +64 -0
  12. package/lib/components/accordion/accordion-item/AccordionItemContext.d.ts +8 -8
  13. package/lib/components/accordion/accordion-item/AccordionItemContext.js +3 -0
  14. package/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.d.ts +4 -4
  15. package/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.js +71 -0
  16. package/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.d.ts +4 -4
  17. package/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.js +41 -0
  18. package/lib/components/breadcrumb/Breadcrumb.d.ts +14 -14
  19. package/lib/components/breadcrumb/Breadcrumb.js +45 -0
  20. package/lib/components/buttons/button/Button.d.ts +12 -12
  21. package/lib/components/buttons/button/Button.js +37 -0
  22. package/lib/components/card/Card.d.ts +4 -4
  23. package/lib/components/card/Card.js +13 -0
  24. package/lib/components/card/CardBody.d.ts +7 -7
  25. package/lib/components/card/CardBody.js +18 -0
  26. package/lib/components/card/CardHeader.d.ts +9 -9
  27. package/lib/components/card/CardHeader.js +23 -0
  28. package/lib/components/card/CardNotification.d.ts +9 -9
  29. package/lib/components/card/CardNotification.js +26 -0
  30. package/lib/components/chips/chip/Chip.d.ts +19 -19
  31. package/lib/components/chips/chip/Chip.js +46 -0
  32. package/lib/components/chips/chip/DeleteIcon.d.ts +2 -0
  33. package/lib/components/chips/chip/DeleteIcon.js +7 -0
  34. package/lib/components/chips/chip-container/ChipContainer.d.ts +8 -8
  35. package/lib/components/chips/chip-container/ChipContainer.js +17 -0
  36. package/lib/components/link-button/LinkButton.d.ts +10 -10
  37. package/lib/components/link-button/LinkButton.js +26 -0
  38. package/lib/components/loading-indicator/LoadingIndicator.d.ts +7 -7
  39. package/lib/components/loading-indicator/LoadingIndicator.js +40 -0
  40. package/lib/components/modals/AlertModal.d.ts +14 -14
  41. package/lib/components/modals/AlertModal.js +76 -0
  42. package/lib/components/modals/ConfirmModal.d.ts +13 -13
  43. package/lib/components/modals/ConfirmModal.js +56 -0
  44. package/lib/components/modals/Modal.d.ts +11 -11
  45. package/lib/components/modals/Modal.js +76 -0
  46. package/lib/components/modals/ModalFooter.d.ts +4 -4
  47. package/lib/components/modals/ModalFooter.js +18 -0
  48. package/lib/components/modals/Prompt.d.ts +16 -16
  49. package/lib/components/modals/Prompt.js +65 -0
  50. package/lib/components/pagination/Pagination.d.ts +17 -17
  51. package/lib/components/pagination/Pagination.js +107 -0
  52. package/lib/components/popovers/legend/Legend.d.ts +12 -12
  53. package/lib/components/popovers/legend/Legend.js +25 -0
  54. package/lib/components/popovers/popover/Popover.d.ts +18 -18
  55. package/lib/components/popovers/popover/Popover.js +109 -0
  56. package/lib/components/popovers/popover-menu/PopoverMenu.d.ts +15 -15
  57. package/lib/components/popovers/popover-menu/PopoverMenu.js +54 -0
  58. package/lib/components/popovers/tooltip/Tooltip.d.ts +10 -10
  59. package/lib/components/popovers/tooltip/Tooltip.js +64 -0
  60. package/lib/components/progress/Progress.d.ts +9 -9
  61. package/lib/components/progress/Progress.js +32 -0
  62. package/lib/components/search-input/ClearButton.d.ts +2 -0
  63. package/lib/components/search-input/ClearButton.js +10 -0
  64. package/lib/components/search-input/SearchInput.d.ts +15 -0
  65. package/lib/components/search-input/SearchInput.js +75 -0
  66. package/lib/components/search-input/SearchSuggestion.d.ts +17 -0
  67. package/lib/components/search-input/SearchSuggestion.js +32 -0
  68. package/lib/components/search-input/useSearchInput.d.ts +13 -0
  69. package/lib/components/search-input/useSearchInput.js +94 -0
  70. package/lib/components/snackbar/Snackbar.d.ts +23 -23
  71. package/lib/components/snackbar/Snackbar.js +87 -0
  72. package/lib/components/snackbar/SnackbarContext.d.ts +8 -8
  73. package/lib/components/snackbar/SnackbarContext.js +2 -0
  74. package/lib/components/snackbar/SnackbarProvider.d.ts +8 -8
  75. package/lib/components/snackbar/SnackbarProvider.js +58 -0
  76. package/lib/components/snackbar/useSnackbar.d.ts +3 -3
  77. package/lib/components/snackbar/useSnackbar.js +3 -0
  78. package/lib/components/stepper-horizontal/StepperHorizontal.d.ts +7 -7
  79. package/lib/components/stepper-horizontal/StepperHorizontal.js +62 -0
  80. package/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.d.ts +7 -7
  81. package/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.js +23 -0
  82. package/lib/components/stepper-vertical/StepperVertical.d.ts +7 -7
  83. package/lib/components/stepper-vertical/StepperVertical.js +37 -0
  84. package/lib/components/stepper-vertical/step-vertical/StepVertical.d.ts +12 -12
  85. package/lib/components/stepper-vertical/step-vertical/StepVertical.js +77 -0
  86. package/lib/components/tab/Tabs.d.ts +23 -23
  87. package/lib/components/tab/Tabs.js +229 -0
  88. package/lib/components/tab/interfaces.d.ts +5 -0
  89. package/lib/components/tab/interfaces.js +1 -0
  90. package/lib/components/tab/tab-pane/TabPane.d.ts +11 -13
  91. package/lib/components/tab/tab-pane/TabPane.js +23 -0
  92. package/lib/components/tab/useTabScroll.d.ts +24 -24
  93. package/lib/components/tab/useTabScroll.js +233 -0
  94. package/lib/components/table-header-cell/TableHeaderCell.d.ts +7 -7
  95. package/lib/components/table-header-cell/TableHeaderCell.js +21 -0
  96. package/lib/forms/checkbox/Checkbox.d.ts +16 -16
  97. package/lib/forms/checkbox/Checkbox.js +88 -0
  98. package/lib/forms/color-indicator/ColorIndicator.d.ts +12 -12
  99. package/lib/forms/color-indicator/ColorIndicator.js +122 -0
  100. package/lib/forms/color-picker/ColorHelper.d.ts +9 -9
  101. package/lib/forms/color-picker/ColorHelper.js +142 -0
  102. package/lib/forms/color-picker/ColorPicker.d.ts +15 -15
  103. package/lib/forms/color-picker/ColorPicker.js +539 -0
  104. package/lib/forms/date-picker/DatePicker.d.ts +22 -21
  105. package/lib/forms/date-picker/DatePicker.js +124 -0
  106. package/lib/forms/date-range-picker/DateRangePicker.d.ts +20 -20
  107. package/lib/forms/date-range-picker/DateRangePicker.js +135 -0
  108. package/lib/forms/radio/RadioButton.d.ts +15 -15
  109. package/lib/forms/radio/RadioButton.js +56 -0
  110. package/lib/forms/radio/RadioGroup.d.ts +13 -13
  111. package/lib/forms/radio/RadioGroup.js +35 -0
  112. package/lib/forms/radio/RadioGroupContext.d.ts +12 -12
  113. package/lib/forms/radio/RadioGroupContext.js +3 -0
  114. package/lib/forms/segment/Segment.d.ts +14 -14
  115. package/lib/forms/segment/Segment.js +77 -0
  116. package/lib/forms/segment/segment-control/SegmentControl.d.ts +15 -15
  117. package/lib/forms/segment/segment-control/SegmentControl.js +64 -0
  118. package/lib/forms/select/Select.d.ts +26 -26
  119. package/lib/forms/select/Select.js +281 -0
  120. package/lib/forms/select/select-option/SelectOption.d.ts +10 -10
  121. package/lib/forms/select/select-option/SelectOption.js +16 -0
  122. package/lib/forms/slider/Slider.d.ts +18 -17
  123. package/lib/forms/slider/Slider.js +92 -0
  124. package/lib/forms/switch/Switch.d.ts +13 -12
  125. package/lib/forms/switch/Switch.js +51 -0
  126. package/lib/forms/text-area/TextArea.d.ts +22 -21
  127. package/lib/forms/text-area/TextArea.js +108 -0
  128. package/lib/forms/text-editor/TextEditor.d.ts +29 -29
  129. package/lib/forms/text-editor/TextEditor.js +255 -0
  130. package/lib/forms/text-editor/TextEditorButton.d.ts +14 -14
  131. package/lib/forms/text-editor/TextEditorButton.js +82 -0
  132. package/lib/forms/text-input/TextInput.d.ts +21 -21
  133. package/lib/forms/text-input/TextInput.js +75 -0
  134. package/lib/forms/time-picker/TimePicker.d.ts +18 -18
  135. package/lib/forms/time-picker/TimePicker.js +161 -0
  136. package/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.d.ts +12 -12
  137. package/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.js +213 -0
  138. package/lib/helper/index.d.ts +2 -2
  139. package/lib/helper/index.js +7 -0
  140. package/lib/helper/setRef.d.ts +2 -2
  141. package/lib/helper/setRef.js +7 -0
  142. package/lib/helper/types.d.ts +7 -7
  143. package/lib/helper/types.js +1 -0
  144. package/lib/helper/useControlled.d.ts +6 -6
  145. package/lib/helper/useControlled.js +18 -0
  146. package/lib/helper/useForkRef.d.ts +2 -2
  147. package/lib/helper/useForkRef.js +20 -0
  148. package/lib/helper/useId.d.ts +1 -0
  149. package/lib/helper/useId.js +21 -0
  150. package/lib/helper/useOnClickOutside.d.ts +2 -2
  151. package/lib/helper/useOnClickOutside.js +18 -0
  152. package/node/index.js +370 -0
  153. package/node/lib/components/accordion/Accordion.js +46 -0
  154. package/node/lib/components/accordion/AccordionContext.js +10 -0
  155. package/node/lib/components/accordion/accordion-header/AccordionHeader.js +25 -0
  156. package/node/lib/components/accordion/accordion-item/AccordionItem.js +71 -0
  157. package/node/lib/components/accordion/accordion-item/AccordionItemContext.js +10 -0
  158. package/node/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.js +78 -0
  159. package/node/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.js +49 -0
  160. package/node/lib/components/breadcrumb/Breadcrumb.js +52 -0
  161. package/node/lib/components/buttons/button/Button.js +44 -0
  162. package/node/lib/components/card/Card.js +21 -0
  163. package/node/lib/components/card/CardBody.js +25 -0
  164. package/node/lib/components/card/CardHeader.js +30 -0
  165. package/node/lib/components/card/CardNotification.js +33 -0
  166. package/node/lib/components/chips/chip/Chip.js +54 -0
  167. package/node/lib/components/chips/chip/DeleteIcon.js +13 -0
  168. package/node/lib/components/chips/chip-container/ChipContainer.js +25 -0
  169. package/node/lib/components/link-button/LinkButton.js +33 -0
  170. package/node/lib/components/loading-indicator/LoadingIndicator.js +48 -0
  171. package/node/lib/components/modals/AlertModal.js +82 -0
  172. package/node/lib/components/modals/ConfirmModal.js +62 -0
  173. package/node/lib/components/modals/Modal.js +84 -0
  174. package/node/lib/components/modals/ModalFooter.js +26 -0
  175. package/node/lib/components/modals/Prompt.js +72 -0
  176. package/node/lib/components/pagination/Pagination.js +116 -0
  177. package/node/lib/components/popovers/legend/Legend.js +32 -0
  178. package/node/lib/components/popovers/popover/Popover.js +117 -0
  179. package/node/lib/components/popovers/popover-menu/PopoverMenu.js +61 -0
  180. package/node/lib/components/popovers/tooltip/Tooltip.js +70 -0
  181. package/node/lib/components/progress/Progress.js +40 -0
  182. package/node/lib/components/search-input/ClearButton.js +16 -0
  183. package/node/lib/components/search-input/SearchInput.js +82 -0
  184. package/node/lib/components/search-input/SearchSuggestion.js +39 -0
  185. package/node/lib/components/search-input/useSearchInput.js +101 -0
  186. package/node/lib/components/snackbar/Snackbar.js +94 -0
  187. package/node/lib/components/snackbar/SnackbarContext.js +10 -0
  188. package/node/lib/components/snackbar/SnackbarProvider.js +65 -0
  189. package/node/lib/components/snackbar/useSnackbar.js +11 -0
  190. package/node/lib/components/stepper-horizontal/StepperHorizontal.js +70 -0
  191. package/node/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.js +31 -0
  192. package/node/lib/components/stepper-vertical/StepperVertical.js +47 -0
  193. package/node/lib/components/stepper-vertical/step-vertical/StepVertical.js +84 -0
  194. package/node/lib/components/tab/Tabs.js +237 -0
  195. package/node/lib/components/tab/interfaces.js +5 -0
  196. package/node/lib/components/tab/tab-pane/TabPane.js +31 -0
  197. package/node/lib/components/tab/useTabScroll.js +236 -0
  198. package/node/lib/components/table-header-cell/TableHeaderCell.js +29 -0
  199. package/node/lib/forms/checkbox/Checkbox.js +97 -0
  200. package/node/lib/forms/color-indicator/ColorIndicator.js +130 -0
  201. package/node/lib/forms/color-picker/ColorHelper.js +149 -0
  202. package/node/lib/forms/color-picker/ColorPicker.js +549 -0
  203. package/node/lib/forms/date-picker/DatePicker.js +131 -0
  204. package/node/lib/forms/date-range-picker/DateRangePicker.js +142 -0
  205. package/node/lib/forms/radio/RadioButton.js +63 -0
  206. package/node/lib/forms/radio/RadioGroup.js +43 -0
  207. package/node/lib/forms/radio/RadioGroupContext.js +10 -0
  208. package/node/lib/forms/segment/Segment.js +84 -0
  209. package/node/lib/forms/segment/segment-control/SegmentControl.js +72 -0
  210. package/node/lib/forms/select/Select.js +289 -0
  211. package/node/lib/forms/select/select-option/SelectOption.js +26 -0
  212. package/node/lib/forms/slider/Slider.js +101 -0
  213. package/node/lib/forms/switch/Switch.js +58 -0
  214. package/node/lib/forms/text-area/TextArea.js +117 -0
  215. package/node/lib/forms/text-editor/TextEditor.js +261 -0
  216. package/node/lib/forms/text-editor/TextEditorButton.js +88 -0
  217. package/node/lib/forms/text-input/TextInput.js +84 -0
  218. package/node/lib/forms/time-picker/TimePicker.js +169 -0
  219. package/node/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.js +222 -0
  220. package/node/lib/helper/index.js +15 -0
  221. package/node/lib/helper/setRef.js +13 -0
  222. package/node/lib/helper/types.js +5 -0
  223. package/node/lib/helper/useControlled.js +24 -0
  224. package/node/lib/helper/useForkRef.js +26 -0
  225. package/node/lib/helper/useId.js +27 -0
  226. package/node/lib/helper/useOnClickOutside.js +24 -0
  227. package/package.json +20 -10
  228. package/README.md +0 -17
@@ -0,0 +1,108 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import useId from '../../helper/useId';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ function TextArea(_ref) {
7
+ let {
8
+ disabled,
9
+ onBlur,
10
+ onChange,
11
+ onFocus,
12
+ onInput,
13
+ readonly,
14
+ required,
15
+ label,
16
+ error,
17
+ hint,
18
+ value,
19
+ rows,
20
+ maxLength,
21
+ className,
22
+ id: idProps,
23
+ defaultValue
24
+ } = _ref;
25
+ const controlled = value !== undefined;
26
+ const [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
27
+ const id = useId(idProps);
28
+ const hintClasses = classNames('fwe-input-text-info');
29
+ const shadowRef = React.useRef(null);
30
+ const ref = React.useRef(null);
31
+ const [height, setHeight] = useState(undefined);
32
+ useEffect(() => {
33
+ if (controlled) {
34
+ setInnerValue(value);
35
+ }
36
+ }, [value, controlled]);
37
+ useEffect(() => {
38
+ const input = ref.current;
39
+ const shadow = shadowRef.current;
40
+ const minRows = 2;
41
+ if (shadow && input) {
42
+ shadow.value = input.value || 'x';
43
+ shadow.style.width = `${input.clientWidth}`;
44
+ const newHeight = Math.max(minRows * 24, shadow.scrollHeight);
45
+ setHeight(newHeight + 4 + 4 + 1);
46
+ }
47
+ }, [innerValue]);
48
+ function handleChange(event) {
49
+ if (!controlled) {
50
+ setInnerValue(event.target.value);
51
+ }
52
+ if (onChange) {
53
+ onChange(event);
54
+ }
55
+ }
56
+ return /*#__PURE__*/_jsxs("label", {
57
+ className: classNames('fwe-input-text', className),
58
+ htmlFor: id,
59
+ children: [/*#__PURE__*/_jsx("textarea", {
60
+ style: {
61
+ ...(!rows && {
62
+ height,
63
+ overflow: 'hidden'
64
+ })
65
+ },
66
+ ref: ref,
67
+ className: classNames('fr-textarea', `fwe-row-${rows}`),
68
+ disabled: disabled,
69
+ readOnly: readonly,
70
+ required: required,
71
+ autoComplete: "off",
72
+ onChange: handleChange,
73
+ onFocus: onFocus,
74
+ onInput: onInput,
75
+ onBlur: onBlur,
76
+ maxLength: maxLength,
77
+ defaultValue: innerValue,
78
+ value: innerValue,
79
+ id: id
80
+ }), /*#__PURE__*/_jsx("textarea", {
81
+ style: {
82
+ visibility: 'hidden',
83
+ position: 'absolute',
84
+ overflow: 'hidden',
85
+ height: 0,
86
+ top: 0,
87
+ left: 0,
88
+ transform: 'translateZ(0)',
89
+ padding: '0'
90
+ },
91
+ ref: shadowRef,
92
+ readOnly: true
93
+ }), /*#__PURE__*/_jsx("span", {
94
+ className: "fwe-input-text-label",
95
+ children: label
96
+ }), hint && /*#__PURE__*/_jsx("span", {
97
+ className: hintClasses,
98
+ children: hint
99
+ }), error !== undefined && /*#__PURE__*/_jsx("span", {
100
+ className: "fwe-input-text-invalid",
101
+ children: error
102
+ }), maxLength > 0 && innerValue !== undefined && /*#__PURE__*/_jsxs("span", {
103
+ className: "fwe-input-text-count",
104
+ children: [innerValue.length, " /", maxLength]
105
+ })]
106
+ });
107
+ }
108
+ export default TextArea;
@@ -1,29 +1,29 @@
1
- /// <reference types="react" />
2
- import './TextEditor.scss';
3
- export interface TextEditorConfiguration {
4
- toolbar?: {
5
- bold?: boolean;
6
- italic?: boolean;
7
- underline?: boolean;
8
- alignCenter?: boolean;
9
- alignRight?: boolean;
10
- bulletList?: boolean;
11
- orderedList?: boolean;
12
- image?: boolean;
13
- link?: boolean;
14
- };
15
- }
16
- export interface TextEditorProps {
17
- disabled?: boolean;
18
- label: string;
19
- maxLength?: number;
20
- value?: string;
21
- hint?: string;
22
- error?: string;
23
- readOnly?: boolean;
24
- onChange?: (value: string) => void;
25
- className?: string;
26
- config?: TextEditorConfiguration;
27
- }
28
- export declare function TextEditor({ disabled, label, maxLength, value, hint, error, readOnly, onChange, className, config: configProps }: TextEditorProps): JSX.Element;
29
- export default TextEditor;
1
+ /// <reference types="react" />
2
+ import './TextEditor.scss';
3
+ export interface TextEditorConfiguration {
4
+ toolbar?: {
5
+ bold?: boolean;
6
+ italic?: boolean;
7
+ underline?: boolean;
8
+ alignCenter?: boolean;
9
+ alignRight?: boolean;
10
+ bulletList?: boolean;
11
+ orderedList?: boolean;
12
+ image?: boolean;
13
+ link?: boolean;
14
+ };
15
+ }
16
+ export interface TextEditorProps {
17
+ disabled?: boolean;
18
+ label: string;
19
+ maxLength?: number;
20
+ value?: string;
21
+ hint?: string;
22
+ error?: string;
23
+ readOnly?: boolean;
24
+ onChange?: (value: string | null) => void;
25
+ className?: string;
26
+ config?: TextEditorConfiguration;
27
+ }
28
+ declare function TextEditor({ disabled, label, maxLength, value, hint, error, readOnly, onChange, className, config: configProps, }: TextEditorProps): JSX.Element;
29
+ export default TextEditor;
@@ -0,0 +1,255 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import TextEditorButton from './TextEditorButton';
4
+ import useId from '../../helper/useId';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ import { Fragment as _Fragment } from "react/jsx-runtime";
8
+ const xss = require('xss');
9
+ const defaultConfig = {
10
+ toolbar: {
11
+ bold: true,
12
+ italic: true,
13
+ underline: true,
14
+ alignCenter: true,
15
+ alignRight: true,
16
+ bulletList: true,
17
+ orderedList: true,
18
+ image: true,
19
+ link: true
20
+ }
21
+ };
22
+ function TextEditor(_ref) {
23
+ let {
24
+ disabled = false,
25
+ label,
26
+ maxLength,
27
+ value,
28
+ hint,
29
+ error,
30
+ readOnly = false,
31
+ onChange,
32
+ className,
33
+ config: configProps
34
+ } = _ref;
35
+ const editorRef = useRef(null);
36
+ const [editor, setEditor] = useState(null);
37
+ const id = useId();
38
+ const [innerValue, setInnerValue] = useState(value);
39
+ const config = {
40
+ toolbar: {
41
+ ...defaultConfig.toolbar,
42
+ ...configProps?.toolbar
43
+ }
44
+ };
45
+ useEffect(() => {
46
+ if (editorRef && editor === null && typeof window === 'object') {
47
+ // eslint-disable-next-line global-require
48
+ const Quill = require('quill');
49
+ const newEditor = new Quill(editorRef.current, {
50
+ modules: {
51
+ toolbar: `#editor-toolbar-${CSS.escape(id ?? '')}`
52
+ },
53
+ theme: 'snow',
54
+ scrollingContainer: `#editor-container-${CSS.escape(id ?? '')}`
55
+ });
56
+ newEditor.root.setAttribute('role', 'textbox');
57
+ newEditor.root.setAttribute('aria-labelledby', `editor-label-${id}`);
58
+ newEditor.root.setAttribute('aria-multiline', 'true');
59
+ newEditor.enable(!readOnly);
60
+ if (disabled) {
61
+ newEditor.disable();
62
+ } else if (!readOnly) {
63
+ newEditor.enable();
64
+ }
65
+
66
+ // set up a matcher that does allow/disallow to paste images corresponding to config settings
67
+ newEditor.clipboard.addMatcher('img', (_node, delta) => {
68
+ // allowed, passthru delta
69
+ if (config.toolbar?.image === true) {
70
+ return delta;
71
+ }
72
+
73
+ // not allowed, remove image by setting up a new delta
74
+ const Delta = Quill.import('quill-delta');
75
+ return new Delta().insert('');
76
+ });
77
+ setEditor(newEditor);
78
+ }
79
+ }, [editorRef, editor, disabled, readOnly, className, id, config.toolbar?.image]);
80
+ useEffect(() => {
81
+ if (editor) {
82
+ editor.on('text-change', () => {
83
+ let html = editor.root.innerHTML;
84
+ if (html === '<p><br></p>' || html === '<div><br></div>' || html === undefined) {
85
+ html = null;
86
+ }
87
+ if (onChange) {
88
+ onChange(html);
89
+ }
90
+ setInnerValue(html);
91
+ });
92
+ }
93
+ }, [editor, onChange]);
94
+ useEffect(() => {
95
+ if (editor) {
96
+ const whiteList = {
97
+ ...xss.whiteList,
98
+ a: [...xss.whiteList.a, 'rel']
99
+ };
100
+ const sanitizedValue = xss(value, {
101
+ whiteList
102
+ });
103
+ const content = editor.clipboard.convert(sanitizedValue);
104
+ editor.setContents(content, 'silent');
105
+ }
106
+ }, [editor, value]);
107
+ function currentLength() {
108
+ return innerValue?.length || 0;
109
+ }
110
+ function hideDivider(name) {
111
+ const linkOrImage = config.toolbar?.image || config.toolbar?.link;
112
+ const lists = config.toolbar?.bulletList || config.toolbar?.orderedList;
113
+ const typos = config.toolbar?.bold || config.toolbar?.italic || config.toolbar?.underline;
114
+ const textAlign = config.toolbar?.alignCenter || config.toolbar?.alignRight;
115
+ switch (name) {
116
+ case 'typo':
117
+ return !typos || !textAlign && !linkOrImage && !lists;
118
+ case 'text-align':
119
+ return !textAlign || !linkOrImage && !lists;
120
+ case 'lists':
121
+ return !lists || !linkOrImage;
122
+ case 'image':
123
+ return !config.toolbar?.image || !config.toolbar.link;
124
+ default:
125
+ break;
126
+ }
127
+ return true;
128
+ }
129
+ return /*#__PURE__*/_jsxs("label", {
130
+ className: classNames('fwe-input-text', {
131
+ disabled
132
+ }),
133
+ htmlFor: `editor-label-${id}`,
134
+ children: [/*#__PURE__*/_jsxs("div", {
135
+ className: classNames('fwe-editor-toolbar', {
136
+ [`fwe-editor-toolbar-${className}`]: className
137
+ }),
138
+ id: `editor-toolbar-${id}`,
139
+ children: [/*#__PURE__*/_jsx("span", {
140
+ className: "ql-formats fwe-d-none",
141
+ children: /*#__PURE__*/_jsxs("select", {
142
+ className: "ql-size",
143
+ "aria-hidden": "true",
144
+ children: [/*#__PURE__*/_jsx("option", {
145
+ value: "small",
146
+ "aria-label": "small"
147
+ }), /*#__PURE__*/_jsx("option", {
148
+ selected: true,
149
+ "aria-label": "selected"
150
+ }), /*#__PURE__*/_jsx("option", {
151
+ value: "large",
152
+ "aria-label": "large"
153
+ }), /*#__PURE__*/_jsx("option", {
154
+ value: "huge",
155
+ "aria-label": "huge"
156
+ })]
157
+ })
158
+ }), /*#__PURE__*/_jsxs("span", {
159
+ className: "ql-formats fwe-mr-3",
160
+ children: [config?.toolbar?.bold && /*#__PURE__*/_jsx(TextEditorButton, {
161
+ disabled: disabled,
162
+ type: "bold",
163
+ className: "fwe-mr-3",
164
+ label: "B"
165
+ }), config?.toolbar?.italic && /*#__PURE__*/_jsx(TextEditorButton, {
166
+ disabled: disabled,
167
+ type: "italic",
168
+ className: "fwe-mr-3",
169
+ label: "I"
170
+ }), config?.toolbar?.underline && /*#__PURE__*/_jsx(TextEditorButton, {
171
+ disabled: disabled,
172
+ type: "underline",
173
+ label: "U"
174
+ }), !hideDivider('typo') && /*#__PURE__*/_jsx("div", {
175
+ className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
176
+ }), config?.toolbar?.alignCenter && /*#__PURE__*/_jsx(TextEditorButton, {
177
+ disabled: disabled,
178
+ category: "align",
179
+ type: "align-center",
180
+ icon: classNames('text-align-center', {
181
+ 'fwe-gray': disabled
182
+ }),
183
+ value: "center",
184
+ className: classNames('fwe-btn-toolbar-list fwe-btn-toolbar-list-alignments', {
185
+ 'fwe-mr-3': config?.toolbar?.alignRight
186
+ })
187
+ }), config?.toolbar?.alignRight && /*#__PURE__*/_jsx(TextEditorButton, {
188
+ disabled: disabled,
189
+ category: "align",
190
+ type: "align-right",
191
+ icon: classNames('text-align-right', {
192
+ 'fwe-gray': disabled
193
+ }),
194
+ value: "right",
195
+ className: "fwe-btn-toolbar-list fwe-btn-toolbar-list-alignments"
196
+ }), !hideDivider('text-align') && /*#__PURE__*/_jsx("div", {
197
+ className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
198
+ }), config?.toolbar?.bulletList && /*#__PURE__*/_jsx(TextEditorButton, {
199
+ disabled: disabled,
200
+ className: "fwe-mr-3",
201
+ type: "ul",
202
+ list: true,
203
+ icon: "list-list-view",
204
+ value: "bullet"
205
+ }), config?.toolbar?.orderedList && /*#__PURE__*/_jsx(TextEditorButton, {
206
+ disabled: disabled,
207
+ type: "ol",
208
+ list: true,
209
+ icon: "enumeration",
210
+ value: "ordered"
211
+ }), config?.toolbar?.image && /*#__PURE__*/_jsxs(_Fragment, {
212
+ children: [/*#__PURE__*/_jsx("div", {
213
+ className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
214
+ }), /*#__PURE__*/_jsx(TextEditorButton, {
215
+ disabled: disabled,
216
+ type: "image",
217
+ icon: "image-image",
218
+ noAction: true
219
+ })]
220
+ }), config?.toolbar?.link && /*#__PURE__*/_jsxs(_Fragment, {
221
+ children: [/*#__PURE__*/_jsx("div", {
222
+ className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
223
+ }), /*#__PURE__*/_jsx(TextEditorButton, {
224
+ disabled: disabled,
225
+ type: "link",
226
+ icon: "file-link",
227
+ noAction: true
228
+ })]
229
+ })]
230
+ })]
231
+ }), /*#__PURE__*/_jsx("div", {
232
+ className: classNames('fwe-editor-container', {
233
+ 'fwe-editor-container--error': error
234
+ }),
235
+ id: `editor-container-${id}`,
236
+ children: /*#__PURE__*/_jsx("div", {
237
+ className: "fwe-editor",
238
+ ref: editorRef
239
+ })
240
+ }), /*#__PURE__*/_jsx("span", {
241
+ className: "fwe-input-text-label",
242
+ children: label
243
+ }), error && /*#__PURE__*/_jsx("span", {
244
+ className: "fwe-text-editor-invalid",
245
+ children: error
246
+ }), hint && /*#__PURE__*/_jsx("span", {
247
+ className: "fwe-text-editor-info",
248
+ children: hint
249
+ }), maxLength && maxLength > 0 && value != null && /*#__PURE__*/_jsx("span", {
250
+ className: "fwe-input-text-count",
251
+ children: `${currentLength()} / ${maxLength}`
252
+ })]
253
+ });
254
+ }
255
+ export default TextEditor;
@@ -1,14 +1,14 @@
1
- /// <reference types="react" />
2
- interface TextEditorButtonProps {
3
- type: string;
4
- label?: string;
5
- icon?: string;
6
- disabled: boolean;
7
- className?: string;
8
- list?: boolean;
9
- value?: string;
10
- noAction?: boolean;
11
- category?: string;
12
- }
13
- declare function TextEditorButton({ disabled, label, type, className, icon, list, value, noAction, category }: TextEditorButtonProps): JSX.Element;
14
- export default TextEditorButton;
1
+ /// <reference types="react" />
2
+ interface TextEditorButtonProps {
3
+ type: string;
4
+ label?: string;
5
+ icon?: string;
6
+ disabled: boolean;
7
+ className?: string;
8
+ list?: boolean;
9
+ value?: string;
10
+ noAction?: boolean;
11
+ category?: string;
12
+ }
13
+ declare function TextEditorButton({ disabled, label, type, className, icon, list, value, noAction, category, }: TextEditorButtonProps): JSX.Element;
14
+ export default TextEditorButton;
@@ -0,0 +1,82 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ function TextEditorButton(_ref) {
7
+ let {
8
+ disabled,
9
+ label,
10
+ type,
11
+ className,
12
+ icon,
13
+ list,
14
+ value,
15
+ noAction,
16
+ category
17
+ } = _ref;
18
+ const [active, setActive] = useState(false);
19
+ const btnRef = useRef(null);
20
+ function handleClick() {
21
+ const btn = btnRef.current;
22
+ setActive(prevActive => !prevActive);
23
+ btn?.click();
24
+ }
25
+ useEffect(() => {
26
+ function callback(mutationRecords) {
27
+ mutationRecords.forEach(mutationRecord => {
28
+ const {
29
+ classList
30
+ } = mutationRecord.target;
31
+ const {
32
+ oldValue
33
+ } = mutationRecord;
34
+ if (classList.contains('ql-active')) {
35
+ setActive(true);
36
+ }
37
+ if (!classList.contains('ql-active') && oldValue?.includes('ql-active')) {
38
+ setActive(false);
39
+ }
40
+ });
41
+ }
42
+ if (btnRef.current && !noAction) {
43
+ const observer = new MutationObserver(callback);
44
+ observer.observe(btnRef.current, {
45
+ attributes: true,
46
+ attributeFilter: ['class'],
47
+ attributeOldValue: true
48
+ });
49
+ }
50
+ }, [btnRef, noAction]);
51
+ return /*#__PURE__*/_jsxs(_Fragment, {
52
+ children: [/*#__PURE__*/_jsx("button", {
53
+ ref: btnRef,
54
+ type: "button",
55
+ className: classNames({
56
+ [`ql-${category || type}`]: !list
57
+ }, {
58
+ 'ql-list': list
59
+ }, 'fwe-d-none', {
60
+ [`action-${type}`]: !noAction
61
+ }),
62
+ "aria-hidden": "true",
63
+ value: value
64
+ }), /*#__PURE__*/_jsxs("button", {
65
+ type: "button",
66
+ className: classNames('fwe-btn', {
67
+ 'fwe-btn-toolbar-list': list
68
+ }, 'fr-button', className, {
69
+ 'fwe-active': active && !noAction
70
+ }),
71
+ onClick: () => handleClick(),
72
+ disabled: disabled,
73
+ children: [label && /*#__PURE__*/_jsx("div", {
74
+ className: `fr-button-text fwe-text-${type}`,
75
+ children: label
76
+ }), icon && /*#__PURE__*/_jsx("i", {
77
+ className: classNames('fwe-icon fwe-icon-toolbar-list', `fwe-icon-${icon}`, 'fwe-pr-0')
78
+ })]
79
+ })]
80
+ });
81
+ }
82
+ export default TextEditorButton;
@@ -1,21 +1,21 @@
1
- import React from 'react';
2
- interface TextInputProps {
3
- disabled?: boolean;
4
- required?: boolean;
5
- readonly?: boolean;
6
- placeholder?: string;
7
- type?: string;
8
- step?: string;
9
- min?: number;
10
- max?: number;
11
- value?: string;
12
- onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
13
- onInput?: (event: React.FormEvent<HTMLInputElement>) => void;
14
- onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
15
- label?: string;
16
- hint?: string;
17
- error?: string;
18
- labelClassName?: string;
19
- }
20
- declare const TextInput: React.FC<TextInputProps & React.HTMLProps<HTMLInputElement>>;
21
- export default TextInput;
1
+ import React from 'react';
2
+ interface TextInputProps {
3
+ disabled?: boolean;
4
+ required?: boolean;
5
+ readonly?: boolean;
6
+ placeholder?: string;
7
+ type?: string;
8
+ step?: string;
9
+ min?: number;
10
+ max?: number;
11
+ value?: string;
12
+ onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
13
+ onInput?: (event: React.FormEvent<HTMLInputElement>) => void;
14
+ onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
15
+ label?: string;
16
+ hint?: string;
17
+ error?: string;
18
+ labelClassName?: string;
19
+ }
20
+ declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputProps & React.HTMLProps<HTMLInputElement>, "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "value" | "list" | "step" | "type" | "height" | "start" | "content" | "size" | "default" | "wrap" | "open" | "multiple" | "disabled" | "href" | "action" | "selected" | "error" | "required" | "readonly" | "max" | "min" | "hint" | "labelClassName" | "accept" | "acceptCharset" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "dateTime" | "defer" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "maxLength" | "media" | "mediaGroup" | "method" | "minLength" | "muted" | "name" | "noValidate" | "optimum" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "shape" | "sizes" | "src" | "srcDoc" | "srcLang" | "srcSet" | "target" | "useMap" | "width" | "wmode"> & React.RefAttributes<HTMLLabelElement>>;
21
+ export default TextInput;
@@ -0,0 +1,75 @@
1
+ import React, { forwardRef, useEffect, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import useId from '../../helper/useId';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
7
+ let {
8
+ disabled,
9
+ required,
10
+ readonly,
11
+ placeholder,
12
+ max,
13
+ min,
14
+ onBlur,
15
+ onFocus,
16
+ onInput,
17
+ step,
18
+ type,
19
+ value,
20
+ error,
21
+ hint,
22
+ label,
23
+ labelClassName,
24
+ id: idProps,
25
+ ...props
26
+ } = _ref;
27
+ const id = useId(idProps);
28
+ const [innerValue, setInnerValue] = useState(value);
29
+ useEffect(() => {
30
+ setInnerValue(value);
31
+ }, [value]);
32
+ const supported = ['text', 'number', 'password', 'datetime-local'];
33
+ const innerType = type && supported.indexOf(type) !== -1 ? type : 'text';
34
+ const labelClasses = classNames('fwe-input-text', labelClassName);
35
+ const hintClasses = classNames('fwe-input-text-info');
36
+ function handleChange(e) {
37
+ setInnerValue(e.target.value);
38
+ if (props.onChange) {
39
+ props.onChange(e);
40
+ }
41
+ }
42
+ return /*#__PURE__*/_jsxs("label", {
43
+ className: labelClasses,
44
+ htmlFor: id,
45
+ ref: ref,
46
+ children: [/*#__PURE__*/_jsx("input", {
47
+ disabled: disabled,
48
+ required: required,
49
+ readOnly: readonly,
50
+ placeholder: placeholder,
51
+ autoComplete: "off",
52
+ min: min,
53
+ max: max,
54
+ step: step,
55
+ onChange: handleChange,
56
+ onBlur: onBlur,
57
+ onFocus: onFocus,
58
+ onInput: onInput,
59
+ type: innerType,
60
+ value: innerValue,
61
+ id: id,
62
+ ...props
63
+ }), /*#__PURE__*/_jsx("span", {
64
+ className: "fwe-input-text-label",
65
+ children: label
66
+ }), hint && /*#__PURE__*/_jsx("span", {
67
+ className: hintClasses,
68
+ children: hint
69
+ }), error && /*#__PURE__*/_jsx("span", {
70
+ className: "fwe-input-text-invalid",
71
+ children: error
72
+ })]
73
+ });
74
+ });
75
+ export default TextInput;