@rolster/react-components 18.21.9 → 18.21.10

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.js CHANGED
@@ -1540,10 +1540,18 @@ function RlsCheckBoxControl({ formControl, disabled, identifier, rlsTheme }) {
1540
1540
  }
1541
1541
 
1542
1542
  function RlsInput({ children, disabled, formControl, identifier, onValue, placeholder, type, value }) {
1543
+ const valueInitial = formControl?.value ?? value ? String(value) : '';
1544
+ const [valueInput, setValueInput] = require$$0.useState(valueInitial);
1543
1545
  const [focused, setFocused] = require$$0.useState(false);
1546
+ require$$0.useEffect(() => {
1547
+ const valueControl = formControl?.value ? String(formControl.value) : '';
1548
+ (!focused || valueInput !== valueControl) && setValueInput(valueControl);
1549
+ }, [formControl?.value]);
1544
1550
  const onChange = require$$0.useCallback((event) => {
1545
- const value = type === 'number' ? +event.target.value : event.target.value;
1551
+ const valueInput = event.target.value;
1552
+ const value = type === 'number' ? +valueInput : valueInput;
1546
1553
  onValue && onValue(value);
1554
+ setValueInput(valueInput);
1547
1555
  formControl?.setValue(value);
1548
1556
  }, [formControl, onValue]);
1549
1557
  const onFocus = require$$0.useCallback(() => {
@@ -1560,25 +1568,25 @@ function RlsInput({ children, disabled, formControl, identifier, onValue, placeh
1560
1568
  focused: formControl?.focused ?? focused
1561
1569
  });
1562
1570
  }, [formControl?.focused, formControl?.disabled, focused, disabled]);
1563
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.value || value || '' }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
1571
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: valueInput }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
1564
1572
  }
1565
1573
 
1566
1574
  function RlsInputMoney({ decimals, disabled, formControl, identifier, onValue, placeholder, symbol, value }) {
1567
- const [valueInput, setValueInput] = require$$0.useState(value || 0);
1575
+ const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? 0);
1568
1576
  const onValueInput = require$$0.useCallback((value) => {
1569
1577
  !formControl && setValueInput(value);
1570
1578
  onValue && onValue(value);
1571
1579
  }, [formControl, onValue]);
1572
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onValueInput, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value ?? value ?? valueInput, symbol: symbol, decimals: decimals }) }) }));
1580
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: valueInput, disabled: disabled, placeholder: placeholder, onValue: onValueInput, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value ?? valueInput, symbol: symbol, decimals: decimals }) }) }));
1573
1581
  }
1574
1582
 
1575
1583
  function RlsInputNumber({ disabled, formControl, identifier, onValue, placeholder, value }) {
1576
- const [valueInput, setValueInput] = require$$0.useState(value ?? 0);
1584
+ const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? 0);
1577
1585
  const onValueInput = require$$0.useCallback((value) => {
1578
1586
  !formControl && setValueInput(value);
1579
1587
  onValue && onValue(value);
1580
1588
  }, [formControl, onValue]);
1581
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onValueInput, children: formControl?.value ?? value ?? valueInput }) }));
1589
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: valueInput, disabled: disabled, placeholder: placeholder, onValue: onValueInput, children: formControl?.value ?? valueInput }) }));
1582
1590
  }
1583
1591
 
1584
1592
  function RlsInputPassword({ disabled, formControl, identifier, onValue, placeholder, type }) {
@@ -1613,12 +1621,12 @@ function RlsInputSearch({ formControl, identifier, onSearch, placeholder }) {
1613
1621
  }
1614
1622
 
1615
1623
  function RlsInputText({ disabled, formControl, identifier, onValue, placeholder, value }) {
1616
- const [valueInput, setValueInput] = require$$0.useState(value ?? '');
1624
+ const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? '');
1617
1625
  const onValueInput = require$$0.useCallback((value) => {
1618
1626
  !formControl && setValueInput(value);
1619
1627
  onValue && onValue(value);
1620
1628
  }, [formControl, onValue]);
1621
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue: onValueInput, children: formControl?.value ?? value ?? valueInput }) }));
1629
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "text", value: valueInput, disabled: disabled, placeholder: placeholder, onValue: onValueInput, children: formControl?.value ?? valueInput }) }));
1622
1630
  }
1623
1631
 
1624
1632
  function RlsLabel({ children, rlsTheme }) {
@@ -2310,52 +2318,58 @@ function useConfirmation() {
2310
2318
  };
2311
2319
  }
2312
2320
 
2321
+ function RlsDatatable({ children, datatable, footer, header, identifier, rlsTheme, summary, toolbar }) {
2322
+ const className = require$$0.useMemo(() => {
2323
+ return renderClassStatus('rls-datatable', {
2324
+ scrolleable: datatable?.scrolleable
2325
+ });
2326
+ }, [datatable]);
2327
+ return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [toolbar && jsxRuntimeExports.jsx("div", { className: "rls-datatable__toolbar", children: toolbar }), jsxRuntimeExports.jsxs("table", { id: identifier, children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__head", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.tableRef, 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 })] }));
2328
+ }
2313
2329
  function RlsDatatableHeader({ children, identifier }) {
2314
2330
  return (jsxRuntimeExports.jsx("tr", { id: identifier, className: "rls-datatable__header", children: children }));
2315
2331
  }
2316
2332
  function RlsDatatableTitle({ children, className, control, identifier }) {
2317
- const classDatatableName = require$$0.useMemo(() => {
2333
+ const classNameTitle = require$$0.useMemo(() => {
2318
2334
  return renderClassStatus('rls-datatable__title', { control }, className);
2319
- }, [control, className]);
2320
- return (jsxRuntimeExports.jsx("th", { id: identifier, className: classDatatableName, children: children }));
2335
+ }, [className, control]);
2336
+ return (jsxRuntimeExports.jsx("th", { id: identifier, className: classNameTitle, children: children }));
2321
2337
  }
2322
2338
  function RlsDatatableSubheader({ children, className, identifier }) {
2323
- const classDatatableName = require$$0.useMemo(() => {
2339
+ const classNameSubheader = require$$0.useMemo(() => {
2324
2340
  return renderClassStatus('rls-datatable__subheader', {}, className);
2325
2341
  }, [className]);
2326
- return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classDatatableName, children: children }));
2342
+ return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classNameSubheader, children: children }));
2327
2343
  }
2328
- function RlsDatatableRecord({ children, className, error, identifier, info, successs, warning }) {
2329
- const classDatatableName = require$$0.useMemo(() => {
2330
- return renderClassStatus('rls-datatable__record', { error, info, successs, warning }, className);
2331
- }, [error, info, successs, warning, className]);
2332
- return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classDatatableName, children: children }));
2344
+ function RlsDatatableRecord({ children, className, error, identifier, info, overflow, successs, warning }) {
2345
+ const classNameRecord = require$$0.useMemo(() => {
2346
+ return renderClassStatus('rls-datatable__record', { error, info, overflow, successs, warning }, className);
2347
+ }, [className, error, info, overflow, successs, warning]);
2348
+ return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classNameRecord, children: children }));
2333
2349
  }
2334
- function RlsDatatableTotals({ children, className, error, identifier, info, successs, warning }) {
2335
- const classDatatableName = require$$0.useMemo(() => {
2336
- return renderClassStatus('rls-datatable__totals', { error, info, successs, warning }, className);
2337
- }, [error, info, successs, warning, className]);
2338
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: classDatatableName, children: children }));
2350
+ function RlsDatatableTotals({ children, className, error, identifier, info, overflow, successs, warning }) {
2351
+ const classNameTotals = require$$0.useMemo(() => {
2352
+ return renderClassStatus('rls-datatable__totals', { error, info, overflow, successs, warning }, className);
2353
+ }, [className, error, info, overflow, successs, warning]);
2354
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameTotals, children: children }));
2339
2355
  }
2340
2356
  function RlsDatatableCell({ children, className, control, identifier, overflow }) {
2341
- const classDatatableName = require$$0.useMemo(() => {
2357
+ const classNameCell = require$$0.useMemo(() => {
2342
2358
  return renderClassStatus('rls-datatable__cell', { control, overflow }, className);
2343
- }, [control, overflow, className]);
2344
- return (jsxRuntimeExports.jsx("th", { id: identifier, className: classDatatableName, children: children }));
2359
+ }, [className, control, overflow]);
2360
+ return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameCell, children: children }));
2345
2361
  }
2346
2362
  function RlsDatatableData({ children, className, control, identifier, overflow }) {
2347
- const classDatatableName = require$$0.useMemo(() => {
2363
+ const classNameData = require$$0.useMemo(() => {
2348
2364
  return renderClassStatus('rls-datatable__data', { control, overflow }, className);
2349
- }, [control, overflow, className]);
2350
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: classDatatableName, children: children }));
2365
+ }, [className, overflow, control]);
2366
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameData, children: children }));
2351
2367
  }
2352
- function RlsDatatable({ children, datatable, footer, header, identifier, rlsTheme, summary, toolbar }) {
2353
- const className = require$$0.useMemo(() => {
2354
- return renderClassStatus('rls-datatable', {
2355
- scrolleable: datatable?.scrolleable
2356
- });
2357
- }, [datatable]);
2358
- return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [toolbar && jsxRuntimeExports.jsx("div", { className: "rls-datatable__toolbar", children: toolbar }), jsxRuntimeExports.jsxs("table", { id: identifier, children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__head", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.tableRef, 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 })] }));
2368
+ function RlsDatatableFloating({ children, className, identifier, invested }) {
2369
+ const classNameFloating = require$$0.useMemo(() => {
2370
+ return renderClassStatus('rls-datatable__floating', { invested }, className);
2371
+ }, [className, invested]);
2372
+ return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameFloating, children: children }));
2359
2373
  }
2360
2374
 
2361
2375
  function createObserver(options) {
@@ -3131,6 +3145,7 @@ exports.RlsContext = RlsContext;
3131
3145
  exports.RlsDatatable = RlsDatatable;
3132
3146
  exports.RlsDatatableCell = RlsDatatableCell;
3133
3147
  exports.RlsDatatableData = RlsDatatableData;
3148
+ exports.RlsDatatableFloating = RlsDatatableFloating;
3134
3149
  exports.RlsDatatableHeader = RlsDatatableHeader;
3135
3150
  exports.RlsDatatableRecord = RlsDatatableRecord;
3136
3151
  exports.RlsDatatableSubheader = RlsDatatableSubheader;