@festo-ui/react 9.0.1-dev.782 → 9.0.1-dev.784

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 (209) hide show
  1. package/dist/components/accordion/Accordion.css +4 -0
  2. package/dist/components/accordion/Accordion.d.ts +10 -0
  3. package/dist/components/accordion/Accordion.js +41 -0
  4. package/dist/components/accordion/AccordionContext.d.ts +11 -0
  5. package/dist/components/accordion/AccordionContext.js +3 -0
  6. package/dist/components/accordion/accordion-header/AccordionHeader.css +11 -0
  7. package/dist/components/accordion/accordion-header/AccordionHeader.d.ts +2 -0
  8. package/dist/components/accordion/accordion-header/AccordionHeader.js +11 -0
  9. package/dist/components/accordion/accordion-item/AccordionItem.css +64 -0
  10. package/dist/components/accordion/accordion-item/AccordionItem.d.ts +8 -0
  11. package/dist/components/accordion/accordion-item/AccordionItem.js +60 -0
  12. package/dist/components/accordion/accordion-item/AccordionItemContext.d.ts +7 -0
  13. package/dist/components/accordion/accordion-item/AccordionItemContext.js +3 -0
  14. package/dist/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.css +76 -0
  15. package/dist/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.d.ts +2 -0
  16. package/dist/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.js +61 -0
  17. package/dist/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.css +11 -0
  18. package/dist/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.d.ts +2 -0
  19. package/dist/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.js +20 -0
  20. package/dist/components/bottom-sheet/BottomSheet.css +18 -0
  21. package/dist/components/bottom-sheet/BottomSheet.d.ts +11 -0
  22. package/dist/components/bottom-sheet/BottomSheet.js +101 -0
  23. package/dist/components/breadcrumb/Breadcrumb.d.ts +14 -0
  24. package/dist/components/breadcrumb/Breadcrumb.js +87 -0
  25. package/dist/components/button/Button.d.ts +11 -0
  26. package/dist/components/button/Button.js +36 -0
  27. package/dist/components/card/Card.d.ts +5 -0
  28. package/dist/components/card/Card.js +9 -0
  29. package/dist/components/card/CardBody.d.ts +5 -0
  30. package/dist/components/card/CardBody.js +15 -0
  31. package/dist/components/card/CardHeader.d.ts +8 -0
  32. package/dist/components/card/CardHeader.js +31 -0
  33. package/dist/components/card/CardHeader.stories.helper.js +7 -0
  34. package/dist/components/card/CardNotification.d.ts +6 -0
  35. package/dist/components/card/CardNotification.js +26 -0
  36. package/dist/components/chips/chip/Chip.d.ts +17 -0
  37. package/dist/components/chips/chip/Chip.js +38 -0
  38. package/dist/components/chips/chip-container/ChipContainer.d.ts +5 -0
  39. package/dist/components/chips/chip-container/ChipContainer.js +12 -0
  40. package/dist/components/icon-wrapper/IconWrapper.d.ts +7 -0
  41. package/dist/components/icon-wrapper/IconWrapper.js +13 -0
  42. package/dist/components/loading-indicator/LoadingIndicator.d.ts +5 -0
  43. package/dist/components/loading-indicator/LoadingIndicator.js +41 -0
  44. package/dist/components/mobile-flyout/MobileFlyout.d.ts +11 -0
  45. package/dist/components/mobile-flyout/MobileFlyout.js +88 -0
  46. package/dist/components/mobile-flyout/MobileFlyoutContext.d.ts +8 -0
  47. package/dist/components/mobile-flyout/MobileFlyoutContext.js +3 -0
  48. package/dist/components/mobile-flyout/mobile-flyout-item/MobileFlyoutItem.d.ts +17 -0
  49. package/dist/components/mobile-flyout/mobile-flyout-item/MobileFlyoutItem.js +36 -0
  50. package/dist/components/mobile-flyout/mobile-flyout-page/MobileFlyoutPage.css +5 -0
  51. package/dist/components/mobile-flyout/mobile-flyout-page/MobileFlyoutPage.d.ts +8 -0
  52. package/dist/components/mobile-flyout/mobile-flyout-page/MobileFlyoutPage.js +35 -0
  53. package/dist/components/modals/AlertModal.d.ts +12 -0
  54. package/dist/components/modals/AlertModal.js +53 -0
  55. package/dist/components/modals/ConfirmModal.d.ts +11 -0
  56. package/dist/components/modals/ConfirmModal.js +46 -0
  57. package/dist/components/modals/CustomModal.d.ts +8 -0
  58. package/dist/components/modals/CustomModal.js +38 -0
  59. package/dist/components/modals/Modal.css +39 -0
  60. package/dist/components/modals/Modal.d.ts +8 -0
  61. package/dist/components/modals/Modal.js +31 -0
  62. package/dist/components/modals/ModalBase.d.ts +9 -0
  63. package/dist/components/modals/ModalBase.js +124 -0
  64. package/dist/components/modals/ModalFooter.d.ts +2 -0
  65. package/dist/components/modals/ModalFooter.js +12 -0
  66. package/dist/components/modals/Prompt.d.ts +16 -0
  67. package/dist/components/modals/Prompt.js +58 -0
  68. package/dist/components/modals/image-gallery/ImageGallery.css +833 -0
  69. package/dist/components/modals/image-gallery/ImageGallery.d.ts +21 -0
  70. package/dist/components/modals/image-gallery/ImageGallery.helper.d.ts +2 -0
  71. package/dist/components/modals/image-gallery/ImageGallery.helper.js +13 -0
  72. package/dist/components/modals/image-gallery/ImageGallery.js +103 -0
  73. package/dist/components/modals/image-gallery/ImageGallery.stories.helper.js +112 -0
  74. package/dist/components/modals/image-gallery/ImageGalleryContent.d.ts +8 -0
  75. package/dist/components/modals/image-gallery/ImageGalleryContent.js +15 -0
  76. package/dist/components/modals/image-gallery/ImageGalleryScale.d.ts +6 -0
  77. package/dist/components/modals/image-gallery/ImageGalleryScale.js +15 -0
  78. package/dist/components/modals/image-gallery/ImageGallerySwiper.d.ts +12 -0
  79. package/dist/components/modals/image-gallery/ImageGallerySwiper.js +40 -0
  80. package/dist/components/modals/image-gallery/ImageGalleryThumbsSwiper.d.ts +7 -0
  81. package/dist/components/modals/image-gallery/ImageGalleryThumbsSwiper.js +27 -0
  82. package/dist/components/modals/image-gallery/internal/CloseButton.d.ts +6 -0
  83. package/dist/components/modals/image-gallery/internal/CloseButton.js +14 -0
  84. package/dist/components/modals/image-gallery/internal/ImageGalleryContainer.d.ts +5 -0
  85. package/dist/components/modals/image-gallery/internal/ImageGalleryContainer.js +8 -0
  86. package/dist/components/modals/image-gallery/internal/ImageGalleryPagination.d.ts +5 -0
  87. package/dist/components/modals/image-gallery/internal/ImageGalleryPagination.js +29 -0
  88. package/dist/components/pagination/Pagination.css +10 -0
  89. package/dist/components/pagination/Pagination.d.ts +15 -0
  90. package/dist/components/pagination/Pagination.js +100 -0
  91. package/dist/components/popovers/legend/Legend.d.ts +10 -0
  92. package/dist/components/popovers/legend/Legend.js +22 -0
  93. package/dist/components/popovers/popover/Popover.css +8 -0
  94. package/dist/components/popovers/popover/Popover.d.ts +19 -0
  95. package/dist/components/popovers/popover/Popover.js +82 -0
  96. package/dist/components/popovers/popover-menu/PopoverMenu.d.ts +7 -0
  97. package/dist/components/popovers/popover-menu/PopoverMenu.js +31 -0
  98. package/dist/components/popovers/popover-menu/PopoverMenuContext.d.ts +4 -0
  99. package/dist/components/popovers/popover-menu/PopoverMenuContext.js +5 -0
  100. package/dist/components/popovers/popover-menu/popover-menu-item/PopoverMenuItem.d.ts +7 -0
  101. package/dist/components/popovers/popover-menu/popover-menu-item/PopoverMenuItem.js +27 -0
  102. package/dist/components/popovers/tooltip/Tooltip.d.ts +5 -0
  103. package/dist/components/popovers/tooltip/Tooltip.js +12 -0
  104. package/dist/components/progress/Progress.d.ts +7 -0
  105. package/dist/components/progress/Progress.js +26 -0
  106. package/dist/components/search-input/ClearButton.d.ts +2 -0
  107. package/dist/components/search-input/ClearButton.js +10 -0
  108. package/dist/components/search-input/SearchInput.css +13 -0
  109. package/dist/components/search-input/SearchInput.d.ts +14 -0
  110. package/dist/components/search-input/SearchInput.js +61 -0
  111. package/dist/components/search-input/SearchSuggestion.d.ts +17 -0
  112. package/dist/components/search-input/SearchSuggestion.js +21 -0
  113. package/dist/components/search-input/useSearchInput.d.ts +13 -0
  114. package/dist/components/search-input/useSearchInput.js +85 -0
  115. package/dist/components/snackbar/Snackbar.css +55 -0
  116. package/dist/components/snackbar/Snackbar.d.ts +21 -0
  117. package/dist/components/snackbar/Snackbar.js +78 -0
  118. package/dist/components/snackbar/SnackbarContext.d.ts +7 -0
  119. package/dist/components/snackbar/SnackbarContext.js +3 -0
  120. package/dist/components/snackbar/SnackbarProvider.d.ts +7 -0
  121. package/dist/components/snackbar/SnackbarProvider.js +66 -0
  122. package/dist/components/snackbar/useSnackbar.d.ts +2 -0
  123. package/dist/components/snackbar/useSnackbar.js +4 -0
  124. package/dist/components/stepper-horizontal/StepperHorizontal.css +6 -0
  125. package/dist/components/stepper-horizontal/StepperHorizontal.d.ts +7 -0
  126. package/dist/components/stepper-horizontal/StepperHorizontal.js +48 -0
  127. package/dist/components/stepper-horizontal/step-horizontal/StepHorizontal.css +24 -0
  128. package/dist/components/stepper-horizontal/step-horizontal/StepHorizontal.d.ts +6 -0
  129. package/dist/components/stepper-horizontal/step-horizontal/StepHorizontal.js +16 -0
  130. package/dist/components/stepper-vertical/StepperVertical.d.ts +6 -0
  131. package/dist/components/stepper-vertical/StepperVertical.js +25 -0
  132. package/dist/components/stepper-vertical/step-vertical/StepVertical.css +10 -0
  133. package/dist/components/stepper-vertical/step-vertical/StepVertical.d.ts +11 -0
  134. package/dist/components/stepper-vertical/step-vertical/StepVertical.js +58 -0
  135. package/dist/components/tab/Tabs.css +285 -0
  136. package/dist/components/tab/Tabs.d.ts +22 -0
  137. package/dist/components/tab/Tabs.js +193 -0
  138. package/dist/components/tab/interfaces.d.ts +5 -0
  139. package/dist/components/tab/interfaces.js +0 -0
  140. package/dist/components/tab/tab-pane/TabPane.css +8 -0
  141. package/dist/components/tab/tab-pane/TabPane.d.ts +9 -0
  142. package/dist/components/tab/tab-pane/TabPane.js +18 -0
  143. package/dist/components/tab/useTabScroll.d.ts +25 -0
  144. package/dist/components/tab/useTabScroll.js +151 -0
  145. package/dist/components/table-header-cell/TableHeaderCell.d.ts +5 -0
  146. package/dist/components/table-header-cell/TableHeaderCell.js +21 -0
  147. package/dist/forms/checkbox/Checkbox.css +134 -0
  148. package/dist/forms/checkbox/Checkbox.d.ts +15 -0
  149. package/dist/forms/checkbox/Checkbox.js +80 -0
  150. package/dist/forms/combobox/ComboBox.css +124 -0
  151. package/dist/forms/combobox/ComboBox.d.ts +28 -0
  152. package/dist/forms/combobox/ComboBox.js +175 -0
  153. package/dist/forms/multi-select/MultiSelect.d.ts +20 -0
  154. package/dist/forms/multi-select/MultiSelect.js +191 -0
  155. package/dist/forms/multi-select/MultiSelect.module.js +8 -0
  156. package/dist/forms/multi-select/MultiSelect_module.css +13 -0
  157. package/dist/forms/radio/RadioButton.d.ts +14 -0
  158. package/dist/forms/radio/RadioButton.js +61 -0
  159. package/dist/forms/radio/RadioGroup.d.ts +12 -0
  160. package/dist/forms/radio/RadioGroup.js +50 -0
  161. package/dist/forms/radio/RadioGroupContext.d.ts +12 -0
  162. package/dist/forms/radio/RadioGroupContext.js +3 -0
  163. package/dist/forms/segment/Segment.d.ts +13 -0
  164. package/dist/forms/segment/Segment.js +58 -0
  165. package/dist/forms/segment/segment-control/SegmentControl.d.ts +14 -0
  166. package/dist/forms/segment/segment-control/SegmentControl.js +57 -0
  167. package/dist/forms/select/Select.d.ts +25 -0
  168. package/dist/forms/select/Select.js +92 -0
  169. package/dist/forms/select/internal/SelectButton.d.ts +0 -0
  170. package/dist/forms/select/internal/SelectButton.js +0 -0
  171. package/dist/forms/select/internal/SelectButtonContent.d.ts +0 -0
  172. package/dist/forms/select/internal/SelectButtonContent.js +0 -0
  173. package/dist/forms/select/internal/SelectOptionsContainer.d.ts +0 -0
  174. package/dist/forms/select/internal/SelectOptionsContainer.js +0 -0
  175. package/dist/forms/slider/Slider.css +50 -0
  176. package/dist/forms/slider/Slider.d.ts +17 -0
  177. package/dist/forms/slider/Slider.js +93 -0
  178. package/dist/forms/switch/Switch.d.ts +12 -0
  179. package/dist/forms/switch/Switch.js +42 -0
  180. package/dist/forms/text-area/TextArea.css +14 -0
  181. package/dist/forms/text-area/TextArea.d.ts +22 -0
  182. package/dist/forms/text-area/TextArea.js +99 -0
  183. package/dist/forms/text-input/TextInput.d.ts +24 -0
  184. package/dist/forms/text-input/TextInput.js +74 -0
  185. package/dist/forms/time-picker/TimePicker.css +10 -0
  186. package/dist/forms/time-picker/TimePicker.d.ts +24 -0
  187. package/dist/forms/time-picker/TimePicker.js +123 -0
  188. package/dist/forms/time-picker/time-picker-dropdown/TimePickerDropdown.css +4 -0
  189. package/dist/forms/time-picker/time-picker-dropdown/TimePickerDropdown.d.ts +19 -0
  190. package/dist/forms/time-picker/time-picker-dropdown/TimePickerDropdown.js +208 -0
  191. package/dist/forms/time-picker/time-picker-dropdown/TimePickerInput.d.ts +9 -0
  192. package/dist/forms/time-picker/time-picker-dropdown/TimePickerInput.js +14 -0
  193. package/dist/index.d.ts +60 -0
  194. package/dist/index.js +60 -0
  195. package/dist/utils/index.d.ts +1 -0
  196. package/dist/utils/index.js +7 -0
  197. package/dist/utils/setRef.d.ts +1 -0
  198. package/dist/utils/setRef.js +5 -0
  199. package/dist/utils/types.d.ts +36 -0
  200. package/dist/utils/types.js +0 -0
  201. package/dist/utils/useControlled.d.ts +7 -0
  202. package/dist/utils/useControlled.js +20 -0
  203. package/dist/utils/useForkRef.d.ts +2 -0
  204. package/dist/utils/useForkRef.js +15 -0
  205. package/dist/utils/useId.d.ts +1 -0
  206. package/dist/utils/useId.js +20 -0
  207. package/dist/utils/useOnClickOutside.d.ts +2 -0
  208. package/dist/utils/useOnClickOutside.js +20 -0
  209. package/package.json +1 -1
@@ -0,0 +1,99 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "./TextArea.css";
3
+ import classnames from "classnames";
4
+ import react, { useEffect, useState } from "react";
5
+ import { useId } from "../../utils/useId.js";
6
+ function TextArea({ disabled, onBlur, onChange, onFocus, onInput, readonly, required, label, error, hint, value, defaultValue, name, rows, maxLength, className, id: idProps }) {
7
+ const controlled = void 0 !== value;
8
+ const [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
9
+ const id = useId(idProps);
10
+ const hintClasses = classnames('fwe-input-text-info');
11
+ const shadowRef = react.useRef(null);
12
+ const ref = react.useRef(null);
13
+ const [height, setHeight] = useState(void 0);
14
+ useEffect(()=>{
15
+ if (controlled) setInnerValue(value);
16
+ }, [
17
+ value,
18
+ controlled
19
+ ]);
20
+ useEffect(()=>{
21
+ const input = ref.current;
22
+ const shadow = shadowRef.current;
23
+ const minRows = 2;
24
+ if (shadow && input) {
25
+ shadow.value = input.value || 'x';
26
+ shadow.style.width = `${input.clientWidth}`;
27
+ const newHeight = Math.max(24 * minRows, shadow.scrollHeight);
28
+ setHeight(newHeight + 4 + 4 + 1);
29
+ }
30
+ }, []);
31
+ function handleChange(event) {
32
+ if (!controlled) setInnerValue(event.target.value);
33
+ if (onChange) onChange(event);
34
+ }
35
+ return /*#__PURE__*/ jsxs("label", {
36
+ className: classnames('fwe-input-text', className),
37
+ htmlFor: id,
38
+ children: [
39
+ /*#__PURE__*/ jsx("textarea", {
40
+ style: {
41
+ ...!rows && {
42
+ height,
43
+ overflow: 'hidden'
44
+ }
45
+ },
46
+ ref: ref,
47
+ name: name,
48
+ className: classnames('fr-textarea', `fwe-row-${rows}`),
49
+ disabled: disabled,
50
+ readOnly: readonly,
51
+ required: required,
52
+ autoComplete: "off",
53
+ onChange: handleChange,
54
+ onFocus: onFocus,
55
+ onInput: onInput,
56
+ onBlur: onBlur,
57
+ maxLength: maxLength,
58
+ defaultValue: defaultValue,
59
+ value: value,
60
+ id: id
61
+ }),
62
+ /*#__PURE__*/ jsx("textarea", {
63
+ style: {
64
+ visibility: 'hidden',
65
+ position: 'absolute',
66
+ overflow: 'hidden',
67
+ height: 0,
68
+ top: 0,
69
+ left: 0,
70
+ transform: 'translateZ(0)',
71
+ padding: '0'
72
+ },
73
+ ref: shadowRef,
74
+ readOnly: true
75
+ }),
76
+ /*#__PURE__*/ jsx("span", {
77
+ className: "fwe-input-text-label",
78
+ children: label
79
+ }),
80
+ hint && /*#__PURE__*/ jsx("span", {
81
+ className: hintClasses,
82
+ children: hint
83
+ }),
84
+ void 0 !== error && /*#__PURE__*/ jsx("span", {
85
+ className: "fwe-input-text-invalid",
86
+ children: error
87
+ }),
88
+ !!maxLength && void 0 !== innerValue && /*#__PURE__*/ jsxs("span", {
89
+ className: "fwe-input-text-count",
90
+ children: [
91
+ innerValue.length,
92
+ " /",
93
+ maxLength
94
+ ]
95
+ })
96
+ ]
97
+ });
98
+ }
99
+ export { TextArea };
@@ -0,0 +1,24 @@
1
+ import type React from 'react';
2
+ export 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
+ defaultValue?: string;
13
+ name?: string;
14
+ onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
15
+ onInput?: (event: React.FormEvent<HTMLInputElement>) => void;
16
+ onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
17
+ label?: string;
18
+ hint?: string;
19
+ error?: string;
20
+ labelClassName?: string;
21
+ icon?: React.ReactNode;
22
+ autoFocus?: boolean;
23
+ }
24
+ export declare const TextInput: (props: TextInputProps & React.HTMLProps<HTMLInputElement> & React.RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
@@ -0,0 +1,74 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import classnames from "classnames";
3
+ import { forwardRef, useEffect, useRef } from "react";
4
+ import { useId } from "../../utils/useId.js";
5
+ const TextInput = /*#__PURE__*/ forwardRef(({ disabled, required, readonly, placeholder, max, min, onBlur, onFocus, onInput, step, type, value, defaultValue, name, error, hint, label, labelClassName, icon, id: idProps, autoFocus, ...props }, ref)=>{
6
+ const id = useId(idProps);
7
+ const inputRef = useRef(null);
8
+ useEffect(()=>{
9
+ if (autoFocus && inputRef.current) {
10
+ const timer = setTimeout(()=>{
11
+ inputRef.current?.focus();
12
+ }, 0);
13
+ return ()=>clearTimeout(timer);
14
+ }
15
+ }, [
16
+ autoFocus
17
+ ]);
18
+ const supported = [
19
+ 'text',
20
+ 'number',
21
+ 'password',
22
+ 'datetime-local'
23
+ ];
24
+ const innerType = type && supported.includes(type) ? type : 'text';
25
+ const labelClasses = classnames('fwe-input-text', {
26
+ 'fwe-input-text-icon': icon
27
+ }, labelClassName);
28
+ const hintClasses = classnames('fwe-input-text-info');
29
+ function handleChange(e) {
30
+ if (props.onChange) props.onChange(e);
31
+ }
32
+ return /*#__PURE__*/ jsxs("label", {
33
+ className: labelClasses,
34
+ htmlFor: id,
35
+ ref: ref,
36
+ children: [
37
+ /*#__PURE__*/ jsx("input", {
38
+ name: name,
39
+ disabled: disabled,
40
+ required: required,
41
+ readOnly: readonly,
42
+ placeholder: placeholder,
43
+ autoComplete: "off",
44
+ min: min,
45
+ max: max,
46
+ step: step,
47
+ onChange: handleChange,
48
+ onBlur: onBlur,
49
+ onFocus: onFocus,
50
+ onInput: onInput,
51
+ type: innerType,
52
+ value: value,
53
+ defaultValue: defaultValue,
54
+ id: id,
55
+ ref: inputRef,
56
+ ...props
57
+ }),
58
+ icon,
59
+ /*#__PURE__*/ jsx("span", {
60
+ className: "fwe-input-text-label",
61
+ children: label
62
+ }),
63
+ hint && /*#__PURE__*/ jsx("span", {
64
+ className: hintClasses,
65
+ children: hint
66
+ }),
67
+ error && /*#__PURE__*/ jsx("span", {
68
+ className: "fwe-input-text-invalid",
69
+ children: error
70
+ })
71
+ ]
72
+ });
73
+ });
74
+ export { TextInput };
@@ -0,0 +1,10 @@
1
+ .fr-time-picker {
2
+ all: unset;
3
+ cursor: pointer;
4
+ display: contents;
5
+ }
6
+
7
+ .fr-time-picker:disabled {
8
+ cursor: default;
9
+ }
10
+
@@ -0,0 +1,24 @@
1
+ import './TimePicker.scss';
2
+ import type React from 'react';
3
+ import { type ComponentPropsWithoutRef } from 'react';
4
+ export interface TimePickerOptions {
5
+ readonly timeFormat?: '12' | '24';
6
+ readonly showSeconds?: boolean;
7
+ readonly minuteStepSize?: number;
8
+ readonly range?: {
9
+ minValue: Date;
10
+ maxValue: Date;
11
+ };
12
+ }
13
+ export interface TimePickerProps extends Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'defaultValue' | 'onChange'> {
14
+ readonly error?: string;
15
+ readonly hint?: string;
16
+ readonly required?: boolean;
17
+ readonly disabled?: boolean;
18
+ readonly value?: Date;
19
+ readonly defaultValue?: Date;
20
+ readonly options?: TimePickerOptions;
21
+ readonly formatDate?: (date: Date) => string;
22
+ readonly onChange?: (date: Date) => void;
23
+ }
24
+ export declare const TimePicker: (props: TimePickerProps & React.RefAttributes<HTMLButtonElement>) => React.ReactElement | null;
@@ -0,0 +1,123 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import "./TimePicker.css";
3
+ import { IconTime } from "@festo-ui/react-icons";
4
+ import { offset, useFloating } from "@floating-ui/react";
5
+ import classnames from "classnames";
6
+ import { forwardRef, useEffect, useRef, useState } from "react";
7
+ import { createPortal } from "react-dom";
8
+ import { useForkRef } from "../../utils/useForkRef.js";
9
+ import { useId } from "../../utils/useId.js";
10
+ import { TimePickerDropdown } from "./time-picker-dropdown/TimePickerDropdown.js";
11
+ const TimePicker = /*#__PURE__*/ forwardRef(({ error, hint, required, disabled, children, value, options, defaultValue, formatDate, onChange, id: idProps, ...props }, ref)=>{
12
+ const id = useId(idProps);
13
+ const innerFormatDate = formatDate ?? Intl.DateTimeFormat('default', {
14
+ hour: 'numeric',
15
+ minute: 'numeric',
16
+ ...options?.showSeconds && {
17
+ second: 'numeric'
18
+ }
19
+ }).format;
20
+ const timeFormat = options?.timeFormat ?? '24';
21
+ const { refs, floatingStyles } = useFloating({
22
+ placement: 'bottom',
23
+ middleware: [
24
+ offset(({ rects })=>-rects.reference.height - 12)
25
+ ]
26
+ });
27
+ const buttonRef = useRef(null);
28
+ const allRefs = useForkRef(ref, buttonRef);
29
+ const labelRef = useRef(null);
30
+ const combinedLabelRef = useForkRef(labelRef, refs.setReference);
31
+ const timePickerRef = useRef(null);
32
+ const combinedTimePickerRef = useForkRef(timePickerRef, refs.setFloating);
33
+ const [open, setOpen] = useState(false);
34
+ const controlled = void 0 !== value;
35
+ const initialValue = controlled ? value : defaultValue;
36
+ const [innerValue, setInnerValue] = useState(initialValue ?? new Date());
37
+ useEffect(()=>{
38
+ if (void 0 !== value) {
39
+ value.setMilliseconds(0);
40
+ setInnerValue(value);
41
+ }
42
+ }, [
43
+ value
44
+ ]);
45
+ function toggle(e) {
46
+ e?.preventDefault();
47
+ if (!disabled) setOpen((prevOpen)=>!prevOpen);
48
+ }
49
+ function handleDateChange(newDate) {
50
+ if (!controlled) setInnerValue(newDate);
51
+ if (onChange) onChange(newDate);
52
+ }
53
+ function handleClose(newDate) {
54
+ if (newDate) handleDateChange(newDate);
55
+ setOpen(false);
56
+ }
57
+ const container = labelRef?.current?.ownerDocument || document;
58
+ return /*#__PURE__*/ jsxs(Fragment, {
59
+ children: [
60
+ /*#__PURE__*/ jsx("button", {
61
+ type: "button",
62
+ ref: allRefs,
63
+ onClick: toggle,
64
+ disabled: disabled,
65
+ className: "fr-time-picker",
66
+ ...props,
67
+ children: /*#__PURE__*/ jsxs("label", {
68
+ htmlFor: id,
69
+ ref: combinedLabelRef,
70
+ className: "fr-time-picker fwe-input-text fwe-input-text-icon",
71
+ children: [
72
+ /*#__PURE__*/ jsx(IconTime, {
73
+ className: classnames({
74
+ 'fwe-color-hero': open && !disabled,
75
+ 'fwe-color-control-disabled': disabled
76
+ })
77
+ }),
78
+ /*#__PURE__*/ jsx("input", {
79
+ id: id,
80
+ "aria-label": "picked time",
81
+ type: "text",
82
+ readOnly: true,
83
+ required: required,
84
+ className: classnames({
85
+ 'fwe-border-hero': open
86
+ }),
87
+ value: innerFormatDate(innerValue),
88
+ disabled: disabled
89
+ }),
90
+ /*#__PURE__*/ jsx("span", {
91
+ className: "fwe-input-text-label",
92
+ children: children
93
+ }),
94
+ hint && /*#__PURE__*/ jsx("span", {
95
+ className: "fwe-input-text-info",
96
+ children: hint
97
+ }),
98
+ error && /*#__PURE__*/ jsx("span", {
99
+ className: "fwe-input-text-invalid",
100
+ children: error
101
+ })
102
+ ]
103
+ })
104
+ }),
105
+ open && /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(TimePickerDropdown, {
106
+ labelRef: labelRef,
107
+ ref: combinedTimePickerRef,
108
+ onClose: handleClose,
109
+ onDateChange: handleDateChange,
110
+ timeFormat: timeFormat,
111
+ showSeconds: options?.showSeconds,
112
+ minuteStepSize: options?.minuteStepSize,
113
+ range: options?.range,
114
+ date: innerValue,
115
+ style: {
116
+ ...floatingStyles,
117
+ minWidth: labelRef?.current?.scrollWidth
118
+ }
119
+ }), container.body)
120
+ ]
121
+ });
122
+ });
123
+ export { TimePicker };
@@ -0,0 +1,4 @@
1
+ .fr-timepicker {
2
+ z-index: var(--fwe-z-index-modal);
3
+ }
4
+
@@ -0,0 +1,19 @@
1
+ import './TimePickerDropdown.scss';
2
+ import type React from 'react';
3
+ import { type RefObject } from 'react';
4
+ interface TimePickerDropdownProps {
5
+ timeFormat: '12' | '24';
6
+ date: Date;
7
+ onDateChange: (date: Date) => void;
8
+ showSeconds?: boolean;
9
+ minuteStepSize?: number;
10
+ range?: {
11
+ minValue: Date;
12
+ maxValue: Date;
13
+ };
14
+ onClose: (date?: Date) => void;
15
+ style?: React.CSSProperties;
16
+ labelRef: RefObject<HTMLLabelElement>;
17
+ }
18
+ export declare const TimePickerDropdown: (props: TimePickerDropdownProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
19
+ export {};
@@ -0,0 +1,208 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "./TimePickerDropdown.css";
3
+ import { IconCollapse, IconExpand } from "@festo-ui/react-icons";
4
+ import classnames from "classnames";
5
+ import { forwardRef, useEffect, useRef, useState } from "react";
6
+ import { Button } from "../../../components/button/Button.js";
7
+ import { useForkRef } from "../../../utils/useForkRef.js";
8
+ import { useOnClickOutside } from "../../../utils/useOnClickOutside.js";
9
+ import { TimePickerInput } from "./TimePickerInput.js";
10
+ const TimePickerDropdown = /*#__PURE__*/ forwardRef(({ timeFormat, date, onDateChange, showSeconds, minuteStepSize, range, onClose, style, labelRef }, ref)=>{
11
+ const innerRef = useRef(null);
12
+ const combinedRef = useForkRef(ref, innerRef);
13
+ const hoursRef = useRef(null);
14
+ const [tmpHours, setTmpHours] = useState(null);
15
+ const [tmpMinutes, setTmpMinutes] = useState(null);
16
+ const [tmpSeconds, setTmpSeconds] = useState(null);
17
+ const [innerDate, setInnerDate] = useState(date);
18
+ useOnClickOutside(labelRef, ()=>onClose(innerDate), innerRef);
19
+ const min = 0;
20
+ const hourMax = '12' === timeFormat ? 12 : 23;
21
+ const minutesSecondsMax = 59;
22
+ let innerMinuteStepSize = 1;
23
+ if (minuteStepSize) {
24
+ if (minuteStepSize > 1 && minuteStepSize < 60) innerMinuteStepSize = Math.round(minuteStepSize);
25
+ }
26
+ useEffect(()=>{
27
+ requestAnimationFrame(()=>{
28
+ hoursRef.current?.focus();
29
+ });
30
+ }, []);
31
+ function handleKeyPress(e) {
32
+ if ('Escape' === e.key || 'Enter' === e.key) onClose('Enter' === e.key ? innerDate : void 0);
33
+ }
34
+ function limitRange(newDate) {
35
+ if (range) {
36
+ if (newDate > range.maxValue) return range.minValue;
37
+ if (newDate < range.minValue) return range.maxValue;
38
+ }
39
+ return newDate;
40
+ }
41
+ function handleHourIncrement(increment) {
42
+ let newDate = new Date(innerDate);
43
+ newDate.setHours(innerDate.getHours() + increment);
44
+ newDate = limitRange(newDate);
45
+ setInnerDate(newDate);
46
+ onDateChange(newDate);
47
+ setTmpHours(null);
48
+ }
49
+ function handleHourChange(e) {
50
+ let newDate = new Date(innerDate);
51
+ const hour = +e.target.value;
52
+ newDate.setHours(Math.min(Math.max(hour, min), hourMax));
53
+ newDate = limitRange(newDate);
54
+ setInnerDate(newDate);
55
+ setTmpHours(newDate.getHours().toString());
56
+ }
57
+ function handleMinuteIncrement(increment) {
58
+ let newDate = new Date(innerDate);
59
+ newDate.setMinutes(innerDate.getMinutes() + increment);
60
+ newDate = limitRange(newDate);
61
+ setInnerDate(newDate);
62
+ onDateChange(newDate);
63
+ setTmpMinutes(null);
64
+ }
65
+ function handleMinuteChange(e) {
66
+ let newDate = new Date(innerDate);
67
+ const minute = +e.target.value;
68
+ newDate.setMinutes(Math.min(Math.max(minute, min), minutesSecondsMax));
69
+ newDate = limitRange(newDate);
70
+ setInnerDate(newDate);
71
+ setTmpMinutes(newDate.getMinutes().toString());
72
+ }
73
+ function handleSecondIncrement(increment) {
74
+ let newDate = new Date(innerDate);
75
+ newDate.setSeconds(innerDate.getSeconds() + increment);
76
+ newDate = limitRange(newDate);
77
+ setInnerDate(newDate);
78
+ onDateChange(newDate);
79
+ setTmpSeconds(null);
80
+ }
81
+ function handleSecondChange(e) {
82
+ let newDate = new Date(innerDate);
83
+ const seconds = +e.target.value;
84
+ newDate.setSeconds(Math.min(Math.max(seconds, min), minutesSecondsMax));
85
+ newDate = limitRange(newDate);
86
+ setInnerDate(newDate);
87
+ setTmpSeconds(newDate.getSeconds().toString());
88
+ }
89
+ const hours = '12' === timeFormat ? (innerDate.getHours() + 11) % 12 + 1 : innerDate.getHours();
90
+ function toggleAmPm() {
91
+ const newDate = new Date(innerDate);
92
+ const currentHours = innerDate.getHours();
93
+ if (currentHours >= 0 && currentHours < 12) newDate.setHours(currentHours + 12);
94
+ else newDate.setHours(currentHours - 12);
95
+ setInnerDate(newDate);
96
+ onDateChange(newDate);
97
+ }
98
+ const formatNumberWithLeadingZero = (number)=>(number < 10 ? '0' : '') + number;
99
+ return /*#__PURE__*/ jsxs("div", {
100
+ role: "dialog",
101
+ style: style,
102
+ ref: combinedRef,
103
+ className: classnames('fr-timepicker fwe-timepicker', {
104
+ 'fwe-timepicker-am-pm': '12' === timeFormat
105
+ }),
106
+ onKeyDown: (e)=>handleKeyPress(e),
107
+ tabIndex: -1,
108
+ children: [
109
+ /*#__PURE__*/ jsxs("div", {
110
+ className: "fwe-timepicker-spinners",
111
+ children: [
112
+ /*#__PURE__*/ jsxs("div", {
113
+ className: "fwe-timepicker-spinners-hours",
114
+ children: [
115
+ /*#__PURE__*/ jsx(Button, {
116
+ tertiary: true,
117
+ "aria-label": "hour up",
118
+ className: "fwe-dark",
119
+ onClick: ()=>handleHourIncrement(1),
120
+ iconOnly: true,
121
+ icon: /*#__PURE__*/ jsx(IconExpand, {})
122
+ }),
123
+ /*#__PURE__*/ jsx(TimePickerInput, {
124
+ "aria-label": "hours value",
125
+ min: min,
126
+ max: hourMax,
127
+ value: tmpHours ?? formatNumberWithLeadingZero(hours),
128
+ onInput: handleHourChange,
129
+ ref: hoursRef
130
+ }),
131
+ /*#__PURE__*/ jsx(Button, {
132
+ tertiary: true,
133
+ "aria-label": "hour down",
134
+ className: "fwe-dark",
135
+ onClick: ()=>handleHourIncrement(-1),
136
+ iconOnly: true,
137
+ icon: /*#__PURE__*/ jsx(IconCollapse, {})
138
+ })
139
+ ]
140
+ }),
141
+ /*#__PURE__*/ jsxs("div", {
142
+ className: "fwe-timepicker-spinners-minutes",
143
+ children: [
144
+ /*#__PURE__*/ jsx(Button, {
145
+ tertiary: true,
146
+ "aria-label": "minute up",
147
+ className: "fwe-dark",
148
+ onClick: ()=>handleMinuteIncrement(innerMinuteStepSize),
149
+ iconOnly: true,
150
+ icon: /*#__PURE__*/ jsx(IconExpand, {})
151
+ }),
152
+ /*#__PURE__*/ jsx(TimePickerInput, {
153
+ "aria-label": "minutes value",
154
+ min: min,
155
+ max: minutesSecondsMax,
156
+ value: tmpMinutes ?? formatNumberWithLeadingZero(innerDate.getMinutes()),
157
+ onInput: handleMinuteChange
158
+ }),
159
+ /*#__PURE__*/ jsx(Button, {
160
+ tertiary: true,
161
+ "aria-label": "minute down",
162
+ className: "fwe-dark",
163
+ onClick: ()=>handleMinuteIncrement(-innerMinuteStepSize),
164
+ iconOnly: true,
165
+ icon: /*#__PURE__*/ jsx(IconCollapse, {})
166
+ })
167
+ ]
168
+ }),
169
+ showSeconds && /*#__PURE__*/ jsxs("div", {
170
+ className: "fwe-timepicker-spinners-seconds",
171
+ children: [
172
+ /*#__PURE__*/ jsx(Button, {
173
+ tertiary: true,
174
+ "aria-label": "seconds up",
175
+ className: "fwe-dark",
176
+ onClick: ()=>handleSecondIncrement(1),
177
+ iconOnly: true,
178
+ icon: /*#__PURE__*/ jsx(IconExpand, {})
179
+ }),
180
+ /*#__PURE__*/ jsx(TimePickerInput, {
181
+ "aria-label": "seconds value",
182
+ min: min,
183
+ max: minutesSecondsMax,
184
+ value: tmpSeconds ?? formatNumberWithLeadingZero(innerDate.getSeconds()),
185
+ onInput: handleSecondChange
186
+ }),
187
+ /*#__PURE__*/ jsx(Button, {
188
+ tertiary: true,
189
+ "aria-label": "minute down",
190
+ className: "fwe-dark",
191
+ onClick: ()=>handleSecondIncrement(-1),
192
+ iconOnly: true,
193
+ icon: /*#__PURE__*/ jsx(IconCollapse, {})
194
+ })
195
+ ]
196
+ })
197
+ ]
198
+ }),
199
+ '12' === timeFormat && /*#__PURE__*/ jsx("button", {
200
+ onClick: toggleAmPm,
201
+ type: "button",
202
+ className: "fwe-btn fwe-ml-m",
203
+ children: innerDate.getHours() >= 12 ? 'PM' : 'AM'
204
+ })
205
+ ]
206
+ });
207
+ });
208
+ export { TimePickerDropdown };
@@ -0,0 +1,9 @@
1
+ interface TimePickerInputProps {
2
+ min: number;
3
+ value: string | number;
4
+ max: number;
5
+ onInput: React.FormEventHandler<HTMLInputElement>;
6
+ 'aria-label': string;
7
+ }
8
+ export declare const TimePickerInput: (props: TimePickerInputProps & import("react").RefAttributes<HTMLInputElement>) => React.ReactElement | null;
9
+ export {};
@@ -0,0 +1,14 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ const TimePickerInput = /*#__PURE__*/ forwardRef(({ min, max, value, onInput, 'aria-label': ariaLabel }, ref)=>/*#__PURE__*/ jsx("input", {
4
+ "aria-label": ariaLabel,
5
+ className: "fwe-timepicker-hide-spinners",
6
+ type: "number",
7
+ min: min,
8
+ step: 1,
9
+ value: value,
10
+ max: max,
11
+ onInput: onInput,
12
+ ref: ref
13
+ }));
14
+ export { TimePickerInput };