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