@festo-ui/react 4.0.3-pre-20221213.1 → 5.0.0-dev.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.css +3 -3202
- package/index.d.ts +50 -48
- package/index.js +50 -4797
- package/lib/components/accordion/Accordion.d.ts +9 -9
- package/lib/components/accordion/Accordion.js +38 -0
- package/lib/components/accordion/AccordionContext.d.ts +11 -11
- package/lib/components/accordion/AccordionContext.js +3 -0
- package/lib/components/accordion/accordion-header/AccordionHeader.d.ts +4 -4
- package/lib/components/accordion/accordion-header/AccordionHeader.js +17 -0
- package/lib/components/accordion/accordion-item/AccordionItem.d.ts +9 -9
- package/lib/components/accordion/accordion-item/AccordionItem.js +64 -0
- package/lib/components/accordion/accordion-item/AccordionItemContext.d.ts +8 -8
- package/lib/components/accordion/accordion-item/AccordionItemContext.js +3 -0
- package/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.d.ts +4 -4
- package/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.js +71 -0
- package/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.d.ts +4 -4
- package/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.js +41 -0
- package/lib/components/breadcrumb/Breadcrumb.d.ts +14 -14
- package/lib/components/breadcrumb/Breadcrumb.js +45 -0
- package/lib/components/buttons/button/Button.d.ts +12 -12
- package/lib/components/buttons/button/Button.js +37 -0
- package/lib/components/card/Card.d.ts +4 -4
- package/lib/components/card/Card.js +13 -0
- package/lib/components/card/CardBody.d.ts +7 -7
- package/lib/components/card/CardBody.js +18 -0
- package/lib/components/card/CardHeader.d.ts +9 -9
- package/lib/components/card/CardHeader.js +23 -0
- package/lib/components/card/CardNotification.d.ts +9 -9
- package/lib/components/card/CardNotification.js +26 -0
- package/lib/components/chips/chip/Chip.d.ts +19 -19
- package/lib/components/chips/chip/Chip.js +46 -0
- package/lib/components/chips/chip/DeleteIcon.d.ts +2 -0
- package/lib/components/chips/chip/DeleteIcon.js +7 -0
- package/lib/components/chips/chip-container/ChipContainer.d.ts +8 -8
- package/lib/components/chips/chip-container/ChipContainer.js +17 -0
- package/lib/components/link-button/LinkButton.d.ts +10 -10
- package/lib/components/link-button/LinkButton.js +26 -0
- package/lib/components/loading-indicator/LoadingIndicator.d.ts +7 -7
- package/lib/components/loading-indicator/LoadingIndicator.js +40 -0
- package/lib/components/modals/AlertModal.d.ts +14 -14
- package/lib/components/modals/AlertModal.js +76 -0
- package/lib/components/modals/ConfirmModal.d.ts +13 -13
- package/lib/components/modals/ConfirmModal.js +56 -0
- package/lib/components/modals/Modal.d.ts +11 -11
- package/lib/components/modals/Modal.js +76 -0
- package/lib/components/modals/ModalFooter.d.ts +4 -4
- package/lib/components/modals/ModalFooter.js +18 -0
- package/lib/components/modals/Prompt.d.ts +16 -16
- package/lib/components/modals/Prompt.js +65 -0
- package/lib/components/pagination/Pagination.d.ts +17 -17
- package/lib/components/pagination/Pagination.js +107 -0
- package/lib/components/popovers/legend/Legend.d.ts +12 -12
- package/lib/components/popovers/legend/Legend.js +25 -0
- package/lib/components/popovers/popover/Popover.d.ts +18 -18
- package/lib/components/popovers/popover/Popover.js +109 -0
- package/lib/components/popovers/popover-menu/PopoverMenu.d.ts +15 -15
- package/lib/components/popovers/popover-menu/PopoverMenu.js +54 -0
- package/lib/components/popovers/tooltip/Tooltip.d.ts +10 -10
- package/lib/components/popovers/tooltip/Tooltip.js +64 -0
- package/lib/components/progress/Progress.d.ts +9 -9
- package/lib/components/progress/Progress.js +32 -0
- package/lib/components/search-input/ClearButton.d.ts +2 -0
- package/lib/components/search-input/ClearButton.js +10 -0
- package/lib/components/search-input/SearchInput.d.ts +15 -0
- package/lib/components/search-input/SearchInput.js +75 -0
- package/lib/components/search-input/SearchSuggestion.d.ts +17 -0
- package/lib/components/search-input/SearchSuggestion.js +32 -0
- package/lib/components/search-input/useSearchInput.d.ts +13 -0
- package/lib/components/search-input/useSearchInput.js +94 -0
- package/lib/components/snackbar/Snackbar.d.ts +23 -23
- package/lib/components/snackbar/Snackbar.js +87 -0
- package/lib/components/snackbar/SnackbarContext.d.ts +8 -8
- package/lib/components/snackbar/SnackbarContext.js +2 -0
- package/lib/components/snackbar/SnackbarProvider.d.ts +8 -8
- package/lib/components/snackbar/SnackbarProvider.js +58 -0
- package/lib/components/snackbar/useSnackbar.d.ts +3 -3
- package/lib/components/snackbar/useSnackbar.js +3 -0
- package/lib/components/stepper-horizontal/StepperHorizontal.d.ts +7 -7
- package/lib/components/stepper-horizontal/StepperHorizontal.js +62 -0
- package/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.d.ts +7 -7
- package/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.js +23 -0
- package/lib/components/stepper-vertical/StepperVertical.d.ts +7 -7
- package/lib/components/stepper-vertical/StepperVertical.js +37 -0
- package/lib/components/stepper-vertical/step-vertical/StepVertical.d.ts +12 -12
- package/lib/components/stepper-vertical/step-vertical/StepVertical.js +77 -0
- package/lib/components/tab/Tabs.d.ts +23 -23
- package/lib/components/tab/Tabs.js +229 -0
- package/lib/components/tab/interfaces.d.ts +5 -0
- package/lib/components/tab/interfaces.js +1 -0
- package/lib/components/tab/tab-pane/TabPane.d.ts +11 -13
- package/lib/components/tab/tab-pane/TabPane.js +23 -0
- package/lib/components/tab/useTabScroll.d.ts +24 -24
- package/lib/components/tab/useTabScroll.js +233 -0
- package/lib/components/table-header-cell/TableHeaderCell.d.ts +7 -7
- package/lib/components/table-header-cell/TableHeaderCell.js +21 -0
- package/lib/forms/checkbox/Checkbox.d.ts +16 -16
- package/lib/forms/checkbox/Checkbox.js +88 -0
- package/lib/forms/color-indicator/ColorIndicator.d.ts +12 -12
- package/lib/forms/color-indicator/ColorIndicator.js +122 -0
- package/lib/forms/color-picker/ColorHelper.d.ts +9 -9
- package/lib/forms/color-picker/ColorHelper.js +142 -0
- package/lib/forms/color-picker/ColorPicker.d.ts +15 -15
- package/lib/forms/color-picker/ColorPicker.js +539 -0
- package/lib/forms/date-picker/DatePicker.d.ts +22 -21
- package/lib/forms/date-picker/DatePicker.js +124 -0
- package/lib/forms/date-range-picker/DateRangePicker.d.ts +20 -20
- package/lib/forms/date-range-picker/DateRangePicker.js +135 -0
- package/lib/forms/radio/RadioButton.d.ts +15 -15
- package/lib/forms/radio/RadioButton.js +56 -0
- package/lib/forms/radio/RadioGroup.d.ts +13 -13
- package/lib/forms/radio/RadioGroup.js +35 -0
- package/lib/forms/radio/RadioGroupContext.d.ts +12 -12
- package/lib/forms/radio/RadioGroupContext.js +3 -0
- package/lib/forms/segment/Segment.d.ts +14 -14
- package/lib/forms/segment/Segment.js +77 -0
- package/lib/forms/segment/segment-control/SegmentControl.d.ts +15 -15
- package/lib/forms/segment/segment-control/SegmentControl.js +64 -0
- package/lib/forms/select/Select.d.ts +26 -26
- package/lib/forms/select/Select.js +281 -0
- package/lib/forms/select/select-option/SelectOption.d.ts +10 -10
- package/lib/forms/select/select-option/SelectOption.js +16 -0
- package/lib/forms/slider/Slider.d.ts +18 -17
- package/lib/forms/slider/Slider.js +92 -0
- package/lib/forms/switch/Switch.d.ts +13 -12
- package/lib/forms/switch/Switch.js +51 -0
- package/lib/forms/text-area/TextArea.d.ts +22 -21
- package/lib/forms/text-area/TextArea.js +108 -0
- package/lib/forms/text-editor/TextEditor.d.ts +29 -29
- package/lib/forms/text-editor/TextEditor.js +255 -0
- package/lib/forms/text-editor/TextEditorButton.d.ts +14 -14
- package/lib/forms/text-editor/TextEditorButton.js +82 -0
- package/lib/forms/text-input/TextInput.d.ts +21 -21
- package/lib/forms/text-input/TextInput.js +75 -0
- package/lib/forms/time-picker/TimePicker.d.ts +18 -18
- package/lib/forms/time-picker/TimePicker.js +161 -0
- package/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.d.ts +12 -12
- package/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.js +213 -0
- package/lib/helper/index.d.ts +2 -2
- package/lib/helper/index.js +7 -0
- package/lib/helper/setRef.d.ts +2 -2
- package/lib/helper/setRef.js +7 -0
- package/lib/helper/types.d.ts +7 -7
- package/lib/helper/types.js +1 -0
- package/lib/helper/useControlled.d.ts +6 -6
- package/lib/helper/useControlled.js +18 -0
- package/lib/helper/useForkRef.d.ts +2 -2
- package/lib/helper/useForkRef.js +20 -0
- package/lib/helper/useId.d.ts +1 -0
- package/lib/helper/useId.js +21 -0
- package/lib/helper/useOnClickOutside.d.ts +2 -2
- package/lib/helper/useOnClickOutside.js +18 -0
- package/node/index.js +370 -0
- package/node/lib/components/accordion/Accordion.js +46 -0
- package/node/lib/components/accordion/AccordionContext.js +10 -0
- package/node/lib/components/accordion/accordion-header/AccordionHeader.js +25 -0
- package/node/lib/components/accordion/accordion-item/AccordionItem.js +71 -0
- package/node/lib/components/accordion/accordion-item/AccordionItemContext.js +10 -0
- package/node/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.js +78 -0
- package/node/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.js +49 -0
- package/node/lib/components/breadcrumb/Breadcrumb.js +52 -0
- package/node/lib/components/buttons/button/Button.js +44 -0
- package/node/lib/components/card/Card.js +21 -0
- package/node/lib/components/card/CardBody.js +25 -0
- package/node/lib/components/card/CardHeader.js +30 -0
- package/node/lib/components/card/CardNotification.js +33 -0
- package/node/lib/components/chips/chip/Chip.js +54 -0
- package/node/lib/components/chips/chip/DeleteIcon.js +13 -0
- package/node/lib/components/chips/chip-container/ChipContainer.js +25 -0
- package/node/lib/components/link-button/LinkButton.js +33 -0
- package/node/lib/components/loading-indicator/LoadingIndicator.js +48 -0
- package/node/lib/components/modals/AlertModal.js +82 -0
- package/node/lib/components/modals/ConfirmModal.js +62 -0
- package/node/lib/components/modals/Modal.js +84 -0
- package/node/lib/components/modals/ModalFooter.js +26 -0
- package/node/lib/components/modals/Prompt.js +72 -0
- package/node/lib/components/pagination/Pagination.js +116 -0
- package/node/lib/components/popovers/legend/Legend.js +32 -0
- package/node/lib/components/popovers/popover/Popover.js +117 -0
- package/node/lib/components/popovers/popover-menu/PopoverMenu.js +61 -0
- package/node/lib/components/popovers/tooltip/Tooltip.js +70 -0
- package/node/lib/components/progress/Progress.js +40 -0
- package/node/lib/components/search-input/ClearButton.js +16 -0
- package/node/lib/components/search-input/SearchInput.js +82 -0
- package/node/lib/components/search-input/SearchSuggestion.js +39 -0
- package/node/lib/components/search-input/useSearchInput.js +101 -0
- package/node/lib/components/snackbar/Snackbar.js +94 -0
- package/node/lib/components/snackbar/SnackbarContext.js +10 -0
- package/node/lib/components/snackbar/SnackbarProvider.js +65 -0
- package/node/lib/components/snackbar/useSnackbar.js +11 -0
- package/node/lib/components/stepper-horizontal/StepperHorizontal.js +70 -0
- package/node/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.js +31 -0
- package/node/lib/components/stepper-vertical/StepperVertical.js +47 -0
- package/node/lib/components/stepper-vertical/step-vertical/StepVertical.js +84 -0
- package/node/lib/components/tab/Tabs.js +237 -0
- package/node/lib/components/tab/interfaces.js +5 -0
- package/node/lib/components/tab/tab-pane/TabPane.js +31 -0
- package/node/lib/components/tab/useTabScroll.js +236 -0
- package/node/lib/components/table-header-cell/TableHeaderCell.js +29 -0
- package/node/lib/forms/checkbox/Checkbox.js +97 -0
- package/node/lib/forms/color-indicator/ColorIndicator.js +130 -0
- package/node/lib/forms/color-picker/ColorHelper.js +149 -0
- package/node/lib/forms/color-picker/ColorPicker.js +549 -0
- package/node/lib/forms/date-picker/DatePicker.js +131 -0
- package/node/lib/forms/date-range-picker/DateRangePicker.js +142 -0
- package/node/lib/forms/radio/RadioButton.js +63 -0
- package/node/lib/forms/radio/RadioGroup.js +43 -0
- package/node/lib/forms/radio/RadioGroupContext.js +10 -0
- package/node/lib/forms/segment/Segment.js +84 -0
- package/node/lib/forms/segment/segment-control/SegmentControl.js +72 -0
- package/node/lib/forms/select/Select.js +289 -0
- package/node/lib/forms/select/select-option/SelectOption.js +26 -0
- package/node/lib/forms/slider/Slider.js +101 -0
- package/node/lib/forms/switch/Switch.js +58 -0
- package/node/lib/forms/text-area/TextArea.js +117 -0
- package/node/lib/forms/text-editor/TextEditor.js +261 -0
- package/node/lib/forms/text-editor/TextEditorButton.js +88 -0
- package/node/lib/forms/text-input/TextInput.js +84 -0
- package/node/lib/forms/time-picker/TimePicker.js +169 -0
- package/node/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.js +222 -0
- package/node/lib/helper/index.js +15 -0
- package/node/lib/helper/setRef.js +13 -0
- package/node/lib/helper/types.js +5 -0
- package/node/lib/helper/useControlled.js +24 -0
- package/node/lib/helper/useForkRef.js +26 -0
- package/node/lib/helper/useId.js +27 -0
- package/node/lib/helper/useOnClickOutside.js +24 -0
- package/package.json +20 -10
- package/README.md +0 -17
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
// provides details about the left and right edges of the tab element and the tab content element
|
|
4
|
+
// these values are used to determine the visual position of the tab with respect of its parent container
|
|
5
|
+
|
|
6
|
+
const useTabScroll = (tabLength, componentId, refs) => {
|
|
7
|
+
const {
|
|
8
|
+
elRef,
|
|
9
|
+
scrollContent,
|
|
10
|
+
scrollArea
|
|
11
|
+
} = refs;
|
|
12
|
+
const [style, setStyle] = useState({});
|
|
13
|
+
const [classes, setClasses] = useState('');
|
|
14
|
+
function getScrollContentStyleValue(propName) {
|
|
15
|
+
return scrollContent.current ? window.getComputedStyle(scrollContent.current).getPropertyValue(propName) : '';
|
|
16
|
+
}
|
|
17
|
+
function calculateCurrentTranslateX() {
|
|
18
|
+
const transformValue = getScrollContentStyleValue('transform');
|
|
19
|
+
if (transformValue === 'none') {
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// the transform value is in form of 'matrix(a, b, c, d, tx, ty)'
|
|
24
|
+
// get all the parenthesized values
|
|
25
|
+
const match = /\((.+?)\)/.exec(transformValue);
|
|
26
|
+
if (!match) {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
const matrixParams = match[1];
|
|
30
|
+
// we need value of tx -> translateX
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
+
const [a, b, c, d, tx, ty] = matrixParams.split(',');
|
|
33
|
+
return parseFloat(tx);
|
|
34
|
+
}
|
|
35
|
+
function getScrollPosition() {
|
|
36
|
+
const currentTranslateX = calculateCurrentTranslateX();
|
|
37
|
+
const scrollLeft = scrollArea.current?.scrollLeft ?? 0;
|
|
38
|
+
return scrollLeft - currentTranslateX;
|
|
39
|
+
}
|
|
40
|
+
function calculateScrollEdges() {
|
|
41
|
+
const scrollContentWidth = scrollContent.current?.offsetWidth ?? 0;
|
|
42
|
+
const scrollAreaWidth = scrollArea.current?.offsetWidth ?? 0;
|
|
43
|
+
return {
|
|
44
|
+
left: 0,
|
|
45
|
+
right: scrollContentWidth - scrollAreaWidth
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function clampScrollValue(scrollX) {
|
|
49
|
+
const edges = calculateScrollEdges();
|
|
50
|
+
return Math.min(Math.max(edges.left, scrollX), edges.right);
|
|
51
|
+
}
|
|
52
|
+
function getIncrementScrollOperation(scrollX) {
|
|
53
|
+
const currentScrollX = getScrollPosition();
|
|
54
|
+
const targetScrollX = scrollX + currentScrollX;
|
|
55
|
+
const safeScrollX = clampScrollValue(targetScrollX);
|
|
56
|
+
const scrollDelta = safeScrollX - currentScrollX;
|
|
57
|
+
return {
|
|
58
|
+
finalScrollPosition: safeScrollX,
|
|
59
|
+
scrollDelta
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function getAnimatingScrollPosition() {
|
|
63
|
+
const currentTranslateX = calculateCurrentTranslateX();
|
|
64
|
+
const scrollLeft = scrollArea.current?.scrollLeft ?? 0;
|
|
65
|
+
return scrollLeft - currentTranslateX;
|
|
66
|
+
}
|
|
67
|
+
function stopScrollAnimation() {
|
|
68
|
+
const currentScrollPosition = getAnimatingScrollPosition();
|
|
69
|
+
setClasses('');
|
|
70
|
+
setStyle({
|
|
71
|
+
transform: 'translateX(0px)'
|
|
72
|
+
});
|
|
73
|
+
if (scrollArea.current) {
|
|
74
|
+
scrollArea.current.scrollLeft = currentScrollPosition;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function animate(animation) {
|
|
78
|
+
// no animation needed
|
|
79
|
+
if (animation.scrollDelta === 0) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
stopScrollAnimation();
|
|
83
|
+
|
|
84
|
+
// this animation uses the flip approach
|
|
85
|
+
// https://aerotwist.com/blog/flip-your-animations/
|
|
86
|
+
// https://css-tricks.com/animating-layouts-with-the-flip-technique/
|
|
87
|
+
if (scrollArea.current) {
|
|
88
|
+
scrollArea.current.scrollLeft = animation.finalScrollPosition;
|
|
89
|
+
}
|
|
90
|
+
setStyle({
|
|
91
|
+
transform: `translateX(${animation.scrollDelta}px)`
|
|
92
|
+
});
|
|
93
|
+
// force repaint
|
|
94
|
+
if (scrollArea.current) {
|
|
95
|
+
scrollArea.current.getBoundingClientRect();
|
|
96
|
+
}
|
|
97
|
+
requestAnimationFrame(() => {
|
|
98
|
+
setClasses('fr-tab-scroller--animating');
|
|
99
|
+
setStyle({
|
|
100
|
+
transform: 'none'
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function incrementScroll(scrollXIncrement) {
|
|
105
|
+
// no scroll needed
|
|
106
|
+
if (scrollXIncrement === 0) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const scrollOperation = getIncrementScrollOperation(scrollXIncrement);
|
|
110
|
+
animate(scrollOperation);
|
|
111
|
+
}
|
|
112
|
+
function computeDimensions(tab) {
|
|
113
|
+
const rootWidth = tab.offsetWidth;
|
|
114
|
+
const rootLeft = tab.offsetLeft;
|
|
115
|
+
const tabContent = tab.querySelector('.fr-tab-content');
|
|
116
|
+
const contentWidth = tabContent?.offsetWidth ?? 0;
|
|
117
|
+
const contentLeft = tabContent?.offsetLeft ?? 0;
|
|
118
|
+
return {
|
|
119
|
+
contentLeft: rootLeft + contentLeft,
|
|
120
|
+
contentRight: rootLeft + contentLeft + contentWidth,
|
|
121
|
+
rootLeft,
|
|
122
|
+
rootRight: rootLeft + rootWidth
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function calculateScrollIncrement(index, nextIndex, scrollPosition, barWidth) {
|
|
126
|
+
const nextTab = elRef.current?.querySelector(`#${componentId}-tab-${nextIndex}`);
|
|
127
|
+
if (nextTab === null || nextTab === undefined) {
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
const nextTabDimensions = computeDimensions(nextTab);
|
|
131
|
+
const relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth;
|
|
132
|
+
const relativeContentRight = nextTabDimensions.contentRight - scrollPosition;
|
|
133
|
+
const leftIncrement = relativeContentRight - 48;
|
|
134
|
+
const rightIncrement = relativeContentLeft + 48;
|
|
135
|
+
if (nextIndex < index) {
|
|
136
|
+
return Math.min(leftIncrement, 0);
|
|
137
|
+
}
|
|
138
|
+
return Math.max(rightIncrement, 0);
|
|
139
|
+
}
|
|
140
|
+
function findAdjacentTabIndexClosestToEdge(index, tabDimensions, scrollPosition, barWidth) {
|
|
141
|
+
/**
|
|
142
|
+
* tabs are laid out in the tab scroller like this:
|
|
143
|
+
*
|
|
144
|
+
* scroll position
|
|
145
|
+
* +---+
|
|
146
|
+
* | | bar width
|
|
147
|
+
* | +-----------------------------------+
|
|
148
|
+
* | | |
|
|
149
|
+
* | v v
|
|
150
|
+
* | +-----------------------------------+
|
|
151
|
+
* v | tab scroller |
|
|
152
|
+
* +------------+--------------+-------------------+
|
|
153
|
+
* | tab | tab | tab |
|
|
154
|
+
* +------------+--------------+-------------------+
|
|
155
|
+
* | |
|
|
156
|
+
* +-----------------------------------+
|
|
157
|
+
*
|
|
158
|
+
* to determine the next adjacent index, we look at the tab root left and
|
|
159
|
+
* tab root right, both relative to the scroll position. if the tab root
|
|
160
|
+
* left is less than 0, then we know it's out of view to the left. if the
|
|
161
|
+
* tab root right minus the bar width is greater than 0, we know the tab is
|
|
162
|
+
* out of view to the right. from there, we either increment or decrement
|
|
163
|
+
* the index.
|
|
164
|
+
*/
|
|
165
|
+
const relativeRootLeft = tabDimensions.rootLeft - scrollPosition;
|
|
166
|
+
const relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth;
|
|
167
|
+
const relativeRootDelta = relativeRootLeft + relativeRootRight;
|
|
168
|
+
const leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0;
|
|
169
|
+
const rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0;
|
|
170
|
+
if (leftEdgeIsCloser) {
|
|
171
|
+
return index - 1;
|
|
172
|
+
}
|
|
173
|
+
if (rightEdgeIsCloser) {
|
|
174
|
+
return index + 1;
|
|
175
|
+
}
|
|
176
|
+
return -1;
|
|
177
|
+
}
|
|
178
|
+
function indexIsInRange(index) {
|
|
179
|
+
return index >= 0 && index < tabLength;
|
|
180
|
+
}
|
|
181
|
+
function scrollIntoView(index, tab) {
|
|
182
|
+
const scrollPosition = getScrollPosition();
|
|
183
|
+
const barWidth = scrollArea.current?.offsetWidth ?? 0;
|
|
184
|
+
const tabDimensions = computeDimensions(tab);
|
|
185
|
+
const nextIndex = findAdjacentTabIndexClosestToEdge(index, tabDimensions, scrollPosition, barWidth);
|
|
186
|
+
if (!indexIsInRange(nextIndex)) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const scrollIncrement = calculateScrollIncrement(index, nextIndex, scrollPosition, barWidth);
|
|
190
|
+
incrementScroll(scrollIncrement);
|
|
191
|
+
}
|
|
192
|
+
function scrollTo(scrollX) {
|
|
193
|
+
const currentScrollX = getScrollPosition();
|
|
194
|
+
const safeScrollX = clampScrollValue(scrollX);
|
|
195
|
+
const scrollDelta = safeScrollX - currentScrollX;
|
|
196
|
+
animate({
|
|
197
|
+
finalScrollPosition: safeScrollX,
|
|
198
|
+
scrollDelta
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function handleTabScroll(e, index) {
|
|
202
|
+
const scrollContentWidth = scrollContent.current?.offsetWidth ?? 0;
|
|
203
|
+
const scrollAreaWidth = scrollArea.current?.offsetWidth ?? 0;
|
|
204
|
+
|
|
205
|
+
// check if no scroll is needed
|
|
206
|
+
if (scrollAreaWidth > scrollContentWidth) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// check index
|
|
211
|
+
if (!indexIsInRange(index)) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// always scroll to 0 if scrolling to the first tab
|
|
216
|
+
if (index === 0) {
|
|
217
|
+
scrollTo(0);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// always scroll to the max value if scrolling to the last tab
|
|
222
|
+
if (index === tabLength - 1 && scrollContent.current) {
|
|
223
|
+
scrollTo(scrollContent.current.offsetWidth);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (e.currentTarget instanceof HTMLElement) {
|
|
227
|
+
const currentTab = e.currentTarget;
|
|
228
|
+
scrollIntoView(index, currentTab);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return [handleTabScroll, classes, style];
|
|
232
|
+
};
|
|
233
|
+
export default useTabScroll;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export interface TableHeaderCellProps extends React.ThHTMLAttributes<HTMLTableCellElement> {
|
|
3
|
-
active?: boolean;
|
|
4
|
-
ascending: boolean;
|
|
5
|
-
}
|
|
6
|
-
declare const TableHeaderCell:
|
|
7
|
-
export default TableHeaderCell;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface TableHeaderCellProps extends React.ThHTMLAttributes<HTMLTableCellElement> {
|
|
3
|
+
active?: boolean;
|
|
4
|
+
ascending: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const TableHeaderCell: import("react").ForwardRefExoticComponent<TableHeaderCellProps & import("react").RefAttributes<HTMLTableHeaderCellElement>>;
|
|
7
|
+
export default TableHeaderCell;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const TableHeaderCell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
5
|
+
function handleClick(event) {
|
|
6
|
+
if (props.onClick) {
|
|
7
|
+
props.onClick(event);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return /*#__PURE__*/_jsx("th", {
|
|
11
|
+
...props,
|
|
12
|
+
className: classNames('fwe-table-order', {
|
|
13
|
+
'fwe-active': props.active
|
|
14
|
+
}, {
|
|
15
|
+
'fwe-table-order-descending': !props.ascending
|
|
16
|
+
}, props.className),
|
|
17
|
+
onClick: handleClick,
|
|
18
|
+
ref: ref
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
export default TableHeaderCell;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './Checkbox.scss';
|
|
3
|
-
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
4
|
-
id: string;
|
|
5
|
-
checked: boolean;
|
|
6
|
-
onChange: (value: boolean) => void;
|
|
7
|
-
name?: string;
|
|
8
|
-
large?: boolean;
|
|
9
|
-
valid?: boolean;
|
|
10
|
-
labelPosition?: 'before' | 'after' | 'below';
|
|
11
|
-
required?: boolean;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
indeterminate?: boolean;
|
|
14
|
-
}
|
|
15
|
-
declare function Checkbox({ id, checked, onChange, name, large, valid, labelPosition, required, disabled, indeterminate, children, className, ...props }: CheckboxProps): JSX.Element;
|
|
16
|
-
export default Checkbox;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './Checkbox.scss';
|
|
3
|
+
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
4
|
+
id: string;
|
|
5
|
+
checked: boolean;
|
|
6
|
+
onChange: (value: boolean) => void;
|
|
7
|
+
name?: string;
|
|
8
|
+
large?: boolean;
|
|
9
|
+
valid?: boolean;
|
|
10
|
+
labelPosition?: 'before' | 'after' | 'below';
|
|
11
|
+
required?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
indeterminate?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare function Checkbox({ id, checked, onChange, name, large, valid, labelPosition, required, disabled, indeterminate, children, className, ...props }: CheckboxProps): JSX.Element;
|
|
16
|
+
export default Checkbox;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useState, useEffect } 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
|
+
function Checkbox(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
id,
|
|
8
|
+
checked,
|
|
9
|
+
onChange,
|
|
10
|
+
name,
|
|
11
|
+
large = false,
|
|
12
|
+
valid = true,
|
|
13
|
+
labelPosition = 'after',
|
|
14
|
+
required,
|
|
15
|
+
disabled = false,
|
|
16
|
+
indeterminate = false,
|
|
17
|
+
children,
|
|
18
|
+
className,
|
|
19
|
+
...props
|
|
20
|
+
} = _ref;
|
|
21
|
+
const [isChecked, setChecked] = useState(checked);
|
|
22
|
+
const [isIndeterminate, setIndeterminate] = useState(indeterminate);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
setChecked(checked);
|
|
25
|
+
setIndeterminate(indeterminate);
|
|
26
|
+
}, [checked, indeterminate]);
|
|
27
|
+
const handleChange = () => {
|
|
28
|
+
const newChecked = !isChecked;
|
|
29
|
+
if (indeterminate) {
|
|
30
|
+
setIndeterminate(false);
|
|
31
|
+
}
|
|
32
|
+
setChecked(newChecked);
|
|
33
|
+
onChange(newChecked);
|
|
34
|
+
};
|
|
35
|
+
const containerClasses = classNames('fwe-checkbox-container', {
|
|
36
|
+
'fr-checkbox-large': large
|
|
37
|
+
}, {
|
|
38
|
+
'fr-checkbox-invalid': !valid || required
|
|
39
|
+
}, {
|
|
40
|
+
'fwe-disabled': disabled
|
|
41
|
+
}, {
|
|
42
|
+
'fwe-checked': isChecked
|
|
43
|
+
}, {
|
|
44
|
+
'fwe-label-below': labelPosition === 'below'
|
|
45
|
+
}, {
|
|
46
|
+
'fwe-label-before': labelPosition === 'before'
|
|
47
|
+
}, {
|
|
48
|
+
'fr-checkbox-indeterminate': isIndeterminate
|
|
49
|
+
}, className);
|
|
50
|
+
return /*#__PURE__*/_jsxs("label", {
|
|
51
|
+
className: containerClasses,
|
|
52
|
+
htmlFor: id,
|
|
53
|
+
children: [/*#__PURE__*/_jsx("input", {
|
|
54
|
+
name: name,
|
|
55
|
+
type: "checkbox",
|
|
56
|
+
id: id,
|
|
57
|
+
disabled: disabled,
|
|
58
|
+
onChange: () => handleChange(),
|
|
59
|
+
...props
|
|
60
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
61
|
+
className: "fwe-checkbox-indicator-container",
|
|
62
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
63
|
+
className: "fwe-checkbox-indicator-background"
|
|
64
|
+
}), !isIndeterminate && isChecked && (large ? /*#__PURE__*/_jsx("svg", {
|
|
65
|
+
width: "24px",
|
|
66
|
+
height: "24px",
|
|
67
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
68
|
+
d: "M17.5 7L10 14.5 7.501 12l-1.5 1.501L10 17.5l9-9z",
|
|
69
|
+
fill: "#fff"
|
|
70
|
+
})
|
|
71
|
+
}) : /*#__PURE__*/_jsx("svg", {
|
|
72
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
73
|
+
width: "16",
|
|
74
|
+
height: "16",
|
|
75
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
76
|
+
d: "M6 12L3 9l1.25-1.25L6 9.5l5.75-5.75L13 5l-7 7z",
|
|
77
|
+
fill: "#fff"
|
|
78
|
+
})
|
|
79
|
+
})), isIndeterminate && !isChecked && /*#__PURE__*/_jsx("div", {
|
|
80
|
+
className: "fwe-indeterminate-indicator"
|
|
81
|
+
})]
|
|
82
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
83
|
+
className: "fwe-checkbox-title",
|
|
84
|
+
children: children
|
|
85
|
+
})]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
export default Checkbox;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ClassNamePropsWithChildren } from '../../helper/types';
|
|
3
|
-
import './ColorIndicator.scss';
|
|
4
|
-
interface ColorIndicatorProps extends ClassNamePropsWithChildren {
|
|
5
|
-
text: string;
|
|
6
|
-
label: string;
|
|
7
|
-
color?: string;
|
|
8
|
-
showPopOver?: boolean;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}
|
|
11
|
-
declare function ColorIndicator({ text, label, color, className, showPopOver, children, disabled }: ColorIndicatorProps): JSX.Element;
|
|
12
|
-
export default ColorIndicator;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ClassNamePropsWithChildren } from '../../helper/types';
|
|
3
|
+
import './ColorIndicator.scss';
|
|
4
|
+
interface ColorIndicatorProps extends ClassNamePropsWithChildren {
|
|
5
|
+
text: string;
|
|
6
|
+
label: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
showPopOver?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function ColorIndicator({ text, label, color, className, showPopOver, children, disabled, }: ColorIndicatorProps): JSX.Element;
|
|
12
|
+
export default ColorIndicator;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import Popover from '../../components/popovers/popover/Popover';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
function ColorIndicator(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
text,
|
|
10
|
+
label,
|
|
11
|
+
color,
|
|
12
|
+
className,
|
|
13
|
+
showPopOver = false,
|
|
14
|
+
children,
|
|
15
|
+
disabled
|
|
16
|
+
} = _ref;
|
|
17
|
+
const classes = classNames('fwe-color-indicator', className, disabled);
|
|
18
|
+
const [isEditorOpen, setEditorOpen] = useState(false);
|
|
19
|
+
function getBorderColor() {
|
|
20
|
+
if (!color || color.toUpperCase() === '#FFFFFF' || color.toUpperCase() === '#F2F3F5') {
|
|
21
|
+
return '#b6bec6'; // = $control-border
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return color;
|
|
25
|
+
}
|
|
26
|
+
const colorBox = /*#__PURE__*/_jsx("div", {
|
|
27
|
+
className: "fwe-color-box",
|
|
28
|
+
style: {
|
|
29
|
+
background: color,
|
|
30
|
+
borderColor: getBorderColor()
|
|
31
|
+
},
|
|
32
|
+
children: !color && /*#__PURE__*/_jsxs("svg", {
|
|
33
|
+
className: "fwe-no-color-pattern",
|
|
34
|
+
version: "1.1",
|
|
35
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
36
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
37
|
+
id: "canvas1",
|
|
38
|
+
width: "18",
|
|
39
|
+
height: "18",
|
|
40
|
+
children: [/*#__PURE__*/_jsx("defs", {
|
|
41
|
+
children: /*#__PURE__*/_jsxs("pattern", {
|
|
42
|
+
id: "bwsquare2px",
|
|
43
|
+
width: "4",
|
|
44
|
+
height: "4",
|
|
45
|
+
patternUnits: "userSpaceOnUse",
|
|
46
|
+
children: [/*#__PURE__*/_jsx("rect", {
|
|
47
|
+
x: "0",
|
|
48
|
+
y: "0",
|
|
49
|
+
width: "2",
|
|
50
|
+
height: "2",
|
|
51
|
+
stroke: "none",
|
|
52
|
+
fill: "#ffffff"
|
|
53
|
+
}), /*#__PURE__*/_jsx("rect", {
|
|
54
|
+
x: "2",
|
|
55
|
+
y: "0",
|
|
56
|
+
width: "2",
|
|
57
|
+
height: "2",
|
|
58
|
+
stroke: "none",
|
|
59
|
+
fill: "#e5e8eb"
|
|
60
|
+
}), /*#__PURE__*/_jsx("rect", {
|
|
61
|
+
x: "0",
|
|
62
|
+
y: "2",
|
|
63
|
+
width: "2",
|
|
64
|
+
height: "2",
|
|
65
|
+
stroke: "none",
|
|
66
|
+
fill: "#e5e8eb"
|
|
67
|
+
}), /*#__PURE__*/_jsx("rect", {
|
|
68
|
+
x: "2",
|
|
69
|
+
y: "2",
|
|
70
|
+
width: "2",
|
|
71
|
+
height: "2",
|
|
72
|
+
stroke: "none",
|
|
73
|
+
fill: "#ffffff"
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
}), /*#__PURE__*/_jsx("rect", {
|
|
77
|
+
x: "0",
|
|
78
|
+
y: "0",
|
|
79
|
+
rx: "0",
|
|
80
|
+
ry: "0",
|
|
81
|
+
width: "18",
|
|
82
|
+
height: "18",
|
|
83
|
+
fill: "url(#bwsquare2px)",
|
|
84
|
+
strokeWidth: "0"
|
|
85
|
+
})]
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
const wrapperProperties = showPopOver ? {
|
|
89
|
+
onClick: () => setEditorOpen(prevOpen => !prevOpen)
|
|
90
|
+
} : {};
|
|
91
|
+
const wrapper = wrapperChildren => /*#__PURE__*/_jsxs("div", {
|
|
92
|
+
className: classes,
|
|
93
|
+
...wrapperProperties,
|
|
94
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
95
|
+
style: {
|
|
96
|
+
opacity: isEditorOpen ? 0 : 1
|
|
97
|
+
},
|
|
98
|
+
className: "fwe-color-label",
|
|
99
|
+
children: label
|
|
100
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
101
|
+
className: "fwe-color-container",
|
|
102
|
+
children: [wrapperChildren, " ", text && /*#__PURE__*/_jsx("div", {
|
|
103
|
+
className: "fwe-color-indicator-text",
|
|
104
|
+
children: text
|
|
105
|
+
}), ' ']
|
|
106
|
+
})]
|
|
107
|
+
});
|
|
108
|
+
return showPopOver ? /*#__PURE__*/_jsx(Popover, {
|
|
109
|
+
containerClassName: "fwe-popover-container--color-indicator",
|
|
110
|
+
position: "top",
|
|
111
|
+
flip: false,
|
|
112
|
+
wrapper: wrapper,
|
|
113
|
+
popoverContent: children,
|
|
114
|
+
open: isEditorOpen,
|
|
115
|
+
onStatusChange: setEditorOpen,
|
|
116
|
+
stopPropagation: true,
|
|
117
|
+
children: colorBox
|
|
118
|
+
}) : /*#__PURE__*/_jsx(_Fragment, {
|
|
119
|
+
children: wrapper(colorBox)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
export default ColorIndicator;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export default abstract class ColorHelper {
|
|
2
|
-
static rgbToHsv(rgb: Record<'r' | 'g' | 'b', number>): Record<'h' | 's' | 'v', number> | undefined;
|
|
3
|
-
static hsvToRgb(_hsv: Record<'h' | 's' | 'v', number>): Record<'r' | 'g' | 'b', number>;
|
|
4
|
-
private static limitToByte;
|
|
5
|
-
private static limitToOne;
|
|
6
|
-
private static numberToHex;
|
|
7
|
-
static rgbToHex(_rgb: Record<'r' | 'g' | 'b', number>): string;
|
|
8
|
-
static hexToRgb(hexString: string): Record<'r' | 'g' | 'b', number> | undefined;
|
|
9
|
-
}
|
|
1
|
+
export default abstract class ColorHelper {
|
|
2
|
+
static rgbToHsv(rgb: Record<'r' | 'g' | 'b', number>): Record<'h' | 's' | 'v', number> | undefined;
|
|
3
|
+
static hsvToRgb(_hsv: Record<'h' | 's' | 'v', number>): Record<'r' | 'g' | 'b', number>;
|
|
4
|
+
private static limitToByte;
|
|
5
|
+
private static limitToOne;
|
|
6
|
+
private static numberToHex;
|
|
7
|
+
static rgbToHex(_rgb: Record<'r' | 'g' | 'b', number>): string;
|
|
8
|
+
static hexToRgb(hexString: string): Record<'r' | 'g' | 'b', number> | undefined;
|
|
9
|
+
}
|