@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/cjs/index.js
CHANGED
|
@@ -1395,8 +1395,18 @@ function RlsBadge({ children, rlsTheme }) {
|
|
|
1395
1395
|
return (jsxRuntimeExports.jsx("div", { className: "rls-badge", "rls-theme": rlsTheme, children: children }));
|
|
1396
1396
|
}
|
|
1397
1397
|
|
|
1398
|
+
const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
|
|
1399
|
+
|
|
1400
|
+
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
1401
|
+
const minFormat = dates.dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
|
|
1402
|
+
const maxFormat = dates.dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
|
|
1403
|
+
return `${minFormat} - ${maxFormat}`;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1398
1406
|
function RlsBreadcrumb({ labels }) {
|
|
1399
|
-
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:
|
|
1407
|
+
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', {
|
|
1408
|
+
actionable: !!onClick
|
|
1409
|
+
}), children: label }) }, index))) }));
|
|
1400
1410
|
}
|
|
1401
1411
|
|
|
1402
1412
|
function RlsIcon({ value, skeleton }) {
|
|
@@ -1482,7 +1492,11 @@ function RlsInputPassword({ disabled, formControl, identifier, onValue, placehol
|
|
|
1482
1492
|
}
|
|
1483
1493
|
|
|
1484
1494
|
function RlsInputSearch({ formControl, identifier, onSearch, placeholder }) {
|
|
1485
|
-
|
|
1495
|
+
const [value, setValue] = require$$0.useState('');
|
|
1496
|
+
function onValueInput(value) {
|
|
1497
|
+
!formControl && setValue(value);
|
|
1498
|
+
}
|
|
1499
|
+
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 })] }));
|
|
1486
1500
|
}
|
|
1487
1501
|
|
|
1488
1502
|
function RlsInputText({ disabled, formControl, identifier, onValue, placeholder, value }) {
|
|
@@ -1502,14 +1516,6 @@ function RlsMessageIcon({ icon, children, rlsTheme }) {
|
|
|
1502
1516
|
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 })] }));
|
|
1503
1517
|
}
|
|
1504
1518
|
|
|
1505
|
-
const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
|
|
1506
|
-
|
|
1507
|
-
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
1508
|
-
const minFormat = dates.dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
|
|
1509
|
-
const maxFormat = dates.dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
|
|
1510
|
-
return `${minFormat} - ${maxFormat}`;
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
1519
|
function RlsPoster({ children, contrast, outline, rlsTheme }) {
|
|
1514
1520
|
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-poster', { contrast, outline }), "rls-theme": rlsTheme, children: children }));
|
|
1515
1521
|
}
|
|
@@ -1994,28 +2000,30 @@ function useConfirmationService() {
|
|
|
1994
2000
|
const [config, setConfig] = require$$0.useState({});
|
|
1995
2001
|
const [visible, setVisible] = require$$0.useState(false);
|
|
1996
2002
|
const rlsConfirmation = ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
|
|
1997
|
-
function confirmation(
|
|
2003
|
+
function confirmation(options) {
|
|
1998
2004
|
return new Promise((resolve) => {
|
|
1999
|
-
const { content, rlsTheme, subtitle, title, approved, reject } =
|
|
2005
|
+
const { content, rlsTheme, subtitle, title, approved, reject } = options;
|
|
2000
2006
|
setConfig({
|
|
2001
2007
|
content,
|
|
2002
2008
|
rlsTheme,
|
|
2003
2009
|
subtitle,
|
|
2004
2010
|
title,
|
|
2005
2011
|
approved: {
|
|
2006
|
-
label: approved
|
|
2012
|
+
label: approved?.label ?? reactI18n('confirmationActionApproved'),
|
|
2007
2013
|
onClick: () => {
|
|
2008
2014
|
setVisible(false);
|
|
2009
2015
|
resolve(ConfirmationResult.approved());
|
|
2010
|
-
}
|
|
2016
|
+
},
|
|
2017
|
+
identifier: approved?.identifier
|
|
2011
2018
|
},
|
|
2012
2019
|
reject: reject
|
|
2013
2020
|
? {
|
|
2014
|
-
label: reject,
|
|
2021
|
+
label: reject.label,
|
|
2015
2022
|
onClick: () => {
|
|
2016
2023
|
setVisible(false);
|
|
2017
2024
|
resolve(ConfirmationResult.reject());
|
|
2018
|
-
}
|
|
2025
|
+
},
|
|
2026
|
+
identifier: reject.identifier
|
|
2019
2027
|
}
|
|
2020
2028
|
: undefined
|
|
2021
2029
|
});
|
|
@@ -2076,7 +2084,7 @@ function useDatatable() {
|
|
|
2076
2084
|
}
|
|
2077
2085
|
|
|
2078
2086
|
function useListController(props) {
|
|
2079
|
-
const { suggestions, formControl, value } = props;
|
|
2087
|
+
const { suggestions, automatic, formControl, value } = props;
|
|
2080
2088
|
const listIsOpen = require$$0.useRef(false);
|
|
2081
2089
|
const contentRef = require$$0.useRef(null);
|
|
2082
2090
|
const listRef = require$$0.useRef(null);
|
|
@@ -2089,7 +2097,7 @@ function useListController(props) {
|
|
|
2089
2097
|
});
|
|
2090
2098
|
const collection = require$$0.useRef(new components.ListCollection([]));
|
|
2091
2099
|
const position = require$$0.useRef(0);
|
|
2092
|
-
const
|
|
2100
|
+
const _protected = require$$0.useRef();
|
|
2093
2101
|
require$$0.useEffect(() => {
|
|
2094
2102
|
function onCloseSuggestions({ target }) {
|
|
2095
2103
|
!contentRef?.current?.contains(target) &&
|
|
@@ -2114,31 +2122,38 @@ function useListController(props) {
|
|
|
2114
2122
|
}, [state.modalIsVisible]);
|
|
2115
2123
|
require$$0.useEffect(() => {
|
|
2116
2124
|
collection.current = new components.ListCollection(suggestions);
|
|
2125
|
+
refresh(collection.current, formControl?.value, automatic);
|
|
2126
|
+
}, [suggestions]);
|
|
2127
|
+
require$$0.useEffect(() => {
|
|
2117
2128
|
refresh(collection.current, formControl?.value);
|
|
2118
|
-
}, [
|
|
2119
|
-
function refresh(collection, state) {
|
|
2129
|
+
}, [formControl?.value]);
|
|
2130
|
+
function refresh(collection, state, automatic) {
|
|
2120
2131
|
if (!state) {
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2132
|
+
!refreshWithProtected(collection, automatic) &&
|
|
2133
|
+
refreshState({ value: '' });
|
|
2134
|
+
return undefined;
|
|
2124
2135
|
}
|
|
2125
2136
|
const element = collection.find(state);
|
|
2126
2137
|
if (element) {
|
|
2127
|
-
|
|
2138
|
+
_protected.current = undefined;
|
|
2128
2139
|
return refreshState({ value: element.description });
|
|
2129
2140
|
}
|
|
2130
|
-
if (!
|
|
2131
|
-
|
|
2141
|
+
if (!refreshWithProtected(collection, automatic)) {
|
|
2142
|
+
_protected.current = state;
|
|
2132
2143
|
setFormValue(value);
|
|
2133
2144
|
refreshState({ value: '' });
|
|
2134
2145
|
}
|
|
2135
2146
|
}
|
|
2136
|
-
function
|
|
2137
|
-
if (
|
|
2138
|
-
|
|
2147
|
+
function refreshWithProtected(collection, automatic) {
|
|
2148
|
+
if (automatic && collection.value[0]) {
|
|
2149
|
+
setFormValue(collection.value[0].value);
|
|
2150
|
+
return true;
|
|
2151
|
+
}
|
|
2152
|
+
if (_protected.current) {
|
|
2153
|
+
const element = collection.find(_protected.current);
|
|
2139
2154
|
if (element) {
|
|
2140
|
-
formControl?.setValue(
|
|
2141
|
-
|
|
2155
|
+
formControl?.setValue(_protected.current);
|
|
2156
|
+
_protected.current = undefined;
|
|
2142
2157
|
return true;
|
|
2143
2158
|
}
|
|
2144
2159
|
}
|
|
@@ -2192,21 +2207,12 @@ function useFieldAutocomplete(props) {
|
|
|
2192
2207
|
pattern: '',
|
|
2193
2208
|
previous: null
|
|
2194
2209
|
});
|
|
2195
|
-
const disabled = props.formControl?.disabled || props.disabled;
|
|
2196
2210
|
require$$0.useEffect(() => {
|
|
2197
2211
|
refreshCoincidences(pattern, true);
|
|
2198
2212
|
}, [props.suggestions]);
|
|
2199
2213
|
require$$0.useEffect(() => {
|
|
2200
2214
|
refreshCoincidences(pattern);
|
|
2201
2215
|
}, [pattern]);
|
|
2202
|
-
function onClickControl() {
|
|
2203
|
-
if (!disabled) {
|
|
2204
|
-
controller.setState({ modalIsVisible: true });
|
|
2205
|
-
setTimeout(() => {
|
|
2206
|
-
controller.inputRef?.current?.focus();
|
|
2207
|
-
}, DURATION_ANIMATION$1);
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
2216
|
function onFocusInput() {
|
|
2211
2217
|
controller.setState({ focused: true });
|
|
2212
2218
|
}
|
|
@@ -2224,10 +2230,21 @@ function useFieldAutocomplete(props) {
|
|
|
2224
2230
|
break;
|
|
2225
2231
|
}
|
|
2226
2232
|
}
|
|
2233
|
+
function onClickControl() {
|
|
2234
|
+
controller.setState({ modalIsVisible: true });
|
|
2235
|
+
setTimeout(() => {
|
|
2236
|
+
controller.inputRef?.current?.focus();
|
|
2237
|
+
}, DURATION_ANIMATION$1);
|
|
2238
|
+
}
|
|
2227
2239
|
function onClickAction() {
|
|
2228
|
-
controller.
|
|
2229
|
-
|
|
2230
|
-
|
|
2240
|
+
if (controller.value) {
|
|
2241
|
+
controller.setState({ modalIsVisible: false, value: '' });
|
|
2242
|
+
controller.setFormValue(props.value);
|
|
2243
|
+
props.onValue && props.onValue(props.value);
|
|
2244
|
+
}
|
|
2245
|
+
else {
|
|
2246
|
+
onClickControl();
|
|
2247
|
+
}
|
|
2231
2248
|
}
|
|
2232
2249
|
function onClickBackdrop() {
|
|
2233
2250
|
controller.setState({ modalIsVisible: false });
|
|
@@ -2245,15 +2262,16 @@ function useFieldAutocomplete(props) {
|
|
|
2245
2262
|
};
|
|
2246
2263
|
}
|
|
2247
2264
|
function onChange({ description, value }) {
|
|
2248
|
-
|
|
2265
|
+
const { onSelect, onValue } = props;
|
|
2266
|
+
if (onSelect) {
|
|
2249
2267
|
controller.setState({ modalIsVisible: false });
|
|
2250
|
-
value &&
|
|
2268
|
+
value && onSelect(value);
|
|
2251
2269
|
}
|
|
2252
2270
|
else {
|
|
2253
2271
|
controller.setState({ modalIsVisible: false, value: description });
|
|
2254
2272
|
controller.setFormValue(value);
|
|
2255
2273
|
}
|
|
2256
|
-
|
|
2274
|
+
onValue && onValue(value);
|
|
2257
2275
|
}
|
|
2258
2276
|
function refreshCoincidences(pattern, reboot = false) {
|
|
2259
2277
|
const { collection, store } = components.createAutocompleteStore({
|
|
@@ -2284,7 +2302,7 @@ function useFieldAutocomplete(props) {
|
|
|
2284
2302
|
function RlsFieldAutocompleteTemplate(props) {
|
|
2285
2303
|
const autocomplete = useFieldAutocomplete(props);
|
|
2286
2304
|
const { controller } = autocomplete;
|
|
2287
|
-
const { render, children, formControl,
|
|
2305
|
+
const { render, children, formControl, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2288
2306
|
const disabled = formControl?.disabled || props.disabled;
|
|
2289
2307
|
const className = renderClassStatus('rls-field-box', {
|
|
2290
2308
|
focused: controller.focused,
|
|
@@ -2292,12 +2310,12 @@ function RlsFieldAutocompleteTemplate(props) {
|
|
|
2292
2310
|
error: formControl?.wrong,
|
|
2293
2311
|
selected: !!controller.value
|
|
2294
2312
|
}, 'rls-field-list rls-field-autocomplete');
|
|
2295
|
-
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 }),
|
|
2313
|
+
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', {
|
|
2296
2314
|
visible: controller.modalIsVisible,
|
|
2297
2315
|
higher: controller.higher,
|
|
2298
2316
|
hide: !controller.modalIsVisible
|
|
2299
|
-
}), 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: (
|
|
2300
|
-
autocomplete.setPattern(value);
|
|
2317
|
+
}), 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) => {
|
|
2318
|
+
autocomplete.setPattern(event.target.value);
|
|
2301
2319
|
}, disabled: disabled || searching, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: autocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
2302
2320
|
onSearch(autocomplete.pattern);
|
|
2303
2321
|
}, 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 })] })] }));
|
|
@@ -2538,16 +2556,17 @@ function useFieldSelect(props) {
|
|
|
2538
2556
|
};
|
|
2539
2557
|
}
|
|
2540
2558
|
function onChange({ description, value }) {
|
|
2559
|
+
const { onSelect, onValue } = props;
|
|
2541
2560
|
controller.inputRef?.current?.focus();
|
|
2542
|
-
if (
|
|
2561
|
+
if (onSelect) {
|
|
2543
2562
|
controller.setState({ modalIsVisible: false });
|
|
2544
|
-
value &&
|
|
2563
|
+
value && onSelect(value);
|
|
2545
2564
|
}
|
|
2546
2565
|
else {
|
|
2547
2566
|
controller.setFormValue(value);
|
|
2548
2567
|
controller.setState({ modalIsVisible: false, value: description });
|
|
2549
2568
|
}
|
|
2550
|
-
|
|
2569
|
+
onValue && onValue(value);
|
|
2551
2570
|
}
|
|
2552
2571
|
return {
|
|
2553
2572
|
controller,
|