@versini/ui-truncate 4.0.4 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/dist/components/Truncate/Truncate.js +181 -163
- package/dist/index.js +3 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
1
|
# @versini/ui-truncate
|
|
2
2
|
|
|
3
3
|
A simple truncate component for React.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @versini/ui-truncate
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Truncate } from "@versini/ui-truncate";
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<Truncate length={100} mode="dark" focusMode="light">
|
|
19
|
+
This is a very long text that needs to be truncated.
|
|
20
|
+
</Truncate>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Props
|
|
26
|
+
|
|
27
|
+
| Prop | Type | Default | Description |
|
|
28
|
+
| ----------- | ----------------------------------------------- | ---------- | -------------------------------------------------------------------- |
|
|
29
|
+
| `children` | `React.ReactNode` | `null` | The content to render. If not a string, it will be rendered as-is. |
|
|
30
|
+
| `length` | `number` | `200` | The maximum number of characters to display before truncating. |
|
|
31
|
+
| `mode` | `"dark" \| "light" \| "system" \| "alt-system"` | `"system"` | The mode of the button used for toggling truncated text. |
|
|
32
|
+
| `focusMode` | `"dark" \| "light" \| "system" \| "alt-system"` | `"system"` | The focus mode of the button, affecting the focus ring's appearance. |
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { Truncate } from "@versini/ui-truncate";
|
|
38
|
+
|
|
39
|
+
function App() {
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<Truncate length={50} mode="light" focusMode="dark">
|
|
43
|
+
Lorem ipsum dolor sit amet. Sed do ut labore et dolore magna aliqua. Sed
|
|
44
|
+
do ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet.
|
|
45
|
+
</Truncate>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Behavior
|
|
52
|
+
|
|
53
|
+
- If the `children` prop is not a string, the component will render the `children` as-is without truncation.
|
|
54
|
+
- If the text exceeds the specified `length`, it will be truncated, and a button will appear to toggle between the truncated and full text.
|
|
55
|
+
- The button's appearance and focus ring can be customized using the `mode` and `focusMode` props.
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as g, jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsx as g, jsxs as q } from "react/jsx-runtime";
|
|
2
|
+
import I, { useRef as w, useLayoutEffect as D, useEffect as A, useState as G, useMemo as P, useCallback as ae } from "react";
|
|
3
3
|
import n from "clsx";
|
|
4
|
-
const
|
|
4
|
+
const F = "av-button", R = "icon", S = "button", j = "link", ie = ({
|
|
5
5
|
type: e,
|
|
6
6
|
size: t,
|
|
7
7
|
labelRight: r,
|
|
@@ -9,16 +9,16 @@ const O = "av-button", T = "icon", M = "button", z = "link", ee = ({
|
|
|
9
9
|
align: o,
|
|
10
10
|
animated: i
|
|
11
11
|
}) => {
|
|
12
|
-
const
|
|
12
|
+
const l = "max-h-8 py-0 px-2", d = "max-h-9 h-8 px-3", s = "max-h-12 py-2 px-4";
|
|
13
13
|
switch (e) {
|
|
14
|
-
case
|
|
15
|
-
case
|
|
14
|
+
case S:
|
|
15
|
+
case j:
|
|
16
16
|
return n({
|
|
17
|
-
[
|
|
18
|
-
[
|
|
17
|
+
[l]: t === "small",
|
|
18
|
+
[d]: t === "medium",
|
|
19
19
|
[s]: t === "large"
|
|
20
20
|
});
|
|
21
|
-
case
|
|
21
|
+
case R:
|
|
22
22
|
return n("flex items-center", {
|
|
23
23
|
"justify-center": o === "center",
|
|
24
24
|
"justify-start": o === "left",
|
|
@@ -37,30 +37,30 @@ const O = "av-button", T = "icon", M = "button", z = "link", ee = ({
|
|
|
37
37
|
"h-12": t === "large" && i && (r || a)
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
},
|
|
40
|
+
}, ne = ({
|
|
41
41
|
type: e,
|
|
42
42
|
size: t,
|
|
43
43
|
labelRight: r,
|
|
44
44
|
labelLeft: a
|
|
45
45
|
}) => {
|
|
46
|
-
const o = "text-sm font-medium", i = "text-base font-medium",
|
|
46
|
+
const o = "text-sm font-medium", i = "text-base font-medium", l = "text-lg font-medium";
|
|
47
47
|
switch (e) {
|
|
48
|
-
case
|
|
49
|
-
case
|
|
48
|
+
case S:
|
|
49
|
+
case j:
|
|
50
50
|
return n({
|
|
51
|
-
"text-center": e ===
|
|
51
|
+
"text-center": e === j,
|
|
52
52
|
[o]: t === "small",
|
|
53
53
|
[i]: t === "medium",
|
|
54
|
-
[
|
|
54
|
+
[l]: t === "large"
|
|
55
55
|
});
|
|
56
|
-
case
|
|
56
|
+
case R:
|
|
57
57
|
return n({
|
|
58
58
|
[o]: t === "small" && (r || a),
|
|
59
59
|
[i]: t === "medium" && (r || a),
|
|
60
|
-
[
|
|
60
|
+
[l]: t === "large" && (r || a)
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
},
|
|
63
|
+
}, oe = ({
|
|
64
64
|
mode: e,
|
|
65
65
|
noBackground: t,
|
|
66
66
|
truncate: r,
|
|
@@ -96,7 +96,7 @@ const O = "av-button", T = "icon", M = "button", z = "link", ee = ({
|
|
|
96
96
|
return n("not-prose text-copy-lighter", {
|
|
97
97
|
truncate: r
|
|
98
98
|
});
|
|
99
|
-
},
|
|
99
|
+
}, le = ({
|
|
100
100
|
mode: e,
|
|
101
101
|
noBackground: t,
|
|
102
102
|
variant: r
|
|
@@ -126,13 +126,13 @@ const O = "av-button", T = "icon", M = "button", z = "link", ee = ({
|
|
|
126
126
|
if (r === "selected")
|
|
127
127
|
return "bg-action-selected-dark";
|
|
128
128
|
}
|
|
129
|
-
},
|
|
129
|
+
}, ce = ({
|
|
130
130
|
radius: e
|
|
131
131
|
}) => n({
|
|
132
132
|
"rounded-full": e === "large",
|
|
133
133
|
"rounded-md": e === "medium",
|
|
134
134
|
"rounded-xs": e === "small"
|
|
135
|
-
}),
|
|
135
|
+
}), de = ({
|
|
136
136
|
mode: e,
|
|
137
137
|
disabled: t,
|
|
138
138
|
variant: r
|
|
@@ -162,7 +162,7 @@ const O = "av-button", T = "icon", M = "button", z = "link", ee = ({
|
|
|
162
162
|
});
|
|
163
163
|
if (r === "selected")
|
|
164
164
|
return "hover:text-copy-light-hover hover:bg-action-selected-dark-hover";
|
|
165
|
-
},
|
|
165
|
+
}, se = ({
|
|
166
166
|
mode: e,
|
|
167
167
|
disabled: t,
|
|
168
168
|
variant: r
|
|
@@ -192,7 +192,7 @@ const O = "av-button", T = "icon", M = "button", z = "link", ee = ({
|
|
|
192
192
|
});
|
|
193
193
|
if (r === "selected")
|
|
194
194
|
return "active:text-copy-lighter-active active:bg-action-selected-dark-active";
|
|
195
|
-
},
|
|
195
|
+
}, ue = ({
|
|
196
196
|
mode: e,
|
|
197
197
|
noBorder: t,
|
|
198
198
|
variant: r
|
|
@@ -222,14 +222,14 @@ const O = "av-button", T = "icon", M = "button", z = "link", ee = ({
|
|
|
222
222
|
});
|
|
223
223
|
if (r === "selected")
|
|
224
224
|
return "border border-border-selected-dark";
|
|
225
|
-
},
|
|
225
|
+
}, ge = ({
|
|
226
226
|
focusMode: e
|
|
227
227
|
}) => n("focus:outline", "focus:outline-2", "focus:outline-offset-2", {
|
|
228
228
|
"focus:outline-focus-dark": e === "dark",
|
|
229
229
|
"focus:outline-focus-light": e === "light",
|
|
230
230
|
"focus:outline-focus-light dark:focus:outline-focus-dark": e === "alt-system",
|
|
231
231
|
"focus:outline-focus-dark dark:focus:outline-focus-light": e === "system"
|
|
232
|
-
}),
|
|
232
|
+
}), me = ({
|
|
233
233
|
mode: e,
|
|
234
234
|
raw: t,
|
|
235
235
|
iconClassName: r
|
|
@@ -241,77 +241,77 @@ const O = "av-button", T = "icon", M = "button", z = "link", ee = ({
|
|
|
241
241
|
"dark:text-copy-accent-dark": e === "system"
|
|
242
242
|
},
|
|
243
243
|
r
|
|
244
|
-
),
|
|
244
|
+
), he = ({
|
|
245
245
|
animated: e
|
|
246
246
|
}) => n({
|
|
247
|
-
"transition-opacity duration-300 ease-in": e
|
|
248
|
-
}),
|
|
247
|
+
"transition-opacity duration-300 ease-in-out": e
|
|
248
|
+
}), V = ({
|
|
249
249
|
type: e,
|
|
250
250
|
className: t,
|
|
251
251
|
raw: r,
|
|
252
252
|
mode: a,
|
|
253
253
|
focusMode: o,
|
|
254
254
|
disabled: i,
|
|
255
|
-
fullWidth:
|
|
256
|
-
size:
|
|
255
|
+
fullWidth: l,
|
|
256
|
+
size: d,
|
|
257
257
|
noBorder: s,
|
|
258
|
-
labelRight:
|
|
259
|
-
labelLeft:
|
|
258
|
+
labelRight: f,
|
|
259
|
+
labelLeft: k,
|
|
260
260
|
noBackground: u,
|
|
261
|
-
variant:
|
|
261
|
+
variant: c,
|
|
262
262
|
truncate: m,
|
|
263
|
-
align:
|
|
264
|
-
radius:
|
|
265
|
-
animated:
|
|
266
|
-
}) => (
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
align: N,
|
|
264
|
+
radius: E,
|
|
265
|
+
animated: T
|
|
266
|
+
}) => (c || (c = "primary"), r ? n(F, t) : n(
|
|
267
|
+
F,
|
|
268
|
+
oe({
|
|
269
269
|
mode: a,
|
|
270
|
-
variant:
|
|
270
|
+
variant: c,
|
|
271
271
|
noBackground: u,
|
|
272
272
|
truncate: m
|
|
273
273
|
}),
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
le({ mode: a, noBackground: u, variant: c }),
|
|
275
|
+
ce({ radius: E }),
|
|
276
|
+
ie({
|
|
277
277
|
type: e,
|
|
278
|
-
size:
|
|
279
|
-
labelRight:
|
|
280
|
-
labelLeft:
|
|
281
|
-
align:
|
|
282
|
-
animated:
|
|
278
|
+
size: d,
|
|
279
|
+
labelRight: f,
|
|
280
|
+
labelLeft: k,
|
|
281
|
+
align: N,
|
|
282
|
+
animated: T
|
|
283
283
|
}),
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
284
|
+
ne({ type: e, size: d, labelRight: f, labelLeft: k }),
|
|
285
|
+
ue({ mode: a, variant: c, noBorder: s }),
|
|
286
|
+
ge({ focusMode: o }),
|
|
287
|
+
de({ mode: a, variant: c, disabled: i }),
|
|
288
|
+
se({ mode: a, variant: c, disabled: i }),
|
|
289
289
|
{
|
|
290
|
-
"w-full":
|
|
290
|
+
"w-full": l,
|
|
291
291
|
"disabled:cursor-not-allowed disabled:opacity-50": i
|
|
292
292
|
},
|
|
293
293
|
n({
|
|
294
|
-
"transition-[width] duration-300 ease-in
|
|
294
|
+
"transition-[width] duration-300 ease-in": e === R && T
|
|
295
295
|
}),
|
|
296
296
|
t
|
|
297
|
-
)),
|
|
297
|
+
)), be = (e, t, r) => {
|
|
298
298
|
var a;
|
|
299
299
|
!t && (!document.activeElement || document.activeElement !== e.currentTarget) && typeof ((a = e == null ? void 0 : e.currentTarget) == null ? void 0 : a.focus) == "function" && e.currentTarget.focus(), typeof r == "function" && r(e);
|
|
300
|
-
},
|
|
300
|
+
}, O = I.forwardRef((e, t) => {
|
|
301
301
|
const { onClick: r, noInternalClick: a = !1, ...o } = e;
|
|
302
302
|
return /* @__PURE__ */ g(
|
|
303
303
|
"button",
|
|
304
304
|
{
|
|
305
305
|
ref: t,
|
|
306
306
|
onClick: (i) => {
|
|
307
|
-
|
|
307
|
+
be(i, a, r);
|
|
308
308
|
},
|
|
309
309
|
...o
|
|
310
310
|
}
|
|
311
311
|
);
|
|
312
312
|
});
|
|
313
|
-
|
|
314
|
-
const
|
|
313
|
+
O.displayName = "BaseButton";
|
|
314
|
+
const J = I.forwardRef(
|
|
315
315
|
({
|
|
316
316
|
children: e,
|
|
317
317
|
disabled: t = !1,
|
|
@@ -319,56 +319,56 @@ const P = B.forwardRef(
|
|
|
319
319
|
focusMode: a = "system",
|
|
320
320
|
fullWidth: o = !1,
|
|
321
321
|
className: i,
|
|
322
|
-
size:
|
|
323
|
-
raw:
|
|
322
|
+
size: l = "medium",
|
|
323
|
+
raw: d = !1,
|
|
324
324
|
noBorder: s = !1,
|
|
325
|
-
variant:
|
|
326
|
-
truncate:
|
|
325
|
+
variant: f = "primary",
|
|
326
|
+
truncate: k = !1,
|
|
327
327
|
radius: u = "large",
|
|
328
|
-
...
|
|
328
|
+
...c
|
|
329
329
|
}, m) => {
|
|
330
|
-
const
|
|
331
|
-
type:
|
|
330
|
+
const N = V({
|
|
331
|
+
type: S,
|
|
332
332
|
mode: r,
|
|
333
333
|
focusMode: a,
|
|
334
334
|
fullWidth: o,
|
|
335
335
|
disabled: t,
|
|
336
|
-
raw:
|
|
336
|
+
raw: d,
|
|
337
337
|
className: i,
|
|
338
|
-
size:
|
|
338
|
+
size: l,
|
|
339
339
|
noBorder: s,
|
|
340
|
-
variant:
|
|
341
|
-
truncate:
|
|
340
|
+
variant: f,
|
|
341
|
+
truncate: k,
|
|
342
342
|
radius: u
|
|
343
343
|
});
|
|
344
344
|
return /* @__PURE__ */ g(
|
|
345
|
-
|
|
345
|
+
O,
|
|
346
346
|
{
|
|
347
347
|
ref: m,
|
|
348
|
-
className:
|
|
348
|
+
className: N,
|
|
349
349
|
disabled: t,
|
|
350
|
-
...
|
|
350
|
+
...c,
|
|
351
351
|
children: e
|
|
352
352
|
}
|
|
353
353
|
);
|
|
354
354
|
}
|
|
355
355
|
);
|
|
356
|
-
|
|
357
|
-
function
|
|
358
|
-
const e =
|
|
359
|
-
return
|
|
356
|
+
J.displayName = "Button";
|
|
357
|
+
function fe() {
|
|
358
|
+
const e = w(!1);
|
|
359
|
+
return A(() => (e.current = !0, () => {
|
|
360
360
|
e.current = !1;
|
|
361
|
-
}), []),
|
|
361
|
+
}), []), ae(() => e.current, []);
|
|
362
362
|
}
|
|
363
|
-
function
|
|
364
|
-
return
|
|
363
|
+
function ye(e) {
|
|
364
|
+
return P(() => e.every((t) => t == null) ? () => {
|
|
365
365
|
} : (t) => {
|
|
366
366
|
e.forEach((r) => {
|
|
367
367
|
typeof r == "function" ? r(t) : r != null && (r.current = t);
|
|
368
368
|
});
|
|
369
369
|
}, e);
|
|
370
370
|
}
|
|
371
|
-
const
|
|
371
|
+
const ve = {
|
|
372
372
|
x: 0,
|
|
373
373
|
y: 0,
|
|
374
374
|
width: 0,
|
|
@@ -378,32 +378,32 @@ const me = {
|
|
|
378
378
|
bottom: 0,
|
|
379
379
|
right: 0
|
|
380
380
|
};
|
|
381
|
-
function
|
|
382
|
-
const t =
|
|
383
|
-
const s =
|
|
381
|
+
function M(e) {
|
|
382
|
+
const t = fe(), r = w(0), a = w(null), [o, i] = G(ve), l = P(() => typeof ResizeObserver > "u" ? null : new ResizeObserver((d) => {
|
|
383
|
+
const s = d[0];
|
|
384
384
|
s && (cancelAnimationFrame(r.current), r.current = requestAnimationFrame(() => {
|
|
385
385
|
a.current && t() && i(s.contentRect);
|
|
386
386
|
}));
|
|
387
387
|
}), [t]);
|
|
388
|
-
return
|
|
389
|
-
|
|
390
|
-
}), [
|
|
388
|
+
return A(() => (a.current && (l == null || l.observe(a.current, e)), () => {
|
|
389
|
+
l == null || l.disconnect(), r.current && cancelAnimationFrame(r.current);
|
|
390
|
+
}), [l, e]), [a, o];
|
|
391
391
|
}
|
|
392
|
-
const
|
|
392
|
+
const C = {
|
|
393
393
|
small: 24,
|
|
394
394
|
// w-6
|
|
395
395
|
medium: 32,
|
|
396
396
|
// w-8
|
|
397
397
|
large: 48
|
|
398
398
|
// w-12
|
|
399
|
-
},
|
|
399
|
+
}, ke = {
|
|
400
400
|
small: 8 * 2,
|
|
401
401
|
// px-2 x 2
|
|
402
402
|
medium: 12 * 2,
|
|
403
403
|
// px-3 x 2
|
|
404
404
|
large: 16 * 2
|
|
405
405
|
// px-4 x 2
|
|
406
|
-
},
|
|
406
|
+
}, pe = 2, xe = 300, K = I.forwardRef(
|
|
407
407
|
({
|
|
408
408
|
children: e,
|
|
409
409
|
disabled: t = !1,
|
|
@@ -411,107 +411,125 @@ const be = {
|
|
|
411
411
|
focusMode: a = "system",
|
|
412
412
|
fullWidth: o = !1,
|
|
413
413
|
className: i,
|
|
414
|
-
type:
|
|
415
|
-
raw:
|
|
414
|
+
type: l = "button",
|
|
415
|
+
raw: d = !1,
|
|
416
416
|
noBorder: s = !1,
|
|
417
|
-
"aria-label":
|
|
418
|
-
label:
|
|
417
|
+
"aria-label": f,
|
|
418
|
+
label: k,
|
|
419
419
|
size: u = "medium",
|
|
420
|
-
labelRight:
|
|
420
|
+
labelRight: c,
|
|
421
421
|
labelLeft: m,
|
|
422
|
-
noBackground:
|
|
423
|
-
align:
|
|
424
|
-
radius:
|
|
425
|
-
variant:
|
|
422
|
+
noBackground: N = !1,
|
|
423
|
+
align: E = "center",
|
|
424
|
+
radius: T = "large",
|
|
425
|
+
variant: Q = "primary",
|
|
426
426
|
iconClassName: X,
|
|
427
427
|
animated: y = !1,
|
|
428
|
-
...
|
|
429
|
-
},
|
|
430
|
-
const
|
|
431
|
-
type:
|
|
428
|
+
...Y
|
|
429
|
+
}, Z) => {
|
|
430
|
+
const $ = V({
|
|
431
|
+
type: R,
|
|
432
432
|
mode: r,
|
|
433
433
|
focusMode: a,
|
|
434
434
|
fullWidth: o,
|
|
435
435
|
disabled: t,
|
|
436
|
-
raw:
|
|
436
|
+
raw: d,
|
|
437
437
|
className: i,
|
|
438
438
|
noBorder: s,
|
|
439
439
|
size: u,
|
|
440
|
-
labelRight:
|
|
440
|
+
labelRight: c,
|
|
441
441
|
labelLeft: m,
|
|
442
|
-
noBackground:
|
|
443
|
-
align:
|
|
444
|
-
radius:
|
|
445
|
-
variant:
|
|
442
|
+
noBackground: N,
|
|
443
|
+
align: E,
|
|
444
|
+
radius: T,
|
|
445
|
+
variant: Q,
|
|
446
446
|
animated: y
|
|
447
|
-
}),
|
|
448
|
-
return
|
|
449
|
-
|
|
450
|
-
}, [
|
|
451
|
-
|
|
447
|
+
}), ee = me({ mode: r, raw: d, iconClassName: X }), U = he({ animated: y }), re = "flex items-center justify-center relative w-full h-full overflow-hidden", [h, _] = M(), [b, z] = M(), [B, W] = M(), L = w(0), v = w(null), p = w(null), te = ye([Z, v]);
|
|
448
|
+
return D(() => {
|
|
449
|
+
B && B.current && y && (L.current = W.width + ke[u] + (s ? 0 : pe), v.current && !v.current.style.width && (v.current.style.width = `${C[u]}px`));
|
|
450
|
+
}, [W, B, u, s, y]), D(() => {
|
|
451
|
+
if (v && v.current && y) {
|
|
452
|
+
let x = C[u];
|
|
453
|
+
c && h && _.width > 0 ? x = _.width + L.current : m && b && z.width > 0 && (x = z.width + L.current), p.current && clearTimeout(p.current), x !== parseInt(v.current.style.width || "0", 10) && (h.current && (h.current.style.opacity = "0"), b.current && (b.current.style.opacity = "0"), v.current.style.width = `${x}px`, x > C[u] && (p.current = setTimeout(() => {
|
|
454
|
+
h.current && c && (h.current.style.opacity = "1"), b.current && m && (b.current.style.opacity = "1"), p.current = null;
|
|
455
|
+
}, xe * 0.8))), x === C[u] && (h.current && (h.current.style.opacity = "0"), b.current && (b.current.style.opacity = "0"));
|
|
456
|
+
}
|
|
452
457
|
}, [
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
458
|
+
_,
|
|
459
|
+
c,
|
|
460
|
+
h,
|
|
461
|
+
z,
|
|
457
462
|
m,
|
|
458
|
-
|
|
463
|
+
b,
|
|
459
464
|
u,
|
|
460
465
|
y
|
|
461
|
-
]),
|
|
462
|
-
|
|
466
|
+
]), A(() => () => {
|
|
467
|
+
p.current && clearTimeout(p.current);
|
|
468
|
+
}, []), /* @__PURE__ */ g(
|
|
469
|
+
O,
|
|
463
470
|
{
|
|
464
|
-
ref:
|
|
465
|
-
className:
|
|
471
|
+
ref: te,
|
|
472
|
+
className: $,
|
|
466
473
|
disabled: t,
|
|
467
|
-
type:
|
|
468
|
-
"aria-label":
|
|
469
|
-
...
|
|
470
|
-
children: [
|
|
474
|
+
type: l,
|
|
475
|
+
"aria-label": f || k,
|
|
476
|
+
...Y,
|
|
477
|
+
children: /* @__PURE__ */ q("div", { className: re, children: [
|
|
471
478
|
/* @__PURE__ */ g(
|
|
472
|
-
|
|
479
|
+
H,
|
|
473
480
|
{
|
|
474
481
|
label: m,
|
|
475
|
-
labelRef:
|
|
476
|
-
labelClass:
|
|
477
|
-
labelInnerClass: "pr-2"
|
|
482
|
+
labelRef: b,
|
|
483
|
+
labelClass: U,
|
|
484
|
+
labelInnerClass: "pr-2",
|
|
485
|
+
initiallyHidden: y
|
|
478
486
|
}
|
|
479
487
|
),
|
|
480
|
-
/* @__PURE__ */ g("span", { ref:
|
|
488
|
+
/* @__PURE__ */ g("span", { ref: B, className: ee, children: e }),
|
|
481
489
|
/* @__PURE__ */ g(
|
|
482
|
-
|
|
490
|
+
H,
|
|
483
491
|
{
|
|
484
|
-
label:
|
|
485
|
-
labelRef:
|
|
486
|
-
labelClass:
|
|
487
|
-
labelInnerClass: "pl-2"
|
|
492
|
+
label: c,
|
|
493
|
+
labelRef: h,
|
|
494
|
+
labelClass: U,
|
|
495
|
+
labelInnerClass: "pl-2",
|
|
496
|
+
initiallyHidden: y
|
|
488
497
|
}
|
|
489
498
|
)
|
|
490
|
-
]
|
|
499
|
+
] })
|
|
491
500
|
}
|
|
492
501
|
);
|
|
493
502
|
}
|
|
494
|
-
),
|
|
503
|
+
), H = ({
|
|
495
504
|
labelRef: e,
|
|
496
505
|
labelClass: t,
|
|
497
506
|
label: r,
|
|
498
|
-
labelInnerClass: a
|
|
499
|
-
|
|
500
|
-
|
|
507
|
+
labelInnerClass: a,
|
|
508
|
+
initiallyHidden: o = !1
|
|
509
|
+
}) => /* @__PURE__ */ g(
|
|
510
|
+
"span",
|
|
511
|
+
{
|
|
512
|
+
ref: e,
|
|
513
|
+
className: t,
|
|
514
|
+
style: o ? { opacity: 0 } : void 0,
|
|
515
|
+
children: r && /* @__PURE__ */ g("span", { className: a, children: r })
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
K.displayName = "ButtonIcon";
|
|
501
519
|
/*!
|
|
502
|
-
@versini/ui-button v6.0.
|
|
520
|
+
@versini/ui-button v6.0.6
|
|
503
521
|
© 2025 gizmette.com
|
|
504
522
|
*/
|
|
505
523
|
try {
|
|
506
524
|
window.__VERSINI_UI_BUTTON__ || (window.__VERSINI_UI_BUTTON__ = {
|
|
507
|
-
version: "6.0.
|
|
508
|
-
buildTime: "
|
|
525
|
+
version: "6.0.6",
|
|
526
|
+
buildTime: "05/26/2025 03:48 PM EDT",
|
|
509
527
|
homepage: "https://github.com/aversini/ui-components",
|
|
510
528
|
license: "MIT"
|
|
511
529
|
});
|
|
512
530
|
} catch {
|
|
513
531
|
}
|
|
514
|
-
const
|
|
532
|
+
const we = I.forwardRef(
|
|
515
533
|
({
|
|
516
534
|
children: e,
|
|
517
535
|
mode: t = "system",
|
|
@@ -519,7 +537,7 @@ const ve = B.forwardRef(
|
|
|
519
537
|
active: a = !1,
|
|
520
538
|
...o
|
|
521
539
|
}, i) => {
|
|
522
|
-
const
|
|
540
|
+
const l = a ? n(
|
|
523
541
|
"relative",
|
|
524
542
|
"focus-within:static",
|
|
525
543
|
"focus-within:after:border-transparent",
|
|
@@ -536,8 +554,8 @@ const ve = B.forwardRef(
|
|
|
536
554
|
"after:border-table-light dark:after:border-table-dark": t === "alt-system"
|
|
537
555
|
}
|
|
538
556
|
) : "";
|
|
539
|
-
return /* @__PURE__ */ g("div", { className:
|
|
540
|
-
|
|
557
|
+
return /* @__PURE__ */ g("div", { className: l, children: /* @__PURE__ */ g(
|
|
558
|
+
K,
|
|
541
559
|
{
|
|
542
560
|
className: n("justify-center", r),
|
|
543
561
|
ref: i,
|
|
@@ -549,10 +567,10 @@ const ve = B.forwardRef(
|
|
|
549
567
|
) });
|
|
550
568
|
}
|
|
551
569
|
);
|
|
552
|
-
|
|
553
|
-
const
|
|
570
|
+
we.displayName = "ButtonSort";
|
|
571
|
+
const Ne = 200, Te = ({
|
|
554
572
|
string: e,
|
|
555
|
-
idealLength: t =
|
|
573
|
+
idealLength: t = Ne
|
|
556
574
|
}) => {
|
|
557
575
|
if (e.length <= t)
|
|
558
576
|
return { string: e, isTruncated: !1 };
|
|
@@ -563,30 +581,30 @@ const ke = 200, pe = ({
|
|
|
563
581
|
string: e.slice(0, t + o),
|
|
564
582
|
isTruncated: !0
|
|
565
583
|
};
|
|
566
|
-
},
|
|
584
|
+
}, Re = ({
|
|
567
585
|
children: e,
|
|
568
586
|
length: t = 200,
|
|
569
587
|
mode: r = "system",
|
|
570
588
|
focusMode: a = "system"
|
|
571
589
|
}) => {
|
|
572
|
-
const [o, i] =
|
|
590
|
+
const [o, i] = G(!1);
|
|
573
591
|
if (typeof e != "string")
|
|
574
592
|
return e;
|
|
575
|
-
const { string:
|
|
593
|
+
const { string: l, isTruncated: d } = Te({
|
|
576
594
|
string: e,
|
|
577
595
|
idealLength: t
|
|
578
596
|
});
|
|
579
|
-
return /* @__PURE__ */
|
|
580
|
-
o ? e :
|
|
581
|
-
|
|
582
|
-
|
|
597
|
+
return /* @__PURE__ */ q("span", { style: { wordBreak: "break-word" }, children: [
|
|
598
|
+
o ? e : l,
|
|
599
|
+
d && /* @__PURE__ */ g(
|
|
600
|
+
J,
|
|
583
601
|
{
|
|
584
602
|
mode: r,
|
|
585
603
|
focusMode: a,
|
|
586
604
|
className: "ml-2",
|
|
587
605
|
size: "small",
|
|
588
|
-
onClick: (
|
|
589
|
-
|
|
606
|
+
onClick: (f) => {
|
|
607
|
+
f.preventDefault(), i(!o);
|
|
590
608
|
},
|
|
591
609
|
children: o ? "less..." : "more..."
|
|
592
610
|
}
|
|
@@ -594,5 +612,5 @@ const ke = 200, pe = ({
|
|
|
594
612
|
] });
|
|
595
613
|
};
|
|
596
614
|
export {
|
|
597
|
-
|
|
615
|
+
Re as Truncate
|
|
598
616
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Truncate as o } from "./components/Truncate/Truncate.js";
|
|
2
2
|
/*!
|
|
3
|
-
@versini/ui-truncate v4.0.
|
|
3
|
+
@versini/ui-truncate v4.0.6
|
|
4
4
|
© 2025 gizmette.com
|
|
5
5
|
*/
|
|
6
6
|
try {
|
|
7
7
|
window.__VERSINI_UI_TRUNCATE__ || (window.__VERSINI_UI_TRUNCATE__ = {
|
|
8
|
-
version: "4.0.
|
|
9
|
-
buildTime: "
|
|
8
|
+
version: "4.0.6",
|
|
9
|
+
buildTime: "05/26/2025 03:48 PM EDT",
|
|
10
10
|
homepage: "https://github.com/aversini/ui-components",
|
|
11
11
|
license: "MIT"
|
|
12
12
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-truncate",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@tailwindcss/typography": "0.5.16",
|
|
43
|
-
"@versini/ui-button": "6.0.
|
|
44
|
-
"tailwindcss": "4.1.
|
|
43
|
+
"@versini/ui-button": "6.0.6",
|
|
44
|
+
"tailwindcss": "4.1.7"
|
|
45
45
|
},
|
|
46
46
|
"sideEffects": [
|
|
47
47
|
"**/*.css"
|
|
48
48
|
],
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "863a399128080a19f2668e458d495110aa0f68f8"
|
|
50
50
|
}
|