@rolster/react-components 19.7.13 → 19.8.16
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 +791 -542
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +788 -545
- 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 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
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: {}};
|
|
@@ -1638,6 +1638,89 @@ const reactI18n = i18n.i18n({
|
|
|
1638
1638
|
}
|
|
1639
1639
|
});
|
|
1640
1640
|
|
|
1641
|
+
function getScrollableAncestors(element) {
|
|
1642
|
+
const ancestors = [];
|
|
1643
|
+
let parent = element.parentElement;
|
|
1644
|
+
while (parent && parent !== document.body) {
|
|
1645
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(parent);
|
|
1646
|
+
if (/auto|scroll|hidden/.test(`${overflow}${overflowX}${overflowY}`)) {
|
|
1647
|
+
ancestors.push(parent);
|
|
1648
|
+
}
|
|
1649
|
+
parent = parent.parentElement;
|
|
1650
|
+
}
|
|
1651
|
+
return ancestors;
|
|
1652
|
+
}
|
|
1653
|
+
function anchorIsVisible(rect, scrollables) {
|
|
1654
|
+
if (!rect.width || !rect.height) {
|
|
1655
|
+
return false;
|
|
1656
|
+
}
|
|
1657
|
+
let top = 0;
|
|
1658
|
+
let left = 0;
|
|
1659
|
+
let bottom = window.innerHeight;
|
|
1660
|
+
let right = window.innerWidth;
|
|
1661
|
+
for (const scrollable of scrollables) {
|
|
1662
|
+
const scrollableRect = scrollable.getBoundingClientRect();
|
|
1663
|
+
top = Math.max(top, scrollableRect.top);
|
|
1664
|
+
left = Math.max(left, scrollableRect.left);
|
|
1665
|
+
bottom = Math.min(bottom, scrollableRect.bottom);
|
|
1666
|
+
right = Math.min(right, scrollableRect.right);
|
|
1667
|
+
}
|
|
1668
|
+
return (rect.bottom > top &&
|
|
1669
|
+
rect.top < bottom &&
|
|
1670
|
+
rect.right > left &&
|
|
1671
|
+
rect.left < right);
|
|
1672
|
+
}
|
|
1673
|
+
function useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor) {
|
|
1674
|
+
const [mounted, setMounted] = require$$0.useState(false);
|
|
1675
|
+
const [style, setStyle] = require$$0.useState();
|
|
1676
|
+
const [theme, setTheme] = require$$0.useState();
|
|
1677
|
+
require$$0.useEffect(() => {
|
|
1678
|
+
setMounted(true);
|
|
1679
|
+
}, []);
|
|
1680
|
+
const onAnchorHidden = require$$0.useEffectEvent(() => {
|
|
1681
|
+
onHiddenAnchor?.();
|
|
1682
|
+
});
|
|
1683
|
+
require$$0.useEffect(() => {
|
|
1684
|
+
const anchor = refAnchor?.current;
|
|
1685
|
+
if (!mounted || !visible || !anchor) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
setTheme((anchor.closest('[rls-theme]')?.getAttribute('rls-theme') ??
|
|
1689
|
+
undefined));
|
|
1690
|
+
const scrollables = getScrollableAncestors(anchor);
|
|
1691
|
+
let frame = 0;
|
|
1692
|
+
function reposition() {
|
|
1693
|
+
if (!anchor) {
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
const rect = anchor.getBoundingClientRect();
|
|
1697
|
+
if (!anchorIsVisible(rect, scrollables)) {
|
|
1698
|
+
onAnchorHidden();
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
setStyle({
|
|
1702
|
+
'--pvt-portal-top': `${rect.bottom}px`,
|
|
1703
|
+
'--pvt-portal-bottom': `${window.innerHeight - rect.top}px`,
|
|
1704
|
+
'--pvt-portal-left': `${rect.left}px`,
|
|
1705
|
+
'--pvt-portal-width': `${rect.width}px`
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
function requestReposition() {
|
|
1709
|
+
cancelAnimationFrame(frame);
|
|
1710
|
+
frame = requestAnimationFrame(reposition);
|
|
1711
|
+
}
|
|
1712
|
+
reposition();
|
|
1713
|
+
window.addEventListener('scroll', requestReposition, true);
|
|
1714
|
+
window.addEventListener('resize', requestReposition);
|
|
1715
|
+
return () => {
|
|
1716
|
+
cancelAnimationFrame(frame);
|
|
1717
|
+
window.removeEventListener('scroll', requestReposition, true);
|
|
1718
|
+
window.removeEventListener('resize', requestReposition);
|
|
1719
|
+
};
|
|
1720
|
+
}, [mounted, visible, refAnchor]);
|
|
1721
|
+
return { active: mounted && !!refAnchor, style, theme };
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1641
1724
|
function RlsFieldListLi({ element, onClickElement, onKeydownElement, render }) {
|
|
1642
1725
|
const onClick = require$$0.useMemo(() => {
|
|
1643
1726
|
return onClickElement(element);
|
|
@@ -1647,7 +1730,8 @@ function RlsFieldListLi({ element, onClickElement, onKeydownElement, render }) {
|
|
|
1647
1730
|
}, [element, onKeydownElement]);
|
|
1648
1731
|
return (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: onClick, onKeyDown: onKeyDown, children: render(element) }));
|
|
1649
1732
|
}
|
|
1650
|
-
function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher, render, renderEmpty, searchControl, visible, onClickBackdrop, onClickElement, onKeydownElement, refList, rlsTheme }) {
|
|
1733
|
+
function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher, render, renderEmpty, searchControl, visible, onClickBackdrop, onClickElement, onHiddenAnchor, onKeydownElement, refAnchor, refList, refSuggestions, rlsTheme }) {
|
|
1734
|
+
const portal = useSuggestionsPortalController(visible, refAnchor, onHiddenAnchor);
|
|
1651
1735
|
const [labels, setLabels] = require$$0.useState({
|
|
1652
1736
|
listEmptyDescription: reactI18n('listEmptyDescription'),
|
|
1653
1737
|
listEmptyTitle: reactI18n('listEmptyTitle')
|
|
@@ -1663,6 +1747,7 @@ function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher,
|
|
|
1663
1747
|
const className = renderClassStatus('rls-field-list__suggestions', {
|
|
1664
1748
|
disabled,
|
|
1665
1749
|
higher,
|
|
1750
|
+
portal: portal.active,
|
|
1666
1751
|
visible
|
|
1667
1752
|
});
|
|
1668
1753
|
const onChangePattern = require$$0.useCallback((event) => {
|
|
@@ -1675,7 +1760,8 @@ function RlsFieldListSuggestionsComponent({ elements, action, disabled, higher,
|
|
|
1675
1760
|
}
|
|
1676
1761
|
}, [action?.onClick, action?.keepOpen, onClickBackdrop]);
|
|
1677
1762
|
const searching = searchControl?.searching ?? false;
|
|
1678
|
-
|
|
1763
|
+
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 })] }));
|
|
1764
|
+
return portal.active ? ReactDOM.createPortal(suggestions, document.body) : suggestions;
|
|
1679
1765
|
}
|
|
1680
1766
|
const RlsFieldListSuggestions = require$$0.memo(RlsFieldListSuggestionsComponent);
|
|
1681
1767
|
|
|
@@ -2377,161 +2463,6 @@ function RlsCardComponent({ children, className, outline, rlsTheme }) {
|
|
|
2377
2463
|
}
|
|
2378
2464
|
const RlsCard = require$$0.memo(RlsCardComponent);
|
|
2379
2465
|
|
|
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
2466
|
const MAX_LIST_HEIGHT_REM$1 = 90;
|
|
2536
2467
|
const FALLBACK_REM_SIZE$1 = 16;
|
|
2537
2468
|
function getRemSize$1() {
|
|
@@ -2573,6 +2504,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2573
2504
|
const refContent = require$$0.useRef(null);
|
|
2574
2505
|
const refList = require$$0.useRef(null);
|
|
2575
2506
|
const refInput = require$$0.useRef(null);
|
|
2507
|
+
const refSuggestions = require$$0.useRef(null);
|
|
2576
2508
|
const listIsOpen = require$$0.useRef(false);
|
|
2577
2509
|
const stableSuggestions = useStableSuggestions(suggestions);
|
|
2578
2510
|
const collection = require$$0.useMemo(() => new components.ListCollection(stableSuggestions, reference), [stableSuggestions, reference]);
|
|
@@ -2587,7 +2519,8 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2587
2519
|
const valueProtected = require$$0.useRef(undefined);
|
|
2588
2520
|
require$$0.useEffect(() => {
|
|
2589
2521
|
function onCloseSuggestions({ target }) {
|
|
2590
|
-
if (!refContent?.current?.contains(target)
|
|
2522
|
+
if (!refContent?.current?.contains(target) &&
|
|
2523
|
+
!refSuggestions?.current?.contains(target)) {
|
|
2591
2524
|
refreshState((state) => ({ ...state, listIsVisible: false }));
|
|
2592
2525
|
}
|
|
2593
2526
|
}
|
|
@@ -2604,7 +2537,29 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2604
2537
|
formControl?.touch();
|
|
2605
2538
|
}
|
|
2606
2539
|
}, [state.listIsVisible]);
|
|
2607
|
-
require$$0.
|
|
2540
|
+
const setState = require$$0.useCallback((state) => {
|
|
2541
|
+
const newState = state.listIsVisible
|
|
2542
|
+
? {
|
|
2543
|
+
...state,
|
|
2544
|
+
higher: shouldDisplayHigher$1(refContent.current, refList.current)
|
|
2545
|
+
}
|
|
2546
|
+
: state;
|
|
2547
|
+
refreshState((currentState) => ({ ...currentState, ...newState }));
|
|
2548
|
+
}, []);
|
|
2549
|
+
const setFormValue = require$$0.useCallback((element, valueIsDefault = false) => {
|
|
2550
|
+
refreshState((state) => ({
|
|
2551
|
+
...state,
|
|
2552
|
+
value: element?.description || ''
|
|
2553
|
+
}));
|
|
2554
|
+
changeValueInternal.current = true;
|
|
2555
|
+
if (valueIsDefault) {
|
|
2556
|
+
formControl?.setDefaultValue(element?.value);
|
|
2557
|
+
}
|
|
2558
|
+
else {
|
|
2559
|
+
formControl?.setValue(element?.value);
|
|
2560
|
+
}
|
|
2561
|
+
}, [formControl]);
|
|
2562
|
+
const reconcileFormValue = require$$0.useEffectEvent(() => {
|
|
2608
2563
|
if (!changeValueInternal.current) {
|
|
2609
2564
|
if (formControl?.value) {
|
|
2610
2565
|
const element = collection.find(formControl.value);
|
|
@@ -2640,29 +2595,10 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2640
2595
|
}
|
|
2641
2596
|
}
|
|
2642
2597
|
changeValueInternal.current = false;
|
|
2598
|
+
});
|
|
2599
|
+
require$$0.useEffect(() => {
|
|
2600
|
+
reconcileFormValue();
|
|
2643
2601
|
}, [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
2602
|
const navigationInput = require$$0.useCallback((event) => {
|
|
2667
2603
|
if (state.listIsVisible) {
|
|
2668
2604
|
const newPosition = components.navigationListFromInput({
|
|
@@ -2691,6 +2627,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2691
2627
|
refContent,
|
|
2692
2628
|
refInput,
|
|
2693
2629
|
refList,
|
|
2630
|
+
refSuggestions,
|
|
2694
2631
|
setFormValue,
|
|
2695
2632
|
setState
|
|
2696
2633
|
}), [state, navigationElement, navigationInput, setFormValue, setState]);
|
|
@@ -2852,9 +2789,9 @@ function useFieldAutocomplete(props) {
|
|
|
2852
2789
|
]);
|
|
2853
2790
|
}
|
|
2854
2791
|
|
|
2855
|
-
function
|
|
2792
|
+
function RlsChooserAutocompleteTemplateComponent(props) {
|
|
2856
2793
|
const autocomplete = useFieldAutocomplete(props);
|
|
2857
|
-
const { render, action, children, formControl,
|
|
2794
|
+
const { render, action, children, formControl, onSearch, rlsTheme, searching } = props;
|
|
2858
2795
|
const [listInputPlaceholder, setListInputPlaceholder] = require$$0.useState(reactI18n('listInputPlaceholder'));
|
|
2859
2796
|
require$$0.useEffect(() => {
|
|
2860
2797
|
return i18n.i18nSubscribe(() => {
|
|
@@ -2867,13 +2804,11 @@ function RlsFieldAutocompleteTemplateComponent(props) {
|
|
|
2867
2804
|
const disabled = require$$0.useMemo(() => {
|
|
2868
2805
|
return formControl?.disabled || props.disabled;
|
|
2869
2806
|
}, [formControl?.disabled, props.disabled]);
|
|
2870
|
-
const className = renderClassStatus('rls-
|
|
2807
|
+
const className = renderClassStatus('rls-chooser', {
|
|
2871
2808
|
focused: autocomplete.focused && !disabled,
|
|
2872
|
-
|
|
2873
|
-
disabled
|
|
2874
|
-
|
|
2875
|
-
selected: !!autocomplete.value
|
|
2876
|
-
}, `rls-field-list rls-field-autocomplete ${props.className ?? ''}`);
|
|
2809
|
+
visible: autocomplete.listIsVisible,
|
|
2810
|
+
disabled
|
|
2811
|
+
}, `rls-chooser-autocomplete ${props.className ?? ''}`);
|
|
2877
2812
|
const onClickPattern = require$$0.useCallback(() => {
|
|
2878
2813
|
onSearch?.(autocomplete.pattern);
|
|
2879
2814
|
}, [onSearch, autocomplete.pattern]);
|
|
@@ -2883,6 +2818,18 @@ function RlsFieldAutocompleteTemplateComponent(props) {
|
|
|
2883
2818
|
}
|
|
2884
2819
|
autocomplete.onKeydownInput(event);
|
|
2885
2820
|
}, [autocomplete.onKeydownInput, onSearch, autocomplete.pattern]);
|
|
2821
|
+
const onKeydownTrigger = require$$0.useCallback((event) => {
|
|
2822
|
+
switch (event.code) {
|
|
2823
|
+
case 'Space':
|
|
2824
|
+
case 'Enter':
|
|
2825
|
+
event.preventDefault();
|
|
2826
|
+
autocomplete.onClickControl();
|
|
2827
|
+
break;
|
|
2828
|
+
case 'Escape':
|
|
2829
|
+
autocomplete.onClickBackdrop();
|
|
2830
|
+
break;
|
|
2831
|
+
}
|
|
2832
|
+
}, [autocomplete.onClickControl, autocomplete.onClickBackdrop]);
|
|
2886
2833
|
const searchControl = require$$0.useMemo(() => ({
|
|
2887
2834
|
pattern: autocomplete.pattern,
|
|
2888
2835
|
placeholder: listInputPlaceholder,
|
|
@@ -2905,24 +2852,582 @@ function RlsFieldAutocompleteTemplateComponent(props) {
|
|
|
2905
2852
|
onClickPattern,
|
|
2906
2853
|
onSearch
|
|
2907
2854
|
]);
|
|
2908
|
-
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.refContent, className: className, "rls-theme": rlsTheme, children: [
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2855
|
+
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'
|
|
2856
|
+
? children({
|
|
2857
|
+
description: autocomplete.value,
|
|
2858
|
+
listIsVisible: autocomplete.listIsVisible,
|
|
2859
|
+
pattern: autocomplete.pattern,
|
|
2860
|
+
value: formControl?.value ?? props.value
|
|
2861
|
+
})
|
|
2862
|
+
: 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 })] }));
|
|
2863
|
+
}
|
|
2864
|
+
const RlsChooserAutocompleteTemplate = require$$0.memo(RlsChooserAutocompleteTemplateComponent);
|
|
2865
|
+
function RlsChooserAutocompleteComponent(props) {
|
|
2912
2866
|
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(
|
|
2867
|
+
return jsxRuntimeExports.jsx(RlsChooserAutocompleteTemplate, { ...props, render: render });
|
|
2914
2868
|
}
|
|
2915
|
-
const
|
|
2869
|
+
const RlsChooserAutocomplete = require$$0.memo(RlsChooserAutocompleteComponent);
|
|
2916
2870
|
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2871
|
+
const MAX_LIST_HEIGHT_REM = 90;
|
|
2872
|
+
const FALLBACK_REM_SIZE = 16;
|
|
2873
|
+
function getRemSize() {
|
|
2874
|
+
if (typeof window === 'undefined') {
|
|
2875
|
+
return FALLBACK_REM_SIZE;
|
|
2876
|
+
}
|
|
2877
|
+
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
2878
|
+
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE;
|
|
2879
|
+
}
|
|
2880
|
+
function shouldDisplayHigher(content, list) {
|
|
2881
|
+
if (!content) {
|
|
2882
|
+
return false;
|
|
2883
|
+
}
|
|
2884
|
+
const { top, bottom } = content.getBoundingClientRect();
|
|
2885
|
+
const spaceAbove = top;
|
|
2886
|
+
const spaceBelow = window.innerHeight - bottom;
|
|
2887
|
+
const maxHeight = MAX_LIST_HEIGHT_REM * getRemSize();
|
|
2888
|
+
const desiredHeight = Math.min(list?.scrollHeight || maxHeight, maxHeight);
|
|
2889
|
+
if (spaceBelow >= desiredHeight) {
|
|
2890
|
+
return false;
|
|
2891
|
+
}
|
|
2892
|
+
if (spaceAbove >= desiredHeight) {
|
|
2893
|
+
return true;
|
|
2894
|
+
}
|
|
2895
|
+
return spaceAbove > spaceBelow;
|
|
2896
|
+
}
|
|
2897
|
+
function useFieldList(props) {
|
|
2898
|
+
const { suggestions, disabled } = props;
|
|
2899
|
+
const refContent = require$$0.useRef(null);
|
|
2900
|
+
const refList = require$$0.useRef(null);
|
|
2901
|
+
const refSuggestions = require$$0.useRef(null);
|
|
2902
|
+
const formControl = props.formControl;
|
|
2903
|
+
const [state, setState] = require$$0.useState({
|
|
2904
|
+
higher: false,
|
|
2905
|
+
listIsVisible: false
|
|
2906
|
+
});
|
|
2907
|
+
const [selected, setSelected] = require$$0.useState([]);
|
|
2908
|
+
require$$0.useEffect(() => {
|
|
2909
|
+
function onCloseSuggestions({ target }) {
|
|
2910
|
+
if (!refContent?.current?.contains(target) &&
|
|
2911
|
+
!refSuggestions?.current?.contains(target)) {
|
|
2912
|
+
setState((state) => ({ ...state, listIsVisible: false }));
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
document.addEventListener('click', onCloseSuggestions);
|
|
2916
|
+
return () => {
|
|
2917
|
+
document.removeEventListener('click', onCloseSuggestions);
|
|
2918
|
+
};
|
|
2919
|
+
}, []);
|
|
2920
|
+
require$$0.useEffect(() => {
|
|
2921
|
+
const formValue = formControl?.value;
|
|
2922
|
+
if (formValue !== undefined && formValue !== null && formValue.length) {
|
|
2923
|
+
setSelected(suggestions.filter((state) => formValue.some((value) => state.compareTo(value))));
|
|
2924
|
+
}
|
|
2925
|
+
else {
|
|
2926
|
+
setSelected([]);
|
|
2927
|
+
}
|
|
2928
|
+
}, [formControl?.value, suggestions]);
|
|
2929
|
+
const setListState = require$$0.useCallback((controllerState) => {
|
|
2930
|
+
setState((state) => {
|
|
2931
|
+
const newState = controllerState.listIsVisible !== undefined
|
|
2932
|
+
? {
|
|
2933
|
+
...controllerState,
|
|
2934
|
+
...(controllerState.listIsVisible
|
|
2935
|
+
? {
|
|
2936
|
+
higher: shouldDisplayHigher(refContent.current, refList.current)
|
|
2937
|
+
}
|
|
2938
|
+
: {})
|
|
2939
|
+
}
|
|
2940
|
+
: controllerState;
|
|
2941
|
+
return { ...state, ...newState };
|
|
2942
|
+
});
|
|
2943
|
+
}, []);
|
|
2944
|
+
const toggleElement = require$$0.useCallback((element) => {
|
|
2945
|
+
const alreadySelected = selected.some((state) => state.compareTo(element.value));
|
|
2946
|
+
const newSelected = alreadySelected
|
|
2947
|
+
? selected.filter((state) => !state.compareTo(element.value))
|
|
2948
|
+
: [...selected, element];
|
|
2949
|
+
const newValues = newSelected.map((state) => state.value);
|
|
2950
|
+
setSelected(newSelected);
|
|
2951
|
+
formControl?.setValue(newValues);
|
|
2952
|
+
props.onValue?.(newValues);
|
|
2953
|
+
}, [selected, formControl, props.onValue]);
|
|
2954
|
+
const isSelected = require$$0.useCallback((element) => {
|
|
2955
|
+
return selected.some((state) => state.compareTo(element.value));
|
|
2956
|
+
}, [selected]);
|
|
2957
|
+
const onClickInput = require$$0.useCallback(() => {
|
|
2958
|
+
if (!props.readOnly) {
|
|
2959
|
+
setListState({ listIsVisible: true });
|
|
2960
|
+
}
|
|
2961
|
+
}, [setListState, props.readOnly]);
|
|
2962
|
+
const onClickBackdrop = require$$0.useCallback(() => {
|
|
2963
|
+
setListState({ listIsVisible: false });
|
|
2964
|
+
}, [setListState]);
|
|
2965
|
+
const onClickAction = require$$0.useCallback(() => {
|
|
2966
|
+
if (!disabled && !props.readOnly) {
|
|
2967
|
+
setListState({ listIsVisible: !state.listIsVisible });
|
|
2968
|
+
}
|
|
2969
|
+
}, [disabled, props.readOnly, setListState, state.listIsVisible]);
|
|
2970
|
+
const onClickElement = require$$0.useCallback((element) => {
|
|
2971
|
+
return () => {
|
|
2972
|
+
toggleElement(element);
|
|
2973
|
+
};
|
|
2974
|
+
}, [toggleElement]);
|
|
2975
|
+
const onRemoveElement = require$$0.useCallback((element) => {
|
|
2976
|
+
return (event) => {
|
|
2977
|
+
event.stopPropagation();
|
|
2978
|
+
const newSelected = selected.filter((state) => !state.compareTo(element.value));
|
|
2979
|
+
const newValues = newSelected.map((state) => state.value);
|
|
2980
|
+
setSelected(newSelected);
|
|
2981
|
+
formControl?.setValue(newValues);
|
|
2982
|
+
props.onValue?.(newValues);
|
|
2983
|
+
};
|
|
2984
|
+
}, [selected, formControl, props.onValue]);
|
|
2985
|
+
const onKeydownElement = require$$0.useCallback((element) => {
|
|
2986
|
+
return (event) => {
|
|
2987
|
+
if (event.code === 'Enter') {
|
|
2988
|
+
toggleElement(element);
|
|
2989
|
+
}
|
|
2990
|
+
};
|
|
2991
|
+
}, [toggleElement]);
|
|
2992
|
+
return require$$0.useMemo(() => ({
|
|
2993
|
+
...state,
|
|
2994
|
+
selected,
|
|
2995
|
+
refContent,
|
|
2996
|
+
refList,
|
|
2997
|
+
refSuggestions,
|
|
2998
|
+
isSelected,
|
|
2999
|
+
onClickAction,
|
|
3000
|
+
onClickBackdrop,
|
|
3001
|
+
onClickElement,
|
|
3002
|
+
onClickInput,
|
|
3003
|
+
onKeydownElement,
|
|
3004
|
+
onRemoveElement
|
|
3005
|
+
}), [
|
|
3006
|
+
state,
|
|
3007
|
+
selected,
|
|
3008
|
+
isSelected,
|
|
3009
|
+
onClickAction,
|
|
3010
|
+
onClickBackdrop,
|
|
3011
|
+
onClickElement,
|
|
3012
|
+
onClickInput,
|
|
3013
|
+
onKeydownElement,
|
|
3014
|
+
onRemoveElement
|
|
3015
|
+
]);
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
function RlsChooserListTemplateComponent(props) {
|
|
3019
|
+
const fieldList = useFieldList(props);
|
|
3020
|
+
const { render, suggestions, action, children, formControl, rlsTheme } = props;
|
|
3021
|
+
const disabled = require$$0.useMemo(() => {
|
|
3022
|
+
return formControl?.disabled || props.disabled;
|
|
3023
|
+
}, [formControl?.disabled, props.disabled]);
|
|
3024
|
+
const className = renderClassStatus('rls-chooser', {
|
|
3025
|
+
visible: fieldList.listIsVisible,
|
|
3026
|
+
disabled
|
|
3027
|
+
}, `rls-chooser-list ${props.className ?? ''}`);
|
|
3028
|
+
const onKeydownTrigger = require$$0.useCallback((event) => {
|
|
3029
|
+
switch (event.code) {
|
|
3030
|
+
case 'Space':
|
|
3031
|
+
case 'Enter':
|
|
3032
|
+
event.preventDefault();
|
|
3033
|
+
fieldList.onClickAction();
|
|
3034
|
+
break;
|
|
3035
|
+
case 'Escape':
|
|
3036
|
+
fieldList.onClickBackdrop();
|
|
3037
|
+
break;
|
|
3038
|
+
}
|
|
3039
|
+
}, [fieldList.onClickAction, fieldList.onClickBackdrop]);
|
|
3040
|
+
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]);
|
|
3041
|
+
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'
|
|
3042
|
+
? children({
|
|
3043
|
+
listIsVisible: fieldList.listIsVisible,
|
|
3044
|
+
selected: fieldList.selected
|
|
3045
|
+
})
|
|
3046
|
+
: 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 })] }));
|
|
3047
|
+
}
|
|
3048
|
+
const RlsChooserListTemplate = require$$0.memo(RlsChooserListTemplateComponent);
|
|
3049
|
+
function RlsChooserListComponent(props) {
|
|
3050
|
+
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 }) })), []);
|
|
3051
|
+
return jsxRuntimeExports.jsx(RlsChooserListTemplate, { ...props, render: render });
|
|
3052
|
+
}
|
|
3053
|
+
const RlsChooserList = require$$0.memo(RlsChooserListComponent);
|
|
3054
|
+
|
|
3055
|
+
function useFieldSelect(props) {
|
|
3056
|
+
const controller = useListController(props);
|
|
3057
|
+
require$$0.useEffect(() => {
|
|
3058
|
+
if (props.disabled) {
|
|
3059
|
+
controller.setState({ focused: false });
|
|
3060
|
+
}
|
|
3061
|
+
}, [props.disabled]);
|
|
3062
|
+
const onFocusInput = require$$0.useCallback(() => {
|
|
3063
|
+
controller.setState({ focused: true });
|
|
3064
|
+
}, [controller.setState]);
|
|
3065
|
+
const onBlurInput = require$$0.useCallback(() => {
|
|
3066
|
+
controller.setState({ focused: false });
|
|
3067
|
+
}, [controller.setState]);
|
|
3068
|
+
const onClickInput = require$$0.useCallback(() => {
|
|
3069
|
+
if (!props.readOnly) {
|
|
3070
|
+
controller.setState({ listIsVisible: true });
|
|
3071
|
+
}
|
|
3072
|
+
}, [controller.setState, props.readOnly]);
|
|
3073
|
+
const onKeydownInput = require$$0.useCallback((event) => {
|
|
3074
|
+
switch (event.code) {
|
|
3075
|
+
case 'Space':
|
|
3076
|
+
case 'Enter':
|
|
3077
|
+
controller.setState({ listIsVisible: true });
|
|
3078
|
+
break;
|
|
3079
|
+
case 'Escape':
|
|
3080
|
+
case 'Tab':
|
|
3081
|
+
controller.setState({ listIsVisible: false });
|
|
3082
|
+
break;
|
|
3083
|
+
default:
|
|
3084
|
+
controller.navigationInput(event);
|
|
3085
|
+
break;
|
|
3086
|
+
}
|
|
3087
|
+
}, [controller.setState, controller.navigationInput]);
|
|
3088
|
+
const onClickAction = require$$0.useCallback(() => {
|
|
3089
|
+
const removable = !props.unremovable && !!controller.value;
|
|
3090
|
+
if (removable) {
|
|
3091
|
+
controller.setState({ listIsVisible: false });
|
|
3092
|
+
controller.setFormValue(undefined);
|
|
3093
|
+
props.onValue?.(props.value);
|
|
3094
|
+
}
|
|
3095
|
+
else {
|
|
3096
|
+
const listIsVisible = !controller.listIsVisible;
|
|
3097
|
+
controller.setState({ listIsVisible });
|
|
3098
|
+
if (listIsVisible) {
|
|
3099
|
+
controller.refInput?.current?.focus();
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
}, [
|
|
3103
|
+
controller.listIsVisible,
|
|
3104
|
+
controller.value,
|
|
3105
|
+
controller.setState,
|
|
3106
|
+
controller.setFormValue,
|
|
3107
|
+
props.unremovable,
|
|
3108
|
+
props.onValue
|
|
3109
|
+
]);
|
|
3110
|
+
const onClickBackdrop = require$$0.useCallback(() => {
|
|
3111
|
+
controller.setState({ listIsVisible: false });
|
|
3112
|
+
}, [controller.setState]);
|
|
3113
|
+
const onChange = require$$0.useCallback((element) => {
|
|
3114
|
+
if (!props.disabled) {
|
|
3115
|
+
controller.refInput?.current?.focus();
|
|
3116
|
+
}
|
|
3117
|
+
if (props.onSelect) {
|
|
3118
|
+
controller.setState({ listIsVisible: false });
|
|
3119
|
+
if (element.value) {
|
|
3120
|
+
props.onSelect(element.value);
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
else {
|
|
3124
|
+
controller.setFormValue(element);
|
|
3125
|
+
controller.setState({ listIsVisible: false });
|
|
3126
|
+
}
|
|
3127
|
+
props.onValue?.(element.value);
|
|
3128
|
+
}, [
|
|
3129
|
+
controller.setState,
|
|
3130
|
+
controller.setFormValue,
|
|
3131
|
+
props.onSelect,
|
|
3132
|
+
props.onValue,
|
|
3133
|
+
props.disabled
|
|
3134
|
+
]);
|
|
3135
|
+
const onClickElement = require$$0.useCallback((element) => {
|
|
3136
|
+
return () => {
|
|
3137
|
+
onChange(element);
|
|
3138
|
+
};
|
|
3139
|
+
}, [onChange]);
|
|
3140
|
+
const onKeydownElement = require$$0.useCallback((element) => {
|
|
3141
|
+
return (event) => {
|
|
3142
|
+
if (event.code === 'Enter') {
|
|
3143
|
+
onChange(element);
|
|
3144
|
+
}
|
|
3145
|
+
else {
|
|
3146
|
+
controller.navigationElement(event);
|
|
3147
|
+
}
|
|
3148
|
+
};
|
|
3149
|
+
}, [onChange, controller.navigationElement]);
|
|
3150
|
+
return require$$0.useMemo(() => ({
|
|
3151
|
+
...controller,
|
|
3152
|
+
onBlurInput,
|
|
3153
|
+
onClickAction,
|
|
3154
|
+
onClickBackdrop,
|
|
3155
|
+
onClickInput,
|
|
3156
|
+
onClickElement,
|
|
3157
|
+
onFocusInput,
|
|
3158
|
+
onKeydownElement,
|
|
3159
|
+
onKeydownInput
|
|
3160
|
+
}), [
|
|
3161
|
+
controller,
|
|
3162
|
+
onBlurInput,
|
|
3163
|
+
onClickAction,
|
|
3164
|
+
onClickBackdrop,
|
|
3165
|
+
onClickInput,
|
|
3166
|
+
onClickElement,
|
|
3167
|
+
onFocusInput,
|
|
3168
|
+
onKeydownElement,
|
|
3169
|
+
onKeydownInput
|
|
3170
|
+
]);
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
function RlsChooserSelectTemplateComponent(props) {
|
|
3174
|
+
const select = useFieldSelect({ ...props, unremovable: true });
|
|
3175
|
+
const { render, suggestions, action, children, formControl, rlsTheme } = props;
|
|
3176
|
+
const disabled = require$$0.useMemo(() => {
|
|
3177
|
+
return formControl?.disabled || props.disabled;
|
|
3178
|
+
}, [formControl?.disabled, props.disabled]);
|
|
3179
|
+
const className = renderClassStatus('rls-chooser', {
|
|
3180
|
+
focused: select.focused && !disabled,
|
|
3181
|
+
visible: select.listIsVisible,
|
|
3182
|
+
disabled
|
|
3183
|
+
}, `rls-chooser-select ${props.className ?? ''}`);
|
|
3184
|
+
const onKeydownTrigger = require$$0.useCallback((event) => {
|
|
3185
|
+
if (event.code === 'Space') {
|
|
3186
|
+
event.preventDefault();
|
|
3187
|
+
}
|
|
3188
|
+
select.onKeydownInput(event);
|
|
3189
|
+
}, [select.onKeydownInput]);
|
|
3190
|
+
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'
|
|
3191
|
+
? children({
|
|
3192
|
+
description: select.value,
|
|
3193
|
+
listIsVisible: select.listIsVisible,
|
|
3194
|
+
value: formControl?.value ?? props.value
|
|
3195
|
+
})
|
|
3196
|
+
: 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 })] }));
|
|
3197
|
+
}
|
|
3198
|
+
const RlsChooserSelectTemplate = require$$0.memo(RlsChooserSelectTemplateComponent);
|
|
3199
|
+
function RlsChooserSelectComponent(props) {
|
|
3200
|
+
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 }) })), []);
|
|
3201
|
+
return jsxRuntimeExports.jsx(RlsChooserSelectTemplate, { ...props, render: render });
|
|
3202
|
+
}
|
|
3203
|
+
const RlsChooserSelect = require$$0.memo(RlsChooserSelectComponent);
|
|
3204
|
+
|
|
3205
|
+
class ConfirmationResult extends commons.SealedPartial {
|
|
3206
|
+
static approved() {
|
|
3207
|
+
return new ConfirmationResult('approved');
|
|
3208
|
+
}
|
|
3209
|
+
static reject() {
|
|
3210
|
+
return new ConfirmationResult('reject');
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
function RlsConfirmationComponent({ approved, className, content, reject, rlsTheme, subtitle, title, visible }) {
|
|
3214
|
+
const classConfirmation = renderClassStatus('rls-confirmation', { visible }, className);
|
|
3215
|
+
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" })] }));
|
|
3216
|
+
}
|
|
3217
|
+
const RlsConfirmation = require$$0.memo(RlsConfirmationComponent);
|
|
3218
|
+
const RlsConfirmationBase = RlsConfirmation;
|
|
3219
|
+
function useConfirmation() {
|
|
3220
|
+
const [config, setConfig] = require$$0.useState({});
|
|
3221
|
+
const [visible, setVisible] = require$$0.useState(false);
|
|
3222
|
+
const configRef = require$$0.useRef(config);
|
|
3223
|
+
configRef.current = config;
|
|
3224
|
+
const visibleRef = require$$0.useRef(visible);
|
|
3225
|
+
visibleRef.current = visible;
|
|
3226
|
+
const RlsConfirmation = require$$0.useMemo(() => {
|
|
3227
|
+
return function RlsConfirmation(props) {
|
|
3228
|
+
return ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmationBase, { ...props, ...configRef.current, visible: visibleRef.current }), document.body);
|
|
3229
|
+
};
|
|
3230
|
+
}, []);
|
|
3231
|
+
const confirmation = require$$0.useCallback((options) => {
|
|
3232
|
+
return new Promise((resolve) => {
|
|
3233
|
+
setConfig({
|
|
3234
|
+
...options,
|
|
3235
|
+
approved: {
|
|
3236
|
+
label: options.approved?.label ?? reactI18n('confirmationActionApproved'),
|
|
3237
|
+
onClick: () => {
|
|
3238
|
+
setVisible(false);
|
|
3239
|
+
resolve(ConfirmationResult.approved());
|
|
3240
|
+
},
|
|
3241
|
+
type: options.approved?.type ?? 'raised',
|
|
3242
|
+
disabled: options.approved?.disabled,
|
|
3243
|
+
identifier: options.approved?.identifier,
|
|
3244
|
+
rlsTheme: options.approved?.rlsTheme
|
|
3245
|
+
},
|
|
3246
|
+
reject: options.reject
|
|
3247
|
+
? {
|
|
3248
|
+
label: options.reject.label,
|
|
3249
|
+
onClick: () => {
|
|
3250
|
+
setVisible(false);
|
|
3251
|
+
resolve(ConfirmationResult.reject());
|
|
3252
|
+
},
|
|
3253
|
+
type: options.reject.type ?? 'flat',
|
|
3254
|
+
disabled: options.reject.disabled,
|
|
3255
|
+
identifier: options.reject.identifier,
|
|
3256
|
+
rlsTheme: options.reject.rlsTheme
|
|
3257
|
+
}
|
|
3258
|
+
: undefined
|
|
3259
|
+
});
|
|
3260
|
+
setVisible(true);
|
|
3261
|
+
});
|
|
3262
|
+
}, []);
|
|
3263
|
+
return {
|
|
3264
|
+
confirmation,
|
|
3265
|
+
RlsConfirmation
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
function createObserver(options) {
|
|
3270
|
+
const { setScrolleable, table } = options;
|
|
3271
|
+
const observer = new ResizeObserver(() => {
|
|
3272
|
+
const scrollHeight = table.scrollHeight || 0;
|
|
3273
|
+
const clientHeight = table.clientHeight || 0;
|
|
3274
|
+
setScrolleable(scrollHeight > clientHeight);
|
|
3275
|
+
});
|
|
3276
|
+
observer.observe(table);
|
|
3277
|
+
return observer;
|
|
3278
|
+
}
|
|
3279
|
+
function useDatatable(table) {
|
|
3280
|
+
const [scrolleable, setScrolleable] = require$$0.useState(false);
|
|
3281
|
+
const refTable = require$$0.useRef(table ? table : null);
|
|
3282
|
+
require$$0.useEffect(() => {
|
|
3283
|
+
const observer = refTable.current &&
|
|
3284
|
+
createObserver({ setScrolleable, table: refTable.current });
|
|
3285
|
+
return () => {
|
|
3286
|
+
observer?.disconnect();
|
|
3287
|
+
};
|
|
3288
|
+
}, []);
|
|
3289
|
+
return { refTable, scrolleable };
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
function RlsDatatableComponent({ children, footer, header, identifier, rlsTheme, resizable, summary, table, toolbar }) {
|
|
3293
|
+
const datatable = useDatatable(table);
|
|
3294
|
+
const className = renderClassStatus('rls-datatable', {
|
|
3295
|
+
resizable,
|
|
3296
|
+
scrolleable: resizable && datatable?.scrolleable
|
|
3297
|
+
});
|
|
3298
|
+
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 })] }));
|
|
3299
|
+
}
|
|
3300
|
+
const RlsDatatable = require$$0.memo(RlsDatatableComponent);
|
|
3301
|
+
function RlsDatatableHeaderComponent({ children, identifier, rlsTheme }) {
|
|
3302
|
+
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: "rls-datatable__header", "rls-theme": rlsTheme, children: children }));
|
|
3303
|
+
}
|
|
3304
|
+
const RlsDatatableHeader = require$$0.memo(RlsDatatableHeaderComponent);
|
|
3305
|
+
function RlsDatatableTitleComponent({ actions, children, className, control, identifier, rlsTheme, truncated }) {
|
|
3306
|
+
const classNameTitle = renderClassStatus('rls-datatable__title', { actions, control, truncated }, className);
|
|
3307
|
+
return (jsxRuntimeExports.jsx("th", { id: identifier, className: classNameTitle, "rls-theme": rlsTheme, children: children }));
|
|
3308
|
+
}
|
|
3309
|
+
const RlsDatatableTitle = require$$0.memo(RlsDatatableTitleComponent);
|
|
3310
|
+
function RlsDatatableSubheaderComponent({ children, className, identifier, rlsTheme }) {
|
|
3311
|
+
const classNameSubheader = renderClassStatus('rls-datatable__subheader', {}, className);
|
|
3312
|
+
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classNameSubheader, "rls-theme": rlsTheme, children: children }));
|
|
3313
|
+
}
|
|
3314
|
+
const RlsDatatableSubheader = require$$0.memo(RlsDatatableSubheaderComponent);
|
|
3315
|
+
function RlsDatatableRecordComponent({ children, className, error, identifier, info, rlsTheme, success, truncated, warning }) {
|
|
3316
|
+
const classNameRecord = renderClassStatus('rls-datatable__record', { error, info, truncated, success, warning }, className);
|
|
3317
|
+
return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classNameRecord, "rls-theme": rlsTheme, children: children }));
|
|
3318
|
+
}
|
|
3319
|
+
const RlsDatatableRecord = require$$0.memo(RlsDatatableRecordComponent);
|
|
3320
|
+
function RlsDatatableTotalsComponent({ children, className, error, identifier, info, rlsTheme, success, truncated, warning }) {
|
|
3321
|
+
const classNameTotals = renderClassStatus('rls-datatable__totals', { error, info, truncated, success, warning }, className);
|
|
3322
|
+
return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameTotals, "rls-theme": rlsTheme, children: children }));
|
|
3323
|
+
}
|
|
3324
|
+
const RlsDatatableTotals = require$$0.memo(RlsDatatableTotalsComponent);
|
|
3325
|
+
function RlsDatatableCellComponent({ actions, children, className, control, identifier, rlsTheme, truncated }) {
|
|
3326
|
+
const classNameCell = renderClassStatus('rls-datatable__cell', { actions, control, truncated }, className);
|
|
3327
|
+
return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameCell, "rls-theme": rlsTheme, children: children }));
|
|
3328
|
+
}
|
|
3329
|
+
const RlsDatatableCell = require$$0.memo(RlsDatatableCellComponent);
|
|
3330
|
+
function RlsDatatableDataComponent({ actions, children, className, control, identifier, truncated }) {
|
|
3331
|
+
const classNameData = renderClassStatus('rls-datatable__data', { actions, control, truncated }, className);
|
|
3332
|
+
return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameData, children: children }));
|
|
3333
|
+
}
|
|
3334
|
+
const RlsDatatableData = require$$0.memo(RlsDatatableDataComponent);
|
|
3335
|
+
function RlsDatatableFloatingComponent({ children, className, identifier, invested, rlsTheme }) {
|
|
3336
|
+
const classNameFloating = renderClassStatus('rls-datatable__floating', { invested }, className);
|
|
3337
|
+
return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameFloating, "rls-theme": rlsTheme, children: children }));
|
|
3338
|
+
}
|
|
3339
|
+
const RlsDatatableFloating = require$$0.memo(RlsDatatableFloatingComponent);
|
|
3340
|
+
|
|
3341
|
+
function RlsDropdownComponent({ children, controller, rlsTheme }) {
|
|
3342
|
+
const className = renderClassStatus('rls-dropdown', {
|
|
3343
|
+
visible: controller.visible
|
|
3344
|
+
});
|
|
3345
|
+
require$$0.useEffect(() => {
|
|
3346
|
+
function onCloseDropdown({ target }) {
|
|
3347
|
+
if (!controller.component.current.contains(target)) {
|
|
3348
|
+
controller.close();
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
document.addEventListener('click', onCloseDropdown);
|
|
3352
|
+
return () => {
|
|
3353
|
+
document.removeEventListener('click', onCloseDropdown);
|
|
3354
|
+
};
|
|
3355
|
+
}, []);
|
|
3356
|
+
return (jsxRuntimeExports.jsx("div", { ref: controller.component, className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-dropdown__content", children: children }) }));
|
|
3357
|
+
}
|
|
3358
|
+
const RlsDropdown = require$$0.memo(RlsDropdownComponent);
|
|
3359
|
+
|
|
3360
|
+
function RlsFieldAutocompleteTemplateComponent(props) {
|
|
3361
|
+
const autocomplete = useFieldAutocomplete(props);
|
|
3362
|
+
const { render, action, children, formControl, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
3363
|
+
const [listInputPlaceholder, setListInputPlaceholder] = require$$0.useState(reactI18n('listInputPlaceholder'));
|
|
3364
|
+
require$$0.useEffect(() => {
|
|
3365
|
+
return i18n.i18nSubscribe(() => {
|
|
3366
|
+
setListInputPlaceholder(reactI18n('listInputPlaceholder'));
|
|
3367
|
+
});
|
|
3368
|
+
}, []);
|
|
3369
|
+
require$$0.useEffect(() => {
|
|
3370
|
+
props.onInput?.(autocomplete.pattern);
|
|
3371
|
+
}, [autocomplete.pattern, props.onInput]);
|
|
3372
|
+
const disabled = require$$0.useMemo(() => {
|
|
3373
|
+
return formControl?.disabled || props.disabled;
|
|
3374
|
+
}, [formControl?.disabled, props.disabled]);
|
|
3375
|
+
const className = renderClassStatus('rls-field-box', {
|
|
3376
|
+
focused: autocomplete.focused && !disabled,
|
|
3377
|
+
error: formControl?.wrong,
|
|
3378
|
+
disabled,
|
|
3379
|
+
readonly: props.readOnly,
|
|
3380
|
+
selected: !!autocomplete.value
|
|
3381
|
+
}, `rls-field-list rls-field-autocomplete ${props.className ?? ''}`);
|
|
3382
|
+
const onClickPattern = require$$0.useCallback(() => {
|
|
3383
|
+
onSearch?.(autocomplete.pattern);
|
|
3384
|
+
}, [onSearch, autocomplete.pattern]);
|
|
3385
|
+
const onKeyDownPattern = require$$0.useCallback((event) => {
|
|
3386
|
+
if (event.key === 'Enter') {
|
|
3387
|
+
onSearch?.(autocomplete.pattern);
|
|
3388
|
+
}
|
|
3389
|
+
autocomplete.onKeydownInput(event);
|
|
3390
|
+
}, [autocomplete.onKeydownInput, onSearch, autocomplete.pattern]);
|
|
3391
|
+
const searchControl = require$$0.useMemo(() => ({
|
|
3392
|
+
pattern: autocomplete.pattern,
|
|
3393
|
+
placeholder: listInputPlaceholder,
|
|
3394
|
+
searching,
|
|
3395
|
+
refInput: autocomplete.refInput,
|
|
3396
|
+
onChange: autocomplete.setPattern,
|
|
3397
|
+
onFocus: autocomplete.onFocusInput,
|
|
3398
|
+
onBlur: autocomplete.onBlurInput,
|
|
3399
|
+
onKeyDown: onKeyDownPattern,
|
|
3400
|
+
onSearch: onSearch ? onClickPattern : undefined
|
|
3401
|
+
}), [
|
|
3402
|
+
autocomplete.pattern,
|
|
3403
|
+
autocomplete.refInput,
|
|
3404
|
+
autocomplete.setPattern,
|
|
3405
|
+
autocomplete.onFocusInput,
|
|
3406
|
+
autocomplete.onBlurInput,
|
|
3407
|
+
listInputPlaceholder,
|
|
3408
|
+
searching,
|
|
3409
|
+
onKeyDownPattern,
|
|
3410
|
+
onClickPattern,
|
|
3411
|
+
onSearch
|
|
3412
|
+
]);
|
|
3413
|
+
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 })] }));
|
|
3414
|
+
}
|
|
3415
|
+
const RlsFieldAutocompleteTemplate = require$$0.memo(RlsFieldAutocompleteTemplateComponent);
|
|
3416
|
+
function RlsFieldAutocompleteComponent(props) {
|
|
3417
|
+
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 }) })), []);
|
|
3418
|
+
return jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: render });
|
|
3419
|
+
}
|
|
3420
|
+
const RlsFieldAutocomplete = require$$0.memo(RlsFieldAutocompleteComponent);
|
|
3421
|
+
|
|
3422
|
+
function RlsModalComponent({ autoclose, children, className, controller, onBackdrop, visible, rlsTheme }) {
|
|
3423
|
+
const classNameModal = renderClassStatus('rls-modal', { visible: controller?.visible ?? visible }, className);
|
|
3424
|
+
const onClickBackdrop = require$$0.useCallback(() => {
|
|
3425
|
+
if (autoclose) {
|
|
3426
|
+
controller?.close();
|
|
3427
|
+
}
|
|
3428
|
+
onBackdrop?.();
|
|
3429
|
+
}, [autoclose, controller, onBackdrop]);
|
|
3430
|
+
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
3431
|
}
|
|
2927
3432
|
const RlsModal = require$$0.memo(RlsModalComponent);
|
|
2928
3433
|
|
|
@@ -3697,192 +4202,48 @@ function RlsFieldDateRangeComponent({ children, date, disabled: disabledProps, f
|
|
|
3697
4202
|
const disabled = require$$0.useMemo(() => {
|
|
3698
4203
|
return formControl?.disabled || disabledProps;
|
|
3699
4204
|
}, [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);
|
|
4205
|
+
const className = renderClassStatus('rls-field-box', {
|
|
4206
|
+
disabled,
|
|
4207
|
+
readonly: readOnly
|
|
4208
|
+
});
|
|
4209
|
+
const dateRangeValue = require$$0.useMemo(() => {
|
|
4210
|
+
return formControl ? formControl.value : value;
|
|
4211
|
+
}, [formControl?.value, value]);
|
|
4212
|
+
const status = require$$0.useMemo(() => {
|
|
4213
|
+
return {
|
|
4214
|
+
icon: dateRangeValue ? 'trash-2' : 'calendar',
|
|
4215
|
+
valueInput: dateRangeValue ? rangeFormatTemplate(dateRangeValue) : ''
|
|
3788
4216
|
};
|
|
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]);
|
|
4217
|
+
}, [dateRangeValue]);
|
|
3827
4218
|
const onClickInput = require$$0.useCallback(() => {
|
|
3828
|
-
if (!
|
|
3829
|
-
|
|
4219
|
+
if (!readOnly) {
|
|
4220
|
+
setModalIsVisible(true);
|
|
3830
4221
|
}
|
|
3831
|
-
}, [
|
|
3832
|
-
const
|
|
3833
|
-
|
|
3834
|
-
|
|
4222
|
+
}, [readOnly]);
|
|
4223
|
+
const onChange = require$$0.useCallback((value) => {
|
|
4224
|
+
setValue(value);
|
|
4225
|
+
onValue?.(value);
|
|
4226
|
+
}, [onValue]);
|
|
3835
4227
|
const onClickAction = require$$0.useCallback(() => {
|
|
3836
|
-
if (
|
|
3837
|
-
|
|
4228
|
+
if (dateRangeValue) {
|
|
4229
|
+
formControl?.setValue(valueInitial);
|
|
4230
|
+
formControl?.touch();
|
|
4231
|
+
onChange(valueInitial);
|
|
3838
4232
|
}
|
|
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
|
-
]);
|
|
4233
|
+
else {
|
|
4234
|
+
setModalIsVisible(true);
|
|
4235
|
+
}
|
|
4236
|
+
}, [dateRangeValue, formControl, valueInitial, onChange]);
|
|
4237
|
+
const onCloseModal = require$$0.useCallback((dateRange) => {
|
|
4238
|
+
if (dateRange) {
|
|
4239
|
+
onChange(dateRange);
|
|
4240
|
+
}
|
|
4241
|
+
formControl?.touch();
|
|
4242
|
+
setModalIsVisible(false);
|
|
4243
|
+
}, [formControl, onChange]);
|
|
4244
|
+
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
4245
|
}
|
|
4246
|
+
const RlsFieldDateRange = require$$0.memo(RlsFieldDateRangeComponent);
|
|
3886
4247
|
|
|
3887
4248
|
function RlsFieldListInner({ render, suggestions, action, children, formControl, fieldList, msgErrorDisabled, placeholder, rlsTheme, ...props }) {
|
|
3888
4249
|
const disabled = require$$0.useMemo(() => {
|
|
@@ -3895,7 +4256,7 @@ function RlsFieldListInner({ render, suggestions, action, children, formControl,
|
|
|
3895
4256
|
readonly: props.readOnly
|
|
3896
4257
|
}, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
|
|
3897
4258
|
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 })] }));
|
|
4259
|
+
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
4260
|
}
|
|
3900
4261
|
function RlsFieldListTemplateComponent(props) {
|
|
3901
4262
|
const fieldList = useFieldList(props);
|
|
@@ -3909,124 +4270,6 @@ function RlsFieldListComponent(props) {
|
|
|
3909
4270
|
}
|
|
3910
4271
|
const RlsFieldList = require$$0.memo(RlsFieldListComponent);
|
|
3911
4272
|
|
|
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
4273
|
function RlsFieldSelectTemplateComponent(props) {
|
|
4031
4274
|
const select = useFieldSelect(props);
|
|
4032
4275
|
const { render, suggestions, action, children, formControl, msgErrorDisabled, placeholder, rlsTheme, unremovable } = props;
|
|
@@ -4039,7 +4282,7 @@ function RlsFieldSelectTemplateComponent(props) {
|
|
|
4039
4282
|
disabled: disabled,
|
|
4040
4283
|
readonly: props.readOnly
|
|
4041
4284
|
}, `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 })] }));
|
|
4285
|
+
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
4286
|
}
|
|
4044
4287
|
const RlsFieldSelectTemplate = require$$0.memo(RlsFieldSelectTemplateComponent);
|
|
4045
4288
|
function RlsFieldSelectComponent(props) {
|
|
@@ -4054,54 +4297,56 @@ function RlsFormNavigationComponent({ children, className, controller, visible,
|
|
|
4054
4297
|
}
|
|
4055
4298
|
const RlsFormNavigation = require$$0.memo(RlsFormNavigationComponent);
|
|
4056
4299
|
|
|
4057
|
-
function useRelocationOnComponent({ container, element, onDrag }) {
|
|
4300
|
+
function useRelocationOnComponent({ container: containerRef, element: elementRef, onDrag }) {
|
|
4058
4301
|
const position = require$$0.useRef({ x: 0, y: 0 });
|
|
4059
4302
|
const dragOffset = require$$0.useRef({ x: 0, y: 0 });
|
|
4060
4303
|
const dragging = require$$0.useRef(false);
|
|
4061
|
-
|
|
4304
|
+
function getClientX(positionX) {
|
|
4062
4305
|
let clientX = position.current.x + positionX - dragOffset.current.x;
|
|
4063
4306
|
if (clientX < 0) {
|
|
4064
4307
|
clientX = 0;
|
|
4065
4308
|
}
|
|
4066
4309
|
else {
|
|
4067
|
-
const width = clientX +
|
|
4068
|
-
if (width >
|
|
4069
|
-
clientX =
|
|
4310
|
+
const width = clientX + elementRef.current.offsetWidth;
|
|
4311
|
+
if (width > containerRef.current.offsetWidth) {
|
|
4312
|
+
clientX =
|
|
4313
|
+
containerRef.current.offsetWidth - elementRef.current.offsetWidth;
|
|
4070
4314
|
}
|
|
4071
4315
|
}
|
|
4072
4316
|
return clientX;
|
|
4073
|
-
}
|
|
4074
|
-
|
|
4317
|
+
}
|
|
4318
|
+
function getClientY(positionY) {
|
|
4075
4319
|
let clientY = position.current.y + positionY - dragOffset.current.y;
|
|
4076
4320
|
if (clientY < 0) {
|
|
4077
4321
|
clientY = 0;
|
|
4078
4322
|
}
|
|
4079
4323
|
else {
|
|
4080
|
-
const height = clientY +
|
|
4081
|
-
if (height >
|
|
4082
|
-
clientY =
|
|
4324
|
+
const height = clientY + elementRef.current.offsetHeight;
|
|
4325
|
+
if (height > containerRef.current.offsetHeight) {
|
|
4326
|
+
clientY =
|
|
4327
|
+
containerRef.current.offsetHeight - elementRef.current.offsetHeight;
|
|
4083
4328
|
}
|
|
4084
4329
|
}
|
|
4085
4330
|
return clientY;
|
|
4086
|
-
}
|
|
4087
|
-
const start = require$$0.
|
|
4331
|
+
}
|
|
4332
|
+
const start = require$$0.useEffectEvent((positionX, positionY) => {
|
|
4088
4333
|
dragOffset.current = {
|
|
4089
4334
|
x: positionX,
|
|
4090
4335
|
y: positionY
|
|
4091
4336
|
};
|
|
4092
4337
|
position.current = {
|
|
4093
|
-
x:
|
|
4094
|
-
y:
|
|
4338
|
+
x: elementRef.current.offsetLeft,
|
|
4339
|
+
y: elementRef.current.offsetTop
|
|
4095
4340
|
};
|
|
4096
4341
|
dragging.current = true;
|
|
4097
|
-
}
|
|
4098
|
-
const relocation = require$$0.
|
|
4342
|
+
});
|
|
4343
|
+
const relocation = require$$0.useEffectEvent((positionX, positionY) => {
|
|
4099
4344
|
const clientX = getClientX(positionX);
|
|
4100
4345
|
const clientY = getClientY(positionY);
|
|
4101
|
-
|
|
4102
|
-
|
|
4346
|
+
elementRef.current.style.top = `${clientY}px`;
|
|
4347
|
+
elementRef.current.style.left = `${clientX}px`;
|
|
4103
4348
|
onDrag?.();
|
|
4104
|
-
}
|
|
4349
|
+
});
|
|
4105
4350
|
require$$0.useEffect(() => {
|
|
4106
4351
|
const mousedown = (event) => {
|
|
4107
4352
|
start(event.clientX, event.clientY);
|
|
@@ -4129,30 +4374,28 @@ function useRelocationOnComponent({ container, element, onDrag }) {
|
|
|
4129
4374
|
const touchend = () => {
|
|
4130
4375
|
dragging.current = false;
|
|
4131
4376
|
};
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4377
|
+
elementRef.current.addEventListener('mousedown', mousedown);
|
|
4378
|
+
elementRef.current.addEventListener('mousemove', mousemove);
|
|
4379
|
+
elementRef.current.addEventListener('mouseup', mouseup);
|
|
4380
|
+
elementRef.current.addEventListener('touchstart', touchstart);
|
|
4381
|
+
elementRef.current.addEventListener('touchmove', touchmove);
|
|
4382
|
+
elementRef.current.addEventListener('touchend', touchend);
|
|
4138
4383
|
return () => {
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4384
|
+
elementRef.current?.removeEventListener('mousedown', mousedown);
|
|
4385
|
+
elementRef.current?.removeEventListener('mousemove', mousemove);
|
|
4386
|
+
elementRef.current?.removeEventListener('mouseup', mouseup);
|
|
4387
|
+
elementRef.current?.removeEventListener('touchstart', touchstart);
|
|
4388
|
+
elementRef.current?.removeEventListener('touchmove', touchmove);
|
|
4389
|
+
elementRef.current?.removeEventListener('touchend', touchend);
|
|
4145
4390
|
};
|
|
4146
4391
|
}, []);
|
|
4147
4392
|
}
|
|
4148
4393
|
|
|
4149
4394
|
function useResize({ refElement, onResize }) {
|
|
4150
4395
|
const dimension = require$$0.useRef({ height: 0, width: 0 });
|
|
4151
|
-
const
|
|
4152
|
-
onResizeRef.current = onResize;
|
|
4153
|
-
const observer = require$$0.useCallback((entries) => {
|
|
4396
|
+
const observer = require$$0.useEffectEvent((entries) => {
|
|
4154
4397
|
const { height, width } = entries[0].contentRect;
|
|
4155
|
-
|
|
4398
|
+
onResize?.({
|
|
4156
4399
|
current: dimension.current,
|
|
4157
4400
|
dimension: {
|
|
4158
4401
|
height,
|
|
@@ -4160,13 +4403,13 @@ function useResize({ refElement, onResize }) {
|
|
|
4160
4403
|
}
|
|
4161
4404
|
});
|
|
4162
4405
|
dimension.current = { height, width };
|
|
4163
|
-
}
|
|
4406
|
+
});
|
|
4164
4407
|
require$$0.useEffect(() => {
|
|
4165
4408
|
dimension.current = {
|
|
4166
4409
|
height: refElement.current.offsetHeight,
|
|
4167
4410
|
width: refElement.current.offsetWidth
|
|
4168
4411
|
};
|
|
4169
|
-
const resizeObserver = new ResizeObserver(observer);
|
|
4412
|
+
const resizeObserver = new ResizeObserver((entries) => observer(entries));
|
|
4170
4413
|
resizeObserver.observe(refElement.current);
|
|
4171
4414
|
return () => {
|
|
4172
4415
|
resizeObserver.disconnect();
|
|
@@ -4854,6 +5097,12 @@ exports.RlsButtonToggle = RlsButtonToggle;
|
|
|
4854
5097
|
exports.RlsCard = RlsCard;
|
|
4855
5098
|
exports.RlsCheckBox = RlsCheckBox;
|
|
4856
5099
|
exports.RlsCheckBoxControl = RlsCheckBoxControl;
|
|
5100
|
+
exports.RlsChooserAutocomplete = RlsChooserAutocomplete;
|
|
5101
|
+
exports.RlsChooserAutocompleteTemplate = RlsChooserAutocompleteTemplate;
|
|
5102
|
+
exports.RlsChooserList = RlsChooserList;
|
|
5103
|
+
exports.RlsChooserListTemplate = RlsChooserListTemplate;
|
|
5104
|
+
exports.RlsChooserSelect = RlsChooserSelect;
|
|
5105
|
+
exports.RlsChooserSelectTemplate = RlsChooserSelectTemplate;
|
|
4857
5106
|
exports.RlsConfirmation = RlsConfirmation;
|
|
4858
5107
|
exports.RlsContent = RlsContent;
|
|
4859
5108
|
exports.RlsContext = RlsContext;
|