update utils
This commit is contained in:
parent
34959deb18
commit
97407cffc0
10
README.md
10
README.md
@ -61,11 +61,19 @@ yarn upgrade uikit
|
||||
# utils
|
||||
|
||||
```js
|
||||
import { toFaDigits, toEnDigits, toFaNumber } from "uikit/utils";
|
||||
import { toFaDigits, toEnDigits, toFaNumber, processImage, truncateText, thinScrollbar } from "uikit/utils";
|
||||
|
||||
toFaDigits(123456);
|
||||
toEnDigits("۱۲۳۴۵۶");
|
||||
toFaNumber(123456);
|
||||
|
||||
processImage("https://example.com/image.jpg");
|
||||
processImage("https://example.com/image.jpg", { w: 300, h: 200, q: 70, webp: true, g: "sm" });
|
||||
|
||||
truncateText("این یک متن طولانی برای تست است", 12); // "این یک متن ط..."
|
||||
|
||||
// در Chakra UI، بدون dependency اضافه:
|
||||
// <Box overflowY="auto" sx={thinScrollbar}>...</Box>
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { jsxs as a, jsx as n } from "react/jsx-runtime";
|
||||
import { forwardRef as D, useState as k, useRef as L, useEffect as y } from "react";
|
||||
import { HStack as v, Text as u, IconButton as B, Button as S, Input as W } from "@chakra-ui/react";
|
||||
import { toFaDigits as t, toEnDigits as C } from "../utils.js";
|
||||
import { t, a as C } from "./numbers-CnO9mrbW.js";
|
||||
const A = D(
|
||||
({ size: i = 24, title: o, children: h, ...l }, r) => /* @__PURE__ */ a(
|
||||
"svg",
|
||||
18
dist/chunks/numbers-CnO9mrbW.js
vendored
Normal file
18
dist/chunks/numbers-CnO9mrbW.js
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
const t = (n) => {
|
||||
if (!(n == null || n === ""))
|
||||
return String(n).replace(/\d/g, (r) => "۰۱۲۳۴۵۶۷۸۹"[Number(r)]);
|
||||
}, e = (n) => {
|
||||
if (!(n == null || n === ""))
|
||||
return String(n).replace(
|
||||
/[۰-۹]/g,
|
||||
(r) => String("۰۱۲۳۴۵۶۷۸۹".indexOf(r))
|
||||
);
|
||||
}, i = (n) => {
|
||||
if (!(n == null || n === ""))
|
||||
return new Intl.NumberFormat("fa-IR").format(Number(n));
|
||||
};
|
||||
export {
|
||||
e as a,
|
||||
i as b,
|
||||
t
|
||||
};
|
||||
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -1,6 +1,10 @@
|
||||
import { toEnDigits as i, toFaDigits as r, toFaNumber as a } from "./utils.js";
|
||||
import { a as o, t as r, b as e } from "./chunks/numbers-CnO9mrbW.js";
|
||||
import { processImage as i, thinScrollbar as m, truncateText as b } from "./utils.js";
|
||||
export {
|
||||
i as toEnDigits,
|
||||
i as processImage,
|
||||
m as thinScrollbar,
|
||||
o as toEnDigits,
|
||||
r as toFaDigits,
|
||||
a as toFaNumber
|
||||
e as toFaNumber,
|
||||
b as truncateText
|
||||
};
|
||||
|
||||
46
dist/pagination.js
vendored
46
dist/pagination.js
vendored
@ -1,14 +1,14 @@
|
||||
import { jsxs as A, jsx as s } from "react/jsx-runtime";
|
||||
import { useState as B, useRef as g, useEffect as v, useCallback as E } from "react";
|
||||
import { HStack as y, IconButton as I, Button as N, Input as j, Text as M } from "@chakra-ui/react";
|
||||
import { toFaDigits as f, toEnDigits as D } from "./utils.js";
|
||||
import { C as z, a as S } from "./chunks/Pagination-DjllHYU8.js";
|
||||
import { P as J } from "./chunks/Pagination-DjllHYU8.js";
|
||||
import { t as f, a as D } from "./chunks/numbers-CnO9mrbW.js";
|
||||
import { C as z, a as S } from "./chunks/Pagination-AcPxxOEh.js";
|
||||
import { P as J } from "./chunks/Pagination-AcPxxOEh.js";
|
||||
const K = ({
|
||||
currentPage: e,
|
||||
totalPages: t,
|
||||
totalCount: k,
|
||||
onPageChange: a
|
||||
onPageChange: p
|
||||
}) => {
|
||||
const [r, n] = B(f(e)), [d, c] = B(!1), [b, o] = B(null), x = g(null), h = [.../* @__PURE__ */ new Set([1, e, t])].filter(
|
||||
(i) => i >= 1 && i <= t
|
||||
@ -26,7 +26,7 @@ const K = ({
|
||||
const m = setTimeout(() => {
|
||||
var C;
|
||||
const u = Math.min(Math.max(i, 1), t);
|
||||
u !== e ? (o(u), n(f(u)), a(u)) : (c(!1), n(f(e))), (C = x.current) == null || C.blur();
|
||||
u !== e ? (o(u), n(f(u)), p(u)) : (c(!1), n(f(e))), (C = x.current) == null || C.blur();
|
||||
}, 1e3);
|
||||
return () => clearTimeout(m);
|
||||
}, [
|
||||
@ -35,7 +35,7 @@ const K = ({
|
||||
b,
|
||||
t,
|
||||
e,
|
||||
a
|
||||
p
|
||||
]);
|
||||
const w = () => {
|
||||
var u, C;
|
||||
@ -45,7 +45,7 @@ const K = ({
|
||||
return;
|
||||
}
|
||||
const m = Math.min(Math.max(i, 1), t);
|
||||
m !== e ? (o(m), n(f(m)), a(m)) : (n(f(e)), c(!1), o(null)), (C = x.current) == null || C.blur();
|
||||
m !== e ? (o(m), n(f(m)), p(m)) : (n(f(e)), c(!1), o(null)), (C = x.current) == null || C.blur();
|
||||
};
|
||||
return t === 0 || !k ? null : /* @__PURE__ */ A(
|
||||
y,
|
||||
@ -67,7 +67,7 @@ const K = ({
|
||||
bg: "#e6e6f1",
|
||||
color: "#4B49AC",
|
||||
_hover: { bg: "#cbcbe8" },
|
||||
onClick: () => a(e - 1),
|
||||
onClick: () => p(e - 1),
|
||||
isDisabled: e === 1,
|
||||
icon: /* @__PURE__ */ s(z, {}),
|
||||
"aria-label": "صفحه قبلی"
|
||||
@ -81,7 +81,7 @@ const K = ({
|
||||
bg: e === i ? "#4B49AC" : "#e6e6f1",
|
||||
color: e === i ? "#e6e6f1" : "#4B49AC",
|
||||
_hover: { bg: e === i ? "#4B49AC" : "#cbcbe8" },
|
||||
onClick: () => a(i),
|
||||
onClick: () => p(i),
|
||||
variant: "soft",
|
||||
children: f(i)
|
||||
},
|
||||
@ -94,7 +94,7 @@ const K = ({
|
||||
bg: "#e6e6f1",
|
||||
color: "#4B49AC",
|
||||
_hover: { bg: "#cbcbe8" },
|
||||
onClick: () => a(e + 1),
|
||||
onClick: () => p(e + 1),
|
||||
isDisabled: e === t,
|
||||
icon: /* @__PURE__ */ s(S, {}),
|
||||
"aria-label": "صفحه بعدی"
|
||||
@ -141,14 +141,14 @@ const K = ({
|
||||
currentPage: e,
|
||||
totalPages: t,
|
||||
totalCount: k,
|
||||
onPageChange: a
|
||||
onPageChange: p
|
||||
}) => {
|
||||
const [r, n] = B(""), [d, c] = B(!1), [b, o] = B(null), x = g(null), h = b ?? e, w = E(
|
||||
(l) => {
|
||||
const p = Math.min(Math.max(l, 1), t);
|
||||
c(!1), n(""), o(null), p !== e && a(p);
|
||||
const a = Math.min(Math.max(l, 1), t);
|
||||
c(!1), n(""), o(null), a !== e && p(a);
|
||||
},
|
||||
[e, t, a]
|
||||
[e, t, p]
|
||||
), i = E(() => {
|
||||
if (!r) {
|
||||
c(!1), n(""), o(null);
|
||||
@ -159,9 +159,9 @@ const K = ({
|
||||
c(!1), n(""), o(null);
|
||||
return;
|
||||
}
|
||||
const p = Math.min(Math.max(l, 1), t);
|
||||
c(!1), n(""), p !== e ? (o(p), a(p)) : o(null);
|
||||
}, [r, e, t, a]);
|
||||
const a = Math.min(Math.max(l, 1), t);
|
||||
c(!1), n(""), a !== e ? (o(a), p(a)) : o(null);
|
||||
}, [r, e, t, p]);
|
||||
v(() => {
|
||||
var l;
|
||||
d && ((l = x.current) == null || l.focus());
|
||||
@ -176,14 +176,14 @@ const K = ({
|
||||
}, [r, d, i]);
|
||||
const m = () => {
|
||||
o(null), n(""), c(!0);
|
||||
}, u = (l, p = !1) => /* @__PURE__ */ s(
|
||||
}, u = (l, a = !1) => /* @__PURE__ */ s(
|
||||
N,
|
||||
{
|
||||
size: "md",
|
||||
bg: p ? "#4B49AC" : "#e6e6f1",
|
||||
color: p ? "#e6e6f1" : "#4B49AC",
|
||||
_hover: { bg: p ? "#4B49AC" : "#cbcbe8" },
|
||||
onClick: p ? m : () => w(l),
|
||||
bg: a ? "#4B49AC" : "#e6e6f1",
|
||||
color: a ? "#e6e6f1" : "#4B49AC",
|
||||
_hover: { bg: a ? "#4B49AC" : "#cbcbe8" },
|
||||
onClick: a ? m : () => w(l),
|
||||
variant: "soft",
|
||||
children: f(l)
|
||||
},
|
||||
@ -227,7 +227,7 @@ const K = ({
|
||||
w: "48px",
|
||||
value: r,
|
||||
onChange: (l) => {
|
||||
const p = l.target.value, V = D(p).replace(/\D/g, "");
|
||||
const a = l.target.value, V = D(a).replace(/\D/g, "");
|
||||
n(f(V));
|
||||
},
|
||||
onBlur: () => {
|
||||
|
||||
56
dist/table.js
vendored
56
dist/table.js
vendored
@ -1,8 +1,8 @@
|
||||
import { jsx as r, jsxs as X, Fragment as ne } from "react/jsx-runtime";
|
||||
import { VStack as oe, Box as _, Tbody as re, Tr as H, Td as F, Text as R, Thead as le, Th as ce, Table as se, Checkbox as W, HStack as Y, Spacer as ie } from "@chakra-ui/react";
|
||||
import { P as ue } from "./chunks/Pagination-DjllHYU8.js";
|
||||
import { toFaDigits as q } from "./utils.js";
|
||||
import { useReactTable as ae, getCoreRowModel as de, flexRender as J } from "@tanstack/react-table";
|
||||
import { P as ae } from "./chunks/Pagination-AcPxxOEh.js";
|
||||
import { t as q } from "./chunks/numbers-CnO9mrbW.js";
|
||||
import { useReactTable as ue, getCoreRowModel as de, flexRender as J } from "@tanstack/react-table";
|
||||
import { useMemo as P, useCallback as p, useState as me, useRef as fe, useEffect as ge, createContext as he, useContext as be } from "react";
|
||||
const K = he(null);
|
||||
function C() {
|
||||
@ -18,7 +18,7 @@ function xe({
|
||||
page: s = 1,
|
||||
size: c = 10,
|
||||
pagination: l,
|
||||
onPageChange: a,
|
||||
onPageChange: u,
|
||||
getRowId: g = (d) => String(d == null ? void 0 : d.id),
|
||||
enableSelection: b = !1,
|
||||
showIndex: S = !0,
|
||||
@ -31,15 +31,15 @@ function xe({
|
||||
pageSize: h
|
||||
}), [d, h]), Q = p(
|
||||
(n) => {
|
||||
const u = (typeof n == "function" ? n(z) : n).pageIndex + 1;
|
||||
u !== d && (a == null || a(u));
|
||||
const a = (typeof n == "function" ? n(z) : n).pageIndex + 1;
|
||||
a !== d && (u == null || u(a));
|
||||
},
|
||||
[z, d, a]
|
||||
[z, d, u]
|
||||
), [A, U] = me(L), m = p(
|
||||
(n) => {
|
||||
U((i) => {
|
||||
const u = typeof n == "function" ? n(i) : n;
|
||||
return k == null || k(u), u;
|
||||
const a = typeof n == "function" ? n(i) : n;
|
||||
return k == null || k(a), a;
|
||||
});
|
||||
},
|
||||
[k]
|
||||
@ -60,7 +60,7 @@ function xe({
|
||||
m([]);
|
||||
}, [m]), B = p(
|
||||
(n) => {
|
||||
m((i) => f.includes(n) ? i.includes(n) ? i.filter((u) => u !== n) : [...i, n] : i);
|
||||
m((i) => f.includes(n) ? i.includes(n) ? i.filter((a) => a !== n) : [...i, n] : i);
|
||||
},
|
||||
[f, m]
|
||||
), Z = B, I = p(() => {
|
||||
@ -81,20 +81,20 @@ function xe({
|
||||
return b && n.push({
|
||||
id: "__selection",
|
||||
header: ({ table: i }) => {
|
||||
const u = i.options.meta;
|
||||
const a = i.options.meta;
|
||||
return /* @__PURE__ */ r(
|
||||
W,
|
||||
{
|
||||
isChecked: u.isAllSelected,
|
||||
isIndeterminate: u.isIndeterminate,
|
||||
onChange: (x) => u.toggleSelectAll(x.target.checked),
|
||||
isChecked: a.isAllSelected,
|
||||
isIndeterminate: a.isIndeterminate,
|
||||
onChange: (x) => a.toggleSelectAll(x.target.checked),
|
||||
colorScheme: "purple",
|
||||
size: "md"
|
||||
}
|
||||
);
|
||||
},
|
||||
cell: ({ row: i, table: u }) => {
|
||||
const x = u.options.meta, D = x.getRowId(i.original);
|
||||
cell: ({ row: i, table: a }) => {
|
||||
const x = a.options.meta, D = x.getRowId(i.original);
|
||||
return /* @__PURE__ */ r(
|
||||
W,
|
||||
{
|
||||
@ -109,14 +109,14 @@ function xe({
|
||||
}), S && n.push({
|
||||
id: "__index",
|
||||
header: "ردیف",
|
||||
cell: ({ row: i, table: u }) => {
|
||||
const { pageIndex: x, pageSize: D } = u.getState().pagination, te = x * D + i.index + 1;
|
||||
cell: ({ row: i, table: a }) => {
|
||||
const { pageIndex: x, pageSize: D } = a.getState().pagination, te = x * D + i.index + 1;
|
||||
return /* @__PURE__ */ r(R, { fontWeight: "bold", sx: { fontVariantNumeric: "normal" }, children: q(te) });
|
||||
},
|
||||
meta: { isCentered: !0 }
|
||||
}), [...n, ...o];
|
||||
}, [o, b, S]), ee = {
|
||||
table: ae({
|
||||
table: ue({
|
||||
data: t,
|
||||
columns: E,
|
||||
getCoreRowModel: de(),
|
||||
@ -149,7 +149,7 @@ function xe({
|
||||
page: d,
|
||||
size: h,
|
||||
pagination: l,
|
||||
onPageChange: a,
|
||||
onPageChange: u,
|
||||
paginationState: z,
|
||||
totalCount: y,
|
||||
totalPages: v,
|
||||
@ -193,14 +193,14 @@ function ke({ children: e = "انتخاب همه", ...t }) {
|
||||
enableSelection: s,
|
||||
isAllSelected: c,
|
||||
isIndeterminate: l,
|
||||
toggleSelectAll: a
|
||||
toggleSelectAll: u
|
||||
} = C();
|
||||
return !s || o.length === 0 ? null : /* @__PURE__ */ r(
|
||||
W,
|
||||
{
|
||||
isChecked: c,
|
||||
isIndeterminate: l,
|
||||
onChange: (g) => a(g.target.checked),
|
||||
onChange: (g) => u(g.target.checked),
|
||||
colorScheme: "purple",
|
||||
size: "lg",
|
||||
...t,
|
||||
@ -322,7 +322,7 @@ function De({ emptyText: e = "موردی وجود ندارد" }) {
|
||||
_hover: { bg: "blue.50" },
|
||||
transition: "0.2s",
|
||||
children: c.getVisibleCells().map((l) => {
|
||||
var a;
|
||||
var u;
|
||||
return /* @__PURE__ */ r(
|
||||
F,
|
||||
{
|
||||
@ -331,7 +331,7 @@ function De({ emptyText: e = "موردی وجود ندارد" }) {
|
||||
color: "gray.700",
|
||||
borderRightWidth: "1px",
|
||||
borderRightColor: "gray.200",
|
||||
textAlign: (a = l.column.columnDef.meta) != null && a.isCentered ? "center" : "start",
|
||||
textAlign: (u = l.column.columnDef.meta) != null && u.isCentered ? "center" : "start",
|
||||
verticalAlign: "middle",
|
||||
children: l.column.columnDef.cell ? J(l.column.columnDef.cell, l.getContext()) : l.getValue()
|
||||
},
|
||||
@ -346,20 +346,20 @@ function Pe({
|
||||
pagination: e,
|
||||
onPageChange: t
|
||||
}) {
|
||||
const o = C(), { table: s } = o, c = e ?? o.pagination, l = (c == null ? void 0 : c.total) ?? (c == null ? void 0 : c.totalCount) ?? o.totalCount ?? 0, a = (c == null ? void 0 : c.total_pages) ?? (c == null ? void 0 : c.totalPages) ?? o.totalPages ?? s.getPageCount() ?? 0, g = s.getState().pagination.pageIndex + 1, b = (S) => {
|
||||
const o = C(), { table: s } = o, c = e ?? o.pagination, l = (c == null ? void 0 : c.total) ?? (c == null ? void 0 : c.totalCount) ?? o.totalCount ?? 0, u = (c == null ? void 0 : c.total_pages) ?? (c == null ? void 0 : c.totalPages) ?? o.totalPages ?? s.getPageCount() ?? 0, g = s.getState().pagination.pageIndex + 1, b = (S) => {
|
||||
if (t) {
|
||||
t(S);
|
||||
return;
|
||||
}
|
||||
s.setPageIndex(S - 1);
|
||||
};
|
||||
return !o.onPageChange && !t || a <= 0 ? null : /* @__PURE__ */ r(_, { mt: 1, flexShrink: 0, children: /* @__PURE__ */ r(
|
||||
ue,
|
||||
return !o.onPageChange && !t || u <= 0 ? null : /* @__PURE__ */ r(_, { mt: 1, flexShrink: 0, children: /* @__PURE__ */ r(
|
||||
ae,
|
||||
{
|
||||
currentPage: g,
|
||||
onPageChange: b,
|
||||
totalCount: l,
|
||||
totalPages: a
|
||||
totalPages: u
|
||||
}
|
||||
) });
|
||||
}
|
||||
|
||||
21
dist/utils.d.ts
vendored
21
dist/utils.d.ts
vendored
@ -1,3 +1,24 @@
|
||||
export function toFaNumber(value: string | number): string;
|
||||
export function toFaDigits(value: string | number): string;
|
||||
export function toEnDigits(value: string | number): string;
|
||||
|
||||
export interface ProcessImageOptions {
|
||||
w?: number;
|
||||
h?: number;
|
||||
q?: number;
|
||||
webp?: boolean;
|
||||
g?: string;
|
||||
}
|
||||
|
||||
export function processImage(url?: string | null, options?: ProcessImageOptions): string;
|
||||
|
||||
export function truncateText(str: string | null | undefined, length: number): string;
|
||||
|
||||
export const thinScrollbar: {
|
||||
scrollbarWidth: "thin";
|
||||
scrollbarColor: string;
|
||||
"&::-webkit-scrollbar": { width: string; height: string };
|
||||
"&::-webkit-scrollbar-track": { background: string };
|
||||
"&::-webkit-scrollbar-thumb": { backgroundColor: string; borderRadius: string };
|
||||
"&::-webkit-scrollbar-button": { display: "none"; width: number; height: number };
|
||||
};
|
||||
|
||||
45
dist/utils.js
vendored
45
dist/utils.js
vendored
@ -1,18 +1,33 @@
|
||||
const t = (n) => {
|
||||
if (!(n == null || n === ""))
|
||||
return String(n).replace(/\d/g, (r) => "۰۱۲۳۴۵۶۷۸۹"[Number(r)]);
|
||||
}, e = (n) => {
|
||||
if (!(n == null || n === ""))
|
||||
return String(n).replace(
|
||||
/[۰-۹]/g,
|
||||
(r) => String("۰۱۲۳۴۵۶۷۸۹".indexOf(r))
|
||||
);
|
||||
}, i = (n) => {
|
||||
if (!(n == null || n === ""))
|
||||
return new Intl.NumberFormat("fa-IR").format(Number(n));
|
||||
import { a as u, t as g, b as h } from "./chunks/numbers-CnO9mrbW.js";
|
||||
const b = (r, { w: t, h: a, q: e = 70, webp: i = !0, g: o = "sm" } = {}) => r ? `https://img.d.aiengines.ir/preset:sharp${t || a ? `/rs:auto:${t || 0}:${a || 0}:0` : ""}/q:${e}/g:${o}/plain/${r}${i ? "@webp" : ""}` : "";
|
||||
function s(r, t) {
|
||||
return (r == null ? void 0 : r.length) < t ? r : (r == null ? void 0 : r.slice(0, t)) + "...";
|
||||
}
|
||||
const l = {
|
||||
scrollbarWidth: "thin",
|
||||
scrollbarColor: "rgba(0,0,0,0.22) transparent",
|
||||
"&::-webkit-scrollbar": {
|
||||
width: "4px",
|
||||
height: "4px"
|
||||
},
|
||||
"&::-webkit-scrollbar-track": {
|
||||
background: "transparent"
|
||||
},
|
||||
"&::-webkit-scrollbar-thumb": {
|
||||
backgroundColor: "rgba(0,0,0,0.22)",
|
||||
borderRadius: "999px"
|
||||
},
|
||||
"&::-webkit-scrollbar-button": {
|
||||
display: "none",
|
||||
width: 0,
|
||||
height: 0
|
||||
}
|
||||
};
|
||||
export {
|
||||
e as toEnDigits,
|
||||
t as toFaDigits,
|
||||
i as toFaNumber
|
||||
b as processImage,
|
||||
l as thinScrollbar,
|
||||
u as toEnDigits,
|
||||
g as toFaDigits,
|
||||
h as toFaNumber,
|
||||
s as truncateText
|
||||
};
|
||||
|
||||
8
src/utils/images.js
Normal file
8
src/utils/images.js
Normal file
@ -0,0 +1,8 @@
|
||||
export const processImage = (
|
||||
url,
|
||||
{ w, h, q = 70, webp = true, g = "sm" } = {},
|
||||
) => {
|
||||
if (!url) return "";
|
||||
const resizePart = w || h ? `/rs:auto:${w || 0}:${h || 0}:0` : "";
|
||||
return `https://img.d.aiengines.ir/preset:sharp${resizePart}/q:${q}/g:${g}/plain/${url}${webp ? "@webp" : ""}`;
|
||||
};
|
||||
21
src/utils/index.d.ts
vendored
21
src/utils/index.d.ts
vendored
@ -1,3 +1,24 @@
|
||||
export function toFaNumber(value: string | number): string;
|
||||
export function toFaDigits(value: string | number): string;
|
||||
export function toEnDigits(value: string | number): string;
|
||||
|
||||
export interface ProcessImageOptions {
|
||||
w?: number;
|
||||
h?: number;
|
||||
q?: number;
|
||||
webp?: boolean;
|
||||
g?: string;
|
||||
}
|
||||
|
||||
export function processImage(url?: string | null, options?: ProcessImageOptions): string;
|
||||
|
||||
export function truncateText(str: string | null | undefined, length: number): string;
|
||||
|
||||
export const thinScrollbar: {
|
||||
scrollbarWidth: "thin";
|
||||
scrollbarColor: string;
|
||||
"&::-webkit-scrollbar": { width: string; height: string };
|
||||
"&::-webkit-scrollbar-track": { background: string };
|
||||
"&::-webkit-scrollbar-thumb": { backgroundColor: string; borderRadius: string };
|
||||
"&::-webkit-scrollbar-button": { display: "none"; width: number; height: number };
|
||||
};
|
||||
|
||||
@ -1 +1,4 @@
|
||||
export { toFaNumber, toFaDigits, toEnDigits } from "./numbers.js";
|
||||
export { processImage } from "./images.js";
|
||||
export { default as truncateText } from "./text.js";
|
||||
export { thinScrollbar } from "./scrollbar.js";
|
||||
|
||||
21
src/utils/scrollbar.js
Normal file
21
src/utils/scrollbar.js
Normal file
@ -0,0 +1,21 @@
|
||||
export const thinScrollbar = {
|
||||
scrollbarWidth: "thin",
|
||||
scrollbarColor: "rgba(0,0,0,0.22) transparent",
|
||||
|
||||
"&::-webkit-scrollbar": {
|
||||
width: "4px",
|
||||
height: "4px",
|
||||
},
|
||||
"&::-webkit-scrollbar-track": {
|
||||
background: "transparent",
|
||||
},
|
||||
"&::-webkit-scrollbar-thumb": {
|
||||
backgroundColor: "rgba(0,0,0,0.22)",
|
||||
borderRadius: "999px",
|
||||
},
|
||||
"&::-webkit-scrollbar-button": {
|
||||
display: "none",
|
||||
width: 0,
|
||||
height: 0,
|
||||
},
|
||||
};
|
||||
4
src/utils/text.js
Normal file
4
src/utils/text.js
Normal file
@ -0,0 +1,4 @@
|
||||
export default function truncateText(str, length) {
|
||||
if (str?.length < length) return str;
|
||||
return str?.slice(0, length) + "...";
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user