@axzydev/axzy_ui_system 1.3.1 → 1.3.2
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/README.md +6 -2
- package/dist/index.cjs +930 -544
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +187 -9
- package/dist/index.d.ts +187 -9
- package/dist/index.js +881 -495
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +150 -154
- package/src/components/molecules/table/table.doc.mdx +64 -21
- package/src/components/molecules/table/table.props.ts +81 -2
- package/src/components/molecules/table/table.stories.tsx +155 -0
- package/src/components/molecules/table/table.tsx +177 -36
- package/src/components/organisms/data-table/ITDataTable.doc.mdx +37 -3
- package/src/components/organisms/data-table/ITDataTable.stories.tsx +43 -0
- package/src/components/organisms/data-table/dataTable.props.ts +64 -0
- package/src/components/organisms/data-table/dataTable.tsx +240 -82
- package/src/components/organisms/sidebar/sidebar.doc.mdx +5 -0
- package/src/components/organisms/sidebar/sidebar.props.ts +5 -0
- package/src/components/organisms/sidebar/sidebar.stories.tsx +1 -1
- package/src/components/organisms/sidebar/sidebar.tsx +27 -7
- package/src/components/organisms/topbar/topbar.doc.mdx +3 -0
- package/src/components/organisms/topbar/topbar.props.ts +16 -0
- package/src/components/organisms/topbar/topbar.tsx +133 -98
- package/src/components/templates/layout/layout.doc.mdx +2 -0
- package/src/components/templates/layout/layout.tsx +7 -1
- package/src/components/templates/page/page.doc.mdx +8 -2
- package/src/components/templates/page/page.props.ts +11 -1
- package/src/components/templates/page/page.tsx +11 -1
- package/src/dev.css +58 -1
- package/src/hooks/useElementSize.ts +46 -0
- package/src/hooks/useVirtualRows.ts +123 -0
- package/src/index.ts +2 -0
- package/src/sandbox/LandingShowcase.tsx +465 -0
- package/src/sandbox/NotFoundShowcase.tsx +70 -0
- package/src/sandbox/TopbarSearch.tsx +85 -0
- package/src/sandbox/navigation.ts +148 -0
- package/src/sandbox/useHashRoute.ts +149 -0
- package/src/showcases/DataShowcases.tsx +321 -24
- package/src/showcases/PageShowcases.tsx +31 -0
- package/src/showcases/StructureShowcases.tsx +42 -4
- package/src/types/table.types.ts +48 -0
- package/src/utils/styles.ts +9 -4
- package/src/utils/table.utils.ts +31 -0
package/src/types/table.types.ts
CHANGED
|
@@ -13,3 +13,51 @@ export const sizeStyles: Record<TableSize, string> = {
|
|
|
13
13
|
md: "text-sm",
|
|
14
14
|
lg: "text-lg",
|
|
15
15
|
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Cell padding / row-height preset for tables. Independent of `TableSize`
|
|
19
|
+
* (which only controls font-size, and shifts the row height via the line box).
|
|
20
|
+
*/
|
|
21
|
+
export type TableDensity = "compact" | "normal" | "comfortable";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Padding classes and target row height per density. `normal` MUST stay
|
|
25
|
+
* byte-identical to the historical hard-coded `px-4 py-4` / `px-4 py-3`.
|
|
26
|
+
*
|
|
27
|
+
* The `rowHeight` values are the `size="md"` baseline:
|
|
28
|
+
* rowHeight = cell vertical padding + text-sm line box (20px) + 1px divide-y border.
|
|
29
|
+
* compact: py-1.5 (12) + 20 + 1 = 33 · normal: py-3 (24) + 20 + 1 = 45 · comfortable: py-4 (32) + 20 + 1 = 53
|
|
30
|
+
*
|
|
31
|
+
* `size` shifts that baseline via the font-size line box; use
|
|
32
|
+
* `getRowHeight(size, density)` for the real rendered row height.
|
|
33
|
+
*/
|
|
34
|
+
export const densityStyles: Record<
|
|
35
|
+
TableDensity,
|
|
36
|
+
{ header: string; cell: string; rowHeight: number }
|
|
37
|
+
> = {
|
|
38
|
+
compact: { header: "px-3 py-2", cell: "px-3 py-1.5", rowHeight: 33 },
|
|
39
|
+
normal: { header: "px-4 py-4", cell: "px-4 py-3", rowHeight: 45 },
|
|
40
|
+
comfortable: { header: "px-4 py-5", cell: "px-4 py-4", rowHeight: 53 },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Line box (px) contributed by the `size` prop's font-size class (`text-xs|sm|lg`). */
|
|
44
|
+
export const sizeLineHeights: Record<TableSize, number> = { sm: 16, md: 20, lg: 28 };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Row height (px) for a given `size` + `density`, matching the real rendered
|
|
48
|
+
* row: cell vertical padding + the size line box + 1px divide-y border.
|
|
49
|
+
* `densityStyles[density].rowHeight` is the `md` baseline.
|
|
50
|
+
*/
|
|
51
|
+
export function getRowHeight(size: TableSize, density: TableDensity): number {
|
|
52
|
+
return densityStyles[density].rowHeight - sizeLineHeights.md + sizeLineHeights[size];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Static horizontal alignment classes for columns. Kept as full literal
|
|
57
|
+
* strings so Tailwind's scanner can see them (never build them dynamically).
|
|
58
|
+
*/
|
|
59
|
+
export const tableAlignClasses: Record<"left" | "center" | "right", string> = {
|
|
60
|
+
left: "text-left",
|
|
61
|
+
center: "text-center",
|
|
62
|
+
right: "text-right",
|
|
63
|
+
};
|
package/src/utils/styles.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
2
|
import type { CSSProperties } from "react";
|
|
3
3
|
import { inputSizeTokens } from "@/theme/theme";
|
|
4
|
+
import { densityStyles, type TableDensity } from "@/types/table.types";
|
|
4
5
|
|
|
5
6
|
/** Theme shape expected from `theme.input` (used by input-like components). */
|
|
6
7
|
export type InputThemeLike = {
|
|
@@ -76,8 +77,8 @@ export const tableContainer = "rounded-xl shadow-sm border border-secondary-200
|
|
|
76
77
|
|
|
77
78
|
export const tableHeaderRow = "bg-secondary-50 border-b border-secondary-200 text-xs uppercase tracking-wider font-semibold text-secondary-500";
|
|
78
79
|
|
|
79
|
-
export function tableHeaderCell(className?: string) {
|
|
80
|
-
return clsx("
|
|
80
|
+
export function tableHeaderCell(className?: string, density: TableDensity = "normal") {
|
|
81
|
+
return clsx(densityStyles[density].header, "align-top", className);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
export const tableSortButtonActive = "bg-secondary-200 text-secondary-900";
|
|
@@ -87,8 +88,12 @@ export const tableBody = "divide-y divide-secondary-100";
|
|
|
87
88
|
|
|
88
89
|
export const tableRow = "hover:bg-secondary-50/50 transition-colors duration-150 group";
|
|
89
90
|
|
|
90
|
-
export
|
|
91
|
-
|
|
91
|
+
export const tableRowClickable = "cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-inset";
|
|
92
|
+
|
|
93
|
+
export const tableCardClickable = "cursor-pointer rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500";
|
|
94
|
+
|
|
95
|
+
export function tableCell(className?: string, density: TableDensity = "normal") {
|
|
96
|
+
return clsx(densityStyles[density].cell, "align-middle", className);
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
export const tableActionsCell = "flex items-center justify-center gap-2";
|
package/src/utils/table.utils.ts
CHANGED
|
@@ -8,3 +8,34 @@ export const formatCurrencyMX = (value: number) => {
|
|
|
8
8
|
export const getNestedValue = (obj: any, path: string) => {
|
|
9
9
|
return path.split('.').reduce((acc, part) => acc && acc[part], obj);
|
|
10
10
|
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* CSS selector matching any element that should swallow a row/card click
|
|
14
|
+
* instead of letting it bubble up to the row activation handler. Covers native
|
|
15
|
+
* interactive elements plus anything explicitly opted out with
|
|
16
|
+
* `data-row-click-ignore`.
|
|
17
|
+
*/
|
|
18
|
+
export const ROW_CLICK_IGNORE_SELECTOR =
|
|
19
|
+
'button, a, input, select, textarea, [role="button"], [role="link"], [data-row-click-ignore]';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns `true` when the event target (or one of its ancestors) is an
|
|
23
|
+
* interactive element that must not trigger the row/card `onRowClick` handler.
|
|
24
|
+
*
|
|
25
|
+
* @param target - The event target to inspect (usually `event.target`).
|
|
26
|
+
* @param boundary - Optional activation container (usually `event.currentTarget`).
|
|
27
|
+
* When the matched interactive element is the boundary itself it is ignored,
|
|
28
|
+
* because the cards-view wrapper carries `role="button"` for accessibility and
|
|
29
|
+
* would otherwise swallow its own activation. Only interactive descendants
|
|
30
|
+
* block the handler.
|
|
31
|
+
*/
|
|
32
|
+
export function isInteractiveTarget(
|
|
33
|
+
target: EventTarget | null,
|
|
34
|
+
boundary: EventTarget | null = null
|
|
35
|
+
): boolean {
|
|
36
|
+
if (!(target instanceof Element)) return false;
|
|
37
|
+
const interactive = target.closest(ROW_CLICK_IGNORE_SELECTOR);
|
|
38
|
+
if (!interactive) return false;
|
|
39
|
+
if (boundary instanceof Node && interactive === boundary) return false;
|
|
40
|
+
return true;
|
|
41
|
+
}
|