@moontra/moonui 3.3.0 → 3.4.0

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.mjs CHANGED
@@ -1679,14 +1679,14 @@ var CarouselNext = React10.forwardRef(({ className, variant = "outline", size =
1679
1679
  });
1680
1680
  CarouselNext.displayName = "CarouselNext";
1681
1681
  var checkboxVariants = cva(
1682
- "peer shrink-0 border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:text-primary-foreground",
1682
+ "peer shrink-0 border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:text-primary-foreground data-[state=indeterminate]:text-primary-foreground",
1683
1683
  {
1684
1684
  variants: {
1685
1685
  variant: {
1686
- default: "border-border bg-background data-[state=checked]:bg-primary data-[state=checked]:border-primary",
1687
- outline: "border-border bg-transparent data-[state=checked]:bg-primary data-[state=checked]:border-primary",
1688
- muted: "border-border bg-accent data-[state=checked]:bg-primary data-[state=checked]:border-primary",
1689
- ghost: "border-transparent bg-transparent hover:bg-accent data-[state=checked]:bg-primary data-[state=checked]:border-primary"
1686
+ default: "border-border bg-background data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:border-primary",
1687
+ outline: "border-border bg-transparent data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:border-primary",
1688
+ muted: "border-border bg-accent data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:border-primary",
1689
+ ghost: "border-transparent bg-transparent hover:bg-accent data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:border-primary"
1690
1690
  },
1691
1691
  size: {
1692
1692
  sm: "h-3.5 w-3.5",
@@ -1727,11 +1727,7 @@ var Checkbox = React10.forwardRef(({
1727
1727
  checked,
1728
1728
  ...props
1729
1729
  }, ref) => {
1730
- const [isIndeterminate, setIsIndeterminate] = React10.useState(indeterminate);
1731
- React10.useEffect(() => {
1732
- setIsIndeterminate(indeterminate);
1733
- }, [indeterminate]);
1734
- const effectiveChecked = isIndeterminate ? false : checked;
1730
+ const effectiveChecked = indeterminate ? "indeterminate" : checked;
1735
1731
  return /* @__PURE__ */ jsx(
1736
1732
  CheckboxPrimitive.Root,
1737
1733
  {
@@ -1746,7 +1742,7 @@ var Checkbox = React10.forwardRef(({
1746
1742
  "flex items-center justify-center text-current",
1747
1743
  animation === "bounce" && "data-[state=checked]:animate-bounce"
1748
1744
  ),
1749
- children: isIndeterminate ? /* @__PURE__ */ jsx(Minus, { className: "h-[65%] w-[65%]" }) : icon ? icon : /* @__PURE__ */ jsx(Check, { className: "h-[65%] w-[65%]" })
1745
+ children: indeterminate ? /* @__PURE__ */ jsx(Minus, { className: "h-[65%] w-[65%]" }) : icon ? icon : /* @__PURE__ */ jsx(Check, { className: "h-[65%] w-[65%]" })
1750
1746
  }
1751
1747
  )
1752
1748
  }
@@ -2538,6 +2534,44 @@ var Slider = React10.forwardRef(({
2538
2534
  document.addEventListener("mousemove", handleMouseMove);
2539
2535
  document.addEventListener("mouseup", handleMouseUp);
2540
2536
  };
2537
+ const handleThumbKeyDown = (index) => (event) => {
2538
+ if (disabled)
2539
+ return;
2540
+ const largeStep = step * 10;
2541
+ const current = sliderValue[index];
2542
+ let next;
2543
+ switch (event.key) {
2544
+ case "ArrowRight":
2545
+ case "ArrowUp":
2546
+ next = current + step;
2547
+ break;
2548
+ case "ArrowLeft":
2549
+ case "ArrowDown":
2550
+ next = current - step;
2551
+ break;
2552
+ case "PageUp":
2553
+ next = current + largeStep;
2554
+ break;
2555
+ case "PageDown":
2556
+ next = current - largeStep;
2557
+ break;
2558
+ case "Home":
2559
+ next = min;
2560
+ break;
2561
+ case "End":
2562
+ next = max;
2563
+ break;
2564
+ default:
2565
+ return;
2566
+ }
2567
+ event.preventDefault();
2568
+ const lowerBound = index > 0 ? sliderValue[index - 1] : min;
2569
+ const upperBound = index < sliderValue.length - 1 ? sliderValue[index + 1] : max;
2570
+ const bounded = Math.max(lowerBound, Math.min(upperBound, next));
2571
+ const newValues = [...sliderValue];
2572
+ newValues[index] = bounded;
2573
+ handleValueChange(newValues);
2574
+ };
2541
2575
  return /* @__PURE__ */ jsxs("div", { className: "w-full", ref, ...props, children: [
2542
2576
  showValueLabel && /* @__PURE__ */ jsx("div", { className: cn(
2543
2577
  "flex justify-end mb-1 text-sm text-muted-foreground",
@@ -2587,6 +2621,7 @@ var Slider = React10.forwardRef(({
2587
2621
  cursor: disabled ? "not-allowed" : "pointer"
2588
2622
  },
2589
2623
  onMouseDown: handleThumbMouseDown(i),
2624
+ onKeyDown: handleThumbKeyDown(i),
2590
2625
  "aria-label": `Thumb ${i + 1}`,
2591
2626
  tabIndex: disabled ? -1 : 0,
2592
2627
  role: "slider",
@@ -3105,8 +3140,12 @@ function ColorPicker({
3105
3140
  /* @__PURE__ */ jsx("div", { className: "grid grid-cols-10 gap-1", children: presets.map((presetColor) => /* @__PURE__ */ jsx(
3106
3141
  "button",
3107
3142
  {
3143
+ type: "button",
3144
+ "aria-label": `Select color ${presetColor}`,
3145
+ "aria-pressed": color === presetColor,
3108
3146
  className: cn(
3109
3147
  "h-7 w-7 rounded border-2 transition-all hover:scale-110",
3148
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
3110
3149
  color === presetColor ? "border-primary" : "border-transparent"
3111
3150
  ),
3112
3151
  style: { backgroundColor: presetColor },
@@ -3133,8 +3172,12 @@ function SimpleColorPicker({
3133
3172
  return /* @__PURE__ */ jsx("div", { className: cn("moonui-theme", "flex flex-wrap gap-2", className), children: colors.map((color) => /* @__PURE__ */ jsx(
3134
3173
  "button",
3135
3174
  {
3175
+ type: "button",
3176
+ "aria-label": `Select color ${color}`,
3177
+ "aria-pressed": value === color,
3136
3178
  className: cn(
3137
3179
  "rounded-full border-2 transition-all hover:scale-110",
3180
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
3138
3181
  sizeClasses[size],
3139
3182
  value === color ? "border-primary ring-2 ring-primary/20" : "border-transparent"
3140
3183
  ),
@@ -6091,16 +6134,41 @@ var radioGroupItemVariants = cva(
6091
6134
  );
6092
6135
  var RadioGroupContext = React10.createContext({});
6093
6136
  var RadioGroup2 = React10.forwardRef(
6094
- ({ className, value, onValueChange, disabled, name, ...props }, ref) => {
6095
- return /* @__PURE__ */ jsx(RadioGroupContext.Provider, { value: { value, onValueChange, disabled, name }, children: /* @__PURE__ */ jsx(
6096
- "div",
6137
+ ({ className, value, defaultValue, onValueChange, disabled, name, ...props }, ref) => {
6138
+ const [internalValue, setInternalValue] = React10.useState(
6139
+ defaultValue
6140
+ );
6141
+ const isControlled = value !== void 0;
6142
+ const currentValue = isControlled ? value : internalValue;
6143
+ const handleValueChange = React10.useCallback(
6144
+ (next) => {
6145
+ if (!isControlled) {
6146
+ setInternalValue(next);
6147
+ }
6148
+ onValueChange?.(next);
6149
+ },
6150
+ [isControlled, onValueChange]
6151
+ );
6152
+ return /* @__PURE__ */ jsx(
6153
+ RadioGroupContext.Provider,
6097
6154
  {
6098
- ref,
6099
- role: "radiogroup",
6100
- className: cn("moonui-theme", "grid gap-2", className),
6101
- ...props
6155
+ value: {
6156
+ value: currentValue,
6157
+ onValueChange: handleValueChange,
6158
+ disabled,
6159
+ name
6160
+ },
6161
+ children: /* @__PURE__ */ jsx(
6162
+ "div",
6163
+ {
6164
+ ref,
6165
+ role: "radiogroup",
6166
+ className: cn("moonui-theme", "grid gap-2", className),
6167
+ ...props
6168
+ }
6169
+ )
6102
6170
  }
6103
- ) });
6171
+ );
6104
6172
  }
6105
6173
  );
6106
6174
  RadioGroup2.displayName = "RadioGroup";
@@ -6129,7 +6197,7 @@ var RadioGroupItem = React10.forwardRef(({ className, variant, size, indicator,
6129
6197
  disabled: disabled || radioGroup.disabled,
6130
6198
  name: radioGroup.name,
6131
6199
  onChange: handleChange,
6132
- className: "sr-only",
6200
+ className: "peer sr-only",
6133
6201
  ...props
6134
6202
  }
6135
6203
  ),
@@ -6140,7 +6208,12 @@ var RadioGroupItem = React10.forwardRef(({ className, variant, size, indicator,
6140
6208
  className: cn(
6141
6209
  radioGroupItemVariants({ variant, size }),
6142
6210
  "rounded-full",
6143
- "focus-visible:ring-primary/50",
6211
+ // Gerçekte odaklanan eleman görsel olarak gizli `sr-only` input'tur.
6212
+ // Görünür label onun KARDEŞİ olduğu için label'da `:focus-visible` hiç
6213
+ // tetiklenmiyor, dolayısıyla klavye kullanıcısı hiçbir focus izi
6214
+ // görmüyordu. Tailwind `peer` deseniyle (input `peer` sınıfını taşır ve
6215
+ // DOM'da label'dan önce gelir) focus izi görünür elemana taşınır.
6216
+ "peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-primary/50",
6144
6217
  "relative inline-flex shrink-0 cursor-pointer items-center justify-center overflow-hidden",
6145
6218
  disabled && "cursor-not-allowed opacity-50",
6146
6219
  className
@@ -8474,6 +8547,10 @@ var ToggleGroup = React10.forwardRef(({ className, variant, size, children, ...p
8474
8547
  ref,
8475
8548
  className: cn(
8476
8549
  "moonui-theme inline-flex items-center justify-center gap-1",
8550
+ // Radix roving-focus kök elemana `data-orientation` yazar; dikey yerleşim
8551
+ // buna bağlanır. Yatay/tanımsız durumda taban sınıflar geçerli kalır —
8552
+ // yani mevcut render değişmez. Kardeş `button-group` ile desen paritesi.
8553
+ "data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch data-[orientation=vertical]:justify-start",
8477
8554
  className
8478
8555
  ),
8479
8556
  ...props,