@sofya-ds/react 1.1.15 → 1.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.cjs CHANGED
@@ -133,6 +133,7 @@ __export(index_exports, {
133
133
  TooltipContent: () => TooltipContent,
134
134
  TooltipProvider: () => TooltipProvider,
135
135
  TooltipTrigger: () => TooltipTrigger,
136
+ accordionAppearanceOptions: () => accordionAppearanceOptions,
136
137
  alertSizeOptions: () => alertSizeOptions,
137
138
  alertToneOptions: () => alertToneOptions,
138
139
  avatarSizeOptions: () => avatarSizeOptions,
@@ -181,6 +182,7 @@ __export(index_exports, {
181
182
  sofyaSurfaceNames: () => import_tokens2.sofyaSurfaceNames,
182
183
  sofyaTextStyleNames: () => import_tokens2.sofyaTextStyleNames,
183
184
  spinnerSizeOptions: () => spinnerSizeOptions,
185
+ switchSizeOptions: () => switchSizeOptions,
184
186
  tableActionToneOptions: () => tableActionToneOptions,
185
187
  tableCellVariantOptions: () => tableCellVariantOptions,
186
188
  tableStatusToneOptions: () => tableStatusToneOptions,
@@ -340,6 +342,8 @@ var tablerIconRegistry = {
340
342
  IconTrashOff: import_icons_react.IconTrashOff,
341
343
  IconTrashX: import_icons_react.IconTrashX,
342
344
  IconChevronRight: import_icons_react.IconChevronRight,
345
+ IconLogout: import_icons_react.IconLogout,
346
+ IconSettings: import_icons_react.IconSettings,
343
347
  IconX: import_icons_react.IconX
344
348
  };
345
349
  var tablerIconNames = Object.keys(tablerIconRegistry).sort(
@@ -383,6 +387,7 @@ var legacyIconToTablerNameMap = {
383
387
  "caret-up": "IconChevronUp",
384
388
  "caret-left": "IconChevronLeft",
385
389
  "caret-right": "IconChevronRight",
390
+ "logout": "IconLogout",
386
391
  "users-group": "IconUsersGroup",
387
392
  "archive": "IconArchive",
388
393
  "folder": "IconFolder",
@@ -392,7 +397,8 @@ var legacyIconToTablerNameMap = {
392
397
  "trash-x": "IconTrashX",
393
398
  "delete": "IconTrash",
394
399
  "remove": "IconTrashX",
395
- "lixeira": "IconTrash"
400
+ "lixeira": "IconTrash",
401
+ "settings": "IconSettings"
396
402
  };
397
403
  var iconNames = Object.keys(legacyIconToTablerNameMap);
398
404
  var iconRegistry = Object.fromEntries(
@@ -753,67 +759,154 @@ function renderTextContent(children, { as, className, size = "body", style, vari
753
759
 
754
760
  // src/components/accordion.tsx
755
761
  var import_jsx_runtime4 = require("react/jsx-runtime");
756
- var Accordion = AccordionPrimitive.Root;
757
- var AccordionItem = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
758
- AccordionPrimitive.Item,
762
+ var accordionAppearanceOptions = ["default", "card"];
763
+ var AccordionAppearanceContext = React4.createContext("default");
764
+ var accordionItemClasses = {
765
+ default: "group/accordion-item border-b border-border bg-transparent text-foreground",
766
+ card: "group/accordion-item bg-transparent text-foreground"
767
+ };
768
+ var accordionTriggerClasses = {
769
+ default: "sofya-accordion-trigger flex flex-1 items-center justify-between gap-4 py-4 text-left [font-family:var(--sofya-text-body-font-family)] text-[length:var(--sofya-text-body-font-size)] font-medium leading-[var(--sofya-text-body-line-height)] tracking-[var(--sofya-text-body-letter-spacing)] text-foreground 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:pointer-events-none disabled:opacity-50",
770
+ card: "sofya-accordion-trigger flex w-full items-center justify-between gap-4 rounded-[16px] border border-secondary bg-[color:var(--sofya-background)] px-6 py-4 text-left text-foreground transition-[background-color,border-color,box-shadow,color] duration-sofya ease-sofya hover:border-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--sofya-focus-ring-soft)] focus-visible:ring-offset-0 disabled:pointer-events-none disabled:opacity-50"
771
+ };
772
+ var accordionContentClasses = {
773
+ default: "sofya-accordion-content overflow-hidden text-sm text-muted-foreground",
774
+ card: "sofya-accordion-content overflow-hidden text-foreground"
775
+ };
776
+ var accordionContentBodyClasses = {
777
+ default: "pb-4 pr-10",
778
+ card: "flex flex-col gap-4 rounded-[8px] border border-border bg-[color:var(--sofya-background)] p-6"
779
+ };
780
+ function useAccordionAppearance() {
781
+ return React4.useContext(AccordionAppearanceContext);
782
+ }
783
+ var Accordion = React4.forwardRef(({ appearance = "default", className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AccordionAppearanceContext.Provider, { value: appearance, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
784
+ AccordionPrimitive.Root,
759
785
  {
760
786
  ref,
761
- className: cn(
762
- "group/accordion-item border-b border-border bg-transparent text-foreground",
763
- className
764
- ),
787
+ "data-appearance": appearance === "card" ? appearance : void 0,
788
+ className: cn(appearance === "card" && "flex flex-col gap-4", className),
765
789
  ...props
766
790
  }
767
- ));
791
+ ) }));
792
+ Accordion.displayName = AccordionPrimitive.Root.displayName;
793
+ var AccordionItem = React4.forwardRef(({ className, ...props }, ref) => {
794
+ const appearance = useAccordionAppearance();
795
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
796
+ AccordionPrimitive.Item,
797
+ {
798
+ ref,
799
+ "data-appearance": appearance === "card" ? appearance : void 0,
800
+ className: cn(accordionItemClasses[appearance], className),
801
+ ...props
802
+ }
803
+ );
804
+ });
768
805
  AccordionItem.displayName = AccordionPrimitive.Item.displayName;
769
- var AccordionTrigger = React4.forwardRef(({ className, children, indicator, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AccordionPrimitive.Header, { className: "flex", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
770
- AccordionPrimitive.Trigger,
771
- {
772
- ref,
773
- className: cn(
774
- "sofya-accordion-trigger flex flex-1 items-center justify-between gap-4 py-4 text-left [font-family:var(--sofya-text-body-font-family)] text-[length:var(--sofya-text-body-font-size)] font-medium leading-[var(--sofya-text-body-line-height)] tracking-[var(--sofya-text-body-letter-spacing)] text-foreground 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:pointer-events-none disabled:opacity-50",
775
- className
776
- ),
777
- ...props,
778
- children: [
779
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 flex-1", children: renderTextContent(children, {
780
- as: "span",
781
- className: "block text-foreground",
782
- size: "body",
783
- style: {
784
- color: "inherit",
785
- fontFamily: "inherit",
786
- fontSize: "inherit",
787
- fontWeight: "inherit",
788
- letterSpacing: "inherit",
789
- lineHeight: "inherit"
790
- }
791
- }) }),
792
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
793
- "span",
806
+ var AccordionTrigger = React4.forwardRef(
807
+ ({
808
+ className,
809
+ children,
810
+ description,
811
+ hideIndicator,
812
+ indicator,
813
+ leading,
814
+ ...props
815
+ }, ref) => {
816
+ const appearance = useAccordionAppearance();
817
+ const hasDescription = description !== void 0 && description !== null;
818
+ const resolvedHideIndicator = hideIndicator ?? appearance === "card";
819
+ const indicatorNode = indicator !== void 0 ? indicator : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "caret-down", size: 12 });
820
+ const shouldRenderIndicator = !resolvedHideIndicator && indicatorNode != null;
821
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
822
+ AccordionPrimitive.Header,
823
+ {
824
+ "data-appearance": appearance === "card" ? appearance : void 0,
825
+ className: cn("flex", appearance === "card" && "w-full"),
826
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
827
+ AccordionPrimitive.Trigger,
828
+ {
829
+ ref,
830
+ "data-appearance": appearance === "card" ? appearance : void 0,
831
+ className: cn(accordionTriggerClasses[appearance], className),
832
+ ...props,
833
+ children: [
834
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: cn("min-w-0 flex-1", leading && "flex items-center gap-4"), children: [
835
+ leading ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "flex shrink-0 items-center justify-center", children: leading }) : null,
836
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
837
+ "span",
838
+ {
839
+ className: cn(
840
+ "min-w-0 flex-1",
841
+ (appearance === "card" || hasDescription) && "flex flex-col gap-2"
842
+ ),
843
+ children: [
844
+ renderTextContent(children, {
845
+ as: "span",
846
+ className: "block min-w-0 text-foreground",
847
+ size: appearance === "card" ? "h5" : "body",
848
+ style: appearance === "card" ? void 0 : {
849
+ color: "inherit",
850
+ fontFamily: "inherit",
851
+ fontSize: "inherit",
852
+ fontWeight: "inherit",
853
+ letterSpacing: "inherit",
854
+ lineHeight: "inherit"
855
+ }
856
+ }),
857
+ hasDescription ? renderTextContent(description, {
858
+ as: "span",
859
+ className: "block min-w-0 text-muted-foreground",
860
+ size: "body"
861
+ }) : null
862
+ ]
863
+ }
864
+ )
865
+ ] }),
866
+ shouldRenderIndicator ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
867
+ "span",
868
+ {
869
+ "aria-hidden": "true",
870
+ className: cn(
871
+ "sofya-accordion-indicator flex h-5 w-5 shrink-0 items-center justify-center text-muted-foreground transition-transform duration-sofya ease-sofya",
872
+ appearance === "card" && "text-secondary"
873
+ ),
874
+ children: indicatorNode
875
+ }
876
+ ) : null
877
+ ]
878
+ }
879
+ )
880
+ }
881
+ );
882
+ }
883
+ );
884
+ AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
885
+ var AccordionContent = React4.forwardRef(({ className, children, contentClassName, ...props }, ref) => {
886
+ const appearance = useAccordionAppearance();
887
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
888
+ AccordionPrimitive.Content,
889
+ {
890
+ ref,
891
+ "data-appearance": appearance === "card" ? appearance : void 0,
892
+ className: cn(accordionContentClasses[appearance], className),
893
+ ...props,
894
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
895
+ "div",
794
896
  {
795
- "aria-hidden": "true",
796
897
  className: cn(
797
- "sofya-accordion-indicator flex h-5 w-5 shrink-0 items-center justify-center text-muted-foreground transition-transform duration-sofya ease-sofya"
898
+ "sofya-accordion-content-body",
899
+ accordionContentBodyClasses[appearance],
900
+ contentClassName
798
901
  ),
799
- children: indicator ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "caret-down", size: 12 })
902
+ children: renderTextContent(children, {
903
+ className: appearance === "card" ? "text-foreground" : "text-muted-foreground"
904
+ })
800
905
  }
801
906
  )
802
- ]
803
- }
804
- ) }));
805
- AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
806
- var AccordionContent = React4.forwardRef(({ className, children, contentClassName, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
807
- AccordionPrimitive.Content,
808
- {
809
- ref,
810
- className: cn("sofya-accordion-content overflow-hidden text-sm text-muted-foreground", className),
811
- ...props,
812
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cn("pb-4 pr-10", contentClassName), children: renderTextContent(children, {
813
- className: "text-muted-foreground"
814
- }) })
815
- }
816
- ));
907
+ }
908
+ );
909
+ });
817
910
  AccordionContent.displayName = AccordionPrimitive.Content.displayName;
818
911
 
819
912
  // src/components/alert.tsx
@@ -4384,12 +4477,22 @@ Spinner.displayName = "Spinner";
4384
4477
  var React31 = __toESM(require("react"), 1);
4385
4478
  var SwitchPrimitives = __toESM(require("@radix-ui/react-switch"), 1);
4386
4479
  var import_jsx_runtime33 = require("react/jsx-runtime");
4387
- var Switch = React31.forwardRef(({ className, ...props }, ref) => {
4480
+ var switchSizeOptions = ["default", "sm"];
4481
+ var switchRootSizeClasses = {
4482
+ default: "h-6 w-11",
4483
+ sm: "h-5 w-9"
4484
+ };
4485
+ var switchThumbSizeClasses = {
4486
+ default: "h-5 w-5 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
4487
+ sm: "h-4 w-4 data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
4488
+ };
4489
+ var Switch = React31.forwardRef(({ className, size = "default", ...props }, ref) => {
4388
4490
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4389
4491
  SwitchPrimitives.Root,
4390
4492
  {
4391
4493
  className: cn(
4392
- "peer inline-flex h-6 w-11 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",
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],
4393
4496
  className
4394
4497
  ),
4395
4498
  ...props,
@@ -4397,7 +4500,10 @@ var Switch = React31.forwardRef(({ className, ...props }, ref) => {
4397
4500
  children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4398
4501
  SwitchPrimitives.Thumb,
4399
4502
  {
4400
- className: "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-sm ring-0 transition-transform duration-sofya ease-sofya data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
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
+ )
4401
4507
  }
4402
4508
  )
4403
4509
  }
@@ -5021,6 +5127,7 @@ var import_tokens2 = require("@sofya-ds/tokens");
5021
5127
  TooltipContent,
5022
5128
  TooltipProvider,
5023
5129
  TooltipTrigger,
5130
+ accordionAppearanceOptions,
5024
5131
  alertSizeOptions,
5025
5132
  alertToneOptions,
5026
5133
  avatarSizeOptions,
@@ -5069,6 +5176,7 @@ var import_tokens2 = require("@sofya-ds/tokens");
5069
5176
  sofyaSurfaceNames,
5070
5177
  sofyaTextStyleNames,
5071
5178
  spinnerSizeOptions,
5179
+ switchSizeOptions,
5072
5180
  tableActionToneOptions,
5073
5181
  tableCellVariantOptions,
5074
5182
  tableStatusToneOptions,