@jinaan/uikit 0.1.23 → 0.1.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinaan/uikit",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "Reusable React and Tailwind UI components for Jinaan projects.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/src/button.tsx CHANGED
@@ -102,10 +102,10 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
102
102
  {asChild ? (
103
103
  children
104
104
  ) : (
105
- <span className="relative inline-flex items-center justify-center gap-[var(--control-gap)]">
105
+ <span className="relative inline-flex w-full items-center justify-[inherit] gap-[var(--control-gap)]">
106
106
  <span
107
107
  className={cn(
108
- "inline-flex items-center justify-center gap-[var(--control-gap)] transition-[opacity,translate] duration-150 ease-out motion-reduce:transition-none",
108
+ "inline-flex w-full items-center justify-[inherit] gap-[var(--control-gap)] transition-[opacity,translate] duration-150 ease-out motion-reduce:transition-none",
109
109
  loading && "translate-y-2 opacity-0",
110
110
  )}
111
111
  aria-hidden={loading || undefined}
@@ -6,7 +6,6 @@ import {
6
6
  DotsSixVertical,
7
7
  FunnelSimple,
8
8
  Lock,
9
- LockOpen,
10
9
  MagnifyingGlass,
11
10
  WarningCircle,
12
11
  X,
@@ -215,7 +214,6 @@ export function DataTable<T>({
215
214
  );
216
215
  // Column order and runtime pins are per-mount, like `hidden`.
217
216
  const [order, setOrder] = useState<string[] | null>(null);
218
- const [locked, setLocked] = useState<string[]>([]);
219
217
  const [dragId, setDragId] = useState<string | null>(null);
220
218
  const [sort, setSort] = useState<{ id: string; dir: "asc" | "desc" } | null>(
221
219
  defaultSort ?? null,
@@ -233,7 +231,7 @@ export function DataTable<T>({
233
231
  const visibleColumns = orderedColumns.filter((c) => !hidden[c.id]);
234
232
  const hiddenColumns = orderedColumns.filter((c) => hidden[c.id] && !c.required);
235
233
  // ponytail: mouse-only drag reorder; add keyboard move (Alt+Arrow) if asked.
236
- const isPinned = (c: Column<T>) => c.required || locked.includes(c.id);
234
+ const isPinned = (c: Column<T>) => Boolean(c.required);
237
235
  const columnAt = (id: string) => byId.get(id);
238
236
 
239
237
  const moveBefore = (draggedId: string, targetId: string) => {
@@ -250,11 +248,6 @@ export function DataTable<T>({
250
248
  // Re-showing appends at the end of the current order.
251
249
  setOrder((prev) => (prev && prev.includes(id) ? prev : [...(prev ?? propOrder), id]));
252
250
  };
253
-
254
- const togglePin = (id: string) =>
255
- setLocked((prev) =>
256
- prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id],
257
- );
258
251
  const activeFilters = (filters ?? []).filter((f) => activeFilterIds.includes(f.id));
259
252
  const filterSignature = (filters ?? [])
260
253
  .map((f) => `${f.id}:${f.value.join(",")}`)
@@ -421,6 +414,10 @@ export function DataTable<T>({
421
414
  checked
422
415
  draggable={!pinned}
423
416
  onDragStart={(e) => {
417
+ if (pinned) {
418
+ e.preventDefault();
419
+ return;
420
+ }
424
421
  e.dataTransfer.effectAllowed = "move";
425
422
  e.dataTransfer.setData("text/plain", c.id);
426
423
  setDragId(c.id);
@@ -441,40 +438,17 @@ export function DataTable<T>({
441
438
  onSelect={(e) => e.preventDefault()}
442
439
  className="justify-between"
443
440
  >
444
- <span className="flex min-w-0 items-center gap-2">
441
+ <span className="truncate">{c.header}</span>
442
+ {pinned ? (
443
+ <Lock className="size-3.5 shrink-0 text-subtle" aria-hidden />
444
+ ) : (
445
445
  <DotsSixVertical
446
446
  aria-hidden
447
447
  className={cn(
448
448
  "size-3.5 shrink-0",
449
- pinned
450
- ? "text-subtle/60"
451
- : dragId === c.id
452
- ? "text-primary"
453
- : "text-subtle",
449
+ dragId === c.id ? "text-primary" : "text-subtle",
454
450
  )}
455
451
  />
456
- <span className="truncate">{c.header}</span>
457
- </span>
458
- {c.required ? (
459
- <Lock className="size-3.5 shrink-0 text-subtle" aria-hidden />
460
- ) : (
461
- <button
462
- type="button"
463
- aria-label={pinned ? `Unlock ${c.header}` : `Lock ${c.header}`}
464
- onClick={(e) => {
465
- e.stopPropagation();
466
- e.preventDefault();
467
- togglePin(c.id);
468
- }}
469
- onPointerDown={(e) => e.stopPropagation()}
470
- className="-m-1 rounded p-1 text-subtle transition-colors hover:bg-(--menu-highlight) hover:text-fg"
471
- >
472
- {pinned ? (
473
- <LockOpen className="size-3.5" aria-hidden />
474
- ) : (
475
- <Lock className="size-3.5" aria-hidden />
476
- )}
477
- </button>
478
452
  )}
479
453
  </DropdownMenuCheckboxItem>
480
454
  );