UNPKG

@ucheeddev/refine-antd

Version:

Custom Ant Design components for Refine framework

1,447 lines (1,408 loc) 124 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // node_modules/dayjs/dayjs.min.js var require_dayjs_min = __commonJS({ "node_modules/dayjs/dayjs.min.js"(exports2, module2) { "use strict"; !function(t, e) { "object" == typeof exports2 && "undefined" != typeof module2 ? module2.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e(); }(exports2, function() { "use strict"; var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) { var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100; return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]"; } }, m = function(t2, e2, n2) { var r2 = String(t2); return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2; }, v = { s: m, z: function(t2) { var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60; return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0"); }, m: function t2(e2, n2) { if (e2.date() < n2.date()) return -t2(n2, e2); var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c); return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0); }, a: function(t2) { return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2); }, p: function(t2) { return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, ""); }, u: function(t2) { return void 0 === t2; } }, g = "en", D = {}; D[g] = M; var p = "$isDayjsObject", S = function(t2) { return t2 instanceof _ || !(!t2 || !t2[p]); }, w = function t2(e2, n2, r2) { var i2; if (!e2) return g; if ("string" == typeof e2) { var s2 = e2.toLowerCase(); D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2); var u2 = e2.split("-"); if (!i2 && u2.length > 1) return t2(u2[0]); } else { var a2 = e2.name; D[a2] = e2, i2 = a2; } return !r2 && i2 && (g = i2), i2 || !r2 && g; }, O = function(t2, e2) { if (S(t2)) return t2.clone(); var n2 = "object" == typeof e2 ? e2 : {}; return n2.date = t2, n2.args = arguments, new _(n2); }, b = v; b.l = w, b.i = S, b.w = function(t2, e2) { return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset }); }; var _ = function() { function M2(t2) { this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true; } var m2 = M2.prototype; return m2.parse = function(t2) { this.$d = function(t3) { var e2 = t3.date, n2 = t3.utc; if (null === e2) return /* @__PURE__ */ new Date(NaN); if (b.u(e2)) return /* @__PURE__ */ new Date(); if (e2 instanceof Date) return new Date(e2); if ("string" == typeof e2 && !/Z$/i.test(e2)) { var r2 = e2.match($); if (r2) { var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3); return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2); } } return new Date(e2); }(t2), this.init(); }, m2.init = function() { var t2 = this.$d; this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds(); }, m2.$utils = function() { return b; }, m2.isValid = function() { return !(this.$d.toString() === l); }, m2.isSame = function(t2, e2) { var n2 = O(t2); return this.startOf(e2) <= n2 && n2 <= this.endOf(e2); }, m2.isAfter = function(t2, e2) { return O(t2) < this.startOf(e2); }, m2.isBefore = function(t2, e2) { return this.endOf(e2) < O(t2); }, m2.$g = function(t2, e2, n2) { return b.u(t2) ? this[e2] : this.set(n2, t2); }, m2.unix = function() { return Math.floor(this.valueOf() / 1e3); }, m2.valueOf = function() { return this.$d.getTime(); }, m2.startOf = function(t2, e2) { var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) { var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2); return r2 ? i2 : i2.endOf(a); }, $2 = function(t3, e3) { return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2); }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : ""); switch (f2) { case h: return r2 ? l2(1, 0) : l2(31, 11); case c: return r2 ? l2(1, M3) : l2(0, M3 + 1); case o: var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2; return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3); case a: case d: return $2(v2 + "Hours", 0); case u: return $2(v2 + "Minutes", 1); case s: return $2(v2 + "Seconds", 2); case i: return $2(v2 + "Milliseconds", 3); default: return this.clone(); } }, m2.endOf = function(t2) { return this.startOf(t2, false); }, m2.$set = function(t2, e2) { var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2; if (o2 === c || o2 === h) { var y2 = this.clone().set(d, 1); y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d; } else l2 && this.$d[l2]($2); return this.init(), this; }, m2.set = function(t2, e2) { return this.clone().$set(t2, e2); }, m2.get = function(t2) { return this[b.p(t2)](); }, m2.add = function(r2, f2) { var d2, l2 = this; r2 = Number(r2); var $2 = b.p(f2), y2 = function(t2) { var e2 = O(l2); return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2); }; if ($2 === c) return this.set(c, this.$M + r2); if ($2 === h) return this.set(h, this.$y + r2); if ($2 === a) return y2(1); if ($2 === o) return y2(7); var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3; return b.w(m3, this); }, m2.subtract = function(t2, e2) { return this.add(-1 * t2, e2); }, m2.format = function(t2) { var e2 = this, n2 = this.$locale(); if (!this.isValid()) return n2.invalidDate || l; var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) { return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3); }, d2 = function(t3) { return b.s(s2 % 12 || 12, t3, "0"); }, $2 = f2 || function(t3, e3, n3) { var r3 = t3 < 12 ? "AM" : "PM"; return n3 ? r3.toLowerCase() : r3; }; return r2.replace(y, function(t3, r3) { return r3 || function(t4) { switch (t4) { case "YY": return String(e2.$y).slice(-2); case "YYYY": return b.s(e2.$y, 4, "0"); case "M": return a2 + 1; case "MM": return b.s(a2 + 1, 2, "0"); case "MMM": return h2(n2.monthsShort, a2, c2, 3); case "MMMM": return h2(c2, a2); case "D": return e2.$D; case "DD": return b.s(e2.$D, 2, "0"); case "d": return String(e2.$W); case "dd": return h2(n2.weekdaysMin, e2.$W, o2, 2); case "ddd": return h2(n2.weekdaysShort, e2.$W, o2, 3); case "dddd": return o2[e2.$W]; case "H": return String(s2); case "HH": return b.s(s2, 2, "0"); case "h": return d2(1); case "hh": return d2(2); case "a": return $2(s2, u2, true); case "A": return $2(s2, u2, false); case "m": return String(u2); case "mm": return b.s(u2, 2, "0"); case "s": return String(e2.$s); case "ss": return b.s(e2.$s, 2, "0"); case "SSS": return b.s(e2.$ms, 3, "0"); case "Z": return i2; } return null; }(t3) || i2.replace(":", ""); }); }, m2.utcOffset = function() { return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); }, m2.diff = function(r2, d2, l2) { var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() { return b.m(y2, m3); }; switch (M3) { case h: $2 = D2() / 12; break; case c: $2 = D2(); break; case f: $2 = D2() / 3; break; case o: $2 = (g2 - v2) / 6048e5; break; case a: $2 = (g2 - v2) / 864e5; break; case u: $2 = g2 / n; break; case s: $2 = g2 / e; break; case i: $2 = g2 / t; break; default: $2 = g2; } return l2 ? $2 : b.a($2); }, m2.daysInMonth = function() { return this.endOf(c).$D; }, m2.$locale = function() { return D[this.$L]; }, m2.locale = function(t2, e2) { if (!t2) return this.$L; var n2 = this.clone(), r2 = w(t2, e2, true); return r2 && (n2.$L = r2), n2; }, m2.clone = function() { return b.w(this.$d, this); }, m2.toDate = function() { return new Date(this.valueOf()); }, m2.toJSON = function() { return this.isValid() ? this.toISOString() : null; }, m2.toISOString = function() { return this.$d.toISOString(); }, m2.toString = function() { return this.$d.toUTCString(); }, M2; }(), k = _.prototype; return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) { k[t2[1]] = function(e2) { return this.$g(e2, t2[0], t2[1]); }; }), O.extend = function(t2, e2) { return t2.$i || (t2(e2, _, O), t2.$i = true), O; }, O.locale = w, O.isDayjs = S, O.unix = function(t2) { return O(1e3 * t2); }, O.en = D[g], O.Ls = D, O.p = {}, O; }); } }); // src/index.ts var index_exports = {}; __export(index_exports, { Bootstrap: () => Bootstrap, CustomAvatar: () => CustomAvatar, DEFAULT_THEME_CONFIG: () => DEFAULT_THEME_CONFIG, EmailLink: () => EmailLink, Fallback: () => Fallback, FieldFormTitle: () => FieldFormTitle, FilterDropdown: () => FilterDropdown, FullScreenLoading: () => FullScreenLoading, FullWidthLayout: () => FullWidthLayout, HeaderWithSearch: () => HeaderWithSearch, IconInvoicerLogo: () => IconInvoicerLogo, IconMoon: () => IconMoon, IconSun: () => IconSun, ImageUpload: () => ImageUpload, Layout: () => Layout5, LayoutContext: () => LayoutContext, LayoutContextProvider: () => LayoutContextProvider, ListPage: () => ListPage, ListTitleButton: () => ListTitleButton, Logo: () => Logo, PaginationTotal: () => PaginationTotal, PhoneNumberLink: () => PhoneNumberLink, SelectOptionWithAvatar: () => SelectOptionWithAvatar, ShowLinkButton: () => ShowLinkButton, Sider: () => Sider, SingleElementForm: () => SingleElementForm, Text: () => Text, TextIcon: () => TextIcon, Title: () => Title, Unauthorized: () => Unauthorized, UploadButton: () => UploadButton, UserPhotoUpload: () => UserPhotoUpload, isUrl: () => isUrl, lightenHexColor: () => lightenHexColor, useLayoutContext: () => useLayoutContext, useStyles: () => useStyles, useThemeConfig: () => useThemeConfig }); module.exports = __toCommonJS(index_exports); // src/components/bootstrap/bootstrap.tsx var import_antd4 = require("@refinedev/antd"); var import_refine_core2 = require("@ucheeddev/refine-core"); var import_antd5 = require("antd"); // src/providers/config/config-provider.tsx var import_react2 = require("react"); var import_antd2 = require("antd"); var import_antd_style = require("antd-style"); // src/hooks/theme-config/use-theme-config.ts var import_react = require("react"); var import_refine_core = require("@ucheeddev/refine-core"); var import_antd = require("antd"); // src/constants/theme-config.ts var DEFAULT_THEME_CONFIG = { // token: { // colorPrimaryText: 'rgba(0, 0, 0, 0.85)', // colorTextSecondary: 'rgba(0, 0, 0, 0.65)', // colorTextTertiary: 'rgba(0, 0, 0, 0.45)', // colorPrimary: '#6eb2cc', // colorBgContainer: '#FFFFFF', // colorBgLayout: '#F0F2F5', // colorBorderBg: '#E8E9EA', // fontFamily: // "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Arial', 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'", // }, // components: { // Typography: { // colorText: 'rgba(0, 0, 0, 0.85)', // colorTextDescription: 'rgba(0, 0, 0, 0.65)', // colorTextDisabled: 'rgba(0, 0, 0, 0.45)', // }, // Card: { // colorBgContainer: '#FFFFFF', // headerBg: '#FFFFFF', // boxShadowTertiary: // '0px 1px 2px 0px #00000008,0px 1px 6px -1px #000000050px,2px 4px 0px #00000005', // }, // Table: { // colorBgContainer: '#fff', // }, // Input: { // colorBgContainer: '#fff', // }, // InputNumber: { // colorBgContainer: '#fff', // }, // Calendar: { // colorBgContainer: '#FFFFFF', // }, // Radio: { // colorBgContainer: '#fff', // }, // Select: { // colorBgContainer: '#fff', // }, // }, }; // src/utils/is-url/is-url.ts var isUrl = (url) => { try { new URL(url || ""); return true; } catch (e) { return false; } }; // src/utils/lighten-hex-color/lighten-hex-color.ts var lightenHexColor = (color, amount) => { amount = amount || 20; if (!color) { return ""; } if (color[0] === "#") { color = color.slice(1); } let r = parseInt(color.substring(0, 2), 16); let g = parseInt(color.substring(2, 4), 16); let b = parseInt(color.substring(4, 6), 16); r = Math.min(255, r + amount); g = Math.min(255, g + amount); b = Math.min(255, b + amount); r = r < 0 ? 0 : r; g = g < 0 ? 0 : g; b = b < 0 ? 0 : b; const newColor = "#" + ("0" + r.toString(16)).slice(-2) + ("0" + g.toString(16)).slice(-2) + ("0" + b.toString(16)).slice(-2); return newColor; }; // src/hooks/theme-config/use-theme-config.ts var useThemeConfig = (props) => { const { overrides, mode } = props; const { token: tokenOverrides, ...overridesRest } = overrides || {}; const settings = (0, import_refine_core.useServerSettingsStore)((state) => state.settings); const colorPrimary = settings?.primary_color || ""; const colorPrimaryDark = settings?.primary_color_dark || lightenHexColor(colorPrimary); const token = (0, import_react.useMemo)(() => { const _token = { ...DEFAULT_THEME_CONFIG.token || {}, ...tokenOverrides || {} }; if (colorPrimary) { _token.colorPrimary = mode === "light" ? colorPrimary : colorPrimaryDark; } return _token; }, [tokenOverrides, colorPrimary, colorPrimaryDark, mode]); const themeConfig = (0, import_react.useMemo)( () => ({ ...DEFAULT_THEME_CONFIG, token, ...overridesRest || {} }), [token, overridesRest] ); const customTheme = (0, import_react.useMemo)(() => { const { darkAlgorithm, defaultAlgorithm } = import_antd.theme; const algorithm = mode === "light" ? defaultAlgorithm : darkAlgorithm; const customTheme2 = { ...themeConfig, cssVar: true, algorithm, components: { Card: { headerBg: mode === "dark" ? "#1F1F1F" : "#FAFAFA" } } }; return customTheme2; }, [mode, themeConfig]); return customTheme; }; // src/providers/config/config-provider.tsx var import_jsx_runtime = require("react/jsx-runtime"); var ConfigProviderContext = (0, import_react2.createContext)( {} ); var ConfigProvider = ({ children, theme: themeFromProps, forceLightTheme, ...rest }) => { const colorModeFromLocalStorage = localStorage.getItem("colorMode"); const isSystemPreferenceDark = window.matchMedia( "(prefers-color-scheme: dark)" ).matches; const systemPreference = isSystemPreferenceDark ? "dark" : "light"; const [mode, setMode] = (0, import_react2.useState)( forceLightTheme ? "light" : colorModeFromLocalStorage || systemPreference ); const themeConfig = useThemeConfig({ overrides: themeFromProps, mode }); const toggleMode = (0, import_react2.useCallback)(() => { if (forceLightTheme) { setMode("light"); return; } setMode((prev) => prev === "light" ? "dark" : "light"); }, [forceLightTheme]); (0, import_react2.useEffect)(() => { window.localStorage.setItem("colorMode", mode); }, [mode]); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( ConfigProviderContext.Provider, { value: { toggleMode, mode, isDarkMode: mode === "dark" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.ConfigProvider, { theme: themeConfig, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd_style.ThemeProvider, { theme: themeConfig, appearance: mode, ...rest, children }) }) } ); }; var useConfigProvider = () => { const context = (0, import_react2.useContext)(ConfigProviderContext); if (!context) { throw new Error("useConfigProvider must be used within a ConfigProvider"); } return context; }; // src/components/full-screen-loading/full-screen-loading.tsx var import_antd3 = require("antd"); var import_jsx_runtime2 = require("react/jsx-runtime"); var FullScreenLoading = () => { return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_antd3.Spin, { size: "large", style: { height: "100vh", width: "100%", display: "flex", alignItems: "center", justifyContent: "center" } } ); }; // src/components/bootstrap/bootstrap.tsx var import_jsx_runtime3 = require("react/jsx-runtime"); var Bootstrap = ({ theme: theme6, forceLightTheme, configProviderProps, children, notificationProvider: notificationProviderFromProps, ...rest }) => { return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( ConfigProvider, { theme: theme6, forceLightTheme, ...configProviderProps || {}, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd5.App, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( import_refine_core2.Bootstrap, { ...rest, notificationProvider: notificationProviderFromProps || import_antd4.useNotificationProvider, Loading: FullScreenLoading, Error: ({ error }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd5.Alert, { type: "error", message: error, showIcon: true }), children } ) }) } ); }; // src/components/custom-avatar/custom-avatar.tsx var import_react3 = require("react"); var import_antd6 = require("antd"); var import_jsx_runtime4 = require("react/jsx-runtime"); var getRandomColorFromString = (text) => { const colors = [ "#ff9c6e", "#ff7875", "#ffc069", "#ffd666", "#fadb14", "#95de64", "#5cdbd3", "#69c0ff", "#85a5ff", "#b37feb", "#ff85c0" ]; let hash = 0; for (let i = 0; i < text.length; i++) { hash = text.charCodeAt(i) + ((hash << 5) - hash); hash = hash & hash; } hash = (hash % colors.length + colors.length) % colors.length; return colors[hash]; }; var getNameInitials = (name, count = 2) => { const initials = name.split(" ").map((n) => n[0]).join(""); const filtered = initials.replace(/[^a-zA-Z]/g, ""); return filtered.slice(0, count).toUpperCase(); }; var CustomAvatarComponent = ({ name, style, ...rest }) => { return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( import_antd6.Avatar, { alt: name, size: "small", style: { backgroundColor: rest?.src ? "transparent" : getRandomColorFromString(name || ""), display: "flex", alignItems: "center", border: "none", ...style }, ...rest, children: getNameInitials(name || "") } ); }; var CustomAvatar = (0, import_react3.memo)( CustomAvatarComponent, (prevProps, nextProps) => { return prevProps.name === nextProps.name && prevProps.src === nextProps.src; } ); // src/components/email-link/email-link.tsx var import_antd7 = require("antd"); var import_jsx_runtime5 = require("react/jsx-runtime"); var { Link } = import_antd7.Typography; var EmailLink = ({ email, style }) => { return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Link, { href: `mailto:${email}`, target: "_blank", style, children: email }); }; // src/components/field-form-title/field-form-title.tsx var import_antd8 = require("antd"); var import_jsx_runtime6 = require("react/jsx-runtime"); var FieldFormTitle = ({ title, Icon: Icon2, iconProps, titleStyle, ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd8.Space, { size: 11, ...props, children: [ Icon2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon2, { className: "md colorPrimary", ...iconProps }), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)( import_antd8.Typography.Text, { style: { fontSize: "15px", color: "darkslategray", ...titleStyle }, children: title } ) ] }); }; // src/components/filter-dropdown/filter-dropdown.tsx var import_react4 = __toESM(require("react")); var import_core = require("@refinedev/core"); var import_icons = require("@ant-design/icons"); var import_antd9 = require("antd"); var import_dayjs = __toESM(require_dayjs_min()); var import_jsx_runtime7 = require("react/jsx-runtime"); var FilterDropdown = (props) => { const { setSelectedKeys, confirm, clearFilters, mapValue = (value) => value, selectedKeys, children } = props; const translate = (0, import_core.useTranslate)(); const clearFilter = (0, import_react4.useCallback)(() => { if (clearFilters) { clearFilters(); confirm?.(); } }, [clearFilters, confirm]); const onFilter = (0, import_react4.useCallback)(() => { let keys; if (typeof selectedKeys === "number") { keys = `${selectedKeys}`; } else if (import_dayjs.default.isDayjs(selectedKeys)) { keys = [selectedKeys.toISOString()]; } else { keys = selectedKeys; } setSelectedKeys(keys); confirm?.(); }, [selectedKeys, setSelectedKeys, confirm]); const onChange = (0, import_react4.useCallback)( (e) => { if (typeof e === "object") { if (Array.isArray(e)) { const mappedValue3 = mapValue(e, "onChange"); setSelectedKeys(mappedValue3); confirm?.(); return; } const changeEvent = !e || !e.target || import_dayjs.default.isDayjs(e) ? { target: { value: e } } : e; const { target } = changeEvent; const mappedValue2 = mapValue(target.value, "onChange"); setSelectedKeys(mappedValue2); return; } const mappedValue = mapValue(e, "onChange"); if (typeof mappedValue === "number") { setSelectedKeys(`${mappedValue}`); } else { setSelectedKeys(mappedValue); } confirm?.(); }, [confirm, mapValue, setSelectedKeys] ); const childrenWithProps = (0, import_react4.useMemo)(() => { return import_react4.default.Children.map(children, (child) => { if (import_react4.default.isValidElement(child)) { return import_react4.default.cloneElement(child, { onChange, value: mapValue(selectedKeys, "value") }); } return child; }); }, [children, mapValue, onChange, selectedKeys]); return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)( "div", { style: { padding: 10, display: "flex", flexDirection: "column", alignItems: "flex-end" }, children: [ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { marginBottom: 12 }, children: childrenWithProps }), /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd9.Space, { children: [ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)( import_antd9.Button, { style: { backgroundColor: "#ffff" }, danger: true, size: "small", onClick: () => clearFilter(), children: [ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons.ClearOutlined, {}), translate("buttons.clear", "Clear") ] } ), /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd9.Button, { type: "primary", size: "small", onClick: () => onFilter(), children: [ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons.FilterOutlined, {}), " ", translate("buttons.filter", "Filter") ] }) ] }) ] } ); }; // src/components/full-width-layout/full-width-layout.tsx var import_antd14 = require("@refinedev/antd"); // src/components/header-with-menu/header-with-menu.tsx var import_core4 = require("@refinedev/core"); var import_antd13 = require("antd"); var import_classnames = __toESM(require("classnames")); // src/components/current-user/current-user.tsx var import_core2 = require("@refinedev/core"); var import_icons2 = require("@ant-design/icons"); var import_refine_core3 = require("@ucheeddev/refine-core"); var import_antd11 = require("antd"); // src/components/text/text.tsx var import_antd10 = require("antd"); // src/components/text/sizes.ts var sizes = { xs: { fontSize: 12, lineHeight: 20 / 12 }, sm: { fontSize: 14, lineHeight: 22 / 14 }, md: { fontSize: 16, lineHeight: 24 / 16 }, lg: { fontSize: 20, lineHeight: 28 / 20 }, xl: { fontSize: 24, lineHeight: 32 / 24 }, xxl: { fontSize: 30, lineHeight: 38 / 30 }, xxxl: { fontSize: 38, lineHeight: 46 / 38 }, huge: { fontSize: 46, lineHeight: 54 / 46 }, xhuge: { fontSize: 56, lineHeight: 64 / 56 }, xxhuge: { fontSize: 68, lineHeight: 76 / 68 } }; // src/components/text/text.tsx var import_jsx_runtime8 = require("react/jsx-runtime"); var Text = ({ size = "sm", children, ...rest }) => { return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( import_antd10.ConfigProvider, { theme: { token: { ...sizes[size] } }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd10.Typography.Text, { ...rest, children }) } ); }; // src/components/current-user/current-user.tsx var import_jsx_runtime9 = require("react/jsx-runtime"); var CurrentUser = () => { const { data: user } = (0, import_core2.useGetIdentity)(); const role = (0, import_refine_core3.useCurrentUserRole)(); const { mutate: logout } = (0, import_core2.useLogout)(); const content = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)( "div", { style: { display: "flex", flexDirection: "column" }, children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)( "div", { style: { padding: "12px 20px" }, children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_antd11.Space, { size: 8, children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons2.UserOutlined, { className: "md colorPrimary" }), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { strong: true, children: user?.display_name }) ] }) }), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { paddingTop: 7 }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_antd11.Space, { size: 12, children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons2.MailOutlined, { className: "md colorPrimary" }), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( EmailLink, { email: user?.email || "", style: { fontSize: 14, color: "#000" } } ) ] }) }), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { paddingTop: 7 }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_antd11.Space, { size: 12, children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons2.UserSwitchOutlined, { className: "md colorPrimary" }), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { strong: true, children: role?.label }) ] }) }) ] } ), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "div", { style: { borderTop: "1px solid #d9d9d9", padding: "4px", display: "flex", flexDirection: "column", gap: "4px" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "div", { style: { padding: "8px", display: "flex", flexDirection: "column", gap: "4px" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( import_antd11.Button, { style: { textAlign: "left" }, icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons2.LogoutOutlined, {}), type: "text", danger: true, block: true, onClick: () => logout(), children: "Logout" } ) } ) } ) } ) ] } ); return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( import_antd11.Popover, { placement: "bottomRight", content, trigger: "click", overlayInnerStyle: { padding: 0 }, overlayStyle: { zIndex: 999 }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( CustomAvatar, { name: user?.display_name || "", src: user?.avatar_url || "", size: "default", style: { cursor: "pointer" } } ) } ); }; // src/components/icons/icon-invoicer.tsx var import_jsx_runtime10 = require("react/jsx-runtime"); var IconInvoicerLogo = (props) => { const { mode } = useConfigProvider(); const isDarkMode = mode === "dark"; return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)( "svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 20, viewBox: "0 0 24 20", fill: "none", ...props, children: [ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("title", { children: "Invoicer" }), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( "path", { fill: isDarkMode ? "#3E2069" : "#EFDBFF", d: "m0 0 24 4v12L0 20V0Z" } ), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( "path", { fill: isDarkMode ? "#CDA8F0" : "#531DAB", d: "M4.5 14.015 7.54 20 24 0 4.5 14.015Z" } ), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( "path", { fill: isDarkMode ? "#EBD7FA" : "#22075E", d: "M7.54 20v-4l2.681 1.267L7.541 20Z" } ), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( "path", { fill: isDarkMode ? "#AB7AE0" : "#9254DE", d: "m0 11 4.5 3.015L24 0 7.54 16 16 20l8-20L0 11Z" } ) ] } ); }; // src/components/icons/icon-moon.tsx var import_jsx_runtime11 = require("react/jsx-runtime"); var IconMoon = () => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)( "svg", { xmlns: "http://www.w3.org/2000/svg", className: "icon icon-tabler icon-tabler-moon-stars", width: 20, height: 20, viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" }), /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M17 4a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2" }), /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M19 11h2m-1 -1v2" }) ] } ); // src/components/icons/icon-sun.tsx var import_jsx_runtime12 = require("react/jsx-runtime"); var IconSun = () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)( "svg", { xmlns: "http://www.w3.org/2000/svg", className: "icon icon-tabler icon-tabler-sun", width: 20, height: 20, viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: 12, cy: 12, r: 4 }), /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7" }) ] } ); // src/components/logo/logo.tsx var import_jsx_runtime13 = require("react/jsx-runtime"); var WIDTH = 120; var HEIGHT = 120; var Logo = ({ height, width, src, alt }) => { height = height || HEIGHT; width = width || WIDTH; if (!src) { return; } return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( "img", { alt, src, width, height, style: { maxWidth: "100%", maxHeight: "100%" } } ); }; // src/components/sider/menu-items.tsx var import_core3 = require("@refinedev/core"); var import_icons3 = require("@ant-design/icons"); var import_antd12 = require("antd"); var import_jsx_runtime14 = require("react/jsx-runtime"); var renderMenuItems = ({ tree, selectedKey, Link: Link5, siderCollapsed }) => { return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: tree.map((item) => { const { icon, label, route, key, name, children, parentName, meta, options } = item; if (children.length > 0) { return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( import_core3.CanAccess, { resource: name.toLowerCase(), action: "list", params: { resource: item }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( import_antd12.Menu.SubMenu, { icon: icon ?? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons3.UnorderedListOutlined, {}), title: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link5, { style: { color: "inherit" }, to: route ?? "", children: label }), children: renderMenuItems({ tree: children, selectedKey, Link: Link5, siderCollapsed }) } ) }, key ); } const isSelected = key === selectedKey; const isRoute = !((0, import_core3.pickNotDeprecated)(meta?.parent, options?.parent, parentName) !== void 0 && children.length === 0); return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( import_core3.CanAccess, { resource: name.toLowerCase(), action: "list", params: { resource: item }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)( import_antd12.Menu.Item, { icon: icon ?? (isRoute && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons3.UnorderedListOutlined, {})), children: [ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link5, { to: route ?? "", children: label }), !siderCollapsed && isSelected && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "ant-menu-tree-arrow" }) ] }, key ) }, key ); }) }); }; // src/components/header-with-menu/styled.tsx var import_antd_style2 = require("antd-style"); var useStyles = (0, import_antd_style2.createStyles)(({ css, token, isDarkMode, responsive }) => { return { headerContainer: { backgroundColor: token.colorBgElevated, padding: "0 16px", minHeight: "48px", height: "max-content" }, flexContainer: { width: "100%", maxWidth: "1440px", margin: "0 auto", height: "100%" }, headerTitleRefine: { fontFamily: "Bricolage Grotesque, sans-serif", color: isDarkMode ? token["purple-10"] : token["purple-8"] }, headerTitleInvoicer: { fontFamily: "Bricolage Grotesque, sans-serif", color: isDarkMode ? token["purple-10"] : token["purple-8"], fontWeight: 700 }, tabs: css` margin-left: auto; margin-right: auto; width: 600px; ${responsive.mobile} { width: 320px; } `, inputSuffix: { width: "20px", height: "20px", display: "flex", alignItems: "center", justifyContent: "center", backgroundColor: token.colorBgTextHover, color: token.colorTextDisabled, borderRadius: "4px", fontSize: "12px" }, inputPrefix: { color: token.colorTextPlaceholder, marginRight: "4px" }, languageSwitchText: { color: token.colorTextSecondary }, languageSwitchIcon: { color: token.colorTextTertiary, width: "10px" }, themeSwitch: { display: "flex", alignItems: "center", justifyContent: "center", height: "32px", width: "32px", borderRadius: "50%", cursor: "pointer", flexShrink: 0, backgroundColor: isDarkMode ? token.colorBgLayout : token.colorBgTextHover }, rightSlot: { marginLeft: "auto", "@media (max-width: 1000px)": { padding: "16px" } } }; }); // src/components/header-with-menu/header-with-menu.tsx var import_jsx_runtime15 = require("react/jsx-runtime"); var HeaderWithMenu = ({ Search, logo, logoWidth, logoHeight, hideThemeButton }) => { const { menuItems, selectedKey, defaultOpenKeys } = (0, import_core4.useMenu)(); const { styles: styles2 } = useStyles(); const { isDarkMode, toggleMode } = useConfigProvider(); return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( import_antd13.Layout.Header, { className: (0, import_classnames.default)("print-hidden", styles2.headerContainer), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)( import_antd13.Flex, { align: "center", justify: "space-between", wrap: "wrap", className: styles2.flexContainer, children: [ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd13.Flex, { align: "center", wrap: "wrap", children: [ logo ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( import_core4.Link, { go: { to: "/" }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Logo, { src: logo, width: logoWidth, height: logoHeight }) } ) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, {}), /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( import_antd13.Menu, { selectedKeys: selectedKey ? [selectedKey] : [], defaultOpenKeys, mode: "horizontal", className: styles2.tabs, children: renderMenuItems({ tree: menuItems, Link: import_core4.Link, selectedKey, siderCollapsed: false }) } ) ] }), /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd13.Flex, { align: "center", gap: 32, className: styles2.rightSlot, children: [ Search ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Search, {}) : null, !hideThemeButton && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( import_antd13.Button, { className: styles2.themeSwitch, type: "text", icon: !isDarkMode ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(IconMoon, {}) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(IconSun, {}), onClick: () => { toggleMode(); } } ), /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CurrentUser, {}) ] }) ] } ) } ); }; // src/components/full-width-layout/full-width-layout.tsx var import_jsx_runtime16 = require("react/jsx-runtime"); var FullWidthLayout = ({ headerProps, children }) => { return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( import_antd14.ThemedLayoutV2, { Header: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HeaderWithMenu, { ...headerProps || {} }), Sider: () => null, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( "div", { style: { maxWidth: "1280px", padding: "24px", margin: "0 auto" }, children } ) } ); }; // src/components/header/header.tsx var import_antd15 = require("antd"); var import_jsx_runtime17 = require("react/jsx-runtime"); var { useToken } = import_antd15.theme; var HeaderWithSearch = ({ Search }) => { const { token } = useToken(); const headerStyles = { backgroundColor: token.colorBgElevated, display: "flex", justifyContent: Search ? "space-between" : "flex-end", alignItems: "center", padding: "0px 24px", height: "64px", position: "sticky", top: 0, zIndex: 999 }; return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd15.Layout.Header, { style: headerStyles, children: [ Search ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Search, {}) : null, /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd15.Space, { align: "center", size: "middle", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CurrentUser, {}) }) ] }); }; // src/components/image-upload/image-upload.tsx var import_antd16 = require("antd"); // src/components/upload-button/upload-button.tsx var import_jsx_runtime18 = require("react/jsx-runtime"); var UploadButton = ({ icon, label }) => { return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("button", { style: { border: 0, background: "none" }, type: "button", children: [ icon, /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { marginTop: 8 }, children: label }) ] }); }; // src/components/image-upload/image-upload.tsx var import_jsx_runtime19 = require("react/jsx-runtime"); var ImageUpload = ({ listType, fileList, onPreview, onChange, previewImage, previewImageOpen, onVisibleChange, afterOpenChange, onRemove, multiple, disabled, ...rest }) => { return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( import_antd16.Upload, { listType: listType || "picture-card", fileList, onPreview, onChange, beforeUpload: () => false, onRemove, multiple, disabled, ...rest, children: fileList && fileList.length >= 1 && !multiple ? null : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(UploadButton, {}) } ), previewImage && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( import_antd16.Image, { wrapperStyle: { display: "none" }, preview: { visible: previewImageOpen, onVisibleChange, afterOpenChange }, src: previewImage } ) ] }); }; // src/components/layout/layout.tsx var import_antd24 = require("@refinedev/antd"); var import_antd25 = require("antd"); // src/context/layout/layout-context.ts var import_react5 = require("react"); var DEFAULT_VALUE = { noPadding: false, enableLayoutPadding: () => null, disableLayoutPadding: () => null }; var LayoutContext = (0, import_react5.createContext)(DEFAULT_VALUE); var useLayoutContext = () => (0, import_react5.useContext)(LayoutContext); // src/components/layout-context-provider/layout-context-provider.tsx var import_react6 = require("react"); var import_jsx_runtime20 = require("react/jsx-runtime"); var LayoutContextProvider = ({ children }) => { const [noPadding, setNoPadding] = (0, import_react6.useState)(false); const enableLayoutPadding = (0, import_react6.useCallback)(() => { setNoPadding(false); }, []); const disableLayoutPadding = (0,