@platned/ui 0.10.3 → 0.10.4

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/index.js CHANGED
@@ -4455,7 +4455,7 @@ var CheckboxGroupItem = forwardRef12(
4455
4455
  );
4456
4456
 
4457
4457
  // src/components/forms/slider.tsx
4458
- import { forwardRef as forwardRef13, useId as useId11 } from "react";
4458
+ import { forwardRef as forwardRef13, useId as useId11, useState as useState14 } from "react";
4459
4459
  import clsx34 from "clsx";
4460
4460
  import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
4461
4461
  var Slider = forwardRef13(function Slider2({
@@ -4472,13 +4472,21 @@ var Slider = forwardRef13(function Slider2({
4472
4472
  disabled = false,
4473
4473
  id,
4474
4474
  className,
4475
+ style,
4475
4476
  ...props
4476
4477
  }, ref) {
4477
4478
  const generatedId = useId11();
4478
4479
  const controlId = id ?? generatedId;
4479
4480
  const descriptionId = `${controlId}-description`;
4480
- const current = value ?? defaultValue ?? min;
4481
+ const [uncontrolled, setUncontrolled] = useState14(defaultValue ?? min);
4482
+ const current = value ?? uncontrolled;
4481
4483
  const display = formatValue ? formatValue(current) : String(current);
4484
+ const ratio = max > min ? Math.min(1, Math.max(0, (current - min) / (max - min))) : 0;
4485
+ const trackVars = {
4486
+ "--slider-fill": `calc(0.5rem + (100% - 1rem) * ${ratio})`,
4487
+ "--slider-fill-color": disabled ? "var(--color-background-disabled-default)" : "var(--color-background-brand-default)",
4488
+ "--slider-track-color": "var(--color-background-default-tertiary)"
4489
+ };
4482
4490
  return /* @__PURE__ */ jsxs29("div", { className: clsx34("flex w-full flex-col gap-1.5", className), children: [
4483
4491
  (label || showValue) && /* @__PURE__ */ jsxs29("div", { className: "flex items-baseline justify-between gap-2", children: [
4484
4492
  label && /* @__PURE__ */ jsx40(
@@ -4513,23 +4521,32 @@ var Slider = forwardRef13(function Slider2({
4513
4521
  disabled,
4514
4522
  "aria-describedby": description ? descriptionId : void 0,
4515
4523
  "aria-valuetext": formatValue ? display : void 0,
4516
- onChange: (event) => onValueChange?.(Number(event.target.value)),
4524
+ onChange: (event) => {
4525
+ const next = Number(event.target.value);
4526
+ if (value === void 0) setUncontrolled(next);
4527
+ onValueChange?.(next);
4528
+ },
4529
+ style: { ...trackVars, ...style },
4517
4530
  className: clsx34(
4518
4531
  "h-5 w-full cursor-pointer appearance-none bg-transparent",
4519
4532
  "focus-visible:outline-none",
4520
- disabled && "cursor-not-allowed opacity-50",
4521
- // Track
4522
- "[&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-default-tertiary",
4523
- "[&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-default-tertiary",
4524
- "[&::-moz-range-progress]:h-1.5 [&::-moz-range-progress]:rounded-full [&::-moz-range-progress]:bg-brand",
4525
- // Thumb. The negative margin centres it on the track, since the input box is
4526
- // taller than the track to keep a comfortable pointer target.
4527
- "[&::-webkit-slider-thumb]:-mt-[7px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-brand [&::-webkit-slider-thumb]:bg-default [&::-webkit-slider-thumb]:shadow-100",
4528
- "[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-brand [&::-moz-range-thumb]:bg-default",
4533
+ disabled && "cursor-not-allowed",
4534
+ // Track: filled (brand) up to the thumb, unfilled (grey) after it, as in Figma.
4535
+ "[&::-webkit-slider-runnable-track]:h-1 [&::-webkit-slider-runnable-track]:rounded-full",
4536
+ "[&::-webkit-slider-runnable-track]:[background:linear-gradient(to_right,var(--slider-fill-color)_var(--slider-fill),var(--slider-track-color)_var(--slider-fill))]",
4537
+ "rtl:[&::-webkit-slider-runnable-track]:[background:linear-gradient(to_left,var(--slider-fill-color)_var(--slider-fill),var(--slider-track-color)_var(--slider-fill))]",
4538
+ "[&::-moz-range-track]:h-1 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:[background:var(--slider-track-color)]",
4539
+ "[&::-moz-range-progress]:h-1 [&::-moz-range-progress]:rounded-full [&::-moz-range-progress]:[background:var(--slider-fill-color)]",
4540
+ // Thumb: a solid knob in the fill colour (grey when disabled). The negative margin
4541
+ // centres it on the 4px track; the input box is taller to keep a comfortable target.
4542
+ "[&::-webkit-slider-thumb]:-mt-1.5 [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-0 [&::-webkit-slider-thumb]:[background:var(--slider-fill-color)] [&::-webkit-slider-thumb]:shadow-100",
4543
+ "[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:[background:var(--slider-fill-color)]",
4529
4544
  // Focus ring on the thumb, not the whole 100%-wide input — a ring around the
4530
- // full track reads as the row being focused rather than the handle.
4531
- "focus-visible:[&::-webkit-slider-thumb]:ring-2 focus-visible:[&::-webkit-slider-thumb]:ring-brand focus-visible:[&::-webkit-slider-thumb]:ring-offset-1",
4532
- "focus-visible:[&::-moz-range-thumb]:ring-2 focus-visible:[&::-moz-range-thumb]:ring-brand"
4545
+ // full track reads as the row being focused rather than the handle. Written as
4546
+ // `:focus-visible::thumb`: the `focus-visible:` prefix would emit
4547
+ // `::thumb:focus-visible`, a pseudo-class after a pseudo-element, which browsers drop.
4548
+ "[&:focus-visible::-webkit-slider-thumb]:ring-2 [&:focus-visible::-webkit-slider-thumb]:ring-brand [&:focus-visible::-webkit-slider-thumb]:ring-offset-1",
4549
+ "[&:focus-visible::-moz-range-thumb]:ring-2 [&:focus-visible::-moz-range-thumb]:ring-brand"
4533
4550
  ),
4534
4551
  ...props
4535
4552
  }
@@ -4573,7 +4590,7 @@ import {
4573
4590
  forwardRef as forwardRef15,
4574
4591
  useContext as useContext6,
4575
4592
  useEffect as useEffect7,
4576
- useState as useState14
4593
+ useState as useState15
4577
4594
  } from "react";
4578
4595
  import { Dialog as DialogPrimitive } from "radix-ui";
4579
4596
  import { CircleCheckBigIcon, InfoIcon, OctagonAlertIcon, TriangleAlertIcon, XIcon as XIcon5 } from "lucide-react";
@@ -4635,10 +4652,10 @@ var ModalShell = forwardRef15(
4635
4652
  onInteractOutside,
4636
4653
  initialFocus
4637
4654
  }, ref) {
4638
- const [hasTitle, setHasTitle] = useState14(false);
4639
- const [hasDescription, setHasDescription] = useState14(false);
4640
- const [contentNode, setContentNode] = useState14(null);
4641
- const [returnFocusTo] = useState14(
4655
+ const [hasTitle, setHasTitle] = useState15(false);
4656
+ const [hasDescription, setHasDescription] = useState15(false);
4657
+ const [contentNode, setContentNode] = useState15(null);
4658
+ const [returnFocusTo] = useState15(
4642
4659
  () => typeof document === "undefined" ? null : document.activeElement
4643
4660
  );
4644
4661
  return /* @__PURE__ */ jsx42(
@@ -4867,7 +4884,7 @@ function Tooltip({
4867
4884
  }
4868
4885
 
4869
4886
  // src/components/overlays/hover-card.tsx
4870
- import { useId as useId13, useState as useState15 } from "react";
4887
+ import { useId as useId13, useState as useState16 } from "react";
4871
4888
  import { HoverCard as HoverCardPrimitive } from "radix-ui";
4872
4889
  import { jsx as jsx44, jsxs as jsxs32 } from "react/jsx-runtime";
4873
4890
  function HoverCard({
@@ -4886,7 +4903,7 @@ function HoverCard({
4886
4903
  const baseId = useId13();
4887
4904
  const contentId = `${baseId}-content`;
4888
4905
  const triggerId = `${baseId}-trigger`;
4889
- const [openState, setOpenState] = useState15(defaultOpen);
4906
+ const [openState, setOpenState] = useState16(defaultOpen);
4890
4907
  const open = openProp ?? openState;
4891
4908
  const handleOpenChange = (next) => {
4892
4909
  setOpenState(next);
@@ -5119,13 +5136,13 @@ import {
5119
5136
  forwardRef as forwardRef19,
5120
5137
  useContext as useContext7,
5121
5138
  useEffect as useEffect9,
5122
- useState as useState17
5139
+ useState as useState18
5123
5140
  } from "react";
5124
5141
  import { Dialog as DialogPrimitive2 } from "radix-ui";
5125
5142
  import { XIcon as XIcon6 } from "lucide-react";
5126
5143
 
5127
5144
  // src/components/cards/scroll-area.tsx
5128
- import { forwardRef as forwardRef18, useEffect as useEffect8, useRef as useRef11, useState as useState16 } from "react";
5145
+ import { forwardRef as forwardRef18, useEffect as useEffect8, useRef as useRef11, useState as useState17 } from "react";
5129
5146
  import clsx36 from "clsx";
5130
5147
  import { jsx as jsx47 } from "react/jsx-runtime";
5131
5148
  var OVERFLOW = {
@@ -5135,7 +5152,7 @@ var OVERFLOW = {
5135
5152
  };
5136
5153
  var ScrollArea = forwardRef18(function ScrollArea2({ children, axis = "vertical", label, className, ...rest }, ref) {
5137
5154
  const localRef = useRef11(null);
5138
- const [overflows, setOverflows] = useState16(false);
5155
+ const [overflows, setOverflows] = useState17(false);
5139
5156
  useEffect8(() => {
5140
5157
  const node = localRef.current;
5141
5158
  if (!node) return;
@@ -5216,10 +5233,10 @@ var Drawer = forwardRef19(function Drawer2({
5216
5233
  ] });
5217
5234
  });
5218
5235
  var DrawerPanel = forwardRef19(function DrawerPanel2({ side = "right", width, label, className, onEscapeKeyDown, onInteractOutside, initialFocus, children }, ref) {
5219
- const [hasTitle, setHasTitle] = useState17(false);
5220
- const [hasDescription, setHasDescription] = useState17(false);
5221
- const [panelNode, setPanelNode] = useState17(null);
5222
- const [returnFocusTo] = useState17(
5236
+ const [hasTitle, setHasTitle] = useState18(false);
5237
+ const [hasDescription, setHasDescription] = useState18(false);
5238
+ const [panelNode, setPanelNode] = useState18(null);
5239
+ const [returnFocusTo] = useState18(
5223
5240
  () => typeof document === "undefined" ? null : document.activeElement
5224
5241
  );
5225
5242
  return /* @__PURE__ */ jsx48(
@@ -5452,7 +5469,7 @@ function ConfirmDialog({
5452
5469
  }
5453
5470
 
5454
5471
  // src/components/overlays/note-confirm-modal.tsx
5455
- import { useState as useState18 } from "react";
5472
+ import { useState as useState19 } from "react";
5456
5473
  import { jsx as jsx50, jsxs as jsxs37 } from "react/jsx-runtime";
5457
5474
  function NoteConfirmModal({ open, ...rest }) {
5458
5475
  if (!open) return null;
@@ -5477,7 +5494,7 @@ function NoteConfirmModalShell({
5477
5494
  onConfirm,
5478
5495
  onDiscardNote
5479
5496
  }) {
5480
- const [note, setNote] = useState18("");
5497
+ const [note, setNote] = useState19("");
5481
5498
  const noteMissing = requireNote && !note.trim();
5482
5499
  const requestOpenChange = (next) => {
5483
5500
  if (!next && isSubmitting) return;
@@ -5564,7 +5581,7 @@ function Scrim({ onClose, label, position = "fixed", open, className }) {
5564
5581
  }
5565
5582
 
5566
5583
  // src/components/overlays/fullscreen-surface.tsx
5567
- import { useState as useState19 } from "react";
5584
+ import { useState as useState20 } from "react";
5568
5585
  import { Dialog as DialogPrimitive3 } from "radix-ui";
5569
5586
  import { XIcon as XIcon7 } from "lucide-react";
5570
5587
  import { jsx as jsx52, jsxs as jsxs38 } from "react/jsx-runtime";
@@ -5580,8 +5597,8 @@ function FullscreenSurface({
5580
5597
  children,
5581
5598
  className
5582
5599
  }) {
5583
- const [node, setNode] = useState19(null);
5584
- const [returnFocusTo] = useState19(
5600
+ const [node, setNode] = useState20(null);
5601
+ const [returnFocusTo] = useState20(
5585
5602
  () => typeof document === "undefined" ? null : document.activeElement
5586
5603
  );
5587
5604
  return /* @__PURE__ */ jsx52(DialogPrimitive3.Root, { open: true, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsx52(DialogPrimitive3.Portal, { children: /* @__PURE__ */ jsxs38(
@@ -6241,7 +6258,7 @@ import {
6241
6258
  useId as useId15,
6242
6259
  useMemo as useMemo10,
6243
6260
  useRef as useRef13,
6244
- useState as useState20
6261
+ useState as useState21
6245
6262
  } from "react";
6246
6263
  import clsx39 from "clsx";
6247
6264
  import { ChevronLeftIcon as ChevronLeftIcon2, ChevronRightIcon as ChevronRightIcon3 } from "lucide-react";
@@ -6271,8 +6288,8 @@ function Carousel({
6271
6288
  });
6272
6289
  const baseId = useId15();
6273
6290
  const cursor = useRef13(0);
6274
- const [paused, setPaused] = useState20(false);
6275
- const [userTookControl, setUserTookControl] = useState20(false);
6291
+ const [paused, setPaused] = useState21(false);
6292
+ const [userTookControl, setUserTookControl] = useState21(false);
6276
6293
  const hasAutoplay = autoplayInterval !== void 0 && autoplayInterval > 0;
6277
6294
  const context = useMemo10(
6278
6295
  () => ({
@@ -6446,7 +6463,7 @@ import {
6446
6463
  useId as useId16,
6447
6464
  useMemo as useMemo11,
6448
6465
  useRef as useRef14,
6449
- useState as useState21
6466
+ useState as useState22
6450
6467
  } from "react";
6451
6468
  import clsx40 from "clsx";
6452
6469
  import { jsx as jsx61, jsxs as jsxs41 } from "react/jsx-runtime";
@@ -6474,7 +6491,7 @@ function Resizable({
6474
6491
  });
6475
6492
  const containerRef = useRef14(null);
6476
6493
  const baseId = useId16();
6477
- const [dragging, setDragging] = useState21(false);
6494
+ const [dragging, setDragging] = useState22(false);
6478
6495
  const context = useMemo11(
6479
6496
  () => ({
6480
6497
  direction,
@@ -6764,7 +6781,7 @@ import {
6764
6781
  useId as useId17,
6765
6782
  useLayoutEffect as useLayoutEffect2,
6766
6783
  useRef as useRef15,
6767
- useState as useState22
6784
+ useState as useState23
6768
6785
  } from "react";
6769
6786
  import clsx44 from "clsx";
6770
6787
  import { ChevronLeftIcon as ChevronLeftIcon3, ChevronRightIcon as ChevronRightIcon4 } from "lucide-react";
@@ -6830,7 +6847,7 @@ var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMe
6830
6847
  function useTabStrip(enabled) {
6831
6848
  const listRef = useRef15(null);
6832
6849
  const selected = useRef15(null);
6833
- const [edges, setEdges] = useState22({ start: false, end: false });
6850
+ const [edges, setEdges] = useState23({ start: false, end: false });
6834
6851
  const measure = useCallback6(() => {
6835
6852
  const el = listRef.current;
6836
6853
  if (!enabled || !el) return;
@@ -7402,7 +7419,7 @@ import {
7402
7419
  useEffect as useEffect12,
7403
7420
  useId as useId18,
7404
7421
  useMemo as useMemo12,
7405
- useState as useState23
7422
+ useState as useState24
7406
7423
  } from "react";
7407
7424
  import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
7408
7425
  import {
@@ -7668,7 +7685,7 @@ function itemKey(item) {
7668
7685
  }
7669
7686
  function SidebarGroupView({ group }) {
7670
7687
  const { density, collapsed } = useRow();
7671
- const [open, setOpen] = useState23(group.defaultOpen ?? true);
7688
+ const [open, setOpen] = useState24(group.defaultOpen ?? true);
7672
7689
  const regionId = useId18();
7673
7690
  const foldable = Boolean(group.collapsible && group.title) && !collapsed;
7674
7691
  const comfortable = density === "comfortable";
@@ -7740,7 +7757,7 @@ function ParentRow({ item }) {
7740
7757
  const row = useRow();
7741
7758
  const children = item.children ?? [];
7742
7759
  const childActive = children.some((child) => isRowActive(child, row));
7743
- const [open, setOpen] = useState23(item.defaultOpen ?? childActive);
7760
+ const [open, setOpen] = useState24(item.defaultOpen ?? childActive);
7744
7761
  const regionId = useId18();
7745
7762
  useEffect12(() => {
7746
7763
  if (childActive) setOpen(true);
@@ -8386,12 +8403,12 @@ function slotWidthPx(gridWidthPx, columnGapPx, cols) {
8386
8403
  }
8387
8404
 
8388
8405
  // src/lib/use-width-tier.ts
8389
- import { useCallback as useCallback9, useEffect as useEffect13, useLayoutEffect as useLayoutEffect3, useRef as useRef16, useState as useState24 } from "react";
8406
+ import { useCallback as useCallback9, useEffect as useEffect13, useLayoutEffect as useLayoutEffect3, useRef as useRef16, useState as useState25 } from "react";
8390
8407
  var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect13 : useLayoutEffect3;
8391
8408
  var TIER_SETTLE_MS = 200;
8392
8409
  function useWidthTier({ frozen = false } = {}) {
8393
- const [node, setNode] = useState24(null);
8394
- const [{ widthPx, tier }, setMeasured] = useState24({
8410
+ const [node, setNode] = useState25(null);
8411
+ const [{ widthPx, tier }, setMeasured] = useState25({
8395
8412
  widthPx: null,
8396
8413
  tier: "wide"
8397
8414
  });
@@ -9738,7 +9755,7 @@ function DetailGrid({ children, columns = "auto", className }) {
9738
9755
  }
9739
9756
 
9740
9757
  // src/components/lists/description-list.tsx
9741
- import { useEffect as useEffect15, useState as useState25 } from "react";
9758
+ import { useEffect as useEffect15, useState as useState26 } from "react";
9742
9759
  import clsx78 from "clsx";
9743
9760
  import { CheckIcon as CheckIcon6, CopyIcon } from "lucide-react";
9744
9761
  import { jsx as jsx100, jsxs as jsxs71 } from "react/jsx-runtime";
@@ -9756,7 +9773,7 @@ function DescriptionItem({ label, value, copyValue, className }) {
9756
9773
  ] });
9757
9774
  }
9758
9775
  function CopyButton({ value, label, copiedLabel = "Copied", className }) {
9759
- const [copied, setCopied] = useState25(false);
9776
+ const [copied, setCopied] = useState26(false);
9760
9777
  useEffect15(() => {
9761
9778
  if (!copied) return;
9762
9779
  const timer = window.setTimeout(() => setCopied(false), 2e3);
@@ -9826,7 +9843,7 @@ function CheckedGroupList({
9826
9843
  }
9827
9844
 
9828
9845
  // src/components/lists/tree-view.tsx
9829
- import { useMemo as useMemo14, useRef as useRef17, useState as useState26 } from "react";
9846
+ import { useMemo as useMemo14, useRef as useRef17, useState as useState27 } from "react";
9830
9847
  import clsx80 from "clsx";
9831
9848
  import { ChevronRightIcon as ChevronRightIcon7 } from "lucide-react";
9832
9849
  import { jsx as jsx102, jsxs as jsxs73 } from "react/jsx-runtime";
@@ -9859,7 +9876,7 @@ function TreeView({
9859
9876
  value: selectedProp,
9860
9877
  defaultValue: defaultSelected
9861
9878
  });
9862
- const [focusedId, setFocusedId] = useState26(null);
9879
+ const [focusedId, setFocusedId] = useState27(null);
9863
9880
  const rowRefs = useRef17(/* @__PURE__ */ new Map());
9864
9881
  const expandedSet = useMemo14(() => new Set(expanded), [expanded]);
9865
9882
  const visible = useMemo14(() => {
@@ -10166,7 +10183,7 @@ import {
10166
10183
  useEffect as useEffect16,
10167
10184
  useMemo as useMemo15,
10168
10185
  useRef as useRef18,
10169
- useState as useState27
10186
+ useState as useState28
10170
10187
  } from "react";
10171
10188
  import clsx83 from "clsx";
10172
10189
  import { CircleCheckBigIcon as CircleCheckBigIcon4, InfoIcon as InfoIcon4, TriangleAlertIcon as TriangleAlertIcon4, XIcon as XIcon9 } from "lucide-react";
@@ -10210,7 +10227,7 @@ function Toaster({
10210
10227
  offset = 16,
10211
10228
  mobileOffset
10212
10229
  }) {
10213
- const [toasts, setToasts] = useState27([]);
10230
+ const [toasts, setToasts] = useState28([]);
10214
10231
  const timers = useRef18(/* @__PURE__ */ new Map());
10215
10232
  const counter = useRef18(0);
10216
10233
  const dismiss = useCallback10((id) => {
@@ -10305,11 +10322,11 @@ function ToastItem({ toast, onDismiss }) {
10305
10322
  }
10306
10323
 
10307
10324
  // src/components/forms/password-input.tsx
10308
- import { forwardRef as forwardRef34, useState as useState28 } from "react";
10325
+ import { forwardRef as forwardRef34, useState as useState29 } from "react";
10309
10326
  import { EyeIcon as EyeIcon2, EyeOffIcon as EyeOffIcon2 } from "lucide-react";
10310
10327
  import { jsx as jsx107 } from "react/jsx-runtime";
10311
10328
  var PasswordInput = forwardRef34(function PasswordInput2(props, ref) {
10312
- const [visible, setVisible] = useState28(false);
10329
+ const [visible, setVisible] = useState29(false);
10313
10330
  return /* @__PURE__ */ jsx107(
10314
10331
  Input,
10315
10332
  {