@rolster/react-components 19.7.13 → 19.8.15
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/LICENSE +21 -21
- package/dist/cjs/index.cjs +789 -546
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +786 -548
- package/dist/es/index.mjs.map +1 -1
- package/dist/esm/components/atoms/Label/Label.js.map +1 -1
- package/dist/esm/components/molecules/Content/Content.js.map +1 -1
- package/dist/esm/components/molecules/FieldListSuggestions/FieldListSuggestions.d.ts +4 -1
- package/dist/esm/components/molecules/FieldListSuggestions/FieldListSuggestions.js +7 -2
- package/dist/esm/components/molecules/FieldListSuggestions/FieldListSuggestions.js.map +1 -1
- package/dist/esm/components/molecules/FieldListSuggestions/SuggestionsPortalController.d.ts +8 -0
- package/dist/esm/components/molecules/FieldListSuggestions/SuggestionsPortalController.js +84 -0
- package/dist/esm/components/molecules/FieldListSuggestions/SuggestionsPortalController.js.map +1 -0
- package/dist/esm/components/organisms/ChooserAutocomplete/ChooserAutocomplete.d.ts +36 -0
- package/dist/esm/components/organisms/ChooserAutocomplete/ChooserAutocomplete.js +87 -0
- package/dist/esm/components/organisms/ChooserAutocomplete/ChooserAutocomplete.js.map +1 -0
- package/dist/esm/components/organisms/ChooserList/ChooserList.d.ts +27 -0
- package/dist/esm/components/organisms/ChooserList/ChooserList.js +44 -0
- package/dist/esm/components/organisms/ChooserList/ChooserList.js.map +1 -0
- package/dist/esm/components/organisms/ChooserSelect/ChooserSelect.d.ts +31 -0
- package/dist/esm/components/organisms/ChooserSelect/ChooserSelect.js +38 -0
- package/dist/esm/components/organisms/ChooserSelect/ChooserSelect.js.map +1 -0
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
- package/dist/esm/components/organisms/FieldList/FieldList.js +1 -1
- package/dist/esm/components/organisms/FieldList/FieldList.js.map +1 -1
- package/dist/esm/components/organisms/FieldList/FieldListController.d.ts +1 -0
- package/dist/esm/components/organisms/FieldList/FieldListController.js +4 -1
- package/dist/esm/components/organisms/FieldList/FieldListController.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js.map +1 -1
- package/dist/esm/controllers/DropdownController.js.map +1 -1
- package/dist/esm/controllers/ListController.d.ts +1 -0
- package/dist/esm/controllers/ListController.js +31 -25
- package/dist/esm/controllers/ListController.js.map +1 -1
- package/dist/esm/controllers/RelocationOnComponentController.d.ts +4 -4
- package/dist/esm/controllers/RelocationOnComponentController.js +34 -32
- package/dist/esm/controllers/RelocationOnComponentController.js.map +1 -1
- package/dist/esm/controllers/ResizeController.js +5 -7
- package/dist/esm/controllers/ResizeController.js.map +1 -1
- package/dist/esm/definitions.d.ts +1 -0
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/esm/components/atoms/SwapHover/SwapHover.d.ts +0 -8
- package/dist/esm/components/atoms/SwapHover/SwapHover.js +0 -7
- package/dist/esm/components/atoms/SwapHover/SwapHover.js.map +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
var require$$0 = require('react');
|
|
4
4
|
var commons = require('@rolster/commons');
|
|
5
5
|
var i18n = require('@rolster/i18n');
|
|
6
|
+
var ReactDOM = require('react-dom');
|
|
6
7
|
var components = require('@rolster/components');
|
|
7
8
|
var dates = require('@rolster/dates');
|
|
8
|
-
var ReactDOM = require('react-dom');
|
|
9
9
|
var reactForms = require('@rolster/react-forms');
|
|
10
10
|
|
|
11
11
|
var jsxRuntime = {exports: {}};
|
|
@@ -1257,11 +1257,6 @@ function RlsSkeletonTextComponent({ active, children, rlsTheme }) {
|
|
|
1257
1257
|
}
|
|
1258
1258
|
const RlsSkeletonText = require$$0.memo(RlsSkeletonTextComponent);
|
|
1259
1259
|
|
|
1260
|
-
function RlsSwapHoverComponent({ children, content, identifier, rlsTheme }) {
|
|
1261
|
-
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 })] }));
|
|
1262
|
-
}
|
|
1263
|
-
const RlsHoverSwap = require$$0.memo(RlsSwapHoverComponent);
|
|
1264
|
-
|
|
1265
1260
|
function RlsSwitchComponent({ checked, capsule, disabled, identifier, onClick, rlsTheme }) {
|
|
1266
1261
|
const className = renderClassStatus('rls-switch', {
|
|
1267
1262
|
checked,
|
|
@@ -1638,6 +1633,89 @@ const reactI18n = i18n.i18n({
|
|
|
1638
1633
|
}
|
|
1639
1634
|
});
|
|
1640
1635
|
|
|
1636
|
+
function getScrollableAncestors(element) {
|
|
1637
|
+
const ancestors = [];
|
|
1638
|
+
let parent = element.parentElement;
|
|
1639
|
+
while (parent && parent !== document.body) {
|
|
1640
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(parent);
|
|
1641
|
+
if (/auto|scroll|hidden/.test(`${overflow}${overflowX}${overflowY}`)) {
|
|
1642
|
+
ancestors.push(parent);
|
|
1643
|
+
}
|
|
1644
|
+
parent = parent.parentElement;
|
|
1645
|
+
}
|
|
1646
|
+
return ancestors;
|
|
1647
|
+
}
|
|
1648
|
+
function anchorIsVisible(rect, scrollables) {
|
|
1649
|
+
if (!rect.width || !rect.height) {
|
|
1650
|
+
return false;
|
|
1651
|
+
}
|
|
1652
|
+
let top = 0;
|
|
1653
|
+
let left = 0;
|
|
1654
|
+
let bottom = window.innerHeight;
|
|
1655
|
+
let right = window.innerWidth;
|
|
1656
|
+
for (const scrollable of scrollables) {
|
|
1657
|
+
const scrollableRect = scrollable.getBoundingClientRect();
|
|
1658
|
+
top = Math.max(top, scrollableRect.top);
|
|
1659
|
+
left = Math.max(left, scrollableRect.left);
|
|
1660
|
+
bottom = Math.min(bottom, scrollableRect.bottom);
|
|
1661
|
+
right = Math.min(right, scrollableRect.right);
|
|
1662
|
+
}
|
|
1663
|
+
return (rect.bottom > top &&
|
|
1664
|
+
rect.top < bottom &&
|
|
1665
|
+
rect.right > left &&
|
|
1666
|
+
rect.left < right);
|
|
1667
|
+
}
|
|
1668
|
+
function useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor) {
|
|
1669
|
+
const [mounted, setMounted] = require$$0.useState(false);
|
|
1670
|
+
const [style, setStyle] = require$$0.useState();
|
|
1671
|
+
const [theme, setTheme] = require$$0.useState();
|
|
1672
|
+
require$$0.useEffect(() => {
|
|
1673
|
+
setMounted(true);
|
|
1674
|
+
}, []);
|
|
1675
|
+
const onAnchorHidden = require$$0.useEffectEvent(() => {
|
|
1676
|
+
onHiddenAnchor?.();
|
|
1677
|
+
});
|
|
1678
|
+
require$$0.useEffect(() => {
|
|
1679
|
+
const anchor = refAnchor?.current;
|
|
1680
|
+
if (!mounted || !visible || !anchor) {
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
setTheme((anchor.closest('[rls-theme]')?.getAttribute('rls-theme') ??
|
|
1684
|
+
undefined));
|
|
1685
|
+
const scrollables = getScrollableAncestors(anchor);
|
|
1686
|
+
let frame = 0;
|
|
1687
|
+
function reposition() {
|
|
1688
|
+
if (!anchor) {
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
const rect = anchor.getBoundingClientRect();
|
|
1692
|
+
if (!anchorIsVisible(rect, scrollables)) {
|
|
1693
|
+
onAnchorHidden();
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
setStyle({
|
|
1697
|
+
'--pvt-portal-top': `${rect.bottom}px`,
|
|
1698
|
+
'--pvt-portal-bottom': `${window.innerHeight - rect.top}px`,
|
|
1699
|
+
'--pvt-portal-left': `${rect.left}px`,
|
|
1700
|
+
'--pvt-portal-width': `${rect.width}px`
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
function requestReposition() {
|
|
1704
|
+
cancelAnimationFrame(frame);
|
|
1705
|
+
frame = requestAnimationFrame(reposition);
|
|
1706
|
+
}
|
|
1707
|
+
reposition();
|
|
1708
|
+
window.addEventListener('scroll', requestReposition, true);
|
|
1709
|
+
window.addEventListener('resize', requestReposition);
|
|
1710
|
+
return () => {
|
|
1711
|
+
cancelAnimationFrame(frame);
|
|
1712
|
+
window.removeEventListener('scroll', requestReposition, true);
|
|
1713
|
+
window.removeEventListener('resize', requestReposition);
|
|
1714
|
+
};
|
|
1715
|
+
}, [mounted, visible, refAnchor]);
|
|
1716
|
+
return { active: mounted && !!refAnchor, style, theme };
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1641
1719
|
function RlsFieldListLi({ element, onClickElement, onKeydownElement, render }) {
|
|
1642
1720
|
const onClick = require$$0.useMemo(() => {
|
|
1643
1721
|
return onClickElement(element);
|
|
@@ -1647,7 +1725,8 @@ function RlsFieldListLi({ element, onClickElement, onKeydownElement, render }) {
|
|
|
1647
1725
|
}, [element, onKeydownElement]);
|
|
1648
1726
|
return (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: onClick, onKeyDown: onKeyDown, children: render(element) }));
|
|
1649
1727
|
}
|
|
1650
|
-
function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher, render, renderEmpty, searchControl, visible, onClickBackdrop, onClickElement, onKeydownElement, refList, rlsTheme }) {
|
|
1728
|
+
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);
|
|
1651
1730
|
const [labels, setLabels] = require$$0.useState({
|
|
1652
1731
|
listEmptyDescription: reactI18n('listEmptyDescription'),
|
|
1653
1732
|
listEmptyTitle: reactI18n('listEmptyTitle')
|
|
@@ -1663,6 +1742,7 @@ function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher,
|
|
|
1663
1742
|
const className = renderClassStatus('rls-field-list__suggestions', {
|
|
1664
1743
|
disabled,
|
|
1665
1744
|
higher,
|
|
1745
|
+
portal: portal.active,
|
|
1666
1746
|
visible
|
|
1667
1747
|
});
|
|
1668
1748
|
const onChangePattern = require$$0.useCallback((event) => {
|
|
@@ -1675,7 +1755,8 @@ function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher,
|
|
|
1675
1755
|
}
|
|
1676
1756
|
}, [action?.onClick, action?.keepOpen, onClickBackdrop]);
|
|
1677
1757
|
const searching = searchControl?.searching ?? false;
|
|
1678
|
-
|
|
1758
|
+
const suggestions = (jsxRuntimeExports.jsxs("div", { ref: refSuggestions, className: className, style: portal.active ? portal.style : undefined, "rls-theme": rlsTheme ?? portal.theme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__suggestions__body", children: [jsxRuntimeExports.jsxs("ul", { ref: refList, className: "rls-field-list__ul", children: [searchControl && (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-list__ul__control", ref: searchControl.refInput, type: "text", placeholder: searchControl.placeholder, value: searchControl.pattern, onChange: onChangePattern, onFocus: searchControl.onFocus, onBlur: searchControl.onBlur, onKeyDown: searchControl.onKeyDown, disabled: disabled || searching }), searchControl.onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: searchControl.onSearch, children: jsxRuntimeExports.jsx(RlsIcon, { value: "search" }) }))] })), searching && jsxRuntimeExports.jsx(RlsProgressBar, { indeterminate: true }), elements.map((element, index) => (jsxRuntimeExports.jsx(RlsFieldListLi, { element: element, onClickElement: onClickElement, onKeydownElement: onKeydownElement, render: render }, index))), !elements.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: renderEmpty ? (renderEmpty()) : (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("span", { className: "rls-label-font-bold rls-truncate", children: labels.listEmptyTitle }), jsxRuntimeExports.jsx("p", { className: "rls-caption-font-regular", children: labels.listEmptyDescription })] })) }))] }), action && (jsxRuntimeExports.jsx("div", { className: "rls-field-list__action", children: jsxRuntimeExports.jsxs("button", { type: "button", disabled: disabled || action.disabled, onClick: onClickAction, children: [action.icon && jsxRuntimeExports.jsx(RlsIcon, { value: action.icon }), jsxRuntimeExports.jsx("span", { className: "rls-field-list__action__description", children: action.description })] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: onClickBackdrop })] }));
|
|
1759
|
+
return portal.active ? ReactDOM.createPortal(suggestions, document.body) : suggestions;
|
|
1679
1760
|
}
|
|
1680
1761
|
const RlsFieldListSuggestions = require$$0.memo(RlsFieldListSuggestionsComponent);
|
|
1681
1762
|
|
|
@@ -2377,161 +2458,6 @@ function RlsCardComponent({ children, className, outline, rlsTheme }) {
|
|
|
2377
2458
|
}
|
|
2378
2459
|
const RlsCard = require$$0.memo(RlsCardComponent);
|
|
2379
2460
|
|
|
2380
|
-
class ConfirmationResult extends commons.SealedPartial {
|
|
2381
|
-
static approved() {
|
|
2382
|
-
return new ConfirmationResult('approved');
|
|
2383
|
-
}
|
|
2384
|
-
static reject() {
|
|
2385
|
-
return new ConfirmationResult('reject');
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
function RlsConfirmationComponent({ approved, className, content, reject, rlsTheme, subtitle, title, visible }) {
|
|
2389
|
-
const classConfirmation = renderClassStatus('rls-confirmation', { visible }, className);
|
|
2390
|
-
return (jsxRuntimeExports.jsxs("div", { className: classConfirmation, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__header", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__content", children: content })) }), (approved || reject) && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsxRuntimeExports.jsx(RlsButton, { identifier: approved.identifier, type: approved.type, onClick: approved.onClick, disabled: approved.disabled, rlsTheme: approved.rlsTheme, children: approved.label })), reject && (jsxRuntimeExports.jsx(RlsButton, { identifier: reject.identifier, type: reject.type, onClick: reject.onClick, disabled: reject.disabled, rlsTheme: reject.rlsTheme, children: reject.label }))] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
2391
|
-
}
|
|
2392
|
-
const RlsConfirmation = require$$0.memo(RlsConfirmationComponent);
|
|
2393
|
-
const RlsConfirmationBase = RlsConfirmation;
|
|
2394
|
-
function useConfirmation() {
|
|
2395
|
-
const [config, setConfig] = require$$0.useState({});
|
|
2396
|
-
const [visible, setVisible] = require$$0.useState(false);
|
|
2397
|
-
const configRef = require$$0.useRef(config);
|
|
2398
|
-
configRef.current = config;
|
|
2399
|
-
const visibleRef = require$$0.useRef(visible);
|
|
2400
|
-
visibleRef.current = visible;
|
|
2401
|
-
const RlsConfirmation = require$$0.useMemo(() => {
|
|
2402
|
-
return function RlsConfirmation(props) {
|
|
2403
|
-
return ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmationBase, { ...props, ...configRef.current, visible: visibleRef.current }), document.body);
|
|
2404
|
-
};
|
|
2405
|
-
}, []);
|
|
2406
|
-
const confirmation = require$$0.useCallback((options) => {
|
|
2407
|
-
return new Promise((resolve) => {
|
|
2408
|
-
setConfig({
|
|
2409
|
-
...options,
|
|
2410
|
-
approved: {
|
|
2411
|
-
label: options.approved?.label ?? reactI18n('confirmationActionApproved'),
|
|
2412
|
-
onClick: () => {
|
|
2413
|
-
setVisible(false);
|
|
2414
|
-
resolve(ConfirmationResult.approved());
|
|
2415
|
-
},
|
|
2416
|
-
type: options.approved?.type ?? 'raised',
|
|
2417
|
-
disabled: options.approved?.disabled,
|
|
2418
|
-
identifier: options.approved?.identifier,
|
|
2419
|
-
rlsTheme: options.approved?.rlsTheme
|
|
2420
|
-
},
|
|
2421
|
-
reject: options.reject
|
|
2422
|
-
? {
|
|
2423
|
-
label: options.reject.label,
|
|
2424
|
-
onClick: () => {
|
|
2425
|
-
setVisible(false);
|
|
2426
|
-
resolve(ConfirmationResult.reject());
|
|
2427
|
-
},
|
|
2428
|
-
type: options.reject.type ?? 'flat',
|
|
2429
|
-
disabled: options.reject.disabled,
|
|
2430
|
-
identifier: options.reject.identifier,
|
|
2431
|
-
rlsTheme: options.reject.rlsTheme
|
|
2432
|
-
}
|
|
2433
|
-
: undefined
|
|
2434
|
-
});
|
|
2435
|
-
setVisible(true);
|
|
2436
|
-
});
|
|
2437
|
-
}, []);
|
|
2438
|
-
return {
|
|
2439
|
-
confirmation,
|
|
2440
|
-
RlsConfirmation
|
|
2441
|
-
};
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
|
-
function createObserver(options) {
|
|
2445
|
-
const { setScrolleable, table } = options;
|
|
2446
|
-
const observer = new ResizeObserver(() => {
|
|
2447
|
-
const scrollHeight = table.scrollHeight || 0;
|
|
2448
|
-
const clientHeight = table.clientHeight || 0;
|
|
2449
|
-
setScrolleable(scrollHeight > clientHeight);
|
|
2450
|
-
});
|
|
2451
|
-
observer.observe(table);
|
|
2452
|
-
return observer;
|
|
2453
|
-
}
|
|
2454
|
-
function useDatatable(table) {
|
|
2455
|
-
const [scrolleable, setScrolleable] = require$$0.useState(false);
|
|
2456
|
-
const refTable = require$$0.useRef(table ? table : null);
|
|
2457
|
-
require$$0.useEffect(() => {
|
|
2458
|
-
const observer = refTable.current &&
|
|
2459
|
-
createObserver({ setScrolleable, table: refTable.current });
|
|
2460
|
-
return () => {
|
|
2461
|
-
observer?.disconnect();
|
|
2462
|
-
};
|
|
2463
|
-
}, []);
|
|
2464
|
-
return { refTable, scrolleable };
|
|
2465
|
-
}
|
|
2466
|
-
|
|
2467
|
-
function RlsDatatableComponent({ children, footer, header, identifier, rlsTheme, resizable, summary, table, toolbar }) {
|
|
2468
|
-
const datatable = useDatatable(table);
|
|
2469
|
-
const className = renderClassStatus('rls-datatable', {
|
|
2470
|
-
resizable,
|
|
2471
|
-
scrolleable: resizable && datatable?.scrolleable
|
|
2472
|
-
});
|
|
2473
|
-
return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [toolbar && jsxRuntimeExports.jsx("div", { className: "rls-datatable__toolbar", children: toolbar }), jsxRuntimeExports.jsx("div", { className: "rls-datatable__table", children: jsxRuntimeExports.jsxs("table", { id: identifier, children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__head", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.refTable, className: "rls-datatable__body", children: children })] }) }), summary && jsxRuntimeExports.jsx("div", { className: "rls-datatable__summary", children: summary }), footer && jsxRuntimeExports.jsx("div", { className: "rls-datatable__footer", children: footer })] }));
|
|
2474
|
-
}
|
|
2475
|
-
const RlsDatatable = require$$0.memo(RlsDatatableComponent);
|
|
2476
|
-
function RlsDatatableHeaderComponent({ children, identifier, rlsTheme }) {
|
|
2477
|
-
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: "rls-datatable__header", "rls-theme": rlsTheme, children: children }));
|
|
2478
|
-
}
|
|
2479
|
-
const RlsDatatableHeader = require$$0.memo(RlsDatatableHeaderComponent);
|
|
2480
|
-
function RlsDatatableTitleComponent({ actions, children, className, control, identifier, rlsTheme, truncated }) {
|
|
2481
|
-
const classNameTitle = renderClassStatus('rls-datatable__title', { actions, control, truncated }, className);
|
|
2482
|
-
return (jsxRuntimeExports.jsx("th", { id: identifier, className: classNameTitle, "rls-theme": rlsTheme, children: children }));
|
|
2483
|
-
}
|
|
2484
|
-
const RlsDatatableTitle = require$$0.memo(RlsDatatableTitleComponent);
|
|
2485
|
-
function RlsDatatableSubheaderComponent({ children, className, identifier, rlsTheme }) {
|
|
2486
|
-
const classNameSubheader = renderClassStatus('rls-datatable__subheader', {}, className);
|
|
2487
|
-
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classNameSubheader, "rls-theme": rlsTheme, children: children }));
|
|
2488
|
-
}
|
|
2489
|
-
const RlsDatatableSubheader = require$$0.memo(RlsDatatableSubheaderComponent);
|
|
2490
|
-
function RlsDatatableRecordComponent({ children, className, error, identifier, info, rlsTheme, success, truncated, warning }) {
|
|
2491
|
-
const classNameRecord = renderClassStatus('rls-datatable__record', { error, info, truncated, success, warning }, className);
|
|
2492
|
-
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classNameRecord, "rls-theme": rlsTheme, children: children }));
|
|
2493
|
-
}
|
|
2494
|
-
const RlsDatatableRecord = require$$0.memo(RlsDatatableRecordComponent);
|
|
2495
|
-
function RlsDatatableTotalsComponent({ children, className, error, identifier, info, rlsTheme, success, truncated, warning }) {
|
|
2496
|
-
const classNameTotals = renderClassStatus('rls-datatable__totals', { error, info, truncated, success, warning }, className);
|
|
2497
|
-
return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameTotals, "rls-theme": rlsTheme, children: children }));
|
|
2498
|
-
}
|
|
2499
|
-
const RlsDatatableTotals = require$$0.memo(RlsDatatableTotalsComponent);
|
|
2500
|
-
function RlsDatatableCellComponent({ actions, children, className, control, identifier, rlsTheme, truncated }) {
|
|
2501
|
-
const classNameCell = renderClassStatus('rls-datatable__cell', { actions, control, truncated }, className);
|
|
2502
|
-
return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameCell, "rls-theme": rlsTheme, children: children }));
|
|
2503
|
-
}
|
|
2504
|
-
const RlsDatatableCell = require$$0.memo(RlsDatatableCellComponent);
|
|
2505
|
-
function RlsDatatableDataComponent({ actions, children, className, control, identifier, truncated }) {
|
|
2506
|
-
const classNameData = renderClassStatus('rls-datatable__data', { actions, control, truncated }, className);
|
|
2507
|
-
return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameData, children: children }));
|
|
2508
|
-
}
|
|
2509
|
-
const RlsDatatableData = require$$0.memo(RlsDatatableDataComponent);
|
|
2510
|
-
function RlsDatatableFloatingComponent({ children, className, identifier, invested, rlsTheme }) {
|
|
2511
|
-
const classNameFloating = renderClassStatus('rls-datatable__floating', { invested }, className);
|
|
2512
|
-
return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameFloating, "rls-theme": rlsTheme, children: children }));
|
|
2513
|
-
}
|
|
2514
|
-
const RlsDatatableFloating = require$$0.memo(RlsDatatableFloatingComponent);
|
|
2515
|
-
|
|
2516
|
-
function RlsDropdownComponent({ children, controller, rlsTheme }) {
|
|
2517
|
-
const className = renderClassStatus('rls-dropdown', {
|
|
2518
|
-
visible: controller.visible
|
|
2519
|
-
});
|
|
2520
|
-
require$$0.useEffect(() => {
|
|
2521
|
-
function onCloseDropdown({ target }) {
|
|
2522
|
-
if (!controller.component.current.contains(target)) {
|
|
2523
|
-
controller.close();
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
document.addEventListener('click', onCloseDropdown);
|
|
2527
|
-
return () => {
|
|
2528
|
-
document.removeEventListener('click', onCloseDropdown);
|
|
2529
|
-
};
|
|
2530
|
-
}, []);
|
|
2531
|
-
return (jsxRuntimeExports.jsx("div", { ref: controller.component, className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-dropdown__content", children: children }) }));
|
|
2532
|
-
}
|
|
2533
|
-
const RlsDropdown = require$$0.memo(RlsDropdownComponent);
|
|
2534
|
-
|
|
2535
2461
|
const MAX_LIST_HEIGHT_REM$1 = 90;
|
|
2536
2462
|
const FALLBACK_REM_SIZE$1 = 16;
|
|
2537
2463
|
function getRemSize$1() {
|
|
@@ -2573,6 +2499,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2573
2499
|
const refContent = require$$0.useRef(null);
|
|
2574
2500
|
const refList = require$$0.useRef(null);
|
|
2575
2501
|
const refInput = require$$0.useRef(null);
|
|
2502
|
+
const refSuggestions = require$$0.useRef(null);
|
|
2576
2503
|
const listIsOpen = require$$0.useRef(false);
|
|
2577
2504
|
const stableSuggestions = useStableSuggestions(suggestions);
|
|
2578
2505
|
const collection = require$$0.useMemo(() => new components.ListCollection(stableSuggestions, reference), [stableSuggestions, reference]);
|
|
@@ -2587,7 +2514,8 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2587
2514
|
const valueProtected = require$$0.useRef(undefined);
|
|
2588
2515
|
require$$0.useEffect(() => {
|
|
2589
2516
|
function onCloseSuggestions({ target }) {
|
|
2590
|
-
if (!refContent?.current?.contains(target)
|
|
2517
|
+
if (!refContent?.current?.contains(target) &&
|
|
2518
|
+
!refSuggestions?.current?.contains(target)) {
|
|
2591
2519
|
refreshState((state) => ({ ...state, listIsVisible: false }));
|
|
2592
2520
|
}
|
|
2593
2521
|
}
|
|
@@ -2604,7 +2532,29 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2604
2532
|
formControl?.touch();
|
|
2605
2533
|
}
|
|
2606
2534
|
}, [state.listIsVisible]);
|
|
2607
|
-
require$$0.
|
|
2535
|
+
const setState = require$$0.useCallback((state) => {
|
|
2536
|
+
const newState = state.listIsVisible
|
|
2537
|
+
? {
|
|
2538
|
+
...state,
|
|
2539
|
+
higher: shouldDisplayHigher$1(refContent.current, refList.current)
|
|
2540
|
+
}
|
|
2541
|
+
: state;
|
|
2542
|
+
refreshState((currentState) => ({ ...currentState, ...newState }));
|
|
2543
|
+
}, []);
|
|
2544
|
+
const setFormValue = require$$0.useCallback((element, valueIsDefault = false) => {
|
|
2545
|
+
refreshState((state) => ({
|
|
2546
|
+
...state,
|
|
2547
|
+
value: element?.description || ''
|
|
2548
|
+
}));
|
|
2549
|
+
changeValueInternal.current = true;
|
|
2550
|
+
if (valueIsDefault) {
|
|
2551
|
+
formControl?.setDefaultValue(element?.value);
|
|
2552
|
+
}
|
|
2553
|
+
else {
|
|
2554
|
+
formControl?.setValue(element?.value);
|
|
2555
|
+
}
|
|
2556
|
+
}, [formControl]);
|
|
2557
|
+
const reconcileFormValue = require$$0.useEffectEvent(() => {
|
|
2608
2558
|
if (!changeValueInternal.current) {
|
|
2609
2559
|
if (formControl?.value) {
|
|
2610
2560
|
const element = collection.find(formControl.value);
|
|
@@ -2640,29 +2590,10 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2640
2590
|
}
|
|
2641
2591
|
}
|
|
2642
2592
|
changeValueInternal.current = false;
|
|
2593
|
+
});
|
|
2594
|
+
require$$0.useEffect(() => {
|
|
2595
|
+
reconcileFormValue();
|
|
2643
2596
|
}, [collection, formControl?.value]);
|
|
2644
|
-
const setState = require$$0.useCallback((state) => {
|
|
2645
|
-
const newState = state.listIsVisible
|
|
2646
|
-
? {
|
|
2647
|
-
...state,
|
|
2648
|
-
higher: shouldDisplayHigher$1(refContent.current, refList.current)
|
|
2649
|
-
}
|
|
2650
|
-
: state;
|
|
2651
|
-
refreshState((currentState) => ({ ...currentState, ...newState }));
|
|
2652
|
-
}, []);
|
|
2653
|
-
const setFormValue = require$$0.useCallback((element, valueIsDefault = false) => {
|
|
2654
|
-
refreshState((state) => ({
|
|
2655
|
-
...state,
|
|
2656
|
-
value: element?.description || ''
|
|
2657
|
-
}));
|
|
2658
|
-
changeValueInternal.current = true;
|
|
2659
|
-
if (valueIsDefault) {
|
|
2660
|
-
formControl?.setDefaultValue(element?.value);
|
|
2661
|
-
}
|
|
2662
|
-
else {
|
|
2663
|
-
formControl?.setValue(element?.value);
|
|
2664
|
-
}
|
|
2665
|
-
}, [formControl]);
|
|
2666
2597
|
const navigationInput = require$$0.useCallback((event) => {
|
|
2667
2598
|
if (state.listIsVisible) {
|
|
2668
2599
|
const newPosition = components.navigationListFromInput({
|
|
@@ -2691,6 +2622,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2691
2622
|
refContent,
|
|
2692
2623
|
refInput,
|
|
2693
2624
|
refList,
|
|
2625
|
+
refSuggestions,
|
|
2694
2626
|
setFormValue,
|
|
2695
2627
|
setState
|
|
2696
2628
|
}), [state, navigationElement, navigationInput, setFormValue, setState]);
|
|
@@ -2852,9 +2784,9 @@ function useFieldAutocomplete(props) {
|
|
|
2852
2784
|
]);
|
|
2853
2785
|
}
|
|
2854
2786
|
|
|
2855
|
-
function
|
|
2787
|
+
function RlsChooserAutocompleteTemplateComponent(props) {
|
|
2856
2788
|
const autocomplete = useFieldAutocomplete(props);
|
|
2857
|
-
const { render, action, children, formControl,
|
|
2789
|
+
const { render, action, children, formControl, onSearch, rlsTheme, searching } = props;
|
|
2858
2790
|
const [listInputPlaceholder, setListInputPlaceholder] = require$$0.useState(reactI18n('listInputPlaceholder'));
|
|
2859
2791
|
require$$0.useEffect(() => {
|
|
2860
2792
|
return i18n.i18nSubscribe(() => {
|
|
@@ -2867,13 +2799,11 @@ function RlsFieldAutocompleteTemplateComponent(props) {
|
|
|
2867
2799
|
const disabled = require$$0.useMemo(() => {
|
|
2868
2800
|
return formControl?.disabled || props.disabled;
|
|
2869
2801
|
}, [formControl?.disabled, props.disabled]);
|
|
2870
|
-
const className = renderClassStatus('rls-
|
|
2802
|
+
const className = renderClassStatus('rls-chooser', {
|
|
2871
2803
|
focused: autocomplete.focused && !disabled,
|
|
2872
|
-
|
|
2873
|
-
disabled
|
|
2874
|
-
|
|
2875
|
-
selected: !!autocomplete.value
|
|
2876
|
-
}, `rls-field-list rls-field-autocomplete ${props.className ?? ''}`);
|
|
2804
|
+
visible: autocomplete.listIsVisible,
|
|
2805
|
+
disabled
|
|
2806
|
+
}, `rls-chooser-autocomplete ${props.className ?? ''}`);
|
|
2877
2807
|
const onClickPattern = require$$0.useCallback(() => {
|
|
2878
2808
|
onSearch?.(autocomplete.pattern);
|
|
2879
2809
|
}, [onSearch, autocomplete.pattern]);
|
|
@@ -2883,6 +2813,18 @@ function RlsFieldAutocompleteTemplateComponent(props) {
|
|
|
2883
2813
|
}
|
|
2884
2814
|
autocomplete.onKeydownInput(event);
|
|
2885
2815
|
}, [autocomplete.onKeydownInput, onSearch, autocomplete.pattern]);
|
|
2816
|
+
const onKeydownTrigger = require$$0.useCallback((event) => {
|
|
2817
|
+
switch (event.code) {
|
|
2818
|
+
case 'Space':
|
|
2819
|
+
case 'Enter':
|
|
2820
|
+
event.preventDefault();
|
|
2821
|
+
autocomplete.onClickControl();
|
|
2822
|
+
break;
|
|
2823
|
+
case 'Escape':
|
|
2824
|
+
autocomplete.onClickBackdrop();
|
|
2825
|
+
break;
|
|
2826
|
+
}
|
|
2827
|
+
}, [autocomplete.onClickControl, autocomplete.onClickBackdrop]);
|
|
2886
2828
|
const searchControl = require$$0.useMemo(() => ({
|
|
2887
2829
|
pattern: autocomplete.pattern,
|
|
2888
2830
|
placeholder: listInputPlaceholder,
|
|
@@ -2905,22 +2847,580 @@ function RlsFieldAutocompleteTemplateComponent(props) {
|
|
|
2905
2847
|
onClickPattern,
|
|
2906
2848
|
onSearch
|
|
2907
2849
|
]);
|
|
2908
|
-
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.refContent, className: className, "rls-theme": rlsTheme, children: [
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2850
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.refContent, className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-chooser__trigger", role: "combobox", "aria-expanded": autocomplete.listIsVisible, "aria-haspopup": "listbox", "aria-disabled": disabled || undefined, tabIndex: disabled ? -1 : 0, onClick: disabled ? undefined : autocomplete.onClickControl, onKeyDown: disabled ? undefined : onKeydownTrigger, children: typeof children === 'function'
|
|
2851
|
+
? children({
|
|
2852
|
+
description: autocomplete.value,
|
|
2853
|
+
listIsVisible: autocomplete.listIsVisible,
|
|
2854
|
+
pattern: autocomplete.pattern,
|
|
2855
|
+
value: formControl?.value ?? props.value
|
|
2856
|
+
})
|
|
2857
|
+
: children }), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: autocomplete.coincidences, visible: autocomplete.listIsVisible, action: action, disabled: disabled, higher: autocomplete.higher, render: render, refAnchor: autocomplete.refContent, refList: autocomplete.refList, refSuggestions: autocomplete.refSuggestions, searchControl: searchControl, onClickElement: autocomplete.onClickElement, onKeydownElement: autocomplete.onKeydownElement, onClickBackdrop: autocomplete.onClickBackdrop, onHiddenAnchor: autocomplete.onClickBackdrop })] }));
|
|
2858
|
+
}
|
|
2859
|
+
const RlsChooserAutocompleteTemplate = require$$0.memo(RlsChooserAutocompleteTemplateComponent);
|
|
2860
|
+
function RlsChooserAutocompleteComponent(props) {
|
|
2912
2861
|
const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
|
|
2913
|
-
return jsxRuntimeExports.jsx(
|
|
2862
|
+
return jsxRuntimeExports.jsx(RlsChooserAutocompleteTemplate, { ...props, render: render });
|
|
2914
2863
|
}
|
|
2915
|
-
const
|
|
2864
|
+
const RlsChooserAutocomplete = require$$0.memo(RlsChooserAutocompleteComponent);
|
|
2916
2865
|
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2866
|
+
const MAX_LIST_HEIGHT_REM = 90;
|
|
2867
|
+
const FALLBACK_REM_SIZE = 16;
|
|
2868
|
+
function getRemSize() {
|
|
2869
|
+
if (typeof window === 'undefined') {
|
|
2870
|
+
return FALLBACK_REM_SIZE;
|
|
2871
|
+
}
|
|
2872
|
+
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
2873
|
+
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE;
|
|
2874
|
+
}
|
|
2875
|
+
function shouldDisplayHigher(content, list) {
|
|
2876
|
+
if (!content) {
|
|
2877
|
+
return false;
|
|
2878
|
+
}
|
|
2879
|
+
const { top, bottom } = content.getBoundingClientRect();
|
|
2880
|
+
const spaceAbove = top;
|
|
2881
|
+
const spaceBelow = window.innerHeight - bottom;
|
|
2882
|
+
const maxHeight = MAX_LIST_HEIGHT_REM * getRemSize();
|
|
2883
|
+
const desiredHeight = Math.min(list?.scrollHeight || maxHeight, maxHeight);
|
|
2884
|
+
if (spaceBelow >= desiredHeight) {
|
|
2885
|
+
return false;
|
|
2886
|
+
}
|
|
2887
|
+
if (spaceAbove >= desiredHeight) {
|
|
2888
|
+
return true;
|
|
2889
|
+
}
|
|
2890
|
+
return spaceAbove > spaceBelow;
|
|
2891
|
+
}
|
|
2892
|
+
function useFieldList(props) {
|
|
2893
|
+
const { suggestions, disabled } = props;
|
|
2894
|
+
const refContent = require$$0.useRef(null);
|
|
2895
|
+
const refList = require$$0.useRef(null);
|
|
2896
|
+
const refSuggestions = require$$0.useRef(null);
|
|
2897
|
+
const formControl = props.formControl;
|
|
2898
|
+
const [state, setState] = require$$0.useState({
|
|
2899
|
+
higher: false,
|
|
2900
|
+
listIsVisible: false
|
|
2901
|
+
});
|
|
2902
|
+
const [selected, setSelected] = require$$0.useState([]);
|
|
2903
|
+
require$$0.useEffect(() => {
|
|
2904
|
+
function onCloseSuggestions({ target }) {
|
|
2905
|
+
if (!refContent?.current?.contains(target) &&
|
|
2906
|
+
!refSuggestions?.current?.contains(target)) {
|
|
2907
|
+
setState((state) => ({ ...state, listIsVisible: false }));
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
document.addEventListener('click', onCloseSuggestions);
|
|
2911
|
+
return () => {
|
|
2912
|
+
document.removeEventListener('click', onCloseSuggestions);
|
|
2913
|
+
};
|
|
2914
|
+
}, []);
|
|
2915
|
+
require$$0.useEffect(() => {
|
|
2916
|
+
const formValue = formControl?.value;
|
|
2917
|
+
if (formValue !== undefined && formValue !== null && formValue.length) {
|
|
2918
|
+
setSelected(suggestions.filter((state) => formValue.some((value) => state.compareTo(value))));
|
|
2919
|
+
}
|
|
2920
|
+
else {
|
|
2921
|
+
setSelected([]);
|
|
2922
|
+
}
|
|
2923
|
+
}, [formControl?.value, suggestions]);
|
|
2924
|
+
const setListState = require$$0.useCallback((controllerState) => {
|
|
2925
|
+
setState((state) => {
|
|
2926
|
+
const newState = controllerState.listIsVisible !== undefined
|
|
2927
|
+
? {
|
|
2928
|
+
...controllerState,
|
|
2929
|
+
...(controllerState.listIsVisible
|
|
2930
|
+
? {
|
|
2931
|
+
higher: shouldDisplayHigher(refContent.current, refList.current)
|
|
2932
|
+
}
|
|
2933
|
+
: {})
|
|
2934
|
+
}
|
|
2935
|
+
: controllerState;
|
|
2936
|
+
return { ...state, ...newState };
|
|
2937
|
+
});
|
|
2938
|
+
}, []);
|
|
2939
|
+
const toggleElement = require$$0.useCallback((element) => {
|
|
2940
|
+
const alreadySelected = selected.some((state) => state.compareTo(element.value));
|
|
2941
|
+
const newSelected = alreadySelected
|
|
2942
|
+
? selected.filter((state) => !state.compareTo(element.value))
|
|
2943
|
+
: [...selected, element];
|
|
2944
|
+
const newValues = newSelected.map((state) => state.value);
|
|
2945
|
+
setSelected(newSelected);
|
|
2946
|
+
formControl?.setValue(newValues);
|
|
2947
|
+
props.onValue?.(newValues);
|
|
2948
|
+
}, [selected, formControl, props.onValue]);
|
|
2949
|
+
const isSelected = require$$0.useCallback((element) => {
|
|
2950
|
+
return selected.some((state) => state.compareTo(element.value));
|
|
2951
|
+
}, [selected]);
|
|
2952
|
+
const onClickInput = require$$0.useCallback(() => {
|
|
2953
|
+
if (!props.readOnly) {
|
|
2954
|
+
setListState({ listIsVisible: true });
|
|
2955
|
+
}
|
|
2956
|
+
}, [setListState, props.readOnly]);
|
|
2957
|
+
const onClickBackdrop = require$$0.useCallback(() => {
|
|
2958
|
+
setListState({ listIsVisible: false });
|
|
2959
|
+
}, [setListState]);
|
|
2960
|
+
const onClickAction = require$$0.useCallback(() => {
|
|
2961
|
+
if (!disabled && !props.readOnly) {
|
|
2962
|
+
setListState({ listIsVisible: !state.listIsVisible });
|
|
2963
|
+
}
|
|
2964
|
+
}, [disabled, props.readOnly, setListState, state.listIsVisible]);
|
|
2965
|
+
const onClickElement = require$$0.useCallback((element) => {
|
|
2966
|
+
return () => {
|
|
2967
|
+
toggleElement(element);
|
|
2968
|
+
};
|
|
2969
|
+
}, [toggleElement]);
|
|
2970
|
+
const onRemoveElement = require$$0.useCallback((element) => {
|
|
2971
|
+
return (event) => {
|
|
2972
|
+
event.stopPropagation();
|
|
2973
|
+
const newSelected = selected.filter((state) => !state.compareTo(element.value));
|
|
2974
|
+
const newValues = newSelected.map((state) => state.value);
|
|
2975
|
+
setSelected(newSelected);
|
|
2976
|
+
formControl?.setValue(newValues);
|
|
2977
|
+
props.onValue?.(newValues);
|
|
2978
|
+
};
|
|
2979
|
+
}, [selected, formControl, props.onValue]);
|
|
2980
|
+
const onKeydownElement = require$$0.useCallback((element) => {
|
|
2981
|
+
return (event) => {
|
|
2982
|
+
if (event.code === 'Enter') {
|
|
2983
|
+
toggleElement(element);
|
|
2984
|
+
}
|
|
2985
|
+
};
|
|
2986
|
+
}, [toggleElement]);
|
|
2987
|
+
return require$$0.useMemo(() => ({
|
|
2988
|
+
...state,
|
|
2989
|
+
selected,
|
|
2990
|
+
refContent,
|
|
2991
|
+
refList,
|
|
2992
|
+
refSuggestions,
|
|
2993
|
+
isSelected,
|
|
2994
|
+
onClickAction,
|
|
2995
|
+
onClickBackdrop,
|
|
2996
|
+
onClickElement,
|
|
2997
|
+
onClickInput,
|
|
2998
|
+
onKeydownElement,
|
|
2999
|
+
onRemoveElement
|
|
3000
|
+
}), [
|
|
3001
|
+
state,
|
|
3002
|
+
selected,
|
|
3003
|
+
isSelected,
|
|
3004
|
+
onClickAction,
|
|
3005
|
+
onClickBackdrop,
|
|
3006
|
+
onClickElement,
|
|
3007
|
+
onClickInput,
|
|
3008
|
+
onKeydownElement,
|
|
3009
|
+
onRemoveElement
|
|
3010
|
+
]);
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
function RlsChooserListTemplateComponent(props) {
|
|
3014
|
+
const fieldList = useFieldList(props);
|
|
3015
|
+
const { render, suggestions, action, children, formControl, rlsTheme } = props;
|
|
3016
|
+
const disabled = require$$0.useMemo(() => {
|
|
3017
|
+
return formControl?.disabled || props.disabled;
|
|
3018
|
+
}, [formControl?.disabled, props.disabled]);
|
|
3019
|
+
const className = renderClassStatus('rls-chooser', {
|
|
3020
|
+
visible: fieldList.listIsVisible,
|
|
3021
|
+
disabled
|
|
3022
|
+
}, `rls-chooser-list ${props.className ?? ''}`);
|
|
3023
|
+
const onKeydownTrigger = require$$0.useCallback((event) => {
|
|
3024
|
+
switch (event.code) {
|
|
3025
|
+
case 'Space':
|
|
3026
|
+
case 'Enter':
|
|
3027
|
+
event.preventDefault();
|
|
3028
|
+
fieldList.onClickAction();
|
|
3029
|
+
break;
|
|
3030
|
+
case 'Escape':
|
|
3031
|
+
fieldList.onClickBackdrop();
|
|
3032
|
+
break;
|
|
3033
|
+
}
|
|
3034
|
+
}, [fieldList.onClickAction, fieldList.onClickBackdrop]);
|
|
3035
|
+
const renderWithCheckbox = require$$0.useCallback((element) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__element", children: [jsxRuntimeExports.jsx(RlsCheckBox, { checked: fieldList.isSelected(element) }), render(element)] })), [fieldList.isSelected, render]);
|
|
3036
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-chooser__trigger", role: "combobox", "aria-expanded": fieldList.listIsVisible, "aria-haspopup": "listbox", "aria-disabled": disabled || undefined, tabIndex: disabled ? -1 : 0, onClick: disabled ? undefined : fieldList.onClickAction, onKeyDown: disabled ? undefined : onKeydownTrigger, children: typeof children === 'function'
|
|
3037
|
+
? children({
|
|
3038
|
+
listIsVisible: fieldList.listIsVisible,
|
|
3039
|
+
selected: fieldList.selected
|
|
3040
|
+
})
|
|
3041
|
+
: children }), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: fieldList.listIsVisible, action: action, disabled: disabled, higher: fieldList.higher, render: renderWithCheckbox, refAnchor: fieldList.refContent, refList: fieldList.refList, refSuggestions: fieldList.refSuggestions, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop, onHiddenAnchor: fieldList.onClickBackdrop })] }));
|
|
3042
|
+
}
|
|
3043
|
+
const RlsChooserListTemplate = require$$0.memo(RlsChooserListTemplateComponent);
|
|
3044
|
+
function RlsChooserListComponent(props) {
|
|
3045
|
+
const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
|
|
3046
|
+
return jsxRuntimeExports.jsx(RlsChooserListTemplate, { ...props, render: render });
|
|
3047
|
+
}
|
|
3048
|
+
const RlsChooserList = require$$0.memo(RlsChooserListComponent);
|
|
3049
|
+
|
|
3050
|
+
function useFieldSelect(props) {
|
|
3051
|
+
const controller = useListController(props);
|
|
3052
|
+
require$$0.useEffect(() => {
|
|
3053
|
+
if (props.disabled) {
|
|
3054
|
+
controller.setState({ focused: false });
|
|
3055
|
+
}
|
|
3056
|
+
}, [props.disabled]);
|
|
3057
|
+
const onFocusInput = require$$0.useCallback(() => {
|
|
3058
|
+
controller.setState({ focused: true });
|
|
3059
|
+
}, [controller.setState]);
|
|
3060
|
+
const onBlurInput = require$$0.useCallback(() => {
|
|
3061
|
+
controller.setState({ focused: false });
|
|
3062
|
+
}, [controller.setState]);
|
|
3063
|
+
const onClickInput = require$$0.useCallback(() => {
|
|
3064
|
+
if (!props.readOnly) {
|
|
3065
|
+
controller.setState({ listIsVisible: true });
|
|
3066
|
+
}
|
|
3067
|
+
}, [controller.setState, props.readOnly]);
|
|
3068
|
+
const onKeydownInput = require$$0.useCallback((event) => {
|
|
3069
|
+
switch (event.code) {
|
|
3070
|
+
case 'Space':
|
|
3071
|
+
case 'Enter':
|
|
3072
|
+
controller.setState({ listIsVisible: true });
|
|
3073
|
+
break;
|
|
3074
|
+
case 'Escape':
|
|
3075
|
+
case 'Tab':
|
|
3076
|
+
controller.setState({ listIsVisible: false });
|
|
3077
|
+
break;
|
|
3078
|
+
default:
|
|
3079
|
+
controller.navigationInput(event);
|
|
3080
|
+
break;
|
|
3081
|
+
}
|
|
3082
|
+
}, [controller.setState, controller.navigationInput]);
|
|
3083
|
+
const onClickAction = require$$0.useCallback(() => {
|
|
3084
|
+
const removable = !props.unremovable && !!controller.value;
|
|
3085
|
+
if (removable) {
|
|
3086
|
+
controller.setState({ listIsVisible: false });
|
|
3087
|
+
controller.setFormValue(undefined);
|
|
3088
|
+
props.onValue?.(props.value);
|
|
3089
|
+
}
|
|
3090
|
+
else {
|
|
3091
|
+
const listIsVisible = !controller.listIsVisible;
|
|
3092
|
+
controller.setState({ listIsVisible });
|
|
3093
|
+
if (listIsVisible) {
|
|
3094
|
+
controller.refInput?.current?.focus();
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
}, [
|
|
3098
|
+
controller.listIsVisible,
|
|
3099
|
+
controller.value,
|
|
3100
|
+
controller.setState,
|
|
3101
|
+
controller.setFormValue,
|
|
3102
|
+
props.unremovable,
|
|
3103
|
+
props.onValue
|
|
3104
|
+
]);
|
|
3105
|
+
const onClickBackdrop = require$$0.useCallback(() => {
|
|
3106
|
+
controller.setState({ listIsVisible: false });
|
|
3107
|
+
}, [controller.setState]);
|
|
3108
|
+
const onChange = require$$0.useCallback((element) => {
|
|
3109
|
+
if (!props.disabled) {
|
|
3110
|
+
controller.refInput?.current?.focus();
|
|
3111
|
+
}
|
|
3112
|
+
if (props.onSelect) {
|
|
3113
|
+
controller.setState({ listIsVisible: false });
|
|
3114
|
+
if (element.value) {
|
|
3115
|
+
props.onSelect(element.value);
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
else {
|
|
3119
|
+
controller.setFormValue(element);
|
|
3120
|
+
controller.setState({ listIsVisible: false });
|
|
3121
|
+
}
|
|
3122
|
+
props.onValue?.(element.value);
|
|
3123
|
+
}, [
|
|
3124
|
+
controller.setState,
|
|
3125
|
+
controller.setFormValue,
|
|
3126
|
+
props.onSelect,
|
|
3127
|
+
props.onValue,
|
|
3128
|
+
props.disabled
|
|
3129
|
+
]);
|
|
3130
|
+
const onClickElement = require$$0.useCallback((element) => {
|
|
3131
|
+
return () => {
|
|
3132
|
+
onChange(element);
|
|
3133
|
+
};
|
|
3134
|
+
}, [onChange]);
|
|
3135
|
+
const onKeydownElement = require$$0.useCallback((element) => {
|
|
3136
|
+
return (event) => {
|
|
3137
|
+
if (event.code === 'Enter') {
|
|
3138
|
+
onChange(element);
|
|
3139
|
+
}
|
|
3140
|
+
else {
|
|
3141
|
+
controller.navigationElement(event);
|
|
3142
|
+
}
|
|
3143
|
+
};
|
|
3144
|
+
}, [onChange, controller.navigationElement]);
|
|
3145
|
+
return require$$0.useMemo(() => ({
|
|
3146
|
+
...controller,
|
|
3147
|
+
onBlurInput,
|
|
3148
|
+
onClickAction,
|
|
3149
|
+
onClickBackdrop,
|
|
3150
|
+
onClickInput,
|
|
3151
|
+
onClickElement,
|
|
3152
|
+
onFocusInput,
|
|
3153
|
+
onKeydownElement,
|
|
3154
|
+
onKeydownInput
|
|
3155
|
+
}), [
|
|
3156
|
+
controller,
|
|
3157
|
+
onBlurInput,
|
|
3158
|
+
onClickAction,
|
|
3159
|
+
onClickBackdrop,
|
|
3160
|
+
onClickInput,
|
|
3161
|
+
onClickElement,
|
|
3162
|
+
onFocusInput,
|
|
3163
|
+
onKeydownElement,
|
|
3164
|
+
onKeydownInput
|
|
3165
|
+
]);
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
function RlsChooserSelectTemplateComponent(props) {
|
|
3169
|
+
const select = useFieldSelect({ ...props, unremovable: true });
|
|
3170
|
+
const { render, suggestions, action, children, formControl, rlsTheme } = props;
|
|
3171
|
+
const disabled = require$$0.useMemo(() => {
|
|
3172
|
+
return formControl?.disabled || props.disabled;
|
|
3173
|
+
}, [formControl?.disabled, props.disabled]);
|
|
3174
|
+
const className = renderClassStatus('rls-chooser', {
|
|
3175
|
+
focused: select.focused && !disabled,
|
|
3176
|
+
visible: select.listIsVisible,
|
|
3177
|
+
disabled
|
|
3178
|
+
}, `rls-chooser-select ${props.className ?? ''}`);
|
|
3179
|
+
const onKeydownTrigger = require$$0.useCallback((event) => {
|
|
3180
|
+
if (event.code === 'Space') {
|
|
3181
|
+
event.preventDefault();
|
|
3182
|
+
}
|
|
3183
|
+
select.onKeydownInput(event);
|
|
3184
|
+
}, [select.onKeydownInput]);
|
|
3185
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.refContent, className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-chooser__trigger", role: "combobox", "aria-expanded": select.listIsVisible, "aria-haspopup": "listbox", "aria-disabled": disabled || undefined, tabIndex: disabled ? -1 : 0, onClick: disabled ? undefined : select.onClickAction, onKeyDown: disabled ? undefined : onKeydownTrigger, onFocus: select.onFocusInput, onBlur: select.onBlurInput, children: typeof children === 'function'
|
|
3186
|
+
? children({
|
|
3187
|
+
description: select.value,
|
|
3188
|
+
listIsVisible: select.listIsVisible,
|
|
3189
|
+
value: formControl?.value ?? props.value
|
|
3190
|
+
})
|
|
3191
|
+
: children }), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: select.listIsVisible, action: action, disabled: disabled, higher: select.higher, render: render, refAnchor: select.refContent, refList: select.refList, refSuggestions: select.refSuggestions, onClickElement: select.onClickElement, onKeydownElement: select.onKeydownElement, onClickBackdrop: select.onClickBackdrop, onHiddenAnchor: select.onClickBackdrop })] }));
|
|
3192
|
+
}
|
|
3193
|
+
const RlsChooserSelectTemplate = require$$0.memo(RlsChooserSelectTemplateComponent);
|
|
3194
|
+
function RlsChooserSelectComponent(props) {
|
|
3195
|
+
const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
|
|
3196
|
+
return jsxRuntimeExports.jsx(RlsChooserSelectTemplate, { ...props, render: render });
|
|
3197
|
+
}
|
|
3198
|
+
const RlsChooserSelect = require$$0.memo(RlsChooserSelectComponent);
|
|
3199
|
+
|
|
3200
|
+
class ConfirmationResult extends commons.SealedPartial {
|
|
3201
|
+
static approved() {
|
|
3202
|
+
return new ConfirmationResult('approved');
|
|
3203
|
+
}
|
|
3204
|
+
static reject() {
|
|
3205
|
+
return new ConfirmationResult('reject');
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
function RlsConfirmationComponent({ approved, className, content, reject, rlsTheme, subtitle, title, visible }) {
|
|
3209
|
+
const classConfirmation = renderClassStatus('rls-confirmation', { visible }, className);
|
|
3210
|
+
return (jsxRuntimeExports.jsxs("div", { className: classConfirmation, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__header", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__content", children: content })) }), (approved || reject) && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsxRuntimeExports.jsx(RlsButton, { identifier: approved.identifier, type: approved.type, onClick: approved.onClick, disabled: approved.disabled, rlsTheme: approved.rlsTheme, children: approved.label })), reject && (jsxRuntimeExports.jsx(RlsButton, { identifier: reject.identifier, type: reject.type, onClick: reject.onClick, disabled: reject.disabled, rlsTheme: reject.rlsTheme, children: reject.label }))] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
3211
|
+
}
|
|
3212
|
+
const RlsConfirmation = require$$0.memo(RlsConfirmationComponent);
|
|
3213
|
+
const RlsConfirmationBase = RlsConfirmation;
|
|
3214
|
+
function useConfirmation() {
|
|
3215
|
+
const [config, setConfig] = require$$0.useState({});
|
|
3216
|
+
const [visible, setVisible] = require$$0.useState(false);
|
|
3217
|
+
const configRef = require$$0.useRef(config);
|
|
3218
|
+
configRef.current = config;
|
|
3219
|
+
const visibleRef = require$$0.useRef(visible);
|
|
3220
|
+
visibleRef.current = visible;
|
|
3221
|
+
const RlsConfirmation = require$$0.useMemo(() => {
|
|
3222
|
+
return function RlsConfirmation(props) {
|
|
3223
|
+
return ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmationBase, { ...props, ...configRef.current, visible: visibleRef.current }), document.body);
|
|
3224
|
+
};
|
|
3225
|
+
}, []);
|
|
3226
|
+
const confirmation = require$$0.useCallback((options) => {
|
|
3227
|
+
return new Promise((resolve) => {
|
|
3228
|
+
setConfig({
|
|
3229
|
+
...options,
|
|
3230
|
+
approved: {
|
|
3231
|
+
label: options.approved?.label ?? reactI18n('confirmationActionApproved'),
|
|
3232
|
+
onClick: () => {
|
|
3233
|
+
setVisible(false);
|
|
3234
|
+
resolve(ConfirmationResult.approved());
|
|
3235
|
+
},
|
|
3236
|
+
type: options.approved?.type ?? 'raised',
|
|
3237
|
+
disabled: options.approved?.disabled,
|
|
3238
|
+
identifier: options.approved?.identifier,
|
|
3239
|
+
rlsTheme: options.approved?.rlsTheme
|
|
3240
|
+
},
|
|
3241
|
+
reject: options.reject
|
|
3242
|
+
? {
|
|
3243
|
+
label: options.reject.label,
|
|
3244
|
+
onClick: () => {
|
|
3245
|
+
setVisible(false);
|
|
3246
|
+
resolve(ConfirmationResult.reject());
|
|
3247
|
+
},
|
|
3248
|
+
type: options.reject.type ?? 'flat',
|
|
3249
|
+
disabled: options.reject.disabled,
|
|
3250
|
+
identifier: options.reject.identifier,
|
|
3251
|
+
rlsTheme: options.reject.rlsTheme
|
|
3252
|
+
}
|
|
3253
|
+
: undefined
|
|
3254
|
+
});
|
|
3255
|
+
setVisible(true);
|
|
3256
|
+
});
|
|
3257
|
+
}, []);
|
|
3258
|
+
return {
|
|
3259
|
+
confirmation,
|
|
3260
|
+
RlsConfirmation
|
|
3261
|
+
};
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
function createObserver(options) {
|
|
3265
|
+
const { setScrolleable, table } = options;
|
|
3266
|
+
const observer = new ResizeObserver(() => {
|
|
3267
|
+
const scrollHeight = table.scrollHeight || 0;
|
|
3268
|
+
const clientHeight = table.clientHeight || 0;
|
|
3269
|
+
setScrolleable(scrollHeight > clientHeight);
|
|
3270
|
+
});
|
|
3271
|
+
observer.observe(table);
|
|
3272
|
+
return observer;
|
|
3273
|
+
}
|
|
3274
|
+
function useDatatable(table) {
|
|
3275
|
+
const [scrolleable, setScrolleable] = require$$0.useState(false);
|
|
3276
|
+
const refTable = require$$0.useRef(table ? table : null);
|
|
3277
|
+
require$$0.useEffect(() => {
|
|
3278
|
+
const observer = refTable.current &&
|
|
3279
|
+
createObserver({ setScrolleable, table: refTable.current });
|
|
3280
|
+
return () => {
|
|
3281
|
+
observer?.disconnect();
|
|
3282
|
+
};
|
|
3283
|
+
}, []);
|
|
3284
|
+
return { refTable, scrolleable };
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
function RlsDatatableComponent({ children, footer, header, identifier, rlsTheme, resizable, summary, table, toolbar }) {
|
|
3288
|
+
const datatable = useDatatable(table);
|
|
3289
|
+
const className = renderClassStatus('rls-datatable', {
|
|
3290
|
+
resizable,
|
|
3291
|
+
scrolleable: resizable && datatable?.scrolleable
|
|
3292
|
+
});
|
|
3293
|
+
return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [toolbar && jsxRuntimeExports.jsx("div", { className: "rls-datatable__toolbar", children: toolbar }), jsxRuntimeExports.jsx("div", { className: "rls-datatable__table", children: jsxRuntimeExports.jsxs("table", { id: identifier, children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__head", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.refTable, className: "rls-datatable__body", children: children })] }) }), summary && jsxRuntimeExports.jsx("div", { className: "rls-datatable__summary", children: summary }), footer && jsxRuntimeExports.jsx("div", { className: "rls-datatable__footer", children: footer })] }));
|
|
3294
|
+
}
|
|
3295
|
+
const RlsDatatable = require$$0.memo(RlsDatatableComponent);
|
|
3296
|
+
function RlsDatatableHeaderComponent({ children, identifier, rlsTheme }) {
|
|
3297
|
+
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: "rls-datatable__header", "rls-theme": rlsTheme, children: children }));
|
|
3298
|
+
}
|
|
3299
|
+
const RlsDatatableHeader = require$$0.memo(RlsDatatableHeaderComponent);
|
|
3300
|
+
function RlsDatatableTitleComponent({ actions, children, className, control, identifier, rlsTheme, truncated }) {
|
|
3301
|
+
const classNameTitle = renderClassStatus('rls-datatable__title', { actions, control, truncated }, className);
|
|
3302
|
+
return (jsxRuntimeExports.jsx("th", { id: identifier, className: classNameTitle, "rls-theme": rlsTheme, children: children }));
|
|
3303
|
+
}
|
|
3304
|
+
const RlsDatatableTitle = require$$0.memo(RlsDatatableTitleComponent);
|
|
3305
|
+
function RlsDatatableSubheaderComponent({ children, className, identifier, rlsTheme }) {
|
|
3306
|
+
const classNameSubheader = renderClassStatus('rls-datatable__subheader', {}, className);
|
|
3307
|
+
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classNameSubheader, "rls-theme": rlsTheme, children: children }));
|
|
3308
|
+
}
|
|
3309
|
+
const RlsDatatableSubheader = require$$0.memo(RlsDatatableSubheaderComponent);
|
|
3310
|
+
function RlsDatatableRecordComponent({ children, className, error, identifier, info, rlsTheme, success, truncated, warning }) {
|
|
3311
|
+
const classNameRecord = renderClassStatus('rls-datatable__record', { error, info, truncated, success, warning }, className);
|
|
3312
|
+
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classNameRecord, "rls-theme": rlsTheme, children: children }));
|
|
3313
|
+
}
|
|
3314
|
+
const RlsDatatableRecord = require$$0.memo(RlsDatatableRecordComponent);
|
|
3315
|
+
function RlsDatatableTotalsComponent({ children, className, error, identifier, info, rlsTheme, success, truncated, warning }) {
|
|
3316
|
+
const classNameTotals = renderClassStatus('rls-datatable__totals', { error, info, truncated, success, warning }, className);
|
|
3317
|
+
return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameTotals, "rls-theme": rlsTheme, children: children }));
|
|
3318
|
+
}
|
|
3319
|
+
const RlsDatatableTotals = require$$0.memo(RlsDatatableTotalsComponent);
|
|
3320
|
+
function RlsDatatableCellComponent({ actions, children, className, control, identifier, rlsTheme, truncated }) {
|
|
3321
|
+
const classNameCell = renderClassStatus('rls-datatable__cell', { actions, control, truncated }, className);
|
|
3322
|
+
return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameCell, "rls-theme": rlsTheme, children: children }));
|
|
3323
|
+
}
|
|
3324
|
+
const RlsDatatableCell = require$$0.memo(RlsDatatableCellComponent);
|
|
3325
|
+
function RlsDatatableDataComponent({ actions, children, className, control, identifier, truncated }) {
|
|
3326
|
+
const classNameData = renderClassStatus('rls-datatable__data', { actions, control, truncated }, className);
|
|
3327
|
+
return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameData, children: children }));
|
|
3328
|
+
}
|
|
3329
|
+
const RlsDatatableData = require$$0.memo(RlsDatatableDataComponent);
|
|
3330
|
+
function RlsDatatableFloatingComponent({ children, className, identifier, invested, rlsTheme }) {
|
|
3331
|
+
const classNameFloating = renderClassStatus('rls-datatable__floating', { invested }, className);
|
|
3332
|
+
return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameFloating, "rls-theme": rlsTheme, children: children }));
|
|
3333
|
+
}
|
|
3334
|
+
const RlsDatatableFloating = require$$0.memo(RlsDatatableFloatingComponent);
|
|
3335
|
+
|
|
3336
|
+
function RlsDropdownComponent({ children, controller, rlsTheme }) {
|
|
3337
|
+
const className = renderClassStatus('rls-dropdown', {
|
|
3338
|
+
visible: controller.visible
|
|
3339
|
+
});
|
|
3340
|
+
require$$0.useEffect(() => {
|
|
3341
|
+
function onCloseDropdown({ target }) {
|
|
3342
|
+
if (!controller.component.current.contains(target)) {
|
|
3343
|
+
controller.close();
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
document.addEventListener('click', onCloseDropdown);
|
|
3347
|
+
return () => {
|
|
3348
|
+
document.removeEventListener('click', onCloseDropdown);
|
|
3349
|
+
};
|
|
3350
|
+
}, []);
|
|
3351
|
+
return (jsxRuntimeExports.jsx("div", { ref: controller.component, className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-dropdown__content", children: children }) }));
|
|
3352
|
+
}
|
|
3353
|
+
const RlsDropdown = require$$0.memo(RlsDropdownComponent);
|
|
3354
|
+
|
|
3355
|
+
function RlsFieldAutocompleteTemplateComponent(props) {
|
|
3356
|
+
const autocomplete = useFieldAutocomplete(props);
|
|
3357
|
+
const { render, action, children, formControl, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
3358
|
+
const [listInputPlaceholder, setListInputPlaceholder] = require$$0.useState(reactI18n('listInputPlaceholder'));
|
|
3359
|
+
require$$0.useEffect(() => {
|
|
3360
|
+
return i18n.i18nSubscribe(() => {
|
|
3361
|
+
setListInputPlaceholder(reactI18n('listInputPlaceholder'));
|
|
3362
|
+
});
|
|
3363
|
+
}, []);
|
|
3364
|
+
require$$0.useEffect(() => {
|
|
3365
|
+
props.onInput?.(autocomplete.pattern);
|
|
3366
|
+
}, [autocomplete.pattern, props.onInput]);
|
|
3367
|
+
const disabled = require$$0.useMemo(() => {
|
|
3368
|
+
return formControl?.disabled || props.disabled;
|
|
3369
|
+
}, [formControl?.disabled, props.disabled]);
|
|
3370
|
+
const className = renderClassStatus('rls-field-box', {
|
|
3371
|
+
focused: autocomplete.focused && !disabled,
|
|
3372
|
+
error: formControl?.wrong,
|
|
3373
|
+
disabled,
|
|
3374
|
+
readonly: props.readOnly,
|
|
3375
|
+
selected: !!autocomplete.value
|
|
3376
|
+
}, `rls-field-list rls-field-autocomplete ${props.className ?? ''}`);
|
|
3377
|
+
const onClickPattern = require$$0.useCallback(() => {
|
|
3378
|
+
onSearch?.(autocomplete.pattern);
|
|
3379
|
+
}, [onSearch, autocomplete.pattern]);
|
|
3380
|
+
const onKeyDownPattern = require$$0.useCallback((event) => {
|
|
3381
|
+
if (event.key === 'Enter') {
|
|
3382
|
+
onSearch?.(autocomplete.pattern);
|
|
3383
|
+
}
|
|
3384
|
+
autocomplete.onKeydownInput(event);
|
|
3385
|
+
}, [autocomplete.onKeydownInput, onSearch, autocomplete.pattern]);
|
|
3386
|
+
const searchControl = require$$0.useMemo(() => ({
|
|
3387
|
+
pattern: autocomplete.pattern,
|
|
3388
|
+
placeholder: listInputPlaceholder,
|
|
3389
|
+
searching,
|
|
3390
|
+
refInput: autocomplete.refInput,
|
|
3391
|
+
onChange: autocomplete.setPattern,
|
|
3392
|
+
onFocus: autocomplete.onFocusInput,
|
|
3393
|
+
onBlur: autocomplete.onBlurInput,
|
|
3394
|
+
onKeyDown: onKeyDownPattern,
|
|
3395
|
+
onSearch: onSearch ? onClickPattern : undefined
|
|
3396
|
+
}), [
|
|
3397
|
+
autocomplete.pattern,
|
|
3398
|
+
autocomplete.refInput,
|
|
3399
|
+
autocomplete.setPattern,
|
|
3400
|
+
autocomplete.onFocusInput,
|
|
3401
|
+
autocomplete.onBlurInput,
|
|
3402
|
+
listInputPlaceholder,
|
|
3403
|
+
searching,
|
|
3404
|
+
onKeyDownPattern,
|
|
3405
|
+
onClickPattern,
|
|
3406
|
+
onSearch
|
|
3407
|
+
]);
|
|
3408
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-list__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: autocomplete.value, onClick: autocomplete.onClickControl }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: autocomplete.value ? 'trash-2' : 'arrow-ios-down', onClick: autocomplete.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: autocomplete.coincidences, visible: autocomplete.listIsVisible, action: action, disabled: disabled, higher: autocomplete.higher, render: render, refAnchor: autocomplete.refContent, refList: autocomplete.refList, refSuggestions: autocomplete.refSuggestions, searchControl: searchControl, onClickElement: autocomplete.onClickElement, onKeydownElement: autocomplete.onKeydownElement, onClickBackdrop: autocomplete.onClickBackdrop, onHiddenAnchor: autocomplete.onClickBackdrop })] }));
|
|
3409
|
+
}
|
|
3410
|
+
const RlsFieldAutocompleteTemplate = require$$0.memo(RlsFieldAutocompleteTemplateComponent);
|
|
3411
|
+
function RlsFieldAutocompleteComponent(props) {
|
|
3412
|
+
const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
|
|
3413
|
+
return jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: render });
|
|
3414
|
+
}
|
|
3415
|
+
const RlsFieldAutocomplete = require$$0.memo(RlsFieldAutocompleteComponent);
|
|
3416
|
+
|
|
3417
|
+
function RlsModalComponent({ autoclose, children, className, controller, onBackdrop, visible, rlsTheme }) {
|
|
3418
|
+
const classNameModal = renderClassStatus('rls-modal', { visible: controller?.visible ?? visible }, className);
|
|
3419
|
+
const onClickBackdrop = require$$0.useCallback(() => {
|
|
3420
|
+
if (autoclose) {
|
|
3421
|
+
controller?.close();
|
|
3422
|
+
}
|
|
3423
|
+
onBackdrop?.();
|
|
2924
3424
|
}, [autoclose, controller, onBackdrop]);
|
|
2925
3425
|
return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: classNameModal, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal__backdrop", onClick: onClickBackdrop })] }), document.body);
|
|
2926
3426
|
}
|
|
@@ -3697,192 +4197,48 @@ function RlsFieldDateRangeComponent({ children, date, disabled: disabledProps, f
|
|
|
3697
4197
|
const disabled = require$$0.useMemo(() => {
|
|
3698
4198
|
return formControl?.disabled || disabledProps;
|
|
3699
4199
|
}, [formControl?.disabled, disabledProps]);
|
|
3700
|
-
const className = renderClassStatus('rls-field-box', {
|
|
3701
|
-
disabled,
|
|
3702
|
-
readonly: readOnly
|
|
3703
|
-
});
|
|
3704
|
-
const dateRangeValue = require$$0.useMemo(() => {
|
|
3705
|
-
return formControl ? formControl.value : value;
|
|
3706
|
-
}, [formControl?.value, value]);
|
|
3707
|
-
const status = require$$0.useMemo(() => {
|
|
3708
|
-
return {
|
|
3709
|
-
icon: dateRangeValue ? 'trash-2' : 'calendar',
|
|
3710
|
-
valueInput: dateRangeValue ? rangeFormatTemplate(dateRangeValue) : ''
|
|
3711
|
-
};
|
|
3712
|
-
}, [dateRangeValue]);
|
|
3713
|
-
const onClickInput = require$$0.useCallback(() => {
|
|
3714
|
-
if (!readOnly) {
|
|
3715
|
-
setModalIsVisible(true);
|
|
3716
|
-
}
|
|
3717
|
-
}, [readOnly]);
|
|
3718
|
-
const onChange = require$$0.useCallback((value) => {
|
|
3719
|
-
setValue(value);
|
|
3720
|
-
onValue?.(value);
|
|
3721
|
-
}, [onValue]);
|
|
3722
|
-
const onClickAction = require$$0.useCallback(() => {
|
|
3723
|
-
if (dateRangeValue) {
|
|
3724
|
-
formControl?.setValue(valueInitial);
|
|
3725
|
-
formControl?.touch();
|
|
3726
|
-
onChange(valueInitial);
|
|
3727
|
-
}
|
|
3728
|
-
else {
|
|
3729
|
-
setModalIsVisible(true);
|
|
3730
|
-
}
|
|
3731
|
-
}, [dateRangeValue, formControl, valueInitial, onChange]);
|
|
3732
|
-
const onCloseModal = require$$0.useCallback((dateRange) => {
|
|
3733
|
-
if (dateRange) {
|
|
3734
|
-
onChange(dateRange);
|
|
3735
|
-
}
|
|
3736
|
-
formControl?.touch();
|
|
3737
|
-
setModalIsVisible(false);
|
|
3738
|
-
}, [formControl, onChange]);
|
|
3739
|
-
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date-range__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModalDateRange, { visible: modalIsVisible, formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onClose: onCloseModal, rlsTheme: rlsTheme })] }));
|
|
3740
|
-
}
|
|
3741
|
-
const RlsFieldDateRange = require$$0.memo(RlsFieldDateRangeComponent);
|
|
3742
|
-
|
|
3743
|
-
const MAX_LIST_HEIGHT_REM = 90;
|
|
3744
|
-
const FALLBACK_REM_SIZE = 16;
|
|
3745
|
-
function getRemSize() {
|
|
3746
|
-
if (typeof window === 'undefined') {
|
|
3747
|
-
return FALLBACK_REM_SIZE;
|
|
3748
|
-
}
|
|
3749
|
-
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
3750
|
-
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE;
|
|
3751
|
-
}
|
|
3752
|
-
function shouldDisplayHigher(content, list) {
|
|
3753
|
-
if (!content) {
|
|
3754
|
-
return false;
|
|
3755
|
-
}
|
|
3756
|
-
const { top, bottom } = content.getBoundingClientRect();
|
|
3757
|
-
const spaceAbove = top;
|
|
3758
|
-
const spaceBelow = window.innerHeight - bottom;
|
|
3759
|
-
const maxHeight = MAX_LIST_HEIGHT_REM * getRemSize();
|
|
3760
|
-
const desiredHeight = Math.min(list?.scrollHeight || maxHeight, maxHeight);
|
|
3761
|
-
if (spaceBelow >= desiredHeight) {
|
|
3762
|
-
return false;
|
|
3763
|
-
}
|
|
3764
|
-
if (spaceAbove >= desiredHeight) {
|
|
3765
|
-
return true;
|
|
3766
|
-
}
|
|
3767
|
-
return spaceAbove > spaceBelow;
|
|
3768
|
-
}
|
|
3769
|
-
function useFieldList(props) {
|
|
3770
|
-
const { suggestions, disabled } = props;
|
|
3771
|
-
const refContent = require$$0.useRef(null);
|
|
3772
|
-
const refList = require$$0.useRef(null);
|
|
3773
|
-
const formControl = props.formControl;
|
|
3774
|
-
const [state, setState] = require$$0.useState({
|
|
3775
|
-
higher: false,
|
|
3776
|
-
listIsVisible: false
|
|
3777
|
-
});
|
|
3778
|
-
const [selected, setSelected] = require$$0.useState([]);
|
|
3779
|
-
require$$0.useEffect(() => {
|
|
3780
|
-
function onCloseSuggestions({ target }) {
|
|
3781
|
-
if (!refContent?.current?.contains(target)) {
|
|
3782
|
-
setState((state) => ({ ...state, listIsVisible: false }));
|
|
3783
|
-
}
|
|
3784
|
-
}
|
|
3785
|
-
document.addEventListener('click', onCloseSuggestions);
|
|
3786
|
-
return () => {
|
|
3787
|
-
document.removeEventListener('click', onCloseSuggestions);
|
|
4200
|
+
const className = renderClassStatus('rls-field-box', {
|
|
4201
|
+
disabled,
|
|
4202
|
+
readonly: readOnly
|
|
4203
|
+
});
|
|
4204
|
+
const dateRangeValue = require$$0.useMemo(() => {
|
|
4205
|
+
return formControl ? formControl.value : value;
|
|
4206
|
+
}, [formControl?.value, value]);
|
|
4207
|
+
const status = require$$0.useMemo(() => {
|
|
4208
|
+
return {
|
|
4209
|
+
icon: dateRangeValue ? 'trash-2' : 'calendar',
|
|
4210
|
+
valueInput: dateRangeValue ? rangeFormatTemplate(dateRangeValue) : ''
|
|
3788
4211
|
};
|
|
3789
|
-
}, []);
|
|
3790
|
-
require$$0.useEffect(() => {
|
|
3791
|
-
const formValue = formControl?.value;
|
|
3792
|
-
if (formValue !== undefined && formValue !== null && formValue.length) {
|
|
3793
|
-
setSelected(suggestions.filter((state) => formValue.some((value) => state.compareTo(value))));
|
|
3794
|
-
}
|
|
3795
|
-
else {
|
|
3796
|
-
setSelected([]);
|
|
3797
|
-
}
|
|
3798
|
-
}, [formControl?.value, suggestions]);
|
|
3799
|
-
const setListState = require$$0.useCallback((controllerState) => {
|
|
3800
|
-
setState((state) => {
|
|
3801
|
-
const newState = controllerState.listIsVisible !== undefined
|
|
3802
|
-
? {
|
|
3803
|
-
...controllerState,
|
|
3804
|
-
...(controllerState.listIsVisible
|
|
3805
|
-
? {
|
|
3806
|
-
higher: shouldDisplayHigher(refContent.current, refList.current)
|
|
3807
|
-
}
|
|
3808
|
-
: {})
|
|
3809
|
-
}
|
|
3810
|
-
: controllerState;
|
|
3811
|
-
return { ...state, ...newState };
|
|
3812
|
-
});
|
|
3813
|
-
}, []);
|
|
3814
|
-
const toggleElement = require$$0.useCallback((element) => {
|
|
3815
|
-
const alreadySelected = selected.some((state) => state.compareTo(element.value));
|
|
3816
|
-
const newSelected = alreadySelected
|
|
3817
|
-
? selected.filter((state) => !state.compareTo(element.value))
|
|
3818
|
-
: [...selected, element];
|
|
3819
|
-
const newValues = newSelected.map((state) => state.value);
|
|
3820
|
-
setSelected(newSelected);
|
|
3821
|
-
formControl?.setValue(newValues);
|
|
3822
|
-
props.onValue?.(newValues);
|
|
3823
|
-
}, [selected, formControl, props.onValue]);
|
|
3824
|
-
const isSelected = require$$0.useCallback((element) => {
|
|
3825
|
-
return selected.some((state) => state.compareTo(element.value));
|
|
3826
|
-
}, [selected]);
|
|
4212
|
+
}, [dateRangeValue]);
|
|
3827
4213
|
const onClickInput = require$$0.useCallback(() => {
|
|
3828
|
-
if (!
|
|
3829
|
-
|
|
4214
|
+
if (!readOnly) {
|
|
4215
|
+
setModalIsVisible(true);
|
|
3830
4216
|
}
|
|
3831
|
-
}, [
|
|
3832
|
-
const
|
|
3833
|
-
|
|
3834
|
-
|
|
4217
|
+
}, [readOnly]);
|
|
4218
|
+
const onChange = require$$0.useCallback((value) => {
|
|
4219
|
+
setValue(value);
|
|
4220
|
+
onValue?.(value);
|
|
4221
|
+
}, [onValue]);
|
|
3835
4222
|
const onClickAction = require$$0.useCallback(() => {
|
|
3836
|
-
if (
|
|
3837
|
-
|
|
4223
|
+
if (dateRangeValue) {
|
|
4224
|
+
formControl?.setValue(valueInitial);
|
|
4225
|
+
formControl?.touch();
|
|
4226
|
+
onChange(valueInitial);
|
|
3838
4227
|
}
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
formControl?.setValue(newValues);
|
|
3852
|
-
props.onValue?.(newValues);
|
|
3853
|
-
};
|
|
3854
|
-
}, [selected, formControl, props.onValue]);
|
|
3855
|
-
const onKeydownElement = require$$0.useCallback((element) => {
|
|
3856
|
-
return (event) => {
|
|
3857
|
-
if (event.code === 'Enter') {
|
|
3858
|
-
toggleElement(element);
|
|
3859
|
-
}
|
|
3860
|
-
};
|
|
3861
|
-
}, [toggleElement]);
|
|
3862
|
-
return require$$0.useMemo(() => ({
|
|
3863
|
-
...state,
|
|
3864
|
-
selected,
|
|
3865
|
-
refContent,
|
|
3866
|
-
refList,
|
|
3867
|
-
isSelected,
|
|
3868
|
-
onClickAction,
|
|
3869
|
-
onClickBackdrop,
|
|
3870
|
-
onClickElement,
|
|
3871
|
-
onClickInput,
|
|
3872
|
-
onKeydownElement,
|
|
3873
|
-
onRemoveElement
|
|
3874
|
-
}), [
|
|
3875
|
-
state,
|
|
3876
|
-
selected,
|
|
3877
|
-
isSelected,
|
|
3878
|
-
onClickAction,
|
|
3879
|
-
onClickBackdrop,
|
|
3880
|
-
onClickElement,
|
|
3881
|
-
onClickInput,
|
|
3882
|
-
onKeydownElement,
|
|
3883
|
-
onRemoveElement
|
|
3884
|
-
]);
|
|
4228
|
+
else {
|
|
4229
|
+
setModalIsVisible(true);
|
|
4230
|
+
}
|
|
4231
|
+
}, [dateRangeValue, formControl, valueInitial, onChange]);
|
|
4232
|
+
const onCloseModal = require$$0.useCallback((dateRange) => {
|
|
4233
|
+
if (dateRange) {
|
|
4234
|
+
onChange(dateRange);
|
|
4235
|
+
}
|
|
4236
|
+
formControl?.touch();
|
|
4237
|
+
setModalIsVisible(false);
|
|
4238
|
+
}, [formControl, onChange]);
|
|
4239
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date-range__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModalDateRange, { visible: modalIsVisible, formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onClose: onCloseModal, rlsTheme: rlsTheme })] }));
|
|
3885
4240
|
}
|
|
4241
|
+
const RlsFieldDateRange = require$$0.memo(RlsFieldDateRangeComponent);
|
|
3886
4242
|
|
|
3887
4243
|
function RlsFieldListInner({ render, suggestions, action, children, formControl, fieldList, msgErrorDisabled, placeholder, rlsTheme, ...props }) {
|
|
3888
4244
|
const disabled = require$$0.useMemo(() => {
|
|
@@ -3895,7 +4251,7 @@ function RlsFieldListInner({ render, suggestions, action, children, formControl,
|
|
|
3895
4251
|
readonly: props.readOnly
|
|
3896
4252
|
}, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
|
|
3897
4253
|
const renderWithCheckbox = require$$0.useCallback((element) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__element", children: [jsxRuntimeExports.jsx(RlsCheckBox, { checked: fieldList.isSelected(element) }), render(element)] })), [fieldList.isSelected, render]);
|
|
3898
|
-
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__chip", children: [jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__chip__description", children: item.description }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__multi__chip__remove", onClick: fieldList.onRemoveElement(item), children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }))] }, index)))) }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", onClick: fieldList.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: fieldList.listIsVisible, action: action, disabled: disabled, higher: fieldList.higher, render: renderWithCheckbox, refList: fieldList.refList, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop })] }));
|
|
4254
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__chip", children: [jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__chip__description", children: item.description }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__multi__chip__remove", onClick: fieldList.onRemoveElement(item), children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }))] }, index)))) }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", onClick: fieldList.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: fieldList.listIsVisible, action: action, disabled: disabled, higher: fieldList.higher, render: renderWithCheckbox, refAnchor: fieldList.refContent, refList: fieldList.refList, refSuggestions: fieldList.refSuggestions, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop, onHiddenAnchor: fieldList.onClickBackdrop })] }));
|
|
3899
4255
|
}
|
|
3900
4256
|
function RlsFieldListTemplateComponent(props) {
|
|
3901
4257
|
const fieldList = useFieldList(props);
|
|
@@ -3909,124 +4265,6 @@ function RlsFieldListComponent(props) {
|
|
|
3909
4265
|
}
|
|
3910
4266
|
const RlsFieldList = require$$0.memo(RlsFieldListComponent);
|
|
3911
4267
|
|
|
3912
|
-
function useFieldSelect(props) {
|
|
3913
|
-
const controller = useListController(props);
|
|
3914
|
-
require$$0.useEffect(() => {
|
|
3915
|
-
if (props.disabled) {
|
|
3916
|
-
controller.setState({ focused: false });
|
|
3917
|
-
}
|
|
3918
|
-
}, [props.disabled]);
|
|
3919
|
-
const onFocusInput = require$$0.useCallback(() => {
|
|
3920
|
-
controller.setState({ focused: true });
|
|
3921
|
-
}, [controller.setState]);
|
|
3922
|
-
const onBlurInput = require$$0.useCallback(() => {
|
|
3923
|
-
controller.setState({ focused: false });
|
|
3924
|
-
}, [controller.setState]);
|
|
3925
|
-
const onClickInput = require$$0.useCallback(() => {
|
|
3926
|
-
if (!props.readOnly) {
|
|
3927
|
-
controller.setState({ listIsVisible: true });
|
|
3928
|
-
}
|
|
3929
|
-
}, [controller.setState, props.readOnly]);
|
|
3930
|
-
const onKeydownInput = require$$0.useCallback((event) => {
|
|
3931
|
-
switch (event.code) {
|
|
3932
|
-
case 'Space':
|
|
3933
|
-
case 'Enter':
|
|
3934
|
-
controller.setState({ listIsVisible: true });
|
|
3935
|
-
break;
|
|
3936
|
-
case 'Escape':
|
|
3937
|
-
case 'Tab':
|
|
3938
|
-
controller.setState({ listIsVisible: false });
|
|
3939
|
-
break;
|
|
3940
|
-
default:
|
|
3941
|
-
controller.navigationInput(event);
|
|
3942
|
-
break;
|
|
3943
|
-
}
|
|
3944
|
-
}, [controller.setState, controller.navigationInput]);
|
|
3945
|
-
const onClickAction = require$$0.useCallback(() => {
|
|
3946
|
-
const removable = !props.unremovable && !!controller.value;
|
|
3947
|
-
if (removable) {
|
|
3948
|
-
controller.setState({ listIsVisible: false });
|
|
3949
|
-
controller.setFormValue(undefined);
|
|
3950
|
-
props.onValue?.(props.value);
|
|
3951
|
-
}
|
|
3952
|
-
else {
|
|
3953
|
-
const listIsVisible = !controller.listIsVisible;
|
|
3954
|
-
controller.setState({ listIsVisible });
|
|
3955
|
-
if (listIsVisible) {
|
|
3956
|
-
controller.refInput?.current?.focus();
|
|
3957
|
-
}
|
|
3958
|
-
}
|
|
3959
|
-
}, [
|
|
3960
|
-
controller.listIsVisible,
|
|
3961
|
-
controller.value,
|
|
3962
|
-
controller.setState,
|
|
3963
|
-
controller.setFormValue,
|
|
3964
|
-
props.unremovable,
|
|
3965
|
-
props.onValue
|
|
3966
|
-
]);
|
|
3967
|
-
const onClickBackdrop = require$$0.useCallback(() => {
|
|
3968
|
-
controller.setState({ listIsVisible: false });
|
|
3969
|
-
}, [controller.setState]);
|
|
3970
|
-
const onChange = require$$0.useCallback((element) => {
|
|
3971
|
-
if (!props.disabled) {
|
|
3972
|
-
controller.refInput?.current?.focus();
|
|
3973
|
-
}
|
|
3974
|
-
if (props.onSelect) {
|
|
3975
|
-
controller.setState({ listIsVisible: false });
|
|
3976
|
-
if (element.value) {
|
|
3977
|
-
props.onSelect(element.value);
|
|
3978
|
-
}
|
|
3979
|
-
}
|
|
3980
|
-
else {
|
|
3981
|
-
controller.setFormValue(element);
|
|
3982
|
-
controller.setState({ listIsVisible: false });
|
|
3983
|
-
}
|
|
3984
|
-
props.onValue?.(element.value);
|
|
3985
|
-
}, [
|
|
3986
|
-
controller.setState,
|
|
3987
|
-
controller.setFormValue,
|
|
3988
|
-
props.onSelect,
|
|
3989
|
-
props.onValue,
|
|
3990
|
-
props.disabled
|
|
3991
|
-
]);
|
|
3992
|
-
const onClickElement = require$$0.useCallback((element) => {
|
|
3993
|
-
return () => {
|
|
3994
|
-
onChange(element);
|
|
3995
|
-
};
|
|
3996
|
-
}, [onChange]);
|
|
3997
|
-
const onKeydownElement = require$$0.useCallback((element) => {
|
|
3998
|
-
return (event) => {
|
|
3999
|
-
if (event.code === 'Enter') {
|
|
4000
|
-
onChange(element);
|
|
4001
|
-
}
|
|
4002
|
-
else {
|
|
4003
|
-
controller.navigationElement(event);
|
|
4004
|
-
}
|
|
4005
|
-
};
|
|
4006
|
-
}, [onChange, controller.navigationElement]);
|
|
4007
|
-
return require$$0.useMemo(() => ({
|
|
4008
|
-
...controller,
|
|
4009
|
-
onBlurInput,
|
|
4010
|
-
onClickAction,
|
|
4011
|
-
onClickBackdrop,
|
|
4012
|
-
onClickInput,
|
|
4013
|
-
onClickElement,
|
|
4014
|
-
onFocusInput,
|
|
4015
|
-
onKeydownElement,
|
|
4016
|
-
onKeydownInput
|
|
4017
|
-
}), [
|
|
4018
|
-
controller,
|
|
4019
|
-
onBlurInput,
|
|
4020
|
-
onClickAction,
|
|
4021
|
-
onClickBackdrop,
|
|
4022
|
-
onClickInput,
|
|
4023
|
-
onClickElement,
|
|
4024
|
-
onFocusInput,
|
|
4025
|
-
onKeydownElement,
|
|
4026
|
-
onKeydownInput
|
|
4027
|
-
]);
|
|
4028
|
-
}
|
|
4029
|
-
|
|
4030
4268
|
function RlsFieldSelectTemplateComponent(props) {
|
|
4031
4269
|
const select = useFieldSelect(props);
|
|
4032
4270
|
const { render, suggestions, action, children, formControl, msgErrorDisabled, placeholder, rlsTheme, unremovable } = props;
|
|
@@ -4039,7 +4277,7 @@ function RlsFieldSelectTemplateComponent(props) {
|
|
|
4039
4277
|
disabled: disabled,
|
|
4040
4278
|
readonly: props.readOnly
|
|
4041
4279
|
}, `rls-field-list rls-field-select ${props.className ?? ''}`);
|
|
4042
|
-
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { ref: select.refInput, className: "rls-field-list__control", readOnly: true, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput, disabled: disabled }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: !unremovable && !!select.value ? 'close' : 'arrow-ios-down', onClick: select.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: select.listIsVisible, action: action, disabled: disabled, higher: select.higher, render: render, refList: select.refList, onClickElement: select.onClickElement, onKeydownElement: select.onKeydownElement, onClickBackdrop: select.onClickBackdrop })] }));
|
|
4280
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { ref: select.refInput, className: "rls-field-list__control", readOnly: true, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput, disabled: disabled }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: !unremovable && !!select.value ? 'close' : 'arrow-ios-down', onClick: select.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: select.listIsVisible, action: action, disabled: disabled, higher: select.higher, render: render, refAnchor: select.refContent, refList: select.refList, refSuggestions: select.refSuggestions, onClickElement: select.onClickElement, onKeydownElement: select.onKeydownElement, onClickBackdrop: select.onClickBackdrop, onHiddenAnchor: select.onClickBackdrop })] }));
|
|
4043
4281
|
}
|
|
4044
4282
|
const RlsFieldSelectTemplate = require$$0.memo(RlsFieldSelectTemplateComponent);
|
|
4045
4283
|
function RlsFieldSelectComponent(props) {
|
|
@@ -4054,54 +4292,56 @@ function RlsFormNavigationComponent({ children, className, controller, visible,
|
|
|
4054
4292
|
}
|
|
4055
4293
|
const RlsFormNavigation = require$$0.memo(RlsFormNavigationComponent);
|
|
4056
4294
|
|
|
4057
|
-
function useRelocationOnComponent({ container, element, onDrag }) {
|
|
4295
|
+
function useRelocationOnComponent({ container: containerRef, element: elementRef, onDrag }) {
|
|
4058
4296
|
const position = require$$0.useRef({ x: 0, y: 0 });
|
|
4059
4297
|
const dragOffset = require$$0.useRef({ x: 0, y: 0 });
|
|
4060
4298
|
const dragging = require$$0.useRef(false);
|
|
4061
|
-
|
|
4299
|
+
function getClientX(positionX) {
|
|
4062
4300
|
let clientX = position.current.x + positionX - dragOffset.current.x;
|
|
4063
4301
|
if (clientX < 0) {
|
|
4064
4302
|
clientX = 0;
|
|
4065
4303
|
}
|
|
4066
4304
|
else {
|
|
4067
|
-
const width = clientX +
|
|
4068
|
-
if (width >
|
|
4069
|
-
clientX =
|
|
4305
|
+
const width = clientX + elementRef.current.offsetWidth;
|
|
4306
|
+
if (width > containerRef.current.offsetWidth) {
|
|
4307
|
+
clientX =
|
|
4308
|
+
containerRef.current.offsetWidth - elementRef.current.offsetWidth;
|
|
4070
4309
|
}
|
|
4071
4310
|
}
|
|
4072
4311
|
return clientX;
|
|
4073
|
-
}
|
|
4074
|
-
|
|
4312
|
+
}
|
|
4313
|
+
function getClientY(positionY) {
|
|
4075
4314
|
let clientY = position.current.y + positionY - dragOffset.current.y;
|
|
4076
4315
|
if (clientY < 0) {
|
|
4077
4316
|
clientY = 0;
|
|
4078
4317
|
}
|
|
4079
4318
|
else {
|
|
4080
|
-
const height = clientY +
|
|
4081
|
-
if (height >
|
|
4082
|
-
clientY =
|
|
4319
|
+
const height = clientY + elementRef.current.offsetHeight;
|
|
4320
|
+
if (height > containerRef.current.offsetHeight) {
|
|
4321
|
+
clientY =
|
|
4322
|
+
containerRef.current.offsetHeight - elementRef.current.offsetHeight;
|
|
4083
4323
|
}
|
|
4084
4324
|
}
|
|
4085
4325
|
return clientY;
|
|
4086
|
-
}
|
|
4087
|
-
const start = require$$0.
|
|
4326
|
+
}
|
|
4327
|
+
const start = require$$0.useEffectEvent((positionX, positionY) => {
|
|
4088
4328
|
dragOffset.current = {
|
|
4089
4329
|
x: positionX,
|
|
4090
4330
|
y: positionY
|
|
4091
4331
|
};
|
|
4092
4332
|
position.current = {
|
|
4093
|
-
x:
|
|
4094
|
-
y:
|
|
4333
|
+
x: elementRef.current.offsetLeft,
|
|
4334
|
+
y: elementRef.current.offsetTop
|
|
4095
4335
|
};
|
|
4096
4336
|
dragging.current = true;
|
|
4097
|
-
}
|
|
4098
|
-
const relocation = require$$0.
|
|
4337
|
+
});
|
|
4338
|
+
const relocation = require$$0.useEffectEvent((positionX, positionY) => {
|
|
4099
4339
|
const clientX = getClientX(positionX);
|
|
4100
4340
|
const clientY = getClientY(positionY);
|
|
4101
|
-
|
|
4102
|
-
|
|
4341
|
+
elementRef.current.style.top = `${clientY}px`;
|
|
4342
|
+
elementRef.current.style.left = `${clientX}px`;
|
|
4103
4343
|
onDrag?.();
|
|
4104
|
-
}
|
|
4344
|
+
});
|
|
4105
4345
|
require$$0.useEffect(() => {
|
|
4106
4346
|
const mousedown = (event) => {
|
|
4107
4347
|
start(event.clientX, event.clientY);
|
|
@@ -4129,30 +4369,28 @@ function useRelocationOnComponent({ container, element, onDrag }) {
|
|
|
4129
4369
|
const touchend = () => {
|
|
4130
4370
|
dragging.current = false;
|
|
4131
4371
|
};
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4372
|
+
elementRef.current.addEventListener('mousedown', mousedown);
|
|
4373
|
+
elementRef.current.addEventListener('mousemove', mousemove);
|
|
4374
|
+
elementRef.current.addEventListener('mouseup', mouseup);
|
|
4375
|
+
elementRef.current.addEventListener('touchstart', touchstart);
|
|
4376
|
+
elementRef.current.addEventListener('touchmove', touchmove);
|
|
4377
|
+
elementRef.current.addEventListener('touchend', touchend);
|
|
4138
4378
|
return () => {
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4379
|
+
elementRef.current?.removeEventListener('mousedown', mousedown);
|
|
4380
|
+
elementRef.current?.removeEventListener('mousemove', mousemove);
|
|
4381
|
+
elementRef.current?.removeEventListener('mouseup', mouseup);
|
|
4382
|
+
elementRef.current?.removeEventListener('touchstart', touchstart);
|
|
4383
|
+
elementRef.current?.removeEventListener('touchmove', touchmove);
|
|
4384
|
+
elementRef.current?.removeEventListener('touchend', touchend);
|
|
4145
4385
|
};
|
|
4146
4386
|
}, []);
|
|
4147
4387
|
}
|
|
4148
4388
|
|
|
4149
4389
|
function useResize({ refElement, onResize }) {
|
|
4150
4390
|
const dimension = require$$0.useRef({ height: 0, width: 0 });
|
|
4151
|
-
const
|
|
4152
|
-
onResizeRef.current = onResize;
|
|
4153
|
-
const observer = require$$0.useCallback((entries) => {
|
|
4391
|
+
const observer = require$$0.useEffectEvent((entries) => {
|
|
4154
4392
|
const { height, width } = entries[0].contentRect;
|
|
4155
|
-
|
|
4393
|
+
onResize?.({
|
|
4156
4394
|
current: dimension.current,
|
|
4157
4395
|
dimension: {
|
|
4158
4396
|
height,
|
|
@@ -4160,13 +4398,13 @@ function useResize({ refElement, onResize }) {
|
|
|
4160
4398
|
}
|
|
4161
4399
|
});
|
|
4162
4400
|
dimension.current = { height, width };
|
|
4163
|
-
}
|
|
4401
|
+
});
|
|
4164
4402
|
require$$0.useEffect(() => {
|
|
4165
4403
|
dimension.current = {
|
|
4166
4404
|
height: refElement.current.offsetHeight,
|
|
4167
4405
|
width: refElement.current.offsetWidth
|
|
4168
4406
|
};
|
|
4169
|
-
const resizeObserver = new ResizeObserver(observer);
|
|
4407
|
+
const resizeObserver = new ResizeObserver((entries) => observer(entries));
|
|
4170
4408
|
resizeObserver.observe(refElement.current);
|
|
4171
4409
|
return () => {
|
|
4172
4410
|
resizeObserver.disconnect();
|
|
@@ -4854,6 +5092,12 @@ exports.RlsButtonToggle = RlsButtonToggle;
|
|
|
4854
5092
|
exports.RlsCard = RlsCard;
|
|
4855
5093
|
exports.RlsCheckBox = RlsCheckBox;
|
|
4856
5094
|
exports.RlsCheckBoxControl = RlsCheckBoxControl;
|
|
5095
|
+
exports.RlsChooserAutocomplete = RlsChooserAutocomplete;
|
|
5096
|
+
exports.RlsChooserAutocompleteTemplate = RlsChooserAutocompleteTemplate;
|
|
5097
|
+
exports.RlsChooserList = RlsChooserList;
|
|
5098
|
+
exports.RlsChooserListTemplate = RlsChooserListTemplate;
|
|
5099
|
+
exports.RlsChooserSelect = RlsChooserSelect;
|
|
5100
|
+
exports.RlsChooserSelectTemplate = RlsChooserSelectTemplate;
|
|
4857
5101
|
exports.RlsConfirmation = RlsConfirmation;
|
|
4858
5102
|
exports.RlsContent = RlsContent;
|
|
4859
5103
|
exports.RlsContext = RlsContext;
|
|
@@ -4888,7 +5132,6 @@ exports.RlsFieldSelect = RlsFieldSelect;
|
|
|
4888
5132
|
exports.RlsFieldSelectTemplate = RlsFieldSelectTemplate;
|
|
4889
5133
|
exports.RlsFieldText = RlsFieldText;
|
|
4890
5134
|
exports.RlsFormNavigation = RlsFormNavigation;
|
|
4891
|
-
exports.RlsHoverSwap = RlsHoverSwap;
|
|
4892
5135
|
exports.RlsIcon = RlsIcon;
|
|
4893
5136
|
exports.RlsImage = RlsImage;
|
|
4894
5137
|
exports.RlsImageChooser = RlsImageChooser;
|