@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/cjs/index.js
CHANGED
|
@@ -601,7 +601,7 @@ function RlsInput({ children, decimals, disabled, formControl, identifier, onBlu
|
|
|
601
601
|
? parseFloat((+valueInput).toFixed(decimals))
|
|
602
602
|
: valueInput;
|
|
603
603
|
changeIsInternal.current = true;
|
|
604
|
-
onValue
|
|
604
|
+
onValue?.(value);
|
|
605
605
|
setValueInput(valueInput);
|
|
606
606
|
formControl?.setValue(value);
|
|
607
607
|
}, [formControl, onValue, type, decimals]);
|
|
@@ -640,7 +640,7 @@ function RlsInputDecimal(props) {
|
|
|
640
640
|
const onValueInput = require$$0.useCallback((value) => {
|
|
641
641
|
const valueDecimal = commons.BigDecimal.create(value);
|
|
642
642
|
formControl ? formControl.setValue(valueDecimal) : setValueInput(value);
|
|
643
|
-
onValue
|
|
643
|
+
onValue?.(valueDecimal);
|
|
644
644
|
}, [formControl, onValue]);
|
|
645
645
|
const decimalProps = { ...props, formControl: undefined };
|
|
646
646
|
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 }) }) }));
|
|
@@ -651,7 +651,7 @@ function RlsInputMoney(props) {
|
|
|
651
651
|
const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? 0);
|
|
652
652
|
const onValueInput = require$$0.useCallback((value) => {
|
|
653
653
|
!formControl && setValueInput(value);
|
|
654
|
-
onValue
|
|
654
|
+
onValue?.(value);
|
|
655
655
|
}, [formControl, onValue]);
|
|
656
656
|
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 }) }) }));
|
|
657
657
|
}
|
|
@@ -661,7 +661,7 @@ function RlsInputNumber(props) {
|
|
|
661
661
|
const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? 0);
|
|
662
662
|
const onValueInput = require$$0.useCallback((value) => {
|
|
663
663
|
!formControl && setValueInput(value);
|
|
664
|
-
onValue
|
|
664
|
+
onValue?.(value);
|
|
665
665
|
}, [formControl, onValue]);
|
|
666
666
|
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 }) }));
|
|
667
667
|
}
|
|
@@ -670,7 +670,7 @@ function RlsInputPassword({ disabled, formControl, identifier, onEnter, onKeyDow
|
|
|
670
670
|
const [focused, setFocused] = require$$0.useState(false);
|
|
671
671
|
const _onChange = require$$0.useCallback((event) => {
|
|
672
672
|
formControl?.setValue(event.target.value);
|
|
673
|
-
onValue
|
|
673
|
+
onValue?.(event.target.value);
|
|
674
674
|
}, [formControl, onValue]);
|
|
675
675
|
const _onKeyDown = require$$0.useCallback((event) => {
|
|
676
676
|
onKeyDown && onKeyDown(event);
|
|
@@ -701,7 +701,7 @@ function RlsInputPercentage(props) {
|
|
|
701
701
|
const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? 0);
|
|
702
702
|
const onValueInput = require$$0.useCallback((value) => {
|
|
703
703
|
!formControl && setValueInput(value);
|
|
704
|
-
onValue
|
|
704
|
+
onValue?.(value);
|
|
705
705
|
}, [formControl, onValue]);
|
|
706
706
|
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, "%"] }) }));
|
|
707
707
|
}
|
|
@@ -722,7 +722,7 @@ function RlsInputText(props) {
|
|
|
722
722
|
const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? '');
|
|
723
723
|
const onValueInput = require$$0.useCallback((value) => {
|
|
724
724
|
!formControl && setValueInput(value);
|
|
725
|
-
onValue
|
|
725
|
+
onValue?.(value);
|
|
726
726
|
}, [formControl, onValue]);
|
|
727
727
|
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 }) }));
|
|
728
728
|
}
|
|
@@ -1207,7 +1207,7 @@ function RlsPickerDay({ date: _date, disabled, formControl, maxDate, month, minD
|
|
|
1207
1207
|
}, [formControl]);
|
|
1208
1208
|
const onSelect = require$$0.useCallback((value) => {
|
|
1209
1209
|
setDayValue(value);
|
|
1210
|
-
onValue
|
|
1210
|
+
onValue?.(value);
|
|
1211
1211
|
}, [setDayValue, onValue]);
|
|
1212
1212
|
require$$0.useEffect(() => {
|
|
1213
1213
|
return i18n.i18nSubscribe(() => {
|
|
@@ -1332,7 +1332,7 @@ function RlsPickerMonth({ date: _date, disabled, formControl, maxDate, minDate,
|
|
|
1332
1332
|
}, [formControl]);
|
|
1333
1333
|
const onSelect = require$$0.useCallback((value) => {
|
|
1334
1334
|
setMonthValue(value);
|
|
1335
|
-
onValue
|
|
1335
|
+
onValue?.(value);
|
|
1336
1336
|
}, [setMonthValue, onValue]);
|
|
1337
1337
|
require$$0.useEffect(() => {
|
|
1338
1338
|
setComponent(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: months.map((month, index) => (jsxRuntimeExports.jsx(RlsPickerMonthElement, { month: month, onSelect: onSelect, disabled: disabled }, index))) }));
|
|
@@ -1463,7 +1463,7 @@ function RlsPickerYear({ date: _date, disabled, formControl, maxDate, minDate, o
|
|
|
1463
1463
|
}, [formControl]);
|
|
1464
1464
|
const onSelect = require$$0.useCallback((value) => {
|
|
1465
1465
|
setYearValue(value);
|
|
1466
|
-
onValue
|
|
1466
|
+
onValue?.(value);
|
|
1467
1467
|
}, [setYearValue, onValue]);
|
|
1468
1468
|
require$$0.useEffect(() => {
|
|
1469
1469
|
const options = createPickerOptions(); // YearPickerProps
|
|
@@ -1559,7 +1559,7 @@ function RlsTabs({ tabs, onValue, rlsTheme }) {
|
|
|
1559
1559
|
const [value, setValue] = require$$0.useState();
|
|
1560
1560
|
const onSelect = require$$0.useCallback((value) => {
|
|
1561
1561
|
setValue(value);
|
|
1562
|
-
onValue
|
|
1562
|
+
onValue?.(value);
|
|
1563
1563
|
}, [onValue]);
|
|
1564
1564
|
require$$0.useEffect(() => {
|
|
1565
1565
|
const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
|
|
@@ -2060,10 +2060,6 @@ function RlsFieldAutocomplete(props) {
|
|
|
2060
2060
|
return jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: render });
|
|
2061
2061
|
}
|
|
2062
2062
|
|
|
2063
|
-
const DATE_FORMAT = '{dd}/{mx}/{yy}';
|
|
2064
|
-
const DATE_FORMAT_TITLE = '{dw}, {mx} {dd} de {yy}';
|
|
2065
|
-
const DATE_RANGE_FORMAT = '{dd}/{mx}/{yy}';
|
|
2066
|
-
|
|
2067
2063
|
function RlsModal({ children, className, onAutoClose, visible, rlsTheme }) {
|
|
2068
2064
|
const classNameModal = require$$0.useMemo(() => {
|
|
2069
2065
|
return renderClassStatus('rls-modal', { visible }, className);
|
|
@@ -2074,6 +2070,266 @@ function RlsModal({ children, className, onAutoClose, visible, rlsTheme }) {
|
|
|
2074
2070
|
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);
|
|
2075
2071
|
}
|
|
2076
2072
|
|
|
2073
|
+
function formatTime(value) {
|
|
2074
|
+
return String(value).padStart(2, '0');
|
|
2075
|
+
}
|
|
2076
|
+
const CLOCK_VALUES = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
2077
|
+
const RADIUS = 48;
|
|
2078
|
+
const DIAL_RADIUS = 60;
|
|
2079
|
+
const TICK_RADIUS = 7;
|
|
2080
|
+
function RlsPickerClockTick({ onValue, selectionIsHours, value }) {
|
|
2081
|
+
const styleTick = require$$0.useMemo(() => {
|
|
2082
|
+
const radian = (value / 6) * Math.PI;
|
|
2083
|
+
const x = Math.sin(radian) * RADIUS;
|
|
2084
|
+
const y = Math.cos(radian) * RADIUS;
|
|
2085
|
+
return {
|
|
2086
|
+
left: `${DIAL_RADIUS + x - TICK_RADIUS - 1}rem`,
|
|
2087
|
+
top: `${DIAL_RADIUS - y - TICK_RADIUS - 1}rem`
|
|
2088
|
+
};
|
|
2089
|
+
}, []);
|
|
2090
|
+
const label = require$$0.useMemo(() => {
|
|
2091
|
+
if (selectionIsHours) {
|
|
2092
|
+
return formatTime(value);
|
|
2093
|
+
}
|
|
2094
|
+
if (value === 12) {
|
|
2095
|
+
return formatTime(0);
|
|
2096
|
+
}
|
|
2097
|
+
return formatTime(value * 5);
|
|
2098
|
+
}, [selectionIsHours]);
|
|
2099
|
+
const onClick = require$$0.useCallback((event) => {
|
|
2100
|
+
event.preventDefault();
|
|
2101
|
+
onValue(value);
|
|
2102
|
+
}, [onValue]);
|
|
2103
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__tick", style: styleTick, onClick: onClick, children: label }));
|
|
2104
|
+
}
|
|
2105
|
+
function RlsPickerClock({ formControl, onListener, rlsTheme, time }) {
|
|
2106
|
+
const timeInitial = require$$0.useMemo(() => {
|
|
2107
|
+
return formControl?.value ?? time ?? dates.Time.now();
|
|
2108
|
+
}, [formControl?.value, time]);
|
|
2109
|
+
const plateElement = require$$0.useRef(null);
|
|
2110
|
+
const lineElement = require$$0.useRef(null);
|
|
2111
|
+
const centerElement = require$$0.useRef(null);
|
|
2112
|
+
const indicatorElement = require$$0.useRef(null);
|
|
2113
|
+
const pointElement = require$$0.useRef(null);
|
|
2114
|
+
const [labels, setLabels] = require$$0.useState({
|
|
2115
|
+
timeActionCancel: reactI18n('dateActionCancel'),
|
|
2116
|
+
timeActionSelect: reactI18n('dateActionSelect')
|
|
2117
|
+
});
|
|
2118
|
+
const [zoneIsPM, setZoneIsPM] = require$$0.useState(timeInitial.hour >= 12);
|
|
2119
|
+
const [hour, setHour] = require$$0.useState(zoneIsPM ? timeInitial.hour - 12 : timeInitial.hour);
|
|
2120
|
+
const [minute, setMinute] = require$$0.useState(timeInitial.minute);
|
|
2121
|
+
const [selectionIsHours, setSelectionIsHours] = require$$0.useState(true);
|
|
2122
|
+
const changeIsInternal = require$$0.useRef(true);
|
|
2123
|
+
const selectionIsActive = require$$0.useRef(false);
|
|
2124
|
+
const radianUnit = require$$0.useMemo(() => {
|
|
2125
|
+
return Math.PI / (selectionIsHours ? 6 : 30);
|
|
2126
|
+
}, [selectionIsHours]);
|
|
2127
|
+
const hourFormat = require$$0.useMemo(() => {
|
|
2128
|
+
return formatTime(hour === 0 ? 12 : hour);
|
|
2129
|
+
}, [hour]);
|
|
2130
|
+
const minuteFormat = require$$0.useMemo(() => {
|
|
2131
|
+
return formatTime(minute);
|
|
2132
|
+
}, [minute]);
|
|
2133
|
+
const classNameHour = require$$0.useMemo(() => {
|
|
2134
|
+
return renderClassStatus('rls-picker-clock__title__value', {
|
|
2135
|
+
active: selectionIsHours
|
|
2136
|
+
});
|
|
2137
|
+
}, [selectionIsHours]);
|
|
2138
|
+
const classNameMinute = require$$0.useMemo(() => {
|
|
2139
|
+
return renderClassStatus('rls-picker-clock__title__value', {
|
|
2140
|
+
active: !selectionIsHours
|
|
2141
|
+
});
|
|
2142
|
+
}, [selectionIsHours]);
|
|
2143
|
+
const classNameAM = require$$0.useMemo(() => {
|
|
2144
|
+
return renderClassStatus('rls-picker-clock__zone__value', {
|
|
2145
|
+
active: !zoneIsPM
|
|
2146
|
+
});
|
|
2147
|
+
}, [zoneIsPM]);
|
|
2148
|
+
const classNamePM = require$$0.useMemo(() => {
|
|
2149
|
+
return renderClassStatus('rls-picker-clock__zone__value', {
|
|
2150
|
+
active: zoneIsPM
|
|
2151
|
+
});
|
|
2152
|
+
}, [zoneIsPM]);
|
|
2153
|
+
const refreshClockHour = require$$0.useEffectEvent(() => {
|
|
2154
|
+
refreshClock(hour > 12 ? hour - 12 : hour);
|
|
2155
|
+
});
|
|
2156
|
+
const refreshClockMinute = require$$0.useEffectEvent(() => {
|
|
2157
|
+
refreshClock(minute);
|
|
2158
|
+
});
|
|
2159
|
+
require$$0.useEffect(() => {
|
|
2160
|
+
return i18n.i18nSubscribe(() => {
|
|
2161
|
+
setLabels({
|
|
2162
|
+
timeActionCancel: reactI18n('dateActionCancel'),
|
|
2163
|
+
timeActionSelect: reactI18n('dateActionSelect')
|
|
2164
|
+
});
|
|
2165
|
+
});
|
|
2166
|
+
}, []);
|
|
2167
|
+
require$$0.useEffect(() => {
|
|
2168
|
+
selectionIsHours ? refreshClockHour() : refreshClockMinute();
|
|
2169
|
+
}, [selectionIsHours]);
|
|
2170
|
+
require$$0.useEffect(() => {
|
|
2171
|
+
if (!changeIsInternal.current && formControl?.value) {
|
|
2172
|
+
const zoneIsPM = formControl.value.hour >= 12;
|
|
2173
|
+
setZoneIsPM(zoneIsPM);
|
|
2174
|
+
setHour(zoneIsPM ? formControl.value.hour - 12 : formControl.value.hour);
|
|
2175
|
+
setMinute(formControl.value.minute);
|
|
2176
|
+
}
|
|
2177
|
+
changeIsInternal.current = false;
|
|
2178
|
+
}, [formControl?.value]);
|
|
2179
|
+
const refreshComponent = require$$0.useCallback((clientX, clientY) => {
|
|
2180
|
+
const rectangle = plateElement.current.getBoundingClientRect();
|
|
2181
|
+
const centerX = rectangle.left + rectangle.width / 2;
|
|
2182
|
+
const centerY = rectangle.top + rectangle.height / 2;
|
|
2183
|
+
const positionX = clientX - centerX;
|
|
2184
|
+
const positionY = clientY - centerY;
|
|
2185
|
+
const angle = Math.atan2(-positionX, positionY) + Math.PI;
|
|
2186
|
+
const value = Math.round(angle / radianUnit);
|
|
2187
|
+
refreshClock(value);
|
|
2188
|
+
selectionIsHours ? setHour(value === 0 ? 12 : value) : setMinute(value);
|
|
2189
|
+
}, [selectionIsHours, radianUnit]);
|
|
2190
|
+
const refreshClock = require$$0.useCallback((value) => {
|
|
2191
|
+
const angle = value * radianUnit;
|
|
2192
|
+
const x2 = Math.sin(angle) * (RADIUS - TICK_RADIUS);
|
|
2193
|
+
const y2 = -Math.cos(angle) * (RADIUS - TICK_RADIUS);
|
|
2194
|
+
const cx = Math.sin(angle) * RADIUS;
|
|
2195
|
+
const cy = -Math.cos(angle) * RADIUS;
|
|
2196
|
+
lineElement.current.setAttribute('x2', `${x2 - 1}rem`);
|
|
2197
|
+
lineElement.current.setAttribute('y2', `${y2 - 1}rem`);
|
|
2198
|
+
indicatorElement.current.setAttribute('cx', `${cx - 1}rem`);
|
|
2199
|
+
indicatorElement.current.setAttribute('cy', `${cy - 1}rem`);
|
|
2200
|
+
pointElement.current.setAttribute('cx', `${cx - 1}rem`);
|
|
2201
|
+
pointElement.current.setAttribute('cy', `${cy - 1}rem`);
|
|
2202
|
+
pointElement.current.style.visibility =
|
|
2203
|
+
selectionIsHours || value % 5 === 0 ? 'hidden' : 'visible';
|
|
2204
|
+
}, [selectionIsHours, radianUnit]);
|
|
2205
|
+
const onClickHour = require$$0.useCallback(() => {
|
|
2206
|
+
setSelectionIsHours(true);
|
|
2207
|
+
}, []);
|
|
2208
|
+
const onClickMinute = require$$0.useCallback(() => {
|
|
2209
|
+
setSelectionIsHours(false);
|
|
2210
|
+
}, []);
|
|
2211
|
+
const onClickAM = require$$0.useCallback(() => {
|
|
2212
|
+
setZoneIsPM(false);
|
|
2213
|
+
}, []);
|
|
2214
|
+
const onClickPM = require$$0.useCallback(() => {
|
|
2215
|
+
setZoneIsPM(true);
|
|
2216
|
+
}, []);
|
|
2217
|
+
const onActiveSelection = require$$0.useCallback(() => {
|
|
2218
|
+
selectionIsActive.current = true;
|
|
2219
|
+
}, []);
|
|
2220
|
+
const onMouseSelection = require$$0.useCallback((event) => {
|
|
2221
|
+
if (selectionIsActive.current) {
|
|
2222
|
+
event.preventDefault();
|
|
2223
|
+
refreshComponent(event.clientX, event.clientY);
|
|
2224
|
+
}
|
|
2225
|
+
}, [refreshComponent]);
|
|
2226
|
+
const onTouchSelection = require$$0.useCallback((event) => {
|
|
2227
|
+
const touch = event.touches.item(0);
|
|
2228
|
+
if (selectionIsActive.current && touch) {
|
|
2229
|
+
refreshComponent(touch.clientX, touch.clientY);
|
|
2230
|
+
}
|
|
2231
|
+
}, [refreshComponent]);
|
|
2232
|
+
const onInactiveSelection = require$$0.useCallback(() => {
|
|
2233
|
+
selectionIsActive.current = false;
|
|
2234
|
+
}, []);
|
|
2235
|
+
const onClickValue = require$$0.useCallback((value) => {
|
|
2236
|
+
if (selectionIsHours) {
|
|
2237
|
+
setHour(value);
|
|
2238
|
+
refreshClock(value);
|
|
2239
|
+
}
|
|
2240
|
+
else {
|
|
2241
|
+
const minute = value === 12 ? 0 : value * 5;
|
|
2242
|
+
setMinute(minute);
|
|
2243
|
+
refreshClock(minute);
|
|
2244
|
+
}
|
|
2245
|
+
}, [selectionIsHours]);
|
|
2246
|
+
const onCancel = require$$0.useCallback(() => {
|
|
2247
|
+
onListener?.({ event: components.PickerListenerEvent.Cancel });
|
|
2248
|
+
}, [onListener]);
|
|
2249
|
+
const onCurrentTime = require$$0.useCallback(() => {
|
|
2250
|
+
const currentTime = dates.Time.now();
|
|
2251
|
+
changeIsInternal.current = true;
|
|
2252
|
+
formControl?.setValue(currentTime);
|
|
2253
|
+
setHour(currentTime.hour);
|
|
2254
|
+
setMinute(currentTime.minute);
|
|
2255
|
+
onListener?.({
|
|
2256
|
+
event: components.PickerListenerEvent.Select,
|
|
2257
|
+
value: currentTime
|
|
2258
|
+
});
|
|
2259
|
+
}, [formControl, onListener]);
|
|
2260
|
+
const onSelect = require$$0.useCallback(() => {
|
|
2261
|
+
const hourValue = zoneIsPM
|
|
2262
|
+
? hour !== 12
|
|
2263
|
+
? hour + 12
|
|
2264
|
+
: 12
|
|
2265
|
+
: hour === 12
|
|
2266
|
+
? 0
|
|
2267
|
+
: hour;
|
|
2268
|
+
const timeValue = new dates.Time(hourValue, minute);
|
|
2269
|
+
changeIsInternal.current = true;
|
|
2270
|
+
formControl?.setValue(timeValue);
|
|
2271
|
+
onListener?.({
|
|
2272
|
+
event: components.PickerListenerEvent.Select,
|
|
2273
|
+
value: timeValue
|
|
2274
|
+
});
|
|
2275
|
+
}, [formControl, hour, minute, zoneIsPM, onListener]);
|
|
2276
|
+
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: {
|
|
2277
|
+
transform: `translate(${DIAL_RADIUS}rem, ${DIAL_RADIUS}rem)`
|
|
2278
|
+
}, 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) => {
|
|
2279
|
+
return (jsxRuntimeExports.jsx(RlsPickerClockTick, { value: value, selectionIsHours: selectionIsHours, onValue: onClickValue }, value));
|
|
2280
|
+
}) })] }) }), 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 }) })] })] }));
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
function RlsFieldClock({ children, disabled: disabledProps, formControl, identifier, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, time, value: valueInitial }) {
|
|
2284
|
+
const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
|
|
2285
|
+
const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
|
|
2286
|
+
const disabled = require$$0.useMemo(() => {
|
|
2287
|
+
return formControl?.disabled || disabledProps;
|
|
2288
|
+
}, [formControl?.disabled, disabledProps]);
|
|
2289
|
+
const className = require$$0.useMemo(() => {
|
|
2290
|
+
return renderClassStatus('rls-field-box', {
|
|
2291
|
+
disabled,
|
|
2292
|
+
readonly: readOnly
|
|
2293
|
+
});
|
|
2294
|
+
}, [disabled, readOnly]);
|
|
2295
|
+
const timeValue = require$$0.useMemo(() => {
|
|
2296
|
+
return formControl ? formControl.value : value;
|
|
2297
|
+
}, [formControl?.value, value]);
|
|
2298
|
+
const status = require$$0.useMemo(() => {
|
|
2299
|
+
return {
|
|
2300
|
+
icon: timeValue ? 'trash-2' : 'timer',
|
|
2301
|
+
valueInput: timeValue?.normalizeMeridiemFormat || ''
|
|
2302
|
+
};
|
|
2303
|
+
}, [timeValue]);
|
|
2304
|
+
const onClickInput = require$$0.useCallback(() => {
|
|
2305
|
+
!readOnly && setModalIsVisible(true);
|
|
2306
|
+
}, [readOnly]);
|
|
2307
|
+
const onChange = require$$0.useCallback((value) => {
|
|
2308
|
+
setValue(value);
|
|
2309
|
+
onValue?.(value);
|
|
2310
|
+
}, [onValue]);
|
|
2311
|
+
const onClickAction = require$$0.useCallback(() => {
|
|
2312
|
+
if (timeValue) {
|
|
2313
|
+
formControl?.setValue(valueInitial);
|
|
2314
|
+
formControl?.touch();
|
|
2315
|
+
onChange(valueInitial);
|
|
2316
|
+
}
|
|
2317
|
+
else {
|
|
2318
|
+
setModalIsVisible(true);
|
|
2319
|
+
}
|
|
2320
|
+
}, [timeValue, formControl, valueInitial, onChange]);
|
|
2321
|
+
const onListener = require$$0.useCallback(({ event, value }) => {
|
|
2322
|
+
event !== components.PickerListenerEvent.Cancel && onChange(value);
|
|
2323
|
+
formControl?.touch();
|
|
2324
|
+
setModalIsVisible(false);
|
|
2325
|
+
}, [formControl, onChange]);
|
|
2326
|
+
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 }) })] }));
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
const DATE_FORMAT = '{dd}/{mx}/{yy}';
|
|
2330
|
+
const DATE_FORMAT_TITLE = '{dw}, {mx} {dd} de {yy}';
|
|
2331
|
+
const DATE_RANGE_FORMAT = '{dd}/{mx}/{yy}';
|
|
2332
|
+
|
|
2077
2333
|
function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
2078
2334
|
const today = require$$0.useRef(new Date()); // Initial current date in component
|
|
2079
2335
|
const _date = require$$0.useMemo(() => {
|
|
@@ -2126,81 +2382,84 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2126
2382
|
type === 'month' ? setVisibility('MONTH') : setVisibility('YEAR');
|
|
2127
2383
|
}, []);
|
|
2128
2384
|
const onCancel = require$$0.useCallback(() => {
|
|
2129
|
-
onListener
|
|
2385
|
+
onListener?.({ event: components.PickerListenerEvent.Cancel });
|
|
2130
2386
|
}, [onListener]);
|
|
2131
2387
|
const onToday = require$$0.useCallback(() => {
|
|
2132
2388
|
yearControl.setValue(today.current.getFullYear());
|
|
2133
2389
|
dayControl.setValue(today.current.getDate());
|
|
2134
2390
|
monthControl.setValue(today.current.getMonth());
|
|
2135
2391
|
formControl?.setValue(today.current);
|
|
2136
|
-
onListener
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
}, [today.current, formControl, onListener]);
|
|
2392
|
+
onListener?.({
|
|
2393
|
+
event: components.PickerListenerEvent.Now,
|
|
2394
|
+
value: today.current
|
|
2395
|
+
});
|
|
2396
|
+
}, [formControl, onListener]);
|
|
2142
2397
|
const onSelect = require$$0.useCallback(() => {
|
|
2143
2398
|
formControl?.setValue(value);
|
|
2144
|
-
onListener
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
});
|
|
2399
|
+
onListener?.({
|
|
2400
|
+
event: components.PickerListenerEvent.Select,
|
|
2401
|
+
value
|
|
2402
|
+
});
|
|
2149
2403
|
}, [formControl, value, onListener]);
|
|
2150
2404
|
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 }) })] }) }))] }));
|
|
2151
2405
|
}
|
|
2152
2406
|
|
|
2153
|
-
function RlsFieldDate({ children, date, disabled, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value:
|
|
2407
|
+
function RlsFieldDate({ children, date, disabled: disabledProps, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
|
|
2154
2408
|
const today = require$$0.useRef(new Date()); // Initial current date in component
|
|
2155
|
-
const [value, setValue] = require$$0.useState(formControl?.value ??
|
|
2409
|
+
const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
|
|
2156
2410
|
const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
|
|
2157
|
-
const
|
|
2158
|
-
return formControl?.disabled ||
|
|
2159
|
-
}, [formControl?.disabled,
|
|
2411
|
+
const disabled = require$$0.useMemo(() => {
|
|
2412
|
+
return formControl?.disabled || disabledProps;
|
|
2413
|
+
}, [formControl?.disabled, disabledProps]);
|
|
2160
2414
|
const className = require$$0.useMemo(() => {
|
|
2161
2415
|
return renderClassStatus('rls-field-box', {
|
|
2162
|
-
disabled
|
|
2416
|
+
disabled,
|
|
2163
2417
|
readonly: readOnly
|
|
2164
2418
|
});
|
|
2165
|
-
}, [
|
|
2166
|
-
const
|
|
2419
|
+
}, [disabled, readOnly]);
|
|
2420
|
+
const dateValue = require$$0.useMemo(() => {
|
|
2421
|
+
return formControl ? formControl.value : value;
|
|
2422
|
+
}, [formControl?.value, value]);
|
|
2423
|
+
const status = require$$0.useMemo(() => {
|
|
2167
2424
|
return {
|
|
2168
|
-
icon:
|
|
2169
|
-
|
|
2425
|
+
icon: dateValue ? 'trash-2' : 'calendar',
|
|
2426
|
+
label: dateValue
|
|
2427
|
+
? dates.dateFormatTemplate(dateValue, format || DATE_FORMAT)
|
|
2428
|
+
: ''
|
|
2170
2429
|
};
|
|
2171
|
-
}, [
|
|
2430
|
+
}, [dateValue, format]);
|
|
2172
2431
|
require$$0.useEffect(() => {
|
|
2173
|
-
const
|
|
2432
|
+
const dateSecure = components.verifyDateRange({
|
|
2174
2433
|
date: formControl?.value ?? date ?? today.current,
|
|
2175
2434
|
minDate,
|
|
2176
2435
|
maxDate
|
|
2177
2436
|
});
|
|
2178
|
-
setValue(
|
|
2179
|
-
formControl?.setValue(
|
|
2437
|
+
setValue(dateSecure);
|
|
2438
|
+
formControl?.setValue(dateSecure);
|
|
2180
2439
|
}, []);
|
|
2181
2440
|
const onClickInput = require$$0.useCallback(() => {
|
|
2182
2441
|
!readOnly && setModalIsVisible(true);
|
|
2183
2442
|
}, [readOnly]);
|
|
2184
2443
|
const onChange = require$$0.useCallback((value) => {
|
|
2185
2444
|
setValue(value);
|
|
2186
|
-
onValue
|
|
2445
|
+
onValue?.(value);
|
|
2187
2446
|
}, [onValue]);
|
|
2188
2447
|
const onClickAction = require$$0.useCallback(() => {
|
|
2189
|
-
if (
|
|
2190
|
-
formControl?.setValue(
|
|
2448
|
+
if (dateValue) {
|
|
2449
|
+
formControl?.setValue(valueInitial);
|
|
2191
2450
|
formControl?.touch();
|
|
2192
|
-
onChange(
|
|
2451
|
+
onChange(valueInitial);
|
|
2193
2452
|
}
|
|
2194
2453
|
else {
|
|
2195
2454
|
setModalIsVisible(true);
|
|
2196
2455
|
}
|
|
2197
|
-
}, [
|
|
2456
|
+
}, [dateValue, formControl, valueInitial, onChange]);
|
|
2198
2457
|
const onListener = require$$0.useCallback(({ event, value }) => {
|
|
2199
2458
|
event !== components.PickerListenerEvent.Cancel && onChange(value);
|
|
2200
2459
|
formControl?.touch();
|
|
2201
2460
|
setModalIsVisible(false);
|
|
2202
2461
|
}, [formControl, onChange]);
|
|
2203
|
-
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:
|
|
2462
|
+
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 }) })] }));
|
|
2204
2463
|
}
|
|
2205
2464
|
|
|
2206
2465
|
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
@@ -2209,8 +2468,8 @@ function rangeFormatTemplate({ maxDate, minDate }) {
|
|
|
2209
2468
|
return `${minFormat} - ${maxFormat}`;
|
|
2210
2469
|
}
|
|
2211
2470
|
|
|
2212
|
-
function RlsPickerDateRange({ automatic, date:
|
|
2213
|
-
const _date = require$$0.useMemo(() => dates.normalizeMinTime(
|
|
2471
|
+
function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
2472
|
+
const _date = require$$0.useMemo(() => dates.normalizeMinTime(datePicker ?? new Date()), [datePicker]);
|
|
2214
2473
|
const _range = require$$0.useMemo(() => formControl?.value ?? dates.DateRange.now(), [formControl?.value]);
|
|
2215
2474
|
const yearControl = reactForms.useReactControl(_date.getFullYear());
|
|
2216
2475
|
const monthControl = reactForms.useReactControl(_date.getMonth());
|
|
@@ -2275,48 +2534,51 @@ function RlsPickerDateRange({ automatic, date: _picker, disabled, formControl, m
|
|
|
2275
2534
|
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 }) })] }) })] }));
|
|
2276
2535
|
}
|
|
2277
2536
|
|
|
2278
|
-
function RlsFieldDateRange({ children, date
|
|
2279
|
-
const currentDate = require$$0.useMemo(() =>
|
|
2280
|
-
const [value, setValue] = require$$0.useState(formControl?.value ||
|
|
2537
|
+
function RlsFieldDateRange({ children, date, disabled: disabledProps, formControl, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
|
|
2538
|
+
const currentDate = require$$0.useMemo(() => date ?? new Date(), [date]);
|
|
2539
|
+
const [value, setValue] = require$$0.useState(formControl?.value || valueInitial);
|
|
2281
2540
|
const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
|
|
2282
|
-
const
|
|
2283
|
-
return formControl?.disabled ||
|
|
2284
|
-
}, [formControl?.disabled,
|
|
2541
|
+
const disabled = require$$0.useMemo(() => {
|
|
2542
|
+
return formControl?.disabled || disabledProps;
|
|
2543
|
+
}, [formControl?.disabled, disabledProps]);
|
|
2285
2544
|
const className = require$$0.useMemo(() => {
|
|
2286
2545
|
return renderClassStatus('rls-field-box', {
|
|
2287
|
-
disabled
|
|
2546
|
+
disabled,
|
|
2288
2547
|
readonly: readOnly
|
|
2289
2548
|
});
|
|
2290
|
-
}, [
|
|
2291
|
-
const
|
|
2549
|
+
}, [disabled, readOnly]);
|
|
2550
|
+
const dateRangeValue = require$$0.useMemo(() => {
|
|
2551
|
+
return formControl ? formControl.value : value;
|
|
2552
|
+
}, [formControl?.value, value]);
|
|
2553
|
+
const status = require$$0.useMemo(() => {
|
|
2292
2554
|
return {
|
|
2293
|
-
icon:
|
|
2294
|
-
valueInput:
|
|
2555
|
+
icon: dateRangeValue ? 'trash-2' : 'calendar',
|
|
2556
|
+
valueInput: dateRangeValue ? rangeFormatTemplate(dateRangeValue) : ''
|
|
2295
2557
|
};
|
|
2296
|
-
}, [
|
|
2558
|
+
}, [dateRangeValue]);
|
|
2297
2559
|
const onClickInput = require$$0.useCallback(() => {
|
|
2298
2560
|
!readOnly && setModalIsVisible(true);
|
|
2299
2561
|
}, [readOnly]);
|
|
2300
2562
|
const onChange = require$$0.useCallback((value) => {
|
|
2301
2563
|
setValue(value);
|
|
2302
|
-
onValue
|
|
2564
|
+
onValue?.(value);
|
|
2303
2565
|
}, [onValue]);
|
|
2304
2566
|
const onClickAction = require$$0.useCallback(() => {
|
|
2305
|
-
if (
|
|
2306
|
-
formControl?.setValue(
|
|
2567
|
+
if (dateRangeValue) {
|
|
2568
|
+
formControl?.setValue(valueInitial);
|
|
2307
2569
|
formControl?.touch();
|
|
2308
|
-
onChange(
|
|
2570
|
+
onChange(valueInitial);
|
|
2309
2571
|
}
|
|
2310
2572
|
else {
|
|
2311
2573
|
setModalIsVisible(true);
|
|
2312
2574
|
}
|
|
2313
|
-
}, [
|
|
2575
|
+
}, [dateRangeValue, formControl, valueInitial, onChange]);
|
|
2314
2576
|
const onListener = require$$0.useCallback(({ event, value }) => {
|
|
2315
2577
|
event !== components.PickerListenerEvent.Cancel && onChange(value);
|
|
2316
2578
|
formControl?.touch();
|
|
2317
2579
|
setModalIsVisible(false);
|
|
2318
2580
|
}, [formControl, onChange]);
|
|
2319
|
-
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:
|
|
2581
|
+
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 }) })] }));
|
|
2320
2582
|
}
|
|
2321
2583
|
|
|
2322
2584
|
function useFieldSelect(props) {
|
|
@@ -3045,6 +3307,7 @@ exports.RlsDatatableTitle = RlsDatatableTitle;
|
|
|
3045
3307
|
exports.RlsDatatableTotals = RlsDatatableTotals;
|
|
3046
3308
|
exports.RlsFieldAutocomplete = RlsFieldAutocomplete;
|
|
3047
3309
|
exports.RlsFieldAutocompleteTemplate = RlsFieldAutocompleteTemplate;
|
|
3310
|
+
exports.RlsFieldClock = RlsFieldClock;
|
|
3048
3311
|
exports.RlsFieldDate = RlsFieldDate;
|
|
3049
3312
|
exports.RlsFieldDateRange = RlsFieldDateRange;
|
|
3050
3313
|
exports.RlsFieldDecimal = RlsFieldDecimal;
|
|
@@ -3079,6 +3342,7 @@ exports.RlsModal = RlsModal;
|
|
|
3079
3342
|
exports.RlsModalSheet = RlsModalSheet;
|
|
3080
3343
|
exports.RlsNavbar = RlsNavbar;
|
|
3081
3344
|
exports.RlsPagination = RlsPagination;
|
|
3345
|
+
exports.RlsPickerClock = RlsPickerClock;
|
|
3082
3346
|
exports.RlsPickerDate = RlsPickerDate;
|
|
3083
3347
|
exports.RlsPickerDateRange = RlsPickerDateRange;
|
|
3084
3348
|
exports.RlsPickerDay = RlsPickerDay;
|