@rolster/react-components 19.10.0 → 19.11.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.
@@ -721,6 +721,12 @@ function RlsCheckBoxControlComponent({ formControl, disabled, identifier, rlsThe
721
721
  }
722
722
  const RlsCheckBoxControl = require$$0.memo(RlsCheckBoxControlComponent);
723
723
 
724
+ function RlsChipComponent({ children, className, contrasted, disabled, icon, identifier, onClick, onRemove, rlsTheme, selected }) {
725
+ const classNameChip = renderClassStatus('rls-chip', { clickable: !!onClick && !disabled, contrasted, disabled, selected }, className);
726
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: classNameChip, "rls-theme": rlsTheme, onClick: disabled ? undefined : onClick, children: [icon && jsxRuntimeExports.jsx(RlsIcon, { className: "rls-chip__icon", value: icon }), jsxRuntimeExports.jsx("span", { className: "rls-chip__description", children: children }), onRemove && !disabled && (jsxRuntimeExports.jsx("button", { className: "rls-chip__remove", type: "button", onClick: onRemove, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }))] }));
727
+ }
728
+ const RlsChip = require$$0.memo(RlsChipComponent);
729
+
724
730
  function RlsSkeletonComponent({ animation, rlsTheme }) {
725
731
  const className = renderClassStatus('rls-skeleton', {
726
732
  animation: animation !== 'shimmer' && animation
@@ -1671,6 +1677,36 @@ function RlsButtonToggleComponent({ onAction, options, type, automatic, disabled
1671
1677
  }
1672
1678
  const RlsButtonToggle = require$$0.memo(RlsButtonToggleComponent);
1673
1679
 
1680
+ function RlsChipGroupComponent({ className, disabled: disabledProps, formControl, identifier, onValue, options, reference, render, rlsTheme, value: valueInitial }) {
1681
+ const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
1682
+ const selected = require$$0.useMemo(() => {
1683
+ return formControl ? formControl.value : value;
1684
+ }, [formControl?.value, value]);
1685
+ const disabled = require$$0.useMemo(() => {
1686
+ return formControl?.disabled || disabledProps;
1687
+ }, [formControl?.disabled, disabledProps]);
1688
+ const classNameGroup = renderClassStatus('rls-chip-group', { disabled }, className);
1689
+ const isSelected = require$$0.useCallback((option) => {
1690
+ if (selected === undefined || selected === null) {
1691
+ return false;
1692
+ }
1693
+ return reference
1694
+ ? reference(option) === reference(selected)
1695
+ : option === selected;
1696
+ }, [reference, selected]);
1697
+ const onSelect = require$$0.useCallback((option) => () => {
1698
+ if (disabled) {
1699
+ return;
1700
+ }
1701
+ setValue(option);
1702
+ formControl?.setValue(option);
1703
+ formControl?.touch();
1704
+ onValue?.(option);
1705
+ }, [disabled, formControl, onValue]);
1706
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameGroup, "rls-theme": rlsTheme, children: options.map((option, index) => (jsxRuntimeExports.jsx(RlsChip, { disabled: disabled, selected: isSelected(option), onClick: onSelect(option), children: render ? render(option) : String(option) }, index))) }));
1707
+ }
1708
+ const RlsChipGroup = require$$0.memo(RlsChipGroupComponent);
1709
+
1674
1710
  function RlsContentComponent({ children, identifier, rlsTheme }) {
1675
1711
  return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-app__page__content", "rls-theme": rlsTheme, children: children }));
1676
1712
  }
@@ -4609,7 +4645,9 @@ function RlsFieldListInner({ render, suggestions, action, children, formControl,
4609
4645
  readonly: props.readOnly
4610
4646
  }, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
4611
4647
  const renderWithCheckbox = require$$0.useCallback((element) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__element", children: [jsxRuntimeExports.jsx(RlsCheckBox, { checked: fieldList.isSelected(element) }), render(element)] })), [fieldList.isSelected, render]);
4612
- return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { 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("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__chip", children: [jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__chip__description", children: item.description }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__multi__chip__remove", onClick: fieldList.onRemoveElement(item), children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }))] }, index)))) }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", onClick: fieldList.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: fieldList.listIsVisible, action: action, disabled: disabled, higher: fieldList.higher, render: renderWithCheckbox, refAnchor: fieldList.refContent, refList: fieldList.refList, refSuggestions: fieldList.refSuggestions, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop, onHiddenAnchor: fieldList.onClickBackdrop })] }));
4648
+ return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { 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("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.jsx(RlsChip, { onRemove: !props.readOnly && !disabled
4649
+ ? fieldList.onRemoveElement(item)
4650
+ : undefined, children: item.description }, index)))) }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", onClick: fieldList.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: fieldList.listIsVisible, action: action, disabled: disabled, higher: fieldList.higher, render: renderWithCheckbox, refAnchor: fieldList.refContent, refList: fieldList.refList, refSuggestions: fieldList.refSuggestions, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop, onHiddenAnchor: fieldList.onClickBackdrop })] }));
4613
4651
  }
4614
4652
  function RlsFieldListTemplateComponent(props) {
4615
4653
  const fieldList = useFieldList(props);
@@ -5098,6 +5136,46 @@ function RlsImageChooserComponent(props) {
5098
5136
  }
5099
5137
  const RlsImageChooser = require$$0.memo(RlsImageChooserComponent);
5100
5138
 
5139
+ function RlsLedColorComponent({ className, color, disabled: disabledProps, formControl, identifier, onValue, readOnly, rlsTheme, value: valueInitial }) {
5140
+ const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
5141
+ const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
5142
+ const [pickerKey, setPickerKey] = require$$0.useState(0);
5143
+ const colorValue = require$$0.useMemo(() => {
5144
+ return formControl ? formControl.value : value;
5145
+ }, [formControl?.value, value]);
5146
+ const disabled = require$$0.useMemo(() => {
5147
+ return formControl?.disabled || disabledProps;
5148
+ }, [formControl?.disabled, disabledProps]);
5149
+ const ledColor = require$$0.useMemo(() => {
5150
+ return colorValue && hexIsValid(colorValue)
5151
+ ? normalizeHex(colorValue)
5152
+ : undefined;
5153
+ }, [colorValue]);
5154
+ const classNameLed = renderClassStatus('rls-led-color', { disabled, error: formControl?.wrong, readonly: readOnly }, className);
5155
+ const onChange = require$$0.useCallback((value) => {
5156
+ setValue(value);
5157
+ onValue?.(value);
5158
+ }, [onValue]);
5159
+ const onClickLed = require$$0.useCallback(() => {
5160
+ if (!disabled && !readOnly) {
5161
+ setPickerKey((key) => key + 1);
5162
+ setModalIsVisible(true);
5163
+ }
5164
+ }, [disabled, readOnly]);
5165
+ const onListener = require$$0.useCallback(({ event, value }) => {
5166
+ if (event !== components.PickerListenerEvent.Cancel) {
5167
+ onChange(value);
5168
+ }
5169
+ formControl?.touch();
5170
+ setModalIsVisible(false);
5171
+ }, [formControl, onChange]);
5172
+ const onBackdrop = require$$0.useCallback(() => {
5173
+ setModalIsVisible(false);
5174
+ }, []);
5175
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: classNameLed, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("button", { className: "rls-led-color__trigger", type: "button", disabled: disabled, onClick: onClickLed, children: jsxRuntimeExports.jsx(RlsLed, { color: ledColor, rlsTheme: rlsTheme }) }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-modal-color", visible: modalIsVisible, rlsTheme: rlsTheme, onBackdrop: onBackdrop, children: jsxRuntimeExports.jsx(RlsPickerColor, { formControl: formControl, color: ledColor ?? color, disabled: disabled, onListener: onListener }, pickerKey) })] }));
5176
+ }
5177
+ const RlsLedColor = require$$0.memo(RlsLedColorComponent);
5178
+
5101
5179
  function RlsModalSheetComponent({ autoclose, children, className, controller, onAutoClose, visible, rlsTheme }) {
5102
5180
  const classNameModal = renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
5103
5181
  const onClickBackdrop = require$$0.useCallback(() => {
@@ -5455,6 +5533,8 @@ exports.RlsButtonToggle = RlsButtonToggle;
5455
5533
  exports.RlsCard = RlsCard;
5456
5534
  exports.RlsCheckBox = RlsCheckBox;
5457
5535
  exports.RlsCheckBoxControl = RlsCheckBoxControl;
5536
+ exports.RlsChip = RlsChip;
5537
+ exports.RlsChipGroup = RlsChipGroup;
5458
5538
  exports.RlsChooserAutocomplete = RlsChooserAutocomplete;
5459
5539
  exports.RlsChooserAutocompleteTemplate = RlsChooserAutocompleteTemplate;
5460
5540
  exports.RlsChooserList = RlsChooserList;
@@ -5514,6 +5594,7 @@ exports.RlsLabelCheckBox = RlsLabelCheckBox;
5514
5594
  exports.RlsLabelRadioButton = RlsLabelRadioButton;
5515
5595
  exports.RlsLabelSwitch = RlsLabelSwitch;
5516
5596
  exports.RlsLed = RlsLed;
5597
+ exports.RlsLedColor = RlsLedColor;
5517
5598
  exports.RlsMessageEmpty = RlsMessageEmpty;
5518
5599
  exports.RlsMessageFormError = RlsMessageFormError;
5519
5600
  exports.RlsMessageIcon = RlsMessageIcon;