@algorithm-shift/design-system 1.2.67 → 1.2.69

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/index.d.mts CHANGED
@@ -3,6 +3,18 @@ import React$1 from 'react';
3
3
  import { ToasterProps } from 'sonner';
4
4
  import { ClassValue } from 'clsx';
5
5
 
6
+ interface ModalProps {
7
+ isOpen: boolean;
8
+ onClose?: () => void;
9
+ title: string;
10
+ children: React$1.ReactNode;
11
+ size?: 'sm' | 'md' | 'lg' | 'xl';
12
+ showCloseButton?: boolean;
13
+ className?: string;
14
+ style?: React$1.CSSProperties;
15
+ }
16
+ declare function Modal({ isOpen, onClose, title, children, size, showCloseButton, className, style }: ModalProps): react_jsx_runtime.JSX.Element | null;
17
+
6
18
  interface ElementProps {
7
19
  children?: React.ReactNode;
8
20
  className?: string;
@@ -144,12 +156,6 @@ interface BarChartProps extends ElementProps {
144
156
  loading?: boolean;
145
157
  }
146
158
 
147
- interface ModalProps extends ElementProps {
148
- label?: string;
149
- showModal: boolean;
150
- onModalClose?: (show: boolean) => void;
151
- }
152
-
153
159
  interface EmailComposerProps extends ElementProps {
154
160
  to?: string;
155
161
  setTo?: (to: string) => void;
@@ -211,8 +217,6 @@ interface TabGroupProps extends ElementProps {
211
217
  onTabChange?: (tabId: string) => void;
212
218
  }
213
219
 
214
- declare const Modal: ({ children, className, style, showModal, onModalClose, label }: ModalProps) => react_jsx_runtime.JSX.Element | null;
215
-
216
220
  declare const Flex: ({ children, className, style, ...props }: ElementProps) => react_jsx_runtime.JSX.Element;
217
221
 
218
222
  declare const Grid: ({ children, className, style, ...props }: ElementProps) => react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,18 @@ import React$1 from 'react';
3
3
  import { ToasterProps } from 'sonner';
4
4
  import { ClassValue } from 'clsx';
5
5
 
6
+ interface ModalProps {
7
+ isOpen: boolean;
8
+ onClose?: () => void;
9
+ title: string;
10
+ children: React$1.ReactNode;
11
+ size?: 'sm' | 'md' | 'lg' | 'xl';
12
+ showCloseButton?: boolean;
13
+ className?: string;
14
+ style?: React$1.CSSProperties;
15
+ }
16
+ declare function Modal({ isOpen, onClose, title, children, size, showCloseButton, className, style }: ModalProps): react_jsx_runtime.JSX.Element | null;
17
+
6
18
  interface ElementProps {
7
19
  children?: React.ReactNode;
8
20
  className?: string;
@@ -144,12 +156,6 @@ interface BarChartProps extends ElementProps {
144
156
  loading?: boolean;
145
157
  }
146
158
 
147
- interface ModalProps extends ElementProps {
148
- label?: string;
149
- showModal: boolean;
150
- onModalClose?: (show: boolean) => void;
151
- }
152
-
153
159
  interface EmailComposerProps extends ElementProps {
154
160
  to?: string;
155
161
  setTo?: (to: string) => void;
@@ -211,8 +217,6 @@ interface TabGroupProps extends ElementProps {
211
217
  onTabChange?: (tabId: string) => void;
212
218
  }
213
219
 
214
- declare const Modal: ({ children, className, style, showModal, onModalClose, label }: ModalProps) => react_jsx_runtime.JSX.Element | null;
215
-
216
220
  declare const Flex: ({ children, className, style, ...props }: ElementProps) => react_jsx_runtime.JSX.Element;
217
221
 
218
222
  declare const Grid: ({ children, className, style, ...props }: ElementProps) => react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ __export(src_exports, {
49
49
  GridLayout: () => Grid_default,
50
50
  Icon: () => Icon_default,
51
51
  Image: () => Image_default,
52
- Modal: () => Modal_default,
52
+ Modal: () => Modal,
53
53
  MultiCheckbox: () => MultiCheckbox_default,
54
54
  Navbar: () => Navbar,
55
55
  NumberInput: () => NumberInput_default,
@@ -83,45 +83,88 @@ module.exports = __toCommonJS(src_exports);
83
83
 
84
84
  // src/components/Layout/Modal.tsx
85
85
  var import_react = require("react");
86
+ var import_free_solid_svg_icons = require("@fortawesome/free-solid-svg-icons");
87
+ var import_react_fontawesome = require("@fortawesome/react-fontawesome");
88
+
89
+ // src/lib/utils.ts
90
+ var import_clsx = require("clsx");
91
+ var import_tailwind_merge = require("tailwind-merge");
92
+ function cn(...inputs) {
93
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
94
+ }
95
+ function getInitials(name) {
96
+ const words = name.split(" ");
97
+ if (words.length === 0) {
98
+ return "";
99
+ }
100
+ if (words.length === 1) {
101
+ return words[0].charAt(0);
102
+ }
103
+ return words[0].charAt(0) + words[1].charAt(0);
104
+ }
105
+
106
+ // src/components/Layout/Modal.tsx
86
107
  var import_jsx_runtime = require("react/jsx-runtime");
87
- var Modal = ({
108
+ function Modal({
109
+ isOpen,
110
+ onClose,
111
+ title,
88
112
  children,
89
- className,
90
- style,
91
- showModal,
92
- onModalClose,
93
- label
94
- }) => {
113
+ size = "md",
114
+ showCloseButton = true,
115
+ className = "",
116
+ style = {}
117
+ }) {
95
118
  (0, import_react.useEffect)(() => {
96
- if (showModal) {
97
- const wrapper = document.getElementById("canvas-wrapper") || document.getElementById("canvas-preview");
98
- if (!wrapper) return;
99
- const overlay = document.createElement("div");
100
- overlay.className = "absolute flex inset-0 bg-black opacity-50 z-10 w-full h-full";
101
- wrapper.appendChild(overlay);
102
- return () => {
103
- if (wrapper.contains(overlay)) wrapper.removeChild(overlay);
104
- };
105
- }
106
- }, [showModal]);
107
- if (!showModal) return null;
108
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${className} top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 shadow-lg rounded-md z-90 bg-[#fff] `, style: { position: "fixed", ...style }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-h-80", children: [
109
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex justify-between items-center p-4 border-b border-gray-300 bg-gray-100", children: [
110
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { className: "text-[#000]", children: label || "Modal Title" }),
111
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
112
- "span",
113
- {
114
- className: "cursor-pointer text-[#000]",
115
- role: "presentation",
116
- onClick: () => onModalClose && onModalClose(false),
117
- children: "X"
118
- }
119
- )
120
- ] }),
121
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-90 overflow-y-auto p-4 custom-scroll", children })
122
- ] }) });
123
- };
124
- var Modal_default = Modal;
119
+ const handleEscape = (e) => {
120
+ if (e.key === "Escape") {
121
+ onClose?.();
122
+ }
123
+ };
124
+ if (isOpen) {
125
+ document.addEventListener("keydown", handleEscape);
126
+ document.body.style.overflow = "hidden";
127
+ }
128
+ return () => {
129
+ document.removeEventListener("keydown", handleEscape);
130
+ document.body.style.overflow = "unset";
131
+ };
132
+ }, [isOpen, onClose]);
133
+ if (!isOpen) return null;
134
+ const sizeClasses = {
135
+ sm: "w-md",
136
+ md: "w-lg",
137
+ lg: "w-2xl",
138
+ xl: "w-4xl"
139
+ };
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 shadow-lg rounded-md z-90", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
141
+ "div",
142
+ {
143
+ className: cn(
144
+ "bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-h-[90vh] overflow-hidden",
145
+ `bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full ${sizeClasses[size]} max-h-[90vh] overflow-hidden`,
146
+ className,
147
+ `${sizeClasses[size]}`
148
+ ),
149
+ style,
150
+ children: [
151
+ (title || showCloseButton) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between p-4 py-3 border-b border-gray-200 dark:border-gray-700", children: [
152
+ title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: title }),
153
+ showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
154
+ "button",
155
+ {
156
+ onClick: onClose,
157
+ className: "text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors cursor-pointer",
158
+ "aria-label": "Close modal",
159
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_fontawesome.FontAwesomeIcon, { icon: import_free_solid_svg_icons.faTimes, className: "w-5 h-5" })
160
+ }
161
+ )
162
+ ] }),
163
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "p-4 py-3 overflow-y-auto max-h-[calc(90vh-140px)] min-h-[90px]", children })
164
+ ]
165
+ }
166
+ ) });
167
+ }
125
168
 
126
169
  // src/components/Layout/Flex.tsx
127
170
  var import_jsx_runtime2 = require("react/jsx-runtime");
@@ -243,11 +286,13 @@ function TabGroupComponent({
243
286
  activeTab,
244
287
  onTabChange
245
288
  }) {
289
+ const [mounted, setMounted] = (0, import_react3.useState)(false);
246
290
  (0, import_react3.useEffect)(() => {
247
- if (list && list.length > 0 && !activeTab && onTabChange) {
291
+ if (list && list.length > 0 && !activeTab && onTabChange && !mounted) {
248
292
  onTabChange(list[0]?.tabId);
293
+ setMounted(true);
249
294
  }
250
- }, [list, activeTab, onTabChange]);
295
+ }, [list, activeTab, onTabChange, mounted]);
251
296
  const formatedList = (0, import_react3.useMemo)(
252
297
  () => Array.isArray(list) ? [...list].sort((a, b) => (a.orderNumber ?? 0) - (b.orderNumber ?? 0)) : [],
253
298
  [list]
@@ -270,25 +315,6 @@ function TabGroupComponent({
270
315
  // src/components/ui/button.tsx
271
316
  var import_react_slot = require("@radix-ui/react-slot");
272
317
  var import_class_variance_authority = require("class-variance-authority");
273
-
274
- // src/lib/utils.ts
275
- var import_clsx = require("clsx");
276
- var import_tailwind_merge = require("tailwind-merge");
277
- function cn(...inputs) {
278
- return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
279
- }
280
- function getInitials(name) {
281
- const words = name.split(" ");
282
- if (words.length === 0) {
283
- return "";
284
- }
285
- if (words.length === 1) {
286
- return words[0].charAt(0);
287
- }
288
- return words[0].charAt(0) + words[1].charAt(0);
289
- }
290
-
291
- // src/components/ui/button.tsx
292
318
  var import_jsx_runtime10 = require("react/jsx-runtime");
293
319
  var buttonVariants = (0, import_class_variance_authority.cva)(
294
320
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
@@ -26889,7 +26915,7 @@ function SplitButton({ style, textContent, className, list = [] }) {
26889
26915
 
26890
26916
  // src/components/Basic/Icon/Icon.tsx
26891
26917
  var faSolid = __toESM(require("@fortawesome/free-solid-svg-icons"));
26892
- var import_react_fontawesome = require("@fortawesome/react-fontawesome");
26918
+ var import_react_fontawesome2 = require("@fortawesome/react-fontawesome");
26893
26919
  var import_jsx_runtime17 = require("react/jsx-runtime");
26894
26920
  var Icon2 = ({ iconType = "fontawesome", name = "Envelope", className, fontSize = 10, style }) => {
26895
26921
  let content = null;
@@ -26900,7 +26926,7 @@ var Icon2 = ({ iconType = "fontawesome", name = "Envelope", className, fontSize
26900
26926
  return null;
26901
26927
  }
26902
26928
  content = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
26903
- import_react_fontawesome.FontAwesomeIcon,
26929
+ import_react_fontawesome2.FontAwesomeIcon,
26904
26930
  {
26905
26931
  icon: faIcon,
26906
26932
  className: cn("inline-block"),
@@ -28006,7 +28032,7 @@ var import_react24 = __toESM(require("react"));
28006
28032
  var import_date_fns = require("date-fns");
28007
28033
 
28008
28034
  // src/components/ui/calendar.tsx
28009
- var React4 = __toESM(require("react"));
28035
+ var React5 = __toESM(require("react"));
28010
28036
  var import_react_day_picker = require("react-day-picker");
28011
28037
  var import_jsx_runtime42 = require("react/jsx-runtime");
28012
28038
  function Calendar2({
@@ -28161,8 +28187,8 @@ function CalendarDayButton({
28161
28187
  ...props
28162
28188
  }) {
28163
28189
  const defaultClassNames = (0, import_react_day_picker.getDefaultClassNames)();
28164
- const ref = React4.useRef(null);
28165
- React4.useEffect(() => {
28190
+ const ref = React5.useRef(null);
28191
+ React5.useEffect(() => {
28166
28192
  if (modifiers.focused) ref.current?.focus();
28167
28193
  }, [modifiers.focused]);
28168
28194
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
@@ -28338,9 +28364,9 @@ var TextInputGroup = ({ className, style, prepend, append, ...props }) => {
28338
28364
  var TextInputGroup_default = TextInputGroup;
28339
28365
 
28340
28366
  // src/components/ui/data-table.tsx
28341
- var React6 = __toESM(require("react"));
28342
- var import_free_solid_svg_icons = require("@fortawesome/free-solid-svg-icons");
28343
- var import_react_fontawesome2 = require("@fortawesome/react-fontawesome");
28367
+ var React7 = __toESM(require("react"));
28368
+ var import_free_solid_svg_icons2 = require("@fortawesome/free-solid-svg-icons");
28369
+ var import_react_fontawesome3 = require("@fortawesome/react-fontawesome");
28344
28370
  var import_react_table = require("@tanstack/react-table");
28345
28371
 
28346
28372
  // src/components/ui/table.tsx
@@ -28445,10 +28471,10 @@ function DataTable({
28445
28471
  onGlobalSearch,
28446
28472
  globalSearch
28447
28473
  }) {
28448
- const [columnFilters, setColumnFilters] = React6.useState([]);
28449
- const [columnVisibility, setColumnVisibility] = React6.useState({});
28450
- const [manualSort, setManualSort] = React6.useState(null);
28451
- const [searchTerm, setSearchTerm] = React6.useState("");
28474
+ const [columnFilters, setColumnFilters] = React7.useState([]);
28475
+ const [columnVisibility, setColumnVisibility] = React7.useState({});
28476
+ const [manualSort, setManualSort] = React7.useState(null);
28477
+ const [searchTerm, setSearchTerm] = React7.useState("");
28452
28478
  const table = (0, import_react_table.useReactTable)({
28453
28479
  data,
28454
28480
  columns,
@@ -28602,7 +28628,7 @@ function DataTable({
28602
28628
  role: "presentation",
28603
28629
  className: "pl-5 cursor-pointer",
28604
28630
  onClick: (e) => e.stopPropagation(),
28605
- children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons.faEllipsisH, className: "w-5 h-5 text-gray-500" })
28631
+ children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEllipsisH, className: "w-5 h-5 text-gray-500" })
28606
28632
  }
28607
28633
  ) }),
28608
28634
  /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
@@ -29082,10 +29108,10 @@ var import_jsx_runtime55 = require("react/jsx-runtime");
29082
29108
  var import_jsx_runtime56 = require("react/jsx-runtime");
29083
29109
 
29084
29110
  // src/components/ui/avatar.tsx
29085
- var React8 = __toESM(require("react"));
29111
+ var React9 = __toESM(require("react"));
29086
29112
  var AvatarPrimitive = __toESM(require("@radix-ui/react-avatar"));
29087
29113
  var import_jsx_runtime57 = require("react/jsx-runtime");
29088
- var Avatar = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
29114
+ var Avatar = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
29089
29115
  AvatarPrimitive.Root,
29090
29116
  {
29091
29117
  ref,
@@ -29097,7 +29123,7 @@ var Avatar = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
29097
29123
  }
29098
29124
  ));
29099
29125
  Avatar.displayName = AvatarPrimitive.Root.displayName;
29100
- var AvatarImage = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
29126
+ var AvatarImage = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
29101
29127
  AvatarPrimitive.Image,
29102
29128
  {
29103
29129
  ref,
@@ -29106,7 +29132,7 @@ var AvatarImage = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE
29106
29132
  }
29107
29133
  ));
29108
29134
  AvatarImage.displayName = AvatarPrimitive.Image.displayName;
29109
- var AvatarFallback = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
29135
+ var AvatarFallback = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
29110
29136
  AvatarPrimitive.Fallback,
29111
29137
  {
29112
29138
  ref,