@rolster/react-components 19.8.15 → 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 +66 -29
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +65 -31
- package/dist/es/index.mjs.map +1 -1
- package/dist/esm/components/atoms/SwapHover/SwapHover.d.ts +8 -0
- package/dist/esm/components/atoms/SwapHover/SwapHover.js +7 -0
- package/dist/esm/components/atoms/SwapHover/SwapHover.js.map +1 -0
- 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 +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +4 -4
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]) => {
|
|
@@ -1257,6 +1265,11 @@ function RlsSkeletonTextComponent({ active, children, rlsTheme }) {
|
|
|
1257
1265
|
}
|
|
1258
1266
|
const RlsSkeletonText = require$$0.memo(RlsSkeletonTextComponent);
|
|
1259
1267
|
|
|
1268
|
+
function RlsSwapHoverComponent({ children, content, identifier, rlsTheme }) {
|
|
1269
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-swap-hover", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-swap-hover__primary", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-swap-hover__secondary", children: content })] }));
|
|
1270
|
+
}
|
|
1271
|
+
const RlsHoverSwap = require$$0.memo(RlsSwapHoverComponent);
|
|
1272
|
+
|
|
1260
1273
|
function RlsSwitchComponent({ checked, capsule, disabled, identifier, onClick, rlsTheme }) {
|
|
1261
1274
|
const className = renderClassStatus('rls-switch', {
|
|
1262
1275
|
checked,
|
|
@@ -1633,6 +1646,19 @@ const reactI18n = i18n.i18n({
|
|
|
1633
1646
|
}
|
|
1634
1647
|
});
|
|
1635
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;
|
|
1636
1662
|
function getScrollableAncestors(element) {
|
|
1637
1663
|
const ancestors = [];
|
|
1638
1664
|
let parent = element.parentElement;
|
|
@@ -1665,14 +1691,22 @@ function anchorIsVisible(rect, scrollables) {
|
|
|
1665
1691
|
rect.right > left &&
|
|
1666
1692
|
rect.left < right);
|
|
1667
1693
|
}
|
|
1668
|
-
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) {
|
|
1669
1703
|
const [mounted, setMounted] = require$$0.useState(false);
|
|
1670
1704
|
const [style, setStyle] = require$$0.useState();
|
|
1671
1705
|
const [theme, setTheme] = require$$0.useState();
|
|
1672
1706
|
require$$0.useEffect(() => {
|
|
1673
1707
|
setMounted(true);
|
|
1674
1708
|
}, []);
|
|
1675
|
-
const onAnchorHidden =
|
|
1709
|
+
const onAnchorHidden = useEventCallback(() => {
|
|
1676
1710
|
onHiddenAnchor?.();
|
|
1677
1711
|
});
|
|
1678
1712
|
require$$0.useEffect(() => {
|
|
@@ -1690,15 +1724,20 @@ function useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor) {
|
|
|
1690
1724
|
}
|
|
1691
1725
|
const rect = anchor.getBoundingClientRect();
|
|
1692
1726
|
if (!anchorIsVisible(rect, scrollables)) {
|
|
1693
|
-
onAnchorHidden();
|
|
1694
|
-
return;
|
|
1727
|
+
return onAnchorHidden();
|
|
1695
1728
|
}
|
|
1696
|
-
|
|
1729
|
+
const style = {
|
|
1697
1730
|
'--pvt-portal-top': `${rect.bottom}px`,
|
|
1698
1731
|
'--pvt-portal-bottom': `${window.innerHeight - rect.top}px`,
|
|
1699
1732
|
'--pvt-portal-left': `${rect.left}px`,
|
|
1700
1733
|
'--pvt-portal-width': `${rect.width}px`
|
|
1701
|
-
}
|
|
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);
|
|
1702
1741
|
}
|
|
1703
1742
|
function requestReposition() {
|
|
1704
1743
|
cancelAnimationFrame(frame);
|
|
@@ -1712,7 +1751,7 @@ function useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor) {
|
|
|
1712
1751
|
window.removeEventListener('scroll', requestReposition, true);
|
|
1713
1752
|
window.removeEventListener('resize', requestReposition);
|
|
1714
1753
|
};
|
|
1715
|
-
}, [mounted, visible, refAnchor]);
|
|
1754
|
+
}, [mounted, visible, refAnchor, higher]);
|
|
1716
1755
|
return { active: mounted && !!refAnchor, style, theme };
|
|
1717
1756
|
}
|
|
1718
1757
|
|
|
@@ -1726,7 +1765,7 @@ function RlsFieldListLi({ element, onClickElement, onKeydownElement, render }) {
|
|
|
1726
1765
|
return (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: onClick, onKeyDown: onKeyDown, children: render(element) }));
|
|
1727
1766
|
}
|
|
1728
1767
|
function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher, render, renderEmpty, searchControl, visible, onClickBackdrop, onClickElement, onHiddenAnchor, onKeydownElement, refAnchor, refList, refSuggestions, rlsTheme }) {
|
|
1729
|
-
const portal = useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor);
|
|
1768
|
+
const portal = useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor, higher);
|
|
1730
1769
|
const [labels, setLabels] = require$$0.useState({
|
|
1731
1770
|
listEmptyDescription: reactI18n('listEmptyDescription'),
|
|
1732
1771
|
listEmptyTitle: reactI18n('listEmptyTitle')
|
|
@@ -2459,14 +2498,7 @@ function RlsCardComponent({ children, className, outline, rlsTheme }) {
|
|
|
2459
2498
|
const RlsCard = require$$0.memo(RlsCardComponent);
|
|
2460
2499
|
|
|
2461
2500
|
const MAX_LIST_HEIGHT_REM$1 = 90;
|
|
2462
|
-
const
|
|
2463
|
-
function getRemSize$1() {
|
|
2464
|
-
if (typeof window === 'undefined') {
|
|
2465
|
-
return FALLBACK_REM_SIZE$1;
|
|
2466
|
-
}
|
|
2467
|
-
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
2468
|
-
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE$1;
|
|
2469
|
-
}
|
|
2501
|
+
const VIEWPORT_GAP_REM = 8;
|
|
2470
2502
|
function suggestionsShallowEqual(a, b) {
|
|
2471
2503
|
return (a === b ||
|
|
2472
2504
|
(a.length === b.length && a.every((element, index) => element === b[index])));
|
|
@@ -2482,10 +2514,12 @@ function shouldDisplayHigher$1(content, list) {
|
|
|
2482
2514
|
if (!content) {
|
|
2483
2515
|
return false;
|
|
2484
2516
|
}
|
|
2517
|
+
const remSize = getRemSize$1();
|
|
2518
|
+
const gap = VIEWPORT_GAP_REM * remSize;
|
|
2485
2519
|
const { top, bottom } = content.getBoundingClientRect();
|
|
2486
|
-
const spaceAbove = top;
|
|
2487
|
-
const spaceBelow = window.innerHeight - bottom;
|
|
2488
|
-
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;
|
|
2489
2523
|
const desiredHeight = Math.min(list?.scrollHeight || maxHeight, maxHeight);
|
|
2490
2524
|
if (spaceBelow >= desiredHeight) {
|
|
2491
2525
|
return false;
|
|
@@ -2554,7 +2588,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2554
2588
|
formControl?.setValue(element?.value);
|
|
2555
2589
|
}
|
|
2556
2590
|
}, [formControl]);
|
|
2557
|
-
const reconcileFormValue =
|
|
2591
|
+
const reconcileFormValue = useEventCallback(() => {
|
|
2558
2592
|
if (!changeValueInternal.current) {
|
|
2559
2593
|
if (formControl?.value) {
|
|
2560
2594
|
const element = collection.find(formControl.value);
|
|
@@ -3498,10 +3532,10 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3498
3532
|
const classNamePM = renderClassStatus('rls-picker-clock__zone__value', {
|
|
3499
3533
|
active: zoneIsPM
|
|
3500
3534
|
});
|
|
3501
|
-
const refreshClockHour =
|
|
3535
|
+
const refreshClockHour = useEventCallback(() => {
|
|
3502
3536
|
refreshClock(hour > 12 ? hour - 12 : hour);
|
|
3503
3537
|
});
|
|
3504
|
-
const refreshClockMinute =
|
|
3538
|
+
const refreshClockMinute = useEventCallback(() => {
|
|
3505
3539
|
refreshClock(minute);
|
|
3506
3540
|
});
|
|
3507
3541
|
require$$0.useEffect(() => {
|
|
@@ -3765,7 +3799,7 @@ function RlsPickerColorComponent({ color, formControl, onListener, rlsTheme }) {
|
|
|
3765
3799
|
y: (clientY - rect.top) / rect.height
|
|
3766
3800
|
};
|
|
3767
3801
|
}, []);
|
|
3768
|
-
const updateColorOnCanvas =
|
|
3802
|
+
const updateColorOnCanvas = useEventCallback((clientX, clientY) => {
|
|
3769
3803
|
if (!canvasRef.current)
|
|
3770
3804
|
return;
|
|
3771
3805
|
const pos = getPositionInElement(canvasRef.current, clientX, clientY);
|
|
@@ -3775,7 +3809,7 @@ function RlsPickerColorComponent({ color, formControl, onListener, rlsTheme }) {
|
|
|
3775
3809
|
v: Math.round(Math.min(1, Math.max(0, 1 - pos.y)) * 100)
|
|
3776
3810
|
}));
|
|
3777
3811
|
});
|
|
3778
|
-
const updateHueOnSlider =
|
|
3812
|
+
const updateHueOnSlider = useEventCallback((clientX, clientY) => {
|
|
3779
3813
|
if (!hueRef.current)
|
|
3780
3814
|
return;
|
|
3781
3815
|
const pos = getPositionInElement(hueRef.current, clientX, clientY);
|
|
@@ -3784,7 +3818,7 @@ function RlsPickerColorComponent({ color, formControl, onListener, rlsTheme }) {
|
|
|
3784
3818
|
h: Math.round(Math.min(1, Math.max(0, pos.x)) * 360)
|
|
3785
3819
|
}));
|
|
3786
3820
|
});
|
|
3787
|
-
const updateAlphaOnSlider =
|
|
3821
|
+
const updateAlphaOnSlider = useEventCallback((clientX, clientY) => {
|
|
3788
3822
|
if (!alphaRef.current)
|
|
3789
3823
|
return;
|
|
3790
3824
|
const pos = getPositionInElement(alphaRef.current, clientX, clientY);
|
|
@@ -3879,7 +3913,7 @@ function RlsPickerColorComponent({ color, formControl, onListener, rlsTheme }) {
|
|
|
3879
3913
|
const onHexFocus = require$$0.useCallback(() => {
|
|
3880
3914
|
hexEditing.current = true;
|
|
3881
3915
|
}, []);
|
|
3882
|
-
const onHexBlur =
|
|
3916
|
+
const onHexBlur = useEventCallback(() => {
|
|
3883
3917
|
hexEditing.current = false;
|
|
3884
3918
|
const normalized = normalizeHex(hexInput);
|
|
3885
3919
|
if (normalized) {
|
|
@@ -4324,7 +4358,7 @@ function useRelocationOnComponent({ container: containerRef, element: elementRef
|
|
|
4324
4358
|
}
|
|
4325
4359
|
return clientY;
|
|
4326
4360
|
}
|
|
4327
|
-
const start =
|
|
4361
|
+
const start = useEventCallback((positionX, positionY) => {
|
|
4328
4362
|
dragOffset.current = {
|
|
4329
4363
|
x: positionX,
|
|
4330
4364
|
y: positionY
|
|
@@ -4335,7 +4369,7 @@ function useRelocationOnComponent({ container: containerRef, element: elementRef
|
|
|
4335
4369
|
};
|
|
4336
4370
|
dragging.current = true;
|
|
4337
4371
|
});
|
|
4338
|
-
const relocation =
|
|
4372
|
+
const relocation = useEventCallback((positionX, positionY) => {
|
|
4339
4373
|
const clientX = getClientX(positionX);
|
|
4340
4374
|
const clientY = getClientY(positionY);
|
|
4341
4375
|
elementRef.current.style.top = `${clientY}px`;
|
|
@@ -4388,7 +4422,7 @@ function useRelocationOnComponent({ container: containerRef, element: elementRef
|
|
|
4388
4422
|
|
|
4389
4423
|
function useResize({ refElement, onResize }) {
|
|
4390
4424
|
const dimension = require$$0.useRef({ height: 0, width: 0 });
|
|
4391
|
-
const observer =
|
|
4425
|
+
const observer = useEventCallback((entries) => {
|
|
4392
4426
|
const { height, width } = entries[0].contentRect;
|
|
4393
4427
|
onResize?.({
|
|
4394
4428
|
current: dimension.current,
|
|
@@ -5132,6 +5166,7 @@ exports.RlsFieldSelect = RlsFieldSelect;
|
|
|
5132
5166
|
exports.RlsFieldSelectTemplate = RlsFieldSelectTemplate;
|
|
5133
5167
|
exports.RlsFieldText = RlsFieldText;
|
|
5134
5168
|
exports.RlsFormNavigation = RlsFormNavigation;
|
|
5169
|
+
exports.RlsHoverSwap = RlsHoverSwap;
|
|
5135
5170
|
exports.RlsIcon = RlsIcon;
|
|
5136
5171
|
exports.RlsImage = RlsImage;
|
|
5137
5172
|
exports.RlsImageChooser = RlsImageChooser;
|
|
@@ -5187,6 +5222,7 @@ exports.RlsToolbar = RlsToolbar;
|
|
|
5187
5222
|
exports.calculateImgDimension = calculateImgDimension;
|
|
5188
5223
|
exports.generateThemePalette = generateThemePalette;
|
|
5189
5224
|
exports.getAppTheme = getAppTheme;
|
|
5225
|
+
exports.getRemSize = getRemSize$1;
|
|
5190
5226
|
exports.hexIsValid = hexIsValid;
|
|
5191
5227
|
exports.hexToHsl = hexToHsl;
|
|
5192
5228
|
exports.hexToHsv = hexToHsv;
|
|
@@ -5209,6 +5245,7 @@ exports.useConfirmation = useConfirmation;
|
|
|
5209
5245
|
exports.useDatatable = useDatatable;
|
|
5210
5246
|
exports.useDesingSystemController = useDesingSystemController;
|
|
5211
5247
|
exports.useDropdownController = useDropdownController;
|
|
5248
|
+
exports.useEventCallback = useEventCallback;
|
|
5212
5249
|
exports.useFieldAutocomplete = useFieldAutocomplete;
|
|
5213
5250
|
exports.useFieldList = useFieldList;
|
|
5214
5251
|
exports.useFieldSelect = useFieldSelect;
|