@facter/ds-core 1.4.0 → 1.5.1

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
@@ -3394,6 +3394,38 @@ function FormSwitch({
3394
3394
  ) });
3395
3395
  }
3396
3396
  FormSwitch.displayName = "Form.Switch";
3397
+ var colorStyles = {
3398
+ default: {
3399
+ border: "border-primary",
3400
+ bg: "bg-primary/5",
3401
+ text: "text-primary",
3402
+ radio: "border-primary text-primary"
3403
+ },
3404
+ destructive: {
3405
+ border: "border-red-500",
3406
+ bg: "bg-red-500/10",
3407
+ text: "text-red-600",
3408
+ radio: "border-red-500 text-red-500"
3409
+ },
3410
+ warning: {
3411
+ border: "border-amber-500",
3412
+ bg: "bg-amber-500/10",
3413
+ text: "text-amber-600",
3414
+ radio: "border-amber-500 text-amber-500"
3415
+ },
3416
+ success: {
3417
+ border: "border-green-500",
3418
+ bg: "bg-green-500/10",
3419
+ text: "text-green-600",
3420
+ radio: "border-green-500 text-green-500"
3421
+ },
3422
+ info: {
3423
+ border: "border-blue-500",
3424
+ bg: "bg-blue-500/10",
3425
+ text: "text-blue-600",
3426
+ radio: "border-blue-500 text-blue-500"
3427
+ }
3428
+ };
3397
3429
  function FormRadioGroup({
3398
3430
  name,
3399
3431
  label,
@@ -3433,28 +3465,27 @@ function FormRadioGroup({
3433
3465
  children: options.map((option) => {
3434
3466
  const optionId = `${name}-${option.value}`;
3435
3467
  const isSelected = field.value === option.value;
3468
+ const color = option.color || "default";
3469
+ const styles = colorStyles[color];
3436
3470
  return /* @__PURE__ */ jsxs(
3437
- "div",
3471
+ "label",
3438
3472
  {
3473
+ htmlFor: optionId,
3439
3474
  className: cn(
3440
3475
  "flex items-center gap-3 border-2 py-2 px-4 rounded-lg transition-colors cursor-pointer",
3441
- isSelected ? "border-primary bg-primary/5" : "border-border hover:border-muted-foreground/50",
3442
- option.disabled && "opacity-50 cursor-not-allowed"
3476
+ isSelected ? cn(styles.border, styles.bg) : "border-border hover:border-muted-foreground/50",
3477
+ (option.disabled || disabled) && "opacity-50 cursor-not-allowed"
3443
3478
  ),
3444
- onClick: () => {
3445
- if (!option.disabled && !disabled) {
3446
- field.onChange(option.value);
3447
- }
3448
- },
3449
3479
  children: [
3450
3480
  /* @__PURE__ */ jsx(
3451
3481
  RadioGroupPrimitive.Item,
3452
3482
  {
3453
3483
  id: optionId,
3454
3484
  value: option.value,
3455
- disabled: option.disabled,
3485
+ disabled: option.disabled || disabled,
3456
3486
  className: cn(
3457
- "aspect-square h-4 w-4 rounded-full border border-primary text-primary",
3487
+ "aspect-square h-4 w-4 rounded-full border",
3488
+ isSelected ? styles.radio : "border-border text-muted-foreground",
3458
3489
  "ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
3459
3490
  "disabled:cursor-not-allowed disabled:opacity-50"
3460
3491
  ),
@@ -3463,18 +3494,16 @@ function FormRadioGroup({
3463
3494
  ),
3464
3495
  /* @__PURE__ */ jsxs("div", { className: "grid gap-0.5 leading-none", children: [
3465
3496
  /* @__PURE__ */ jsx(
3466
- "label",
3497
+ "span",
3467
3498
  {
3468
- htmlFor: optionId,
3469
3499
  className: cn(
3470
- "text-sm font-medium leading-none cursor-pointer",
3471
- isSelected && "text-primary",
3472
- option.disabled && "cursor-not-allowed"
3500
+ "text-sm font-medium leading-none",
3501
+ isSelected && styles.text
3473
3502
  ),
3474
3503
  children: option.label
3475
3504
  }
3476
3505
  ),
3477
- option.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: option.description })
3506
+ option.description && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: option.description })
3478
3507
  ] })
3479
3508
  ]
3480
3509
  },