@festo-ui/react 4.0.3-pre-20221213.1 → 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,75 @@
1
+ import { useRef } from 'react';
2
+ import useSearchInput from './useSearchInput';
3
+ import useOnClickOutside from '../../helper/useOnClickOutside';
4
+ import ClearButton from './ClearButton';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ function SearchInput(_ref) {
8
+ let {
9
+ defaultValue,
10
+ disabled,
11
+ label,
12
+ value,
13
+ suggestions,
14
+ onChange,
15
+ onSearch,
16
+ onKeyboardNavigate
17
+ } = _ref;
18
+ const inputRef = useRef(null);
19
+ const containerRef = useRef(null);
20
+ const cappedSuggestions = suggestions?.slice(0, 10) ?? [];
21
+ const {
22
+ handleFocus,
23
+ handleInput,
24
+ handleClearQuery,
25
+ handleSuggestionClick,
26
+ handleOutsideClick,
27
+ handleKeyDown,
28
+ hideSuggestionList,
29
+ selectedSuggestionIndex,
30
+ innerValue
31
+ } = useSearchInput(inputRef, cappedSuggestions, value, defaultValue, onChange, onSearch, onKeyboardNavigate);
32
+ useOnClickOutside(containerRef, handleOutsideClick);
33
+ return /*#__PURE__*/_jsxs("div", {
34
+ className: "fwe-search-input fwe-w-100",
35
+ ref: containerRef,
36
+ children: [/*#__PURE__*/_jsx("input", {
37
+ ref: inputRef,
38
+ className: "fwe-w-100",
39
+ disabled: disabled,
40
+ placeholder: label,
41
+ onFocus: handleFocus,
42
+ type: "search",
43
+ onInput: handleInput,
44
+ onKeyDown: handleKeyDown,
45
+ value: innerValue
46
+ }), /*#__PURE__*/_jsx("div", {
47
+ className: "fwe-search-icon"
48
+ }), /*#__PURE__*/_jsx(ClearButton, {
49
+ onClick: handleClearQuery
50
+ }), Boolean(suggestions?.length) && !hideSuggestionList && /*#__PURE__*/_jsxs("div", {
51
+ className: "fwe-search-suggestions",
52
+ children: [cappedSuggestions.map((suggestion, i) =>
53
+ /*#__PURE__*/
54
+ // key event is handled via parent
55
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events
56
+ _jsx("div", {
57
+ role: "option",
58
+ tabIndex: -1,
59
+ "aria-selected": selectedSuggestionIndex === i,
60
+ onClick: () => handleSuggestionClick(suggestion),
61
+ className: `fwe-search-suggestion ${selectedSuggestionIndex === i ? 'fwe-selected' : ''}`,
62
+ children: /*#__PURE__*/_jsx("div", {
63
+ // eslint-disable-next-line react/no-danger
64
+ dangerouslySetInnerHTML: {
65
+ __html: suggestion.template
66
+ }
67
+ })
68
+ }, suggestion.value)), suggestions && suggestions.length > 10 && /*#__PURE__*/_jsx("div", {
69
+ className: "fwe-ml-xxs",
70
+ children: "..."
71
+ })]
72
+ })]
73
+ });
74
+ }
75
+ export default SearchInput;
@@ -0,0 +1,17 @@
1
+ export default class SearchSuggestion {
2
+ /**
3
+ * a html-string. e.g.: '<b> hello </b>'
4
+ */
5
+ template: string;
6
+ /**
7
+ * This Value will be used as new query when the user selects the suggestion.
8
+ */
9
+ value: string;
10
+ /**
11
+ * Creates a basic Suggestion from a string. The first query match is highlighted by bold tags.
12
+ * @param suggestionString The suggested string (should contain the whole query)
13
+ * @param query The current query. This string will be highlighted.
14
+ * @returns a html-string.
15
+ */
16
+ static basicSuggestion(suggestionString: string, query: string): SearchSuggestion;
17
+ }
@@ -0,0 +1,32 @@
1
+ export default class SearchSuggestion {
2
+ /**
3
+ * a html-string. e.g.: '<b> hello </b>'
4
+ */
5
+
6
+ /**
7
+ * This Value will be used as new query when the user selects the suggestion.
8
+ */
9
+
10
+ /**
11
+ * Creates a basic Suggestion from a string. The first query match is highlighted by bold tags.
12
+ * @param suggestionString The suggested string (should contain the whole query)
13
+ * @param query The current query. This string will be highlighted.
14
+ * @returns a html-string.
15
+ */
16
+ static basicSuggestion(suggestionString, query) {
17
+ const i = suggestionString.toLocaleLowerCase().indexOf(query.toLocaleLowerCase());
18
+ let template = suggestionString;
19
+ if (i !== -1) {
20
+ const boldStart = i;
21
+ const boldEnd = i + query.length;
22
+ const part1 = suggestionString.substring(0, boldStart);
23
+ const part2 = suggestionString.substring(boldStart, boldEnd);
24
+ const part3 = suggestionString.substring(boldEnd, suggestionString.length);
25
+ template = `${part1}<b>${part2}</b>${part3}`;
26
+ }
27
+ return {
28
+ value: suggestionString,
29
+ template
30
+ };
31
+ }
32
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import SearchSuggestion from './SearchSuggestion';
3
+ export default function useSearchInput(inputRef: React.MutableRefObject<HTMLInputElement | null>, cappedSuggestions: SearchSuggestion[], value?: string, defaultValue?: string, onChange?: (value: string) => void, onSearch?: (value: string) => void, onKeyboardNavigate?: (value: string) => void): {
4
+ innerValue: string | undefined;
5
+ hideSuggestionList: boolean;
6
+ selectedSuggestionIndex: number;
7
+ handleClearQuery: () => void;
8
+ handleFocus: () => void;
9
+ handleInput: (event: any) => void;
10
+ handleSuggestionClick: (suggestion: SearchSuggestion) => void;
11
+ handleOutsideClick: () => void;
12
+ handleKeyDown: (event: React.KeyboardEvent) => void;
13
+ };
@@ -0,0 +1,94 @@
1
+ import { useState } from 'react';
2
+ import useControlled from '../../helper/useControlled';
3
+ export default function useSearchInput(inputRef, cappedSuggestions, value) {
4
+ let defaultValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
5
+ let onChange = arguments.length > 4 ? arguments[4] : undefined;
6
+ let onSearch = arguments.length > 5 ? arguments[5] : undefined;
7
+ let onKeyboardNavigate = arguments.length > 6 ? arguments[6] : undefined;
8
+ const [innerValue, setValue] = useControlled({
9
+ controlled: value,
10
+ default: defaultValue
11
+ });
12
+ const [hideSuggestionList, setHideSuggestionList] = useState(false);
13
+ const [selectedSuggestionIndex, setSelectedSuggestionIndex] = useState(-1);
14
+ function blurInput() {
15
+ if (inputRef.current) {
16
+ inputRef.current.blur();
17
+ }
18
+ }
19
+ function reset() {
20
+ setSelectedSuggestionIndex(-1);
21
+ setHideSuggestionList(true);
22
+ blurInput();
23
+ }
24
+ function handleSearch() {
25
+ reset();
26
+ if (innerValue !== undefined) {
27
+ onSearch?.(innerValue);
28
+ }
29
+ }
30
+ function updateValue(newValue) {
31
+ setValue(newValue);
32
+ onChange?.(newValue);
33
+ onSearch?.(newValue);
34
+ }
35
+ function handleClearQuery() {
36
+ reset();
37
+ updateValue('');
38
+ }
39
+ function handleArrowKey(newSuggestionIndex) {
40
+ if (!cappedSuggestions || !cappedSuggestions.length) {
41
+ return;
42
+ }
43
+ const selectedSuggestion = cappedSuggestions[newSuggestionIndex];
44
+ setSelectedSuggestionIndex(newSuggestionIndex);
45
+ setValue(selectedSuggestion.value);
46
+ onKeyboardNavigate?.(selectedSuggestion.value);
47
+ }
48
+ function handleUpArrowKey() {
49
+ handleArrowKey(selectedSuggestionIndex > 0 ? selectedSuggestionIndex - 1 : cappedSuggestions.length - 1);
50
+ }
51
+ function handleDownArrowKey() {
52
+ handleArrowKey(selectedSuggestionIndex >= cappedSuggestions.length - 1 ? 0 : selectedSuggestionIndex + 1);
53
+ }
54
+ function handleKeyDown(event) {
55
+ switch (event.key) {
56
+ case 'Enter':
57
+ handleSearch();
58
+ break;
59
+ case 'Escape':
60
+ handleClearQuery();
61
+ break;
62
+ case 'ArrowUp':
63
+ handleUpArrowKey();
64
+ break;
65
+ case 'ArrowDown':
66
+ handleDownArrowKey();
67
+ break;
68
+ default:
69
+ break;
70
+ }
71
+ }
72
+ const handleFocus = () => setHideSuggestionList(false);
73
+ const handleOutsideClick = () => setHideSuggestionList(true);
74
+ function handleSuggestionClick(suggestion) {
75
+ reset();
76
+ updateValue(suggestion.value);
77
+ }
78
+ function handleInput(event) {
79
+ setSelectedSuggestionIndex(-1);
80
+ setValue(event.target.value);
81
+ onChange?.(event.target.value);
82
+ }
83
+ return {
84
+ innerValue,
85
+ hideSuggestionList,
86
+ selectedSuggestionIndex,
87
+ handleClearQuery,
88
+ handleFocus,
89
+ handleInput,
90
+ handleSuggestionClick,
91
+ handleOutsideClick,
92
+ handleKeyDown
93
+ };
94
+ }
@@ -1,23 +1,23 @@
1
- /// <reference types="react" />
2
- import { ClassNameProps } from '../../helper/types';
3
- import './Snackbar.scss';
4
- export interface SnackbarConfig extends ClassNameProps {
5
- type?: 'info' | 'warning' | 'error';
6
- variant?: 'a' | 'b' | 'c';
7
- darkBackground?: boolean;
8
- showClose?: boolean;
9
- action?: string;
10
- disappearAfter?: number | null;
11
- key?: string | number;
12
- }
13
- export interface SnackbarData extends SnackbarConfig {
14
- text: string;
15
- }
16
- export interface SnackbarProps {
17
- data?: SnackbarData;
18
- onAction?: () => void;
19
- onClose?: () => void;
20
- first?: boolean;
21
- }
22
- declare function Snackbar(props: SnackbarProps): JSX.Element;
23
- export default Snackbar;
1
+ /// <reference types="react" />
2
+ import { ClassNameProps } from '../../helper/types';
3
+ import './Snackbar.scss';
4
+ export interface SnackbarConfig extends ClassNameProps {
5
+ type?: 'info' | 'warning' | 'error';
6
+ variant?: 'a' | 'b' | 'c';
7
+ darkBackground?: boolean;
8
+ showClose?: boolean;
9
+ action?: string;
10
+ disappearAfter?: number | null;
11
+ key?: string | number;
12
+ }
13
+ export interface SnackbarData extends SnackbarConfig {
14
+ text: string;
15
+ }
16
+ export interface SnackbarProps {
17
+ data?: SnackbarData;
18
+ onAction?: () => void;
19
+ onClose?: () => void;
20
+ first?: boolean;
21
+ }
22
+ declare function Snackbar(props: SnackbarProps): JSX.Element;
23
+ export default Snackbar;
@@ -0,0 +1,87 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import { CSSTransition } from 'react-transition-group';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ function Snackbar(props) {
7
+ const {
8
+ data,
9
+ onAction,
10
+ onClose,
11
+ first = false
12
+ } = props;
13
+ const [show, setShow] = useState(true);
14
+ const nodeRef = useRef(null);
15
+ useEffect(() => {
16
+ let disappearAfter = 5000;
17
+ if (data?.disappearAfter !== null) {
18
+ if (data?.disappearAfter && data?.disappearAfter > 0) {
19
+ disappearAfter = data?.disappearAfter;
20
+ }
21
+ const timer = setTimeout(() => setShow(false), disappearAfter);
22
+ return () => {
23
+ clearTimeout(timer);
24
+ };
25
+ }
26
+ return undefined;
27
+ }, [data]);
28
+ function handleClose() {
29
+ setShow(false);
30
+ }
31
+ const classes = first ? 'fr-snackbar-wrapper--first' : 'fr-snackbar-wrapper';
32
+ return /*#__PURE__*/_jsx(CSSTransition, {
33
+ nodeRef: nodeRef,
34
+ onExited: () => onClose ? onClose() : undefined,
35
+ unmountOnExit: true,
36
+ timeout: {
37
+ exit: 600
38
+ },
39
+ in: show,
40
+ classNames: classes,
41
+ appear: true,
42
+ children: /*#__PURE__*/_jsx("div", {
43
+ ref: nodeRef,
44
+ className: classes,
45
+ children: /*#__PURE__*/_jsxs("div", {
46
+ className: classNames({
47
+ 'fwe-snackbar': true,
48
+ 'fwe-snackbar-b': data?.variant === 'b',
49
+ 'fwe-snackbar-c': data?.variant === 'c',
50
+ 'fwe-snackbar-warning': data?.type === 'warning',
51
+ 'fwe-snackbar-error': data?.type === 'error',
52
+ 'fwe-snackbar-shadow': data?.darkBackground
53
+ }, data?.className),
54
+ children: [data?.type && /*#__PURE__*/_jsx("i", {
55
+ "aria-hidden": true,
56
+ className: classNames({
57
+ 'fwe-icon': true,
58
+ 'fwe-icon-status-info': data?.type === 'info',
59
+ 'fwe-icon-status-warning': data?.type === 'warning',
60
+ 'fwe-icon-status-failure': data?.type === 'error'
61
+ })
62
+ }), /*#__PURE__*/_jsx("span", {
63
+ children: data?.text
64
+ }), data?.action && /*#__PURE__*/_jsx("button", {
65
+ "aria-label": "UserAction",
66
+ type: "button",
67
+ className: "fwe-btn fwe-btn-link",
68
+ onClick: () => onAction ? onAction() : undefined,
69
+ children: data?.action
70
+ }), data?.showClose && /*#__PURE__*/_jsxs("button", {
71
+ "aria-label": "Close",
72
+ type: "button",
73
+ className: "fwe-btn fwe-btn-link",
74
+ onClick: handleClose,
75
+ children: [/*#__PURE__*/_jsx("i", {
76
+ "aria-hidden": true,
77
+ className: "fwe-icon fwe-icon-close-small"
78
+ }), /*#__PURE__*/_jsx("span", {
79
+ className: "fwe-sr-only",
80
+ children: "Close"
81
+ })]
82
+ })]
83
+ })
84
+ })
85
+ });
86
+ }
87
+ export default Snackbar;
@@ -1,8 +1,8 @@
1
- import React from 'react';
2
- import { SnackbarData } from './Snackbar';
3
- export interface ProviderContext {
4
- addSnackbar: (data: SnackbarData, onAction?: () => void, onClose?: () => void) => void;
5
- closeSnackbar: (key?: number | string) => void;
6
- }
7
- declare const _default: React.Context<ProviderContext>;
8
- export default _default;
1
+ import React from 'react';
2
+ import { SnackbarData } from './Snackbar';
3
+ export interface ProviderContext {
4
+ addSnackbar: (data: SnackbarData, onAction?: () => void, onClose?: () => void) => void;
5
+ closeSnackbar: (key: number | string) => void;
6
+ }
7
+ declare const _default: React.Context<ProviderContext>;
8
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export default /*#__PURE__*/React.createContext(null);
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
2
- import { ClassNamePropsWithChildren } from '../../helper/types';
3
- import { SnackbarConfig } from './Snackbar';
4
- interface SnackbarProviderProps extends ClassNamePropsWithChildren {
5
- config?: SnackbarConfig;
6
- }
7
- declare function SnackbarProvider(props: SnackbarProviderProps): JSX.Element;
8
- export default SnackbarProvider;
1
+ /// <reference types="react" />
2
+ import { ClassNamePropsWithChildren } from '../../helper/types';
3
+ import { SnackbarConfig } from './Snackbar';
4
+ interface SnackbarProviderProps extends ClassNamePropsWithChildren {
5
+ config?: SnackbarConfig;
6
+ }
7
+ declare function SnackbarProvider(props: SnackbarProviderProps): JSX.Element;
8
+ export default SnackbarProvider;
@@ -0,0 +1,58 @@
1
+ import { useMemo, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import Snackbar from './Snackbar';
4
+ import SnackbarContext from './SnackbarContext';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ function SnackbarProvider(props) {
8
+ const {
9
+ config = {
10
+ darkBackground: true
11
+ },
12
+ children,
13
+ className
14
+ } = props;
15
+ const [snacks, setSnacks] = useState([]);
16
+ function addSnackbar(snackData, onAction, onClose) {
17
+ const key = snackData.key ?? new Date().getTime() + Math.random();
18
+ setSnacks(prevSnacks => [{
19
+ data: {
20
+ ...config,
21
+ ...snackData
22
+ },
23
+ onAction,
24
+ onClose,
25
+ key,
26
+ first: prevSnacks.length === 0
27
+ }, ...prevSnacks]);
28
+ return key;
29
+ }
30
+ function closeSnackbar(key) {
31
+ if (key !== undefined) {
32
+ setSnacks(prevSnacks => prevSnacks.filter(snack => snack.key !== key));
33
+ }
34
+ }
35
+ function handleClose(snack) {
36
+ closeSnackbar(snack.key);
37
+ if (snack.onClose) {
38
+ snack.onClose();
39
+ }
40
+ }
41
+ const contextValue = useMemo(() => ({
42
+ addSnackbar,
43
+ closeSnackbar
44
+ }), []);
45
+ return /*#__PURE__*/_jsxs(SnackbarContext.Provider, {
46
+ value: contextValue,
47
+ children: [children, /*#__PURE__*/_jsx("div", {
48
+ className: classNames('fwe-snackbar-container', className),
49
+ children: snacks.map(snack => /*#__PURE__*/_jsx(Snackbar, {
50
+ data: snack.data,
51
+ onAction: () => snack.onAction ? snack.onAction() : undefined,
52
+ onClose: () => handleClose(snack),
53
+ first: snack.first
54
+ }, snack.key))
55
+ })]
56
+ });
57
+ }
58
+ export default SnackbarProvider;
@@ -1,3 +1,3 @@
1
- import { ProviderContext } from './SnackbarContext';
2
- declare const _default: () => ProviderContext;
3
- export default _default;
1
+ import { ProviderContext } from './SnackbarContext';
2
+ declare const _default: () => ProviderContext;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { useContext } from 'react';
2
+ import SnackbarContext from './SnackbarContext';
3
+ export default (() => useContext(SnackbarContext));
@@ -1,7 +1,7 @@
1
- import React, { ComponentPropsWithoutRef } from 'react';
2
- interface StepperHorizontalProps extends Omit<ComponentPropsWithoutRef<'div'>, 'onChange'> {
3
- stepIndex?: number;
4
- onChange?: (stepIndex: number) => void;
5
- }
6
- declare const StepperHorizontal: React.ForwardRefExoticComponent<StepperHorizontalProps & React.RefAttributes<HTMLDivElement>>;
7
- export default StepperHorizontal;
1
+ import React, { ComponentPropsWithoutRef } from 'react';
2
+ interface StepperHorizontalProps extends Omit<ComponentPropsWithoutRef<'div'>, 'onChange'> {
3
+ stepIndex?: number;
4
+ onChange?: (stepIndex: number) => void;
5
+ }
6
+ declare const StepperHorizontal: React.ForwardRefExoticComponent<StepperHorizontalProps & React.RefAttributes<HTMLDivElement>>;
7
+ export default StepperHorizontal;
@@ -0,0 +1,62 @@
1
+ import cn from 'classnames';
2
+ import React, { forwardRef } from 'react';
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
+ const StepperHorizontal = /*#__PURE__*/forwardRef((_ref, ref) => {
7
+ let {
8
+ children,
9
+ className,
10
+ stepIndex = 0,
11
+ onChange,
12
+ ...props
13
+ } = _ref;
14
+ const stepComponents = React.Children.map(children, (child, i) => /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
15
+ ...child.props,
16
+ isActive: i === stepIndex
17
+ }) : null);
18
+ function handleStepClick(index) {
19
+ if (stepIndex > index && onChange) {
20
+ onChange(index);
21
+ }
22
+ }
23
+ const handleKeyDown = i => event => {
24
+ if (event.key === 'Enter') {
25
+ handleStepClick(i);
26
+ }
27
+ };
28
+ const handleKeyUp = i => event => {
29
+ if (event.key === ' ') {
30
+ handleStepClick(i);
31
+ }
32
+ };
33
+ return /*#__PURE__*/_jsxs(_Fragment, {
34
+ children: [/*#__PURE__*/_jsx("div", {
35
+ className: "fwe-stepper-horizontal",
36
+ children: stepComponents && stepComponents.map((step, i) => /*#__PURE__*/_jsx("div", {
37
+ tabIndex: 0,
38
+ role: "button",
39
+ ref: ref,
40
+ onKeyDown: handleKeyDown(i),
41
+ onKeyUp: handleKeyUp(i),
42
+ className: cn('fwe-step-container', {
43
+ 'fwe-step-done': stepIndex > i,
44
+ 'fwe-step-active': i === stepIndex
45
+ }),
46
+ onClick: () => handleStepClick(i),
47
+ ...props,
48
+ children: /*#__PURE__*/_jsxs("div", {
49
+ className: "fwe-step",
50
+ children: [/*#__PURE__*/_jsx("div", {
51
+ className: "fwe-step-no",
52
+ children: i + 1
53
+ }), /*#__PURE__*/_jsx("div", {
54
+ className: "fwe-step-name",
55
+ children: step.props.title
56
+ })]
57
+ })
58
+ }, step.props.title))
59
+ }), stepComponents]
60
+ });
61
+ });
62
+ export default StepperHorizontal;
@@ -1,7 +1,7 @@
1
- import './StepHorizontal.scss';
2
- import { ComponentPropsWithoutRef } from 'react';
3
- interface StepHorizontalProps extends ComponentPropsWithoutRef<'div'> {
4
- isActive?: boolean;
5
- }
6
- declare const StepHorizontal: import("react").ForwardRefExoticComponent<StepHorizontalProps & import("react").RefAttributes<HTMLDivElement>>;
7
- export default StepHorizontal;
1
+ import './StepHorizontal.scss';
2
+ import { ComponentPropsWithoutRef } from 'react';
3
+ export interface StepHorizontalProps extends ComponentPropsWithoutRef<'div'> {
4
+ isActive?: boolean;
5
+ }
6
+ declare const StepHorizontal: import("react").ForwardRefExoticComponent<StepHorizontalProps & import("react").RefAttributes<HTMLDivElement>>;
7
+ export default StepHorizontal;
@@ -0,0 +1,23 @@
1
+ import cn from 'classnames';
2
+ import { forwardRef } from 'react';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const StepHorizontal = /*#__PURE__*/forwardRef((_ref, ref) => {
5
+ let {
6
+ children,
7
+ className,
8
+ isActive,
9
+ ...props
10
+ } = _ref;
11
+ return /*#__PURE__*/_jsx("div", {
12
+ ref: ref,
13
+ className: cn('overflow-hidden', {
14
+ hidden: !isActive
15
+ }),
16
+ ...props,
17
+ children: /*#__PURE__*/_jsx("div", {
18
+ className: "fr-moving-container",
19
+ children: children
20
+ })
21
+ });
22
+ });
23
+ export default StepHorizontal;
@@ -1,7 +1,7 @@
1
- import React, { ComponentPropsWithoutRef } from 'react';
2
- interface StepperVerticalProps extends Omit<ComponentPropsWithoutRef<'div'>, 'onChange'> {
3
- stepIndex?: number;
4
- onChange?: (stepIndex: number) => void;
5
- }
6
- declare const StepperVertical: React.ForwardRefExoticComponent<StepperVerticalProps & React.RefAttributes<HTMLDivElement>>;
7
- export default StepperVertical;
1
+ import React, { ComponentPropsWithoutRef } from 'react';
2
+ interface StepperVerticalProps extends Omit<ComponentPropsWithoutRef<'div'>, 'onChange'> {
3
+ stepIndex?: number;
4
+ onChange?: (stepIndex: number) => void;
5
+ }
6
+ declare const StepperVertical: React.ForwardRefExoticComponent<StepperVerticalProps & React.RefAttributes<HTMLDivElement>>;
7
+ export default StepperVertical;
@@ -0,0 +1,37 @@
1
+ import cn from 'classnames';
2
+ import React, { forwardRef } from 'react';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const StepperVertical = /*#__PURE__*/forwardRef((_ref, ref) => {
5
+ let {
6
+ children,
7
+ className,
8
+ stepIndex = 0,
9
+ onChange,
10
+ ...props
11
+ } = _ref;
12
+ function handleStepClick(index) {
13
+ if (stepIndex > index && onChange) {
14
+ onChange(index);
15
+ }
16
+ }
17
+ const stepComponents = React.Children.map(children, (child, i) => {
18
+ if ( /*#__PURE__*/React.isValidElement(child)) {
19
+ return /*#__PURE__*/React.cloneElement(child, {
20
+ ...child.props,
21
+ isActive: i === stepIndex,
22
+ index: i,
23
+ isDone: i < stepIndex,
24
+ isLastElement: i === React.Children.count(children) - 1,
25
+ onStepClick: () => handleStepClick(i)
26
+ });
27
+ }
28
+ return null;
29
+ });
30
+ return /*#__PURE__*/_jsx("div", {
31
+ ref: ref,
32
+ className: cn('fwe-stepper-vertical', className),
33
+ ...props,
34
+ children: stepComponents
35
+ });
36
+ });
37
+ export default StepperVertical;