@skalfa/skalfa-component 1.0.0

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 (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -0
  3. package/dist/accordion/Accordion.component.d.ts +13 -0
  4. package/dist/accordion/Accordion.component.js +25 -0
  5. package/dist/breadcrumb/Breadcrumb.component.d.ts +14 -0
  6. package/dist/breadcrumb/Breadcrumb.component.js +21 -0
  7. package/dist/button/Button.component.d.ts +21 -0
  8. package/dist/button/Button.component.js +19 -0
  9. package/dist/card/AlertCard.component.d.ts +11 -0
  10. package/dist/card/AlertCard.component.js +9 -0
  11. package/dist/card/Card.component.d.ts +5 -0
  12. package/dist/card/Card.component.js +9 -0
  13. package/dist/card/DashboardCard.component.d.ts +9 -0
  14. package/dist/card/DashboardCard.component.js +13 -0
  15. package/dist/card/GalleryCard.component.d.ts +7 -0
  16. package/dist/card/GalleryCard.component.js +13 -0
  17. package/dist/card/ProductCard.component.d.ts +9 -0
  18. package/dist/card/ProductCard.component.js +13 -0
  19. package/dist/card/ProfileCard.component.d.ts +10 -0
  20. package/dist/card/ProfileCard.component.js +13 -0
  21. package/dist/carousel/Carousel.component.d.ts +13 -0
  22. package/dist/carousel/Carousel.component.js +37 -0
  23. package/dist/chip/Chip.component.d.ts +6 -0
  24. package/dist/chip/Chip.component.js +12 -0
  25. package/dist/index.d.ts +56 -0
  26. package/dist/index.js +85 -0
  27. package/dist/input/Checkbox.component.d.ts +13 -0
  28. package/dist/input/Checkbox.component.js +23 -0
  29. package/dist/input/Input.component.d.ts +23 -0
  30. package/dist/input/Input.component.js +134 -0
  31. package/dist/input/InputCheckbox.component.d.ts +27 -0
  32. package/dist/input/InputCheckbox.component.js +53 -0
  33. package/dist/input/InputCurrency.component.d.ts +21 -0
  34. package/dist/input/InputCurrency.component.js +30 -0
  35. package/dist/input/InputDate.component.d.ts +24 -0
  36. package/dist/input/InputDate.component.js +107 -0
  37. package/dist/input/InputDatetime.component.d.ts +17 -0
  38. package/dist/input/InputDatetime.component.js +75 -0
  39. package/dist/input/InputDocument.component.d.ts +22 -0
  40. package/dist/input/InputDocument.component.js +88 -0
  41. package/dist/input/InputImage.component.d.ts +23 -0
  42. package/dist/input/InputImage.component.js +260 -0
  43. package/dist/input/InputMap.component.d.ts +25 -0
  44. package/dist/input/InputMap.component.js +103 -0
  45. package/dist/input/InputNumber.component.d.ts +19 -0
  46. package/dist/input/InputNumber.component.js +40 -0
  47. package/dist/input/InputOtp.component.d.ts +14 -0
  48. package/dist/input/InputOtp.component.js +65 -0
  49. package/dist/input/InputPassword.component.d.ts +17 -0
  50. package/dist/input/InputPassword.component.js +59 -0
  51. package/dist/input/InputRadio.component.d.ts +27 -0
  52. package/dist/input/InputRadio.component.js +56 -0
  53. package/dist/input/InputTime.component.d.ts +23 -0
  54. package/dist/input/InputTime.component.js +73 -0
  55. package/dist/input/InputValues.component.d.ts +9 -0
  56. package/dist/input/InputValues.component.js +19 -0
  57. package/dist/input/Radio.component.d.ts +12 -0
  58. package/dist/input/Radio.component.js +22 -0
  59. package/dist/input/Select.component.d.ts +47 -0
  60. package/dist/input/Select.component.js +275 -0
  61. package/dist/modal/BottomSheet.component.d.ts +12 -0
  62. package/dist/modal/BottomSheet.component.js +161 -0
  63. package/dist/modal/FloatingPage.component.d.ts +12 -0
  64. package/dist/modal/FloatingPage.component.js +27 -0
  65. package/dist/modal/Modal.component.d.ts +12 -0
  66. package/dist/modal/Modal.component.js +27 -0
  67. package/dist/modal/ModalConfirm.component.d.ts +26 -0
  68. package/dist/modal/ModalConfirm.component.js +68 -0
  69. package/dist/modal/Toast.component.d.ts +11 -0
  70. package/dist/modal/Toast.component.js +58 -0
  71. package/dist/nav/Bottombar.component.d.ts +12 -0
  72. package/dist/nav/Bottombar.component.js +32 -0
  73. package/dist/nav/Footer.component.d.ts +37 -0
  74. package/dist/nav/Footer.component.js +49 -0
  75. package/dist/nav/Headbar.component.d.ts +14 -0
  76. package/dist/nav/Headbar.component.js +32 -0
  77. package/dist/nav/Navbar.component.d.ts +22 -0
  78. package/dist/nav/Navbar.component.js +26 -0
  79. package/dist/nav/Sidebar.component.d.ts +33 -0
  80. package/dist/nav/Sidebar.component.js +87 -0
  81. package/dist/nav/Tabbar.component.d.ts +13 -0
  82. package/dist/nav/Tabbar.component.js +17 -0
  83. package/dist/nav/Wizard.component.d.ts +9 -0
  84. package/dist/nav/Wizard.component.js +24 -0
  85. package/dist/src/accordion/Accordion.component.d.ts +13 -0
  86. package/dist/src/accordion/Accordion.component.js +25 -0
  87. package/dist/src/breadcrumb/Breadcrumb.component.d.ts +14 -0
  88. package/dist/src/breadcrumb/Breadcrumb.component.js +21 -0
  89. package/dist/src/button/Button.component.d.ts +21 -0
  90. package/dist/src/button/Button.component.js +19 -0
  91. package/dist/src/card/AlertCard.component.d.ts +11 -0
  92. package/dist/src/card/AlertCard.component.js +9 -0
  93. package/dist/src/card/Card.component.d.ts +5 -0
  94. package/dist/src/card/Card.component.js +9 -0
  95. package/dist/src/card/DashboardCard.component.d.ts +9 -0
  96. package/dist/src/card/DashboardCard.component.js +13 -0
  97. package/dist/src/card/GalleryCard.component.d.ts +7 -0
  98. package/dist/src/card/GalleryCard.component.js +13 -0
  99. package/dist/src/card/ProductCard.component.d.ts +9 -0
  100. package/dist/src/card/ProductCard.component.js +13 -0
  101. package/dist/src/card/ProfileCard.component.d.ts +10 -0
  102. package/dist/src/card/ProfileCard.component.js +13 -0
  103. package/dist/src/carousel/Carousel.component.d.ts +13 -0
  104. package/dist/src/carousel/Carousel.component.js +37 -0
  105. package/dist/src/chip/Chip.component.d.ts +6 -0
  106. package/dist/src/chip/Chip.component.js +12 -0
  107. package/dist/src/index.d.ts +13 -0
  108. package/dist/src/index.js +29 -0
  109. package/dist/src/input/Checkbox.component.d.ts +13 -0
  110. package/dist/src/input/Checkbox.component.js +23 -0
  111. package/dist/src/input/Input.component.d.ts +23 -0
  112. package/dist/src/input/Input.component.js +134 -0
  113. package/dist/src/input/InputCheckbox.component.d.ts +27 -0
  114. package/dist/src/input/InputCheckbox.component.js +53 -0
  115. package/dist/src/input/InputCurrency.component.d.ts +21 -0
  116. package/dist/src/input/InputCurrency.component.js +30 -0
  117. package/dist/src/input/InputDate.component.d.ts +24 -0
  118. package/dist/src/input/InputDate.component.js +107 -0
  119. package/dist/src/input/InputDatetime.component.d.ts +17 -0
  120. package/dist/src/input/InputDatetime.component.js +75 -0
  121. package/dist/src/input/InputDocument.component.d.ts +22 -0
  122. package/dist/src/input/InputDocument.component.js +88 -0
  123. package/dist/src/input/InputImage.component.d.ts +23 -0
  124. package/dist/src/input/InputImage.component.js +260 -0
  125. package/dist/src/input/InputMap.component.d.ts +25 -0
  126. package/dist/src/input/InputMap.component.js +101 -0
  127. package/dist/src/input/InputNumber.component.d.ts +19 -0
  128. package/dist/src/input/InputNumber.component.js +40 -0
  129. package/dist/src/input/InputOtp.component.d.ts +14 -0
  130. package/dist/src/input/InputOtp.component.js +65 -0
  131. package/dist/src/input/InputPassword.component.d.ts +17 -0
  132. package/dist/src/input/InputPassword.component.js +59 -0
  133. package/dist/src/input/InputRadio.component.d.ts +27 -0
  134. package/dist/src/input/InputRadio.component.js +56 -0
  135. package/dist/src/input/InputTime.component.d.ts +23 -0
  136. package/dist/src/input/InputTime.component.js +73 -0
  137. package/dist/src/input/InputValues.component.d.ts +9 -0
  138. package/dist/src/input/InputValues.component.js +19 -0
  139. package/dist/src/input/Radio.component.d.ts +12 -0
  140. package/dist/src/input/Radio.component.js +22 -0
  141. package/dist/src/input/Select.component.d.ts +47 -0
  142. package/dist/src/input/Select.component.js +275 -0
  143. package/dist/src/modal/BottomSheet.component.d.ts +12 -0
  144. package/dist/src/modal/BottomSheet.component.js +161 -0
  145. package/dist/src/modal/FloatingPage.component.d.ts +12 -0
  146. package/dist/src/modal/FloatingPage.component.js +27 -0
  147. package/dist/src/modal/Modal.component.d.ts +12 -0
  148. package/dist/src/modal/Modal.component.js +27 -0
  149. package/dist/src/modal/ModalConfirm.component.d.ts +26 -0
  150. package/dist/src/modal/ModalConfirm.component.js +68 -0
  151. package/dist/src/modal/Toast.component.d.ts +11 -0
  152. package/dist/src/modal/Toast.component.js +58 -0
  153. package/dist/src/nav/Bottombar.component.d.ts +12 -0
  154. package/dist/src/nav/Bottombar.component.js +32 -0
  155. package/dist/src/nav/Footer.component.d.ts +37 -0
  156. package/dist/src/nav/Footer.component.js +49 -0
  157. package/dist/src/nav/Headbar.component.d.ts +14 -0
  158. package/dist/src/nav/Headbar.component.js +32 -0
  159. package/dist/src/nav/Navbar.component.d.ts +22 -0
  160. package/dist/src/nav/Navbar.component.js +26 -0
  161. package/dist/src/nav/Sidebar.component.d.ts +33 -0
  162. package/dist/src/nav/Sidebar.component.js +87 -0
  163. package/dist/src/nav/Tabbar.component.d.ts +13 -0
  164. package/dist/src/nav/Tabbar.component.js +17 -0
  165. package/dist/src/nav/Wizard.component.d.ts +9 -0
  166. package/dist/src/nav/Wizard.component.js +24 -0
  167. package/dist/src/supervision/FormSupervision.component.d.ts +93 -0
  168. package/dist/src/supervision/FormSupervision.component.js +168 -0
  169. package/dist/src/supervision/TableSupervision.component.d.ts +78 -0
  170. package/dist/src/supervision/TableSupervision.component.js +273 -0
  171. package/dist/src/table/ControlBar.component.d.ts +34 -0
  172. package/dist/src/table/ControlBar.component.js +205 -0
  173. package/dist/src/table/FilterComponent.d.ts +45 -0
  174. package/dist/src/table/FilterComponent.js +132 -0
  175. package/dist/src/table/Pagination.component.d.ts +8 -0
  176. package/dist/src/table/Pagination.component.js +32 -0
  177. package/dist/src/table/Table.component.d.ts +61 -0
  178. package/dist/src/table/Table.component.js +101 -0
  179. package/dist/src/typography/TypographyArticle.component.d.ts +8 -0
  180. package/dist/src/typography/TypographyArticle.component.js +7 -0
  181. package/dist/src/typography/TypographyColumn.component.d.ts +6 -0
  182. package/dist/src/typography/TypographyColumn.component.js +7 -0
  183. package/dist/src/typography/TypographyContent.component.d.ts +6 -0
  184. package/dist/src/typography/TypographyContent.component.js +7 -0
  185. package/dist/src/typography/TypographyTips.component.d.ts +6 -0
  186. package/dist/src/typography/TypographyTips.component.js +7 -0
  187. package/dist/src/wrap/Draggable.component.d.ts +34 -0
  188. package/dist/src/wrap/Draggable.component.js +214 -0
  189. package/dist/src/wrap/Image.component.d.ts +2 -0
  190. package/dist/src/wrap/Image.component.js +13 -0
  191. package/dist/src/wrap/OutsideClick.component.d.ts +6 -0
  192. package/dist/src/wrap/OutsideClick.component.js +34 -0
  193. package/dist/src/wrap/ScrollContainer.component.d.ts +10 -0
  194. package/dist/src/wrap/ScrollContainer.component.js +54 -0
  195. package/dist/src/wrap/ShortcutProvider.d.ts +1 -0
  196. package/dist/src/wrap/ShortcutProvider.js +42 -0
  197. package/dist/src/wrap/Swipe.component.d.ts +14 -0
  198. package/dist/src/wrap/Swipe.component.js +61 -0
  199. package/dist/supervision/FormSupervision.component.d.ts +93 -0
  200. package/dist/supervision/FormSupervision.component.js +168 -0
  201. package/dist/supervision/TableSupervision.component.d.ts +78 -0
  202. package/dist/supervision/TableSupervision.component.js +273 -0
  203. package/dist/table/ControlBar.component.d.ts +34 -0
  204. package/dist/table/ControlBar.component.js +205 -0
  205. package/dist/table/FilterComponent.d.ts +45 -0
  206. package/dist/table/FilterComponent.js +132 -0
  207. package/dist/table/Pagination.component.d.ts +8 -0
  208. package/dist/table/Pagination.component.js +32 -0
  209. package/dist/table/Table.component.d.ts +61 -0
  210. package/dist/table/Table.component.js +101 -0
  211. package/dist/typography/TypographyArticle.component.d.ts +8 -0
  212. package/dist/typography/TypographyArticle.component.js +7 -0
  213. package/dist/typography/TypographyColumn.component.d.ts +6 -0
  214. package/dist/typography/TypographyColumn.component.js +7 -0
  215. package/dist/typography/TypographyContent.component.d.ts +6 -0
  216. package/dist/typography/TypographyContent.component.js +7 -0
  217. package/dist/typography/TypographyTips.component.d.ts +6 -0
  218. package/dist/typography/TypographyTips.component.js +7 -0
  219. package/dist/wrap/Draggable.component.d.ts +1 -0
  220. package/dist/wrap/Draggable.component.js +214 -0
  221. package/dist/wrap/Image.component.d.ts +2 -0
  222. package/dist/wrap/Image.component.js +13 -0
  223. package/dist/wrap/OutsideClick.component.d.ts +6 -0
  224. package/dist/wrap/OutsideClick.component.js +34 -0
  225. package/dist/wrap/ScrollContainer.component.d.ts +10 -0
  226. package/dist/wrap/ScrollContainer.component.js +54 -0
  227. package/dist/wrap/ShortcutProvider.d.ts +1 -0
  228. package/dist/wrap/ShortcutProvider.js +42 -0
  229. package/dist/wrap/Swipe.component.d.ts +14 -0
  230. package/dist/wrap/Swipe.component.js +61 -0
  231. package/package.json +44 -0
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TypographyArticleProps {
3
+ title: string | ReactNode;
4
+ content: string | ReactNode;
5
+ header?: string | ReactNode;
6
+ footer?: string | ReactNode;
7
+ }
8
+ export declare function TypographyArticleComponent({ title, content, header, footer, }: TypographyArticleProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypographyArticleComponent = TypographyArticleComponent;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function TypographyArticleComponent({ title, content, header, footer, }) {
6
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h4", { className: "typography-article-header", children: header }), (0, jsx_runtime_1.jsx)("h1", { className: "typography-article-title", children: title }), (0, jsx_runtime_1.jsx)("div", { className: "typography-article-content", children: content }), (0, jsx_runtime_1.jsx)("div", { className: "typography-article-footer", children: footer })] }));
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TypographyColumnProps {
3
+ title: string | ReactNode;
4
+ content: string | ReactNode;
5
+ }
6
+ export declare function TypographyColumnComponent({ title, content, }: TypographyColumnProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypographyColumnComponent = TypographyColumnComponent;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function TypographyColumnComponent({ title, content, }) {
6
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "typography-column-title", children: title }), (0, jsx_runtime_1.jsx)("div", { children: content })] }) }));
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TypographyContentProps {
3
+ title: string | ReactNode;
4
+ content: string | ReactNode;
5
+ }
6
+ export declare function TypographyContentComponent({ title, content, }: TypographyContentProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypographyContentComponent = TypographyContentComponent;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function TypographyContentComponent({ title, content, }) {
6
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { className: "typography-content-title", children: title }), (0, jsx_runtime_1.jsx)("p", { className: "typography-content-body", children: content })] }) }));
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TypographyTipsProps {
3
+ title: string | ReactNode;
4
+ content: string | ReactNode;
5
+ }
6
+ export declare function TypographyTipsComponent({ title, content, }: TypographyTipsProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypographyTipsComponent = TypographyTipsComponent;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function TypographyTipsComponent({ title, content, }) {
6
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "typography-tips", children: [(0, jsx_runtime_1.jsx)("p", { className: "typography-tips-title", children: title }), (0, jsx_runtime_1.jsx)("p", { className: "typography-tips-body", children: content })] }) }));
7
+ }
@@ -0,0 +1,34 @@
1
+ import { ReactNode, CSSProperties } from 'react';
2
+ type SpringConfig = {
3
+ stiffness?: number;
4
+ damping?: number;
5
+ mass?: number;
6
+ stopThreshold?: number;
7
+ };
8
+ type Bounds = {
9
+ left?: number;
10
+ top?: number;
11
+ right?: number;
12
+ bottom?: number;
13
+ };
14
+ type DraggableProps = {
15
+ children?: ReactNode;
16
+ className?: string;
17
+ style?: CSSProperties;
18
+ initial?: {
19
+ x?: number;
20
+ y?: number;
21
+ };
22
+ bounds?: Bounds;
23
+ spring?: SpringConfig;
24
+ onDrag?: (state: {
25
+ x: number;
26
+ y: number;
27
+ vx: number;
28
+ vy: number;
29
+ dragging: boolean;
30
+ }) => void;
31
+ useTranslate3d?: boolean;
32
+ };
33
+ export declare const DraggableComponent: import("react").ForwardRefExoticComponent<DraggableProps & import("react").RefAttributes<unknown>>;
34
+ export {};
@@ -0,0 +1,214 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DraggableComponent = void 0;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ // -----------------------------------------------------
8
+ // DraggableComponent
9
+ // -----------------------------------------------------
10
+ exports.DraggableComponent = (0, react_1.forwardRef)(function DraggableComponent({ children, className, style, initial = { x: 0, y: 0 }, bounds, spring, onDrag, useTranslate3d = true, }, ref) {
11
+ const elRef = (0, react_1.useRef)(null);
12
+ const frameRef = (0, react_1.useRef)(null);
13
+ const draggingRef = (0, react_1.useRef)(false);
14
+ const pointerIdRef = (0, react_1.useRef)(null);
15
+ const stateRef = (0, react_1.useRef)({ x: initial.x || 0, y: initial.y || 0, vx: 0, vy: 0 });
16
+ const targetRef = (0, react_1.useRef)({ x: initial.x || 0, y: initial.y || 0 });
17
+ const historyRef = (0, react_1.useRef)([]);
18
+ const cfg = {
19
+ stiffness: spring?.stiffness ?? 180,
20
+ damping: spring?.damping ?? 24,
21
+ mass: spring?.mass ?? 1,
22
+ stopThreshold: spring?.stopThreshold ?? 0.02,
23
+ };
24
+ const [, setTick] = (0, react_1.useState)(0);
25
+ const now = () => performance.now();
26
+ function applyStyle(x, y) {
27
+ const el = elRef.current;
28
+ if (!el)
29
+ return;
30
+ const transform = useTranslate3d ? `translate3d(${x}px, ${y}px, 0)` : `translate(${x}px, ${y}px)`;
31
+ el.style.transform = transform;
32
+ }
33
+ function clampToBounds(x, y) {
34
+ if (!bounds)
35
+ return { x, y };
36
+ return {
37
+ x: Math.max(bounds.left ?? -Infinity, Math.min(x, bounds.right ?? Infinity)),
38
+ y: Math.max(bounds.top ?? -Infinity, Math.min(y, bounds.bottom ?? Infinity)),
39
+ };
40
+ }
41
+ function estimateVelocity() {
42
+ const h = historyRef.current;
43
+ if (h.length < 2)
44
+ return { vx: 0, vy: 0 };
45
+ const last = h[h.length - 1];
46
+ const threshold = 50;
47
+ let idx = h.length - 2;
48
+ while (idx > 0 && last.t - h[idx].t < threshold)
49
+ idx--;
50
+ const prev = h[idx];
51
+ const dt = Math.max(1, last.t - prev.t);
52
+ return {
53
+ vx: (last.x - prev.x) / (dt / 1000),
54
+ vy: (last.y - prev.y) / (dt / 1000),
55
+ };
56
+ }
57
+ function cancelFrame() {
58
+ if (frameRef.current != null) {
59
+ cancelAnimationFrame(frameRef.current);
60
+ frameRef.current = null;
61
+ }
62
+ }
63
+ function startSpringAnimation(initVX = 0, initVY = 0) {
64
+ cancelFrame();
65
+ const mass = cfg.mass;
66
+ const k = cfg.stiffness;
67
+ const c = cfg.damping;
68
+ stateRef.current.vx = initVX;
69
+ stateRef.current.vy = initVY;
70
+ let lastTime = now();
71
+ function step() {
72
+ const t = now();
73
+ const dt = Math.min(32, t - lastTime) / 1000;
74
+ lastTime = t;
75
+ const sx = stateRef.current.x;
76
+ const sy = stateRef.current.y;
77
+ const vx = stateRef.current.vx;
78
+ const vy = stateRef.current.vy;
79
+ const tx = targetRef.current.x;
80
+ const ty = targetRef.current.y;
81
+ const ax = (-c * vx - k * (sx - tx)) / mass;
82
+ const ay = (-c * vy - k * (sy - ty)) / mass;
83
+ const nvx = vx + ax * dt;
84
+ const nvy = vy + ay * dt;
85
+ const nx = sx + nvx * dt;
86
+ const ny = sy + nvy * dt;
87
+ stateRef.current.x = nx;
88
+ stateRef.current.y = ny;
89
+ stateRef.current.vx = nvx;
90
+ stateRef.current.vy = nvy;
91
+ applyStyle(nx, ny);
92
+ onDrag?.({ x: nx, y: ny, vx: nvx, vy: nvy, dragging: false });
93
+ const disp = Math.hypot(nx - tx, ny - ty);
94
+ const vel = Math.hypot(nvx, nvy);
95
+ if (disp < cfg.stopThreshold && vel < cfg.stopThreshold) {
96
+ stateRef.current.x = tx;
97
+ stateRef.current.y = ty;
98
+ stateRef.current.vx = 0;
99
+ stateRef.current.vy = 0;
100
+ applyStyle(tx, ty);
101
+ onDrag?.({ x: tx, y: ty, vx: 0, vy: 0, dragging: false });
102
+ frameRef.current = null;
103
+ return;
104
+ }
105
+ frameRef.current = requestAnimationFrame(step);
106
+ }
107
+ frameRef.current = requestAnimationFrame(step);
108
+ }
109
+ // -------------------------------------------------------------------
110
+ // Expose API ke parent: setTarget & setPositionImmediate
111
+ // -------------------------------------------------------------------
112
+ (0, react_1.useImperativeHandle)(ref, () => ({
113
+ setTarget(pos) {
114
+ targetRef.current.x = pos.x;
115
+ targetRef.current.y = pos.y;
116
+ startSpringAnimation(0, 0);
117
+ },
118
+ setPosition(pos) {
119
+ stateRef.current.x = pos.x;
120
+ stateRef.current.y = pos.y;
121
+ targetRef.current.x = pos.x;
122
+ targetRef.current.y = pos.y;
123
+ applyStyle(pos.x, pos.y);
124
+ },
125
+ }));
126
+ (0, react_1.useEffect)(() => {
127
+ const el = elRef.current;
128
+ if (!el)
129
+ return;
130
+ function onDown(e) {
131
+ if (e.pointerType === 'mouse' && e.button !== 0)
132
+ return;
133
+ e.target.setPointerCapture?.(e.pointerId);
134
+ pointerIdRef.current = e.pointerId;
135
+ draggingRef.current = true;
136
+ cancelFrame();
137
+ historyRef.current = [{ t: now(), x: stateRef.current.x, y: stateRef.current.y }];
138
+ el.__dragBase = {
139
+ px: e.clientX,
140
+ py: e.clientY,
141
+ startX: stateRef.current.x,
142
+ startY: stateRef.current.y,
143
+ };
144
+ onDrag?.({
145
+ x: stateRef.current.x,
146
+ y: stateRef.current.y,
147
+ vx: 0,
148
+ vy: 0,
149
+ dragging: true,
150
+ });
151
+ }
152
+ function onMove(e) {
153
+ if (!draggingRef.current)
154
+ return;
155
+ if (pointerIdRef.current !== null && e.pointerId !== pointerIdRef.current)
156
+ return;
157
+ const base = el.__dragBase;
158
+ if (!base)
159
+ return;
160
+ let nx = base.startX + (e.clientX - base.px);
161
+ let ny = base.startY + (e.clientY - base.py);
162
+ ({ x: nx, y: ny } = clampToBounds(nx, ny));
163
+ historyRef.current.push({ t: now(), x: nx, y: ny });
164
+ if (historyRef.current.length > 8)
165
+ historyRef.current.shift();
166
+ stateRef.current.x = nx;
167
+ stateRef.current.y = ny;
168
+ stateRef.current.vx = 0;
169
+ stateRef.current.vy = 0;
170
+ applyStyle(nx, ny);
171
+ onDrag?.({ x: nx, y: ny, vx: 0, vy: 0, dragging: true });
172
+ setTick(t => t + 1);
173
+ }
174
+ function onUp(e) {
175
+ if (!draggingRef.current)
176
+ return;
177
+ if (pointerIdRef.current !== null && e.pointerId !== pointerIdRef.current)
178
+ return;
179
+ e.target.releasePointerCapture?.(e.pointerId);
180
+ draggingRef.current = false;
181
+ pointerIdRef.current = null;
182
+ const { vx, vy } = estimateVelocity();
183
+ let tx = stateRef.current.x;
184
+ let ty = stateRef.current.y;
185
+ ({ x: tx, y: ty } = clampToBounds(tx, ty));
186
+ targetRef.current.x = tx;
187
+ targetRef.current.y = ty;
188
+ startSpringAnimation(vx, vy);
189
+ }
190
+ el.addEventListener('pointerdown', onDown);
191
+ window.addEventListener('pointermove', onMove);
192
+ window.addEventListener('pointerup', onUp);
193
+ window.addEventListener('pointercancel', onUp);
194
+ return () => {
195
+ el.removeEventListener('pointerdown', onDown);
196
+ window.removeEventListener('pointermove', onMove);
197
+ window.removeEventListener('pointerup', onUp);
198
+ window.removeEventListener('pointercancel', onUp);
199
+ cancelFrame();
200
+ };
201
+ }, [bounds]);
202
+ // initial pos
203
+ (0, react_1.useEffect)(() => {
204
+ stateRef.current.x = initial.x || 0;
205
+ stateRef.current.y = initial.y || 0;
206
+ applyStyle(initial.x || 0, initial.y || 0);
207
+ }, []);
208
+ return ((0, jsx_runtime_1.jsx)("div", { ref: elRef, className: className, style: {
209
+ touchAction: 'none',
210
+ cursor: 'grab',
211
+ display: 'inline-block',
212
+ ...style,
213
+ }, onMouseDown: (e) => e.preventDefault(), children: children }));
214
+ });
@@ -0,0 +1,2 @@
1
+ import { ImageProps } from "next/image";
2
+ export declare function ImageComponent(props: ImageProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ImageComponent = ImageComponent;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ /* eslint-disable jsx-a11y/alt-text */
9
+ const image_1 = __importDefault(require("next/image"));
10
+ function ImageComponent(props) {
11
+ const isProd = process.env.NODE_ENV === "production";
12
+ return (0, jsx_runtime_1.jsx)(image_1.default, { ...props, unoptimized: !isProd });
13
+ }
@@ -0,0 +1,6 @@
1
+ import { FC, ReactNode } from "react";
2
+ export interface OutsideClickHandlerProps {
3
+ children: ReactNode;
4
+ onOutsideClick?: () => void;
5
+ }
6
+ export declare const OutsideClickComponent: FC<OutsideClickHandlerProps>;
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.OutsideClickComponent = void 0;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const OutsideClickComponent = ({ children, onOutsideClick, }) => {
8
+ const ref = (0, react_1.useRef)(null);
9
+ const handlerRef = (0, react_1.useRef)(onOutsideClick);
10
+ (0, react_1.useEffect)(() => {
11
+ handlerRef.current = onOutsideClick;
12
+ }, [onOutsideClick]);
13
+ (0, react_1.useEffect)(() => {
14
+ const handlePointerDown = (event) => {
15
+ const el = ref.current;
16
+ if (!el || !(event.target instanceof Node))
17
+ return;
18
+ const isOutside = !el.contains(event.target);
19
+ if (isOutside) {
20
+ queueMicrotask(() => {
21
+ if (ref.current && !ref.current.contains(event.target)) {
22
+ handlerRef.current?.();
23
+ }
24
+ });
25
+ }
26
+ };
27
+ document.addEventListener("pointerdown", handlePointerDown, true);
28
+ return () => {
29
+ document.removeEventListener("pointerdown", handlePointerDown, true);
30
+ };
31
+ }, []);
32
+ return (0, jsx_runtime_1.jsx)("div", { ref: ref, children: children });
33
+ };
34
+ exports.OutsideClickComponent = OutsideClickComponent;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from "react";
2
+ export interface ScrollContainerProps {
3
+ children: ReactNode;
4
+ footer?: ReactNode;
5
+ scrollFloating?: boolean;
6
+ onScroll?: (e: any) => void;
7
+ /** Use custom class with: "container::", "floating-scroll::"". */
8
+ className?: string;
9
+ }
10
+ export declare function ScrollContainerComponent({ children, footer, className, scrollFloating, onScroll, }: ScrollContainerProps): import("react").JSX.Element;
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ScrollContainerComponent = ScrollContainerComponent;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const _utils_1 = require("@utils");
7
+ const react_1 = require("react");
8
+ function ScrollContainerComponent({ children, footer, className = "", scrollFloating = false, onScroll, }) {
9
+ const containerRef = (0, react_1.useRef)(null);
10
+ const floatingScrollbarRef = (0, react_1.useRef)(null);
11
+ const floatingScrollbarContainerRef = (0, react_1.useRef)(null);
12
+ const [containerWidth, setContainerWidth] = (0, react_1.useState)(0);
13
+ (0, react_1.useEffect)(() => {
14
+ const handleScroll = () => {
15
+ if (!containerRef.current)
16
+ return;
17
+ onScroll?.(containerRef.current);
18
+ };
19
+ const container = containerRef.current;
20
+ if (container) {
21
+ handleScroll();
22
+ container.addEventListener("scroll", handleScroll);
23
+ }
24
+ return () => container?.removeEventListener("scroll", handleScroll);
25
+ }, []);
26
+ (0, react_1.useEffect)(() => {
27
+ const scrollContainer = containerRef.current;
28
+ const floatingScrollbar = floatingScrollbarRef.current;
29
+ if (!scrollContainer || !floatingScrollbar)
30
+ return;
31
+ const syncScroll = () => floatingScrollbar.scrollLeft = scrollContainer.scrollLeft;
32
+ const syncScrollReverse = () => scrollContainer.scrollLeft = floatingScrollbar.scrollLeft;
33
+ scrollContainer.addEventListener("scroll", syncScroll);
34
+ floatingScrollbar.addEventListener("scroll", syncScrollReverse);
35
+ return () => {
36
+ scrollContainer.removeEventListener("scroll", syncScroll);
37
+ floatingScrollbar.removeEventListener("scroll", syncScrollReverse);
38
+ };
39
+ }, []);
40
+ const handleResize = () => {
41
+ if (containerRef.current)
42
+ setContainerWidth(containerRef.current.offsetWidth);
43
+ };
44
+ (0, react_1.useEffect)(() => {
45
+ handleResize();
46
+ window.addEventListener("resize", handleResize);
47
+ return () => window.removeEventListener("resize", handleResize);
48
+ }, []);
49
+ (0, react_1.useEffect)(() => {
50
+ if (floatingScrollbarContainerRef.current)
51
+ floatingScrollbarContainerRef.current.style.width = `${containerWidth}px`;
52
+ }, [containerWidth]);
53
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("relative", (0, _utils_1.pcn)(className, "base")), children: [(0, jsx_runtime_1.jsx)("div", { ref: containerRef, className: (0, _utils_1.cn)("scroll-container-main scroll", scrollFloating && "scroll-none", (0, _utils_1.pcn)(className, "container")), children: children }), (0, jsx_runtime_1.jsxs)("div", { className: "scroll-container-floating-bar", ref: floatingScrollbarContainerRef, children: [(0, jsx_runtime_1.jsx)("div", { ref: floatingScrollbarRef, className: (0, _utils_1.cn)(scrollFloating && "scroll-container-floating-wrapper scroll"), children: (0, jsx_runtime_1.jsx)("div", { className: "scroll-container-phantom-element", children: children }) }), footer] })] }));
54
+ }
@@ -0,0 +1 @@
1
+ export declare function ShortcutProvider(): import("react").JSX.Element;
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ShortcutProvider = ShortcutProvider;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const _utils_1 = require("@utils");
8
+ const _contexts_1 = require("@contexts");
9
+ const _components_1 = require("@components");
10
+ function ShortcutProvider() {
11
+ const { setToggle, toggle } = (0, _contexts_1.useToggleContext)();
12
+ const shortcuts = _utils_1.shortcut.list();
13
+ (0, react_1.useEffect)(() => {
14
+ _utils_1.shortcut.init();
15
+ }, []);
16
+ (0, react_1.useEffect)(() => {
17
+ _utils_1.shortcut.register("ctrl+/", () => {
18
+ setToggle("MODAL_SHORTCUT_HELP");
19
+ }, "List Shortcut");
20
+ }, []);
21
+ function formatShortcutKey(key) {
22
+ return key
23
+ .split("+")
24
+ .map(k => {
25
+ if (k === "ctrl")
26
+ return "Ctrl";
27
+ if (k === "shift")
28
+ return "Shift";
29
+ if (k === "alt")
30
+ return "Alt";
31
+ if (k === "arrowup")
32
+ return "↑";
33
+ if (k === "arrowdown")
34
+ return "↓";
35
+ if (k === " ")
36
+ return "SPACE";
37
+ return k.toUpperCase();
38
+ })
39
+ .join(" + ");
40
+ }
41
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(_components_1.ModalComponent, { show: !!toggle["MODAL_SHORTCUT_HELP"], onClose: () => setToggle("MODAL_SHORTCUT_HELP"), title: "Shortcut", children: (0, jsx_runtime_1.jsx)("div", { className: "shortcut-help-grid", children: shortcuts.map(({ key, description }) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("kbd", { className: "shortcut-key-badge", children: formatShortcutKey(key) }), (0, jsx_runtime_1.jsxs)("span", { children: [": ", description] })] }, key))) }) }) }));
42
+ }
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ export type SwipeActionType = {
3
+ label?: string;
4
+ icon?: any;
5
+ onAction?: () => void;
6
+ className?: string;
7
+ };
8
+ export type SwipeProps = {
9
+ leftActionControl?: SwipeActionType;
10
+ rightActionControl?: SwipeActionType;
11
+ children?: ReactNode;
12
+ className?: string;
13
+ };
14
+ export declare function SwipeComponent({ leftActionControl, rightActionControl, children, className, }: SwipeProps): import("react").JSX.Element;
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SwipeComponent = SwipeComponent;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const utils_1 = require("@/utils");
8
+ const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
9
+ function SwipeComponent({ leftActionControl, rightActionControl, children, className, }) {
10
+ const startX = (0, react_1.useRef)(0);
11
+ const [offset, setOffset] = (0, react_1.useState)(0);
12
+ const [dragging, setDragging] = (0, react_1.useState)(false);
13
+ function onTouchStart(e) {
14
+ setDragging(true);
15
+ startX.current = e.touches[0].clientX - offset;
16
+ }
17
+ function onTouchMove(e) {
18
+ if (!dragging)
19
+ return;
20
+ const currentX = e.touches[0].clientX;
21
+ const delta = currentX - startX.current;
22
+ let allowed = delta;
23
+ // Jika tidak ada aksi kiri → larang geser ke kanan
24
+ if (!leftActionControl && delta > 0)
25
+ allowed = 0;
26
+ // Jika tidak ada aksi kanan → larang geser ke kiri
27
+ if (!rightActionControl && delta < 0)
28
+ allowed = 0;
29
+ // Batasi maksimal ±100px
30
+ allowed = Math.max(Math.min(allowed, 100), -100);
31
+ setOffset(allowed);
32
+ }
33
+ function onTouchEnd() {
34
+ if (!dragging)
35
+ return;
36
+ setDragging(false);
37
+ if (offset > 40 && leftActionControl) {
38
+ setOffset(80);
39
+ }
40
+ else if (offset < -40 && rightActionControl) {
41
+ setOffset(-80);
42
+ }
43
+ else {
44
+ setOffset(0);
45
+ }
46
+ }
47
+ function handleAction(side) {
48
+ const control = side === 'left' ? leftActionControl : rightActionControl;
49
+ control?.onAction?.();
50
+ setOffset(0);
51
+ }
52
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("swipe-container", className), children: [(0, jsx_runtime_1.jsxs)("div", { onClick: () => handleAction('left'), className: (0, utils_1.cn)("swipe-left-action", leftActionControl?.className, offset > 0 ? "opacity-100" : "opacity-0"), children: [leftActionControl?.icon && (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: leftActionControl?.icon }), " ", leftActionControl?.label] }), (0, jsx_runtime_1.jsxs)("div", { onClick: () => handleAction('right'), className: (0, utils_1.cn)("swipe-right-action", rightActionControl?.className, offset < 0 ? "opacity-100" : "opacity-0"), children: [rightActionControl?.icon && (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: rightActionControl?.icon }), " ", rightActionControl?.label] }), (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("swipe-content", className), style: {
53
+ transform: `translateX(${offset}px)`,
54
+ transition: dragging ? "none" : "transform 0.2s ease",
55
+ }, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onTouchEnd, onClickCapture: (e) => {
56
+ if (offset !== 0) {
57
+ setOffset(0);
58
+ e.stopPropagation();
59
+ }
60
+ }, children: children })] }));
61
+ }
@@ -0,0 +1,93 @@
1
+ import { ReactNode } from "react";
2
+ import { ApiType, FormErrorType, FormRegisterType, FormValueType, ValidationRules, DBSchema } from "@utils";
3
+ import { InputProps, InputCheckboxProps, InputCurrencyProps, InputDateProps, InputNumberProps, InputRadioProps, SelectProps, InputPasswordProps, InputOtpProps, InputTimeProps, InputImageProps, InputDateTimeProps, InputMapProps } from "@components";
4
+ type formCustomConstructionProps = ({ formControl, values, setValues, setRegister, errors, setErrors, }: {
5
+ formControl: (name: string) => {
6
+ register: (regName: string, regValidations?: ValidationRules | undefined) => void;
7
+ unregister: (regName: string) => void;
8
+ onChange: (e: any) => void;
9
+ value: any;
10
+ invalid: any;
11
+ };
12
+ values: {
13
+ name: string;
14
+ value?: any;
15
+ }[];
16
+ setValues: (values: FormValueType[]) => void;
17
+ errors: FormErrorType[];
18
+ setErrors: (errors: FormErrorType[]) => void;
19
+ setRegister: (registers: FormRegisterType) => void;
20
+ prefixName?: string;
21
+ }) => ReactNode;
22
+ type ClusterConstruction = {
23
+ name: string;
24
+ label: string;
25
+ tip: string;
26
+ fields: FormType[];
27
+ wrap: boolean;
28
+ min?: number;
29
+ /** Use custom class with: "label::", "tip::", "error::", "icon::", "suggest::", "suggest-item::". */
30
+ className: string;
31
+ };
32
+ type ConstructionMap = {
33
+ default: InputProps;
34
+ check: InputCheckboxProps;
35
+ currency: InputCurrencyProps;
36
+ date: InputDateProps;
37
+ datetime: InputDateTimeProps;
38
+ time: InputTimeProps;
39
+ image: InputImageProps;
40
+ cluster: ClusterConstruction;
41
+ number: InputNumberProps;
42
+ radio: InputRadioProps;
43
+ select: SelectProps;
44
+ "enter-password": InputPasswordProps;
45
+ otp: InputOtpProps;
46
+ map: InputMapProps;
47
+ custom: formCustomConstructionProps;
48
+ };
49
+ type TypeKeys = keyof ConstructionMap;
50
+ export type WatchContext = {
51
+ values: Record<string, any>;
52
+ self: string;
53
+ prev: WatchAction;
54
+ };
55
+ export type WatchAction = {
56
+ disabled?: boolean;
57
+ hidden?: boolean;
58
+ value?: any;
59
+ required?: boolean;
60
+ readonly?: boolean;
61
+ reset?: boolean;
62
+ };
63
+ export interface FormType<T extends TypeKeys = keyof ConstructionMap> {
64
+ col?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | string;
65
+ className?: string;
66
+ construction?: ConstructionMap[T];
67
+ type?: T;
68
+ onHide?: (values: any) => boolean;
69
+ watch?: (ctx: WatchContext) => WatchAction | undefined;
70
+ }
71
+ export interface formSupervisionProps {
72
+ title?: string;
73
+ fields: FormType[];
74
+ confirmation?: boolean;
75
+ defaultValue?: object | null;
76
+ payload?: (values: any) => Promise<object> | object;
77
+ submitControl: (ApiType & {
78
+ idb?: never;
79
+ }) | {
80
+ idb: {
81
+ store: string;
82
+ schema?: DBSchema;
83
+ };
84
+ };
85
+ footerControl?: ({ loading }: {
86
+ loading: boolean;
87
+ }) => ReactNode;
88
+ onSuccess?: (data: any) => void;
89
+ onError?: (code: number) => void;
90
+ className?: string;
91
+ }
92
+ export declare function FormSupervisionComponent({ title, fields, submitControl, confirmation, defaultValue, onSuccess, onError, footerControl, payload, className, }: formSupervisionProps): import("react").JSX.Element;
93
+ export {};