@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.cjs CHANGED
@@ -152,7 +152,9 @@ __export(index_exports, {
152
152
  cardVariants: () => cardVariants,
153
153
  createWhitelabelTheme: () => import_tokens2.createWhitelabelTheme,
154
154
  defaultTheme: () => import_tokens2.defaultTheme,
155
+ dropdownAppearanceOptions: () => dropdownAppearanceOptions,
155
156
  dropdownLanguageItems: () => dropdownLanguageItems,
157
+ dropdownTriggerSizeOptions: () => dropdownTriggerSizeOptions,
156
158
  dropdownVariantOptions: () => dropdownVariantOptions,
157
159
  emptyMediaVariantOptions: () => emptyMediaVariantOptions,
158
160
  gradientToCss: () => import_tokens2.gradientToCss,
@@ -1958,22 +1960,51 @@ var dropdownVariantOptions = [
1958
1960
  "language",
1959
1961
  "selected"
1960
1962
  ];
1963
+ var dropdownAppearanceOptions = ["panel", "card"];
1964
+ var dropdownTriggerSizeOptions = ["default", "sm", "lg"];
1961
1965
  var dropdownLanguageItems = [
1962
1966
  { value: "en-US", label: "English", languageLocale: "en-US" },
1963
1967
  { value: "pt-BR", label: "Portuguese", languageLocale: "pt-BR" },
1964
1968
  { value: "es-ES", label: "Spanish", languageLocale: "es-ES" }
1965
1969
  ];
1966
- var dropdownTriggerClasses = {
1967
- card: "h-12 rounded-[20px] px-6 py-2 text-primary",
1968
- panel: "h-12 rounded-[10px] px-6 py-2 text-foreground",
1970
+ var dropdownTriggerToneClasses = {
1971
+ card: "text-primary",
1972
+ panel: "text-foreground",
1969
1973
  language: "",
1970
- 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)]"
1974
+ 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)]"
1971
1975
  };
1972
- var dropdownContentClasses = {
1973
- card: "rounded-[20px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1974
- panel: "rounded-[10px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1975
- language: "w-[224px] min-w-[224px] rounded-[10px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
1976
- 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)]"
1976
+ var dropdownTriggerSizeClasses = {
1977
+ regular: {
1978
+ default: "h-12 px-6 py-2",
1979
+ sm: "h-10 px-4 py-2",
1980
+ lg: "h-14 px-8 py-4"
1981
+ },
1982
+ selected: {
1983
+ default: "h-10 px-4 py-2",
1984
+ sm: "h-9 px-2 py-2",
1985
+ lg: "h-12 px-6 py-2"
1986
+ },
1987
+ language: {
1988
+ default: "h-[38px] w-[38px] p-0",
1989
+ sm: "h-8 w-8 p-0",
1990
+ lg: "h-11 w-11 p-0"
1991
+ }
1992
+ };
1993
+ var dropdownAppearanceClasses = {
1994
+ panel: {
1995
+ content: "rounded-[10px]",
1996
+ trigger: "rounded-[10px]"
1997
+ },
1998
+ card: {
1999
+ content: "rounded-[20px]",
2000
+ trigger: "rounded-[20px]"
2001
+ }
2002
+ };
2003
+ var dropdownContentBaseClasses = {
2004
+ card: "border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
2005
+ panel: "border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
2006
+ language: "w-[224px] min-w-[224px] border-[color:var(--sofya-border-strong)] text-foreground shadow-[var(--sofya-shadow-soft)]",
2007
+ 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)]"
1977
2008
  };
1978
2009
  var dropdownItemClasses = {
1979
2010
  card: "text-foreground",
@@ -1993,6 +2024,24 @@ function resolveItemLanguageLocale(item) {
1993
2024
  }
1994
2025
  return isButtonLanguageLocale(item.value) ? item.value : void 0;
1995
2026
  }
2027
+ function resolveDropdownAppearance({
2028
+ appearance,
2029
+ variant
2030
+ }) {
2031
+ if (appearance) {
2032
+ return appearance;
2033
+ }
2034
+ return variant === "card" ? "card" : "panel";
2035
+ }
2036
+ function resolveDropdownTriggerSizeFamily(variant) {
2037
+ if (variant === "language") {
2038
+ return "language";
2039
+ }
2040
+ if (variant === "selected") {
2041
+ return "selected";
2042
+ }
2043
+ return "regular";
2044
+ }
1996
2045
  function DefaultDropdownTriggerIcon({ variant }) {
1997
2046
  if (variant === "selected") {
1998
2047
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -2024,6 +2073,7 @@ function LanguageFlagIcon({ locale }) {
2024
2073
  }
2025
2074
  function Dropdown({
2026
2075
  align = "start",
2076
+ appearance,
2027
2077
  contentClassName,
2028
2078
  defaultOpen,
2029
2079
  defaultValue,
@@ -2038,11 +2088,14 @@ function Dropdown({
2038
2088
  sideOffset = 8,
2039
2089
  triggerClassName,
2040
2090
  triggerIcon,
2091
+ triggerSize = "default",
2041
2092
  value,
2042
2093
  variant = "card"
2043
2094
  }) {
2044
2095
  const isLanguageVariant = variant === "language";
2045
2096
  const isSelectedVariant = variant === "selected";
2097
+ const resolvedAppearance = resolveDropdownAppearance({ appearance, variant });
2098
+ const triggerSizeFamily = resolveDropdownTriggerSizeFamily(variant);
2046
2099
  const usesDefaultListStyle = !isLanguageVariant;
2047
2100
  const resolvedItems = React12.useMemo(
2048
2101
  () => isLanguageVariant ? items && items.length > 0 ? items : dropdownLanguageItems : items ?? [],
@@ -2092,9 +2145,13 @@ function Dropdown({
2092
2145
  type: "button",
2093
2146
  variant: isLanguageVariant ? "language" : "dropdown",
2094
2147
  languageLocale: selectedLanguageLocale,
2148
+ "data-appearance": resolvedAppearance,
2149
+ "data-trigger-size": triggerSize,
2095
2150
  className: cn(
2096
2151
  "min-w-0",
2097
- isLanguageVariant ? "h-[38px] w-[38px] rounded-[10px] p-0" : dropdownTriggerClasses[variant],
2152
+ dropdownTriggerToneClasses[variant],
2153
+ dropdownTriggerSizeClasses[triggerSizeFamily][triggerSize],
2154
+ dropdownAppearanceClasses[resolvedAppearance].trigger,
2098
2155
  selectedTriggerToneClassName,
2099
2156
  triggerClassName
2100
2157
  ),
@@ -2111,9 +2168,11 @@ function Dropdown({
2111
2168
  {
2112
2169
  align,
2113
2170
  sideOffset,
2171
+ "data-appearance": resolvedAppearance,
2114
2172
  className: cn(
2115
2173
  "sofya-dropdown-content z-50 w-auto min-w-[var(--radix-dropdown-menu-trigger-width)] border bg-card p-2 outline-none",
2116
- dropdownContentClasses[variant],
2174
+ dropdownContentBaseClasses[variant],
2175
+ dropdownAppearanceClasses[resolvedAppearance].content,
2117
2176
  contentClassName
2118
2177
  ),
2119
2178
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -4486,29 +4545,107 @@ var switchThumbSizeClasses = {
4486
4545
  default: "h-5 w-5 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
4487
4546
  sm: "h-4 w-4 data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
4488
4547
  };
4489
- var Switch = React31.forwardRef(({ className, size = "default", ...props }, ref) => {
4490
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4491
- SwitchPrimitives.Root,
4492
- {
4493
- className: cn(
4494
- "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",
4495
- switchRootSizeClasses[size],
4496
- className
4497
- ),
4498
- ...props,
4499
- ref,
4500
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4501
- SwitchPrimitives.Thumb,
4502
- {
4503
- className: cn(
4504
- "pointer-events-none block rounded-full bg-background shadow-sm ring-0 transition-transform duration-sofya ease-sofya",
4505
- switchThumbSizeClasses[size]
4506
- )
4507
- }
4508
- )
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;
4509
4600
  }
4510
- );
4511
- });
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
+ );
4512
4649
  Switch.displayName = SwitchPrimitives.Root.displayName;
4513
4650
 
4514
4651
  // src/components/table.tsx
@@ -5146,7 +5283,9 @@ var import_tokens2 = require("@sofya-ds/tokens");
5146
5283
  cardVariants,
5147
5284
  createWhitelabelTheme,
5148
5285
  defaultTheme,
5286
+ dropdownAppearanceOptions,
5149
5287
  dropdownLanguageItems,
5288
+ dropdownTriggerSizeOptions,
5150
5289
  dropdownVariantOptions,
5151
5290
  emptyMediaVariantOptions,
5152
5291
  gradientToCss,