@sofya-ds/react 1.3.0 → 1.3.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.cjs CHANGED
@@ -4545,29 +4545,107 @@ var switchThumbSizeClasses = {
4545
4545
  default: "h-5 w-5 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
4546
4546
  sm: "h-4 w-4 data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
4547
4547
  };
4548
- var Switch = React31.forwardRef(({ className, size = "default", ...props }, ref) => {
4549
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4550
- SwitchPrimitives.Root,
4551
- {
4552
- className: cn(
4553
- "peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors duration-sofya ease-sofya focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted",
4554
- switchRootSizeClasses[size],
4555
- className
4556
- ),
4557
- ...props,
4558
- ref,
4559
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4560
- SwitchPrimitives.Thumb,
4561
- {
4562
- className: cn(
4563
- "pointer-events-none block rounded-full bg-background shadow-sm ring-0 transition-transform duration-sofya ease-sofya",
4564
- switchThumbSizeClasses[size]
4565
- )
4566
- }
4567
- )
4548
+ var Switch = React31.forwardRef(
4549
+ ({
4550
+ "aria-describedby": ariaDescribedBy,
4551
+ "aria-labelledby": ariaLabelledBy,
4552
+ className,
4553
+ containerClassName,
4554
+ description,
4555
+ descriptionClassName,
4556
+ disabled,
4557
+ id,
4558
+ label,
4559
+ labelClassName,
4560
+ size,
4561
+ ...props
4562
+ }, ref) => {
4563
+ const generatedId = React31.useId();
4564
+ const resolvedId = id ?? generatedId;
4565
+ const labelId = label ? `${resolvedId}-label` : void 0;
4566
+ const descriptionId = description ? `${resolvedId}-description` : void 0;
4567
+ const hasTextContent = label !== void 0 || description !== void 0;
4568
+ const resolvedSize = size ?? (hasTextContent ? "sm" : "default");
4569
+ const alignClassName = description ? "items-start" : "items-center";
4570
+ const resolvedAriaDescribedBy = [ariaDescribedBy, descriptionId].filter(Boolean).join(" ") || void 0;
4571
+ const resolvedAriaLabelledBy = ariaLabelledBy ?? labelId;
4572
+ const switchControl = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4573
+ SwitchPrimitives.Root,
4574
+ {
4575
+ id: resolvedId,
4576
+ className: cn(
4577
+ "peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors duration-sofya ease-sofya focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted",
4578
+ switchRootSizeClasses[resolvedSize],
4579
+ className
4580
+ ),
4581
+ disabled,
4582
+ "aria-describedby": resolvedAriaDescribedBy,
4583
+ "aria-labelledby": resolvedAriaLabelledBy,
4584
+ "data-size": resolvedSize,
4585
+ ...props,
4586
+ ref,
4587
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4588
+ SwitchPrimitives.Thumb,
4589
+ {
4590
+ className: cn(
4591
+ "pointer-events-none block rounded-full bg-background shadow-sm ring-0 transition-transform duration-sofya ease-sofya",
4592
+ switchThumbSizeClasses[resolvedSize]
4593
+ )
4594
+ }
4595
+ )
4596
+ }
4597
+ );
4598
+ if (!hasTextContent) {
4599
+ return switchControl;
4568
4600
  }
4569
- );
4570
- });
4601
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
4602
+ "div",
4603
+ {
4604
+ "data-slot": "switch-container",
4605
+ className: selectionControlContainerClasses({
4606
+ alignClassName,
4607
+ className: containerClassName,
4608
+ disabled
4609
+ }),
4610
+ children: [
4611
+ switchControl,
4612
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { className: selectionControlContentBaseClasses, children: [
4613
+ label ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("label", { htmlFor: resolvedId, className: selectionControlLabelTextBaseClasses, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4614
+ "span",
4615
+ {
4616
+ id: labelId,
4617
+ className: cn(
4618
+ selectionControlLabelTextBaseClasses,
4619
+ labelClassName
4620
+ ),
4621
+ children: renderTextContent(label, {
4622
+ as: "span",
4623
+ className: "text-[color:var(--sofya-text-default)]",
4624
+ size: "body"
4625
+ })
4626
+ }
4627
+ ) }) : null,
4628
+ description ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4629
+ "span",
4630
+ {
4631
+ id: descriptionId,
4632
+ className: cn(
4633
+ selectionControlDescriptionTextBaseClasses,
4634
+ descriptionClassName
4635
+ ),
4636
+ children: renderTextContent(description, {
4637
+ as: "span",
4638
+ className: "text-muted-foreground",
4639
+ size: "body"
4640
+ })
4641
+ }
4642
+ ) : null
4643
+ ] })
4644
+ ]
4645
+ }
4646
+ );
4647
+ }
4648
+ );
4571
4649
  Switch.displayName = SwitchPrimitives.Root.displayName;
4572
4650
 
4573
4651
  // src/components/table.tsx
package/dist/index.d.cts CHANGED
@@ -544,6 +544,11 @@ declare const Spinner: React.ForwardRefExoticComponent<SpinnerProps & React.RefA
544
544
  declare const switchSizeOptions: readonly ["default", "sm"];
545
545
  type SwitchSize = (typeof switchSizeOptions)[number];
546
546
  interface SwitchProps extends React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> {
547
+ containerClassName?: string;
548
+ description?: React.ReactNode;
549
+ descriptionClassName?: string;
550
+ label?: React.ReactNode;
551
+ labelClassName?: string;
547
552
  size?: SwitchSize;
548
553
  }
549
554
  declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
package/dist/index.d.ts CHANGED
@@ -544,6 +544,11 @@ declare const Spinner: React.ForwardRefExoticComponent<SpinnerProps & React.RefA
544
544
  declare const switchSizeOptions: readonly ["default", "sm"];
545
545
  type SwitchSize = (typeof switchSizeOptions)[number];
546
546
  interface SwitchProps extends React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> {
547
+ containerClassName?: string;
548
+ description?: React.ReactNode;
549
+ descriptionClassName?: string;
550
+ label?: React.ReactNode;
551
+ labelClassName?: string;
547
552
  size?: SwitchSize;
548
553
  }
549
554
  declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
package/dist/index.js CHANGED
@@ -4386,7 +4386,7 @@ Spinner.displayName = "Spinner";
4386
4386
  // src/components/switch.tsx
4387
4387
  import * as React31 from "react";
4388
4388
  import * as SwitchPrimitives from "@radix-ui/react-switch";
4389
- import { jsx as jsx33 } from "react/jsx-runtime";
4389
+ import { jsx as jsx33, jsxs as jsxs17 } from "react/jsx-runtime";
4390
4390
  var switchSizeOptions = ["default", "sm"];
4391
4391
  var switchRootSizeClasses = {
4392
4392
  default: "h-6 w-11",
@@ -4396,29 +4396,107 @@ var switchThumbSizeClasses = {
4396
4396
  default: "h-5 w-5 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
4397
4397
  sm: "h-4 w-4 data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
4398
4398
  };
4399
- var Switch = React31.forwardRef(({ className, size = "default", ...props }, ref) => {
4400
- return /* @__PURE__ */ jsx33(
4401
- SwitchPrimitives.Root,
4402
- {
4403
- className: cn(
4404
- "peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors duration-sofya ease-sofya focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted",
4405
- switchRootSizeClasses[size],
4406
- className
4407
- ),
4408
- ...props,
4409
- ref,
4410
- children: /* @__PURE__ */ jsx33(
4411
- SwitchPrimitives.Thumb,
4412
- {
4413
- className: cn(
4414
- "pointer-events-none block rounded-full bg-background shadow-sm ring-0 transition-transform duration-sofya ease-sofya",
4415
- switchThumbSizeClasses[size]
4416
- )
4417
- }
4418
- )
4399
+ var Switch = React31.forwardRef(
4400
+ ({
4401
+ "aria-describedby": ariaDescribedBy,
4402
+ "aria-labelledby": ariaLabelledBy,
4403
+ className,
4404
+ containerClassName,
4405
+ description,
4406
+ descriptionClassName,
4407
+ disabled,
4408
+ id,
4409
+ label,
4410
+ labelClassName,
4411
+ size,
4412
+ ...props
4413
+ }, ref) => {
4414
+ const generatedId = React31.useId();
4415
+ const resolvedId = id ?? generatedId;
4416
+ const labelId = label ? `${resolvedId}-label` : void 0;
4417
+ const descriptionId = description ? `${resolvedId}-description` : void 0;
4418
+ const hasTextContent = label !== void 0 || description !== void 0;
4419
+ const resolvedSize = size ?? (hasTextContent ? "sm" : "default");
4420
+ const alignClassName = description ? "items-start" : "items-center";
4421
+ const resolvedAriaDescribedBy = [ariaDescribedBy, descriptionId].filter(Boolean).join(" ") || void 0;
4422
+ const resolvedAriaLabelledBy = ariaLabelledBy ?? labelId;
4423
+ const switchControl = /* @__PURE__ */ jsx33(
4424
+ SwitchPrimitives.Root,
4425
+ {
4426
+ id: resolvedId,
4427
+ className: cn(
4428
+ "peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors duration-sofya ease-sofya focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted",
4429
+ switchRootSizeClasses[resolvedSize],
4430
+ className
4431
+ ),
4432
+ disabled,
4433
+ "aria-describedby": resolvedAriaDescribedBy,
4434
+ "aria-labelledby": resolvedAriaLabelledBy,
4435
+ "data-size": resolvedSize,
4436
+ ...props,
4437
+ ref,
4438
+ children: /* @__PURE__ */ jsx33(
4439
+ SwitchPrimitives.Thumb,
4440
+ {
4441
+ className: cn(
4442
+ "pointer-events-none block rounded-full bg-background shadow-sm ring-0 transition-transform duration-sofya ease-sofya",
4443
+ switchThumbSizeClasses[resolvedSize]
4444
+ )
4445
+ }
4446
+ )
4447
+ }
4448
+ );
4449
+ if (!hasTextContent) {
4450
+ return switchControl;
4419
4451
  }
4420
- );
4421
- });
4452
+ return /* @__PURE__ */ jsxs17(
4453
+ "div",
4454
+ {
4455
+ "data-slot": "switch-container",
4456
+ className: selectionControlContainerClasses({
4457
+ alignClassName,
4458
+ className: containerClassName,
4459
+ disabled
4460
+ }),
4461
+ children: [
4462
+ switchControl,
4463
+ /* @__PURE__ */ jsxs17("span", { className: selectionControlContentBaseClasses, children: [
4464
+ label ? /* @__PURE__ */ jsx33("label", { htmlFor: resolvedId, className: selectionControlLabelTextBaseClasses, children: /* @__PURE__ */ jsx33(
4465
+ "span",
4466
+ {
4467
+ id: labelId,
4468
+ className: cn(
4469
+ selectionControlLabelTextBaseClasses,
4470
+ labelClassName
4471
+ ),
4472
+ children: renderTextContent(label, {
4473
+ as: "span",
4474
+ className: "text-[color:var(--sofya-text-default)]",
4475
+ size: "body"
4476
+ })
4477
+ }
4478
+ ) }) : null,
4479
+ description ? /* @__PURE__ */ jsx33(
4480
+ "span",
4481
+ {
4482
+ id: descriptionId,
4483
+ className: cn(
4484
+ selectionControlDescriptionTextBaseClasses,
4485
+ descriptionClassName
4486
+ ),
4487
+ children: renderTextContent(description, {
4488
+ as: "span",
4489
+ className: "text-muted-foreground",
4490
+ size: "body"
4491
+ })
4492
+ }
4493
+ ) : null
4494
+ ] })
4495
+ ]
4496
+ }
4497
+ );
4498
+ }
4499
+ );
4422
4500
  Switch.displayName = SwitchPrimitives.Root.displayName;
4423
4501
 
4424
4502
  // src/components/table.tsx
@@ -4672,7 +4750,7 @@ TableActions.displayName = "TableActions";
4672
4750
  import * as React33 from "react";
4673
4751
  import * as TabsPrimitive from "@radix-ui/react-tabs";
4674
4752
  import { motion as motion3 } from "motion/react";
4675
- import { jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
4753
+ import { jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
4676
4754
  function resolveDefaultValue(items, defaultValue) {
4677
4755
  if (defaultValue) {
4678
4756
  return defaultValue;
@@ -4702,7 +4780,7 @@ function Tabs({
4702
4780
  setUncontrolledCurrentValue(resolvedDefaultValue);
4703
4781
  }
4704
4782
  }, [resolvedDefaultValue, setUncontrolledCurrentValue, value]);
4705
- return /* @__PURE__ */ jsxs17(
4783
+ return /* @__PURE__ */ jsxs18(
4706
4784
  TabsPrimitive.Root,
4707
4785
  {
4708
4786
  className: cn("w-full", className),
@@ -4721,7 +4799,7 @@ function Tabs({
4721
4799
  children: items.map((item) => {
4722
4800
  const isUnavailable = item.disabled || item.loading;
4723
4801
  const isActive = item.value === currentValue;
4724
- return /* @__PURE__ */ jsxs17(
4802
+ return /* @__PURE__ */ jsxs18(
4725
4803
  TabsPrimitive.Trigger,
4726
4804
  {
4727
4805
  value: item.value,
@@ -4743,7 +4821,7 @@ function Tabs({
4743
4821
  transition: { duration: 0.25, ease: "easeInOut" }
4744
4822
  }
4745
4823
  ) : null,
4746
- /* @__PURE__ */ jsxs17("span", { className: "relative z-10 inline-flex items-center gap-2", children: [
4824
+ /* @__PURE__ */ jsxs18("span", { className: "relative z-10 inline-flex items-center gap-2", children: [
4747
4825
  item.loading ? /* @__PURE__ */ jsx35(
4748
4826
  "span",
4749
4827
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sofya-ds/react",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Sofya React design system with official brand tokens, provider and UI components.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -59,7 +59,7 @@
59
59
  "motion": "^12.38.0",
60
60
  "sonner": "^2.0.7",
61
61
  "tailwind-merge": "^3.5.0",
62
- "@sofya-ds/tokens": "1.3.0"
62
+ "@sofya-ds/tokens": "1.3.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@testing-library/jest-dom": "^6.9.1",