@rolster/react-components 18.15.1 → 18.15.2
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-xOmRdBnF.css → index-Dbh6DUCn.css} +15 -10
- package/dist/cjs/index.js +1759 -1574
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/assets/{index-xOmRdBnF.css → index-Dbh6DUCn.css} +15 -10
- package/dist/es/index.js +1641 -1456
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/CheckBox/CheckBox.js +2 -2
- package/dist/esm/components/atoms/CheckBox/CheckBox.js.map +1 -1
- package/dist/esm/components/atoms/Input/Input.js +4 -4
- package/dist/esm/components/atoms/InputMoney/InputMoney.js +2 -2
- package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.js +2 -2
- package/dist/esm/components/atoms/InputPassword/InputPassword.js +1 -1
- package/dist/esm/components/atoms/InputText/InputText.js +2 -2
- package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
- package/dist/esm/components/atoms/Switch/Switch.js +2 -2
- package/dist/esm/components/molecules/LabelCheckBox/LabelCheckBox.js +4 -4
- package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js +4 -4
- package/dist/esm/components/molecules/LabelSwitch/LabelSwitch.js +4 -4
- package/dist/esm/components/molecules/Pagination/Pagination.d.ts +7 -19
- package/dist/esm/components/molecules/Pagination/Pagination.js +42 -198
- package/dist/esm/components/molecules/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/molecules/PickerDay/PickerDay.css +5 -3
- package/dist/esm/components/molecules/PickerDay/PickerDay.js +6 -6
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +4 -4
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +6 -6
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.css +1 -1
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js +16 -16
- package/dist/esm/components/molecules/PickerYear/PickerYear.css +8 -3
- package/dist/esm/components/molecules/PickerYear/PickerYear.js +6 -6
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.d.ts +5 -5
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +14 -14
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js +6 -6
- package/dist/esm/components/organisms/FieldDate/FieldDate.d.ts +3 -2
- package/dist/esm/components/organisms/FieldDate/FieldDate.js +15 -14
- package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +2 -2
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.d.ts +4 -4
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +9 -9
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js +4 -4
- package/dist/esm/components/organisms/PickerDate/PickerDate.css +1 -3
- package/dist/esm/components/organisms/PickerDate/PickerDate.js +23 -23
- package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +13 -13
- package/dist/esm/hooks/ListControlHook.d.ts +1 -1
- package/dist/esm/hooks/ListControlHook.js +23 -23
- package/dist/esm/hooks/ListControlHook.js.map +1 -1
- package/package.json +13 -15
|
@@ -5,8 +5,8 @@ export function RlsCheckBox({ checked, disabled, onClick, rlsTheme }) {
|
|
|
5
5
|
return (_jsx("div", { className: renderClassStatus('rls-checkbox', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: _jsx("div", { className: "rls-checkbox__component" }) }));
|
|
6
6
|
}
|
|
7
7
|
export function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
|
|
8
|
-
return (_jsx(RlsCheckBox, { checked: formControl.
|
|
9
|
-
formControl.
|
|
8
|
+
return (_jsx(RlsCheckBox, { checked: !!formControl.value, disabled: disabled, onClick: () => {
|
|
9
|
+
formControl.setValue(!formControl.value);
|
|
10
10
|
}, rlsTheme: rlsTheme }));
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=CheckBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckBox.js","sourceRoot":"","sources":["../../../../../src/components/atoms/CheckBox/CheckBox.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,gBAAgB,CAAC;AAaxB,MAAM,UAAU,WAAW,CAAC,EAC1B,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACM;IACd,OAAO,CACL,cACE,SAAS,EAAE,iBAAiB,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EACnE,OAAO,EAAE,OAAO,eACL,QAAQ,YAEnB,cAAK,SAAS,EAAC,yBAAyB,GAAO,GAC3C,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EACjC,WAAW,EACX,QAAQ,EACR,QAAQ,EACa;IACrB,OAAO,CACL,KAAC,WAAW,IACV,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CheckBox.js","sourceRoot":"","sources":["../../../../../src/components/atoms/CheckBox/CheckBox.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,gBAAgB,CAAC;AAaxB,MAAM,UAAU,WAAW,CAAC,EAC1B,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACM;IACd,OAAO,CACL,cACE,SAAS,EAAE,iBAAiB,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EACnE,OAAO,EAAE,OAAO,eACL,QAAQ,YAEnB,cAAK,SAAS,EAAC,yBAAyB,GAAO,GAC3C,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EACjC,WAAW,EACX,QAAQ,EACR,QAAQ,EACa;IACrB,OAAO,CACL,KAAC,WAAW,IACV,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,EAC5B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,EAAE;YACZ,WAAW,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,EACD,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -5,10 +5,10 @@ import './Input.css';
|
|
|
5
5
|
export function RlsInput({ children, disabled, formControl, placeholder, type, value, onValue }) {
|
|
6
6
|
const [focused, setFocused] = useState(false);
|
|
7
7
|
function onChange(event) {
|
|
8
|
-
|
|
8
|
+
setValue(type === 'number' ? +event.target.value : event.target.value);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
formControl?.
|
|
10
|
+
function setValue(value) {
|
|
11
|
+
formControl?.setValue(value);
|
|
12
12
|
if (onValue) {
|
|
13
13
|
onValue(value);
|
|
14
14
|
}
|
|
@@ -24,6 +24,6 @@ export function RlsInput({ children, disabled, formControl, placeholder, type, v
|
|
|
24
24
|
return (_jsxs("div", { className: renderClassStatus('rls-input', {
|
|
25
25
|
focused: formControl?.focused || focused,
|
|
26
26
|
disabled: formControl?.disabled || disabled
|
|
27
|
-
}), children: [_jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type || 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.
|
|
27
|
+
}), children: [_jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type || 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.value || value || '' }), _jsx("span", { className: "rls-input__value", children: children })] }));
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=Input.js.map
|
|
@@ -5,7 +5,7 @@ import { RlsInput } from '../Input/Input';
|
|
|
5
5
|
import './InputMoney.css';
|
|
6
6
|
export function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, value, onValue }) {
|
|
7
7
|
const [valueInput, setValueInput] = useState(value || 0);
|
|
8
|
-
function
|
|
8
|
+
function onChange(value) {
|
|
9
9
|
if (!formControl) {
|
|
10
10
|
setValueInput(value);
|
|
11
11
|
}
|
|
@@ -13,6 +13,6 @@ export function RlsInputMoney({ decimals, disabled, formControl, placeholder, sy
|
|
|
13
13
|
onValue(value);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
return (_jsx("div", { className: "rls-input-money", children: _jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue:
|
|
16
|
+
return (_jsx("div", { className: "rls-input-money", children: _jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: _jsx(RlsAmount, { value: formControl?.value || value || valueInput, symbol: symbol, decimals: decimals }) }) }));
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=InputMoney.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputMoney.js","sourceRoot":"","sources":["../../../../../src/components/atoms/InputMoney/InputMoney.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,CAAC;AAY1B,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,WAAW,EACX,MAAM,EACN,KAAK,EACL,OAAO,EACS;IAChB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAEzD,SAAS,
|
|
1
|
+
{"version":3,"file":"InputMoney.js","sourceRoot":"","sources":["../../../../../src/components/atoms/InputMoney/InputMoney.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,CAAC;AAY1B,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,WAAW,EACX,MAAM,EACN,KAAK,EACL,OAAO,EACS;IAChB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAEzD,SAAS,QAAQ,CAAC,KAAa;QAC7B,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,CACL,cAAK,SAAS,EAAC,iBAAiB,YAC9B,KAAC,QAAQ,IACP,WAAW,EAAE,WAAW,EACxB,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,QAAQ,YAEjB,KAAC,SAAS,IACR,KAAK,EAAE,WAAW,EAAE,KAAK,IAAI,KAAK,IAAI,UAAU,EAChD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GAClB,GACO,GACP,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { RlsInput } from '../Input/Input';
|
|
|
4
4
|
import './InputNumber.css';
|
|
5
5
|
export function RlsInputNumber({ disabled, formControl, placeholder, value, onValue }) {
|
|
6
6
|
const [valueInput, setValueInput] = useState(value || 0);
|
|
7
|
-
function
|
|
7
|
+
function onChange(value) {
|
|
8
8
|
if (!formControl) {
|
|
9
9
|
setValueInput(value);
|
|
10
10
|
}
|
|
@@ -12,6 +12,6 @@ export function RlsInputNumber({ disabled, formControl, placeholder, value, onVa
|
|
|
12
12
|
onValue(value);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
return (_jsx("div", { className: "rls-input-number", children: _jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue:
|
|
15
|
+
return (_jsx("div", { className: "rls-input-number", children: _jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value || value || valueInput }) }));
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=InputNumber.js.map
|
|
@@ -5,7 +5,7 @@ import './InputPassword.css';
|
|
|
5
5
|
export function RlsInputPassword({ disabled, formControl, placeholder, type, onValue }) {
|
|
6
6
|
const [focused, setFocused] = useState(false);
|
|
7
7
|
function onChange(event) {
|
|
8
|
-
formControl?.
|
|
8
|
+
formControl?.setValue(event.target.value);
|
|
9
9
|
if (onValue) {
|
|
10
10
|
onValue(event.target.value);
|
|
11
11
|
}
|
|
@@ -4,7 +4,7 @@ import { RlsInput } from '../Input/Input';
|
|
|
4
4
|
import './InputText.css';
|
|
5
5
|
export function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
|
|
6
6
|
const [valueInput, setValueInput] = useState(value || '');
|
|
7
|
-
function
|
|
7
|
+
function onChange(value) {
|
|
8
8
|
if (!formControl) {
|
|
9
9
|
setValueInput(value);
|
|
10
10
|
}
|
|
@@ -12,6 +12,6 @@ export function RlsInputText({ disabled, formControl, placeholder, value, onValu
|
|
|
12
12
|
onValue(value);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
return (_jsx("div", { className: "rls-input-text", children: _jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue:
|
|
15
|
+
return (_jsx("div", { className: "rls-input-text", children: _jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value || value || valueInput }) }));
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=InputText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputText.js","sourceRoot":"","sources":["../../../../../src/components/atoms/InputText/InputText.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,iBAAiB,CAAC;AAUzB,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,WAAW,EACX,WAAW,EACX,KAAK,EACL,OAAO,EACQ;IACf,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAE1D,SAAS,
|
|
1
|
+
{"version":3,"file":"InputText.js","sourceRoot":"","sources":["../../../../../src/components/atoms/InputText/InputText.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,iBAAiB,CAAC;AAUzB,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,WAAW,EACX,WAAW,EACX,KAAK,EACL,OAAO,EACQ;IACf,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAE1D,SAAS,QAAQ,CAAC,KAAa;QAC7B,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,CACL,cAAK,SAAS,EAAC,gBAAgB,YAC7B,KAAC,QAAQ,IACP,WAAW,EAAE,WAAW,EACxB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,QAAQ,YAEhB,WAAW,EAAE,KAAK,IAAI,KAAK,IAAI,UAAU,GACjC,GACP,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -5,8 +5,8 @@ export function RlsSwitch({ checked, disabled, rlsTheme, onClick }) {
|
|
|
5
5
|
return (_jsx("div", { className: renderClassStatus('rls-switch', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: _jsxs("div", { className: "rls-switch__component", children: [_jsx("div", { className: "rls-switch__component__element" }), _jsx("div", { className: "rls-switch__component__bar" })] }) }));
|
|
6
6
|
}
|
|
7
7
|
export function RlsSwitchControl({ formControl, disabled, rlsTheme }) {
|
|
8
|
-
return (_jsx(RlsSwitch, { checked: formControl.
|
|
9
|
-
formControl.
|
|
8
|
+
return (_jsx(RlsSwitch, { checked: formControl.value || false, disabled: disabled, onClick: () => {
|
|
9
|
+
formControl.setValue(!formControl.value);
|
|
10
10
|
}, rlsTheme: rlsTheme }));
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=Switch.js.map
|
|
@@ -4,13 +4,13 @@ import { renderClassStatus } from '../../../helpers/css';
|
|
|
4
4
|
import { RlsCheckBox } from '../../atoms';
|
|
5
5
|
import './LabelCheckBox.css';
|
|
6
6
|
export function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme }) {
|
|
7
|
-
const [checked, setChecked] = useState(!!formControl?.
|
|
7
|
+
const [checked, setChecked] = useState(!!formControl?.value);
|
|
8
8
|
useEffect(() => {
|
|
9
|
-
setChecked(!!formControl?.
|
|
10
|
-
}, [formControl?.
|
|
9
|
+
setChecked(!!formControl?.value);
|
|
10
|
+
}, [formControl?.value]);
|
|
11
11
|
function onToggle() {
|
|
12
12
|
if (formControl) {
|
|
13
|
-
formControl?.
|
|
13
|
+
formControl?.setValue(!formControl.value);
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
16
|
setChecked(!checked);
|
|
@@ -4,13 +4,13 @@ import { renderClassStatus } from '../../../helpers/css';
|
|
|
4
4
|
import { RlsRadioButton } from '../../atoms';
|
|
5
5
|
import './LabelRadioButton.css';
|
|
6
6
|
export function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsTheme, value }) {
|
|
7
|
-
const [checked, setChecked] = useState(formControl?.
|
|
7
|
+
const [checked, setChecked] = useState(formControl?.value === value);
|
|
8
8
|
useEffect(() => {
|
|
9
|
-
setChecked(formControl?.
|
|
10
|
-
}, [formControl?.
|
|
9
|
+
setChecked(formControl?.value === value);
|
|
10
|
+
}, [formControl?.value]);
|
|
11
11
|
function onSelect() {
|
|
12
12
|
if (formControl) {
|
|
13
|
-
formControl?.
|
|
13
|
+
formControl?.setValue(value);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
return (_jsxs("div", { className: renderClassStatus('rls-label-radiobutton', {
|
|
@@ -4,13 +4,13 @@ import { renderClassStatus } from '../../../helpers/css';
|
|
|
4
4
|
import { RlsSwitch } from '../../atoms';
|
|
5
5
|
import './LabelSwitch.css';
|
|
6
6
|
export function RlsLabelSwitch({ children, disabled, extended, formControl, rlsTheme }) {
|
|
7
|
-
const [checked, setChecked] = useState(!!formControl?.
|
|
7
|
+
const [checked, setChecked] = useState(!!formControl?.value);
|
|
8
8
|
useEffect(() => {
|
|
9
|
-
setChecked(!!formControl?.
|
|
10
|
-
}, [formControl?.
|
|
9
|
+
setChecked(!!formControl?.value);
|
|
10
|
+
}, [formControl?.value]);
|
|
11
11
|
function onToggle() {
|
|
12
12
|
if (formControl) {
|
|
13
|
-
formControl?.
|
|
13
|
+
formControl?.setValue(!formControl.value);
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
16
|
setChecked(!checked);
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
+
import { FilterCriteria } from '@rolster/components';
|
|
1
2
|
import './Pagination.css';
|
|
2
|
-
interface PaginationEvent {
|
|
3
|
+
interface PaginationEvent<T> {
|
|
3
4
|
firstPage: boolean;
|
|
4
5
|
lastPage: boolean;
|
|
6
|
+
suggestions: T[];
|
|
5
7
|
}
|
|
6
8
|
interface PaginationProps<T> {
|
|
7
|
-
|
|
9
|
+
suggestions: T[];
|
|
8
10
|
count?: number;
|
|
9
|
-
filter?:
|
|
10
|
-
|
|
11
|
-
onPagination?: (event: PaginationEvent) => void;
|
|
11
|
+
filter?: FilterCriteria<T>;
|
|
12
|
+
onPagination?: (event: PaginationEvent<T>) => void;
|
|
12
13
|
}
|
|
13
|
-
export
|
|
14
|
-
collection: T[];
|
|
15
|
-
count: number;
|
|
16
|
-
index: number;
|
|
17
|
-
maxPage: number;
|
|
18
|
-
}
|
|
19
|
-
export interface PaginationState {
|
|
20
|
-
active: boolean;
|
|
21
|
-
label: string;
|
|
22
|
-
value: number;
|
|
23
|
-
prev?: PaginationState;
|
|
24
|
-
next?: PaginationState;
|
|
25
|
-
}
|
|
26
|
-
export declare function RlsPagination<T>({ elements, count: defaultCount, filter, onElements, onPagination }: PaginationProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function RlsPagination<T>({ suggestions, count, filter, onPagination }: PaginationProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
27
15
|
export {};
|
|
@@ -1,219 +1,63 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
2
|
+
import { PaginationController } from '@rolster/components';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { renderClassStatus } from '../../../helpers/css';
|
|
5
5
|
import { RlsIcon } from '../../atoms';
|
|
6
6
|
import './Pagination.css';
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const DEFAULT_MAX_VISIBLE = 4;
|
|
11
|
-
export function RlsPagination({ elements, count: defaultCount, filter, onElements, onPagination }) {
|
|
12
|
-
const count = defaultCount || DEFAULT_COUNT_ELEMENT;
|
|
13
|
-
const [collection, setCollection] = useState([]);
|
|
14
|
-
const [index, setIndex] = useState(0);
|
|
15
|
-
const [maxPage, setMaxPage] = useState(calculateMaxPage(elements, count));
|
|
16
|
-
const [paginations, setPaginations] = useState([]);
|
|
17
|
-
const [currentPagination, setCurrentPagination] = useState();
|
|
18
|
-
const [description, setDescription] = useState('');
|
|
19
|
-
const [firstPage, setFirstPage] = useState(true);
|
|
20
|
-
const [lastPage, setLastPage] = useState(false);
|
|
7
|
+
export function RlsPagination({ suggestions, count, filter, onPagination }) {
|
|
8
|
+
const controller = useRef(new PaginationController({ suggestions, count }));
|
|
9
|
+
const [template, setTemplate] = useState(controller.current.template);
|
|
21
10
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
controller.current = new PaginationController({
|
|
12
|
+
suggestions,
|
|
13
|
+
count,
|
|
14
|
+
position: template.currentPage.value
|
|
15
|
+
});
|
|
16
|
+
onPagination &&
|
|
17
|
+
onPagination({
|
|
18
|
+
firstPage: controller.current.template.firstPage,
|
|
19
|
+
lastPage: controller.current.template.lastPage,
|
|
20
|
+
suggestions: controller.current.page.collection
|
|
21
|
+
});
|
|
22
|
+
setTemplate(controller.current.template);
|
|
23
|
+
}, [suggestions, count]);
|
|
24
24
|
useEffect(() => {
|
|
25
|
-
|
|
26
|
-
const isLastPage = currentPagination?.value === maxPage - 1;
|
|
27
|
-
setFirstPage(isFirstPage);
|
|
28
|
-
setLastPage(isLastPage);
|
|
29
|
-
if (onPagination) {
|
|
30
|
-
onPagination({ firstPage: isFirstPage, lastPage: isLastPage });
|
|
31
|
-
}
|
|
32
|
-
}, [currentPagination]);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
refreshFromFilter(filter);
|
|
25
|
+
refreshPagination(controller.current.filtrable(filter));
|
|
35
26
|
}, [filter]);
|
|
36
|
-
function
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
function refreshPagination(pagination) {
|
|
28
|
+
if (pagination) {
|
|
29
|
+
const { page, template } = pagination;
|
|
30
|
+
const { firstPage, lastPage } = template;
|
|
31
|
+
onPagination &&
|
|
32
|
+
onPagination({
|
|
33
|
+
firstPage,
|
|
34
|
+
lastPage,
|
|
35
|
+
suggestions: page.collection
|
|
36
|
+
});
|
|
37
|
+
setTemplate(template);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function goToPagination(page) {
|
|
41
|
+
refreshPagination(controller.current.goToPage(page));
|
|
50
42
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
currentPagination.active = false;
|
|
54
|
-
}
|
|
55
|
-
onSelectPagination(pagination);
|
|
43
|
+
function goFirstPagination() {
|
|
44
|
+
refreshPagination(controller.current.goFirstPage());
|
|
56
45
|
}
|
|
57
46
|
function goPreviousPagination() {
|
|
58
|
-
|
|
59
|
-
const { prev, value } = currentPagination;
|
|
60
|
-
if (prev) {
|
|
61
|
-
onSelectPagination(prev);
|
|
62
|
-
currentPagination.active = false;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
const prevIndex = value - MIN_NUMBER_PAGE;
|
|
66
|
-
if (prevIndex >= FIRST_PAGE) {
|
|
67
|
-
refreshFromChanged(clonePageFromIndex(prevIndex));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function goFirstPagination() {
|
|
73
|
-
if (collection.length) {
|
|
74
|
-
refreshFromChanged(clonePageFromIndex(FIRST_PAGE));
|
|
75
|
-
}
|
|
47
|
+
refreshPagination(controller.current.goPreviousPage());
|
|
76
48
|
}
|
|
77
49
|
function goNextPagination() {
|
|
78
|
-
|
|
79
|
-
const { next, value } = currentPagination;
|
|
80
|
-
if (next) {
|
|
81
|
-
onSelectPagination(next);
|
|
82
|
-
currentPagination.active = false;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
const nextIndex = value + 1;
|
|
86
|
-
if (nextIndex <= maxPage) {
|
|
87
|
-
refreshFromChanged(clonePageFromIndex(nextIndex));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
50
|
+
refreshPagination(controller.current.goNextPage());
|
|
91
51
|
}
|
|
92
52
|
function goLastPagination() {
|
|
93
|
-
|
|
94
|
-
refreshFromChanged(clonePageFromIndex(maxPage - MIN_NUMBER_PAGE));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function createPageCollection(props) {
|
|
98
|
-
const { collection, count, index } = props;
|
|
99
|
-
if (collection.length) {
|
|
100
|
-
const finish = (index + MIN_NUMBER_PAGE) * count;
|
|
101
|
-
const start = index * count;
|
|
102
|
-
return collection.slice(start, finish);
|
|
103
|
-
}
|
|
104
|
-
return [];
|
|
105
|
-
}
|
|
106
|
-
function refreshFromElements(elements) {
|
|
107
|
-
elements.length
|
|
108
|
-
? refreshFromChanged(refreshPage(elements, filter))
|
|
109
|
-
: rebootPagination();
|
|
110
|
-
}
|
|
111
|
-
function refreshFromFilter(filter) {
|
|
112
|
-
refreshFromChanged(refreshPage(elements, filter));
|
|
113
|
-
}
|
|
114
|
-
function refreshFromChanged(page) {
|
|
115
|
-
refreshPaginations(page);
|
|
116
|
-
refreshDescription(page);
|
|
117
|
-
onChangeElements(createPageCollection(page));
|
|
118
|
-
}
|
|
119
|
-
function refreshCollection(elements, filter) {
|
|
120
|
-
const collection = filter
|
|
121
|
-
? elements.filter((element) => hasPattern(JSON.stringify(element), filter))
|
|
122
|
-
: elements;
|
|
123
|
-
setCollection(collection);
|
|
124
|
-
return collection;
|
|
125
|
-
}
|
|
126
|
-
function refreshMaxPage(collection, count) {
|
|
127
|
-
const maxPage = calculateMaxPage(collection, count);
|
|
128
|
-
setMaxPage(maxPage);
|
|
129
|
-
return maxPage;
|
|
130
|
-
}
|
|
131
|
-
function refreshIndex(collection, currentMaxPage) {
|
|
132
|
-
const maxPage = currentMaxPage || refreshMaxPage(collection, count);
|
|
133
|
-
if (index < maxPage || index === FIRST_PAGE) {
|
|
134
|
-
return index;
|
|
135
|
-
}
|
|
136
|
-
const newIndex = maxPage - 1;
|
|
137
|
-
setIndex(newIndex);
|
|
138
|
-
return newIndex;
|
|
139
|
-
}
|
|
140
|
-
function refreshDescription(page) {
|
|
141
|
-
const { collection, count, index } = page;
|
|
142
|
-
const totalCount = elements.length;
|
|
143
|
-
const start = index * count + MIN_NUMBER_PAGE;
|
|
144
|
-
let end = (index + MIN_NUMBER_PAGE) * count;
|
|
145
|
-
if (end > collection.length) {
|
|
146
|
-
end = collection.length;
|
|
147
|
-
}
|
|
148
|
-
setDescription(`${start} - ${end} de ${totalCount}`);
|
|
149
|
-
}
|
|
150
|
-
function refreshPaginations({ index, maxPage }) {
|
|
151
|
-
let maxPageVisible = index + DEFAULT_MAX_VISIBLE;
|
|
152
|
-
if (maxPageVisible > maxPage) {
|
|
153
|
-
maxPageVisible = maxPage;
|
|
154
|
-
}
|
|
155
|
-
let minIndexPage = maxPageVisible - DEFAULT_MAX_VISIBLE;
|
|
156
|
-
if (minIndexPage < 0) {
|
|
157
|
-
minIndexPage = 0;
|
|
158
|
-
}
|
|
159
|
-
if (minIndexPage > index) {
|
|
160
|
-
minIndexPage = index;
|
|
161
|
-
}
|
|
162
|
-
let prevPagination = undefined;
|
|
163
|
-
const paginations = [];
|
|
164
|
-
for (let i = minIndexPage; i < maxPageVisible; i++) {
|
|
165
|
-
const pagination = createPagination(i, index);
|
|
166
|
-
paginations.push(pagination);
|
|
167
|
-
pagination.prev = prevPagination;
|
|
168
|
-
if (prevPagination) {
|
|
169
|
-
prevPagination.next = pagination;
|
|
170
|
-
}
|
|
171
|
-
prevPagination = pagination;
|
|
172
|
-
}
|
|
173
|
-
setPaginations(paginations);
|
|
174
|
-
}
|
|
175
|
-
function clonePage(pagePartial) {
|
|
176
|
-
return {
|
|
177
|
-
collection: pagePartial.collection || collection,
|
|
178
|
-
index: typeof pagePartial.index === 'number' ? pagePartial.index : index,
|
|
179
|
-
count: pagePartial.count || count,
|
|
180
|
-
maxPage: typeof pagePartial.maxPage === 'number' ? pagePartial.maxPage : maxPage
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function clonePageFromIndex(index) {
|
|
184
|
-
return clonePage({ index });
|
|
185
|
-
}
|
|
186
|
-
function refreshPage(elements, filter) {
|
|
187
|
-
const collection = refreshCollection(elements, filter);
|
|
188
|
-
const maxPage = refreshMaxPage(collection, count);
|
|
189
|
-
const index = refreshIndex(collection, maxPage);
|
|
190
|
-
return clonePage({ collection, index, maxPage });
|
|
191
|
-
}
|
|
192
|
-
function createPagination(value, index) {
|
|
193
|
-
const active = value === index;
|
|
194
|
-
const pagination = {
|
|
195
|
-
label: (value + 1).toString(),
|
|
196
|
-
value,
|
|
197
|
-
active
|
|
198
|
-
};
|
|
199
|
-
if (active) {
|
|
200
|
-
setCurrentPagination(pagination);
|
|
201
|
-
}
|
|
202
|
-
return pagination;
|
|
203
|
-
}
|
|
204
|
-
function rebootPagination() {
|
|
205
|
-
setCollection([]);
|
|
206
|
-
setMaxPage(0);
|
|
207
|
-
setIndex(0);
|
|
208
|
-
setPaginations([]);
|
|
209
|
-
onChangeElements([]);
|
|
53
|
+
refreshPagination(controller.current.goLastPage());
|
|
210
54
|
}
|
|
211
|
-
return (_jsxs("div", { className: "rls-pagination", children: [_jsxs("div", { className: "rls-pagination__actions", children: [_jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: firstPage, children: _jsx(RlsIcon, { value: "arrowhead-left" }) }), _jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: firstPage, children: _jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), _jsx("div", { className: "rls-pagination__pages", children:
|
|
55
|
+
return (_jsxs("div", { className: "rls-pagination", children: [_jsxs("div", { className: "rls-pagination__actions", children: [_jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: template.firstPage, children: _jsx(RlsIcon, { value: "arrowhead-left" }) }), _jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: template.firstPage, children: _jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), _jsx("div", { className: "rls-pagination__pages", children: template.pages.map((page, index) => {
|
|
212
56
|
return (_jsx("div", { className: renderClassStatus('rls-pagination__page', {
|
|
213
57
|
active: page.active
|
|
214
58
|
}), onClick: () => {
|
|
215
|
-
|
|
59
|
+
goToPagination(page);
|
|
216
60
|
}, children: page.label }, index));
|
|
217
|
-
}) }), _jsx("div", { className: "rls-pagination__description", children: description }), _jsxs("div", { className: "rls-pagination__actions", children: [_jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: lastPage, children: _jsx(RlsIcon, { value: "arrow-ios-right" }) }), _jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: lastPage, children: _jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
|
|
61
|
+
}) }), _jsx("div", { className: "rls-pagination__description", children: template.description }), _jsxs("div", { className: "rls-pagination__actions", children: [_jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: template.lastPage, children: _jsx(RlsIcon, { value: "arrow-ios-right" }) }), _jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: template.lastPage, children: _jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
|
|
218
62
|
}
|
|
219
63
|
//# sourceMappingURL=Pagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","sourceRoot":"","sources":["../../../../../src/components/molecules/Pagination/Pagination.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Pagination.js","sourceRoot":"","sources":["../../../../../src/components/molecules/Pagination/Pagination.tsx"],"names":[],"mappings":"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"}
|
|
@@ -13,14 +13,15 @@
|
|
|
13
13
|
margin-bottom: var(--rls-sizing-x4);
|
|
14
14
|
background: var(--rls-app-background-100);
|
|
15
15
|
color: var(--rls-app-color-500);
|
|
16
|
-
border-radius: var(--rls-sizing-
|
|
16
|
+
border-radius: var(--rls-sizing-x4);
|
|
17
17
|
}
|
|
18
18
|
.rls-picker-day__label {
|
|
19
19
|
padding: var(--rls-sizing-x6) 0rem;
|
|
20
20
|
text-align: center;
|
|
21
21
|
width: 100%;
|
|
22
|
-
font-size:
|
|
23
|
-
font-weight: var(--rls-font-weight-
|
|
22
|
+
font-size: 5.75rem;
|
|
23
|
+
font-weight: var(--rls-font-weight-semibold);
|
|
24
|
+
letter-spacing: 0.0375em;
|
|
24
25
|
}
|
|
25
26
|
.rls-picker-day__week {
|
|
26
27
|
display: flex;
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
height: var(--rls-sizing-x18);
|
|
41
42
|
line-height: var(--rls-sizing-x18);
|
|
42
43
|
box-sizing: border-box;
|
|
44
|
+
letter-spacing: 0.0475em;
|
|
43
45
|
}
|
|
44
46
|
.rls-picker-day__element__span:not(:hover) {
|
|
45
47
|
color: var(--pvt-span-font-color);
|
|
@@ -8,7 +8,7 @@ import './PickerDay.css';
|
|
|
8
8
|
export function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
|
|
9
9
|
const currentDate = date || new Date(); // Initial date
|
|
10
10
|
const [weeks, setWeeks] = useState([]);
|
|
11
|
-
const [value, setValue] = useState(formControl?.
|
|
11
|
+
const [value, setValue] = useState(formControl?.value || currentDate.getDate());
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
const props = createPickerProps();
|
|
14
14
|
const day = checkDayPicker(props);
|
|
@@ -17,13 +17,13 @@ export function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxD
|
|
|
17
17
|
useEffect(() => {
|
|
18
18
|
const day = checkDayPicker(createPickerProps());
|
|
19
19
|
day
|
|
20
|
-
? formControl?.
|
|
21
|
-
: setValue(formControl?.
|
|
22
|
-
}, [formControl?.
|
|
20
|
+
? formControl?.setValue(day)
|
|
21
|
+
: setValue(formControl?.value || currentDate.getDate());
|
|
22
|
+
}, [formControl?.value]);
|
|
23
23
|
function createPickerProps() {
|
|
24
24
|
return {
|
|
25
25
|
date: currentDate,
|
|
26
|
-
day: formControl?.
|
|
26
|
+
day: formControl?.value || value,
|
|
27
27
|
month: itIsDefined(month) ? month : currentDate.getMonth(),
|
|
28
28
|
year: year || currentDate.getFullYear(),
|
|
29
29
|
minDate,
|
|
@@ -31,7 +31,7 @@ export function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxD
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
function setDayValue(value) {
|
|
34
|
-
formControl ? formControl.
|
|
34
|
+
formControl ? formControl.setValue(value) : setValue(value);
|
|
35
35
|
}
|
|
36
36
|
function onChange(value) {
|
|
37
37
|
setDayValue(value);
|
|
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createDayRangePicker } from '@rolster/components';
|
|
3
3
|
import { DAY_LABELS, DateRange, assignDayInDate, dateFormatTemplate, dateIsBefore, normalizeMinTime } from '@rolster/dates';
|
|
4
4
|
import { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { DATE_RANGE_FORMAT } from '../../../constants';
|
|
6
5
|
import { renderClassStatus } from '../../../helpers/css';
|
|
7
6
|
import './PickerDayRange.css';
|
|
7
|
+
const FORMAT_RANGE = '{dd}/{mx}/{aa}';
|
|
8
8
|
export function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
9
|
-
const currentRange = formControl?.
|
|
9
|
+
const currentRange = formControl?.value || DateRange.now();
|
|
10
10
|
const currentDate = normalizeMinTime(date || currentRange.minDate);
|
|
11
11
|
const sourceDate = useRef(currentRange.minDate);
|
|
12
12
|
const [weeks, setWeeks] = useState([]);
|
|
@@ -27,9 +27,9 @@ export function RlsPickerDayRange({ date, disabled: disabledPicker, formControl,
|
|
|
27
27
|
: new DateRange(date, sourceDate.current);
|
|
28
28
|
sourceDate.current = date;
|
|
29
29
|
setRange(range);
|
|
30
|
-
formControl?.
|
|
30
|
+
formControl?.setValue(range);
|
|
31
31
|
}
|
|
32
|
-
return (_jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [_jsx("div", { className: "rls-picker-day-range__title", children: dateFormatTemplate(sourceDate.current,
|
|
32
|
+
return (_jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [_jsx("div", { className: "rls-picker-day-range__title", children: dateFormatTemplate(sourceDate.current, FORMAT_RANGE) }), _jsx("div", { className: "rls-picker-day-range__header", children: DAY_LABELS().map((title, index) => (_jsx("label", { className: "rls-picker-day-range__label", children: title }, index))) }), _jsx("div", { className: "rls-picker-day-range__component", children: weeks.map(({ days }, index) => (_jsx("div", { className: "rls-picker-day-range__week", children: days.map(({ disabled, end, forbidden, source, ranged, value }, index) => (_jsx("div", { className: renderClassStatus('rls-picker-day-range__element', {
|
|
33
33
|
disabled: disabled || disabledPicker,
|
|
34
34
|
end,
|
|
35
35
|
forbidden,
|