@krosoft/react 0.0.381 → 0.0.383
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/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/core/cards/DashboardCard.js +18 -0
- package/dist/components/core/cards/KpiCard.js +36 -0
- package/dist/components/core/cards/KpiCards.js +29 -0
- package/dist/components/core/cards/MetricCard.js +63 -0
- package/dist/components/core/cards/SkeletonCard.js +13 -0
- package/dist/components/core/cards/SkeletonCards.js +11 -0
- package/dist/components/core/cards/index.js +7 -1
- package/dist/components/core/changelog/AppChangelog.js +123 -0
- package/dist/components/core/changelog/AppChangelogEntry.js +85 -0
- package/dist/components/core/changelog/AppChangelogNav.js +39 -0
- package/dist/components/core/changelog/AppChangelogTagFilter.js +39 -0
- package/dist/components/core/changelog/index.js +1 -1
- package/dist/components/core/charts/BarChartHorizontal.js +80 -0
- package/dist/components/core/charts/BarChartVertical.js +68 -0
- package/dist/components/core/charts/ChartCard.js +44 -0
- package/dist/components/core/charts/CircularGauge.js +58 -0
- package/dist/components/core/charts/LineChart.js +69 -0
- package/dist/components/core/charts/PieChart.js +55 -0
- package/dist/components/core/charts/chartColors.js +10 -0
- package/dist/components/core/charts/chartTooltip.helper.js +15 -0
- package/dist/components/core/charts/index.js +8 -1
- package/dist/components/core/dialogs/AboutDialog.js +59 -0
- package/dist/components/core/dialogs/AppDialog.js +81 -0
- package/dist/components/core/dialogs/ConfirmationDialog.js +42 -0
- package/dist/components/core/dialogs/FormDialog.js +105 -0
- package/dist/components/core/dialogs/index.js +7 -4
- package/dist/components/core/filters/ActiveFilters.js +69 -0
- package/dist/components/core/filters/AdvancedFilters.js +103 -0
- package/dist/components/core/filters/ConditionFilter.js +162 -0
- package/dist/components/core/filters/ConditionFilterGroup.js +44 -0
- package/dist/components/core/filters/FilterField.js +64 -0
- package/dist/components/core/filters/FilterPills.js +13 -0
- package/dist/components/core/filters/FilterPillsGroup.js +39 -0
- package/dist/components/core/filters/FiltersContainer.js +54 -0
- package/dist/components/core/filters/FiltersMobileDrawer.js +57 -0
- package/dist/components/core/filters/TableFilter.js +101 -0
- package/dist/components/core/filters/index.js +11 -645
- package/dist/{GenericForm-Dxd6k7l-.js → components/core/forms/GenericForm.js} +45 -43
- package/dist/components/core/forms/index.js +1 -1
- package/dist/components/core/icons/FlagFrIcon.js +28 -0
- package/dist/{icons-n0m_1w7z.js → components/core/icons/FlagGbIcon.js} +3 -26
- package/dist/components/core/icons/index.js +3 -1
- package/dist/components/core/index.js +71 -27
- package/dist/components/core/inputs/DatePicker.js +46 -0
- package/dist/components/core/inputs/DateRangePicker.js +92 -0
- package/dist/{inputs-CBojnClc.js → components/core/inputs/FileDropzone.js} +8 -37
- package/dist/{ImageInput-BeIOm3GY.js → components/core/inputs/ImageInput.js} +5 -5
- package/dist/components/core/inputs/MultiSelect.js +191 -0
- package/dist/components/core/inputs/RatingInput.js +36 -0
- package/dist/{SearchInput-IT_Rvthr.js → components/core/inputs/SearchInput.js} +4 -4
- package/dist/components/core/inputs/SingleSelect.js +198 -0
- package/dist/components/core/inputs/index.js +9 -6
- package/dist/components/core/inputs/select.helper.js +46 -0
- package/dist/{language-DY0EYabh.js → components/core/language/LanguageSelector.js} +13 -12
- package/dist/components/core/language/index.js +1 -1
- package/dist/{AppActions-8HjAaTQK.js → components/core/layouts/AppActions.js} +19 -19
- package/dist/components/core/layouts/AppPageHeader.js +44 -0
- package/dist/{AppSubTitle-DI62BaaB.js → components/core/layouts/AppSubTitle.js} +3 -3
- package/dist/{AppTitle-BXoTrXQc.js → components/core/layouts/AppTitle.js} +3 -3
- package/dist/components/core/layouts/KpiCardsLayout.js +8 -0
- package/dist/components/core/layouts/index.js +6 -50
- package/dist/components/core/markdown/AppMarkdown.js +134 -0
- package/dist/components/core/markdown/AppMarkdownHeading.js +45 -0
- package/dist/components/core/markdown/index.js +1 -1
- package/dist/components/core/navbar/GlobalSearch.js +128 -0
- package/dist/components/core/navbar/NotificationsBell.js +133 -0
- package/dist/components/core/navbar/Sidebar.js +99 -0
- package/dist/components/core/navbar/SidebarHeader.js +26 -0
- package/dist/components/core/navbar/SidebarNavItem.js +72 -0
- package/dist/components/core/navbar/Topbar.js +25 -0
- package/dist/components/core/navbar/index.js +7 -1
- package/dist/{ErrorAlert-cJnfBL8H.js → components/core/states/ErrorAlert.js} +5 -5
- package/dist/{states-CJ8xE_Nm.js → components/core/states/ErrorState.js} +4 -11
- package/dist/components/core/states/LoadingState.js +12 -0
- package/dist/components/core/states/index.js +3 -2
- package/dist/components/core/table/DataTable.js +108 -0
- package/dist/components/core/table/JsonTableOutput.js +75 -0
- package/dist/components/core/table/TableActions.js +75 -0
- package/dist/components/core/table/TableBody.js +130 -0
- package/dist/components/core/table/TableBulkActions.js +47 -0
- package/dist/components/core/table/TableHeader.js +103 -0
- package/dist/components/core/table/TablePagination.js +102 -0
- package/dist/components/core/table/TableSettings.js +117 -0
- package/dist/components/core/table/index.js +9 -709
- package/dist/components/core/tabs/AppTabContainer.js +17 -0
- package/dist/components/core/tabs/AppTabHeader.js +19 -0
- package/dist/components/core/tabs/AppTabs.js +56 -0
- package/dist/components/core/tabs/AppVerticalTabs.js +105 -0
- package/dist/components/core/tabs/index.js +5 -188
- package/dist/{theme-DSumNHLX.js → components/core/theme/ThemeSelector.js} +13 -12
- package/dist/components/core/theme/index.js +1 -1
- package/dist/components/index.js +117 -34
- package/dist/components/ui/accordion.js +34 -0
- package/dist/components/ui/alert-dialog.js +54 -0
- package/dist/{alert-REQGK9bR.js → components/ui/alert.js} +2 -2
- package/dist/components/ui/aspect-ratio.js +5 -0
- package/dist/components/ui/avatar.js +25 -0
- package/dist/components/ui/badge.js +22 -0
- package/dist/components/ui/breadcrumb.js +60 -0
- package/dist/{tooltip-_geGvbS7.js → components/ui/button.js} +7 -17
- package/dist/components/ui/calendar.js +44 -0
- package/dist/components/ui/card.js +42 -0
- package/dist/components/ui/carousel.js +115 -0
- package/dist/{chart-wW-fwL3s.js → components/ui/chart.js} +51 -89
- package/dist/components/ui/checkbox.js +31 -0
- package/dist/components/ui/collapsible.js +5 -0
- package/dist/components/ui/command.js +84 -0
- package/dist/components/ui/context-menu.js +71 -0
- package/dist/components/ui/control.js +5 -0
- package/dist/components/ui/dialog.js +49 -0
- package/dist/components/ui/drawer.js +47 -0
- package/dist/components/ui/dropdown-menu.js +72 -0
- package/dist/components/ui/form.js +78 -0
- package/dist/components/ui/hover-card.js +15 -0
- package/dist/components/ui/index.js +49 -9
- package/dist/components/ui/input-otp.js +41 -0
- package/dist/components/ui/input.js +14 -0
- package/dist/components/ui/label.js +14 -0
- package/dist/components/ui/menubar.js +86 -0
- package/dist/components/ui/navigation-menu.js +58 -0
- package/dist/components/ui/pagination.js +62 -0
- package/dist/components/ui/popover.js +15 -0
- package/dist/components/ui/progress.js +17 -0
- package/dist/components/ui/radio-group.js +24 -0
- package/dist/components/ui/resizable.js +18 -0
- package/dist/components/ui/scroll-area.js +29 -0
- package/dist/{select-KWMg2_7Z.js → components/ui/select.js} +3 -3
- package/dist/components/ui/separator.js +15 -0
- package/dist/components/ui/sheet.js +58 -0
- package/dist/components/ui/simple-table.js +57 -0
- package/dist/{skeleton-D6Ga4BLw.js → components/ui/skeleton.js} +2 -2
- package/dist/components/ui/slider.js +17 -0
- package/dist/components/ui/sonner.js +23 -0
- package/dist/components/ui/switch.js +14 -0
- package/dist/components/ui/tabs.js +58 -0
- package/dist/components/ui/textarea.js +12 -0
- package/dist/components/ui/toast.js +53 -0
- package/dist/components/ui/toaster.js +22 -0
- package/dist/components/ui/toggle-group.js +37 -0
- package/dist/components/ui/toggle.js +34 -0
- package/dist/components/ui/tooltip.js +14 -0
- package/dist/{datatable-COQcYUrk.js → constants/datatable.js} +1 -1
- package/dist/constants/index.js +3 -5
- package/dist/constants/search.js +4 -0
- package/dist/contexts/index.js +3 -1
- package/dist/{sidebar.context-BahtU6hE.js → contexts/page.context.js} +2 -2
- package/dist/contexts/sidebar.context.js +5 -0
- package/dist/helpers/changelog.helper.js +69 -0
- package/dist/helpers/index.js +6 -166
- package/dist/{markdown.helper-YJE2H5KQ.js → helpers/markdown.helper.js} +1 -1
- package/dist/helpers/supabase.helper.js +41 -0
- package/dist/helpers/table.helper.js +56 -0
- package/dist/{tailwind.helper-CJaRYBmL.js → helpers/tailwind.helper.js} +1 -1
- package/dist/hooks/behavior/index.js +10 -1
- package/dist/hooks/behavior/useConfirmDeleteDialog.js +21 -0
- package/dist/hooks/behavior/useConfirmationDialog.js +23 -0
- package/dist/hooks/behavior/useDebounce.js +14 -0
- package/dist/hooks/behavior/useDebouncedValue.js +15 -0
- package/dist/hooks/behavior/useDialog.js +21 -0
- package/dist/hooks/behavior/usePage.js +10 -0
- package/dist/hooks/behavior/useSidebar.js +10 -0
- package/dist/hooks/behavior/useTable.js +83 -0
- package/dist/hooks/behavior/useUrlState.js +46 -0
- package/dist/hooks/index.js +20 -11
- package/dist/hooks/ui/index.js +11 -10
- package/dist/{useFixedColumns-Bo-Az3Hp.js → hooks/ui/useDataTable.js} +16 -52
- package/dist/{useDocumentTitle-VoQkict_.js → hooks/ui/useDocumentTitle.js} +2 -2
- package/dist/hooks/ui/useFixedColumns.js +38 -0
- package/dist/{useLanguage-DRnSb5H1.js → hooks/ui/useLanguage.js} +3 -3
- package/dist/{useMobile-pTQ8lWvt.js → hooks/ui/useMobile.js} +1 -1
- package/dist/{useNotifications-CyhTruIG.js → hooks/ui/useNotifications.js} +2 -2
- package/dist/{useScrollFade-D9kqJBDh.js → hooks/ui/useScrollFade.js} +1 -1
- package/dist/{ui-nQGnCss1.js → hooks/ui/useServerTable.js} +2 -2
- package/dist/{useTheme-DIZjiF5F.js → hooks/ui/useTheme.js} +3 -3
- package/dist/{useToast-UeDRLovh.js → hooks/ui/useToast.js} +1 -1
- package/dist/i18n/index.js +4 -1
- package/dist/i18n/krosoftLocales.js +13 -0
- package/dist/i18n/useDateFnsLocale.js +13 -0
- package/dist/i18n/useKrosoftTranslation.js +13 -0
- package/dist/locales/en.json.js +174 -0
- package/dist/locales/fr.json.js +174 -0
- package/dist/providers/SidebarProvider.js +42 -0
- package/dist/providers/index.js +1 -42
- package/dist/pwa/PwaUpdater.js +30 -0
- package/dist/pwa/index.js +3 -50
- package/dist/pwa/pwaUpdateToast.js +25 -0
- package/dist/seasonal/EffectSwitch.js +24 -0
- package/dist/seasonal/EmojiSnowfall.js +24 -0
- package/dist/seasonal/HalloweenEffect.js +17 -0
- package/dist/seasonal/SeasonalEffects.js +8 -0
- package/dist/seasonal/SeasonalEffectsSettings.js +35 -0
- package/dist/seasonal/SnowEffect.js +12 -0
- package/dist/seasonal/index.js +7 -120
- package/dist/seasonal/overlayStyle.js +12 -0
- package/dist/seasonal/seasons.js +7 -0
- package/dist/seasonal/useSeasonalEffects.js +20 -0
- package/dist/seasonal/useStoredToggle.js +21 -0
- package/dist/tailwind/index.js +7 -53
- package/dist/tokens/apply.js +16 -0
- package/dist/tokens/index.js +3 -38
- package/dist/tokens/radius.js +26 -0
- package/dist/types/index.js +0 -1
- package/dist/vendor/tailwindcss/lib/public/create-plugin.js +19 -0
- package/dist/vendor/tailwindcss/lib/util/createPlugin.js +30 -0
- package/dist/vendor/tailwindcss/plugin.js +10 -0
- package/package.json +4 -4
- package/dist/AppMarkdown-CAxm82x0.js +0 -171
- package/dist/MultiSelect-DPN046kI.js +0 -228
- package/dist/SingleSelect-DLY5WylQ.js +0 -313
- package/dist/behavior-B0BYivtN.js +0 -201
- package/dist/cards-DPzVebUM.js +0 -132
- package/dist/changelog-DyPFIscf.js +0 -257
- package/dist/charts-C7rKxkli.js +0 -342
- package/dist/dialogs-CG9Q7pqY.js +0 -269
- package/dist/i18n-BhLphJa3.js +0 -364
- package/dist/navbar-DD0V0pNE.js +0 -432
- package/dist/sheet-cWJO_wkT.js +0 -225
- package/dist/switch-DspImmo_.js +0 -24
- package/dist/ui-Fxy95kSJ.js +0 -1163
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ACTIONS_COLUMN_KEY as e, SELECTION_COLUMN_KEY as t, getAlignmentClass as n, getColumnAlignment as r, getFixedCellProps as i } from "../../../helpers/table.helper.js";
|
|
2
|
+
import { useKrosoftTranslation as a } from "../../../i18n/useKrosoftTranslation.js";
|
|
3
|
+
import { Checkbox as o } from "../../ui/checkbox.js";
|
|
4
|
+
import { TableActions as s } from "./TableActions.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { AlertTriangleIcon as u, Loader2Icon as d } from "lucide-react";
|
|
8
|
+
import { useNavigate as f } from "react-router-dom";
|
|
9
|
+
//#region src/components/core/table/TableBody.tsx
|
|
10
|
+
function p({ isLoading: p, error: m, colSpanCount: h, messages: g, paginatedData: _, rowKey: v, onRowClick: y, onRowNavigate: b, rowNavigable: x, hasBulkActions: S, rowSelectable: C, selectedKeys: w, toggleRowSelection: T, visibleColumnsArray: E, columnWidths: D, hasActions: O, actions: k, columns: A, bordered: j = !1, dense: M = !1, resizableColumns: N = !1, fixedColumns: P = {} }) {
|
|
11
|
+
let { t: F } = a(), I = F(g?.loadingKey ?? "states.loading"), L = F(g?.emptyKey ?? "states.noResult"), R = f(), z = (e, t) => {
|
|
12
|
+
let n = A.find((e) => e.key === t);
|
|
13
|
+
if (n?.renderCell !== void 0) return n.renderCell(e);
|
|
14
|
+
let r = e[t];
|
|
15
|
+
return /* @__PURE__ */ c("span", {
|
|
16
|
+
className: "text-sm truncate",
|
|
17
|
+
children: r == null ? "-" : String(r)
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
if (p) return /* @__PURE__ */ c("tbody", {
|
|
21
|
+
className: "divide-y divide-border",
|
|
22
|
+
children: /* @__PURE__ */ c("tr", { children: /* @__PURE__ */ c("td", {
|
|
23
|
+
colSpan: h,
|
|
24
|
+
className: "py-8 text-center",
|
|
25
|
+
children: /* @__PURE__ */ l("div", {
|
|
26
|
+
className: "flex flex-col items-center justify-center gap-2 text-muted-foreground",
|
|
27
|
+
children: [/* @__PURE__ */ c(d, { className: "h-6 w-6 animate-spin text-primary" }), /* @__PURE__ */ c("span", {
|
|
28
|
+
className: "text-sm",
|
|
29
|
+
children: I
|
|
30
|
+
})]
|
|
31
|
+
})
|
|
32
|
+
}) })
|
|
33
|
+
});
|
|
34
|
+
if (m) return /* @__PURE__ */ c("tbody", {
|
|
35
|
+
className: "divide-y divide-border",
|
|
36
|
+
children: /* @__PURE__ */ c("tr", { children: /* @__PURE__ */ c("td", {
|
|
37
|
+
colSpan: h,
|
|
38
|
+
className: "py-8 text-center",
|
|
39
|
+
children: /* @__PURE__ */ l("div", {
|
|
40
|
+
className: "flex flex-col items-center justify-center gap-2 text-destructive",
|
|
41
|
+
children: [/* @__PURE__ */ c(u, { className: "h-6 w-6" }), /* @__PURE__ */ c("span", {
|
|
42
|
+
className: "text-sm",
|
|
43
|
+
children: m
|
|
44
|
+
})]
|
|
45
|
+
})
|
|
46
|
+
}) })
|
|
47
|
+
});
|
|
48
|
+
if (_.length === 0) return /* @__PURE__ */ c("tbody", {
|
|
49
|
+
className: "divide-y divide-border",
|
|
50
|
+
children: /* @__PURE__ */ c("tr", { children: /* @__PURE__ */ c("td", {
|
|
51
|
+
colSpan: h,
|
|
52
|
+
className: "py-8 text-center text-sm text-muted-foreground",
|
|
53
|
+
children: L
|
|
54
|
+
}) })
|
|
55
|
+
});
|
|
56
|
+
let B = i(P[t], "body"), V = i(P[e], "body"), H = S && w.size > 0, U = (e) => {
|
|
57
|
+
if (x === void 0 || x(e)) return b?.(e);
|
|
58
|
+
}, W = (e, t, n) => {
|
|
59
|
+
H ? T(e) : t === void 0 ? y?.(e, n) : n.ctrlKey || n.metaKey ? window.open(t, "_blank") : R(t);
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ c("tbody", {
|
|
62
|
+
className: "divide-y divide-border",
|
|
63
|
+
children: _.map((e) => {
|
|
64
|
+
let t = v(e), a = C === void 0 || C(e), u = U(e);
|
|
65
|
+
return /* @__PURE__ */ l("tr", {
|
|
66
|
+
className: `group hover:bg-muted/50 transition-colors ${H || u !== void 0 || y !== void 0 ? "cursor-pointer" : ""}`,
|
|
67
|
+
onClick: (t) => {
|
|
68
|
+
W(e, u, t);
|
|
69
|
+
},
|
|
70
|
+
children: [
|
|
71
|
+
S ? /* @__PURE__ */ c("td", {
|
|
72
|
+
className: `p-1 text-center align-middle ${B.className}`,
|
|
73
|
+
style: {
|
|
74
|
+
width: "48px",
|
|
75
|
+
minWidth: "48px",
|
|
76
|
+
maxWidth: "48px",
|
|
77
|
+
...B.style
|
|
78
|
+
},
|
|
79
|
+
onClick: (e) => {
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ c("div", {
|
|
83
|
+
className: "flex items-center justify-center",
|
|
84
|
+
children: /* @__PURE__ */ c(o, {
|
|
85
|
+
checked: w.has(t),
|
|
86
|
+
disabled: !a,
|
|
87
|
+
onCheckedChange: () => {
|
|
88
|
+
T(e);
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
}) : null,
|
|
93
|
+
E.map((t, a) => {
|
|
94
|
+
let o = a === E.length - 1, s = i(P[t.key], "body");
|
|
95
|
+
return /* @__PURE__ */ c("td", {
|
|
96
|
+
className: `${`${a === 0 && !S ? "pl-4" : "pl-2"} ${o && !O ? "pr-4" : "pr-2"}`} ${M ? "py-2" : "py-4"} text-sm ${n(r(t))} ${s.className} ${j && !o ? "border-r border-border" : ""} ${t.className ?? ""}`,
|
|
97
|
+
style: {
|
|
98
|
+
...N ? { width: D[t.key] } : { minWidth: D[t.key] },
|
|
99
|
+
...s.style
|
|
100
|
+
},
|
|
101
|
+
children: /* @__PURE__ */ c("div", {
|
|
102
|
+
className: "w-full h-full",
|
|
103
|
+
children: z(e, t.key)
|
|
104
|
+
})
|
|
105
|
+
}, t.key);
|
|
106
|
+
}),
|
|
107
|
+
O ? /* @__PURE__ */ c("td", {
|
|
108
|
+
className: `py-1 pl-1 pr-4 text-right align-middle whitespace-nowrap ${V.className}`,
|
|
109
|
+
style: {
|
|
110
|
+
minWidth: "32px",
|
|
111
|
+
...V.style
|
|
112
|
+
},
|
|
113
|
+
onClick: (e) => {
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
},
|
|
116
|
+
children: k !== void 0 && k.length > 0 ? /* @__PURE__ */ c("div", {
|
|
117
|
+
className: "flex items-center justify-end",
|
|
118
|
+
children: /* @__PURE__ */ c(s, {
|
|
119
|
+
actions: k,
|
|
120
|
+
row: e
|
|
121
|
+
})
|
|
122
|
+
}) : null
|
|
123
|
+
}) : null
|
|
124
|
+
]
|
|
125
|
+
}, t);
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { p as TableBody };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useKrosoftTranslation as e } from "../../../i18n/useKrosoftTranslation.js";
|
|
2
|
+
import { Button as t } from "../../ui/button.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/core/table/TableBulkActions.tsx
|
|
6
|
+
function i({ selectedRows: i, setSelectedRows: a, bulkActions: o }) {
|
|
7
|
+
let { t: s } = e();
|
|
8
|
+
return /* @__PURE__ */ r("div", {
|
|
9
|
+
className: "bg-muted/60 border border-border px-3 py-1.5 flex items-center justify-between rounded-surface",
|
|
10
|
+
children: [/* @__PURE__ */ r("div", {
|
|
11
|
+
className: "flex items-center gap-4",
|
|
12
|
+
children: [/* @__PURE__ */ n("span", {
|
|
13
|
+
className: "text-sm font-medium text-primary ml-1",
|
|
14
|
+
children: s("table.selectedCount", { count: i.length })
|
|
15
|
+
}), /* @__PURE__ */ n("div", {
|
|
16
|
+
className: "flex items-center gap-2",
|
|
17
|
+
children: o.map((e, o) => {
|
|
18
|
+
let c = e.icon;
|
|
19
|
+
return /* @__PURE__ */ r(t, {
|
|
20
|
+
variant: "outline",
|
|
21
|
+
size: "sm",
|
|
22
|
+
onClick: () => {
|
|
23
|
+
e.onClick(i, () => {
|
|
24
|
+
a([]);
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
className: `h-7 bg-background shadow-sm text-xs px-2.5 ${e.variant === "destructive" ? "text-destructive border-destructive/30 hover:bg-destructive/10 hover:text-destructive" : "text-foreground"}`,
|
|
28
|
+
children: [c !== void 0 && /* @__PURE__ */ n("span", {
|
|
29
|
+
className: "mr-1.5 flex items-center justify-center",
|
|
30
|
+
children: /* @__PURE__ */ n(c, { className: "h-3.5 w-3.5" })
|
|
31
|
+
}), s(e.labelKey)]
|
|
32
|
+
}, o);
|
|
33
|
+
})
|
|
34
|
+
})]
|
|
35
|
+
}), /* @__PURE__ */ n(t, {
|
|
36
|
+
variant: "ghost",
|
|
37
|
+
size: "sm",
|
|
38
|
+
onClick: () => {
|
|
39
|
+
a([]);
|
|
40
|
+
},
|
|
41
|
+
className: "text-xs text-muted-foreground hover:text-foreground h-7 px-2",
|
|
42
|
+
children: s("table.clearSelection")
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { i as TableBulkActions };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ACTIONS_COLUMN_KEY as e, SELECTION_COLUMN_KEY as t, getAlignmentClass as n, getColumnAlignment as r, getFixedCellProps as i } from "../../../helpers/table.helper.js";
|
|
2
|
+
import { useKrosoftTranslation as a } from "../../../i18n/useKrosoftTranslation.js";
|
|
3
|
+
import { Checkbox as o } from "../../ui/checkbox.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
import { ArrowDownIcon as l, ArrowUpDownIcon as u, ArrowUpIcon as d, GripVerticalIcon as f } from "lucide-react";
|
|
7
|
+
//#region src/components/core/table/TableHeader.tsx
|
|
8
|
+
var p = {
|
|
9
|
+
left: "justify-start",
|
|
10
|
+
center: "justify-center",
|
|
11
|
+
right: "justify-end"
|
|
12
|
+
};
|
|
13
|
+
function m({ hasBulkActions: m, allSelected: h, someSelected: g, toggleSelectAll: _, visibleColumnsArray: v, draggableColumns: y, resizableColumns: b, columnWidths: x, sortColumn: S, sortDirection: C, handleSort: w, handleDragStart: T, handleDragOver: E, handleDrop: D, handleMouseDown: O, hasActions: k, settingsNode: A, bordered: j = !1, dense: M = !1, fixedColumns: N = {}, fixedSelection: P = !1, fixedActions: F = !1 }) {
|
|
14
|
+
let { t: I } = a(), L = !1;
|
|
15
|
+
h ? L = !0 : g && (L = "indeterminate");
|
|
16
|
+
let R = (e) => e.sortable === !0 ? S === e.key ? s(C === "asc" ? d : l, { className: "size-3.5 text-foreground" }) : /* @__PURE__ */ s(u, { className: "size-3.5 text-muted-foreground/50 group-hover:text-muted-foreground transition-colors" }) : null, z = (e, t, a) => {
|
|
17
|
+
let o = a !== !1 && e.fixed === void 0, l = e.sortable === !0, u = i(N[e.key], "header"), d = r(e), h = R(e), g = t === 0 && !m, _ = t === v.length - 1 && !(k || A !== void 0), y = `${g ? "pl-4" : "pl-2"} ${_ ? "pr-4" : "pr-2"}`;
|
|
18
|
+
return /* @__PURE__ */ c("th", {
|
|
19
|
+
"data-column-key": e.key,
|
|
20
|
+
"data-fixed-side": e.fixed,
|
|
21
|
+
className: [
|
|
22
|
+
`${y} ${M ? "py-2" : "py-4"} text-sm font-medium text-foreground group`,
|
|
23
|
+
n(d),
|
|
24
|
+
u.className,
|
|
25
|
+
j ? "border-r border-border" : "",
|
|
26
|
+
l ? "cursor-pointer select-none" : "",
|
|
27
|
+
e.className ?? ""
|
|
28
|
+
].filter(Boolean).join(" "),
|
|
29
|
+
style: {
|
|
30
|
+
...b ? { width: x[e.key] } : { minWidth: x[e.key] },
|
|
31
|
+
...u.style
|
|
32
|
+
},
|
|
33
|
+
draggable: o,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
w(e.key);
|
|
36
|
+
},
|
|
37
|
+
onDragStart: (t) => {
|
|
38
|
+
o ? T(t, e.key) : t.preventDefault();
|
|
39
|
+
},
|
|
40
|
+
onDragOver: (t) => {
|
|
41
|
+
E(t, e.key);
|
|
42
|
+
},
|
|
43
|
+
onDrop: (t) => {
|
|
44
|
+
D(t, e.key);
|
|
45
|
+
},
|
|
46
|
+
children: [/* @__PURE__ */ c("div", {
|
|
47
|
+
className: `flex items-center gap-1 ${p[d]} ${b ? "pr-2" : ""}`,
|
|
48
|
+
children: [
|
|
49
|
+
o ? /* @__PURE__ */ s(f, { className: "size-4 text-muted-foreground cursor-grab shrink-0" }) : null,
|
|
50
|
+
/* @__PURE__ */ s("span", {
|
|
51
|
+
className: "truncate",
|
|
52
|
+
children: I(e.headerKey)
|
|
53
|
+
}),
|
|
54
|
+
h === null ? null : /* @__PURE__ */ s("span", {
|
|
55
|
+
className: "ml-1 shrink-0",
|
|
56
|
+
children: h
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
}), b ? /* @__PURE__ */ s("div", {
|
|
60
|
+
className: "absolute right-0 top-0 bottom-0 w-2 cursor-col-resize hover:bg-blue-500 opacity-0 group-hover:opacity-50 transition-opacity",
|
|
61
|
+
onMouseDown: (t) => {
|
|
62
|
+
O(t, e.key);
|
|
63
|
+
}
|
|
64
|
+
}) : null]
|
|
65
|
+
}, e.key);
|
|
66
|
+
}, B = i(N[t], "header"), V = i(N[e], "header");
|
|
67
|
+
return /* @__PURE__ */ s("thead", {
|
|
68
|
+
className: "bg-muted/50 border-b border-border",
|
|
69
|
+
children: /* @__PURE__ */ c("tr", { children: [
|
|
70
|
+
m ? /* @__PURE__ */ s("th", {
|
|
71
|
+
"data-column-key": t,
|
|
72
|
+
"data-fixed-side": P ? "left" : void 0,
|
|
73
|
+
className: `p-1 text-center align-middle ${B.className}`,
|
|
74
|
+
style: {
|
|
75
|
+
width: "48px",
|
|
76
|
+
minWidth: "48px",
|
|
77
|
+
maxWidth: "48px",
|
|
78
|
+
...B.style
|
|
79
|
+
},
|
|
80
|
+
children: /* @__PURE__ */ s("div", {
|
|
81
|
+
className: "flex items-center justify-center",
|
|
82
|
+
children: /* @__PURE__ */ s(o, {
|
|
83
|
+
checked: L,
|
|
84
|
+
onCheckedChange: _
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
}) : null,
|
|
88
|
+
v.map((e, t) => z(e, t, y)),
|
|
89
|
+
k || A !== void 0 ? /* @__PURE__ */ s("th", {
|
|
90
|
+
"data-column-key": e,
|
|
91
|
+
"data-fixed-side": F ? "right" : void 0,
|
|
92
|
+
className: `py-1 pl-1 pr-4 text-right align-middle ${V.className}`,
|
|
93
|
+
style: {
|
|
94
|
+
minWidth: "32px",
|
|
95
|
+
...V.style
|
|
96
|
+
},
|
|
97
|
+
children: A
|
|
98
|
+
}) : null
|
|
99
|
+
] })
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { m as TableHeader };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useKrosoftTranslation as e } from "../../../i18n/useKrosoftTranslation.js";
|
|
2
|
+
import { Button as t } from "../../ui/button.js";
|
|
3
|
+
import { Select as n, SelectContent as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "../../ui/select.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
|
+
import { ChevronLeftIcon as u, ChevronRightIcon as d } from "lucide-react";
|
|
7
|
+
//#region src/components/core/table/TablePagination.tsx
|
|
8
|
+
var f = "…";
|
|
9
|
+
function p(e, t) {
|
|
10
|
+
return Array.from({ length: t - e + 1 }, (t, n) => e + n);
|
|
11
|
+
}
|
|
12
|
+
function m(e, t, n = 1) {
|
|
13
|
+
if (n * 2 + 5 >= t) return p(1, t);
|
|
14
|
+
let r = Math.max(e - n, 1), i = Math.min(e + n, t), a = r > 2, o = i < t - 1;
|
|
15
|
+
return !a && o ? [
|
|
16
|
+
...p(1, n + 2),
|
|
17
|
+
f,
|
|
18
|
+
t
|
|
19
|
+
] : a && !o ? [
|
|
20
|
+
1,
|
|
21
|
+
f,
|
|
22
|
+
...p(t - (n + 2) + 1, t)
|
|
23
|
+
] : [
|
|
24
|
+
1,
|
|
25
|
+
f,
|
|
26
|
+
...p(r, i),
|
|
27
|
+
f,
|
|
28
|
+
t
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
function h({ totalItems: p, startIndex: h, endIndex: g, pageSize: _, setPageSize: v, currentPage: y, setCurrentPage: b, pageSizeOptions: x, totalPages: S }) {
|
|
32
|
+
let { t: C } = e(), w = m(y, S);
|
|
33
|
+
return /* @__PURE__ */ l("div", {
|
|
34
|
+
className: "px-4 py-2 border-t border-border flex flex-col sm:grid sm:grid-cols-3 items-center gap-2 bg-muted/50",
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ c("div", {
|
|
37
|
+
className: "text-sm text-muted-foreground justify-self-start",
|
|
38
|
+
children: C("table.rangeOfTotal", {
|
|
39
|
+
range: p === 0 ? "0" : `${String(h + 1)} - ${String(g)}`,
|
|
40
|
+
total: p
|
|
41
|
+
})
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ c("div", {
|
|
44
|
+
className: "flex items-center justify-center gap-1",
|
|
45
|
+
children: S > 1 && /* @__PURE__ */ l(s, { children: [
|
|
46
|
+
/* @__PURE__ */ c(t, {
|
|
47
|
+
variant: "ghost",
|
|
48
|
+
size: "icon",
|
|
49
|
+
className: "h-8 w-8 rounded-control",
|
|
50
|
+
onClick: () => {
|
|
51
|
+
b((e) => Math.max(1, e - 1));
|
|
52
|
+
},
|
|
53
|
+
disabled: y === 1,
|
|
54
|
+
"aria-label": C("table.previousPage"),
|
|
55
|
+
children: /* @__PURE__ */ c(u, { className: "size-4" })
|
|
56
|
+
}),
|
|
57
|
+
w.map((e, n) => e === f ? /* @__PURE__ */ c("span", {
|
|
58
|
+
className: "flex h-8 w-8 items-center justify-center text-sm text-muted-foreground",
|
|
59
|
+
children: f
|
|
60
|
+
}, `dots-${String(n)}`) : /* @__PURE__ */ c(t, {
|
|
61
|
+
variant: e === y ? "default" : "ghost",
|
|
62
|
+
className: "h-8 min-w-8 px-2 rounded-control text-sm tabular-nums",
|
|
63
|
+
onClick: () => {
|
|
64
|
+
b(e);
|
|
65
|
+
},
|
|
66
|
+
"aria-current": e === y ? "page" : void 0,
|
|
67
|
+
children: e
|
|
68
|
+
}, e)),
|
|
69
|
+
/* @__PURE__ */ c(t, {
|
|
70
|
+
variant: "ghost",
|
|
71
|
+
size: "icon",
|
|
72
|
+
className: "h-8 w-8 rounded-control",
|
|
73
|
+
onClick: () => {
|
|
74
|
+
b((e) => Math.min(S, e + 1));
|
|
75
|
+
},
|
|
76
|
+
disabled: y === S,
|
|
77
|
+
"aria-label": C("table.nextPage"),
|
|
78
|
+
children: /* @__PURE__ */ c(d, { className: "size-4" })
|
|
79
|
+
})
|
|
80
|
+
] })
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ c("div", {
|
|
83
|
+
className: "justify-self-end",
|
|
84
|
+
children: /* @__PURE__ */ l(n, {
|
|
85
|
+
value: String(_),
|
|
86
|
+
onValueChange: (e) => {
|
|
87
|
+
v(Number(e)), b(1);
|
|
88
|
+
},
|
|
89
|
+
children: [/* @__PURE__ */ c(a, {
|
|
90
|
+
className: "h-8 w-[110px] text-sm",
|
|
91
|
+
children: /* @__PURE__ */ c(o, {})
|
|
92
|
+
}), /* @__PURE__ */ c(r, { children: x.map((e) => /* @__PURE__ */ c(i, {
|
|
93
|
+
value: String(e),
|
|
94
|
+
children: C("table.perPage", { count: e })
|
|
95
|
+
}, e)) })]
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { h as TablePagination };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { cn as e } from "../../../helpers/tailwind.helper.js";
|
|
2
|
+
import { useKrosoftTranslation as t } from "../../../i18n/useKrosoftTranslation.js";
|
|
3
|
+
import { Button as n } from "../../ui/button.js";
|
|
4
|
+
import { Checkbox as r } from "../../ui/checkbox.js";
|
|
5
|
+
import { Popover as i, PopoverContent as a, PopoverTrigger as o } from "../../ui/popover.js";
|
|
6
|
+
import { useMemo as s, useState as c } from "react";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
import { SearchIcon as d, SettingsIcon as f } from "lucide-react";
|
|
9
|
+
//#region src/components/core/table/TableSettings.tsx
|
|
10
|
+
function p({ columns: p, visibleColumns: m, toggleColumnVisibility: h, setColumnsVisibility: g }) {
|
|
11
|
+
let { t: _ } = t(), [v, y] = c(""), b = s(() => p.map((e, t) => ({
|
|
12
|
+
key: e.key,
|
|
13
|
+
label: _(e.headerKey),
|
|
14
|
+
locked: t === 0
|
|
15
|
+
})), [p, _]), x = s(() => {
|
|
16
|
+
let e = v.trim().toLowerCase();
|
|
17
|
+
return e === "" ? b : b.filter((t) => t.label.toLowerCase().includes(e));
|
|
18
|
+
}, [b, v]), S = (e) => {
|
|
19
|
+
let t = x.filter((e) => !e.locked).map((e) => e.key).filter((t) => m.has(t) !== e);
|
|
20
|
+
g === void 0 ? t.forEach(h) : g(t, e);
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ u(i, {
|
|
23
|
+
onOpenChange: (e) => {
|
|
24
|
+
e || y("");
|
|
25
|
+
},
|
|
26
|
+
children: [/* @__PURE__ */ l(o, {
|
|
27
|
+
asChild: !0,
|
|
28
|
+
children: /* @__PURE__ */ l(n, {
|
|
29
|
+
variant: "outline",
|
|
30
|
+
size: "sm",
|
|
31
|
+
className: "size-7 p-0 bg-background hover:bg-muted shadow-sm border-border",
|
|
32
|
+
children: /* @__PURE__ */ l(f, { className: "size-3.5 text-muted-foreground" })
|
|
33
|
+
})
|
|
34
|
+
}), /* @__PURE__ */ u(a, {
|
|
35
|
+
align: "end",
|
|
36
|
+
className: "w-64 p-0",
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ u("div", {
|
|
39
|
+
className: "flex items-center justify-between px-3 pt-3 pb-2",
|
|
40
|
+
children: [/* @__PURE__ */ l("span", {
|
|
41
|
+
className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground",
|
|
42
|
+
children: _("table.columnsTitle")
|
|
43
|
+
}), /* @__PURE__ */ u("span", {
|
|
44
|
+
className: "text-xs text-muted-foreground",
|
|
45
|
+
children: [
|
|
46
|
+
m.size,
|
|
47
|
+
" / ",
|
|
48
|
+
p.length
|
|
49
|
+
]
|
|
50
|
+
})]
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ l("div", {
|
|
53
|
+
className: "px-2 pb-2",
|
|
54
|
+
children: /* @__PURE__ */ u("div", {
|
|
55
|
+
className: "relative",
|
|
56
|
+
children: [/* @__PURE__ */ l(d, { className: "absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground" }), /* @__PURE__ */ l("input", {
|
|
57
|
+
value: v,
|
|
58
|
+
onChange: (e) => {
|
|
59
|
+
y(e.target.value);
|
|
60
|
+
},
|
|
61
|
+
placeholder: _("search.placeholder"),
|
|
62
|
+
className: "w-full rounded-control bg-muted/50 py-1.5 pl-7 pr-2 text-sm text-foreground placeholder:text-muted-foreground outline-none focus:ring-1 focus:ring-ring",
|
|
63
|
+
autoFocus: !0
|
|
64
|
+
})]
|
|
65
|
+
})
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ u("div", {
|
|
68
|
+
className: "flex max-h-72 flex-col gap-0.5 overflow-y-auto overflow-x-hidden border-t border-border p-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 [&::-webkit-scrollbar-track]:bg-transparent",
|
|
69
|
+
children: [x.length === 0 && /* @__PURE__ */ l("p", {
|
|
70
|
+
className: "px-2 py-3 text-center text-xs text-muted-foreground",
|
|
71
|
+
children: _("states.noResult")
|
|
72
|
+
}), x.map((t) => /* @__PURE__ */ u("label", {
|
|
73
|
+
className: e("flex min-w-0 items-center gap-2.5 rounded-md px-2 py-1.5 text-sm transition-colors", t.locked ? "cursor-not-allowed text-muted-foreground" : "cursor-pointer hover:bg-muted"),
|
|
74
|
+
children: [/* @__PURE__ */ l(r, {
|
|
75
|
+
checked: t.locked || m.has(t.key),
|
|
76
|
+
disabled: t.locked,
|
|
77
|
+
onCheckedChange: () => {
|
|
78
|
+
h(t.key);
|
|
79
|
+
}
|
|
80
|
+
}), /* @__PURE__ */ l("span", {
|
|
81
|
+
className: "min-w-0 flex-1 truncate",
|
|
82
|
+
title: t.label,
|
|
83
|
+
children: t.label
|
|
84
|
+
})]
|
|
85
|
+
}, t.key))]
|
|
86
|
+
}),
|
|
87
|
+
x.length > 0 && /* @__PURE__ */ u("div", {
|
|
88
|
+
className: "flex items-center justify-end gap-2 border-t border-border px-3 py-2 text-xs",
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ l("button", {
|
|
91
|
+
type: "button",
|
|
92
|
+
onClick: () => {
|
|
93
|
+
S(!0);
|
|
94
|
+
},
|
|
95
|
+
className: "font-medium text-primary hover:underline",
|
|
96
|
+
children: _("table.showAllColumns")
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ l("span", {
|
|
99
|
+
className: "h-3 w-px bg-border",
|
|
100
|
+
"aria-hidden": !0
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ l("button", {
|
|
103
|
+
type: "button",
|
|
104
|
+
onClick: () => {
|
|
105
|
+
S(!1);
|
|
106
|
+
},
|
|
107
|
+
className: "font-medium text-primary hover:underline",
|
|
108
|
+
children: _("table.hideAllColumns")
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { p as TableSettings };
|