@algorithm-shift/design-system 1.2.953 → 1.2.955

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
@@ -131,7 +131,7 @@ interface TabsProps extends ElementProps {
131
131
  tabs?: Record<string, any>;
132
132
  pathname?: string;
133
133
  verticalMenu?: boolean;
134
- canvasMode?: 'desktop' | 'tablet' | 'mobile';
134
+ canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
135
135
  isBuilder?: boolean;
136
136
  source?: string;
137
137
  parentKey?: string;
@@ -163,7 +163,7 @@ interface PieChartProps extends ElementProps {
163
163
  showPercentage?: boolean;
164
164
  showLegends?: boolean;
165
165
  labelType?: string;
166
- canvasMode?: 'desktop' | 'tablet' | 'mobile';
166
+ canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
167
167
  loading?: boolean;
168
168
  }
169
169
 
@@ -171,7 +171,7 @@ interface BarChartProps extends ElementProps {
171
171
  data?: Record<string, any>;
172
172
  chartType?: string;
173
173
  legendsPosition?: string;
174
- canvasMode?: 'desktop' | 'tablet' | 'mobile';
174
+ canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
175
175
  loading?: boolean;
176
176
  }
177
177
 
@@ -201,7 +201,7 @@ interface NavbarProps extends ElementProps {
201
201
  showName?: boolean;
202
202
  imageUrl?: string;
203
203
  altText?: string;
204
- canvasMode?: 'desktop' | 'tablet' | 'mobile' | string;
204
+ canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app' | string;
205
205
  list?: Record<string, any>;
206
206
  profileMenu?: Record<string, any>;
207
207
  userName?: string;
package/dist/index.d.ts CHANGED
@@ -131,7 +131,7 @@ interface TabsProps extends ElementProps {
131
131
  tabs?: Record<string, any>;
132
132
  pathname?: string;
133
133
  verticalMenu?: boolean;
134
- canvasMode?: 'desktop' | 'tablet' | 'mobile';
134
+ canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
135
135
  isBuilder?: boolean;
136
136
  source?: string;
137
137
  parentKey?: string;
@@ -163,7 +163,7 @@ interface PieChartProps extends ElementProps {
163
163
  showPercentage?: boolean;
164
164
  showLegends?: boolean;
165
165
  labelType?: string;
166
- canvasMode?: 'desktop' | 'tablet' | 'mobile';
166
+ canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
167
167
  loading?: boolean;
168
168
  }
169
169
 
@@ -171,7 +171,7 @@ interface BarChartProps extends ElementProps {
171
171
  data?: Record<string, any>;
172
172
  chartType?: string;
173
173
  legendsPosition?: string;
174
- canvasMode?: 'desktop' | 'tablet' | 'mobile';
174
+ canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
175
175
  loading?: boolean;
176
176
  }
177
177
 
@@ -201,7 +201,7 @@ interface NavbarProps extends ElementProps {
201
201
  showName?: boolean;
202
202
  imageUrl?: string;
203
203
  altText?: string;
204
- canvasMode?: 'desktop' | 'tablet' | 'mobile' | string;
204
+ canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app' | string;
205
205
  list?: Record<string, any>;
206
206
  profileMenu?: Record<string, any>;
207
207
  userName?: string;
package/dist/index.js CHANGED
@@ -28163,17 +28163,32 @@ var import_react23 = require("react");
28163
28163
  var import_react_international_phone = require("react-international-phone");
28164
28164
  var import_style = require("react-international-phone/style.css");
28165
28165
  var import_jsx_runtime40 = require("react/jsx-runtime");
28166
+ var ensureIndiaCode = (val) => {
28167
+ if (!val) return "";
28168
+ const trimmed = val.trim();
28169
+ if (trimmed.startsWith("+")) return trimmed;
28170
+ const local = trimmed.replace(/^0+/, "");
28171
+ return `+91${local}`;
28172
+ };
28166
28173
  var PhoneInput = ({ className, style, ...props }) => {
28167
28174
  const placeholder = props.placeholder ?? "Enter phone number";
28168
28175
  const isEditable = props.isEditable ?? true;
28169
28176
  const isDisabled = props.isDisabled ?? false;
28170
28177
  (0, import_react23.useEffect)(() => {
28171
28178
  if (props.value !== void 0) {
28172
- handleChange?.(props.value);
28179
+ const normalized = ensureIndiaCode(props.value);
28180
+ handleChange?.(normalized);
28173
28181
  }
28174
28182
  }, []);
28175
28183
  const handleChange = (val) => {
28176
- props.onChange?.(val, props?.name || "");
28184
+ const normalized = ensureIndiaCode(val);
28185
+ const event = {
28186
+ target: {
28187
+ name: props.name || "",
28188
+ value: normalized
28189
+ }
28190
+ };
28191
+ props.onChange?.(event, props.name || "");
28177
28192
  };
28178
28193
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
28179
28194
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
@@ -28181,7 +28196,7 @@ var PhoneInput = ({ className, style, ...props }) => {
28181
28196
  {
28182
28197
  defaultCountry: "in",
28183
28198
  name: props.name,
28184
- value: props.value || "",
28199
+ value: props.value ? ensureIndiaCode(props.value) : "",
28185
28200
  className: cn(
28186
28201
  "rounded-md border-1",
28187
28202
  className,
@@ -28191,7 +28206,7 @@ var PhoneInput = ({ className, style, ...props }) => {
28191
28206
  ...style,
28192
28207
  borderColor: props.errorMessage ? "#f87171" : style?.borderColor
28193
28208
  },
28194
- onChange: (phone) => handleChange(phone),
28209
+ onChange: handleChange,
28195
28210
  inputProps: {
28196
28211
  id: "phone-field",
28197
28212
  style: { width: "100%", border: "none", outline: "none" }
@@ -29367,6 +29382,8 @@ var useDynamicColumns = (config, customRenderers = {}, customFormatters = {}) =>
29367
29382
  return sanitizeValue(row[accessorKey]);
29368
29383
  };
29369
29384
  return columnHelper.accessor(accessorFn, {
29385
+ ...col,
29386
+ size: col.size > 0 ? col.size : 180,
29370
29387
  id: col.id ?? accessorKey,
29371
29388
  header: col.header,
29372
29389
  cell: (info) => {
@@ -29413,9 +29430,10 @@ function DataTable({
29413
29430
  const [columnVisibility, setColumnVisibility] = React10.useState({});
29414
29431
  const [manualSort, setManualSort] = React10.useState(null);
29415
29432
  const [searchTerm, setSearchTerm] = React10.useState("");
29433
+ const tableData = Array.isArray(data) ? data : [];
29416
29434
  const dynamicCols = useDynamicColumns({ columns });
29417
29435
  const table = (0, import_react_table2.useReactTable)({
29418
- data: data ?? [],
29436
+ data: tableData,
29419
29437
  columns: dynamicCols,
29420
29438
  state: {
29421
29439
  columnFilters,
@@ -29461,6 +29479,7 @@ function DataTable({
29461
29479
  }
29462
29480
  return [];
29463
29481
  };
29482
+ const pageCount = table.getPageCount() === 0 ? 1 : table.getPageCount();
29464
29483
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
29465
29484
  /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: `flex ${globalSearch ? "justify-between" : "justify-end"} p-2 bg-gray-50`, children: [
29466
29485
  globalSearch && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center gap-2 w-full max-w-sm", children: [
@@ -29538,88 +29557,100 @@ function DataTable({
29538
29557
  ] })
29539
29558
  ] })
29540
29559
  ] }),
29541
- /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Table3, { children: [
29560
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Table3, { className: "table-fixed", children: [
29542
29561
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableHeader, { children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: hg.headers.map((header, index) => {
29543
29562
  const canSort = header.column.getCanSort();
29544
29563
  const canFilter = header.column.getCanFilter();
29545
29564
  const sortDir = manualSort?.key === header.column.id ? manualSort.dir : null;
29546
- return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableHead, { className: "relative select-none", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between", children: [
29547
- /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
29548
- "span",
29549
- {
29550
- className: `flex items-center gap-1 ${canSort ? "cursor-pointer" : ""}`,
29551
- onClick: () => {
29552
- if (!canSort) return;
29553
- const newDir = manualSort?.key === header.column.id && manualSort.dir === "asc" ? "desc" : "asc";
29554
- setManualSort({ key: header.column.id, dir: newDir });
29555
- onSortChange?.(header.column.id, newDir);
29556
- },
29557
- children: [
29558
- (0, import_react_table2.flexRender)(header.column.columnDef.header, header.getContext()),
29559
- canSort && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
29560
- sortDir === "asc" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ArrowUp, { size: 14, className: "text-gray-500" }),
29561
- sortDir === "desc" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ArrowDown, { size: 14, className: "text-gray-500" }),
29562
- !sortDir && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ArrowUpDown, { size: 14, className: "text-gray-400" })
29563
- ] })
29564
- ]
29565
- }
29566
- ),
29567
- canFilter && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Popover, { children: [
29568
- /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29569
- "span",
29570
- {
29571
- role: "presentation",
29572
- className: "pl-5 cursor-pointer",
29573
- onClick: (e) => e.stopPropagation(),
29574
- children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEllipsisH, className: "w-5 h-5 text-gray-500" })
29575
- }
29576
- ) }),
29577
- /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29578
- PopoverContent,
29579
- {
29580
- align: "center",
29581
- sideOffset: 14,
29582
- className: "w-50 p-3 z-[200] border-gray-300",
29583
- avoidCollisions: true,
29584
- children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
29585
- "form",
29565
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29566
+ TableHead,
29567
+ {
29568
+ className: "relative select-none",
29569
+ style: {
29570
+ width: header.column.getSize(),
29571
+ minWidth: header.column.columnDef.minSize,
29572
+ maxWidth: header.column.columnDef.maxSize
29573
+ },
29574
+ children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between", children: [
29575
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
29576
+ "span",
29577
+ {
29578
+ className: `flex items-center gap-1 ${canSort ? "cursor-pointer" : ""}`,
29579
+ onClick: () => {
29580
+ if (!canSort) return;
29581
+ const newDir = manualSort?.key === header.column.id && manualSort.dir === "asc" ? "desc" : "asc";
29582
+ setManualSort({ key: header.column.id, dir: newDir });
29583
+ onSortChange?.(header.column.id, newDir);
29584
+ },
29585
+ children: [
29586
+ (0, import_react_table2.flexRender)(header.column.columnDef.header, header.getContext()),
29587
+ canSort && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
29588
+ sortDir === "asc" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ArrowUp, { size: 14, className: "text-gray-500" }),
29589
+ sortDir === "desc" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ArrowDown, { size: 14, className: "text-gray-500" }),
29590
+ !sortDir && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ArrowUpDown, { size: 14, className: "text-gray-400" })
29591
+ ] })
29592
+ ]
29593
+ }
29594
+ ),
29595
+ canFilter && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Popover, { children: [
29596
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29597
+ "span",
29598
+ {
29599
+ role: "presentation",
29600
+ className: "pl-5 cursor-pointer",
29601
+ onClick: (e) => e.stopPropagation(),
29602
+ children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEllipsisH, className: "w-5 h-5 text-gray-500" })
29603
+ }
29604
+ ) }),
29605
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29606
+ PopoverContent,
29586
29607
  {
29587
- onSubmit: (e) => {
29588
- e.preventDefault();
29589
- const formData = new FormData(e.currentTarget);
29590
- const value = formData.get("filter") || "";
29591
- if (onFilterChange && value) {
29592
- onFilterChange({ columnKey: header.column.id, columnTerm: value });
29608
+ align: "center",
29609
+ sideOffset: 14,
29610
+ className: "w-50 p-3 z-[200] border-gray-300",
29611
+ avoidCollisions: true,
29612
+ children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
29613
+ "form",
29614
+ {
29615
+ onSubmit: (e) => {
29616
+ e.preventDefault();
29617
+ const formData = new FormData(e.currentTarget);
29618
+ const value = formData.get("filter") || "";
29619
+ if (onFilterChange && value) {
29620
+ onFilterChange({ columnKey: header.column.id, columnTerm: value });
29621
+ }
29622
+ },
29623
+ className: "space-y-2",
29624
+ children: [
29625
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("label", { htmlFor: "filter", className: "text-xs text-gray-500 font-normal", children: "Filter by value:" }),
29626
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29627
+ "input",
29628
+ {
29629
+ name: "filter",
29630
+ placeholder: "Search",
29631
+ defaultValue: header.column.getFilterValue() ?? "",
29632
+ className: "border-gray-300 border-1 block p-3 rounded-md text-xs w-full h-9 focus:ring-0 focus:border-gray-300 focus-visible:ring-0 focus-visible:border-gray-300 focus-visible:outline-none mt-2 font-normal",
29633
+ autoComplete: "off"
29634
+ }
29635
+ ),
29636
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "justify-end flex", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29637
+ Button,
29638
+ {
29639
+ type: "submit",
29640
+ className: "py-2 px-3 bg-[#12715B] text-white text-xs h-auto cursor-pointer",
29641
+ children: "Apply"
29642
+ }
29643
+ ) })
29644
+ ]
29593
29645
  }
29594
- },
29595
- className: "space-y-2",
29596
- children: [
29597
- /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("label", { htmlFor: "filter", className: "text-xs text-gray-500 font-normal", children: "Filter by value:" }),
29598
- /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29599
- "input",
29600
- {
29601
- name: "filter",
29602
- placeholder: "Search",
29603
- defaultValue: header.column.getFilterValue() ?? "",
29604
- className: "border-gray-300 border-1 block p-3 rounded-md text-xs w-full h-9 focus:ring-0 focus:border-gray-300 focus-visible:ring-0 focus-visible:border-gray-300 focus-visible:outline-none mt-2 font-normal",
29605
- autoComplete: "off"
29606
- }
29607
- ),
29608
- /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "justify-end flex", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
29609
- Button,
29610
- {
29611
- type: "submit",
29612
- className: "py-2 px-3 bg-[#12715B] text-white text-xs h-auto cursor-pointer",
29613
- children: "Apply"
29614
- }
29615
- ) })
29616
- ]
29646
+ )
29617
29647
  }
29618
29648
  )
29619
- }
29620
- )
29621
- ] })
29622
- ] }) }, `header-${header.id}-${index}`);
29649
+ ] })
29650
+ ] })
29651
+ },
29652
+ `header-${header.id}-${index}`
29653
+ );
29623
29654
  }) }, `header-group-${hg.id}`)) }),
29624
29655
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableBody, { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: dynamicCols.map((_2, j) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { className: "p-3", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "h-4 bg-gray-200 rounded w-3/4 block animate-pulse" }) }, j)) }, i)) }) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
29625
29656
  const meta = cell.column.columnDef.meta || {};
@@ -29628,8 +29659,13 @@ function DataTable({
29628
29659
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
29629
29660
  TableCell,
29630
29661
  {
29631
- className: `${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative`,
29632
- style: meta?.cellStyle,
29662
+ className: `${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative py-2`,
29663
+ style: {
29664
+ width: cell.column.getSize(),
29665
+ minWidth: cell.column.columnDef.minSize,
29666
+ maxWidth: cell.column.columnDef.maxSize,
29667
+ ...meta?.cellStyle ?? {}
29668
+ },
29633
29669
  onClick: () => {
29634
29670
  if (isClickable && onCellClick) {
29635
29671
  onCellClick(cell.row.original, cell.column.id);
@@ -29668,7 +29704,7 @@ function DataTable({
29668
29704
  "Page ",
29669
29705
  table.getState().pagination.pageIndex + 1,
29670
29706
  " of ",
29671
- table.getPageCount()
29707
+ pageCount
29672
29708
  ] }),
29673
29709
  /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center gap-2", children: [
29674
29710
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
@@ -30015,7 +30051,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30015
30051
  if (source === "manual") return Array.isArray(tabs) ? tabs : [];
30016
30052
  return groupMenus(tabs);
30017
30053
  }, [tabs, source, parentKey, menuNameKey, menuUrlKey]);
30018
- const baseClasses = "text-[12px] text-foreground p-2 text-center rounded-md transition-colors";
30054
+ const baseClasses = "text-foreground p-2 text-center rounded-md transition-colors";
30019
30055
  const activeClasses = "bg-white/10 text-white";
30020
30056
  const hoverClasses = "hover:bg-white/5";
30021
30057
  const isActive = (path) => {
@@ -30085,7 +30121,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30085
30121
  DropdownMenuItem,
30086
30122
  {
30087
30123
  asChild: true,
30088
- className: "cursor-pointer rounded-sm px-3 py-2 text-[12px] text-gray-800 hover:bg-gray-100 focus:bg-gray-100",
30124
+ className: "cursor-pointer rounded-sm px-3 py-2 text-gray-800 hover:bg-gray-100 focus:bg-gray-100",
30089
30125
  children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
30090
30126
  import_link5.default,
30091
30127
  {
@@ -30138,7 +30174,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30138
30174
  DropdownMenuItem,
30139
30175
  {
30140
30176
  asChild: true,
30141
- className: "cursor-pointer rounded-sm px-3 py-2 text-[12px] text-gray-800 hover:bg-gray-100",
30177
+ className: "cursor-pointer rounded-sm px-3 py-2 text-gray-800 hover:bg-gray-100",
30142
30178
  children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_link5.default, { href: item.url || "#", onClick: (e) => handleBuilderExit(e, item.url || "#"), children: item.header })
30143
30179
  },
30144
30180
  item.id || index