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