@moontra/moonui 3.1.0 → 3.2.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.js CHANGED
@@ -8139,6 +8139,295 @@ function Toaster() {
8139
8139
  /* @__PURE__ */ jsxRuntime.jsx(ToastViewport, {})
8140
8140
  ] });
8141
8141
  }
8142
+ var kbdVariants = classVarianceAuthority.cva(
8143
+ [
8144
+ // Temel klavye-tuşu görünümü — token tabanlı, hardcoded renk yok
8145
+ "inline-flex items-center justify-center rounded",
8146
+ "border border-border bg-muted",
8147
+ "px-1.5 font-mono font-medium text-muted-foreground",
8148
+ // Alt kenarda hafif kabartma (border token'ı ile — [#...] hex sınıfı DEĞİL)
8149
+ "shadow-[0_1px_0_1px_hsl(var(--border))]",
8150
+ "select-none whitespace-nowrap"
8151
+ ],
8152
+ {
8153
+ variants: {
8154
+ size: {
8155
+ sm: "h-5 min-w-5 text-[10px]",
8156
+ md: "h-6 min-w-6 text-xs"
8157
+ }
8158
+ },
8159
+ defaultVariants: {
8160
+ size: "md"
8161
+ }
8162
+ }
8163
+ );
8164
+ var Kbd = React10__namespace.forwardRef(
8165
+ ({ className, size, children, ...props }, ref) => {
8166
+ return /* @__PURE__ */ jsxRuntime.jsx(
8167
+ "kbd",
8168
+ {
8169
+ ref,
8170
+ className: cn("moonui-theme", kbdVariants({ size }), className),
8171
+ ...props,
8172
+ children
8173
+ }
8174
+ );
8175
+ }
8176
+ );
8177
+ Kbd.displayName = "Kbd";
8178
+ var ratingVariants = classVarianceAuthority.cva(
8179
+ [
8180
+ "moonui-theme inline-flex items-center rounded-md outline-none",
8181
+ "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
8182
+ ],
8183
+ {
8184
+ variants: {
8185
+ size: {
8186
+ sm: "gap-0.5",
8187
+ md: "gap-1",
8188
+ lg: "gap-1.5"
8189
+ }
8190
+ },
8191
+ defaultVariants: {
8192
+ size: "md"
8193
+ }
8194
+ }
8195
+ );
8196
+ var iconSizeMap = {
8197
+ sm: "h-4 w-4",
8198
+ md: "h-5 w-5",
8199
+ lg: "h-6 w-6"
8200
+ };
8201
+ var Rating = React10__namespace.forwardRef(
8202
+ ({
8203
+ className,
8204
+ value,
8205
+ defaultValue,
8206
+ onValueChange,
8207
+ max = 5,
8208
+ readOnly = false,
8209
+ precision = "full",
8210
+ icon,
8211
+ size,
8212
+ "aria-label": ariaLabel = "Rating",
8213
+ ...props
8214
+ }, ref) => {
8215
+ const resolvedSize = size ?? "md";
8216
+ const iconSizeClass = iconSizeMap[resolvedSize];
8217
+ const step = precision === "half" ? 0.5 : 1;
8218
+ const isControlled = value !== void 0;
8219
+ const [internalValue, setInternalValue] = React10__namespace.useState(defaultValue ?? 0);
8220
+ const currentValue = isControlled ? value ?? 0 : internalValue;
8221
+ const [hoverValue, setHoverValue] = React10__namespace.useState(null);
8222
+ const displayValue = hoverValue !== null ? hoverValue : currentValue;
8223
+ const commit = React10__namespace.useCallback(
8224
+ (next) => {
8225
+ if (readOnly)
8226
+ return;
8227
+ if (!isControlled)
8228
+ setInternalValue(next);
8229
+ onValueChange?.(next);
8230
+ },
8231
+ [readOnly, isControlled, onValueChange]
8232
+ );
8233
+ const handleKeyDown = React10__namespace.useCallback(
8234
+ (event) => {
8235
+ if (readOnly)
8236
+ return;
8237
+ let next = null;
8238
+ switch (event.key) {
8239
+ case "ArrowRight":
8240
+ case "ArrowUp":
8241
+ next = Math.min(max, currentValue + step);
8242
+ break;
8243
+ case "ArrowLeft":
8244
+ case "ArrowDown":
8245
+ next = Math.max(step, currentValue - step);
8246
+ break;
8247
+ case "Home":
8248
+ next = step;
8249
+ break;
8250
+ case "End":
8251
+ next = max;
8252
+ break;
8253
+ default:
8254
+ return;
8255
+ }
8256
+ event.preventDefault();
8257
+ commit(next);
8258
+ },
8259
+ [readOnly, max, currentValue, step, commit]
8260
+ );
8261
+ const renderIcon = (filled) => {
8262
+ if (React10__namespace.isValidElement(icon)) {
8263
+ const element = icon;
8264
+ return React10__namespace.cloneElement(element, {
8265
+ className: cn(
8266
+ iconSizeClass,
8267
+ "shrink-0",
8268
+ filled && "fill-current",
8269
+ element.props?.className
8270
+ )
8271
+ });
8272
+ }
8273
+ return /* @__PURE__ */ jsxRuntime.jsx(
8274
+ lucideReact.Star,
8275
+ {
8276
+ className: cn(iconSizeClass, "shrink-0", filled && "fill-current"),
8277
+ "aria-hidden": "true"
8278
+ }
8279
+ );
8280
+ };
8281
+ const stars = Array.from({ length: max }, (_, index) => index + 1);
8282
+ return /* @__PURE__ */ jsxRuntime.jsx(
8283
+ "div",
8284
+ {
8285
+ ref,
8286
+ role: "radiogroup",
8287
+ "aria-label": ariaLabel,
8288
+ "aria-orientation": "horizontal",
8289
+ "aria-readonly": readOnly || void 0,
8290
+ tabIndex: readOnly ? void 0 : 0,
8291
+ onKeyDown: handleKeyDown,
8292
+ onMouseLeave: () => setHoverValue(null),
8293
+ className: cn(ratingVariants({ size }), className),
8294
+ ...props,
8295
+ children: stars.map((starValue) => {
8296
+ const fraction = Math.max(0, Math.min(1, displayValue - (starValue - 1)));
8297
+ const halfValue = starValue - 0.5;
8298
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8299
+ "span",
8300
+ {
8301
+ "data-slot": "rating-star",
8302
+ className: cn(
8303
+ "relative inline-flex shrink-0",
8304
+ !readOnly && "cursor-pointer"
8305
+ ),
8306
+ children: [
8307
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "inline-flex text-muted-foreground/30", children: renderIcon(false) }),
8308
+ /* @__PURE__ */ jsxRuntime.jsx(
8309
+ "span",
8310
+ {
8311
+ "aria-hidden": "true",
8312
+ className: "pointer-events-none absolute left-0 top-0 h-full overflow-hidden text-amber-400",
8313
+ style: { width: `${fraction * 100}%` },
8314
+ children: renderIcon(true)
8315
+ }
8316
+ ),
8317
+ !readOnly && precision === "half" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8318
+ /* @__PURE__ */ jsxRuntime.jsx(
8319
+ "button",
8320
+ {
8321
+ type: "button",
8322
+ role: "radio",
8323
+ "aria-checked": currentValue === halfValue,
8324
+ "aria-label": `${halfValue} stars`,
8325
+ tabIndex: -1,
8326
+ onClick: () => commit(halfValue),
8327
+ onMouseEnter: () => setHoverValue(halfValue),
8328
+ className: "absolute inset-y-0 left-0 z-10 w-1/2 cursor-pointer bg-transparent"
8329
+ }
8330
+ ),
8331
+ /* @__PURE__ */ jsxRuntime.jsx(
8332
+ "button",
8333
+ {
8334
+ type: "button",
8335
+ role: "radio",
8336
+ "aria-checked": currentValue === starValue,
8337
+ "aria-label": `${starValue} stars`,
8338
+ tabIndex: -1,
8339
+ onClick: () => commit(starValue),
8340
+ onMouseEnter: () => setHoverValue(starValue),
8341
+ className: "absolute inset-y-0 right-0 z-10 w-1/2 cursor-pointer bg-transparent"
8342
+ }
8343
+ )
8344
+ ] }),
8345
+ !readOnly && precision === "full" && /* @__PURE__ */ jsxRuntime.jsx(
8346
+ "button",
8347
+ {
8348
+ type: "button",
8349
+ role: "radio",
8350
+ "aria-checked": currentValue === starValue,
8351
+ "aria-label": `${starValue} ${starValue === 1 ? "star" : "stars"}`,
8352
+ tabIndex: -1,
8353
+ onClick: () => commit(starValue),
8354
+ onMouseEnter: () => setHoverValue(starValue),
8355
+ className: "absolute inset-0 z-10 cursor-pointer bg-transparent"
8356
+ }
8357
+ )
8358
+ ]
8359
+ },
8360
+ starValue
8361
+ );
8362
+ })
8363
+ }
8364
+ );
8365
+ }
8366
+ );
8367
+ Rating.displayName = "Rating";
8368
+ var spinnerVariants = classVarianceAuthority.cva(
8369
+ [
8370
+ "inline-block shrink-0 rounded-full",
8371
+ "border-current border-t-transparent",
8372
+ "animate-spin motion-reduce:animate-none"
8373
+ ],
8374
+ {
8375
+ variants: {
8376
+ size: {
8377
+ sm: "h-4 w-4 border-2",
8378
+ // 16px
8379
+ md: "h-6 w-6 border-2",
8380
+ // 24px
8381
+ lg: "h-8 w-8 border-[3px]",
8382
+ // 32px
8383
+ xl: "h-10 w-10 border-4"
8384
+ // 40px
8385
+ }
8386
+ },
8387
+ defaultVariants: {
8388
+ size: "md"
8389
+ }
8390
+ }
8391
+ );
8392
+ var dotSizeMap = {
8393
+ sm: "h-1 w-1",
8394
+ md: "h-1.5 w-1.5",
8395
+ lg: "h-2 w-2",
8396
+ xl: "h-2.5 w-2.5"
8397
+ };
8398
+ var Spinner = React10__namespace.forwardRef(
8399
+ ({ className, size, variant = "default", label = "Loading", ...props }, ref) => {
8400
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8401
+ "div",
8402
+ {
8403
+ ref,
8404
+ role: "status",
8405
+ "aria-live": "polite",
8406
+ className: cn(
8407
+ "moonui-theme inline-flex items-center justify-center",
8408
+ className
8409
+ ),
8410
+ ...props,
8411
+ children: [
8412
+ variant === "dots" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex items-center gap-1", "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsxRuntime.jsx(
8413
+ "span",
8414
+ {
8415
+ className: cn(
8416
+ "inline-block rounded-full bg-current",
8417
+ "animate-bounce motion-reduce:animate-none",
8418
+ dotSizeMap[size ?? "md"]
8419
+ ),
8420
+ style: { animationDelay: `${i * 0.15}s` }
8421
+ },
8422
+ i
8423
+ )) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(spinnerVariants({ size })), "aria-hidden": "true" }),
8424
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: label })
8425
+ ]
8426
+ }
8427
+ );
8428
+ }
8429
+ );
8430
+ Spinner.displayName = "Spinner";
8142
8431
 
8143
8432
  Object.defineProperty(exports, 'Palette', {
8144
8433
  enumerable: true,
@@ -8256,6 +8545,7 @@ exports.InputOTP = InputOTP;
8256
8545
  exports.InputOTPGroup = InputOTPGroup;
8257
8546
  exports.InputOTPSeparator = InputOTPSeparator;
8258
8547
  exports.InputOTPSlot = InputOTPSlot;
8548
+ exports.Kbd = Kbd;
8259
8549
  exports.Label = Label;
8260
8550
  exports.LockedComponent = LockedComponent;
8261
8551
  exports.MonthPicker = MonthPicker;
@@ -8354,6 +8644,7 @@ exports.MoonUIInputOTP = InputOTP;
8354
8644
  exports.MoonUIInputOTPGroup = InputOTPGroup;
8355
8645
  exports.MoonUIInputOTPSeparator = InputOTPSeparator;
8356
8646
  exports.MoonUIInputOTPSlot = InputOTPSlot;
8647
+ exports.MoonUIKbd = Kbd;
8357
8648
  exports.MoonUILabel = Label;
8358
8649
  exports.MoonUILockedComponent = LockedComponent;
8359
8650
  exports.MoonUIMonthPicker = MonthPicker;
@@ -8376,6 +8667,7 @@ exports.MoonUIRadioGroup = RadioGroup2;
8376
8667
  exports.MoonUIRadioGroupItem = RadioGroupItem;
8377
8668
  exports.MoonUIRadioItemWithLabel = RadioItemWithLabel;
8378
8669
  exports.MoonUIRadioLabel = RadioLabel;
8670
+ exports.MoonUIRating = Rating;
8379
8671
  exports.MoonUIRichTextEditor = RichTextEditor;
8380
8672
  exports.MoonUIScrollArea = ScrollArea;
8381
8673
  exports.MoonUIScrollBar = ScrollBar;
@@ -8400,6 +8692,7 @@ exports.MoonUISkeletonAvatar = SkeletonAvatar;
8400
8692
  exports.MoonUISkeletonCard = SkeletonCard;
8401
8693
  exports.MoonUISkeletonText = SkeletonText;
8402
8694
  exports.MoonUISlider = Slider;
8695
+ exports.MoonUISpinner = Spinner;
8403
8696
  exports.MoonUISwipeableCard = SwipeableCard;
8404
8697
  exports.MoonUISwitch = Switch;
8405
8698
  exports.MoonUITable = Table;
@@ -8452,6 +8745,7 @@ exports.RadioGroup = RadioGroup2;
8452
8745
  exports.RadioGroupItem = RadioGroupItem;
8453
8746
  exports.RadioItemWithLabel = RadioItemWithLabel;
8454
8747
  exports.RadioLabel = RadioLabel;
8748
+ exports.Rating = Rating;
8455
8749
  exports.RichTextEditor = RichTextEditor;
8456
8750
  exports.ScrollArea = ScrollArea;
8457
8751
  exports.ScrollBar = ScrollBar;
@@ -8477,6 +8771,7 @@ exports.SkeletonAvatar = SkeletonAvatar;
8477
8771
  exports.SkeletonCard = SkeletonCard;
8478
8772
  exports.SkeletonText = SkeletonText;
8479
8773
  exports.Slider = Slider;
8774
+ exports.Spinner = Spinner;
8480
8775
  exports.SwipeableCard = SwipeableCard;
8481
8776
  exports.Switch = Switch;
8482
8777
  exports.Table = Table;
@@ -8516,18 +8811,24 @@ exports.cn = cn;
8516
8811
  exports.collapsibleContentVariants = collapsibleContentVariants;
8517
8812
  exports.collapsibleTriggerVariants = collapsibleTriggerVariants;
8518
8813
  exports.inputOTPSlotVariants = inputOTPSlotVariants;
8814
+ exports.kbdVariants = kbdVariants;
8519
8815
  exports.moonUIBadgeVariants = badgeVariants;
8520
8816
  exports.moonUIButtonVariants = buttonVariants;
8521
8817
  exports.moonUICarouselContentVariants = carouselContentVariants;
8522
8818
  exports.moonUICarouselItemVariants = carouselItemVariants;
8523
8819
  exports.moonUICreateSortableHeader = createSortableHeader;
8524
8820
  exports.moonUIInputOTPSlotVariants = inputOTPSlotVariants;
8821
+ exports.moonUIKbdVariants = kbdVariants;
8822
+ exports.moonUIRatingVariants = ratingVariants;
8525
8823
  exports.moonUISkeletonVariants = skeletonVariants;
8824
+ exports.moonUISpinnerVariants = spinnerVariants;
8526
8825
  exports.moonUIToggleVariants = toggleVariants;
8527
8826
  exports.popoverContentVariants = popoverContentVariants;
8528
8827
  exports.progressVariants = progressVariants;
8828
+ exports.ratingVariants = ratingVariants;
8529
8829
  exports.separatorVariants = separatorVariants;
8530
8830
  exports.skeletonVariants = skeletonVariants;
8831
+ exports.spinnerVariants = spinnerVariants;
8531
8832
  exports.toast = toast;
8532
8833
  exports.toggleVariants = toggleVariants;
8533
8834
  exports.tooltipVariants = tooltipVariants;