@rolster/react-components 18.17.2 → 18.18.0
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/assets/{index-CQEyyT3g.css → index-DIGj2mhy.css} +1 -1
- package/dist/cjs/index.js +72 -53
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/assets/{index-CQEyyT3g.css → index-DIGj2mhy.css} +1 -1
- package/dist/es/index.js +72 -53
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.css +1 -1
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.js +4 -1
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/esm/components/atoms/InputSearch/InputSearch.js +6 -1
- package/dist/esm/components/atoms/InputSearch/InputSearch.js.map +1 -1
- package/dist/esm/components/definitions.d.ts +1 -3
- package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +11 -7
- package/dist/esm/components/organisms/Confirmation/Confirmation.js +8 -6
- package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.d.ts +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +4 -4
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.d.ts +1 -0
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js +18 -15
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.d.ts +1 -0
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelectController.d.ts +1 -0
- package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js +4 -3
- package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js.map +1 -1
- package/dist/esm/controllers/ListController.d.ts +1 -0
- package/dist/esm/controllers/ListController.js +22 -15
- package/dist/esm/controllers/ListController.js.map +1 -1
- package/package.json +3 -3
package/dist/es/index.js
CHANGED
|
@@ -1393,8 +1393,18 @@ function RlsBadge({ children, rlsTheme }) {
|
|
|
1393
1393
|
return (jsxRuntimeExports.jsx("div", { className: "rls-badge", "rls-theme": rlsTheme, children: children }));
|
|
1394
1394
|
}
|
|
1395
1395
|
|
|
1396
|
+
const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
|
|
1397
|
+
|
|
1398
|
+
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
1399
|
+
const minFormat = dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
|
|
1400
|
+
const maxFormat = dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
|
|
1401
|
+
return `${minFormat} - ${maxFormat}`;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1396
1404
|
function RlsBreadcrumb({ labels }) {
|
|
1397
|
-
return (jsxRuntimeExports.jsx("div", { className: "rls-breadcrumb", children: labels.map(({ label, onClick }, index) => (jsxRuntimeExports.jsx("label", { className: "rls-breadcrumb__label", onClick: onClick, children: jsxRuntimeExports.jsx("a", { className:
|
|
1405
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-breadcrumb", children: labels.map(({ label, onClick }, index) => (jsxRuntimeExports.jsx("label", { className: "rls-breadcrumb__label", onClick: onClick, children: jsxRuntimeExports.jsx("a", { className: renderClassStatus('rls-breadcrumb__label__a', {
|
|
1406
|
+
actionable: !!onClick
|
|
1407
|
+
}), children: label }) }, index))) }));
|
|
1398
1408
|
}
|
|
1399
1409
|
|
|
1400
1410
|
function RlsIcon({ value, skeleton }) {
|
|
@@ -1480,7 +1490,11 @@ function RlsInputPassword({ disabled, formControl, identifier, onValue, placehol
|
|
|
1480
1490
|
}
|
|
1481
1491
|
|
|
1482
1492
|
function RlsInputSearch({ formControl, identifier, onSearch, placeholder }) {
|
|
1483
|
-
|
|
1493
|
+
const [value, setValue] = useState('');
|
|
1494
|
+
function onValueInput(value) {
|
|
1495
|
+
!formControl && setValue(value);
|
|
1496
|
+
}
|
|
1497
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-input-search", children: [jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, placeholder: placeholder, onValue: onValueInput, children: formControl?.value ?? value }), onSearch && jsxRuntimeExports.jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
1484
1498
|
}
|
|
1485
1499
|
|
|
1486
1500
|
function RlsInputText({ disabled, formControl, identifier, onValue, placeholder, value }) {
|
|
@@ -1500,14 +1514,6 @@ function RlsMessageIcon({ icon, children, rlsTheme }) {
|
|
|
1500
1514
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-message-icon", "rls-theme": rlsTheme, children: [icon && jsxRuntimeExports.jsx(RlsIcon, { value: icon }), jsxRuntimeExports.jsx("span", { className: "truncate", children: children })] }));
|
|
1501
1515
|
}
|
|
1502
1516
|
|
|
1503
|
-
const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
|
|
1504
|
-
|
|
1505
|
-
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
1506
|
-
const minFormat = dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
|
|
1507
|
-
const maxFormat = dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
|
|
1508
|
-
return `${minFormat} - ${maxFormat}`;
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
1517
|
function RlsPoster({ children, contrast, outline, rlsTheme }) {
|
|
1512
1518
|
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-poster', { contrast, outline }), "rls-theme": rlsTheme, children: children }));
|
|
1513
1519
|
}
|
|
@@ -1992,28 +1998,30 @@ function useConfirmationService() {
|
|
|
1992
1998
|
const [config, setConfig] = useState({});
|
|
1993
1999
|
const [visible, setVisible] = useState(false);
|
|
1994
2000
|
const rlsConfirmation = ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
|
|
1995
|
-
function confirmation(
|
|
2001
|
+
function confirmation(options) {
|
|
1996
2002
|
return new Promise((resolve) => {
|
|
1997
|
-
const { content, rlsTheme, subtitle, title, approved, reject } =
|
|
2003
|
+
const { content, rlsTheme, subtitle, title, approved, reject } = options;
|
|
1998
2004
|
setConfig({
|
|
1999
2005
|
content,
|
|
2000
2006
|
rlsTheme,
|
|
2001
2007
|
subtitle,
|
|
2002
2008
|
title,
|
|
2003
2009
|
approved: {
|
|
2004
|
-
label: approved
|
|
2010
|
+
label: approved?.label ?? reactI18n('confirmationActionApproved'),
|
|
2005
2011
|
onClick: () => {
|
|
2006
2012
|
setVisible(false);
|
|
2007
2013
|
resolve(ConfirmationResult.approved());
|
|
2008
|
-
}
|
|
2014
|
+
},
|
|
2015
|
+
identifier: approved?.identifier
|
|
2009
2016
|
},
|
|
2010
2017
|
reject: reject
|
|
2011
2018
|
? {
|
|
2012
|
-
label: reject,
|
|
2019
|
+
label: reject.label,
|
|
2013
2020
|
onClick: () => {
|
|
2014
2021
|
setVisible(false);
|
|
2015
2022
|
resolve(ConfirmationResult.reject());
|
|
2016
|
-
}
|
|
2023
|
+
},
|
|
2024
|
+
identifier: reject.identifier
|
|
2017
2025
|
}
|
|
2018
2026
|
: undefined
|
|
2019
2027
|
});
|
|
@@ -2074,7 +2082,7 @@ function useDatatable() {
|
|
|
2074
2082
|
}
|
|
2075
2083
|
|
|
2076
2084
|
function useListController(props) {
|
|
2077
|
-
const { suggestions, formControl, value } = props;
|
|
2085
|
+
const { suggestions, automatic, formControl, value } = props;
|
|
2078
2086
|
const listIsOpen = useRef(false);
|
|
2079
2087
|
const contentRef = useRef(null);
|
|
2080
2088
|
const listRef = useRef(null);
|
|
@@ -2087,7 +2095,7 @@ function useListController(props) {
|
|
|
2087
2095
|
});
|
|
2088
2096
|
const collection = useRef(new ListCollection([]));
|
|
2089
2097
|
const position = useRef(0);
|
|
2090
|
-
const
|
|
2098
|
+
const _protected = useRef();
|
|
2091
2099
|
useEffect(() => {
|
|
2092
2100
|
function onCloseSuggestions({ target }) {
|
|
2093
2101
|
!contentRef?.current?.contains(target) &&
|
|
@@ -2112,31 +2120,38 @@ function useListController(props) {
|
|
|
2112
2120
|
}, [state.modalIsVisible]);
|
|
2113
2121
|
useEffect(() => {
|
|
2114
2122
|
collection.current = new ListCollection(suggestions);
|
|
2123
|
+
refresh(collection.current, formControl?.value, automatic);
|
|
2124
|
+
}, [suggestions]);
|
|
2125
|
+
useEffect(() => {
|
|
2115
2126
|
refresh(collection.current, formControl?.value);
|
|
2116
|
-
}, [
|
|
2117
|
-
function refresh(collection, state) {
|
|
2127
|
+
}, [formControl?.value]);
|
|
2128
|
+
function refresh(collection, state, automatic) {
|
|
2118
2129
|
if (!state) {
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2130
|
+
!refreshWithProtected(collection, automatic) &&
|
|
2131
|
+
refreshState({ value: '' });
|
|
2132
|
+
return undefined;
|
|
2122
2133
|
}
|
|
2123
2134
|
const element = collection.find(state);
|
|
2124
2135
|
if (element) {
|
|
2125
|
-
|
|
2136
|
+
_protected.current = undefined;
|
|
2126
2137
|
return refreshState({ value: element.description });
|
|
2127
2138
|
}
|
|
2128
|
-
if (!
|
|
2129
|
-
|
|
2139
|
+
if (!refreshWithProtected(collection, automatic)) {
|
|
2140
|
+
_protected.current = state;
|
|
2130
2141
|
setFormValue(value);
|
|
2131
2142
|
refreshState({ value: '' });
|
|
2132
2143
|
}
|
|
2133
2144
|
}
|
|
2134
|
-
function
|
|
2135
|
-
if (
|
|
2136
|
-
|
|
2145
|
+
function refreshWithProtected(collection, automatic) {
|
|
2146
|
+
if (automatic && collection.value[0]) {
|
|
2147
|
+
setFormValue(collection.value[0].value);
|
|
2148
|
+
return true;
|
|
2149
|
+
}
|
|
2150
|
+
if (_protected.current) {
|
|
2151
|
+
const element = collection.find(_protected.current);
|
|
2137
2152
|
if (element) {
|
|
2138
|
-
formControl?.setValue(
|
|
2139
|
-
|
|
2153
|
+
formControl?.setValue(_protected.current);
|
|
2154
|
+
_protected.current = undefined;
|
|
2140
2155
|
return true;
|
|
2141
2156
|
}
|
|
2142
2157
|
}
|
|
@@ -2190,21 +2205,12 @@ function useFieldAutocomplete(props) {
|
|
|
2190
2205
|
pattern: '',
|
|
2191
2206
|
previous: null
|
|
2192
2207
|
});
|
|
2193
|
-
const disabled = props.formControl?.disabled || props.disabled;
|
|
2194
2208
|
useEffect(() => {
|
|
2195
2209
|
refreshCoincidences(pattern, true);
|
|
2196
2210
|
}, [props.suggestions]);
|
|
2197
2211
|
useEffect(() => {
|
|
2198
2212
|
refreshCoincidences(pattern);
|
|
2199
2213
|
}, [pattern]);
|
|
2200
|
-
function onClickControl() {
|
|
2201
|
-
if (!disabled) {
|
|
2202
|
-
controller.setState({ modalIsVisible: true });
|
|
2203
|
-
setTimeout(() => {
|
|
2204
|
-
controller.inputRef?.current?.focus();
|
|
2205
|
-
}, DURATION_ANIMATION$1);
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
2214
|
function onFocusInput() {
|
|
2209
2215
|
controller.setState({ focused: true });
|
|
2210
2216
|
}
|
|
@@ -2222,10 +2228,21 @@ function useFieldAutocomplete(props) {
|
|
|
2222
2228
|
break;
|
|
2223
2229
|
}
|
|
2224
2230
|
}
|
|
2231
|
+
function onClickControl() {
|
|
2232
|
+
controller.setState({ modalIsVisible: true });
|
|
2233
|
+
setTimeout(() => {
|
|
2234
|
+
controller.inputRef?.current?.focus();
|
|
2235
|
+
}, DURATION_ANIMATION$1);
|
|
2236
|
+
}
|
|
2225
2237
|
function onClickAction() {
|
|
2226
|
-
controller.
|
|
2227
|
-
|
|
2228
|
-
|
|
2238
|
+
if (controller.value) {
|
|
2239
|
+
controller.setState({ modalIsVisible: false, value: '' });
|
|
2240
|
+
controller.setFormValue(props.value);
|
|
2241
|
+
props.onValue && props.onValue(props.value);
|
|
2242
|
+
}
|
|
2243
|
+
else {
|
|
2244
|
+
onClickControl();
|
|
2245
|
+
}
|
|
2229
2246
|
}
|
|
2230
2247
|
function onClickBackdrop() {
|
|
2231
2248
|
controller.setState({ modalIsVisible: false });
|
|
@@ -2243,15 +2260,16 @@ function useFieldAutocomplete(props) {
|
|
|
2243
2260
|
};
|
|
2244
2261
|
}
|
|
2245
2262
|
function onChange({ description, value }) {
|
|
2246
|
-
|
|
2263
|
+
const { onSelect, onValue } = props;
|
|
2264
|
+
if (onSelect) {
|
|
2247
2265
|
controller.setState({ modalIsVisible: false });
|
|
2248
|
-
value &&
|
|
2266
|
+
value && onSelect(value);
|
|
2249
2267
|
}
|
|
2250
2268
|
else {
|
|
2251
2269
|
controller.setState({ modalIsVisible: false, value: description });
|
|
2252
2270
|
controller.setFormValue(value);
|
|
2253
2271
|
}
|
|
2254
|
-
|
|
2272
|
+
onValue && onValue(value);
|
|
2255
2273
|
}
|
|
2256
2274
|
function refreshCoincidences(pattern, reboot = false) {
|
|
2257
2275
|
const { collection, store } = createAutocompleteStore({
|
|
@@ -2282,7 +2300,7 @@ function useFieldAutocomplete(props) {
|
|
|
2282
2300
|
function RlsFieldAutocompleteTemplate(props) {
|
|
2283
2301
|
const autocomplete = useFieldAutocomplete(props);
|
|
2284
2302
|
const { controller } = autocomplete;
|
|
2285
|
-
const { render, children, formControl,
|
|
2303
|
+
const { render, children, formControl, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2286
2304
|
const disabled = formControl?.disabled || props.disabled;
|
|
2287
2305
|
const className = renderClassStatus('rls-field-box', {
|
|
2288
2306
|
focused: controller.focused,
|
|
@@ -2290,12 +2308,12 @@ function RlsFieldAutocompleteTemplate(props) {
|
|
|
2290
2308
|
error: formControl?.wrong,
|
|
2291
2309
|
selected: !!controller.value
|
|
2292
2310
|
}, 'rls-field-list rls-field-autocomplete');
|
|
2293
|
-
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: controller.contentRef, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { 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: controller.value, onClick: autocomplete.onClickControl }),
|
|
2311
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: controller.contentRef, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { 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: controller.value, onClick: autocomplete.onClickControl }), jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: autocomplete.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: controller.value ? 'trash-2' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2294
2312
|
visible: controller.modalIsVisible,
|
|
2295
2313
|
higher: controller.higher,
|
|
2296
2314
|
hide: !controller.modalIsVisible
|
|
2297
|
-
}), children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: controller.listRef, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: controller.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: autocomplete.pattern, onChange: (
|
|
2298
|
-
autocomplete.setPattern(value);
|
|
2315
|
+
}), children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: controller.listRef, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: controller.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: autocomplete.pattern, onChange: (event) => {
|
|
2316
|
+
autocomplete.setPattern(event.target.value);
|
|
2299
2317
|
}, disabled: disabled || searching, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: autocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
2300
2318
|
onSearch(autocomplete.pattern);
|
|
2301
2319
|
}, children: jsxRuntimeExports.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntimeExports.jsx(RlsProgressBar, { indeterminate: true }), autocomplete.coincidences.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: autocomplete.onClickElement(element), onKeyDown: autocomplete.onKeydownElement(element), children: render(element) }, index))), !autocomplete.coincidences.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: autocomplete.onClickBackdrop })] })] }));
|
|
@@ -2536,16 +2554,17 @@ function useFieldSelect(props) {
|
|
|
2536
2554
|
};
|
|
2537
2555
|
}
|
|
2538
2556
|
function onChange({ description, value }) {
|
|
2557
|
+
const { onSelect, onValue } = props;
|
|
2539
2558
|
controller.inputRef?.current?.focus();
|
|
2540
|
-
if (
|
|
2559
|
+
if (onSelect) {
|
|
2541
2560
|
controller.setState({ modalIsVisible: false });
|
|
2542
|
-
value &&
|
|
2561
|
+
value && onSelect(value);
|
|
2543
2562
|
}
|
|
2544
2563
|
else {
|
|
2545
2564
|
controller.setFormValue(value);
|
|
2546
2565
|
controller.setState({ modalIsVisible: false, value: description });
|
|
2547
2566
|
}
|
|
2548
|
-
|
|
2567
|
+
onValue && onValue(value);
|
|
2549
2568
|
}
|
|
2550
2569
|
return {
|
|
2551
2570
|
controller,
|