@rolster/react-components 18.21.45 → 18.22.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.
Files changed (64) hide show
  1. package/dist/cjs/assets/{index-CaA_sxmM.css → index-PeMi6MeC.css} +197 -0
  2. package/dist/cjs/index.js +516 -76
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/es/assets/{index-CaA_sxmM.css → index-PeMi6MeC.css} +197 -0
  5. package/dist/es/index.js +512 -77
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/esm/components/molecules/PickerDay/PickerDay.js +13 -13
  8. package/dist/esm/components/molecules/PickerDay/PickerDay.js.map +1 -1
  9. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +12 -12
  10. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
  11. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +10 -10
  12. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
  13. package/dist/esm/components/molecules/PickerYear/PickerYear.js +11 -11
  14. package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
  15. package/dist/esm/components/molecules/Slider/Slider.css +60 -0
  16. package/dist/esm/components/molecules/Slider/Slider.css.map +1 -0
  17. package/dist/esm/components/molecules/Slider/Slider.d.ts +14 -0
  18. package/dist/esm/components/molecules/Slider/Slider.js +60 -0
  19. package/dist/esm/components/molecules/Slider/Slider.js.map +1 -0
  20. package/dist/esm/components/molecules/index.d.ts +1 -0
  21. package/dist/esm/components/molecules/index.js +1 -0
  22. package/dist/esm/components/molecules/index.js.map +1 -1
  23. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +1 -1
  24. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js +5 -2
  25. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js.map +1 -1
  26. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +3 -3
  27. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
  28. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js +7 -3
  29. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js.map +1 -1
  30. package/dist/esm/components/organisms/ImageChooser/ImageChooser.css +37 -0
  31. package/dist/esm/components/organisms/ImageChooser/ImageChooser.css.map +1 -0
  32. package/dist/esm/components/organisms/ImageChooser/ImageChooser.d.ts +11 -0
  33. package/dist/esm/components/organisms/ImageChooser/ImageChooser.js +62 -0
  34. package/dist/esm/components/organisms/ImageChooser/ImageChooser.js.map +1 -0
  35. package/dist/esm/components/organisms/ImageEditor/ImageEditor.css +97 -0
  36. package/dist/esm/components/organisms/ImageEditor/ImageEditor.css.map +1 -0
  37. package/dist/esm/components/organisms/ImageEditor/ImageEditor.d.ts +20 -0
  38. package/dist/esm/components/organisms/ImageEditor/ImageEditor.js +201 -0
  39. package/dist/esm/components/organisms/ImageEditor/ImageEditor.js.map +1 -0
  40. package/dist/esm/components/organisms/Modal/Modal.d.ts +2 -1
  41. package/dist/esm/components/organisms/Modal/Modal.js +5 -5
  42. package/dist/esm/components/organisms/Modal/Modal.js.map +1 -1
  43. package/dist/esm/components/organisms/PickerDate/PickerDate.js +1 -1
  44. package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
  45. package/dist/esm/components/organisms/index.d.ts +2 -0
  46. package/dist/esm/components/organisms/index.js +2 -0
  47. package/dist/esm/components/organisms/index.js.map +1 -1
  48. package/dist/esm/controllers/ListController.d.ts +3 -3
  49. package/dist/esm/controllers/ListController.js +16 -16
  50. package/dist/esm/controllers/ListController.js.map +1 -1
  51. package/dist/esm/controllers/RelocationOnComponentController.d.ts +8 -0
  52. package/dist/esm/controllers/RelocationOnComponentController.js +93 -0
  53. package/dist/esm/controllers/RelocationOnComponentController.js.map +1 -0
  54. package/dist/esm/controllers/ResizeController.d.ts +15 -0
  55. package/dist/esm/controllers/ResizeController.js +29 -0
  56. package/dist/esm/controllers/ResizeController.js.map +1 -0
  57. package/dist/esm/controllers/index.d.ts +2 -0
  58. package/dist/esm/controllers/index.js +2 -0
  59. package/dist/esm/controllers/index.js.map +1 -1
  60. package/dist/esm/definitions.d.ts +3 -3
  61. package/dist/esm/i18n.d.ts +3 -0
  62. package/dist/esm/i18n.js +6 -0
  63. package/dist/esm/i18n.js.map +1 -1
  64. package/package.json +1 -1
package/dist/es/index.js CHANGED
@@ -1966,7 +1966,10 @@ function RlsPagination({ suggestions, count, filter, onPagination }) {
1966
1966
  }) }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__description", children: template?.description }), jsxRuntimeExports.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: template?.lastPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-right" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: template?.lastPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
1967
1967
  }
1968
1968
 
1969
- function RlsPickerDayItem({ day, onSelect, disabled }) {
1969
+ function RlsPickerDayHeaders() {
1970
+ return (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }));
1971
+ }
1972
+ function RlsPickerDayElement({ day, onSelect, disabled }) {
1970
1973
  const className = useMemo(() => {
1971
1974
  return renderClassStatus('rls-picker-day__element', {
1972
1975
  disabled: day.disabled || disabled,
@@ -1988,23 +1991,27 @@ function RlsPickerDayItem({ day, onSelect, disabled }) {
1988
1991
  }, [day.value, day.disabled, disabled, onSelect]);
1989
1992
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day__element__span", children: day.value || '??' }) }));
1990
1993
  }
1991
- function RlsPickerDayHeaders() {
1992
- return (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }));
1993
- }
1994
1994
  function RlsPickerDay({ date: _date, disabled, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
1995
1995
  const date = useMemo(() => _date ?? new Date(), [_date]);
1996
1996
  const [weeks, setWeeks] = useState([]);
1997
1997
  const [value, setValue] = useState(formControl?.value || date.getDate());
1998
1998
  const [headers, setHeaders] = useState(jsxRuntimeExports.jsx(RlsPickerDayHeaders, {}));
1999
1999
  const [component, setComponent] = useState(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}));
2000
+ const setDayValue = useCallback((value) => {
2001
+ formControl ? formControl.setValue(value) : setValue(value);
2002
+ }, [formControl]);
2003
+ const onSelect = useCallback((value) => {
2004
+ setDayValue(value);
2005
+ onValue && onValue(value);
2006
+ }, [setDayValue, onValue]);
2000
2007
  useEffect(() => {
2001
2008
  return i18nSubscribe(() => {
2002
2009
  setHeaders(jsxRuntimeExports.jsx(RlsPickerDayHeaders, {}));
2003
2010
  });
2004
2011
  }, []);
2005
2012
  useEffect(() => {
2006
- setComponent(jsxRuntimeExports.jsx("div", { className: "rls-picker-day__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__week", children: days.map((day, index) => (jsxRuntimeExports.jsx(RlsPickerDayItem, { day: day, onSelect: onSelect, disabled: disabled }, index))) }, index))) }));
2007
- }, [weeks]);
2013
+ setComponent(jsxRuntimeExports.jsx("div", { className: "rls-picker-day__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__week", children: days.map((day, index) => (jsxRuntimeExports.jsx(RlsPickerDayElement, { day: day, onSelect: onSelect, disabled: disabled }, index))) }, index))) }));
2014
+ }, [weeks, onSelect, disabled]);
2008
2015
  useEffect(() => {
2009
2016
  const options = createPickerOptions();
2010
2017
  const day = verifyDayPicker(options);
@@ -2026,13 +2033,6 @@ function RlsPickerDay({ date: _date, disabled, formControl, maxDate, month, minD
2026
2033
  maxDate
2027
2034
  };
2028
2035
  }, [date, formControl?.value, value, month, year, minDate, maxDate]);
2029
- const setDayValue = useCallback((value) => {
2030
- formControl ? formControl.setValue(value) : setValue(value);
2031
- }, [formControl]);
2032
- const onSelect = useCallback((value) => {
2033
- setDayValue(value);
2034
- onValue && onValue(value);
2035
- }, [setDayValue, onValue]);
2036
2036
  return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [headers, component] }));
2037
2037
  }
2038
2038
 
@@ -2040,7 +2040,7 @@ const formatRange = '{dd}/{mx}/{aa}';
2040
2040
  function RlsPickerDayRangeHeaders() {
2041
2041
  return (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }));
2042
2042
  }
2043
- function RlsPickerDayRangeItem({ day, onSelect, disabled }) {
2043
+ function RlsPickerDayRangeElement({ day, onSelect, disabled }) {
2044
2044
  const className = useMemo(() => {
2045
2045
  return renderClassStatus('rls-picker-day-range__element', {
2046
2046
  disabled: day.disabled || disabled,
@@ -2067,14 +2067,23 @@ function RlsPickerDayRange({ date: _date, disabled, formControl, maxDate, minDat
2067
2067
  const [range, setRange] = useState(_range);
2068
2068
  const [headers, setHeaders] = useState(jsxRuntimeExports.jsx(RlsPickerDayRangeHeaders, {}));
2069
2069
  const [component, setComponent] = useState(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}));
2070
+ const onSelect = useCallback((value) => {
2071
+ const _date = assignDayInDate(date, value);
2072
+ const range = dateIsBefore(_date, sourceDate.current)
2073
+ ? new DateRange(sourceDate.current, _date)
2074
+ : new DateRange(_date, sourceDate.current);
2075
+ sourceDate.current = _date;
2076
+ setRange(range);
2077
+ formControl?.setValue(range);
2078
+ }, [date, sourceDate.current, formControl]);
2070
2079
  useEffect(() => {
2071
2080
  return i18nSubscribe(() => {
2072
2081
  setHeaders(jsxRuntimeExports.jsx(RlsPickerDayRangeHeaders, {}));
2073
2082
  });
2074
2083
  }, []);
2075
2084
  useEffect(() => {
2076
- setComponent(jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__week", children: days.map((day, index) => (jsxRuntimeExports.jsx(RlsPickerDayRangeItem, { day: day, onSelect: onSelect, disabled: disabled }, index))) }, index))) }));
2077
- }, [weeks]);
2085
+ setComponent(jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__week", children: days.map((day, index) => (jsxRuntimeExports.jsx(RlsPickerDayRangeElement, { day: day, onSelect: onSelect, disabled: disabled }, index))) }, index))) }));
2086
+ }, [weeks, onSelect, disabled]);
2078
2087
  useEffect(() => {
2079
2088
  setWeeks(createDayRangePicker({
2080
2089
  date,
@@ -2087,19 +2096,10 @@ function RlsPickerDayRange({ date: _date, disabled, formControl, maxDate, minDat
2087
2096
  const title = useMemo(() => {
2088
2097
  return (jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__title", children: dateFormatTemplate(sourceDate.current, formatRange) }));
2089
2098
  }, [sourceDate.current]);
2090
- const onSelect = useCallback((value) => {
2091
- const _date = assignDayInDate(date, value);
2092
- const range = dateIsBefore(_date, sourceDate.current)
2093
- ? new DateRange(sourceDate.current, _date)
2094
- : new DateRange(_date, sourceDate.current);
2095
- sourceDate.current = _date;
2096
- setRange(range);
2097
- formControl?.setValue(range);
2098
- }, [date, sourceDate.current, formControl]);
2099
2099
  return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [title, headers, component] }));
2100
2100
  }
2101
2101
 
2102
- function RlsPickerMonthItem({ month, onSelect, disabled }) {
2102
+ function RlsPickerMonthElement({ month, onSelect, disabled }) {
2103
2103
  const [label, setLabel] = useState(MONTH_NAMES(month.value));
2104
2104
  useEffect(() => {
2105
2105
  return i18nSubscribe(() => {
@@ -2126,9 +2126,16 @@ function RlsPickerMonth({ date: _date, disabled, formControl, maxDate, minDate,
2126
2126
  const [months, setMonths] = useState([]);
2127
2127
  const [value, setValue] = useState(formControl?.value ?? date.getMonth());
2128
2128
  const [component, setComponent] = useState(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}));
2129
+ const setMonthValue = useCallback((value) => {
2130
+ formControl ? formControl.setValue(value) : setValue(value);
2131
+ }, [formControl]);
2132
+ const onSelect = useCallback((value) => {
2133
+ setMonthValue(value);
2134
+ onValue && onValue(value);
2135
+ }, [setMonthValue, onValue]);
2129
2136
  useEffect(() => {
2130
- setComponent(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: months.map((month, index) => (jsxRuntimeExports.jsx(RlsPickerMonthItem, { month: month, onSelect: onSelect, disabled: disabled }, index))) }));
2131
- }, [months]);
2137
+ setComponent(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: months.map((month, index) => (jsxRuntimeExports.jsx(RlsPickerMonthElement, { month: month, onSelect: onSelect, disabled: disabled }, index))) }));
2138
+ }, [months, onSelect, disabled]);
2132
2139
  useEffect(() => {
2133
2140
  const options = {
2134
2141
  date,
@@ -2154,13 +2161,6 @@ function RlsPickerMonth({ date: _date, disabled, formControl, maxDate, minDate,
2154
2161
  ? formControl?.setValue(month)
2155
2162
  : setValue(formControl?.value ?? date.getMonth());
2156
2163
  }, [formControl?.value]);
2157
- const setMonthValue = useCallback((value) => {
2158
- formControl ? formControl.setValue(value) : setValue(value);
2159
- }, [formControl]);
2160
- const onSelect = useCallback((value) => {
2161
- setMonthValue(value);
2162
- onValue && onValue(value);
2163
- }, [setMonthValue, onValue]);
2164
2164
  return (jsxRuntimeExports.jsx("div", { className: "rls-picker-month", "rls-theme": rlsTheme, children: component }));
2165
2165
  }
2166
2166
 
@@ -2221,7 +2221,7 @@ function RlsPickerSelectorTitle({ monthControl, type, yearControl, date, disable
2221
2221
  return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-selector-title", children: [jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntimeExports.jsx("span", { onClick: onClick, children: label }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
2222
2222
  }
2223
2223
 
2224
- function RlsPickerYearItem({ onSelect, year, disabled }) {
2224
+ function RlsPickerYearElement({ onSelect, year, disabled }) {
2225
2225
  const className = useMemo(() => {
2226
2226
  return renderClassStatus('rls-picker-year__element', {
2227
2227
  disabled: year.disabled || disabled,
@@ -2248,37 +2248,92 @@ function RlsPickerYear({ date: _date, disabled, formControl, maxDate, minDate, o
2248
2248
  };
2249
2249
  }, [date, year, minDate, maxDate]);
2250
2250
  const [template, setTemplate] = useState(createYearPicker(createPickerOptions()));
2251
+ const setYearValue = useCallback((value) => {
2252
+ formControl ? formControl.setValue(value) : setValue(value);
2253
+ setYear(value);
2254
+ }, [formControl]);
2255
+ const onSelect = useCallback((value) => {
2256
+ setYearValue(value);
2257
+ onValue && onValue(value);
2258
+ }, [setYearValue, onValue]);
2251
2259
  useEffect(() => {
2252
2260
  const options = createPickerOptions(); // YearPickerProps
2253
2261
  const year = verifyYearPicker(options);
2254
2262
  year ? setYearValue(year) : setTemplate(createYearPicker(options));
2255
2263
  }, [date, year, value, minDate, maxDate]);
2256
2264
  useEffect(() => {
2257
- setComponent(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: template.years.map((year, index) => (jsxRuntimeExports.jsx(RlsPickerYearItem, { year: year, onSelect: onSelect, disabled: disabled }, index))) }));
2258
- }, [template.years]);
2265
+ setComponent(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: template.years.map((year, index) => (jsxRuntimeExports.jsx(RlsPickerYearElement, { year: year, onSelect: onSelect, disabled: disabled }, index))) }));
2266
+ }, [template.years, onSelect, disabled]);
2259
2267
  useEffect(() => {
2260
2268
  const year = verifyYearPicker(createPickerOptions());
2261
2269
  itIsDefined(year)
2262
2270
  ? formControl?.setValue(year)
2263
2271
  : setValue(formControl?.value ?? date.getFullYear());
2264
2272
  }, [formControl?.value]);
2265
- const setYearValue = useCallback((value) => {
2266
- formControl ? formControl.setValue(value) : setValue(value);
2267
- setYear(value);
2268
- }, [formControl]);
2269
2273
  const onClickPrev = useCallback(() => {
2270
2274
  setYear((year) => year - 8);
2271
2275
  }, []);
2272
2276
  const onClickNext = useCallback(() => {
2273
2277
  setYear((year) => year + 8);
2274
2278
  }, []);
2275
- const onSelect = useCallback((value) => {
2276
- setYearValue(value);
2277
- onValue && onValue(value);
2278
- }, [setYearValue, onValue]);
2279
2279
  return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-year__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--prev", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabled }) }), jsxRuntimeExports.jsxs("label", { className: "rls-title-bold", children: [template.minRange, " - ", template.maxRange] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--next", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabled }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__component", children: component })] }));
2280
2280
  }
2281
2281
 
2282
+ function calculateInitialValue(value, minValue, maxValue) {
2283
+ return minValue > value ? minValue : maxValue < value ? maxValue : value;
2284
+ }
2285
+ function calculateInitialRate(value, minValue, maxValue) {
2286
+ const rateMax = maxValue - minValue;
2287
+ const rateValue = value - minValue;
2288
+ return Math.ceil((rateValue / rateMax) * 100);
2289
+ }
2290
+ function RlsSlider(props) {
2291
+ const minValue = useMemo(() => {
2292
+ return props.minValue ?? 0;
2293
+ }, [props.minValue]);
2294
+ const maxValue = useMemo(() => {
2295
+ return props.maxValue ?? 100;
2296
+ }, [props.maxValue]);
2297
+ const [value, setValue] = useState(calculateInitialValue(props.formControl?.value ?? props.value ?? 0, minValue, maxValue));
2298
+ const [rate, setRate] = useState(calculateInitialRate(value, minValue, maxValue));
2299
+ const refComponent = useRef(null);
2300
+ const refTrack = useRef(null);
2301
+ const refTrackOn = useRef(null);
2302
+ const refThumb = useRef(null);
2303
+ const className = useMemo(() => {
2304
+ return renderClassStatus('rls-slider', {
2305
+ complet: value === maxValue,
2306
+ disabled: props.disabled,
2307
+ empty: value === minValue
2308
+ });
2309
+ }, [value, minValue, maxValue, props.disabled]);
2310
+ useEffect(() => {
2311
+ const valueInitial = props.formControl?.value ?? props.value ?? 0;
2312
+ refThumb.current.style.left = `${rate}%`;
2313
+ refTrackOn.current.style.width = `${rate}%`;
2314
+ if (valueInitial !== value) {
2315
+ props.formControl?.setValue(value);
2316
+ props.onValue && props.onValue(value);
2317
+ }
2318
+ }, []);
2319
+ const calculateValueWithRate = useCallback((rate) => {
2320
+ const value = Math.ceil(((maxValue - minValue) * rate) / 100);
2321
+ refThumb.current.style.left = `${rate}%`;
2322
+ refTrackOn.current.style.width = `${rate}%`;
2323
+ const sliderValue = value + minValue;
2324
+ setRate(rate);
2325
+ setValue(sliderValue);
2326
+ props.formControl?.setValue(sliderValue);
2327
+ props.onValue && props.onValue(sliderValue);
2328
+ }, [minValue, maxValue, props.formControl, props.onValue]);
2329
+ const onClickTrack = useCallback((event) => {
2330
+ const { left, width } = refTrack.current.getBoundingClientRect();
2331
+ const rate = Math.ceil(((event.clientX - left) / width) * 100);
2332
+ calculateValueWithRate(rate);
2333
+ }, [minValue, maxValue]);
2334
+ return (jsxRuntimeExports.jsxs("div", { className: className, children: [props.children && (jsxRuntimeExports.jsx("span", { className: "rls-slider__label", children: props.children })), jsxRuntimeExports.jsxs("div", { className: "rls-slider__body", children: [props.prefixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: props.prefixIcon }), jsxRuntimeExports.jsxs("div", { ref: refComponent, className: "rls-slider__component", children: [jsxRuntimeExports.jsx("div", { ref: refTrack, className: "rls-slider__track", onClick: onClickTrack, children: jsxRuntimeExports.jsx("div", { ref: refTrackOn, className: "rls-slider__track__on" }) }), jsxRuntimeExports.jsxs("div", { ref: refThumb, className: "rls-slider__thumb", children: [rate, "%"] })] })] })] }));
2335
+ }
2336
+
2282
2337
  function RlsToolbar({ actions, children, subtitle }) {
2283
2338
  return (jsxRuntimeExports.jsxs("div", { className: "rls-toolbar", children: [jsxRuntimeExports.jsxs("div", { className: "rls-toolbar__description", children: [children && jsxRuntimeExports.jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsxRuntimeExports.jsx("label", { className: "rls-toolbar__subtitle smalltext-semibold", children: subtitle }))] }), actions && (jsxRuntimeExports.jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsxRuntimeExports.jsx("div", { children: action }, index))) }))] }));
2284
2339
  }
@@ -2296,6 +2351,9 @@ const reactI18n = i18n({
2296
2351
  dateActionCancel: 'Cancelar',
2297
2352
  dateActionSelect: 'Establecer',
2298
2353
  dateActionToday: 'Hoy',
2354
+ chooserImageActionCancel: 'Cancelar',
2355
+ editorImageActionRestore: 'Restaurar',
2356
+ editorImageActionSelect: 'Seleccionar',
2299
2357
  listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
2300
2358
  listEmptyTitle: 'Selección no disponible',
2301
2359
  listInputPlaceholder: 'Escriba palabre clave para filtrar...'
@@ -2305,6 +2363,9 @@ const reactI18n = i18n({
2305
2363
  dateActionCancel: 'Cancel',
2306
2364
  dateActionSelect: 'Select',
2307
2365
  dateActionToday: 'Today',
2366
+ chooserImageActionCancel: 'Cancel',
2367
+ editorImageActionRestore: 'Restore',
2368
+ editorImageActionSelect: 'Select',
2308
2369
  listEmptyDescription: 'Sorry, there are currently no items in the list',
2309
2370
  listEmptyTitle: 'Selection not available',
2310
2371
  listInputPlaceholder: 'Enter keyword to filter...'
@@ -2448,23 +2509,23 @@ function calculateMinHeightList(count, height) {
2448
2509
  }
2449
2510
  function useListController(props) {
2450
2511
  const { count, suggestions, automatic, formControl, lineHeight, reference } = props;
2512
+ const refContent = useRef(null);
2513
+ const refList = useRef(null);
2514
+ const refInput = useRef(null);
2451
2515
  const listIsOpen = useRef(false);
2452
- const contentRef = useRef(null);
2453
- const listRef = useRef(null);
2454
- const inputRef = useRef(null);
2455
2516
  const [collection, setCollection] = useState(new ListCollection(suggestions));
2456
2517
  const [state, refreshState] = useState({
2457
2518
  focused: false,
2458
2519
  higher: false,
2459
- value: '',
2460
- modalIsVisible: false
2520
+ modalIsVisible: false,
2521
+ value: ''
2461
2522
  });
2523
+ const changeValueInternal = useRef(false);
2462
2524
  const position = useRef(0);
2463
2525
  const valueProtected = useRef();
2464
- const changeValueInternal = useRef(false);
2465
2526
  useEffect(() => {
2466
2527
  function onCloseSuggestions({ target }) {
2467
- !contentRef?.current?.contains(target) &&
2528
+ !refContent?.current?.contains(target) &&
2468
2529
  refreshState((state) => ({ ...state, modalIsVisible: false }));
2469
2530
  }
2470
2531
  document.addEventListener('click', onCloseSuggestions);
@@ -2514,7 +2575,7 @@ function useListController(props) {
2514
2575
  const _state = state.modalIsVisible
2515
2576
  ? {
2516
2577
  ...state,
2517
- higher: locationListCanTop(contentRef.current, listRef.current, minHeightList)
2578
+ higher: locationListCanTop(refContent.current, refList.current, minHeightList)
2518
2579
  }
2519
2580
  : state;
2520
2581
  refreshState((state) => ({ ...state, ..._state }));
@@ -2532,34 +2593,154 @@ function useListController(props) {
2532
2593
  const navigationInput = useCallback((event) => {
2533
2594
  if (state.modalIsVisible) {
2534
2595
  const _position = navigationListFromInput({
2535
- content: contentRef.current,
2596
+ content: refContent.current,
2536
2597
  event: event,
2537
- list: listRef.current
2598
+ list: refList.current
2538
2599
  });
2539
2600
  position.current = _position ?? 0;
2540
2601
  }
2541
2602
  }, [state.modalIsVisible]);
2542
2603
  const navigationElement = useCallback((event) => {
2543
2604
  position.current = navigationListFromElement({
2544
- content: contentRef.current,
2605
+ content: refContent.current,
2545
2606
  event: event,
2546
- input: inputRef.current,
2547
- list: listRef.current,
2607
+ input: refInput.current,
2608
+ list: refList.current,
2548
2609
  position: position.current
2549
2610
  });
2550
2611
  }, [state.modalIsVisible]);
2551
2612
  return {
2552
2613
  ...state,
2553
- contentRef,
2554
- inputRef,
2555
- listRef,
2556
2614
  navigationElement,
2557
2615
  navigationInput,
2616
+ refContent,
2617
+ refInput,
2618
+ refList,
2558
2619
  setFormValue,
2559
2620
  setState
2560
2621
  };
2561
2622
  }
2562
2623
 
2624
+ function useRelocationOnComponent({ container, element, onDrag }) {
2625
+ const position = useRef({ x: 0, y: 0 });
2626
+ const dragOffset = useRef({ x: 0, y: 0 });
2627
+ const dragging = useRef(false);
2628
+ const getClientX = useCallback((positionX) => {
2629
+ let clientX = position.current.x + positionX - dragOffset.current.x;
2630
+ if (clientX < 0) {
2631
+ clientX = 0;
2632
+ }
2633
+ else {
2634
+ const width = clientX + element.current.offsetWidth;
2635
+ if (width > container.current.offsetWidth) {
2636
+ clientX = container.current.offsetWidth - element.current.offsetWidth;
2637
+ }
2638
+ }
2639
+ return clientX;
2640
+ }, []);
2641
+ const getClientY = useCallback((positionY) => {
2642
+ let clientY = position.current.y + positionY - dragOffset.current.y;
2643
+ if (clientY < 0) {
2644
+ clientY = 0;
2645
+ }
2646
+ else {
2647
+ const height = clientY + element.current.offsetHeight;
2648
+ if (height > container.current.offsetHeight) {
2649
+ clientY = container.current.offsetHeight - element.current.offsetHeight;
2650
+ }
2651
+ }
2652
+ return clientY;
2653
+ }, []);
2654
+ const start = useCallback((positionX, positionY) => {
2655
+ dragOffset.current = {
2656
+ x: positionX,
2657
+ y: positionY
2658
+ };
2659
+ position.current = {
2660
+ x: element.current.offsetLeft,
2661
+ y: element.current.offsetTop
2662
+ };
2663
+ dragging.current = true;
2664
+ }, []);
2665
+ const relocation = useCallback((positionX, positionY) => {
2666
+ const clientX = getClientX(positionX);
2667
+ const clientY = getClientY(positionY);
2668
+ element.current.style.top = `${clientY}px`;
2669
+ element.current.style.left = `${clientX}px`;
2670
+ onDrag && onDrag();
2671
+ }, []);
2672
+ useEffect(() => {
2673
+ const mousedown = (event) => {
2674
+ start(event.clientX, event.clientY);
2675
+ };
2676
+ const mousemove = (event) => {
2677
+ if (dragging.current) {
2678
+ relocation(event.clientX, event.clientY);
2679
+ event.preventDefault();
2680
+ }
2681
+ };
2682
+ const mouseup = () => {
2683
+ dragging.current = false;
2684
+ };
2685
+ const touchstart = (event) => {
2686
+ if (event.touches[0]) {
2687
+ start(event.touches[0].clientX, event.touches[0].clientY);
2688
+ }
2689
+ };
2690
+ const touchmove = (event) => {
2691
+ if (event.touches[0] && dragging.current) {
2692
+ relocation(event.touches[0].clientX, event.touches[0].clientY);
2693
+ event.preventDefault();
2694
+ }
2695
+ };
2696
+ const touchend = () => {
2697
+ dragging.current = false;
2698
+ };
2699
+ element.current.addEventListener('mousedown', mousedown);
2700
+ element.current.addEventListener('mousemove', mousemove);
2701
+ element.current.addEventListener('mouseup', mouseup);
2702
+ element.current.addEventListener('touchstart', touchstart);
2703
+ element.current.addEventListener('touchmove', touchmove);
2704
+ element.current.addEventListener('touchend', touchend);
2705
+ return () => {
2706
+ element.current?.removeEventListener('mousedown', mousedown);
2707
+ element.current?.removeEventListener('mousemove', mousemove);
2708
+ element.current?.removeEventListener('mouseup', mouseup);
2709
+ element.current?.removeEventListener('touchstart', touchstart);
2710
+ element.current?.removeEventListener('touchmove', touchmove);
2711
+ element.current?.removeEventListener('touchend', touchend);
2712
+ };
2713
+ }, []);
2714
+ }
2715
+
2716
+ function useResize(props) {
2717
+ const { refElement, onResize } = props;
2718
+ const dimension = useRef({ height: 0, width: 0 });
2719
+ const observer = useCallback((entries) => {
2720
+ const { height, width } = entries[0].contentRect;
2721
+ onResize &&
2722
+ onResize({
2723
+ current: dimension.current,
2724
+ dimension: {
2725
+ height,
2726
+ width
2727
+ }
2728
+ });
2729
+ dimension.current = { height, width };
2730
+ }, []);
2731
+ useEffect(() => {
2732
+ dimension.current = {
2733
+ height: refElement.current.offsetHeight,
2734
+ width: refElement.current.offsetWidth
2735
+ };
2736
+ const resizeObserver = new ResizeObserver(observer);
2737
+ resizeObserver.observe(refElement.current);
2738
+ return () => {
2739
+ resizeObserver.disconnect();
2740
+ };
2741
+ }, []);
2742
+ }
2743
+
2563
2744
  const DURATION_ANIMATION$1 = 240;
2564
2745
  const MAX_ELEMENTS = 6;
2565
2746
  function useFieldAutocomplete(props) {
@@ -2593,6 +2774,9 @@ function useFieldAutocomplete(props) {
2593
2774
  useEffect(() => {
2594
2775
  refreshCoincidences(props.suggestions, pattern);
2595
2776
  }, [pattern]);
2777
+ useEffect(() => {
2778
+ props.disabled && controller.setState({ focused: false });
2779
+ }, [props.disabled]);
2596
2780
  const onFocusInput = useCallback(() => {
2597
2781
  controller.setState({ focused: true });
2598
2782
  }, [controller.setState]);
@@ -2613,7 +2797,7 @@ function useFieldAutocomplete(props) {
2613
2797
  const onClickControl = useCallback(() => {
2614
2798
  controller.setState({ modalIsVisible: true });
2615
2799
  setTimeout(() => {
2616
- controller.inputRef?.current?.focus();
2800
+ controller.refInput?.current?.focus();
2617
2801
  }, DURATION_ANIMATION$1);
2618
2802
  }, [controller.setState]);
2619
2803
  const onClickAction = useCallback(() => {
@@ -2643,7 +2827,7 @@ function useFieldAutocomplete(props) {
2643
2827
  }
2644
2828
  if (props.selectionContinuos) {
2645
2829
  setPattern('');
2646
- controller.inputRef?.current?.focus();
2830
+ controller.refInput?.current?.focus();
2647
2831
  }
2648
2832
  else {
2649
2833
  controller.setState({ modalIsVisible: false });
@@ -2729,18 +2913,18 @@ function RlsFieldAutocompleteTemplate(props) {
2729
2913
  event.key === 'Enter' && onSearch && onSearch(autocomplete.pattern);
2730
2914
  autocomplete.onKeydownInput(event);
2731
2915
  }, [autocomplete.onKeydownInput, onSearch, autocomplete.pattern]);
2732
- return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.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: autocomplete.value, onClick: autocomplete.onClickControl }), jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: autocomplete.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: autocomplete.value ? 'trash-2' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsxs("div", { className: classNameList, children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: autocomplete.listRef, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: autocomplete.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: labels.listInputPlaceholder, value: autocomplete.pattern, onChange: onChangePattern, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: onKeyDownPattern, disabled: disabled || searching }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: onClickPattern, 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 rls-truncate", children: labels.listEmptyTitle }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: labels.listEmptyDescription })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: autocomplete.onClickBackdrop })] })] }));
2916
+ return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.refContent, 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: autocomplete.value, onClick: autocomplete.onClickControl }), jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: autocomplete.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: autocomplete.value ? 'trash-2' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsxs("div", { className: classNameList, children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: autocomplete.refList, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: autocomplete.refInput, className: "rls-field-list__ul__control", type: "text", placeholder: labels.listInputPlaceholder, value: autocomplete.pattern, onChange: onChangePattern, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: onKeyDownPattern, disabled: disabled || searching }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: onClickPattern, 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 rls-truncate", children: labels.listEmptyTitle }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: labels.listEmptyDescription })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: autocomplete.onClickBackdrop })] })] }));
2733
2917
  }
2734
2918
  function RlsFieldAutocomplete(props) {
2735
2919
  const render = useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
2736
2920
  return jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: render });
2737
2921
  }
2738
2922
 
2739
- function RlsModal({ children, overflow, visible, rlsTheme }) {
2740
- const className = useMemo(() => {
2741
- return renderClassStatus('rls-modal', { overflow, visible });
2742
- }, [overflow, visible]);
2743
- return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
2923
+ function RlsModal({ children, className, overflow, visible, rlsTheme }) {
2924
+ const classNameModal = useMemo(() => {
2925
+ return renderClassStatus('rls-modal', { overflow, visible }, className);
2926
+ }, [className, overflow, visible]);
2927
+ return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: classNameModal, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
2744
2928
  }
2745
2929
 
2746
2930
  const formatTitle = '{dw}, {mx} {dd} de {aa}';
@@ -2993,6 +3177,9 @@ function useFieldSelect(props) {
2993
3177
  useEffect(() => {
2994
3178
  count.current = props.suggestions.length;
2995
3179
  }, [props.suggestions]);
3180
+ useEffect(() => {
3181
+ props.disabled && controller.setState({ focused: false });
3182
+ }, [props.disabled]);
2996
3183
  const onFocusInput = useCallback(() => {
2997
3184
  controller.setState({ focused: true });
2998
3185
  }, [controller.setState]);
@@ -3027,7 +3214,7 @@ function useFieldSelect(props) {
3027
3214
  else {
3028
3215
  const modalIsVisible = !controller.modalIsVisible;
3029
3216
  controller.setState({ modalIsVisible });
3030
- modalIsVisible && controller.inputRef?.current?.focus();
3217
+ modalIsVisible && controller.refInput?.current?.focus();
3031
3218
  }
3032
3219
  }, [
3033
3220
  controller.modalIsVisible,
@@ -3041,7 +3228,7 @@ function useFieldSelect(props) {
3041
3228
  controller.setState({ modalIsVisible: false });
3042
3229
  }, [controller.setState]);
3043
3230
  const onChange = useCallback((element) => {
3044
- controller.inputRef?.current?.focus();
3231
+ !props.disabled && controller.refInput?.current?.focus();
3045
3232
  if (props.onSelect) {
3046
3233
  controller.setState({ modalIsVisible: false });
3047
3234
  element.value && props.onSelect(element.value);
@@ -3055,7 +3242,8 @@ function useFieldSelect(props) {
3055
3242
  controller.setState,
3056
3243
  controller.setFormValue,
3057
3244
  props.onSelect,
3058
- props.onValue
3245
+ props.onValue,
3246
+ props.disabled
3059
3247
  ]);
3060
3248
  const onClickElement = useCallback((element) => {
3061
3249
  return () => {
@@ -3102,9 +3290,9 @@ function RlsFieldSelectTemplate(props) {
3102
3290
  }, [formControl?.disabled, props.disabled]);
3103
3291
  const className = useMemo(() => {
3104
3292
  return renderClassStatus('rls-field-box', {
3105
- disabled: disabled,
3293
+ focused: select.focused && !disabled,
3106
3294
  error: formControl?.wrong,
3107
- focused: select.focused && !disabled
3295
+ disabled: disabled
3108
3296
  }, 'rls-field-list rls-field-select');
3109
3297
  }, [formControl?.wrong, select.focused, disabled]);
3110
3298
  const classNameList = useMemo(() => {
@@ -3113,7 +3301,7 @@ function RlsFieldSelectTemplate(props) {
3113
3301
  visible: select.modalIsVisible
3114
3302
  });
3115
3303
  }, [select.modalIsVisible, select.higher]);
3116
- return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.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", { ref: select.inputRef, className: "rls-field-list__control", readOnly: true, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: 'rls-field-list__action', disabled: disabled, onClick: select.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: !unremovable && !!select.value ? 'close' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsxs("div", { className: classNameList, children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: select.listRef, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: select.onClickElement(element), onKeyDown: select.onKeydownElement(element), children: render(element) }, index))), !suggestions.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 rls-truncate", children: labels.listEmptyTitle }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: labels.listEmptyDescription })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: select.onClickBackdrop })] })] }));
3304
+ return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.refContent, 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", { ref: select.refInput, className: "rls-field-list__control", readOnly: true, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: 'rls-field-list__action', disabled: disabled, onClick: select.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: !unremovable && !!select.value ? 'close' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsxs("div", { className: classNameList, children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: select.refList, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: select.onClickElement(element), onKeyDown: select.onKeydownElement(element), children: render(element) }, index))), !suggestions.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 rls-truncate", children: labels.listEmptyTitle }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: labels.listEmptyDescription })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: select.onClickBackdrop })] })] }));
3117
3305
  }
3118
3306
  function RlsFieldSelect(props) {
3119
3307
  const render = useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
@@ -3127,6 +3315,253 @@ function RlsFormNavigation({ children, visible, rlsTheme }) {
3127
3315
  return (jsxRuntimeExports.jsx("div", { className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
3128
3316
  }
3129
3317
 
3318
+ function getRatioFactor(ratio) {
3319
+ switch (ratio) {
3320
+ case '16:9':
3321
+ return 9 / 16;
3322
+ case '8:5':
3323
+ return 5 / 8;
3324
+ case '4:3':
3325
+ return 3 / 4;
3326
+ case '3:4':
3327
+ return 4 / 3;
3328
+ case '3:2':
3329
+ return 2 / 3;
3330
+ default:
3331
+ return 1;
3332
+ }
3333
+ }
3334
+ function simpleThreeRule(value1, value2, proportion) {
3335
+ return (value2 * proportion) / value1;
3336
+ }
3337
+ function RlsImageEditor(props) {
3338
+ const [selection, setSelection] = useState(props.rateSelection ?? 60);
3339
+ const [labels, setLabels] = useState({
3340
+ actionRestore: reactI18n('editorImageActionRestore'),
3341
+ actionSelect: reactI18n('editorImageActionSelect')
3342
+ });
3343
+ const refBody = useRef(null);
3344
+ const refImage = useRef(null);
3345
+ const refSelection = useRef(null);
3346
+ const refOverlayTop = useRef(null);
3347
+ const refOverlayBottom = useRef(null);
3348
+ const refOverlayLeft = useRef(null);
3349
+ const refOverlayRight = useRef(null);
3350
+ const refCanvas = useRef(null);
3351
+ const refPicture = useRef(null);
3352
+ const image = useRef(new Image());
3353
+ const originalImage = useRef();
3354
+ const getCropProperties = useCallback(() => {
3355
+ return {
3356
+ height: simpleThreeRule(refImage.current.offsetHeight, image.current.height, refSelection.current.offsetHeight),
3357
+ left: simpleThreeRule(refImage.current.offsetWidth, image.current.width, refSelection.current.offsetLeft),
3358
+ top: simpleThreeRule(refImage.current.offsetHeight, image.current.height, refSelection.current.offsetTop),
3359
+ width: simpleThreeRule(refImage.current.offsetWidth, image.current.width, refSelection.current.offsetWidth)
3360
+ };
3361
+ }, []);
3362
+ const refreshOverlaysStyle = useCallback(() => {
3363
+ const width = refSelection.current.offsetWidth;
3364
+ const height = refSelection.current.offsetHeight;
3365
+ const top = refSelection.current.offsetTop;
3366
+ const left = refSelection.current.offsetLeft;
3367
+ refOverlayTop.current.style.width = `${width}px`;
3368
+ refOverlayTop.current.style.bottom = `calc(100% - ${top}px)`;
3369
+ refOverlayTop.current.style.left = `${left}px`;
3370
+ refOverlayRight.current.style.left = `calc(${width + left}px)`;
3371
+ refOverlayRight.current.style.width = `calc(100% - ${width + left}px)`;
3372
+ refOverlayBottom.current.style.width = `${width}px`;
3373
+ refOverlayBottom.current.style.top = `calc(${height + top}px)`;
3374
+ refOverlayBottom.current.style.left = `${left}px`;
3375
+ refOverlayLeft.current.style.right = `calc(100% - ${left}px)`;
3376
+ refOverlayLeft.current.style.width = `calc(${left}px)`;
3377
+ }, []);
3378
+ const refreshSelectionFromWidth = useCallback((rateSelection) => {
3379
+ const _ratio = rateSelection * getRatioFactor(props.ratio || '1:1');
3380
+ let width = (refImage.current.offsetWidth * rateSelection) / 100;
3381
+ let height = (refImage.current.offsetWidth * _ratio) / 100;
3382
+ if (height > refImage.current.offsetHeight) {
3383
+ height = refImage.current.offsetHeight;
3384
+ width =
3385
+ (height * refImage.current.offsetHeight) /
3386
+ refImage.current.offsetHeight;
3387
+ }
3388
+ return { height, width };
3389
+ }, [props.ratio]);
3390
+ const refreshSelectionFromHeight = useCallback((rateSelection) => {
3391
+ const _ratio = rateSelection * getRatioFactor(props.ratio || '1:1');
3392
+ let height = (refImage.current.offsetHeight * rateSelection) / 100;
3393
+ let width = (refImage.current.offsetHeight * _ratio) / 100;
3394
+ if (width > refImage.current.offsetWidth) {
3395
+ width = refImage.current.offsetWidth;
3396
+ height =
3397
+ (width * refImage.current.offsetWidth) / refImage.current.offsetWidth;
3398
+ }
3399
+ return { height, width };
3400
+ }, [props.ratio]);
3401
+ const refreshSelectionStyle = useCallback((rateSelection) => {
3402
+ if (image.current.width > 0 && image.current.height > 0) {
3403
+ const { height, width } = image.current.width >= image.current.height
3404
+ ? refreshSelectionFromHeight(rateSelection)
3405
+ : refreshSelectionFromWidth(rateSelection);
3406
+ refSelection.current.style.width = `${width}px`;
3407
+ refSelection.current.style.height = `${height}px`;
3408
+ if (refSelection.current.offsetLeft + width >
3409
+ refImage.current.offsetWidth) {
3410
+ const selectionLeft = refImage.current.offsetWidth - width;
3411
+ refSelection.current.style.left = `${selectionLeft}px`;
3412
+ }
3413
+ if (refSelection.current.offsetTop + height >
3414
+ refImage.current.offsetHeight) {
3415
+ const selectionTop = refImage.current.offsetHeight - height;
3416
+ refSelection.current.style.top = `${selectionTop}px`;
3417
+ }
3418
+ refreshOverlaysStyle();
3419
+ }
3420
+ }, [props.ratio]);
3421
+ const setImageStyle = useCallback((width, height) => {
3422
+ refImage.current.style.width = width;
3423
+ refImage.current.style.height = height;
3424
+ refCanvas.current.style.width = width;
3425
+ refCanvas.current.style.height = height;
3426
+ }, []);
3427
+ const refreshImageStyle = useCallback(() => {
3428
+ if (image.current.width <= 0 || image.current.height <= 0) {
3429
+ return setImageStyle('0%', '0%');
3430
+ }
3431
+ const height = (refBody.current.offsetWidth * image.current.height) /
3432
+ image.current.width;
3433
+ if (height <= refBody.current.offsetHeight) {
3434
+ return setImageStyle('100%', `${height}px`);
3435
+ }
3436
+ const width = (refBody.current.offsetHeight * image.current.width) /
3437
+ image.current.height;
3438
+ return setImageStyle(`${width}px`, '100%');
3439
+ }, []);
3440
+ useEffect(() => {
3441
+ image.current.onload = () => {
3442
+ const context = refCanvas.current.getContext('2d', {
3443
+ willReadFrequently: true
3444
+ });
3445
+ refCanvas.current.width = image.current.width;
3446
+ refCanvas.current.height = image.current.height;
3447
+ context?.drawImage(image.current, 0, 0, image.current.width, image.current.height);
3448
+ originalImage.current = context?.getImageData(0, 0, refCanvas.current.width, refCanvas.current.height);
3449
+ refreshImageStyle();
3450
+ refreshSelectionStyle(selection);
3451
+ };
3452
+ const unsubscription = i18nSubscribe(() => {
3453
+ setLabels({
3454
+ actionRestore: reactI18n('editorImageActionRestore'),
3455
+ actionSelect: reactI18n('editorImageActionSelect')
3456
+ });
3457
+ });
3458
+ window.addEventListener('resize', refreshImageStyle);
3459
+ return () => {
3460
+ window.removeEventListener('resize', refreshImageStyle);
3461
+ unsubscription();
3462
+ };
3463
+ }, []);
3464
+ useEffect(() => {
3465
+ image.current.src = props.src || '';
3466
+ }, [props.src]);
3467
+ useEffect(() => {
3468
+ refreshSelectionStyle(selection);
3469
+ }, [selection]);
3470
+ const onResizeElement = useCallback(() => {
3471
+ refreshSelectionStyle(selection);
3472
+ }, [selection]);
3473
+ useRelocationOnComponent({
3474
+ container: refImage,
3475
+ element: refSelection,
3476
+ onDrag: refreshOverlaysStyle
3477
+ });
3478
+ useResize({ refElement: refImage, onResize: onResizeElement });
3479
+ const onCropImage = useCallback(() => {
3480
+ const cropProps = getCropProperties();
3481
+ const width = cropProps.width;
3482
+ const height = width * getRatioFactor(props.ratio || '1:1');
3483
+ refPicture.current.width = width;
3484
+ refPicture.current.height = height;
3485
+ const context = refPicture.current.getContext('2d');
3486
+ context?.drawImage(refCanvas.current, cropProps.left, cropProps.top, cropProps.width, cropProps.height, 0, 0, width, height);
3487
+ refPicture.current.toBlob((blob) => {
3488
+ if (blob) {
3489
+ const reader = new FileReader();
3490
+ reader.readAsDataURL(blob);
3491
+ reader.onloadend = function () {
3492
+ const value = {
3493
+ base64: reader.result,
3494
+ blob
3495
+ };
3496
+ props.onValue && props.onValue(value);
3497
+ props.formControl?.setValue(value);
3498
+ };
3499
+ }
3500
+ }, props.mimeType || 'image/jpeg', 1);
3501
+ }, [props.ratio, props.mimeType, props.onValue, props.formControl]);
3502
+ const onRestore = useCallback(() => {
3503
+ const context = refCanvas.current.getContext('2d');
3504
+ if (originalImage.current) {
3505
+ context?.putImageData(originalImage.current, 0, 0);
3506
+ }
3507
+ }, []);
3508
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-image-editor", children: [jsxRuntimeExports.jsx("div", { ref: refBody, className: "rls-image-editor__body", children: jsxRuntimeExports.jsxs("div", { ref: refImage, className: "rls-image-editor__body__image", children: [jsxRuntimeExports.jsx("div", { ref: refSelection, className: "rls-image-editor__body__selection" }), jsxRuntimeExports.jsx("div", { ref: refOverlayTop, className: "rls-image-editor__body__overlay--top" }), jsxRuntimeExports.jsx("div", { ref: refOverlayRight, className: "rls-image-editor__body__overlay--right" }), jsxRuntimeExports.jsx("div", { ref: refOverlayBottom, className: "rls-image-editor__body__overlay--bottom" }), jsxRuntimeExports.jsx("div", { ref: refOverlayLeft, className: "rls-image-editor__body__overlay--left" }), jsxRuntimeExports.jsx("canvas", { ref: refCanvas })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__footer", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-editor__sliders", children: jsxRuntimeExports.jsx(RlsSlider, { prefixIcon: "external-link", value: selection, minValue: 50, maxValue: 100, onValue: setSelection, disabled: props.disabled }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__actions", children: [props.children, jsxRuntimeExports.jsx(RlsButton, { type: "classic", prefixIcon: "refresh", onClick: onRestore, disabled: props.disabled, children: labels.actionRestore }), jsxRuntimeExports.jsx(RlsButton, { type: "raised", prefixIcon: "crop", onClick: onCropImage, disabled: props.disabled, children: labels.actionSelect })] })] }), jsxRuntimeExports.jsx("canvas", { ref: refPicture })] }));
3509
+ }
3510
+
3511
+ const mimeTypeSupports = [
3512
+ 'image/png',
3513
+ 'image/jpg',
3514
+ 'image/jpeg',
3515
+ 'image/bmp',
3516
+ 'image/webp',
3517
+ 'image/gif',
3518
+ 'image/svg+xml'
3519
+ ];
3520
+ function RlsImageChooser(props) {
3521
+ const refInput = useRef(null);
3522
+ const [labels, setLabels] = useState({
3523
+ actionCancel: reactI18n('chooserImageActionCancel')
3524
+ });
3525
+ const [src, setSrc] = useState();
3526
+ const [srcEditor, setSrcEditor] = useState();
3527
+ const onSelect = useCallback(() => {
3528
+ refInput.current.click();
3529
+ }, []);
3530
+ const processImage = useCallback((file) => {
3531
+ const reader = new FileReader();
3532
+ reader.onload = function () {
3533
+ setSrcEditor(reader.result);
3534
+ refInput.current.value = '';
3535
+ };
3536
+ reader.readAsDataURL(file);
3537
+ }, []);
3538
+ useEffect(() => {
3539
+ refInput.current.onchange = () => {
3540
+ if (refInput.current.files &&
3541
+ mimeTypeSupports.includes(refInput.current.files[0].type)) {
3542
+ processImage(refInput.current.files[0]);
3543
+ }
3544
+ };
3545
+ return i18nSubscribe(() => {
3546
+ setLabels({
3547
+ actionCancel: reactI18n('chooserImageActionCancel')
3548
+ });
3549
+ });
3550
+ }, []);
3551
+ useEffect(() => {
3552
+ props.src && setSrc(props.src);
3553
+ }, [props.src]);
3554
+ const onEditorValue = useCallback((image) => {
3555
+ setSrc(image.base64);
3556
+ setSrcEditor(undefined);
3557
+ props.onValue && props.onValue(image);
3558
+ }, [props.onValue]);
3559
+ const onCancel = useCallback(() => {
3560
+ setSrcEditor(undefined);
3561
+ }, []);
3562
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-image-chooser", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-chooser__avatar", onClick: onSelect, children: src && jsxRuntimeExports.jsx("img", { src: src }) }), srcEditor && (jsxRuntimeExports.jsx(RlsModal, { className: "rls-image-chooser__modal", visible: true, children: jsxRuntimeExports.jsx(RlsImageEditor, { src: srcEditor, formControl: props.formControl, onValue: onEditorValue, children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", rlsTheme: "danger", onClick: onCancel, disabled: props.disabled, children: labels.actionCancel }) }) })), jsxRuntimeExports.jsx("input", { ref: refInput, type: "file", disabled: props.disabled })] }));
3563
+ }
3564
+
3130
3565
  const DURATION_ANIMATION = 240;
3131
3566
  const DURATION_CHAR = 75;
3132
3567
  const DURATION_MAX = 9000;
@@ -3213,5 +3648,5 @@ function RlsApplication({ children }) {
3213
3648
  }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
3214
3649
  }
3215
3650
 
3216
- export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, setErrorsI18n, useConfirmation, useDatatable, useFieldAutocomplete, useFieldSelect, useListController, useSnackbar };
3651
+ export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, setErrorsI18n, useConfirmation, useDatatable, useFieldAutocomplete, useFieldSelect, useListController, useRelocationOnComponent, useResize, useSnackbar };
3217
3652
  //# sourceMappingURL=index.js.map