@rolster/react-components 19.0.0 → 19.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/assets/{index-QCv-Uo8R.css → index--qtFLq_w.css} +204 -8
- package/dist/cjs/index.js +331 -67
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/assets/{index-QCv-Uo8R.css → index--qtFLq_w.css} +204 -8
- package/dist/es/index.js +333 -71
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/Badge/Badge.css +4 -2
- package/dist/esm/components/atoms/Badge/Badge.css.map +1 -1
- package/dist/esm/components/atoms/Input/Input.js +1 -1
- package/dist/esm/components/atoms/Input/Input.js.map +1 -1
- package/dist/esm/components/atoms/InputDecimal/InputDecimal.js +1 -1
- package/dist/esm/components/atoms/InputDecimal/InputDecimal.js.map +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.js +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.js +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.js.map +1 -1
- package/dist/esm/components/atoms/InputPassword/InputPassword.js +1 -1
- package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
- package/dist/esm/components/atoms/InputPercentage/InputPercentage.js +1 -1
- package/dist/esm/components/atoms/InputPercentage/InputPercentage.js.map +1 -1
- package/dist/esm/components/atoms/InputText/InputText.js +1 -1
- package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
- package/dist/esm/components/molecules/PickerDay/PickerDay.js +1 -1
- package/dist/esm/components/molecules/PickerDay/PickerDay.js.map +1 -1
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +1 -1
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
- package/dist/esm/components/molecules/PickerYear/PickerYear.js +1 -1
- package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
- package/dist/esm/components/molecules/Tabs/Tabs.js +1 -1
- package/dist/esm/components/molecules/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/organisms/FieldClock/FieldClock.css +72 -0
- package/dist/esm/components/organisms/FieldClock/FieldClock.css.map +1 -0
- package/dist/esm/components/organisms/FieldClock/FieldClock.d.ts +37 -0
- package/dist/esm/components/organisms/FieldClock/FieldClock.js +55 -0
- package/dist/esm/components/organisms/FieldClock/FieldClock.js.map +1 -0
- package/dist/esm/components/organisms/FieldDate/FieldDate.css +2 -2
- package/dist/esm/components/organisms/FieldDate/FieldDate.css.map +1 -1
- package/dist/esm/components/organisms/FieldDate/FieldDate.js +25 -20
- package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.css +5 -2
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.css.map +1 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +21 -18
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
- package/dist/esm/components/organisms/PickerClock/PickerClock.css +116 -0
- package/dist/esm/components/organisms/PickerClock/PickerClock.css.map +1 -0
- package/dist/esm/components/organisms/PickerClock/PickerClock.d.ts +13 -0
- package/dist/esm/components/organisms/PickerClock/PickerClock.js +220 -0
- package/dist/esm/components/organisms/PickerClock/PickerClock.js.map +1 -0
- package/dist/esm/components/organisms/PickerDate/PickerDate.css +3 -2
- package/dist/esm/components/organisms/PickerDate/PickerDate.css.map +1 -1
- package/dist/esm/components/organisms/PickerDate/PickerDate.js +11 -13
- package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.d.ts +1 -1
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +2 -2
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/esm/components/molecules/PickerClock/PickerClock.d.ts +0 -1
- package/dist/esm/components/molecules/PickerClock/PickerClock.js +0 -5
- package/dist/esm/components/molecules/PickerClock/PickerClock.js.map +0 -1
package/dist/es/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import require$$0, { useMemo, useState, useEffect, useCallback, useRef, createContext } from 'react';
|
|
1
|
+
import require$$0, { useMemo, useState, useEffect, useCallback, useRef, useEffectEvent, createContext } from 'react';
|
|
2
2
|
import { currencyFormat, BigDecimal, valueIsDefined, SealedPartial } from '@rolster/commons';
|
|
3
3
|
import { i18n, i18nSubscribe } from '@rolster/i18n';
|
|
4
|
-
import { PaginationController, verifyDayPicker, createDayPicker, createDayRangePicker, verifyMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, verifyYearPicker, ListCollection, locationListCanTop, navigationListFromInput, navigationListFromElement, createAutocompleteStore, dateOutRange, verifyDateRange
|
|
5
|
-
import { DAY_LABELS, DateRange, normalizeMinTime, assignDayInDate, dateIsBefore, MONTH_NAMES, Month, dateFormatTemplate, assignYearInDate, assignMonthInDate } from '@rolster/dates';
|
|
4
|
+
import { PaginationController, verifyDayPicker, createDayPicker, createDayRangePicker, verifyMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, verifyYearPicker, ListCollection, locationListCanTop, navigationListFromInput, navigationListFromElement, createAutocompleteStore, PickerListenerEvent, dateOutRange, verifyDateRange } from '@rolster/components';
|
|
5
|
+
import { DAY_LABELS, DateRange, normalizeMinTime, assignDayInDate, dateIsBefore, MONTH_NAMES, Month, Time, dateFormatTemplate, assignYearInDate, assignMonthInDate } from '@rolster/dates';
|
|
6
6
|
import ReactDOM from 'react-dom';
|
|
7
7
|
import { useReactControl } from '@rolster/react-forms';
|
|
8
8
|
|
|
@@ -599,7 +599,7 @@ function RlsInput({ children, decimals, disabled, formControl, identifier, onBlu
|
|
|
599
599
|
? parseFloat((+valueInput).toFixed(decimals))
|
|
600
600
|
: valueInput;
|
|
601
601
|
changeIsInternal.current = true;
|
|
602
|
-
onValue
|
|
602
|
+
onValue?.(value);
|
|
603
603
|
setValueInput(valueInput);
|
|
604
604
|
formControl?.setValue(value);
|
|
605
605
|
}, [formControl, onValue, type, decimals]);
|
|
@@ -638,7 +638,7 @@ function RlsInputDecimal(props) {
|
|
|
638
638
|
const onValueInput = useCallback((value) => {
|
|
639
639
|
const valueDecimal = BigDecimal.create(value);
|
|
640
640
|
formControl ? formControl.setValue(valueDecimal) : setValueInput(value);
|
|
641
|
-
onValue
|
|
641
|
+
onValue?.(valueDecimal);
|
|
642
642
|
}, [formControl, onValue]);
|
|
643
643
|
const decimalProps = { ...props, formControl: undefined };
|
|
644
644
|
return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-decimal", children: jsxRuntimeExports.jsx(RlsInput, { ...decimalProps, type: "number", value: valueInput, onValue: onValueInput, children: jsxRuntimeExports.jsx(RlsAmount, { value: amount, symbol: symbol, decimals: decimals }) }) }));
|
|
@@ -649,7 +649,7 @@ function RlsInputMoney(props) {
|
|
|
649
649
|
const [valueInput, setValueInput] = useState(formControl?.value ?? value ?? 0);
|
|
650
650
|
const onValueInput = useCallback((value) => {
|
|
651
651
|
!formControl && setValueInput(value);
|
|
652
|
-
onValue
|
|
652
|
+
onValue?.(value);
|
|
653
653
|
}, [formControl, onValue]);
|
|
654
654
|
return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { ...props, type: "number", value: valueInput, onValue: onValueInput, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value ?? valueInput, symbol: symbol, decimals: decimals }) }) }));
|
|
655
655
|
}
|
|
@@ -659,7 +659,7 @@ function RlsInputNumber(props) {
|
|
|
659
659
|
const [valueInput, setValueInput] = useState(formControl?.value ?? value ?? 0);
|
|
660
660
|
const onValueInput = useCallback((value) => {
|
|
661
661
|
!formControl && setValueInput(value);
|
|
662
|
-
onValue
|
|
662
|
+
onValue?.(value);
|
|
663
663
|
}, [formControl, onValue]);
|
|
664
664
|
return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { ...props, type: "number", value: valueInput, onValue: onValueInput, children: formControl?.value ?? valueInput }) }));
|
|
665
665
|
}
|
|
@@ -668,7 +668,7 @@ function RlsInputPassword({ disabled, formControl, identifier, onEnter, onKeyDow
|
|
|
668
668
|
const [focused, setFocused] = useState(false);
|
|
669
669
|
const _onChange = useCallback((event) => {
|
|
670
670
|
formControl?.setValue(event.target.value);
|
|
671
|
-
onValue
|
|
671
|
+
onValue?.(event.target.value);
|
|
672
672
|
}, [formControl, onValue]);
|
|
673
673
|
const _onKeyDown = useCallback((event) => {
|
|
674
674
|
onKeyDown && onKeyDown(event);
|
|
@@ -699,7 +699,7 @@ function RlsInputPercentage(props) {
|
|
|
699
699
|
const [valueInput, setValueInput] = useState(formControl?.value ?? value ?? 0);
|
|
700
700
|
const onValueInput = useCallback((value) => {
|
|
701
701
|
!formControl && setValueInput(value);
|
|
702
|
-
onValue
|
|
702
|
+
onValue?.(value);
|
|
703
703
|
}, [formControl, onValue]);
|
|
704
704
|
return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-percentage", children: jsxRuntimeExports.jsxs(RlsInput, { ...props, type: "number", value: valueInput, onValue: onValueInput, children: [formControl?.value ?? valueInput, "%"] }) }));
|
|
705
705
|
}
|
|
@@ -720,7 +720,7 @@ function RlsInputText(props) {
|
|
|
720
720
|
const [valueInput, setValueInput] = useState(formControl?.value ?? value ?? '');
|
|
721
721
|
const onValueInput = useCallback((value) => {
|
|
722
722
|
!formControl && setValueInput(value);
|
|
723
|
-
onValue
|
|
723
|
+
onValue?.(value);
|
|
724
724
|
}, [formControl, onValue]);
|
|
725
725
|
return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { ...props, type: "text", value: valueInput, onValue: onValueInput, children: formControl?.value ?? valueInput }) }));
|
|
726
726
|
}
|
|
@@ -1205,7 +1205,7 @@ function RlsPickerDay({ date: _date, disabled, formControl, maxDate, month, minD
|
|
|
1205
1205
|
}, [formControl]);
|
|
1206
1206
|
const onSelect = useCallback((value) => {
|
|
1207
1207
|
setDayValue(value);
|
|
1208
|
-
onValue
|
|
1208
|
+
onValue?.(value);
|
|
1209
1209
|
}, [setDayValue, onValue]);
|
|
1210
1210
|
useEffect(() => {
|
|
1211
1211
|
return i18nSubscribe(() => {
|
|
@@ -1330,7 +1330,7 @@ function RlsPickerMonth({ date: _date, disabled, formControl, maxDate, minDate,
|
|
|
1330
1330
|
}, [formControl]);
|
|
1331
1331
|
const onSelect = useCallback((value) => {
|
|
1332
1332
|
setMonthValue(value);
|
|
1333
|
-
onValue
|
|
1333
|
+
onValue?.(value);
|
|
1334
1334
|
}, [setMonthValue, onValue]);
|
|
1335
1335
|
useEffect(() => {
|
|
1336
1336
|
setComponent(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: months.map((month, index) => (jsxRuntimeExports.jsx(RlsPickerMonthElement, { month: month, onSelect: onSelect, disabled: disabled }, index))) }));
|
|
@@ -1461,7 +1461,7 @@ function RlsPickerYear({ date: _date, disabled, formControl, maxDate, minDate, o
|
|
|
1461
1461
|
}, [formControl]);
|
|
1462
1462
|
const onSelect = useCallback((value) => {
|
|
1463
1463
|
setYearValue(value);
|
|
1464
|
-
onValue
|
|
1464
|
+
onValue?.(value);
|
|
1465
1465
|
}, [setYearValue, onValue]);
|
|
1466
1466
|
useEffect(() => {
|
|
1467
1467
|
const options = createPickerOptions(); // YearPickerProps
|
|
@@ -1557,7 +1557,7 @@ function RlsTabs({ tabs, onValue, rlsTheme }) {
|
|
|
1557
1557
|
const [value, setValue] = useState();
|
|
1558
1558
|
const onSelect = useCallback((value) => {
|
|
1559
1559
|
setValue(value);
|
|
1560
|
-
onValue
|
|
1560
|
+
onValue?.(value);
|
|
1561
1561
|
}, [onValue]);
|
|
1562
1562
|
useEffect(() => {
|
|
1563
1563
|
const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
|
|
@@ -2058,10 +2058,6 @@ function RlsFieldAutocomplete(props) {
|
|
|
2058
2058
|
return jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: render });
|
|
2059
2059
|
}
|
|
2060
2060
|
|
|
2061
|
-
const DATE_FORMAT = '{dd}/{mx}/{yy}';
|
|
2062
|
-
const DATE_FORMAT_TITLE = '{dw}, {mx} {dd} de {yy}';
|
|
2063
|
-
const DATE_RANGE_FORMAT = '{dd}/{mx}/{yy}';
|
|
2064
|
-
|
|
2065
2061
|
function RlsModal({ children, className, onAutoClose, visible, rlsTheme }) {
|
|
2066
2062
|
const classNameModal = useMemo(() => {
|
|
2067
2063
|
return renderClassStatus('rls-modal', { visible }, className);
|
|
@@ -2072,6 +2068,266 @@ function RlsModal({ children, className, onAutoClose, visible, rlsTheme }) {
|
|
|
2072
2068
|
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", onClick: onClickBackdrop })] }), document.body);
|
|
2073
2069
|
}
|
|
2074
2070
|
|
|
2071
|
+
function formatTime(value) {
|
|
2072
|
+
return String(value).padStart(2, '0');
|
|
2073
|
+
}
|
|
2074
|
+
const CLOCK_VALUES = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
2075
|
+
const RADIUS = 48;
|
|
2076
|
+
const DIAL_RADIUS = 60;
|
|
2077
|
+
const TICK_RADIUS = 7;
|
|
2078
|
+
function RlsPickerClockTick({ onValue, selectionIsHours, value }) {
|
|
2079
|
+
const styleTick = useMemo(() => {
|
|
2080
|
+
const radian = (value / 6) * Math.PI;
|
|
2081
|
+
const x = Math.sin(radian) * RADIUS;
|
|
2082
|
+
const y = Math.cos(radian) * RADIUS;
|
|
2083
|
+
return {
|
|
2084
|
+
left: `${DIAL_RADIUS + x - TICK_RADIUS - 1}rem`,
|
|
2085
|
+
top: `${DIAL_RADIUS - y - TICK_RADIUS - 1}rem`
|
|
2086
|
+
};
|
|
2087
|
+
}, []);
|
|
2088
|
+
const label = useMemo(() => {
|
|
2089
|
+
if (selectionIsHours) {
|
|
2090
|
+
return formatTime(value);
|
|
2091
|
+
}
|
|
2092
|
+
if (value === 12) {
|
|
2093
|
+
return formatTime(0);
|
|
2094
|
+
}
|
|
2095
|
+
return formatTime(value * 5);
|
|
2096
|
+
}, [selectionIsHours]);
|
|
2097
|
+
const onClick = useCallback((event) => {
|
|
2098
|
+
event.preventDefault();
|
|
2099
|
+
onValue(value);
|
|
2100
|
+
}, [onValue]);
|
|
2101
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__tick", style: styleTick, onClick: onClick, children: label }));
|
|
2102
|
+
}
|
|
2103
|
+
function RlsPickerClock({ formControl, onListener, rlsTheme, time }) {
|
|
2104
|
+
const timeInitial = useMemo(() => {
|
|
2105
|
+
return formControl?.value ?? time ?? Time.now();
|
|
2106
|
+
}, [formControl?.value, time]);
|
|
2107
|
+
const plateElement = useRef(null);
|
|
2108
|
+
const lineElement = useRef(null);
|
|
2109
|
+
const centerElement = useRef(null);
|
|
2110
|
+
const indicatorElement = useRef(null);
|
|
2111
|
+
const pointElement = useRef(null);
|
|
2112
|
+
const [labels, setLabels] = useState({
|
|
2113
|
+
timeActionCancel: reactI18n('dateActionCancel'),
|
|
2114
|
+
timeActionSelect: reactI18n('dateActionSelect')
|
|
2115
|
+
});
|
|
2116
|
+
const [zoneIsPM, setZoneIsPM] = useState(timeInitial.hour >= 12);
|
|
2117
|
+
const [hour, setHour] = useState(zoneIsPM ? timeInitial.hour - 12 : timeInitial.hour);
|
|
2118
|
+
const [minute, setMinute] = useState(timeInitial.minute);
|
|
2119
|
+
const [selectionIsHours, setSelectionIsHours] = useState(true);
|
|
2120
|
+
const changeIsInternal = useRef(true);
|
|
2121
|
+
const selectionIsActive = useRef(false);
|
|
2122
|
+
const radianUnit = useMemo(() => {
|
|
2123
|
+
return Math.PI / (selectionIsHours ? 6 : 30);
|
|
2124
|
+
}, [selectionIsHours]);
|
|
2125
|
+
const hourFormat = useMemo(() => {
|
|
2126
|
+
return formatTime(hour === 0 ? 12 : hour);
|
|
2127
|
+
}, [hour]);
|
|
2128
|
+
const minuteFormat = useMemo(() => {
|
|
2129
|
+
return formatTime(minute);
|
|
2130
|
+
}, [minute]);
|
|
2131
|
+
const classNameHour = useMemo(() => {
|
|
2132
|
+
return renderClassStatus('rls-picker-clock__title__value', {
|
|
2133
|
+
active: selectionIsHours
|
|
2134
|
+
});
|
|
2135
|
+
}, [selectionIsHours]);
|
|
2136
|
+
const classNameMinute = useMemo(() => {
|
|
2137
|
+
return renderClassStatus('rls-picker-clock__title__value', {
|
|
2138
|
+
active: !selectionIsHours
|
|
2139
|
+
});
|
|
2140
|
+
}, [selectionIsHours]);
|
|
2141
|
+
const classNameAM = useMemo(() => {
|
|
2142
|
+
return renderClassStatus('rls-picker-clock__zone__value', {
|
|
2143
|
+
active: !zoneIsPM
|
|
2144
|
+
});
|
|
2145
|
+
}, [zoneIsPM]);
|
|
2146
|
+
const classNamePM = useMemo(() => {
|
|
2147
|
+
return renderClassStatus('rls-picker-clock__zone__value', {
|
|
2148
|
+
active: zoneIsPM
|
|
2149
|
+
});
|
|
2150
|
+
}, [zoneIsPM]);
|
|
2151
|
+
const refreshClockHour = useEffectEvent(() => {
|
|
2152
|
+
refreshClock(hour > 12 ? hour - 12 : hour);
|
|
2153
|
+
});
|
|
2154
|
+
const refreshClockMinute = useEffectEvent(() => {
|
|
2155
|
+
refreshClock(minute);
|
|
2156
|
+
});
|
|
2157
|
+
useEffect(() => {
|
|
2158
|
+
return i18nSubscribe(() => {
|
|
2159
|
+
setLabels({
|
|
2160
|
+
timeActionCancel: reactI18n('dateActionCancel'),
|
|
2161
|
+
timeActionSelect: reactI18n('dateActionSelect')
|
|
2162
|
+
});
|
|
2163
|
+
});
|
|
2164
|
+
}, []);
|
|
2165
|
+
useEffect(() => {
|
|
2166
|
+
selectionIsHours ? refreshClockHour() : refreshClockMinute();
|
|
2167
|
+
}, [selectionIsHours]);
|
|
2168
|
+
useEffect(() => {
|
|
2169
|
+
if (!changeIsInternal.current && formControl?.value) {
|
|
2170
|
+
const zoneIsPM = formControl.value.hour >= 12;
|
|
2171
|
+
setZoneIsPM(zoneIsPM);
|
|
2172
|
+
setHour(zoneIsPM ? formControl.value.hour - 12 : formControl.value.hour);
|
|
2173
|
+
setMinute(formControl.value.minute);
|
|
2174
|
+
}
|
|
2175
|
+
changeIsInternal.current = false;
|
|
2176
|
+
}, [formControl?.value]);
|
|
2177
|
+
const refreshComponent = useCallback((clientX, clientY) => {
|
|
2178
|
+
const rectangle = plateElement.current.getBoundingClientRect();
|
|
2179
|
+
const centerX = rectangle.left + rectangle.width / 2;
|
|
2180
|
+
const centerY = rectangle.top + rectangle.height / 2;
|
|
2181
|
+
const positionX = clientX - centerX;
|
|
2182
|
+
const positionY = clientY - centerY;
|
|
2183
|
+
const angle = Math.atan2(-positionX, positionY) + Math.PI;
|
|
2184
|
+
const value = Math.round(angle / radianUnit);
|
|
2185
|
+
refreshClock(value);
|
|
2186
|
+
selectionIsHours ? setHour(value === 0 ? 12 : value) : setMinute(value);
|
|
2187
|
+
}, [selectionIsHours, radianUnit]);
|
|
2188
|
+
const refreshClock = useCallback((value) => {
|
|
2189
|
+
const angle = value * radianUnit;
|
|
2190
|
+
const x2 = Math.sin(angle) * (RADIUS - TICK_RADIUS);
|
|
2191
|
+
const y2 = -Math.cos(angle) * (RADIUS - TICK_RADIUS);
|
|
2192
|
+
const cx = Math.sin(angle) * RADIUS;
|
|
2193
|
+
const cy = -Math.cos(angle) * RADIUS;
|
|
2194
|
+
lineElement.current.setAttribute('x2', `${x2 - 1}rem`);
|
|
2195
|
+
lineElement.current.setAttribute('y2', `${y2 - 1}rem`);
|
|
2196
|
+
indicatorElement.current.setAttribute('cx', `${cx - 1}rem`);
|
|
2197
|
+
indicatorElement.current.setAttribute('cy', `${cy - 1}rem`);
|
|
2198
|
+
pointElement.current.setAttribute('cx', `${cx - 1}rem`);
|
|
2199
|
+
pointElement.current.setAttribute('cy', `${cy - 1}rem`);
|
|
2200
|
+
pointElement.current.style.visibility =
|
|
2201
|
+
selectionIsHours || value % 5 === 0 ? 'hidden' : 'visible';
|
|
2202
|
+
}, [selectionIsHours, radianUnit]);
|
|
2203
|
+
const onClickHour = useCallback(() => {
|
|
2204
|
+
setSelectionIsHours(true);
|
|
2205
|
+
}, []);
|
|
2206
|
+
const onClickMinute = useCallback(() => {
|
|
2207
|
+
setSelectionIsHours(false);
|
|
2208
|
+
}, []);
|
|
2209
|
+
const onClickAM = useCallback(() => {
|
|
2210
|
+
setZoneIsPM(false);
|
|
2211
|
+
}, []);
|
|
2212
|
+
const onClickPM = useCallback(() => {
|
|
2213
|
+
setZoneIsPM(true);
|
|
2214
|
+
}, []);
|
|
2215
|
+
const onActiveSelection = useCallback(() => {
|
|
2216
|
+
selectionIsActive.current = true;
|
|
2217
|
+
}, []);
|
|
2218
|
+
const onMouseSelection = useCallback((event) => {
|
|
2219
|
+
if (selectionIsActive.current) {
|
|
2220
|
+
event.preventDefault();
|
|
2221
|
+
refreshComponent(event.clientX, event.clientY);
|
|
2222
|
+
}
|
|
2223
|
+
}, [refreshComponent]);
|
|
2224
|
+
const onTouchSelection = useCallback((event) => {
|
|
2225
|
+
const touch = event.touches.item(0);
|
|
2226
|
+
if (selectionIsActive.current && touch) {
|
|
2227
|
+
refreshComponent(touch.clientX, touch.clientY);
|
|
2228
|
+
}
|
|
2229
|
+
}, [refreshComponent]);
|
|
2230
|
+
const onInactiveSelection = useCallback(() => {
|
|
2231
|
+
selectionIsActive.current = false;
|
|
2232
|
+
}, []);
|
|
2233
|
+
const onClickValue = useCallback((value) => {
|
|
2234
|
+
if (selectionIsHours) {
|
|
2235
|
+
setHour(value);
|
|
2236
|
+
refreshClock(value);
|
|
2237
|
+
}
|
|
2238
|
+
else {
|
|
2239
|
+
const minute = value === 12 ? 0 : value * 5;
|
|
2240
|
+
setMinute(minute);
|
|
2241
|
+
refreshClock(minute);
|
|
2242
|
+
}
|
|
2243
|
+
}, [selectionIsHours]);
|
|
2244
|
+
const onCancel = useCallback(() => {
|
|
2245
|
+
onListener?.({ event: PickerListenerEvent.Cancel });
|
|
2246
|
+
}, [onListener]);
|
|
2247
|
+
const onCurrentTime = useCallback(() => {
|
|
2248
|
+
const currentTime = Time.now();
|
|
2249
|
+
changeIsInternal.current = true;
|
|
2250
|
+
formControl?.setValue(currentTime);
|
|
2251
|
+
setHour(currentTime.hour);
|
|
2252
|
+
setMinute(currentTime.minute);
|
|
2253
|
+
onListener?.({
|
|
2254
|
+
event: PickerListenerEvent.Select,
|
|
2255
|
+
value: currentTime
|
|
2256
|
+
});
|
|
2257
|
+
}, [formControl, onListener]);
|
|
2258
|
+
const onSelect = useCallback(() => {
|
|
2259
|
+
const hourValue = zoneIsPM
|
|
2260
|
+
? hour !== 12
|
|
2261
|
+
? hour + 12
|
|
2262
|
+
: 12
|
|
2263
|
+
: hour === 12
|
|
2264
|
+
? 0
|
|
2265
|
+
: hour;
|
|
2266
|
+
const timeValue = new Time(hourValue, minute);
|
|
2267
|
+
changeIsInternal.current = true;
|
|
2268
|
+
formControl?.setValue(timeValue);
|
|
2269
|
+
onListener?.({
|
|
2270
|
+
event: PickerListenerEvent.Select,
|
|
2271
|
+
value: timeValue
|
|
2272
|
+
});
|
|
2273
|
+
}, [formControl, hour, minute, zoneIsPM, onListener]);
|
|
2274
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__header", children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__title", children: [jsxRuntimeExports.jsx("span", { className: classNameHour, onClick: onClickHour, children: hourFormat }), jsxRuntimeExports.jsx("span", { className: "rls-picker-clock__title__separator", children: ":" }), jsxRuntimeExports.jsx("span", { className: classNameMinute, onClick: onClickMinute, children: minuteFormat })] }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__zone", children: [jsxRuntimeExports.jsx("span", { className: classNameAM, onClick: onClickAM, children: "AM" }), jsxRuntimeExports.jsx("span", { className: classNamePM, onClick: onClickPM, children: "PM" })] })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__body", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__plate", ref: plateElement, onMouseDown: onActiveSelection, onMouseMove: onMouseSelection, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onActiveSelection, onTouchMove: onTouchSelection, onTouchEnd: onInactiveSelection, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__canvas", children: jsxRuntimeExports.jsx("svg", { width: "120rem", height: "120rem", children: jsxRuntimeExports.jsxs("g", { style: {
|
|
2275
|
+
transform: `translate(${DIAL_RADIUS}rem, ${DIAL_RADIUS}rem)`
|
|
2276
|
+
}, children: [jsxRuntimeExports.jsx("line", { ref: lineElement, className: "rls-picker-clock__canvas__line", x1: "-1", y1: "-1" }), jsxRuntimeExports.jsx("circle", { ref: centerElement, className: "rls-picker-clock__canvas__center", r: "4", cx: "-1", cy: "-1" }), jsxRuntimeExports.jsx("circle", { ref: indicatorElement, className: "rls-picker-clock__canvas__indicator", r: `${TICK_RADIUS}rem` }), jsxRuntimeExports.jsx("circle", { ref: pointElement, className: "rls-picker-clock__canvas__point", r: "3.5" })] }) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__hours", children: CLOCK_VALUES.map((value) => {
|
|
2277
|
+
return (jsxRuntimeExports.jsx(RlsPickerClockTick, { value: value, selectionIsHours: selectionIsHours, onValue: onClickValue }, value));
|
|
2278
|
+
}) })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__footer", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__footer--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.timeActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__footer--today", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "timer", onClick: onCurrentTime }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__footer--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.timeActionSelect }) })] })] }));
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
function RlsFieldClock({ children, disabled: disabledProps, formControl, identifier, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, time, value: valueInitial }) {
|
|
2282
|
+
const [value, setValue] = useState(formControl?.value ?? valueInitial);
|
|
2283
|
+
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
2284
|
+
const disabled = useMemo(() => {
|
|
2285
|
+
return formControl?.disabled || disabledProps;
|
|
2286
|
+
}, [formControl?.disabled, disabledProps]);
|
|
2287
|
+
const className = useMemo(() => {
|
|
2288
|
+
return renderClassStatus('rls-field-box', {
|
|
2289
|
+
disabled,
|
|
2290
|
+
readonly: readOnly
|
|
2291
|
+
});
|
|
2292
|
+
}, [disabled, readOnly]);
|
|
2293
|
+
const timeValue = useMemo(() => {
|
|
2294
|
+
return formControl ? formControl.value : value;
|
|
2295
|
+
}, [formControl?.value, value]);
|
|
2296
|
+
const status = useMemo(() => {
|
|
2297
|
+
return {
|
|
2298
|
+
icon: timeValue ? 'trash-2' : 'timer',
|
|
2299
|
+
valueInput: timeValue?.normalizeMeridiemFormat || ''
|
|
2300
|
+
};
|
|
2301
|
+
}, [timeValue]);
|
|
2302
|
+
const onClickInput = useCallback(() => {
|
|
2303
|
+
!readOnly && setModalIsVisible(true);
|
|
2304
|
+
}, [readOnly]);
|
|
2305
|
+
const onChange = useCallback((value) => {
|
|
2306
|
+
setValue(value);
|
|
2307
|
+
onValue?.(value);
|
|
2308
|
+
}, [onValue]);
|
|
2309
|
+
const onClickAction = useCallback(() => {
|
|
2310
|
+
if (timeValue) {
|
|
2311
|
+
formControl?.setValue(valueInitial);
|
|
2312
|
+
formControl?.touch();
|
|
2313
|
+
onChange(valueInitial);
|
|
2314
|
+
}
|
|
2315
|
+
else {
|
|
2316
|
+
setModalIsVisible(true);
|
|
2317
|
+
}
|
|
2318
|
+
}, [timeValue, formControl, valueInitial, onChange]);
|
|
2319
|
+
const onListener = useCallback(({ event, value }) => {
|
|
2320
|
+
event !== PickerListenerEvent.Cancel && onChange(value);
|
|
2321
|
+
formControl?.touch();
|
|
2322
|
+
setModalIsVisible(false);
|
|
2323
|
+
}, [formControl, onChange]);
|
|
2324
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx("button", { className: "rls-field-date__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: status.icon }) }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-clock-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerClock, { formControl: formControl, time: time, disabled: disabled, onListener: onListener }) })] }));
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
const DATE_FORMAT = '{dd}/{mx}/{yy}';
|
|
2328
|
+
const DATE_FORMAT_TITLE = '{dw}, {mx} {dd} de {yy}';
|
|
2329
|
+
const DATE_RANGE_FORMAT = '{dd}/{mx}/{yy}';
|
|
2330
|
+
|
|
2075
2331
|
function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
2076
2332
|
const today = useRef(new Date()); // Initial current date in component
|
|
2077
2333
|
const _date = useMemo(() => {
|
|
@@ -2124,81 +2380,84 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2124
2380
|
type === 'month' ? setVisibility('MONTH') : setVisibility('YEAR');
|
|
2125
2381
|
}, []);
|
|
2126
2382
|
const onCancel = useCallback(() => {
|
|
2127
|
-
onListener
|
|
2383
|
+
onListener?.({ event: PickerListenerEvent.Cancel });
|
|
2128
2384
|
}, [onListener]);
|
|
2129
2385
|
const onToday = useCallback(() => {
|
|
2130
2386
|
yearControl.setValue(today.current.getFullYear());
|
|
2131
2387
|
dayControl.setValue(today.current.getDate());
|
|
2132
2388
|
monthControl.setValue(today.current.getMonth());
|
|
2133
2389
|
formControl?.setValue(today.current);
|
|
2134
|
-
onListener
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
}, [today.current, formControl, onListener]);
|
|
2390
|
+
onListener?.({
|
|
2391
|
+
event: PickerListenerEvent.Now,
|
|
2392
|
+
value: today.current
|
|
2393
|
+
});
|
|
2394
|
+
}, [formControl, onListener]);
|
|
2140
2395
|
const onSelect = useCallback(() => {
|
|
2141
2396
|
formControl?.setValue(value);
|
|
2142
|
-
onListener
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
});
|
|
2397
|
+
onListener?.({
|
|
2398
|
+
event: PickerListenerEvent.Select,
|
|
2399
|
+
value
|
|
2400
|
+
});
|
|
2147
2401
|
}, [formControl, value, onListener]);
|
|
2148
2402
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntimeExports.jsx(RlsPickerSelectorTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityTitle }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) })] }), jsxRuntimeExports.jsxs("div", { className: classNameComponent, children: [jsxRuntimeExports.jsx(RlsPickerDay, { formControl: dayControl, date: _date, month: monthControl.value, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, date: _date, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, date: _date, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), !automatic && (jsxRuntimeExports.jsx("div", { className: "rls-picker-date__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.dateActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--today", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "calendar", onClick: onToday, disabled: itIsDisabledToday }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.dateActionSelect }) })] }) }))] }));
|
|
2149
2403
|
}
|
|
2150
2404
|
|
|
2151
|
-
function RlsFieldDate({ children, date, disabled, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value:
|
|
2405
|
+
function RlsFieldDate({ children, date, disabled: disabledProps, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
|
|
2152
2406
|
const today = useRef(new Date()); // Initial current date in component
|
|
2153
|
-
const [value, setValue] = useState(formControl?.value ??
|
|
2407
|
+
const [value, setValue] = useState(formControl?.value ?? valueInitial);
|
|
2154
2408
|
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
2155
|
-
const
|
|
2156
|
-
return formControl?.disabled ||
|
|
2157
|
-
}, [formControl?.disabled,
|
|
2409
|
+
const disabled = useMemo(() => {
|
|
2410
|
+
return formControl?.disabled || disabledProps;
|
|
2411
|
+
}, [formControl?.disabled, disabledProps]);
|
|
2158
2412
|
const className = useMemo(() => {
|
|
2159
2413
|
return renderClassStatus('rls-field-box', {
|
|
2160
|
-
disabled
|
|
2414
|
+
disabled,
|
|
2161
2415
|
readonly: readOnly
|
|
2162
2416
|
});
|
|
2163
|
-
}, [
|
|
2164
|
-
const
|
|
2417
|
+
}, [disabled, readOnly]);
|
|
2418
|
+
const dateValue = useMemo(() => {
|
|
2419
|
+
return formControl ? formControl.value : value;
|
|
2420
|
+
}, [formControl?.value, value]);
|
|
2421
|
+
const status = useMemo(() => {
|
|
2165
2422
|
return {
|
|
2166
|
-
icon:
|
|
2167
|
-
|
|
2423
|
+
icon: dateValue ? 'trash-2' : 'calendar',
|
|
2424
|
+
label: dateValue
|
|
2425
|
+
? dateFormatTemplate(dateValue, format || DATE_FORMAT)
|
|
2426
|
+
: ''
|
|
2168
2427
|
};
|
|
2169
|
-
}, [
|
|
2428
|
+
}, [dateValue, format]);
|
|
2170
2429
|
useEffect(() => {
|
|
2171
|
-
const
|
|
2430
|
+
const dateSecure = verifyDateRange({
|
|
2172
2431
|
date: formControl?.value ?? date ?? today.current,
|
|
2173
2432
|
minDate,
|
|
2174
2433
|
maxDate
|
|
2175
2434
|
});
|
|
2176
|
-
setValue(
|
|
2177
|
-
formControl?.setValue(
|
|
2435
|
+
setValue(dateSecure);
|
|
2436
|
+
formControl?.setValue(dateSecure);
|
|
2178
2437
|
}, []);
|
|
2179
2438
|
const onClickInput = useCallback(() => {
|
|
2180
2439
|
!readOnly && setModalIsVisible(true);
|
|
2181
2440
|
}, [readOnly]);
|
|
2182
2441
|
const onChange = useCallback((value) => {
|
|
2183
2442
|
setValue(value);
|
|
2184
|
-
onValue
|
|
2443
|
+
onValue?.(value);
|
|
2185
2444
|
}, [onValue]);
|
|
2186
2445
|
const onClickAction = useCallback(() => {
|
|
2187
|
-
if (
|
|
2188
|
-
formControl?.setValue(
|
|
2446
|
+
if (dateValue) {
|
|
2447
|
+
formControl?.setValue(valueInitial);
|
|
2189
2448
|
formControl?.touch();
|
|
2190
|
-
onChange(
|
|
2449
|
+
onChange(valueInitial);
|
|
2191
2450
|
}
|
|
2192
2451
|
else {
|
|
2193
2452
|
setModalIsVisible(true);
|
|
2194
2453
|
}
|
|
2195
|
-
}, [
|
|
2454
|
+
}, [dateValue, formControl, valueInitial, onChange]);
|
|
2196
2455
|
const onListener = useCallback(({ event, value }) => {
|
|
2197
2456
|
event !== PickerListenerEvent.Cancel && onChange(value);
|
|
2198
2457
|
formControl?.touch();
|
|
2199
2458
|
setModalIsVisible(false);
|
|
2200
2459
|
}, [formControl, onChange]);
|
|
2201
|
-
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date__control", type: "text", value:
|
|
2460
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date__control", type: "text", value: status.label, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx("button", { className: "rls-field-date__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: status.icon }) }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-date-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
|
|
2202
2461
|
}
|
|
2203
2462
|
|
|
2204
2463
|
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
@@ -2207,8 +2466,8 @@ function rangeFormatTemplate({ maxDate, minDate }) {
|
|
|
2207
2466
|
return `${minFormat} - ${maxFormat}`;
|
|
2208
2467
|
}
|
|
2209
2468
|
|
|
2210
|
-
function RlsPickerDateRange({ automatic, date:
|
|
2211
|
-
const _date = useMemo(() => normalizeMinTime(
|
|
2469
|
+
function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
2470
|
+
const _date = useMemo(() => normalizeMinTime(datePicker ?? new Date()), [datePicker]);
|
|
2212
2471
|
const _range = useMemo(() => formControl?.value ?? DateRange.now(), [formControl?.value]);
|
|
2213
2472
|
const yearControl = useReactControl(_date.getFullYear());
|
|
2214
2473
|
const monthControl = useReactControl(_date.getMonth());
|
|
@@ -2273,48 +2532,51 @@ function RlsPickerDateRange({ automatic, date: _picker, disabled, formControl, m
|
|
|
2273
2532
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__header", children: [jsxRuntimeExports.jsx(RlsPickerSelectorTitle, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityTitle }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) })] }), jsxRuntimeExports.jsxs("div", { className: classNameComponent, children: [jsxRuntimeExports.jsx(RlsPickerDayRange, { formControl: rangeControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntimeExports.jsx("div", { className: classNameFooter, children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.dateActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.dateActionSelect }) })] }) })] }));
|
|
2274
2533
|
}
|
|
2275
2534
|
|
|
2276
|
-
function RlsFieldDateRange({ children, date
|
|
2277
|
-
const currentDate = useMemo(() =>
|
|
2278
|
-
const [value, setValue] = useState(formControl?.value ||
|
|
2535
|
+
function RlsFieldDateRange({ children, date, disabled: disabledProps, formControl, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
|
|
2536
|
+
const currentDate = useMemo(() => date ?? new Date(), [date]);
|
|
2537
|
+
const [value, setValue] = useState(formControl?.value || valueInitial);
|
|
2279
2538
|
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
2280
|
-
const
|
|
2281
|
-
return formControl?.disabled ||
|
|
2282
|
-
}, [formControl?.disabled,
|
|
2539
|
+
const disabled = useMemo(() => {
|
|
2540
|
+
return formControl?.disabled || disabledProps;
|
|
2541
|
+
}, [formControl?.disabled, disabledProps]);
|
|
2283
2542
|
const className = useMemo(() => {
|
|
2284
2543
|
return renderClassStatus('rls-field-box', {
|
|
2285
|
-
disabled
|
|
2544
|
+
disabled,
|
|
2286
2545
|
readonly: readOnly
|
|
2287
2546
|
});
|
|
2288
|
-
}, [
|
|
2289
|
-
const
|
|
2547
|
+
}, [disabled, readOnly]);
|
|
2548
|
+
const dateRangeValue = useMemo(() => {
|
|
2549
|
+
return formControl ? formControl.value : value;
|
|
2550
|
+
}, [formControl?.value, value]);
|
|
2551
|
+
const status = useMemo(() => {
|
|
2290
2552
|
return {
|
|
2291
|
-
icon:
|
|
2292
|
-
valueInput:
|
|
2553
|
+
icon: dateRangeValue ? 'trash-2' : 'calendar',
|
|
2554
|
+
valueInput: dateRangeValue ? rangeFormatTemplate(dateRangeValue) : ''
|
|
2293
2555
|
};
|
|
2294
|
-
}, [
|
|
2556
|
+
}, [dateRangeValue]);
|
|
2295
2557
|
const onClickInput = useCallback(() => {
|
|
2296
2558
|
!readOnly && setModalIsVisible(true);
|
|
2297
2559
|
}, [readOnly]);
|
|
2298
2560
|
const onChange = useCallback((value) => {
|
|
2299
2561
|
setValue(value);
|
|
2300
|
-
onValue
|
|
2562
|
+
onValue?.(value);
|
|
2301
2563
|
}, [onValue]);
|
|
2302
2564
|
const onClickAction = useCallback(() => {
|
|
2303
|
-
if (
|
|
2304
|
-
formControl?.setValue(
|
|
2565
|
+
if (dateRangeValue) {
|
|
2566
|
+
formControl?.setValue(valueInitial);
|
|
2305
2567
|
formControl?.touch();
|
|
2306
|
-
onChange(
|
|
2568
|
+
onChange(valueInitial);
|
|
2307
2569
|
}
|
|
2308
2570
|
else {
|
|
2309
2571
|
setModalIsVisible(true);
|
|
2310
2572
|
}
|
|
2311
|
-
}, [
|
|
2573
|
+
}, [dateRangeValue, formControl, valueInitial, onChange]);
|
|
2312
2574
|
const onListener = useCallback(({ event, value }) => {
|
|
2313
2575
|
event !== PickerListenerEvent.Cancel && onChange(value);
|
|
2314
2576
|
formControl?.touch();
|
|
2315
2577
|
setModalIsVisible(false);
|
|
2316
2578
|
}, [formControl, onChange]);
|
|
2317
|
-
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date-range__control", type: "text", value: valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled:
|
|
2579
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date-range__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: status.icon }) }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-date-range-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
|
|
2318
2580
|
}
|
|
2319
2581
|
|
|
2320
2582
|
function useFieldSelect(props) {
|
|
@@ -3012,5 +3274,5 @@ function usePortalController() {
|
|
|
3012
3274
|
return { close, open, visible };
|
|
3013
3275
|
}
|
|
3014
3276
|
|
|
3015
|
-
export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBottomSheet, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonOption, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContent, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldDecimal, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldPercentage, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsImage, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputDecimal, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputPercentage, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsModalSheet, RlsNavbar, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSpinner, RlsSwitch, RlsSwitchControl, RlsTabs, RlsTabularText, RlsToolbar, calculateImgDimension, rangeFormatTemplate, renderClassStatus, setErrorsI18n, useConfirmation, useDatatable, useFieldAutocomplete, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, usePortalController, useRelocationOnComponent, useResize, useSnackbar };
|
|
3277
|
+
export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBottomSheet, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonOption, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContent, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldClock, RlsFieldDate, RlsFieldDateRange, RlsFieldDecimal, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldPercentage, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsImage, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputDecimal, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputPercentage, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsModalSheet, RlsNavbar, RlsPagination, RlsPickerClock, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSpinner, RlsSwitch, RlsSwitchControl, RlsTabs, RlsTabularText, RlsToolbar, calculateImgDimension, rangeFormatTemplate, renderClassStatus, setErrorsI18n, useConfirmation, useDatatable, useFieldAutocomplete, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, usePortalController, useRelocationOnComponent, useResize, useSnackbar };
|
|
3016
3278
|
//# sourceMappingURL=index.js.map
|