@rolster/react-components 18.12.6 → 18.12.8

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.
Files changed (30) hide show
  1. package/dist/cjs/assets/{index-r16o2aIF.css → index-7UzJ6VgT.css} +28 -18
  2. package/dist/cjs/index.js +39 -35
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/es/assets/{index-r16o2aIF.css → index-7UzJ6VgT.css} +28 -18
  5. package/dist/es/index.js +38 -36
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/esm/components/atoms/Badge/Badge.css +18 -0
  8. package/dist/esm/components/atoms/Badge/Badge.d.ts +3 -0
  9. package/dist/esm/components/atoms/Badge/Badge.js +6 -0
  10. package/dist/esm/components/atoms/Badge/Badge.js.map +1 -0
  11. package/dist/esm/components/atoms/index.d.ts +1 -0
  12. package/dist/esm/components/atoms/index.js +1 -0
  13. package/dist/esm/components/atoms/index.js.map +1 -1
  14. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.css +4 -3
  15. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.d.ts +3 -2
  16. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js +8 -11
  17. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
  18. package/dist/esm/components/molecules/Toolbar/Toolbar.css +5 -15
  19. package/dist/esm/components/molecules/Toolbar/Toolbar.js +1 -1
  20. package/dist/esm/components/molecules/Toolbar/Toolbar.js.map +1 -1
  21. package/dist/esm/components/organisms/Datatable/Datatable.d.ts +5 -3
  22. package/dist/esm/components/organisms/Datatable/Datatable.js +7 -8
  23. package/dist/esm/components/organisms/Datatable/Datatable.js.map +1 -1
  24. package/dist/esm/hooks/DatatableHook.d.ts +6 -0
  25. package/dist/esm/hooks/DatatableHook.js +12 -0
  26. package/dist/esm/hooks/DatatableHook.js.map +1 -0
  27. package/dist/esm/hooks/index.d.ts +1 -0
  28. package/dist/esm/hooks/index.js +1 -0
  29. package/dist/esm/hooks/index.js.map +1 -1
  30. package/package.json +4 -4
@@ -51,6 +51,25 @@
51
51
  line-height: inherit;
52
52
  }
53
53
 
54
+ .rls-badge {
55
+ position: relative;
56
+ display: inline-block;
57
+ width: auto;
58
+ padding: var(--sizing-x2);
59
+ box-sizing: border-box;
60
+ font-size: var(--caption-font-size);
61
+ letter-spacing: var(--caption-letter-spacing);
62
+ line-height: var(--caption-line-height);
63
+ color: var(--color-rolster-500);
64
+ background: var(--color-rolster-100);
65
+ border-radius: var(--sizing-x2);
66
+ }
67
+ .rls-badge > span {
68
+ font-size: inherit;
69
+ letter-spacing: inherit;
70
+ line-height: inherit;
71
+ }
72
+
54
73
  .rls-breadcrumb {
55
74
  --pvt-link-font-color: var(--color-theme-300);
56
75
  display: -webkit-box;
@@ -933,12 +952,13 @@
933
952
  overflow-x: hidden;
934
953
  z-index: var(--z-index-2);
935
954
  background: var(--background-theme-500);
936
- border: var(--border-3) solid var(--color-rolster-300);
955
+ border: var(--border-1-rolster-500);
937
956
  transform: var(--rls-button-toggle-ul-transform);
938
957
  transform-origin: 0% 0%;
939
958
  transition: transform 240ms 0ms var(--standard-curve),
940
959
  opacity 240ms 0ms var(--standard-curve);
941
960
  will-change: opacity, transform;
961
+ box-shadow: 0px 0px 0px 3px var(--box-shadow-rolster-500);
942
962
  }
943
963
  .rls-button-toggle__list ul li {
944
964
  padding: 0rem var(--sizing-x6);
@@ -946,8 +966,8 @@
946
966
  height: var(--sizing-x20);
947
967
  line-height: var(--sizing-x20);
948
968
  cursor: default;
949
- font-weight: var(--font-weight-bold);
950
- font-size: 6.6rem;
969
+ font-weight: var(--font-weight-semibold);
970
+ font-size: 6rem;
951
971
  letter-spacing: 0.825px;
952
972
  text-transform: uppercase;
953
973
  color: var(--color-theme-300);
@@ -1390,28 +1410,21 @@
1390
1410
  .rls-toolbar {
1391
1411
  display: flex;
1392
1412
  justify-content: space-between;
1413
+ align-items: center;
1393
1414
  column-gap: var(--sizing-x6);
1394
1415
  height: var(--rls-toolbar-height);
1395
1416
  }
1396
1417
  .rls-toolbar > * {
1397
1418
  width: auto;
1398
1419
  }
1399
- .rls-toolbar__content {
1400
- display: flex;
1401
- height: 100%;
1402
- padding: var(--sizing-x2) var(--sizing-x6);
1403
- box-sizing: border-box;
1404
- margin: auto 0rem;
1405
- }
1406
1420
  .rls-toolbar__description {
1421
+ display: flex;
1422
+ flex-direction: column;
1423
+ row-gap: var(--sizing-x2);
1407
1424
  overflow: hidden;
1408
- padding: 0rem var(--sizing-x2);
1409
- box-sizing: border-box;
1410
- margin: auto 0rem;
1411
1425
  }
1412
1426
  .rls-toolbar__description > label {
1413
1427
  position: relative;
1414
- float: left;
1415
1428
  width: 100%;
1416
1429
  overflow: hidden;
1417
1430
  text-overflow: ellipsis;
@@ -1431,11 +1444,8 @@
1431
1444
  .rls-toolbar__actions {
1432
1445
  display: flex;
1433
1446
  box-sizing: border-box;
1434
- margin: auto 0rem;
1435
1447
  column-gap: var(--sizing-x8);
1436
- }
1437
- .rls-toolbar__actions > * {
1438
- margin: auto 0rem;
1448
+ align-items: center;
1439
1449
  }
1440
1450
 
1441
1451
  .rls-year-picker {
package/dist/es/index.js CHANGED
@@ -5,6 +5,7 @@ import { daysFromMonth, weight, assignDay, DAY_LABELS, formatDate, between, Date
5
5
  import { hasPattern } from '@rolster/helpers-string';
6
6
  import { i18n } from '@rolster/i18n';
7
7
  import ReactDOM from 'react-dom';
8
+ import { createFormControlProps } from '@rolster/helpers-forms';
8
9
  import 'uuid';
9
10
  import { BehaviorSubject } from 'rxjs';
10
11
 
@@ -40,6 +41,10 @@ function RlsAvatar({ children, rounded, skeleton, rlsTheme }) {
40
41
  return (jsx("div", { className: renderClassStatus('rls-avatar', { rounded, skeleton }), "rls-theme": rlsTheme, children: children }));
41
42
  }
42
43
 
44
+ function RlsBadge({ children, rlsTheme }) {
45
+ return (jsx("div", { className: "rls-badge", "rls-theme": rlsTheme, children: children }));
46
+ }
47
+
43
48
  function RlsBreadcrumb({ labels }) {
44
49
  return (jsx("div", { className: "rls-breadcrumb", children: labels.map(({ label, onClick }, index) => (jsx("label", { className: "rls-breadcrumb__label", onClick: onClick, children: jsx("a", { className: "rls-breadcrumb__label__a", children: label }) }, index))) }));
45
50
  }
@@ -209,14 +214,14 @@ function RlsBallot({ bordered, children, img, initials, skeleton, subtitle, rlsT
209
214
  return (jsxs("div", { className: renderClassStatus('rls-ballot', { bordered, skeleton }), "rls-theme": rlsTheme, children: [(img || initials) && (jsxs(RlsAvatar, { skeleton: skeleton, children: [img && jsx("img", { src: img }), initials && jsx("span", { children: initials })] })), jsxs("div", { className: "rls-ballot__component", children: [jsx("label", { className: "rls-ballot__title", children: jsx(RlsSkeletonText, { active: skeleton, children: children }) }), subtitle && (jsx("label", { className: "rls-ballot__subtitle", children: jsx(RlsSkeletonText, { active: skeleton, children: subtitle }) }))] })] }));
210
215
  }
211
216
 
212
- function RlsButtonToggle({ options, type, disabled, rlsTheme, onAction }) {
213
- const contentRef = useRef(null);
217
+ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsTheme }) {
218
+ const componentRef = useRef(null);
214
219
  const [firstAction] = options;
215
220
  const [action, setAction] = useState(firstAction);
216
221
  const [visible, setVisible] = useState(false);
217
222
  useEffect(() => {
218
223
  function onCloseMenu({ target }) {
219
- if (!contentRef?.current?.contains(target)) {
224
+ if (!componentRef?.current?.contains(target)) {
220
225
  setVisible(false);
221
226
  }
222
227
  }
@@ -231,17 +236,14 @@ function RlsButtonToggle({ options, type, disabled, rlsTheme, onAction }) {
231
236
  function onSelectAction(action) {
232
237
  setAction(action);
233
238
  setVisible(false);
239
+ if (automatic) {
240
+ onAction(action.value);
241
+ }
234
242
  }
235
- return (jsxs("div", { className: "rls-button-toggle", ref: contentRef, "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-button-toggle__content", children: [action && (jsx("div", { className: "rls-button-toggle__action", children: jsx(RlsButton, { disabled: disabled, type: type, onClick: () => {
236
- if (onAction) {
237
- onAction(action.value);
238
- }
239
- }, children: action.label }) })), jsx("div", { className: "rls-button-toggle__icon", children: jsx(RlsButton, { type: type, prefixIcon: "arrow-ios-down", disabled: disabled, onClick: onClickMenu }) })] }), jsx("div", { className: renderClassStatus('rls-button-toggle__list', {
243
+ return (jsxs("div", { className: "rls-button-toggle", ref: componentRef, "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-button-toggle__content", children: [action && (jsx("div", { className: "rls-button-toggle__action", children: jsx(RlsButton, { disabled: disabled, type: type, onClick: () => onAction(action.value), children: action.label }) })), jsx("div", { className: "rls-button-toggle__icon", children: jsx(RlsButton, { type: type, prefixIcon: "arrow-ios-down", disabled: disabled, onClick: onClickMenu }) })] }), jsx("div", { className: renderClassStatus('rls-button-toggle__list', {
240
244
  visible,
241
245
  hide: !visible
242
- }), children: jsx("ul", { children: options.map((action, index) => (jsx("li", { className: "truncate", onClick: () => {
243
- onSelectAction(action);
244
- }, children: action.label }, index))) }) })] }));
246
+ }), children: jsx("ul", { children: options.map((action, index) => (jsx("li", { className: "truncate", onClick: () => onSelectAction(action), children: action.label }, index))) }) })] }));
245
247
  }
246
248
 
247
249
  function RlsCheckBoxLabel({ children, disabled, extended, formControl, rlsTheme }) {
@@ -960,7 +962,7 @@ function RlsTextField({ children, disabled, formControl, placeholder, rlsTheme,
960
962
  }
961
963
 
962
964
  function RlsToolbar({ actions, children, subtitle }) {
963
- return (jsxs("div", { className: "rls-toolbar", children: [jsxs("div", { className: "rls-toolbar__description", children: [children && jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsx("label", { className: "rls-toolbar__subtitle caption-semibold", children: subtitle }))] }), actions && (jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsx("div", { children: action }, index))) }))] }));
965
+ return (jsxs("div", { className: "rls-toolbar", children: [jsxs("div", { className: "rls-toolbar__description", children: [children && jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsx("label", { className: "rls-toolbar__subtitle smalltext-semibold", children: subtitle }))] }), actions && (jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsx("div", { children: action }, index))) }))] }));
964
966
  }
965
967
 
966
968
  const COUNT_YEAR_RANGE = 4;
@@ -1110,6 +1112,17 @@ const reactI18n = i18n({
1110
1112
  }
1111
1113
  });
1112
1114
 
1115
+ function useDatatable() {
1116
+ const [scrolleable, setScrolleable] = useState(false);
1117
+ const bodyRef = useRef(null);
1118
+ useEffect(() => {
1119
+ const scrollHeight = bodyRef?.current?.scrollHeight || 0;
1120
+ const clientHeight = bodyRef?.current?.clientHeight || 0;
1121
+ setScrolleable(scrollHeight > clientHeight);
1122
+ }, [bodyRef]);
1123
+ return { bodyRef, scrolleable };
1124
+ }
1125
+
1113
1126
  class ListCollection {
1114
1127
  constructor(value) {
1115
1128
  this.value = value;
@@ -1524,19 +1537,18 @@ function RlsDatatableHeader({ children }) {
1524
1537
  return jsx("tr", { className: "rls-datatable__header", children: children });
1525
1538
  }
1526
1539
  function RlsDatatableTitle({ children, className, control }) {
1527
- return (jsx("th", { className: (renderClassStatus('rls-datatable__title', { control }) +
1528
- ` ${className || ''}`).trim(), children: children }));
1540
+ return (jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
1529
1541
  }
1530
1542
  function RlsDatatableData({ children, className, error }) {
1531
- return (jsx("tr", { className: (renderClassStatus('rls-datatable__data', { error }) +
1532
- ` ${className || ''}`).trim(), children: children }));
1543
+ return (jsx("tr", { className: renderClassStatus('rls-datatable__data', { error }, className).trim(), children: children }));
1533
1544
  }
1534
1545
  function RlsDatatableCell({ children, className, control, overflow }) {
1535
- return (jsx("th", { className: (renderClassStatus('rls-datatable__cell', { control, overflow }) +
1536
- ` ${className || ''}`).trim(), children: children }));
1546
+ return (jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
1537
1547
  }
1538
- function RlsDatatable({ children, footer, header, rlsTheme }) {
1539
- return (jsxs("div", { className: "rls-datatable", "rls-theme": rlsTheme, children: [jsxs("table", { children: [header && jsx("thead", { className: "rls-datatable__thead", children: header }), jsx("tbody", { className: "rls-datatable__tbody", children: children })] }), footer && jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
1548
+ function RlsDatatable({ children, datatable, footer, header, rlsTheme }) {
1549
+ return (jsxs("div", { className: renderClassStatus('rls-datatable', {
1550
+ scrolleable: datatable?.scrolleable
1551
+ }), "rls-theme": rlsTheme, children: [jsxs("table", { children: [header && jsx("thead", { className: "rls-datatable__thead", children: header }), jsx("tbody", { ref: datatable?.bodyRef, className: "rls-datatable__tbody", children: children })] }), footer && jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
1540
1552
  }
1541
1553
 
1542
1554
  const controlIsValid = (props) => {
@@ -1550,21 +1562,8 @@ const controlIsValid = (props) => {
1550
1562
  }, []);
1551
1563
  };
1552
1564
 
1553
- function instanceOfReactControlProps(props) {
1554
- return (typeof props === 'object' && ('state' in props || 'validators' in props));
1555
- }
1556
- function createReactControlProps(...argsProps) {
1557
- if (argsProps.length < 1) {
1558
- return { state: undefined, validators: undefined };
1559
- }
1560
- const [state, validators] = argsProps;
1561
- if (argsProps.length < 2 && instanceOfReactControlProps(state)) {
1562
- return state;
1563
- }
1564
- return { state: state, validators };
1565
- }
1566
- function useReactControl(controlProps, controlValidators) {
1567
- const props = createReactControlProps(controlProps, controlValidators);
1565
+ function useControl(controlProps, controlValidators) {
1566
+ const props = createFormControlProps(controlProps, controlValidators);
1568
1567
  const [state, setCurrentState] = useState(props.state);
1569
1568
  const [value, setValue] = useState(props.state);
1570
1569
  const [touched, setTouched] = useState(props.touched || false);
@@ -1643,6 +1642,9 @@ function useReactControl(controlProps, controlValidators) {
1643
1642
  value,
1644
1643
  wrong: touched && !valid
1645
1644
  };
1645
+ }
1646
+ function useReactControl(controlProps, controlValidators) {
1647
+ return useControl(controlProps, controlValidators);
1646
1648
  }
1647
1649
 
1648
1650
  var PickerListenerType;
@@ -2094,5 +2096,5 @@ function RlsApplication({ children }) {
2094
2096
  return (jsxs(RlsContext.Provider, { value: { confirmation, snackbar }, children: [jsx("div", { className: "rls-app__body", children: children }), RlsSnackbar, RlsConfirmation] }));
2095
2097
  }
2096
2098
 
2097
- export { ConfirmationResult, ListCollection, RlsAmount, RlsApplication, RlsAutocompleteField, RlsAutocompleteFieldTemplate, RlsAvatar, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsCheckBoxLabel, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableTitle, RlsDateField, RlsDatePicker, RlsDateRangeField, RlsDateRangePicker, RlsDayPicker, RlsDayRangePicker, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputText, RlsLabel, RlsMessageIcon, RlsModal, RlsMoneyField, RlsMonthPicker, RlsMonthTitlePicker, RlsNumberField, RlsPagination, RlsPasswordField, RlsPoster, RlsProgressBar, RlsRadioButton, RlsRadioButtonLabel, RlsSearchInput, RlsSelectField, RlsSelectFieldTemplate, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsSwitchLabel, RlsTabularText, RlsTextField, RlsToolbar, RlsYearPicker, renderClassStatus, useConfirmationService, useListControl, useSnackbarService };
2099
+ export { ConfirmationResult, ListCollection, RlsAmount, RlsApplication, RlsAutocompleteField, RlsAutocompleteFieldTemplate, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsCheckBoxLabel, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableTitle, RlsDateField, RlsDatePicker, RlsDateRangeField, RlsDateRangePicker, RlsDayPicker, RlsDayRangePicker, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputText, RlsLabel, RlsMessageIcon, RlsModal, RlsMoneyField, RlsMonthPicker, RlsMonthTitlePicker, RlsNumberField, RlsPagination, RlsPasswordField, RlsPoster, RlsProgressBar, RlsRadioButton, RlsRadioButtonLabel, RlsSearchInput, RlsSelectField, RlsSelectFieldTemplate, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsSwitchLabel, RlsTabularText, RlsTextField, RlsToolbar, RlsYearPicker, renderClassStatus, useConfirmationService, useDatatable, useListControl, useSnackbarService };
2098
2100
  //# sourceMappingURL=index.js.map