@sofya-ds/react 1.2.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.js CHANGED
@@ -1799,22 +1799,51 @@ var dropdownVariantOptions = [
1799
1799
  "language",
1800
1800
  "selected"
1801
1801
  ];
1802
+ var dropdownAppearanceOptions = ["panel", "card"];
1803
+ var dropdownTriggerSizeOptions = ["default", "sm", "lg"];
1802
1804
  var dropdownLanguageItems = [
1803
1805
  { value: "en-US", label: "English", languageLocale: "en-US" },
1804
1806
  { value: "pt-BR", label: "Portuguese", languageLocale: "pt-BR" },
1805
1807
  { value: "es-ES", label: "Spanish", languageLocale: "es-ES" }
1806
1808
  ];
1807
- var dropdownTriggerClasses = {
1808
- card: "h-12 rounded-[20px] px-6 py-2 text-primary",
1809
- panel: "h-12 rounded-[10px] px-6 py-2 text-foreground",
1809
+ var dropdownTriggerToneClasses = {
1810
+ card: "text-primary",
1811
+ panel: "text-foreground",
1810
1812
  language: "",
1811
- selected: "h-10 w-full rounded-[10px] border-[color:var(--sofya-border-strong)] px-4 py-2 [font-family:var(--sofya-text-body-font-family)] text-[length:var(--sofya-text-body-font-size)] [font-weight:var(--sofya-text-body-font-weight)] leading-[var(--sofya-text-body-line-height)] tracking-[var(--sofya-text-body-letter-spacing)]"
1813
+ selected: "w-full border-[color:var(--sofya-border-strong)] [font-family:var(--sofya-text-body-font-family)] text-[length:var(--sofya-text-body-font-size)] [font-weight:var(--sofya-text-body-font-weight)] leading-[var(--sofya-text-body-line-height)] tracking-[var(--sofya-text-body-letter-spacing)]"
1812
1814
  };
1813
- var dropdownContentClasses = {
1814
- card: "rounded-[20px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1815
- panel: "rounded-[10px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1816
- language: "w-[224px] min-w-[224px] rounded-[10px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1817
- selected: "w-[var(--radix-dropdown-menu-trigger-width)] min-w-[var(--radix-dropdown-menu-trigger-width)] rounded-[10px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]"
1815
+ var dropdownTriggerSizeClasses = {
1816
+ regular: {
1817
+ default: "h-12 px-6 py-2",
1818
+ sm: "h-10 px-4 py-2",
1819
+ lg: "h-14 px-8 py-4"
1820
+ },
1821
+ selected: {
1822
+ default: "h-10 px-4 py-2",
1823
+ sm: "h-9 px-2 py-2",
1824
+ lg: "h-12 px-6 py-2"
1825
+ },
1826
+ language: {
1827
+ default: "h-[38px] w-[38px] p-0",
1828
+ sm: "h-8 w-8 p-0",
1829
+ lg: "h-11 w-11 p-0"
1830
+ }
1831
+ };
1832
+ var dropdownAppearanceClasses = {
1833
+ panel: {
1834
+ content: "rounded-[10px]",
1835
+ trigger: "rounded-[10px]"
1836
+ },
1837
+ card: {
1838
+ content: "rounded-[20px]",
1839
+ trigger: "rounded-[20px]"
1840
+ }
1841
+ };
1842
+ var dropdownContentBaseClasses = {
1843
+ card: "border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1844
+ panel: "border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1845
+ language: "w-[224px] min-w-[224px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1846
+ selected: "w-[var(--radix-dropdown-menu-trigger-width)] min-w-[var(--radix-dropdown-menu-trigger-width)] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]"
1818
1847
  };
1819
1848
  var dropdownItemClasses = {
1820
1849
  card: "text-foreground",
@@ -1834,6 +1863,24 @@ function resolveItemLanguageLocale(item) {
1834
1863
  }
1835
1864
  return isButtonLanguageLocale(item.value) ? item.value : void 0;
1836
1865
  }
1866
+ function resolveDropdownAppearance({
1867
+ appearance,
1868
+ variant
1869
+ }) {
1870
+ if (appearance) {
1871
+ return appearance;
1872
+ }
1873
+ return variant === "card" ? "card" : "panel";
1874
+ }
1875
+ function resolveDropdownTriggerSizeFamily(variant) {
1876
+ if (variant === "language") {
1877
+ return "language";
1878
+ }
1879
+ if (variant === "selected") {
1880
+ return "selected";
1881
+ }
1882
+ return "regular";
1883
+ }
1837
1884
  function DefaultDropdownTriggerIcon({ variant }) {
1838
1885
  if (variant === "selected") {
1839
1886
  return /* @__PURE__ */ jsx12(
@@ -1865,6 +1912,7 @@ function LanguageFlagIcon({ locale }) {
1865
1912
  }
1866
1913
  function Dropdown({
1867
1914
  align = "start",
1915
+ appearance,
1868
1916
  contentClassName,
1869
1917
  defaultOpen,
1870
1918
  defaultValue,
@@ -1879,11 +1927,14 @@ function Dropdown({
1879
1927
  sideOffset = 8,
1880
1928
  triggerClassName,
1881
1929
  triggerIcon,
1930
+ triggerSize = "default",
1882
1931
  value,
1883
1932
  variant = "card"
1884
1933
  }) {
1885
1934
  const isLanguageVariant = variant === "language";
1886
1935
  const isSelectedVariant = variant === "selected";
1936
+ const resolvedAppearance = resolveDropdownAppearance({ appearance, variant });
1937
+ const triggerSizeFamily = resolveDropdownTriggerSizeFamily(variant);
1887
1938
  const usesDefaultListStyle = !isLanguageVariant;
1888
1939
  const resolvedItems = React12.useMemo(
1889
1940
  () => isLanguageVariant ? items && items.length > 0 ? items : dropdownLanguageItems : items ?? [],
@@ -1933,9 +1984,13 @@ function Dropdown({
1933
1984
  type: "button",
1934
1985
  variant: isLanguageVariant ? "language" : "dropdown",
1935
1986
  languageLocale: selectedLanguageLocale,
1987
+ "data-appearance": resolvedAppearance,
1988
+ "data-trigger-size": triggerSize,
1936
1989
  className: cn(
1937
1990
  "min-w-0",
1938
- isLanguageVariant ? "h-[38px] w-[38px] rounded-[10px] p-0" : dropdownTriggerClasses[variant],
1991
+ dropdownTriggerToneClasses[variant],
1992
+ dropdownTriggerSizeClasses[triggerSizeFamily][triggerSize],
1993
+ dropdownAppearanceClasses[resolvedAppearance].trigger,
1939
1994
  selectedTriggerToneClassName,
1940
1995
  triggerClassName
1941
1996
  ),
@@ -1952,9 +2007,11 @@ function Dropdown({
1952
2007
  {
1953
2008
  align,
1954
2009
  sideOffset,
2010
+ "data-appearance": resolvedAppearance,
1955
2011
  className: cn(
1956
2012
  "sofya-dropdown-content z-50 w-auto min-w-[var(--radix-dropdown-menu-trigger-width)] border bg-card p-2 outline-none",
1957
- dropdownContentClasses[variant],
2013
+ dropdownContentBaseClasses[variant],
2014
+ dropdownAppearanceClasses[resolvedAppearance].content,
1958
2015
  contentClassName
1959
2016
  ),
1960
2017
  children: /* @__PURE__ */ jsx12(
@@ -4329,7 +4386,7 @@ Spinner.displayName = "Spinner";
4329
4386
  // src/components/switch.tsx
4330
4387
  import * as React31 from "react";
4331
4388
  import * as SwitchPrimitives from "@radix-ui/react-switch";
4332
- import { jsx as jsx33 } from "react/jsx-runtime";
4389
+ import { jsx as jsx33, jsxs as jsxs17 } from "react/jsx-runtime";
4333
4390
  var switchSizeOptions = ["default", "sm"];
4334
4391
  var switchRootSizeClasses = {
4335
4392
  default: "h-6 w-11",
@@ -4339,29 +4396,107 @@ var switchThumbSizeClasses = {
4339
4396
  default: "h-5 w-5 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
4340
4397
  sm: "h-4 w-4 data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
4341
4398
  };
4342
- var Switch = React31.forwardRef(({ className, size = "default", ...props }, ref) => {
4343
- return /* @__PURE__ */ jsx33(
4344
- SwitchPrimitives.Root,
4345
- {
4346
- className: cn(
4347
- "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",
4348
- switchRootSizeClasses[size],
4349
- className
4350
- ),
4351
- ...props,
4352
- ref,
4353
- children: /* @__PURE__ */ jsx33(
4354
- SwitchPrimitives.Thumb,
4355
- {
4356
- className: cn(
4357
- "pointer-events-none block rounded-full bg-background shadow-sm ring-0 transition-transform duration-sofya ease-sofya",
4358
- switchThumbSizeClasses[size]
4359
- )
4360
- }
4361
- )
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;
4362
4451
  }
4363
- );
4364
- });
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
+ );
4365
4500
  Switch.displayName = SwitchPrimitives.Root.displayName;
4366
4501
 
4367
4502
  // src/components/table.tsx
@@ -4615,7 +4750,7 @@ TableActions.displayName = "TableActions";
4615
4750
  import * as React33 from "react";
4616
4751
  import * as TabsPrimitive from "@radix-ui/react-tabs";
4617
4752
  import { motion as motion3 } from "motion/react";
4618
- import { jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
4753
+ import { jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
4619
4754
  function resolveDefaultValue(items, defaultValue) {
4620
4755
  if (defaultValue) {
4621
4756
  return defaultValue;
@@ -4645,7 +4780,7 @@ function Tabs({
4645
4780
  setUncontrolledCurrentValue(resolvedDefaultValue);
4646
4781
  }
4647
4782
  }, [resolvedDefaultValue, setUncontrolledCurrentValue, value]);
4648
- return /* @__PURE__ */ jsxs17(
4783
+ return /* @__PURE__ */ jsxs18(
4649
4784
  TabsPrimitive.Root,
4650
4785
  {
4651
4786
  className: cn("w-full", className),
@@ -4664,7 +4799,7 @@ function Tabs({
4664
4799
  children: items.map((item) => {
4665
4800
  const isUnavailable = item.disabled || item.loading;
4666
4801
  const isActive = item.value === currentValue;
4667
- return /* @__PURE__ */ jsxs17(
4802
+ return /* @__PURE__ */ jsxs18(
4668
4803
  TabsPrimitive.Trigger,
4669
4804
  {
4670
4805
  value: item.value,
@@ -4686,7 +4821,7 @@ function Tabs({
4686
4821
  transition: { duration: 0.25, ease: "easeInOut" }
4687
4822
  }
4688
4823
  ) : null,
4689
- /* @__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: [
4690
4825
  item.loading ? /* @__PURE__ */ jsx35(
4691
4826
  "span",
4692
4827
  {
@@ -5020,7 +5155,9 @@ export {
5020
5155
  cardVariants,
5021
5156
  createWhitelabelTheme2 as createWhitelabelTheme,
5022
5157
  defaultTheme2 as defaultTheme,
5158
+ dropdownAppearanceOptions,
5023
5159
  dropdownLanguageItems,
5160
+ dropdownTriggerSizeOptions,
5024
5161
  dropdownVariantOptions,
5025
5162
  emptyMediaVariantOptions,
5026
5163
  gradientToCss,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sofya-ds/react",
3
- "version": "1.2.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.2.0"
62
+ "@sofya-ds/tokens": "1.3.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@testing-library/jest-dom": "^6.9.1",