@skalfa/skalfa-component 1.0.0 → 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.
Files changed (188) hide show
  1. package/dist/accordion/Accordion.component.d.ts +1 -1
  2. package/dist/breadcrumb/Breadcrumb.component.d.ts +1 -1
  3. package/dist/button/Button.component.d.ts +1 -1
  4. package/dist/card/AlertCard.component.d.ts +1 -1
  5. package/dist/card/Card.component.d.ts +1 -1
  6. package/dist/card/DashboardCard.component.d.ts +1 -1
  7. package/dist/card/GalleryCard.component.d.ts +1 -1
  8. package/dist/card/ProductCard.component.d.ts +1 -1
  9. package/dist/card/ProfileCard.component.d.ts +1 -1
  10. package/dist/carousel/Carousel.component.d.ts +1 -1
  11. package/dist/chip/Chip.component.d.ts +1 -1
  12. package/dist/index.js +175 -56
  13. package/dist/input/Checkbox.component.d.ts +1 -1
  14. package/dist/input/Input.component.d.ts +1 -1
  15. package/dist/input/InputCheckbox.component.d.ts +1 -1
  16. package/dist/input/InputCheckbox.component.js +2 -2
  17. package/dist/input/InputCurrency.component.d.ts +1 -1
  18. package/dist/input/InputDate.component.d.ts +1 -1
  19. package/dist/input/InputDate.component.js +9 -7
  20. package/dist/input/InputDatetime.component.d.ts +1 -1
  21. package/dist/input/InputDatetime.component.js +13 -8
  22. package/dist/input/InputDocument.component.d.ts +1 -1
  23. package/dist/input/InputDocument.component.js +6 -4
  24. package/dist/input/InputImage.component.js +5 -3
  25. package/dist/input/InputMap.component.d.ts +1 -1
  26. package/dist/input/InputMap.component.js +5 -3
  27. package/dist/input/InputNumber.component.d.ts +1 -1
  28. package/dist/input/InputPassword.component.d.ts +1 -1
  29. package/dist/input/InputRadio.component.d.ts +1 -1
  30. package/dist/input/InputRadio.component.js +2 -2
  31. package/dist/input/InputTime.component.d.ts +1 -1
  32. package/dist/input/InputTime.component.js +5 -3
  33. package/dist/input/InputValues.component.d.ts +1 -1
  34. package/dist/input/Radio.component.d.ts +1 -1
  35. package/dist/input/Select.component.d.ts +1 -1
  36. package/dist/modal/FloatingPage.component.d.ts +1 -1
  37. package/dist/modal/FloatingPage.component.js +2 -2
  38. package/dist/modal/Modal.component.d.ts +1 -1
  39. package/dist/modal/Modal.component.js +2 -2
  40. package/dist/modal/ModalConfirm.component.d.ts +2 -2
  41. package/dist/modal/ModalConfirm.component.js +5 -3
  42. package/dist/modal/Toast.component.d.ts +1 -1
  43. package/dist/modal/Toast.component.js +2 -2
  44. package/dist/nav/Bottombar.component.d.ts +1 -1
  45. package/dist/nav/Footer.component.d.ts +1 -1
  46. package/dist/nav/Headbar.component.d.ts +4 -11
  47. package/dist/nav/Headbar.component.js +3 -22
  48. package/dist/nav/Navbar.component.d.ts +1 -1
  49. package/dist/nav/Navbar.component.js +2 -2
  50. package/dist/nav/Sidebar.component.d.ts +2 -2
  51. package/dist/nav/Tabbar.component.d.ts +1 -1
  52. package/dist/nav/Wizard.component.d.ts +1 -1
  53. package/dist/supervision/FormSupervision.component.d.ts +14 -2
  54. package/dist/supervision/FormSupervision.component.js +32 -17
  55. package/dist/supervision/TableSupervision.component.d.ts +7 -2
  56. package/dist/supervision/TableSupervision.component.js +25 -19
  57. package/dist/table/ControlBar.component.d.ts +2 -2
  58. package/dist/table/ControlBar.component.js +20 -14
  59. package/dist/table/FilterComponent.d.ts +2 -2
  60. package/dist/table/FilterComponent.js +24 -17
  61. package/dist/table/Pagination.component.d.ts +1 -1
  62. package/dist/table/Pagination.component.js +4 -3
  63. package/dist/table/Table.component.d.ts +4 -2
  64. package/dist/table/Table.component.js +11 -7
  65. package/dist/typography/TypographyArticle.component.d.ts +1 -1
  66. package/dist/typography/TypographyColumn.component.d.ts +1 -1
  67. package/dist/typography/TypographyContent.component.d.ts +1 -1
  68. package/dist/typography/TypographyTips.component.d.ts +1 -1
  69. package/dist/wrap/Image.component.d.ts +1 -1
  70. package/dist/wrap/ScrollContainer.component.d.ts +1 -1
  71. package/dist/wrap/ShortcutProvider.d.ts +1 -1
  72. package/dist/wrap/ShortcutProvider.js +2 -2
  73. package/dist/wrap/Swipe.component.d.ts +1 -1
  74. package/package.json +4 -3
  75. package/dist/src/accordion/Accordion.component.d.ts +0 -13
  76. package/dist/src/accordion/Accordion.component.js +0 -25
  77. package/dist/src/breadcrumb/Breadcrumb.component.d.ts +0 -14
  78. package/dist/src/breadcrumb/Breadcrumb.component.js +0 -21
  79. package/dist/src/button/Button.component.d.ts +0 -21
  80. package/dist/src/button/Button.component.js +0 -19
  81. package/dist/src/card/AlertCard.component.d.ts +0 -11
  82. package/dist/src/card/AlertCard.component.js +0 -9
  83. package/dist/src/card/Card.component.d.ts +0 -5
  84. package/dist/src/card/Card.component.js +0 -9
  85. package/dist/src/card/DashboardCard.component.d.ts +0 -9
  86. package/dist/src/card/DashboardCard.component.js +0 -13
  87. package/dist/src/card/GalleryCard.component.d.ts +0 -7
  88. package/dist/src/card/GalleryCard.component.js +0 -13
  89. package/dist/src/card/ProductCard.component.d.ts +0 -9
  90. package/dist/src/card/ProductCard.component.js +0 -13
  91. package/dist/src/card/ProfileCard.component.d.ts +0 -10
  92. package/dist/src/card/ProfileCard.component.js +0 -13
  93. package/dist/src/carousel/Carousel.component.d.ts +0 -13
  94. package/dist/src/carousel/Carousel.component.js +0 -37
  95. package/dist/src/chip/Chip.component.d.ts +0 -6
  96. package/dist/src/chip/Chip.component.js +0 -12
  97. package/dist/src/index.d.ts +0 -13
  98. package/dist/src/index.js +0 -29
  99. package/dist/src/input/Checkbox.component.d.ts +0 -13
  100. package/dist/src/input/Checkbox.component.js +0 -23
  101. package/dist/src/input/Input.component.d.ts +0 -23
  102. package/dist/src/input/Input.component.js +0 -134
  103. package/dist/src/input/InputCheckbox.component.d.ts +0 -27
  104. package/dist/src/input/InputCheckbox.component.js +0 -53
  105. package/dist/src/input/InputCurrency.component.d.ts +0 -21
  106. package/dist/src/input/InputCurrency.component.js +0 -30
  107. package/dist/src/input/InputDate.component.d.ts +0 -24
  108. package/dist/src/input/InputDate.component.js +0 -107
  109. package/dist/src/input/InputDatetime.component.d.ts +0 -17
  110. package/dist/src/input/InputDatetime.component.js +0 -75
  111. package/dist/src/input/InputDocument.component.d.ts +0 -22
  112. package/dist/src/input/InputDocument.component.js +0 -88
  113. package/dist/src/input/InputImage.component.d.ts +0 -23
  114. package/dist/src/input/InputImage.component.js +0 -260
  115. package/dist/src/input/InputMap.component.d.ts +0 -25
  116. package/dist/src/input/InputMap.component.js +0 -101
  117. package/dist/src/input/InputNumber.component.d.ts +0 -19
  118. package/dist/src/input/InputNumber.component.js +0 -40
  119. package/dist/src/input/InputOtp.component.d.ts +0 -14
  120. package/dist/src/input/InputOtp.component.js +0 -65
  121. package/dist/src/input/InputPassword.component.d.ts +0 -17
  122. package/dist/src/input/InputPassword.component.js +0 -59
  123. package/dist/src/input/InputRadio.component.d.ts +0 -27
  124. package/dist/src/input/InputRadio.component.js +0 -56
  125. package/dist/src/input/InputTime.component.d.ts +0 -23
  126. package/dist/src/input/InputTime.component.js +0 -73
  127. package/dist/src/input/InputValues.component.d.ts +0 -9
  128. package/dist/src/input/InputValues.component.js +0 -19
  129. package/dist/src/input/Radio.component.d.ts +0 -12
  130. package/dist/src/input/Radio.component.js +0 -22
  131. package/dist/src/input/Select.component.d.ts +0 -47
  132. package/dist/src/input/Select.component.js +0 -275
  133. package/dist/src/modal/BottomSheet.component.d.ts +0 -12
  134. package/dist/src/modal/BottomSheet.component.js +0 -161
  135. package/dist/src/modal/FloatingPage.component.d.ts +0 -12
  136. package/dist/src/modal/FloatingPage.component.js +0 -27
  137. package/dist/src/modal/Modal.component.d.ts +0 -12
  138. package/dist/src/modal/Modal.component.js +0 -27
  139. package/dist/src/modal/ModalConfirm.component.d.ts +0 -26
  140. package/dist/src/modal/ModalConfirm.component.js +0 -68
  141. package/dist/src/modal/Toast.component.d.ts +0 -11
  142. package/dist/src/modal/Toast.component.js +0 -58
  143. package/dist/src/nav/Bottombar.component.d.ts +0 -12
  144. package/dist/src/nav/Bottombar.component.js +0 -32
  145. package/dist/src/nav/Footer.component.d.ts +0 -37
  146. package/dist/src/nav/Footer.component.js +0 -49
  147. package/dist/src/nav/Headbar.component.d.ts +0 -14
  148. package/dist/src/nav/Headbar.component.js +0 -32
  149. package/dist/src/nav/Navbar.component.d.ts +0 -22
  150. package/dist/src/nav/Navbar.component.js +0 -26
  151. package/dist/src/nav/Sidebar.component.d.ts +0 -33
  152. package/dist/src/nav/Sidebar.component.js +0 -87
  153. package/dist/src/nav/Tabbar.component.d.ts +0 -13
  154. package/dist/src/nav/Tabbar.component.js +0 -17
  155. package/dist/src/nav/Wizard.component.d.ts +0 -9
  156. package/dist/src/nav/Wizard.component.js +0 -24
  157. package/dist/src/supervision/FormSupervision.component.d.ts +0 -93
  158. package/dist/src/supervision/FormSupervision.component.js +0 -168
  159. package/dist/src/supervision/TableSupervision.component.d.ts +0 -78
  160. package/dist/src/supervision/TableSupervision.component.js +0 -273
  161. package/dist/src/table/ControlBar.component.d.ts +0 -34
  162. package/dist/src/table/ControlBar.component.js +0 -205
  163. package/dist/src/table/FilterComponent.d.ts +0 -45
  164. package/dist/src/table/FilterComponent.js +0 -132
  165. package/dist/src/table/Pagination.component.d.ts +0 -8
  166. package/dist/src/table/Pagination.component.js +0 -32
  167. package/dist/src/table/Table.component.d.ts +0 -61
  168. package/dist/src/table/Table.component.js +0 -101
  169. package/dist/src/typography/TypographyArticle.component.d.ts +0 -8
  170. package/dist/src/typography/TypographyArticle.component.js +0 -7
  171. package/dist/src/typography/TypographyColumn.component.d.ts +0 -6
  172. package/dist/src/typography/TypographyColumn.component.js +0 -7
  173. package/dist/src/typography/TypographyContent.component.d.ts +0 -6
  174. package/dist/src/typography/TypographyContent.component.js +0 -7
  175. package/dist/src/typography/TypographyTips.component.d.ts +0 -6
  176. package/dist/src/typography/TypographyTips.component.js +0 -7
  177. package/dist/src/wrap/Draggable.component.d.ts +0 -34
  178. package/dist/src/wrap/Draggable.component.js +0 -214
  179. package/dist/src/wrap/Image.component.d.ts +0 -2
  180. package/dist/src/wrap/Image.component.js +0 -13
  181. package/dist/src/wrap/OutsideClick.component.d.ts +0 -6
  182. package/dist/src/wrap/OutsideClick.component.js +0 -34
  183. package/dist/src/wrap/ScrollContainer.component.d.ts +0 -10
  184. package/dist/src/wrap/ScrollContainer.component.js +0 -54
  185. package/dist/src/wrap/ShortcutProvider.d.ts +0 -1
  186. package/dist/src/wrap/ShortcutProvider.js +0 -42
  187. package/dist/src/wrap/Swipe.component.d.ts +0 -14
  188. package/dist/src/wrap/Swipe.component.js +0 -61
@@ -1,65 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InputOtpComponent = void 0;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const _utils_1 = require("@utils");
8
- const InputOtpComponent = ({ label, tip, name, disabled, value, invalid, length = 6, onChange, className = "", }) => {
9
- const [isFocus, setIsFocus] = (0, react_1.useState)(false);
10
- const inputsRef = (0, react_1.useRef)([]);
11
- const [otp, setOtp] = (0, react_1.useState)((value || "").split("").concat(Array(length).fill("")).slice(0, length));
12
- (0, react_1.useEffect)(() => {
13
- const handleFocusChange = () => {
14
- const anyFocused = inputsRef.current.some((input) => input === document.activeElement);
15
- setIsFocus(anyFocused);
16
- };
17
- window.addEventListener("focusin", handleFocusChange);
18
- window.addEventListener("focusout", handleFocusChange);
19
- return () => {
20
- window.removeEventListener("focusin", handleFocusChange);
21
- window.removeEventListener("focusout", handleFocusChange);
22
- };
23
- }, []);
24
- const emitChange = (newOtp) => {
25
- const val = newOtp.join("");
26
- onChange?.(val);
27
- };
28
- const handleChange = (val, index) => {
29
- if (!/^[0-9]?$/.test(val))
30
- return;
31
- const newOtp = [...otp];
32
- newOtp[index] = val;
33
- setOtp(newOtp);
34
- emitChange(newOtp);
35
- (val && index < length - 1) && inputsRef.current[index + 1]?.focus();
36
- };
37
- const handleKeyDown = (e, index) => {
38
- if (e.key === "Backspace") {
39
- if (otp[index]) {
40
- const newOtp = [...otp];
41
- newOtp[index] = "";
42
- setOtp(newOtp);
43
- emitChange(newOtp);
44
- }
45
- else if (index > 0) {
46
- inputsRef.current[index - 1]?.focus();
47
- }
48
- }
49
- };
50
- const handlePaste = (e) => {
51
- e.preventDefault();
52
- const paste = e.clipboardData.getData("text").trim();
53
- if (!/^[0-9]+$/.test(paste))
54
- return;
55
- const pasted = paste.slice(0, length).split("");
56
- const newOtp = [...otp];
57
- for (let i = 0; i < pasted.length; i++)
58
- newOtp[i] = pasted[i];
59
- setOtp(newOtp);
60
- emitChange(newOtp);
61
- inputsRef.current[Math.min(pasted.length, length - 1)]?.focus();
62
- };
63
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "input-container", children: [(0, jsx_runtime_1.jsx)("label", { className: (0, _utils_1.cn)("input-label", disabled && "input-label-disabled", isFocus && "input-label-focus", !!invalid && "input-label-error", (0, _utils_1.pcn)(className, "label"), disabled && (0, _utils_1.pcn)(className, "label", "disabled"), isFocus && (0, _utils_1.pcn)(className, "label", "focus"), !!invalid && (0, _utils_1.pcn)(className, "label", "error")), children: label }), tip && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-tip", disabled && "input-tip-disabled", (0, _utils_1.pcn)(className, "tip"), disabled && (0, _utils_1.pcn)(className, "tip", "disabled")), children: tip })), (0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("input input-otp-box", isFocus && "input-otp-box-focus", !!invalid && "input-error"), children: [(0, jsx_runtime_1.jsx)("div", { className: "input-otp-digits-container", children: otp.map((digit, index) => ((0, jsx_runtime_1.jsx)("input", { type: "text", ref: (el) => { inputsRef.current[index] = el; }, inputMode: "numeric", maxLength: 1, value: digit, onChange: (e) => handleChange(e.target.value, index), onKeyDown: (e) => handleKeyDown(e, index), onPaste: handlePaste, className: "input-otp-cell", placeholder: "-", autoFocus: index === 0 }, index))) }), (0, jsx_runtime_1.jsx)("input", { type: "hidden", name: name, value: otp.join("") })] }), invalid && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-error-message", (0, _utils_1.pcn)(className, "error")), children: invalid }))] }) }));
64
- };
65
- exports.InputOtpComponent = InputOtpComponent;
@@ -1,17 +0,0 @@
1
- import { InputHTMLAttributes, ReactNode } from "react";
2
- import { ValidationRules } from "@utils";
3
- export interface InputPasswordProps 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, confirm?: 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 InputPasswordComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className, ...props }: InputPasswordProps): import("react").JSX.Element;
@@ -1,59 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InputPasswordComponent = InputPasswordComponent;
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
- function InputPasswordComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className = "", ...props }) {
10
- const [password, setPassword] = (0, react_1.useState)("");
11
- const [confirmPassword, setConfirmPassword] = (0, react_1.useState)("");
12
- const [strength, setStrength] = (0, react_1.useState)("");
13
- // =========================>
14
- // ## Initial
15
- // =========================>
16
- const inputHandler = (0, _utils_1.useInputHandler)(props.name, value, validations, register, unregister, false);
17
- const randomId = (0, _utils_1.useInputRandomId)();
18
- const randomConfirmId = (0, _utils_1.useInputRandomId)();
19
- // =========================>
20
- // ## Invalid handler
21
- // =========================>
22
- const [invalidMessage] = (0, _utils_1.useValidation)(inputHandler.value, validations, invalid, inputHandler.idle);
23
- // =========================>
24
- // ## Password strength handler
25
- // =========================>
26
- (0, react_1.useEffect)(() => {
27
- if (!password)
28
- return setStrength("");
29
- const hasLetter = /[A-Za-z]/.test(password);
30
- const hasNumber = /\d/.test(password);
31
- const hasSymbol = /[^A-Za-z0-9]/.test(password);
32
- if (hasLetter && !hasNumber && !hasSymbol)
33
- setStrength("weak");
34
- else if (hasLetter && hasNumber && !hasSymbol)
35
- setStrength("strong");
36
- else if (hasLetter && hasNumber && hasSymbol)
37
- setStrength("excellent");
38
- else
39
- setStrength("weak");
40
- }, [password]);
41
- // =========================>
42
- // ## Check match confirm password
43
- // =========================>
44
- const isConfirmMismatch = confirmPassword && password !== confirmPassword;
45
- return ((0, jsx_runtime_1.jsxs)("div", { className: "input-container", children: [label && ((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.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("input", { ...props, type: "password", id: randomId, className: (0, _utils_1.cn)("input", leftIcon && "input-with-left-icon", rightIcon && "input-with-right-icon", !!invalidMessage && "input-error", (0, _utils_1.pcn)(className, "base")), value: password, onChange: (e) => {
46
- setPassword(e.target.value);
47
- inputHandler.setIdle(false);
48
- onChange?.(e.target.value, confirmPassword);
49
- }, onFocus: (e) => {
50
- props.onFocus?.(e);
51
- inputHandler.setFocus(true);
52
- }, onBlur: (e) => {
53
- props.onBlur?.(e);
54
- setTimeout(() => inputHandler.setFocus(false), 100);
55
- }, autoComplete: "off" }), leftIcon && ((0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { className: (0, _utils_1.cn)("input-icon", "input-icon-left", (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", (0, _utils_1.pcn)(className, "icon")), icon: rightIcon }))] }), invalidMessage && ((0, jsx_runtime_1.jsx)("small", { className: "input-error-message", children: invalidMessage })), strength && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", strength === "weak" && "password-strength-bar-weak", strength === "strong" && "password-strength-bar-strong", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", strength === "weak" && "password-strength-bar-empty", strength === "strong" && "password-strength-bar-strong", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", (strength === "weak" || strength === "strong") && "password-strength-bar-empty", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("span", { className: (0, _utils_1.cn)("password-strength-text", strength === "weak" && "password-strength-text-weak", strength === "strong" && "password-strength-text-strong", strength === "excellent" && "password-strength-text-excellent"), children: strength === "weak" ? "Weak" : strength === "strong" ? "Strong" : "Excellent" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "input-password-confirm-wrapper", children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: randomConfirmId, className: (0, _utils_1.cn)("input-label", (0, _utils_1.pcn)(className, "label")), children: "Password Confirm" }), (0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("input", { ...props, id: randomConfirmId, type: "password", className: (0, _utils_1.cn)("input", leftIcon && "input-with-left-icon", rightIcon && "input-with-right-icon", (0, _utils_1.pcn)(className, "base"), isConfirmMismatch && "input-error"), value: confirmPassword, onChange: (e) => {
56
- setConfirmPassword(e.target.value);
57
- onChange?.(password, e.target.value);
58
- }, autoComplete: "off" }) })] }), isConfirmMismatch && ((0, jsx_runtime_1.jsx)("small", { className: "input-error-message", children: "Password confirmation not match" }))] }));
59
- }
@@ -1,27 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { ApiType, ValidationRules } from "@utils";
3
- export type InputRadioOptionProps = {
4
- value: string | number;
5
- label: string;
6
- };
7
- export type InputRadioProps = {
8
- name: string;
9
- label?: string;
10
- tip?: string | ReactNode;
11
- vertical?: boolean;
12
- value?: string | number;
13
- disabled?: boolean;
14
- invalid?: string;
15
- options?: InputRadioOptionProps[];
16
- serverOptionControl?: ApiType;
17
- customOptions?: any;
18
- validations?: ValidationRules;
19
- onChange?: (value: string | number) => any;
20
- register?: (name: string, validations?: ValidationRules) => void;
21
- unregister?: (name: string) => void;
22
- /** Use custom class with: "label::", "tip::", "error::", "icon::", "suggest::", "suggest-item::". */
23
- className?: string;
24
- /** Use custom class with: "label::", "checked::", "error::". */
25
- classNameCheckbox?: string;
26
- };
27
- export declare function InputRadioComponent({ name, label, tip, vertical, value, disabled, invalid, options, serverOptionControl, customOptions, validations, onChange, register, unregister, className, classNameCheckbox, }: InputRadioProps): import("react").JSX.Element;
@@ -1,56 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InputRadioComponent = InputRadioComponent;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const _utils_1 = require("@utils");
8
- const _components_1 = require("@components");
9
- function InputRadioComponent({ name, label, tip, vertical, value, disabled, invalid, options, serverOptionControl, customOptions, validations, onChange, register, unregister, className = "", classNameCheckbox = "", }) {
10
- const [dataOptions, setDataOptions] = (0, react_1.useState)([]);
11
- const [loading, setLoading] = (0, react_1.useState)(false);
12
- // =========================>
13
- // ## Initial
14
- // =========================>
15
- const inputHandler = (0, _utils_1.useInputHandler)(name, value, validations, register, unregister, false);
16
- // =========================>
17
- // ## Invalid handler
18
- // =========================>
19
- const [invalidMessage] = (0, _utils_1.useValidation)(inputHandler.value, validations, invalid, inputHandler.idle);
20
- // =========================>
21
- // ## Fetch option
22
- // =========================>
23
- (0, react_1.useEffect)(() => {
24
- const fetchOptions = async () => {
25
- setLoading(true);
26
- const mutateOptions = await (0, _utils_1.api)(serverOptionControl || {});
27
- if (mutateOptions?.status == 200) {
28
- customOptions
29
- ? setDataOptions([customOptions, ...mutateOptions.data])
30
- : setDataOptions(mutateOptions.data);
31
- setLoading(false);
32
- }
33
- };
34
- if (serverOptionControl?.path || serverOptionControl?.url) {
35
- fetchOptions();
36
- }
37
- else {
38
- !options && setDataOptions([]);
39
- }
40
- }, [serverOptionControl?.path, serverOptionControl?.url]);
41
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "input-container w-full", children: [(0, jsx_runtime_1.jsxs)("label", { className: (0, _utils_1.cn)("input-label", disabled && "input-label-disabled", !!invalidMessage && "input-label-error", (0, _utils_1.pcn)(className, "label"), disabled && (0, _utils_1.pcn)(className, "label", "disabled"), !!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", disabled && "input-tip-disabled", (0, _utils_1.pcn)(className, "tip"), disabled && (0, _utils_1.pcn)(className, "tip", "disabled")), children: tip })), (0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("input input-radio-list", vertical && "input-radio-list-vertical", (0, _utils_1.pcn)(className, "input"), !!invalidMessage && "input-error", !!invalidMessage && (0, _utils_1.pcn)(className, "input", "error")), children: [loading && (vertical ? [1, 2, 3, 4, 5, 6, 7, 8, 9] : [1, 2, 3]).map((_, key) => {
42
- return (0, jsx_runtime_1.jsx)("div", { className: "w-1/3 h-6 rounded-lg" }, key);
43
- }), (options || dataOptions) &&
44
- (options || dataOptions)?.map((option, key) => {
45
- return ((0, jsx_runtime_1.jsx)(_components_1.RadioComponent, { label: option.label, name: `option[${option.value}]#${name}`, checked: inputHandler.value == option.value, disabled: disabled, className: classNameCheckbox, onChange: () => {
46
- if (inputHandler.value == option.value) {
47
- inputHandler.setValue("");
48
- onChange?.("");
49
- }
50
- else {
51
- inputHandler.setValue(option.value || "");
52
- onChange?.(option.value || "");
53
- }
54
- } }, key));
55
- })] }), invalidMessage && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-error-message", (0, _utils_1.pcn)(className, "error")), children: invalidMessage }))] }) }));
56
- }
@@ -1,23 +0,0 @@
1
- import { FC, InputHTMLAttributes, ReactNode } from "react";
2
- import { ValidationRules } from "@utils";
3
- export interface InputTimeProps 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 InputTimeComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className, ...props }: InputTimeProps): import("react").JSX.Element;
18
- interface InputTimePickerProps {
19
- onChange?: (time: string) => void;
20
- rightElement?: ReactNode;
21
- }
22
- export declare const InputTimePickerComponent: FC<InputTimePickerProps>;
23
- export {};
@@ -1,73 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InputTimePickerComponent = void 0;
5
- exports.InputTimeComponent = InputTimeComponent;
6
- const jsx_runtime_1 = require("react/jsx-runtime");
7
- const react_1 = require("react");
8
- const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
9
- const _utils_1 = require("@utils");
10
- const _components_1 = require("@components");
11
- function InputTimeComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className = "", ...props }) {
12
- const { isSm } = (0, _utils_1.useResponsive)();
13
- // =========================>
14
- // ## Initial
15
- // =========================>
16
- const inputHandler = (0, _utils_1.useInputHandler)(props.name, value, validations, register, unregister, false);
17
- const randomId = (0, _utils_1.useInputRandomId)();
18
- // =========================>
19
- // ## Invalid handler
20
- // =========================>
21
- const [invalidMessage] = (0, _utils_1.useValidation)(inputHandler.value, validations, invalid, inputHandler.idle);
22
- 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, 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, onChange: (e) => {
23
- inputHandler.setValue(e.target.value);
24
- inputHandler.setIdle(false);
25
- onChange?.(e.target.value);
26
- }, onFocus: (e) => {
27
- props.onFocus?.(e);
28
- inputHandler.setFocus(true);
29
- }, 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)("div", { className: "input-time-picker-popover", children: (0, jsx_runtime_1.jsx)(exports.InputTimePickerComponent, { onChange: (time) => {
30
- inputHandler.setValue(time);
31
- onChange?.(time);
32
- } }) }))] }) }), 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.InputTimePickerComponent, { onChange: (time) => {
33
- inputHandler.setValue(time);
34
- onChange?.(time);
35
- } }) }) }))] }));
36
- }
37
- ;
38
- const InputTimePickerComponent = ({ onChange, rightElement, }) => {
39
- const [hour, setHour] = (0, react_1.useState)(0);
40
- const [minute, setMinute] = (0, react_1.useState)(0);
41
- const [second, setSecond] = (0, react_1.useState)(0);
42
- const hours = Array.from({ length: 24 }, (_, i) => String(i).padStart(2, "0"));
43
- const minutes = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
44
- const seconds = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
45
- const handleSelect = (type, val) => {
46
- if (type === "h")
47
- setHour(Number(val));
48
- if (type === "m")
49
- setMinute(Number(val));
50
- if (type === "s")
51
- setSecond(Number(val));
52
- };
53
- (0, react_1.useEffect)(() => {
54
- const formatted = `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}:${String(second).padStart(2, "0")}`;
55
- onChange?.(formatted);
56
- }, [hour, minute, second]);
57
- const renderColumn = (items, type, activeValue) => ((0, jsx_runtime_1.jsx)("div", { className: "flex-1 overflow-y-auto text-center input-scroll", children: items.map((item) => {
58
- const active = Number(item) === activeValue;
59
- return ((0, jsx_runtime_1.jsx)("div", { onClick: () => handleSelect(type, item), className: (0, _utils_1.cn)("p-2 cursor-pointer rounded text-sm", active ? "bg-primary text-background font-semibold" : "hover:bg-light-primary"), children: item }, item));
60
- }) }));
61
- const timeSlots = (0, react_1.useMemo)(() => {
62
- const newTimeSlots = [];
63
- for (let i = 0; i <= 24 * 60; i += 30) {
64
- const hours = Math.floor(i / 60);
65
- const minutes = i % 60;
66
- const label = `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
67
- newTimeSlots.push(label);
68
- }
69
- return newTimeSlots;
70
- }, []);
71
- return ((0, jsx_runtime_1.jsxs)("div", { className: "w-full max-h-[260] flex gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-1/3 overflow-y-auto bg-background rounded-[6px] input-scroll", children: timeSlots.map((time) => ((0, jsx_runtime_1.jsx)("div", { className: "p-2 text-sm rounded cursor-pointer hover:bg-light-primary text-center", onClick: () => onChange?.(time), children: time }, time))) }), (0, jsx_runtime_1.jsxs)("div", { className: "w-2/3 flex gap-2", children: [renderColumn(hours, "h", hour), renderColumn(minutes, "m", minute), renderColumn(seconds, "s", second)] }), rightElement && (0, jsx_runtime_1.jsx)("div", { children: rightElement })] }));
72
- };
73
- exports.InputTimePickerComponent = InputTimePickerComponent;
@@ -1,9 +0,0 @@
1
- import { CSSProperties } from 'react';
2
- export declare function InputValues({ value, className, onDelete, isFocus, onFocus, style, }: {
3
- value?: string[] | number[];
4
- className?: string;
5
- onDelete?: (val: string | number, index: string | number) => void;
6
- isFocus?: boolean;
7
- onFocus?: () => void;
8
- style?: CSSProperties;
9
- }): import("react").JSX.Element;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InputValues = InputValues;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
6
- const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
7
- const _utils_1 = require("@utils");
8
- function InputValues({ value, className, onDelete, isFocus, onFocus, style, }) {
9
- if (isFocus) {
10
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !!value?.length && ((0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("input-values-dropdown", className), onClick: () => onFocus?.(), children: value?.map((item, key) => {
11
- return ((0, jsx_runtime_1.jsxs)("div", { className: "input-values-item", children: [(0, jsx_runtime_1.jsx)("span", { className: "", children: item }), (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faTimes, className: "input-values-delete", onClick: () => onDelete?.(item, key) })] }, key));
12
- }) })) }));
13
- }
14
- else {
15
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("input-values-preview", className), style: style, onClick: () => onFocus?.(), children: (0, jsx_runtime_1.jsx)("div", { className: "input-values-container", children: value?.map((item, key) => {
16
- return ((0, jsx_runtime_1.jsxs)("div", { className: "input-values-item", children: [(0, jsx_runtime_1.jsx)("span", { children: item }), (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faTimes, className: "input-values-delete", onClick: () => onDelete?.(item, key) })] }, key));
17
- }) }) }) }));
18
- }
19
- }
@@ -1,12 +0,0 @@
1
- export interface RadioProps {
2
- name: string;
3
- label?: string;
4
- value?: string;
5
- disabled?: boolean;
6
- checked?: boolean;
7
- invalid?: string;
8
- onChange?: () => void;
9
- /** Use custom class with: "label::", "checked::", "error::". */
10
- className?: string;
11
- }
12
- export declare function RadioComponent({ name, label, value, disabled, checked, invalid, onChange, className, }: RadioProps): import("react").JSX.Element;
@@ -1,22 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.RadioComponent = RadioComponent;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const _utils_1 = require("@utils");
8
- ;
9
- function RadioComponent({ name, label, value, disabled, checked, invalid, onChange, className = "", }) {
10
- // =========================>
11
- // ## initial
12
- // =========================>
13
- const randomId = (0, _utils_1.useInputRandomId)();
14
- const [invalidMessage, setInvalidMessage] = (0, react_1.useState)("");
15
- // =========================>
16
- // ## invalid handler
17
- // =========================>
18
- (0, react_1.useEffect)(() => {
19
- setInvalidMessage(invalid || "");
20
- }, [invalid]);
21
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "radio-container", children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", className: "hidden", id: randomId, name: name, onChange: onChange, defaultChecked: checked, value: value, disabled: disabled }), (0, jsx_runtime_1.jsxs)("label", { htmlFor: randomId, className: (0, _utils_1.cn)("radio-wrapper", disabled && "radio-wrapper-disabled"), children: [(0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("radio-input", checked && "radio-input-checked", checked && (0, _utils_1.pcn)(className, "checked"), (0, _utils_1.pcn)(className, "input")) }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("radio-label", checked && "radio-label-checked", (0, _utils_1.pcn)(className, "label"), checked && (0, _utils_1.pcn)(className, "label", "checked"), disabled && (0, _utils_1.pcn)(className, "label", "disabled")), children: label })] }), invalidMessage && ((0, jsx_runtime_1.jsx)("small", { className: (0, _utils_1.cn)("input-error-message", (0, _utils_1.pcn)(className, "error")), children: invalidMessage }))] }) }));
22
- }
@@ -1,47 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { ApiType, ValidationRules } from "@utils";
3
- export interface SelectOptionProps {
4
- label: string | ReactNode;
5
- value: string | number;
6
- searchable?: string[];
7
- customLabel?: ReactNode;
8
- }
9
- export interface SelectProps {
10
- name: string;
11
- label?: string;
12
- placeholder?: string;
13
- tip?: string | ReactNode;
14
- leftIcon?: any;
15
- rightIcon?: any;
16
- value?: string | number | (string | number)[];
17
- invalid?: string;
18
- disabled?: boolean;
19
- validations?: ValidationRules;
20
- multiple?: boolean;
21
- autoFocus?: boolean;
22
- clearable?: boolean;
23
- options?: SelectOptionProps[];
24
- searchable?: boolean;
25
- serverOptionControl?: ApiType & {
26
- cacheName?: string | false;
27
- };
28
- idbOptionControl?: {
29
- store: string;
30
- labelKey: string;
31
- valueKey: string;
32
- };
33
- serverSearchable?: boolean;
34
- includedOptions?: SelectOptionProps[];
35
- exceptOptions?: (string | number)[];
36
- tempOptions?: SelectOptionProps[];
37
- newOption?: SelectOptionProps;
38
- maxShowOption?: number;
39
- onChange?: (value: string | number | (string | number)[], data?: any) => any;
40
- register?: (name: string, validations?: ValidationRules) => void;
41
- unregister?: (name: string) => void;
42
- onFocus?: () => void;
43
- onBlur?: () => void;
44
- /** Use custom class with: "label::", "tip::", "error::", "icon::", "suggest::", "suggest-item::". */
45
- className?: string;
46
- }
47
- export declare function SelectComponent({ name, label, placeholder, tip, leftIcon, rightIcon, value, invalid, disabled, validations, multiple, autoFocus, clearable, options, searchable, serverOptionControl, idbOptionControl, serverSearchable, includedOptions, exceptOptions, tempOptions, newOption, maxShowOption, register, unregister, onChange, onFocus, onBlur, className, }: SelectProps): import("react").JSX.Element;