@skalfa/skalfa-component 1.0.2 → 1.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/accordion/Accordion.component.d.ts +1 -1
- package/dist/breadcrumb/Breadcrumb.component.d.ts +1 -1
- package/dist/button/Button.component.d.ts +1 -1
- package/dist/card/AlertCard.component.d.ts +1 -1
- package/dist/card/Card.component.d.ts +1 -1
- package/dist/card/DashboardCard.component.d.ts +1 -1
- package/dist/card/GalleryCard.component.d.ts +1 -1
- package/dist/card/ProductCard.component.d.ts +1 -1
- package/dist/card/ProfileCard.component.d.ts +1 -1
- package/dist/carousel/Carousel.component.d.ts +1 -1
- package/dist/chip/Chip.component.d.ts +1 -1
- package/dist/input/Checkbox.component.d.ts +1 -1
- package/dist/input/Input.component.d.ts +1 -1
- package/dist/input/InputCheckbox.component.d.ts +1 -1
- package/dist/input/InputCurrency.component.d.ts +1 -1
- package/dist/input/InputDate.component.d.ts +1 -1
- package/dist/input/InputDate.component.js +4 -4
- package/dist/input/InputDatetime.component.d.ts +1 -1
- package/dist/input/InputDocument.component.d.ts +1 -1
- package/dist/input/InputMap.component.d.ts +1 -1
- package/dist/input/InputNumber.component.d.ts +1 -1
- package/dist/input/InputPassword.component.d.ts +1 -1
- package/dist/input/InputRadio.component.d.ts +1 -1
- package/dist/input/InputTime.component.d.ts +1 -1
- package/dist/input/InputValues.component.d.ts +1 -1
- package/dist/input/Radio.component.d.ts +1 -1
- package/dist/input/Select.component.d.ts +1 -1
- package/dist/modal/FloatingPage.component.d.ts +1 -1
- package/dist/modal/Modal.component.d.ts +1 -1
- package/dist/modal/ModalConfirm.component.d.ts +1 -1
- package/dist/modal/Toast.component.d.ts +1 -1
- package/dist/nav/Bottombar.component.d.ts +1 -1
- package/dist/nav/Footer.component.d.ts +1 -1
- package/dist/nav/Headbar.component.d.ts +4 -11
- package/dist/nav/Headbar.component.js +3 -23
- package/dist/nav/Navbar.component.d.ts +1 -1
- package/dist/nav/Sidebar.component.d.ts +2 -2
- package/dist/nav/Tabbar.component.d.ts +1 -1
- package/dist/nav/Wizard.component.d.ts +1 -1
- package/dist/supervision/FormSupervision.component.d.ts +1 -1
- package/dist/supervision/TableSupervision.component.d.ts +1 -1
- package/dist/table/ControlBar.component.d.ts +1 -1
- package/dist/table/FilterComponent.d.ts +2 -2
- package/dist/table/Pagination.component.d.ts +1 -1
- package/dist/table/Table.component.d.ts +1 -1
- package/dist/typography/TypographyArticle.component.d.ts +1 -1
- package/dist/typography/TypographyColumn.component.d.ts +1 -1
- package/dist/typography/TypographyContent.component.d.ts +1 -1
- package/dist/typography/TypographyTips.component.d.ts +1 -1
- package/dist/wrap/Image.component.d.ts +1 -1
- package/dist/wrap/ScrollContainer.component.d.ts +1 -1
- package/dist/wrap/ShortcutProvider.d.ts +1 -1
- package/dist/wrap/Swipe.component.d.ts +1 -1
- package/package.json +2 -2
- package/dist/src/accordion/Accordion.component.d.ts +0 -13
- package/dist/src/accordion/Accordion.component.js +0 -25
- package/dist/src/breadcrumb/Breadcrumb.component.d.ts +0 -14
- package/dist/src/breadcrumb/Breadcrumb.component.js +0 -21
- package/dist/src/button/Button.component.d.ts +0 -21
- package/dist/src/button/Button.component.js +0 -19
- package/dist/src/card/AlertCard.component.d.ts +0 -11
- package/dist/src/card/AlertCard.component.js +0 -9
- package/dist/src/card/Card.component.d.ts +0 -5
- package/dist/src/card/Card.component.js +0 -9
- package/dist/src/card/DashboardCard.component.d.ts +0 -9
- package/dist/src/card/DashboardCard.component.js +0 -13
- package/dist/src/card/GalleryCard.component.d.ts +0 -7
- package/dist/src/card/GalleryCard.component.js +0 -13
- package/dist/src/card/ProductCard.component.d.ts +0 -9
- package/dist/src/card/ProductCard.component.js +0 -13
- package/dist/src/card/ProfileCard.component.d.ts +0 -10
- package/dist/src/card/ProfileCard.component.js +0 -13
- package/dist/src/carousel/Carousel.component.d.ts +0 -13
- package/dist/src/carousel/Carousel.component.js +0 -37
- package/dist/src/chip/Chip.component.d.ts +0 -6
- package/dist/src/chip/Chip.component.js +0 -12
- package/dist/src/index.d.ts +0 -13
- package/dist/src/index.js +0 -29
- package/dist/src/input/Checkbox.component.d.ts +0 -13
- package/dist/src/input/Checkbox.component.js +0 -23
- package/dist/src/input/Input.component.d.ts +0 -23
- package/dist/src/input/Input.component.js +0 -134
- package/dist/src/input/InputCheckbox.component.d.ts +0 -27
- package/dist/src/input/InputCheckbox.component.js +0 -53
- package/dist/src/input/InputCurrency.component.d.ts +0 -21
- package/dist/src/input/InputCurrency.component.js +0 -30
- package/dist/src/input/InputDate.component.d.ts +0 -24
- package/dist/src/input/InputDate.component.js +0 -107
- package/dist/src/input/InputDatetime.component.d.ts +0 -17
- package/dist/src/input/InputDatetime.component.js +0 -75
- package/dist/src/input/InputDocument.component.d.ts +0 -22
- package/dist/src/input/InputDocument.component.js +0 -88
- package/dist/src/input/InputImage.component.d.ts +0 -23
- package/dist/src/input/InputImage.component.js +0 -260
- package/dist/src/input/InputMap.component.d.ts +0 -25
- package/dist/src/input/InputMap.component.js +0 -101
- package/dist/src/input/InputNumber.component.d.ts +0 -19
- package/dist/src/input/InputNumber.component.js +0 -40
- package/dist/src/input/InputOtp.component.d.ts +0 -14
- package/dist/src/input/InputOtp.component.js +0 -65
- package/dist/src/input/InputPassword.component.d.ts +0 -17
- package/dist/src/input/InputPassword.component.js +0 -59
- package/dist/src/input/InputRadio.component.d.ts +0 -27
- package/dist/src/input/InputRadio.component.js +0 -56
- package/dist/src/input/InputTime.component.d.ts +0 -23
- package/dist/src/input/InputTime.component.js +0 -73
- package/dist/src/input/InputValues.component.d.ts +0 -9
- package/dist/src/input/InputValues.component.js +0 -19
- package/dist/src/input/Radio.component.d.ts +0 -12
- package/dist/src/input/Radio.component.js +0 -22
- package/dist/src/input/Select.component.d.ts +0 -47
- package/dist/src/input/Select.component.js +0 -275
- package/dist/src/modal/BottomSheet.component.d.ts +0 -12
- package/dist/src/modal/BottomSheet.component.js +0 -161
- package/dist/src/modal/FloatingPage.component.d.ts +0 -12
- package/dist/src/modal/FloatingPage.component.js +0 -27
- package/dist/src/modal/Modal.component.d.ts +0 -12
- package/dist/src/modal/Modal.component.js +0 -27
- package/dist/src/modal/ModalConfirm.component.d.ts +0 -26
- package/dist/src/modal/ModalConfirm.component.js +0 -68
- package/dist/src/modal/Toast.component.d.ts +0 -11
- package/dist/src/modal/Toast.component.js +0 -58
- package/dist/src/nav/Bottombar.component.d.ts +0 -12
- package/dist/src/nav/Bottombar.component.js +0 -32
- package/dist/src/nav/Footer.component.d.ts +0 -37
- package/dist/src/nav/Footer.component.js +0 -49
- package/dist/src/nav/Headbar.component.d.ts +0 -14
- package/dist/src/nav/Headbar.component.js +0 -32
- package/dist/src/nav/Navbar.component.d.ts +0 -22
- package/dist/src/nav/Navbar.component.js +0 -26
- package/dist/src/nav/Sidebar.component.d.ts +0 -33
- package/dist/src/nav/Sidebar.component.js +0 -87
- package/dist/src/nav/Tabbar.component.d.ts +0 -13
- package/dist/src/nav/Tabbar.component.js +0 -17
- package/dist/src/nav/Wizard.component.d.ts +0 -9
- package/dist/src/nav/Wizard.component.js +0 -24
- package/dist/src/supervision/FormSupervision.component.d.ts +0 -93
- package/dist/src/supervision/FormSupervision.component.js +0 -168
- package/dist/src/supervision/TableSupervision.component.d.ts +0 -78
- package/dist/src/supervision/TableSupervision.component.js +0 -273
- package/dist/src/table/ControlBar.component.d.ts +0 -34
- package/dist/src/table/ControlBar.component.js +0 -205
- package/dist/src/table/FilterComponent.d.ts +0 -45
- package/dist/src/table/FilterComponent.js +0 -132
- package/dist/src/table/Pagination.component.d.ts +0 -8
- package/dist/src/table/Pagination.component.js +0 -32
- package/dist/src/table/Table.component.d.ts +0 -61
- package/dist/src/table/Table.component.js +0 -101
- package/dist/src/typography/TypographyArticle.component.d.ts +0 -8
- package/dist/src/typography/TypographyArticle.component.js +0 -7
- package/dist/src/typography/TypographyColumn.component.d.ts +0 -6
- package/dist/src/typography/TypographyColumn.component.js +0 -7
- package/dist/src/typography/TypographyContent.component.d.ts +0 -6
- package/dist/src/typography/TypographyContent.component.js +0 -7
- package/dist/src/typography/TypographyTips.component.d.ts +0 -6
- package/dist/src/typography/TypographyTips.component.js +0 -7
- package/dist/src/wrap/Draggable.component.d.ts +0 -34
- package/dist/src/wrap/Draggable.component.js +0 -214
- package/dist/src/wrap/Image.component.d.ts +0 -2
- package/dist/src/wrap/Image.component.js +0 -13
- package/dist/src/wrap/OutsideClick.component.d.ts +0 -6
- package/dist/src/wrap/OutsideClick.component.js +0 -34
- package/dist/src/wrap/ScrollContainer.component.d.ts +0 -10
- package/dist/src/wrap/ScrollContainer.component.js +0 -54
- package/dist/src/wrap/ShortcutProvider.d.ts +0 -1
- package/dist/src/wrap/ShortcutProvider.js +0 -42
- package/dist/src/wrap/Swipe.component.d.ts +0 -14
- package/dist/src/wrap/Swipe.component.js +0 -61
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.InputCurrencyComponent = InputCurrencyComponent;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
7
|
-
const _utils_1 = require("@utils");
|
|
8
|
-
function InputCurrencyComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, format, register, unregister, onChange, className = "", ...props }) {
|
|
9
|
-
// =========================>
|
|
10
|
-
// ## Initial
|
|
11
|
-
// =========================>
|
|
12
|
-
const inputHandler = (0, _utils_1.useInputHandler)(props.name, value, validations, register, unregister, false);
|
|
13
|
-
const randomId = (0, _utils_1.useInputRandomId)();
|
|
14
|
-
// =========================>
|
|
15
|
-
// ## Invalid handler
|
|
16
|
-
// =========================>
|
|
17
|
-
const [invalidMessage] = (0, _utils_1.useValidation)(inputHandler.value, validations, invalid, inputHandler.idle);
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "input-container", children: [(0, jsx_runtime_1.jsxs)("label", { htmlFor: randomId, className: (0, _utils_1.cn)("input-label", props.disabled && "input-label-disabled", inputHandler.focus && "input-label-focus", !!invalidMessage && "input-label-error", (0, _utils_1.pcn)(className, "label"), props.disabled && (0, _utils_1.pcn)(className, "label", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "label", "focus"), !!invalidMessage && (0, _utils_1.pcn)(className, "label", "focus")), children: [label, validations && _utils_1.validation.hasRules(validations, "required") && (0, jsx_runtime_1.jsx)("span", { className: "text-danger ml-1", children: "*" })] }), tip && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-tip", props.disabled && "input-tip-disabled", (0, _utils_1.pcn)(className, "tip"), props.disabled && (0, _utils_1.pcn)(className, "tip", "disabled")), children: tip })), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("input", { ...props, id: randomId, className: (0, _utils_1.cn)("input", leftIcon && "input-with-left-icon", rightIcon && "input-with-right-icon", (0, _utils_1.pcn)(className, "input"), !!invalidMessage && "input-error", !!invalidMessage && (0, _utils_1.pcn)(className, "input", "error")), value: inputHandler.value ? _utils_1.conversion.currency(inputHandler.value, format?.locale, format?.currency) : "", onChange: (e) => {
|
|
19
|
-
const val = Number(e.target.value.replace(/[^0-9]/g, ""));
|
|
20
|
-
inputHandler.setValue(val);
|
|
21
|
-
inputHandler.setIdle(false);
|
|
22
|
-
onChange?.(val);
|
|
23
|
-
}, onFocus: (e) => {
|
|
24
|
-
props.onFocus?.(e);
|
|
25
|
-
inputHandler.setFocus(true);
|
|
26
|
-
}, onBlur: (e) => {
|
|
27
|
-
props.onBlur?.(e);
|
|
28
|
-
setTimeout(() => inputHandler.setFocus(false), 100);
|
|
29
|
-
}, autoComplete: "off" }), leftIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-left", props.disabled && "input-icon-disabled", inputHandler.focus && "input-icon-focus", (0, _utils_1.pcn)(className, "icon"), props.disabled && (0, _utils_1.pcn)(className, "icon", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "icon", "focus")), icon: leftIcon })), rightIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-right", props.disabled && "input-icon-disabled", inputHandler.focus && "input-icon-focus", (0, _utils_1.pcn)(className, "icon"), props.disabled && (0, _utils_1.pcn)(className, "icon", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "icon", "focus")), icon: rightIcon }))] }), invalidMessage && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-error-message", (0, _utils_1.pcn)(className, "error")), children: invalidMessage }))] }));
|
|
30
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
-
import { ValidationRules } from "@utils";
|
|
3
|
-
export interface InputDateProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
4
|
-
label?: string;
|
|
5
|
-
tip?: string | ReactNode;
|
|
6
|
-
leftIcon?: any;
|
|
7
|
-
rightIcon?: any;
|
|
8
|
-
value?: string;
|
|
9
|
-
invalid?: string;
|
|
10
|
-
validations?: ValidationRules;
|
|
11
|
-
onChange?: (value: string) => any;
|
|
12
|
-
register?: (name: string, validations?: ValidationRules) => void;
|
|
13
|
-
unregister?: (name: string) => void;
|
|
14
|
-
/** Use custom class with: "label::", "tip::", "error::", "icon::". */
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function InputDateComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className, ...props }: InputDateProps): import("react").JSX.Element;
|
|
18
|
-
export interface InputDatePickerProps {
|
|
19
|
-
onChange?: (date: string) => void;
|
|
20
|
-
minDate?: string;
|
|
21
|
-
maxDate?: string;
|
|
22
|
-
rightElement?: ReactNode;
|
|
23
|
-
}
|
|
24
|
-
export declare const InputDatePickerComponent: React.FC<InputDatePickerProps>;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.InputDatePickerComponent = void 0;
|
|
8
|
-
exports.InputDateComponent = InputDateComponent;
|
|
9
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
-
const react_1 = require("react");
|
|
11
|
-
const moment_1 = __importDefault(require("moment"));
|
|
12
|
-
const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
13
|
-
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
14
|
-
const _utils_1 = require("@utils");
|
|
15
|
-
const _components_1 = require("@components");
|
|
16
|
-
function InputDateComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className = "", ...props }) {
|
|
17
|
-
const { isSm } = (0, _utils_1.useResponsive)();
|
|
18
|
-
// =========================>
|
|
19
|
-
// ## Initial
|
|
20
|
-
// =========================>
|
|
21
|
-
const inputHandler = (0, _utils_1.useInputHandler)(props.name, value, validations, register, unregister, false);
|
|
22
|
-
const randomId = (0, _utils_1.useInputRandomId)();
|
|
23
|
-
// =========================>
|
|
24
|
-
// ## Invalid handler
|
|
25
|
-
// =========================>
|
|
26
|
-
const [invalidMessage] = (0, _utils_1.useValidation)(inputHandler.value, validations, invalid, inputHandler.idle);
|
|
27
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "input-container", children: [(0, jsx_runtime_1.jsxs)("label", { htmlFor: randomId, className: (0, _utils_1.cn)("input-label", props.disabled && "input-label-disabled", inputHandler.focus && "input-label-focus", !!invalidMessage && "input-label-error", (0, _utils_1.pcn)(className, "label"), props.disabled && (0, _utils_1.pcn)(className, "label", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "label", "focus"), !!invalidMessage && (0, _utils_1.pcn)(className, "label", "error")), children: [label, validations && _utils_1.validation.hasRules(validations, "required") && (0, jsx_runtime_1.jsx)("span", { className: "text-danger ml-1", children: "*" })] }), tip && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-tip", props.disabled && "input-tip-disabled", (0, _utils_1.pcn)(className, "tip"), props.disabled && (0, _utils_1.pcn)(className, "tip", "disabled")), children: tip })), (0, jsx_runtime_1.jsx)(_components_1.OutsideClickComponent, { onOutsideClick: !isSm ? () => inputHandler.setFocus(false) : undefined, children: (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("input", { ...props, id: randomId, className: (0, _utils_1.cn)("input", leftIcon && "input-with-left-icon", rightIcon && "input-with-right-icon", (0, _utils_1.pcn)(className, "input"), !!invalidMessage && "input-error", !!invalidMessage && (0, _utils_1.pcn)(className, "input", "error")), value: inputHandler.value, onChange: (e) => {
|
|
28
|
-
inputHandler.setValue(e.target.value);
|
|
29
|
-
inputHandler.setValue(false);
|
|
30
|
-
onChange?.(e.target.value);
|
|
31
|
-
}, onFocus: (e) => {
|
|
32
|
-
props.onFocus?.(e);
|
|
33
|
-
inputHandler.setFocus(true);
|
|
34
|
-
}, onBlur: (e) => {
|
|
35
|
-
props.onBlur?.(e);
|
|
36
|
-
}, autoComplete: "off", inputMode: isSm ? "none" : undefined }), leftIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-left", props.disabled && "input-icon-disabled", inputHandler.focus && "input-icon-focus", (0, _utils_1.pcn)(className, "icon"), props.disabled && (0, _utils_1.pcn)(className, "icon", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "icon", "focus")), icon: leftIcon })), rightIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-right", props.disabled && "input-icon-disabled", inputHandler.focus && "input-icon-focus", (0, _utils_1.pcn)(className, "icon"), props.disabled && (0, _utils_1.pcn)(className, "icon", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "icon", "focus")), icon: rightIcon })), !isSm && inputHandler.focus && ((0, jsx_runtime_1.jsx)("div", { className: "input-date-picker-popover", children: (0, jsx_runtime_1.jsx)(exports.InputDatePickerComponent, { onChange: (e) => {
|
|
37
|
-
inputHandler.setValue(e);
|
|
38
|
-
onChange?.(e);
|
|
39
|
-
} }) }))] }) }), invalidMessage && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-error-message", (0, _utils_1.pcn)(className, "error")), children: invalidMessage }))] }), isSm && ((0, jsx_runtime_1.jsx)(_components_1.BottomSheetComponent, { show: inputHandler.focus, onClose: () => inputHandler.setFocus(false), size: 380, footer: (0, jsx_runtime_1.jsx)("div", { className: "p-4", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { label: "Selesai", variant: "outline", onClick: () => inputHandler.setFocus(false), block: true }) }), children: (0, jsx_runtime_1.jsx)("div", { className: "p-4", children: (0, jsx_runtime_1.jsx)(exports.InputDatePickerComponent, { onChange: (e) => {
|
|
40
|
-
inputHandler.setValue(e);
|
|
41
|
-
onChange?.(e);
|
|
42
|
-
} }) }) }))] }));
|
|
43
|
-
}
|
|
44
|
-
;
|
|
45
|
-
const InputDatePickerComponent = ({ onChange, minDate, maxDate, rightElement, }) => {
|
|
46
|
-
const activeYearRef = (0, react_1.useRef)(null);
|
|
47
|
-
const containerYearRef = (0, react_1.useRef)(null);
|
|
48
|
-
const [currentDate, setCurrentDate] = (0, react_1.useState)((0, moment_1.default)());
|
|
49
|
-
const [selectedDate, setSelectedDate] = (0, react_1.useState)((0, moment_1.default)());
|
|
50
|
-
const startDate = (0, moment_1.default)(currentDate).startOf("month").startOf("week");
|
|
51
|
-
const endDate = (0, moment_1.default)(currentDate).endOf("month").endOf("week");
|
|
52
|
-
const handlePrevMonth = () => setCurrentDate((0, moment_1.default)(currentDate).subtract(1, "month"));
|
|
53
|
-
const handleNextMonth = () => setCurrentDate((0, moment_1.default)(currentDate).add(1, "month"));
|
|
54
|
-
const handleDateClick = (date) => {
|
|
55
|
-
if ((minDate && date.isBefore((0, moment_1.default)(minDate))) || (maxDate && date.isAfter((0, moment_1.default)(maxDate)))) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
setSelectedDate(date);
|
|
59
|
-
onChange?.(date.format("YYYY-MM-DD"));
|
|
60
|
-
};
|
|
61
|
-
const renderDays = () => {
|
|
62
|
-
const days = [];
|
|
63
|
-
const startDay = (0, moment_1.default)(startDate);
|
|
64
|
-
for (let i = 0; i < 7; i++) {
|
|
65
|
-
days.push((0, jsx_runtime_1.jsx)("div", { className: "text-center font-bold", children: startDay.add(i, "days").format("dd") }, i));
|
|
66
|
-
}
|
|
67
|
-
return days;
|
|
68
|
-
};
|
|
69
|
-
const renderCells = () => {
|
|
70
|
-
const rows = [];
|
|
71
|
-
let days = [];
|
|
72
|
-
const day = (0, moment_1.default)(startDate);
|
|
73
|
-
while (day.isBefore(endDate) || day.isSame(endDate, "day")) {
|
|
74
|
-
for (let i = 0; i < 7; i++) {
|
|
75
|
-
const cloneDay = (0, moment_1.default)(day);
|
|
76
|
-
days.push((0, jsx_runtime_1.jsx)("div", { className: `w-8 aspect-square flex items-center justify-center text-center rounded-lg transition-all
|
|
77
|
-
${day.isSame(currentDate, "month") ? "text-foreground" : "text-light-foreground"}
|
|
78
|
-
${day.isSame(selectedDate, "day") ? "bg-primary text-background" : "hover:bg-light-primary"}
|
|
79
|
-
${day.isSame((0, moment_1.default)(), "day") ? "border !border-primary" : "hover:bg-light-primary"}
|
|
80
|
-
${(minDate && day.isBefore((0, moment_1.default)(minDate))) || (maxDate && day.isAfter((0, moment_1.default)(maxDate))) ? "opacity-10 cursor-not-allowed" : "cursor-pointer"}`, onClick: () => handleDateClick(cloneDay), children: day.format("D") }, day.toString()));
|
|
81
|
-
day.add(1, "day");
|
|
82
|
-
}
|
|
83
|
-
rows.push((0, jsx_runtime_1.jsx)("div", { className: "grid grid-cols-7 gap-1", children: days }, day.toString()));
|
|
84
|
-
days = [];
|
|
85
|
-
}
|
|
86
|
-
return rows;
|
|
87
|
-
};
|
|
88
|
-
const years = (0, react_1.useMemo)(() => {
|
|
89
|
-
const dumpYears = [];
|
|
90
|
-
for (let i = 1945; i <= (0, moment_1.default)().year(); i++) {
|
|
91
|
-
dumpYears.push(i);
|
|
92
|
-
}
|
|
93
|
-
return dumpYears;
|
|
94
|
-
}, []);
|
|
95
|
-
(0, react_1.useEffect)(() => {
|
|
96
|
-
if (activeYearRef.current && containerYearRef.current) {
|
|
97
|
-
containerYearRef.current.scrollTo({
|
|
98
|
-
top: activeYearRef.current.offsetTop - containerYearRef.current.offsetTop,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}, []);
|
|
102
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "w-full flex gap-2 max-h-[260]", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-1/5 overflow-y-auto input-scroll pr-1", ref: containerYearRef, children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col", children: years?.map((item) => {
|
|
103
|
-
const isActive = currentDate?.year() === item;
|
|
104
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { ref: isActive ? activeYearRef : null, className: `py-1 px-2 font-semibold rounded-[6px] cursor-pointer ${isActive && "bg-light-primary"}`, onClick: () => setCurrentDate((0, moment_1.default)().set("year", item)), children: item }, item) }));
|
|
105
|
-
}) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "w-4/5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex justify-between items-center mb-2", children: [(0, jsx_runtime_1.jsx)("button", { onClick: handlePrevMonth, className: "w-8 text-sm aspect-square rounded-full cursor-pointer", children: (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faChevronLeft }) }), (0, jsx_runtime_1.jsx)("h2", { className: "font-semibold", children: currentDate.format("MMMM") }), (0, jsx_runtime_1.jsx)("button", { onClick: handleNextMonth, className: "w-8 text-sm aspect-square rounded-full cursor-pointer", children: (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faChevronRight }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "grid grid-cols-7 gap-1 mb-2", children: renderDays() }), (0, jsx_runtime_1.jsx)("div", { children: renderCells() })] }), rightElement && (0, jsx_runtime_1.jsx)("div", { children: rightElement })] }));
|
|
106
|
-
};
|
|
107
|
-
exports.InputDatePickerComponent = InputDatePickerComponent;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
-
import { ValidationRules } from "@utils";
|
|
3
|
-
export interface InputDateTimeProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
4
|
-
label?: string;
|
|
5
|
-
tip?: string | ReactNode;
|
|
6
|
-
leftIcon?: any;
|
|
7
|
-
rightIcon?: any;
|
|
8
|
-
value?: string;
|
|
9
|
-
invalid?: string;
|
|
10
|
-
validations?: ValidationRules;
|
|
11
|
-
onChange?: (value: string) => any;
|
|
12
|
-
register?: (name: string, validations?: ValidationRules) => void;
|
|
13
|
-
unregister?: (name: string) => void;
|
|
14
|
-
/** Use custom class with: "label::", "tip::", "error::", "icon::", "suggest::", "suggest-item::". */
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function InputDatetimeComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className, ...props }: InputDateTimeProps): import("react").JSX.Element;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.InputDatetimeComponent = InputDatetimeComponent;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
8
|
-
const _utils_1 = require("@utils");
|
|
9
|
-
const _components_1 = require("@components");
|
|
10
|
-
function InputDatetimeComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className = "", ...props }) {
|
|
11
|
-
const { isSm } = (0, _utils_1.useResponsive)();
|
|
12
|
-
const [pickerType, setPickerType] = (0, react_1.useState)("date");
|
|
13
|
-
const [dateValue, setDateValue] = (0, react_1.useState)("");
|
|
14
|
-
const [timeValue, setTimeValue] = (0, react_1.useState)("");
|
|
15
|
-
// =========================>
|
|
16
|
-
// ## Initial
|
|
17
|
-
// =========================>
|
|
18
|
-
const inputHandler = (0, _utils_1.useInputHandler)(props.name, value, validations, register, unregister, false);
|
|
19
|
-
const randomId = (0, _utils_1.useInputRandomId)();
|
|
20
|
-
// =========================>
|
|
21
|
-
// ## Invalid handler
|
|
22
|
-
// =========================>
|
|
23
|
-
const [invalidMessage] = (0, _utils_1.useValidation)(inputHandler.value, validations, invalid, inputHandler.idle);
|
|
24
|
-
// =========================>
|
|
25
|
-
// ## change value handler
|
|
26
|
-
// =========================>
|
|
27
|
-
(0, react_1.useEffect)(() => {
|
|
28
|
-
inputHandler.setValue(value || "");
|
|
29
|
-
value && inputHandler.setValue(false);
|
|
30
|
-
if (value) {
|
|
31
|
-
const [d, t] = value.split(" ");
|
|
32
|
-
setDateValue(d || "");
|
|
33
|
-
setTimeValue(t || "");
|
|
34
|
-
}
|
|
35
|
-
}, [value]);
|
|
36
|
-
const handleChange = (date, time) => {
|
|
37
|
-
const newVal = `${date} ${time}`;
|
|
38
|
-
inputHandler.setValue(newVal.trim());
|
|
39
|
-
onChange?.(newVal.trim());
|
|
40
|
-
};
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "input-container", children: [(0, jsx_runtime_1.jsxs)("label", { htmlFor: randomId, className: (0, _utils_1.cn)("input-label", props.disabled && "input-label-disabled", inputHandler.focus && "input-label-focus", !!invalidMessage && "input-label-error", (0, _utils_1.pcn)(className, "label")), children: [label, validations && _utils_1.validation.hasRules(validations, "required") && (0, jsx_runtime_1.jsx)("span", { className: "text-danger ml-1", children: "*" })] }), tip && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-tip", props.disabled && "input-tip-disabled", (0, _utils_1.pcn)(className, "tip")), children: tip })), (0, jsx_runtime_1.jsx)(_components_1.OutsideClickComponent, { onOutsideClick: !isSm ? () => inputHandler.setFocus(false) : undefined, children: (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("input", { ...props, id: randomId, readOnly: true, className: (0, _utils_1.cn)("input", leftIcon && "input-with-left-icon", rightIcon && "input-with-right-icon", (0, _utils_1.pcn)(className, "input"), !!invalidMessage && "input-error"), value: inputHandler.value, onFocus: (e) => {
|
|
42
|
-
props.onFocus?.(e);
|
|
43
|
-
inputHandler.setFocus(true);
|
|
44
|
-
}, autoComplete: "off", inputMode: isSm ? "none" : undefined }), leftIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-left", props.disabled && "input-icon-disabled", inputHandler.focus && "input-icon-focus", (0, _utils_1.pcn)(className, "icon")), icon: leftIcon })), rightIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-right", props.disabled && "input-icon-disabled", inputHandler.focus && "input-icon-focus", (0, _utils_1.pcn)(className, "icon")), icon: rightIcon })), !isSm && inputHandler.focus && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "input-datetime-picker-popover", children: [(0, jsx_runtime_1.jsx)(_components_1.TabbarComponent, { items: [
|
|
45
|
-
{
|
|
46
|
-
label: "Tanggal",
|
|
47
|
-
value: 'date'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
label: "Jam",
|
|
51
|
-
value: 'time'
|
|
52
|
-
},
|
|
53
|
-
], active: pickerType, onChange: (e) => setPickerType(e), className: "mb-4" }), pickerType === "date" ? ((0, jsx_runtime_1.jsx)(_components_1.InputDatePickerComponent, { onChange: (e) => {
|
|
54
|
-
setDateValue(e);
|
|
55
|
-
handleChange(e, timeValue);
|
|
56
|
-
} })) : ((0, jsx_runtime_1.jsx)(_components_1.InputTimePickerComponent, { onChange: (e) => {
|
|
57
|
-
setTimeValue(e);
|
|
58
|
-
handleChange(dateValue, e);
|
|
59
|
-
} }))] }) }))] }) }), invalidMessage && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-error-message", (0, _utils_1.pcn)(className, "error")), children: invalidMessage }))] }), isSm && ((0, jsx_runtime_1.jsx)(_components_1.BottomSheetComponent, { show: inputHandler.focus, onClose: () => inputHandler.setFocus(false), size: 430, footer: (0, jsx_runtime_1.jsx)("div", { className: "p-4", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { label: "Selesai", variant: "outline", onClick: () => inputHandler.setFocus(false), block: true }) }), children: (0, jsx_runtime_1.jsxs)("div", { className: "p-4", children: [(0, jsx_runtime_1.jsx)(_components_1.TabbarComponent, { items: [
|
|
60
|
-
{
|
|
61
|
-
label: "Tanggal",
|
|
62
|
-
value: 'date'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: "Jam",
|
|
66
|
-
value: 'time'
|
|
67
|
-
},
|
|
68
|
-
], active: pickerType, onChange: (e) => setPickerType(e), className: "mb-4" }), pickerType === "date" ? ((0, jsx_runtime_1.jsx)(_components_1.InputDatePickerComponent, { onChange: (e) => {
|
|
69
|
-
setDateValue(e);
|
|
70
|
-
handleChange(e, timeValue);
|
|
71
|
-
} })) : ((0, jsx_runtime_1.jsx)(_components_1.InputTimePickerComponent, { onChange: (e) => {
|
|
72
|
-
setTimeValue(e);
|
|
73
|
-
handleChange(dateValue, e);
|
|
74
|
-
} }))] }) }))] }));
|
|
75
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
-
import { ValidationRules } from "@utils";
|
|
3
|
-
export interface InputDocumentProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
4
|
-
label?: string;
|
|
5
|
-
tip?: string | ReactNode;
|
|
6
|
-
leftIcon?: any;
|
|
7
|
-
rightIcon?: any;
|
|
8
|
-
value?: any;
|
|
9
|
-
invalid?: string;
|
|
10
|
-
validations?: ValidationRules;
|
|
11
|
-
onChange?: (value: any) => any;
|
|
12
|
-
register?: (name: string, validations?: ValidationRules) => void;
|
|
13
|
-
unregister?: (name: string) => void;
|
|
14
|
-
/** Use custom class with: "label::", "tip::", "error::", "icon::", "suggest::", "suggest-item::". */
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function InputDocumentComponent({ label, tip, leftIcon, rightIcon, className, value, invalid, validations, register, unregister, onChange, ...props }: InputDocumentProps): import("react").JSX.Element;
|
|
18
|
-
export interface InputDocumentPickerProps {
|
|
19
|
-
value?: any[];
|
|
20
|
-
onChange?: (value: any[]) => void;
|
|
21
|
-
}
|
|
22
|
-
export declare const InputDocumentPicker: React.FC<InputDocumentPickerProps>;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.InputDocumentPicker = void 0;
|
|
5
|
-
exports.InputDocumentComponent = InputDocumentComponent;
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
9
|
-
const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
10
|
-
const _utils_1 = require("@utils");
|
|
11
|
-
const _components_1 = require("@components");
|
|
12
|
-
const DocumentViewerComponent = (props) => {
|
|
13
|
-
const Comp = _utils_1.registry.get("DocumentViewerComponent");
|
|
14
|
-
return Comp ? (0, jsx_runtime_1.jsx)(Comp, { ...props }) : null;
|
|
15
|
-
};
|
|
16
|
-
const DocumentViewerIcon = (ext) => {
|
|
17
|
-
const getIcon = _utils_1.registry.get("DocumentViewerIcon");
|
|
18
|
-
return getIcon ? getIcon(ext) : null;
|
|
19
|
-
};
|
|
20
|
-
function InputDocumentComponent({ label, tip, leftIcon, rightIcon, className = "", value, invalid, validations, register, unregister, onChange, ...props }) {
|
|
21
|
-
const { isSm } = (0, _utils_1.useResponsive)();
|
|
22
|
-
// =========================>
|
|
23
|
-
// ## Initial
|
|
24
|
-
// =========================>
|
|
25
|
-
const inputHandler = (0, _utils_1.useInputHandler)(props.name, value, validations, register, unregister, props.type == "file");
|
|
26
|
-
const randomId = (0, _utils_1.useInputRandomId)();
|
|
27
|
-
// =========================>
|
|
28
|
-
// ## Invalid handler
|
|
29
|
-
// =========================>
|
|
30
|
-
const [invalidMessage] = (0, _utils_1.useValidation)(inputHandler.value, validations, invalid, inputHandler.idle);
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "input-container", children: [(0, jsx_runtime_1.jsxs)("label", { htmlFor: randomId, className: (0, _utils_1.cn)("input-label", props.disabled && "input-label-disabled", inputHandler.focus && "input-label-focus", !!invalidMessage && "input-label-error", (0, _utils_1.pcn)(className, "label"), props.disabled && (0, _utils_1.pcn)(className, "label", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "label", "focus"), !!invalidMessage && (0, _utils_1.pcn)(className, "label", "focus")), children: [label, validations && _utils_1.validation.hasRules(validations, "required") && (0, jsx_runtime_1.jsx)("span", { className: "text-danger ml-1", children: "*" })] }), tip && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-tip", props.disabled && "input-tip-disabled", (0, _utils_1.pcn)(className, "tip"), props.disabled && (0, _utils_1.pcn)(className, "tip", "disabled")), children: tip })), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("input", { ...props, id: randomId, placeholder: !inputHandler.value ? props.placeholder : "", className: (0, _utils_1.cn)("input cursor-pointer", props.type == "file" && "input-file", leftIcon && "input-with-left-icon", rightIcon && "input-with-right-icon", (0, _utils_1.pcn)(className, "base"), !!invalidMessage && "input-error", !!invalidMessage && (0, _utils_1.pcn)(className, "base", "error")), onFocus: (e) => {
|
|
32
|
-
props.onFocus?.(e);
|
|
33
|
-
inputHandler.setFocus(true);
|
|
34
|
-
}, inputMode: "none" }), (inputHandler.value) && ((0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("input-document-values", leftIcon ? "input-document-values-left-icon" : "input-document-values-no-icon"), style: { maxWidth: `calc(100% - ${leftIcon ? "5.2rem" : "2rem"})` }, onClick: () => {
|
|
35
|
-
inputHandler.setFocus(true);
|
|
36
|
-
}, children: (Array.isArray(inputHandler.value) ? inputHandler.value : []).map((f) => {
|
|
37
|
-
return ((0, jsx_runtime_1.jsxs)("span", { className: "input-document-value-item", children: [(0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: DocumentViewerIcon(f.file.name.split(".").pop()?.toLowerCase()), className: "text-light-foreground" }), (0, jsx_runtime_1.jsx)("span", { className: "line-clamp-1", children: f.file.name })] }, f.id));
|
|
38
|
-
}) })), leftIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-left", props.disabled && "input-icon-disabled", inputHandler.focus && "input-icon-focus", (0, _utils_1.pcn)(className, "icon"), props.disabled && (0, _utils_1.pcn)(className, "icon", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "icon", "focus")), icon: leftIcon })), rightIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-right", props.disabled && "input-icon-disabled", inputHandler.focus && "input-icon-focus", (0, _utils_1.pcn)(className, "icon"), props.disabled && (0, _utils_1.pcn)(className, "icon", "disabled"), inputHandler.focus && (0, _utils_1.pcn)(className, "icon", "focus")), icon: rightIcon }))] }), invalidMessage && (0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-error-message", (0, _utils_1.pcn)(className, "error")), children: invalidMessage })] }), !isSm ? ((0, jsx_runtime_1.jsx)(_components_1.FloatingPageComponent, { show: inputHandler.focus, onClose: () => inputHandler.setFocus(false), title: label, footer: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { label: "Selesai", variant: "outline", onClick: () => inputHandler.setFocus(false), block: true }), children: (0, jsx_runtime_1.jsx)(exports.InputDocumentPicker, { value: inputHandler.value, onChange: (e) => {
|
|
39
|
-
inputHandler.setValue(e);
|
|
40
|
-
if (inputHandler.idle)
|
|
41
|
-
inputHandler.setIdle(false);
|
|
42
|
-
onChange?.(e);
|
|
43
|
-
} }) })) : ((0, jsx_runtime_1.jsx)(_components_1.BottomSheetComponent, { show: inputHandler.focus, onClose: () => inputHandler.setFocus(false), size: '98vh', footer: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { label: "Selesai", variant: "outline", onClick: () => inputHandler.setFocus(false), block: true }), children: (0, jsx_runtime_1.jsx)(exports.InputDocumentPicker, { value: inputHandler.value, onChange: (e) => {
|
|
44
|
-
inputHandler.setValue(e);
|
|
45
|
-
if (inputHandler.idle)
|
|
46
|
-
inputHandler.setIdle(false);
|
|
47
|
-
onChange?.(e);
|
|
48
|
-
} }) }))] }));
|
|
49
|
-
}
|
|
50
|
-
const InputDocumentPicker = ({ value, onChange }) => {
|
|
51
|
-
const { isSm } = (0, _utils_1.useResponsive)();
|
|
52
|
-
const fileInputRef = (0, react_1.useRef)(null);
|
|
53
|
-
const [previewActive, setPreviewActive] = (0, react_1.useState)(null);
|
|
54
|
-
const files = Array.isArray(value) ? value : [];
|
|
55
|
-
function updateFiles(next) {
|
|
56
|
-
onChange?.(next);
|
|
57
|
-
}
|
|
58
|
-
function handleFilePick(e) {
|
|
59
|
-
const picked = e.target.files;
|
|
60
|
-
if (!picked)
|
|
61
|
-
return;
|
|
62
|
-
const next = [...files];
|
|
63
|
-
Array.from(picked).forEach((f) => {
|
|
64
|
-
const id = Math.random().toString(36).substring(7);
|
|
65
|
-
next.push({
|
|
66
|
-
id,
|
|
67
|
-
file: f,
|
|
68
|
-
url: URL.createObjectURL(f),
|
|
69
|
-
type: f.type,
|
|
70
|
-
});
|
|
71
|
-
if (!previewActive)
|
|
72
|
-
setPreviewActive(id);
|
|
73
|
-
});
|
|
74
|
-
updateFiles(next);
|
|
75
|
-
e.target.value = "";
|
|
76
|
-
}
|
|
77
|
-
function removeFile(id) {
|
|
78
|
-
const next = files.filter((x) => x.id !== id);
|
|
79
|
-
updateFiles(next);
|
|
80
|
-
if (previewActive === id) {
|
|
81
|
-
setPreviewActive(next[0]?.id || null);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "p-4 flex flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "input-document-dropzone", children: files.find((x) => x.id === previewActive)?.file ? ((0, jsx_runtime_1.jsx)(DocumentViewerComponent, { file: files.find((x) => x.id === previewActive)?.file })) : ((0, jsx_runtime_1.jsxs)("div", { className: "input-document-empty-box", onClick: () => fileInputRef.current?.click(), children: [(0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faPlus, className: "text-3xl" }), (0, jsx_runtime_1.jsx)("p", { className: "text-lg", children: "Tambah Dokumen" })] })) }), (0, jsx_runtime_1.jsx)("input", { ref: fileInputRef, type: "file", multiple: true, className: "hidden", onChange: handleFilePick }), (0, jsx_runtime_1.jsx)("div", { className: "input-document-thumbs-container", children: (0, jsx_runtime_1.jsxs)("div", { className: "input-document-thumbs-grid", children: [files.map((f) => {
|
|
85
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("input-document-thumb-wrapper", previewActive === f.id && "input-document-thumb-wrapper-active"), onClick: () => setPreviewActive(f.id), children: [(0, jsx_runtime_1.jsx)(DocumentViewerComponent, { file: f.file, mode: "thumb" }), (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faTimes, onClick: () => removeFile(f.id), variant: "light", paint: "danger", className: "absolute top-2 right-2", size: isSm ? "xs" : "sm" })] }, f.id));
|
|
86
|
-
}), (0, jsx_runtime_1.jsxs)("div", { className: "input-document-upload-box", onClick: () => fileInputRef.current?.click(), children: [(0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faPlus }), (0, jsx_runtime_1.jsx)("p", { className: "text-[10px] text-center", children: "Tambah Dokumen" })] })] }) })] }) }));
|
|
87
|
-
};
|
|
88
|
-
exports.InputDocumentPicker = InputDocumentPicker;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ValidationRules } from "@utils";
|
|
2
|
-
export interface InputImageProps {
|
|
3
|
-
name: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
tip?: string;
|
|
6
|
-
value?: string | File;
|
|
7
|
-
aspect?: string;
|
|
8
|
-
invalid?: string;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
validations?: ValidationRules;
|
|
11
|
-
onChange?: (file?: File | null) => void;
|
|
12
|
-
register?: (name: string, validations?: ValidationRules) => void;
|
|
13
|
-
unregister?: (name: string) => void;
|
|
14
|
-
className?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare const InputImageComponent: React.FC<InputImageProps>;
|
|
17
|
-
interface CropperProps {
|
|
18
|
-
src: string;
|
|
19
|
-
aspect: number;
|
|
20
|
-
onDone?: (file: File) => void;
|
|
21
|
-
}
|
|
22
|
-
export declare const CanvasCropper: React.FC<CropperProps>;
|
|
23
|
-
export {};
|