@rolster/react-components 19.8.16 → 19.8.17
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/dist/cjs/index.cjs +60 -29
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +60 -31
- package/dist/es/index.mjs.map +1 -1
- package/dist/esm/components/molecules/FieldListSuggestions/FieldListSuggestions.js +1 -1
- package/dist/esm/components/molecules/FieldListSuggestions/FieldListSuggestions.js.map +1 -1
- package/dist/esm/components/molecules/FieldListSuggestions/SuggestionsPortalController.d.ts +1 -1
- package/dist/esm/components/molecules/FieldListSuggestions/SuggestionsPortalController.js +28 -8
- package/dist/esm/components/molecules/FieldListSuggestions/SuggestionsPortalController.js.map +1 -1
- package/dist/esm/components/organisms/PickerClock/PickerClock.js +4 -3
- package/dist/esm/components/organisms/PickerClock/PickerClock.js.map +1 -1
- package/dist/esm/components/organisms/PickerColor/PickerColor.js +6 -5
- package/dist/esm/components/organisms/PickerColor/PickerColor.js.map +1 -1
- package/dist/esm/controllers/EventCallbackController.d.ts +1 -0
- package/dist/esm/controllers/EventCallbackController.js +9 -0
- package/dist/esm/controllers/EventCallbackController.js.map +1 -0
- package/dist/esm/controllers/ListController.js +10 -13
- package/dist/esm/controllers/ListController.js.map +1 -1
- package/dist/esm/controllers/RelocationOnComponentController.js +4 -3
- package/dist/esm/controllers/RelocationOnComponentController.js.map +1 -1
- package/dist/esm/controllers/ResizeController.js +3 -2
- package/dist/esm/controllers/ResizeController.js.map +1 -1
- package/dist/esm/helpers/css.d.ts +1 -0
- package/dist/esm/helpers/css.js +8 -0
- package/dist/esm/helpers/css.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -430,6 +430,14 @@ function requireJsxRuntime () {
|
|
|
430
430
|
|
|
431
431
|
var jsxRuntimeExports = requireJsxRuntime();
|
|
432
432
|
|
|
433
|
+
const FALLBACK_REM_SIZE$1 = 16;
|
|
434
|
+
function getRemSize$1() {
|
|
435
|
+
if (typeof window === 'undefined') {
|
|
436
|
+
return FALLBACK_REM_SIZE$1;
|
|
437
|
+
}
|
|
438
|
+
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
439
|
+
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE$1;
|
|
440
|
+
}
|
|
433
441
|
function renderClassStatus(base, status = {}, additionals) {
|
|
434
442
|
const classElement = [base];
|
|
435
443
|
Object.entries(status).forEach(([key, state]) => {
|
|
@@ -1638,6 +1646,19 @@ const reactI18n = i18n.i18n({
|
|
|
1638
1646
|
}
|
|
1639
1647
|
});
|
|
1640
1648
|
|
|
1649
|
+
function useEventCallback(callback) {
|
|
1650
|
+
const refCallback = require$$0.useRef(callback);
|
|
1651
|
+
require$$0.useInsertionEffect(() => {
|
|
1652
|
+
refCallback.current = callback;
|
|
1653
|
+
});
|
|
1654
|
+
return require$$0.useCallback((...args) => refCallback.current(...args), []);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
const MAX_LIST_HEIGHT_REM$2 = 180;
|
|
1658
|
+
const MOBILE_MEDIA_QUERY = '(max-width: 480px)';
|
|
1659
|
+
const SUGGESTIONS_OFFSET_REM = 6;
|
|
1660
|
+
const SUGGESTIONS_OVERLAP_REM = 4;
|
|
1661
|
+
const VIEWPORT_GAP_REM$1 = 8;
|
|
1641
1662
|
function getScrollableAncestors(element) {
|
|
1642
1663
|
const ancestors = [];
|
|
1643
1664
|
let parent = element.parentElement;
|
|
@@ -1670,14 +1691,22 @@ function anchorIsVisible(rect, scrollables) {
|
|
|
1670
1691
|
rect.right > left &&
|
|
1671
1692
|
rect.left < right);
|
|
1672
1693
|
}
|
|
1673
|
-
function
|
|
1694
|
+
function getMaxHeight(rect, higher) {
|
|
1695
|
+
const remSize = getRemSize$1();
|
|
1696
|
+
const gap = VIEWPORT_GAP_REM$1 * remSize;
|
|
1697
|
+
const available = higher
|
|
1698
|
+
? rect.top + SUGGESTIONS_OVERLAP_REM * remSize - gap
|
|
1699
|
+
: window.innerHeight - rect.bottom - SUGGESTIONS_OFFSET_REM * remSize - gap;
|
|
1700
|
+
return Math.max(0, Math.round(available));
|
|
1701
|
+
}
|
|
1702
|
+
function useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor, higher) {
|
|
1674
1703
|
const [mounted, setMounted] = require$$0.useState(false);
|
|
1675
1704
|
const [style, setStyle] = require$$0.useState();
|
|
1676
1705
|
const [theme, setTheme] = require$$0.useState();
|
|
1677
1706
|
require$$0.useEffect(() => {
|
|
1678
1707
|
setMounted(true);
|
|
1679
1708
|
}, []);
|
|
1680
|
-
const onAnchorHidden =
|
|
1709
|
+
const onAnchorHidden = useEventCallback(() => {
|
|
1681
1710
|
onHiddenAnchor?.();
|
|
1682
1711
|
});
|
|
1683
1712
|
require$$0.useEffect(() => {
|
|
@@ -1695,15 +1724,20 @@ function useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor) {
|
|
|
1695
1724
|
}
|
|
1696
1725
|
const rect = anchor.getBoundingClientRect();
|
|
1697
1726
|
if (!anchorIsVisible(rect, scrollables)) {
|
|
1698
|
-
onAnchorHidden();
|
|
1699
|
-
return;
|
|
1727
|
+
return onAnchorHidden();
|
|
1700
1728
|
}
|
|
1701
|
-
|
|
1729
|
+
const style = {
|
|
1702
1730
|
'--pvt-portal-top': `${rect.bottom}px`,
|
|
1703
1731
|
'--pvt-portal-bottom': `${window.innerHeight - rect.top}px`,
|
|
1704
1732
|
'--pvt-portal-left': `${rect.left}px`,
|
|
1705
1733
|
'--pvt-portal-width': `${rect.width}px`
|
|
1706
|
-
}
|
|
1734
|
+
};
|
|
1735
|
+
if (!window.matchMedia?.(MOBILE_MEDIA_QUERY).matches) {
|
|
1736
|
+
const maxHeight = `min(${MAX_LIST_HEIGHT_REM$2}rem, ${getMaxHeight(rect, higher)}px)`;
|
|
1737
|
+
style['--pvt-list-max-height'] = maxHeight;
|
|
1738
|
+
style['--pvt-list-body-max-height'] = maxHeight;
|
|
1739
|
+
}
|
|
1740
|
+
setStyle(style);
|
|
1707
1741
|
}
|
|
1708
1742
|
function requestReposition() {
|
|
1709
1743
|
cancelAnimationFrame(frame);
|
|
@@ -1717,7 +1751,7 @@ function useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor) {
|
|
|
1717
1751
|
window.removeEventListener('scroll', requestReposition, true);
|
|
1718
1752
|
window.removeEventListener('resize', requestReposition);
|
|
1719
1753
|
};
|
|
1720
|
-
}, [mounted, visible, refAnchor]);
|
|
1754
|
+
}, [mounted, visible, refAnchor, higher]);
|
|
1721
1755
|
return { active: mounted && !!refAnchor, style, theme };
|
|
1722
1756
|
}
|
|
1723
1757
|
|
|
@@ -1731,7 +1765,7 @@ function RlsFieldListLi({ element, onClickElement, onKeydownElement, render }) {
|
|
|
1731
1765
|
return (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: onClick, onKeyDown: onKeyDown, children: render(element) }));
|
|
1732
1766
|
}
|
|
1733
1767
|
function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher, render, renderEmpty, searchControl, visible, onClickBackdrop, onClickElement, onHiddenAnchor, onKeydownElement, refAnchor, refList, refSuggestions, rlsTheme }) {
|
|
1734
|
-
const portal = useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor);
|
|
1768
|
+
const portal = useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor, higher);
|
|
1735
1769
|
const [labels, setLabels] = require$$0.useState({
|
|
1736
1770
|
listEmptyDescription: reactI18n('listEmptyDescription'),
|
|
1737
1771
|
listEmptyTitle: reactI18n('listEmptyTitle')
|
|
@@ -2464,14 +2498,7 @@ function RlsCardComponent({ children, className, outline, rlsTheme }) {
|
|
|
2464
2498
|
const RlsCard = require$$0.memo(RlsCardComponent);
|
|
2465
2499
|
|
|
2466
2500
|
const MAX_LIST_HEIGHT_REM$1 = 90;
|
|
2467
|
-
const
|
|
2468
|
-
function getRemSize$1() {
|
|
2469
|
-
if (typeof window === 'undefined') {
|
|
2470
|
-
return FALLBACK_REM_SIZE$1;
|
|
2471
|
-
}
|
|
2472
|
-
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
2473
|
-
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE$1;
|
|
2474
|
-
}
|
|
2501
|
+
const VIEWPORT_GAP_REM = 8;
|
|
2475
2502
|
function suggestionsShallowEqual(a, b) {
|
|
2476
2503
|
return (a === b ||
|
|
2477
2504
|
(a.length === b.length && a.every((element, index) => element === b[index])));
|
|
@@ -2487,10 +2514,12 @@ function shouldDisplayHigher$1(content, list) {
|
|
|
2487
2514
|
if (!content) {
|
|
2488
2515
|
return false;
|
|
2489
2516
|
}
|
|
2517
|
+
const remSize = getRemSize$1();
|
|
2518
|
+
const gap = VIEWPORT_GAP_REM * remSize;
|
|
2490
2519
|
const { top, bottom } = content.getBoundingClientRect();
|
|
2491
|
-
const spaceAbove = top;
|
|
2492
|
-
const spaceBelow = window.innerHeight - bottom;
|
|
2493
|
-
const maxHeight = MAX_LIST_HEIGHT_REM$1 *
|
|
2520
|
+
const spaceAbove = top - gap;
|
|
2521
|
+
const spaceBelow = window.innerHeight - bottom - gap;
|
|
2522
|
+
const maxHeight = MAX_LIST_HEIGHT_REM$1 * remSize;
|
|
2494
2523
|
const desiredHeight = Math.min(list?.scrollHeight || maxHeight, maxHeight);
|
|
2495
2524
|
if (spaceBelow >= desiredHeight) {
|
|
2496
2525
|
return false;
|
|
@@ -2559,7 +2588,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2559
2588
|
formControl?.setValue(element?.value);
|
|
2560
2589
|
}
|
|
2561
2590
|
}, [formControl]);
|
|
2562
|
-
const reconcileFormValue =
|
|
2591
|
+
const reconcileFormValue = useEventCallback(() => {
|
|
2563
2592
|
if (!changeValueInternal.current) {
|
|
2564
2593
|
if (formControl?.value) {
|
|
2565
2594
|
const element = collection.find(formControl.value);
|
|
@@ -3503,10 +3532,10 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3503
3532
|
const classNamePM = renderClassStatus('rls-picker-clock__zone__value', {
|
|
3504
3533
|
active: zoneIsPM
|
|
3505
3534
|
});
|
|
3506
|
-
const refreshClockHour =
|
|
3535
|
+
const refreshClockHour = useEventCallback(() => {
|
|
3507
3536
|
refreshClock(hour > 12 ? hour - 12 : hour);
|
|
3508
3537
|
});
|
|
3509
|
-
const refreshClockMinute =
|
|
3538
|
+
const refreshClockMinute = useEventCallback(() => {
|
|
3510
3539
|
refreshClock(minute);
|
|
3511
3540
|
});
|
|
3512
3541
|
require$$0.useEffect(() => {
|
|
@@ -3770,7 +3799,7 @@ function RlsPickerColorComponent({ color, formControl, onListener, rlsTheme }) {
|
|
|
3770
3799
|
y: (clientY - rect.top) / rect.height
|
|
3771
3800
|
};
|
|
3772
3801
|
}, []);
|
|
3773
|
-
const updateColorOnCanvas =
|
|
3802
|
+
const updateColorOnCanvas = useEventCallback((clientX, clientY) => {
|
|
3774
3803
|
if (!canvasRef.current)
|
|
3775
3804
|
return;
|
|
3776
3805
|
const pos = getPositionInElement(canvasRef.current, clientX, clientY);
|
|
@@ -3780,7 +3809,7 @@ function RlsPickerColorComponent({ color, formControl, onListener, rlsTheme }) {
|
|
|
3780
3809
|
v: Math.round(Math.min(1, Math.max(0, 1 - pos.y)) * 100)
|
|
3781
3810
|
}));
|
|
3782
3811
|
});
|
|
3783
|
-
const updateHueOnSlider =
|
|
3812
|
+
const updateHueOnSlider = useEventCallback((clientX, clientY) => {
|
|
3784
3813
|
if (!hueRef.current)
|
|
3785
3814
|
return;
|
|
3786
3815
|
const pos = getPositionInElement(hueRef.current, clientX, clientY);
|
|
@@ -3789,7 +3818,7 @@ function RlsPickerColorComponent({ color, formControl, onListener, rlsTheme }) {
|
|
|
3789
3818
|
h: Math.round(Math.min(1, Math.max(0, pos.x)) * 360)
|
|
3790
3819
|
}));
|
|
3791
3820
|
});
|
|
3792
|
-
const updateAlphaOnSlider =
|
|
3821
|
+
const updateAlphaOnSlider = useEventCallback((clientX, clientY) => {
|
|
3793
3822
|
if (!alphaRef.current)
|
|
3794
3823
|
return;
|
|
3795
3824
|
const pos = getPositionInElement(alphaRef.current, clientX, clientY);
|
|
@@ -3884,7 +3913,7 @@ function RlsPickerColorComponent({ color, formControl, onListener, rlsTheme }) {
|
|
|
3884
3913
|
const onHexFocus = require$$0.useCallback(() => {
|
|
3885
3914
|
hexEditing.current = true;
|
|
3886
3915
|
}, []);
|
|
3887
|
-
const onHexBlur =
|
|
3916
|
+
const onHexBlur = useEventCallback(() => {
|
|
3888
3917
|
hexEditing.current = false;
|
|
3889
3918
|
const normalized = normalizeHex(hexInput);
|
|
3890
3919
|
if (normalized) {
|
|
@@ -4329,7 +4358,7 @@ function useRelocationOnComponent({ container: containerRef, element: elementRef
|
|
|
4329
4358
|
}
|
|
4330
4359
|
return clientY;
|
|
4331
4360
|
}
|
|
4332
|
-
const start =
|
|
4361
|
+
const start = useEventCallback((positionX, positionY) => {
|
|
4333
4362
|
dragOffset.current = {
|
|
4334
4363
|
x: positionX,
|
|
4335
4364
|
y: positionY
|
|
@@ -4340,7 +4369,7 @@ function useRelocationOnComponent({ container: containerRef, element: elementRef
|
|
|
4340
4369
|
};
|
|
4341
4370
|
dragging.current = true;
|
|
4342
4371
|
});
|
|
4343
|
-
const relocation =
|
|
4372
|
+
const relocation = useEventCallback((positionX, positionY) => {
|
|
4344
4373
|
const clientX = getClientX(positionX);
|
|
4345
4374
|
const clientY = getClientY(positionY);
|
|
4346
4375
|
elementRef.current.style.top = `${clientY}px`;
|
|
@@ -4393,7 +4422,7 @@ function useRelocationOnComponent({ container: containerRef, element: elementRef
|
|
|
4393
4422
|
|
|
4394
4423
|
function useResize({ refElement, onResize }) {
|
|
4395
4424
|
const dimension = require$$0.useRef({ height: 0, width: 0 });
|
|
4396
|
-
const observer =
|
|
4425
|
+
const observer = useEventCallback((entries) => {
|
|
4397
4426
|
const { height, width } = entries[0].contentRect;
|
|
4398
4427
|
onResize?.({
|
|
4399
4428
|
current: dimension.current,
|
|
@@ -5193,6 +5222,7 @@ exports.RlsToolbar = RlsToolbar;
|
|
|
5193
5222
|
exports.calculateImgDimension = calculateImgDimension;
|
|
5194
5223
|
exports.generateThemePalette = generateThemePalette;
|
|
5195
5224
|
exports.getAppTheme = getAppTheme;
|
|
5225
|
+
exports.getRemSize = getRemSize$1;
|
|
5196
5226
|
exports.hexIsValid = hexIsValid;
|
|
5197
5227
|
exports.hexToHsl = hexToHsl;
|
|
5198
5228
|
exports.hexToHsv = hexToHsv;
|
|
@@ -5215,6 +5245,7 @@ exports.useConfirmation = useConfirmation;
|
|
|
5215
5245
|
exports.useDatatable = useDatatable;
|
|
5216
5246
|
exports.useDesingSystemController = useDesingSystemController;
|
|
5217
5247
|
exports.useDropdownController = useDropdownController;
|
|
5248
|
+
exports.useEventCallback = useEventCallback;
|
|
5218
5249
|
exports.useFieldAutocomplete = useFieldAutocomplete;
|
|
5219
5250
|
exports.useFieldList = useFieldList;
|
|
5220
5251
|
exports.useFieldSelect = useFieldSelect;
|