@rolster/react-components 18.17.3 → 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 +64 -47
- 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 +64 -47
- 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/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
|
}
|
|
@@ -2076,7 +2082,7 @@ function useDatatable() {
|
|
|
2076
2082
|
}
|
|
2077
2083
|
|
|
2078
2084
|
function useListController(props) {
|
|
2079
|
-
const { suggestions, formControl, value } = props;
|
|
2085
|
+
const { suggestions, automatic, formControl, value } = props;
|
|
2080
2086
|
const listIsOpen = useRef(false);
|
|
2081
2087
|
const contentRef = useRef(null);
|
|
2082
2088
|
const listRef = useRef(null);
|
|
@@ -2089,7 +2095,7 @@ function useListController(props) {
|
|
|
2089
2095
|
});
|
|
2090
2096
|
const collection = useRef(new ListCollection([]));
|
|
2091
2097
|
const position = useRef(0);
|
|
2092
|
-
const
|
|
2098
|
+
const _protected = useRef();
|
|
2093
2099
|
useEffect(() => {
|
|
2094
2100
|
function onCloseSuggestions({ target }) {
|
|
2095
2101
|
!contentRef?.current?.contains(target) &&
|
|
@@ -2114,31 +2120,38 @@ function useListController(props) {
|
|
|
2114
2120
|
}, [state.modalIsVisible]);
|
|
2115
2121
|
useEffect(() => {
|
|
2116
2122
|
collection.current = new ListCollection(suggestions);
|
|
2123
|
+
refresh(collection.current, formControl?.value, automatic);
|
|
2124
|
+
}, [suggestions]);
|
|
2125
|
+
useEffect(() => {
|
|
2117
2126
|
refresh(collection.current, formControl?.value);
|
|
2118
|
-
}, [
|
|
2119
|
-
function refresh(collection, state) {
|
|
2127
|
+
}, [formControl?.value]);
|
|
2128
|
+
function refresh(collection, state, automatic) {
|
|
2120
2129
|
if (!state) {
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2130
|
+
!refreshWithProtected(collection, automatic) &&
|
|
2131
|
+
refreshState({ value: '' });
|
|
2132
|
+
return undefined;
|
|
2124
2133
|
}
|
|
2125
2134
|
const element = collection.find(state);
|
|
2126
2135
|
if (element) {
|
|
2127
|
-
|
|
2136
|
+
_protected.current = undefined;
|
|
2128
2137
|
return refreshState({ value: element.description });
|
|
2129
2138
|
}
|
|
2130
|
-
if (!
|
|
2131
|
-
|
|
2139
|
+
if (!refreshWithProtected(collection, automatic)) {
|
|
2140
|
+
_protected.current = state;
|
|
2132
2141
|
setFormValue(value);
|
|
2133
2142
|
refreshState({ value: '' });
|
|
2134
2143
|
}
|
|
2135
2144
|
}
|
|
2136
|
-
function
|
|
2137
|
-
if (
|
|
2138
|
-
|
|
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);
|
|
2139
2152
|
if (element) {
|
|
2140
|
-
formControl?.setValue(
|
|
2141
|
-
|
|
2153
|
+
formControl?.setValue(_protected.current);
|
|
2154
|
+
_protected.current = undefined;
|
|
2142
2155
|
return true;
|
|
2143
2156
|
}
|
|
2144
2157
|
}
|
|
@@ -2192,21 +2205,12 @@ function useFieldAutocomplete(props) {
|
|
|
2192
2205
|
pattern: '',
|
|
2193
2206
|
previous: null
|
|
2194
2207
|
});
|
|
2195
|
-
const disabled = props.formControl?.disabled || props.disabled;
|
|
2196
2208
|
useEffect(() => {
|
|
2197
2209
|
refreshCoincidences(pattern, true);
|
|
2198
2210
|
}, [props.suggestions]);
|
|
2199
2211
|
useEffect(() => {
|
|
2200
2212
|
refreshCoincidences(pattern);
|
|
2201
2213
|
}, [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
2214
|
function onFocusInput() {
|
|
2211
2215
|
controller.setState({ focused: true });
|
|
2212
2216
|
}
|
|
@@ -2224,10 +2228,21 @@ function useFieldAutocomplete(props) {
|
|
|
2224
2228
|
break;
|
|
2225
2229
|
}
|
|
2226
2230
|
}
|
|
2231
|
+
function onClickControl() {
|
|
2232
|
+
controller.setState({ modalIsVisible: true });
|
|
2233
|
+
setTimeout(() => {
|
|
2234
|
+
controller.inputRef?.current?.focus();
|
|
2235
|
+
}, DURATION_ANIMATION$1);
|
|
2236
|
+
}
|
|
2227
2237
|
function onClickAction() {
|
|
2228
|
-
controller.
|
|
2229
|
-
|
|
2230
|
-
|
|
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
|
+
}
|
|
2231
2246
|
}
|
|
2232
2247
|
function onClickBackdrop() {
|
|
2233
2248
|
controller.setState({ modalIsVisible: false });
|
|
@@ -2245,15 +2260,16 @@ function useFieldAutocomplete(props) {
|
|
|
2245
2260
|
};
|
|
2246
2261
|
}
|
|
2247
2262
|
function onChange({ description, value }) {
|
|
2248
|
-
|
|
2263
|
+
const { onSelect, onValue } = props;
|
|
2264
|
+
if (onSelect) {
|
|
2249
2265
|
controller.setState({ modalIsVisible: false });
|
|
2250
|
-
value &&
|
|
2266
|
+
value && onSelect(value);
|
|
2251
2267
|
}
|
|
2252
2268
|
else {
|
|
2253
2269
|
controller.setState({ modalIsVisible: false, value: description });
|
|
2254
2270
|
controller.setFormValue(value);
|
|
2255
2271
|
}
|
|
2256
|
-
|
|
2272
|
+
onValue && onValue(value);
|
|
2257
2273
|
}
|
|
2258
2274
|
function refreshCoincidences(pattern, reboot = false) {
|
|
2259
2275
|
const { collection, store } = createAutocompleteStore({
|
|
@@ -2284,7 +2300,7 @@ function useFieldAutocomplete(props) {
|
|
|
2284
2300
|
function RlsFieldAutocompleteTemplate(props) {
|
|
2285
2301
|
const autocomplete = useFieldAutocomplete(props);
|
|
2286
2302
|
const { controller } = autocomplete;
|
|
2287
|
-
const { render, children, formControl,
|
|
2303
|
+
const { render, children, formControl, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2288
2304
|
const disabled = formControl?.disabled || props.disabled;
|
|
2289
2305
|
const className = renderClassStatus('rls-field-box', {
|
|
2290
2306
|
focused: controller.focused,
|
|
@@ -2292,12 +2308,12 @@ function RlsFieldAutocompleteTemplate(props) {
|
|
|
2292
2308
|
error: formControl?.wrong,
|
|
2293
2309
|
selected: !!controller.value
|
|
2294
2310
|
}, '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 }),
|
|
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', {
|
|
2296
2312
|
visible: controller.modalIsVisible,
|
|
2297
2313
|
higher: controller.higher,
|
|
2298
2314
|
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);
|
|
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);
|
|
2301
2317
|
}, disabled: disabled || searching, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: autocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
2302
2318
|
onSearch(autocomplete.pattern);
|
|
2303
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 })] })] }));
|
|
@@ -2538,16 +2554,17 @@ function useFieldSelect(props) {
|
|
|
2538
2554
|
};
|
|
2539
2555
|
}
|
|
2540
2556
|
function onChange({ description, value }) {
|
|
2557
|
+
const { onSelect, onValue } = props;
|
|
2541
2558
|
controller.inputRef?.current?.focus();
|
|
2542
|
-
if (
|
|
2559
|
+
if (onSelect) {
|
|
2543
2560
|
controller.setState({ modalIsVisible: false });
|
|
2544
|
-
value &&
|
|
2561
|
+
value && onSelect(value);
|
|
2545
2562
|
}
|
|
2546
2563
|
else {
|
|
2547
2564
|
controller.setFormValue(value);
|
|
2548
2565
|
controller.setState({ modalIsVisible: false, value: description });
|
|
2549
2566
|
}
|
|
2550
|
-
|
|
2567
|
+
onValue && onValue(value);
|
|
2551
2568
|
}
|
|
2552
2569
|
return {
|
|
2553
2570
|
controller,
|