@sarunyu/system-one 4.2.2 → 4.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
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import React__default, { forwardRef, useState, useRef, useEffect, useCallback, useMemo, useLayoutEffect, useContext, createContext } from "react";
4
+ import React__default, { forwardRef, useState, useRef, useEffect, useCallback, useId, useMemo, useLayoutEffect, useContext, createContext } from "react";
5
5
  import { clsx } from "clsx";
6
6
  import { twMerge } from "tailwind-merge";
7
7
  import { BookmarkSimpleIcon, BroadcastIcon, CalendarBlank, MapPin, Users, XCircle, CheckCircle, Lock, Check, Plus, Circle, Minus, CaretLeft, CaretRight, CaretDoubleLeft, CaretDoubleRight, CaretUp, CaretDown, X, MagnifyingGlass, ArrowUp, ArrowDown, ArrowsDownUp, Clock } from "@phosphor-icons/react";
@@ -228,7 +228,6 @@ const Button = forwardRef(function Button2({
228
228
  );
229
229
  });
230
230
  Button.displayName = "Button";
231
- const imgBanner = "";
232
231
  function DurationBadge({
233
232
  duration,
234
233
  size
@@ -324,6 +323,7 @@ const tagConfig = {
324
323
  const Card = forwardRef(function Card2({
325
324
  variant = "event",
326
325
  size = "desktop",
326
+ children,
327
327
  title,
328
328
  locked = true,
329
329
  image,
@@ -346,7 +346,24 @@ const Card = forwardRef(function Card2({
346
346
  // live
347
347
  duration
348
348
  }, ref) {
349
- const bannerSrc = image ?? imgBanner;
349
+ const bannerSrc = image ?? "";
350
+ if (variant === "default") {
351
+ const shellPadding = size === "desktop" ? "p-4" : size === "tablet" ? "p-3" : "p-2.5";
352
+ const shellRadius = size === "mobile" ? "rounded-[6px]" : "rounded-[8px]";
353
+ return /* @__PURE__ */ jsx(
354
+ "div",
355
+ {
356
+ ref,
357
+ className: cn(
358
+ "flex min-h-0 min-w-0 flex-col bg-card text-foreground shadow-card",
359
+ shellRadius,
360
+ shellPadding,
361
+ className
362
+ ),
363
+ children
364
+ }
365
+ );
366
+ }
350
367
  if (variant === "social") {
351
368
  const isDesktop = size === "desktop";
352
369
  const cardWidth = isDesktop ? "w-[587px]" : "w-[343px]";
@@ -983,6 +1000,109 @@ const Checkbox = forwardRef(function Checkbox2({
983
1000
  );
984
1001
  });
985
1002
  Checkbox.displayName = "Checkbox";
1003
+ const trackClass = {
1004
+ sm: "w-8 h-5",
1005
+ md: "w-10 h-6"
1006
+ };
1007
+ const thumbClass = {
1008
+ sm: "top-0.5 left-0.5 size-4",
1009
+ md: "top-0.5 left-0.5 size-5"
1010
+ };
1011
+ const thumbTranslate = {
1012
+ sm: "translate-x-3",
1013
+ md: "translate-x-4"
1014
+ };
1015
+ const Toggle = forwardRef(function Toggle2({
1016
+ checked = false,
1017
+ disabled = false,
1018
+ onChange,
1019
+ label,
1020
+ description,
1021
+ size: sizeProp,
1022
+ id: idProp,
1023
+ ariaLabel,
1024
+ className
1025
+ }, ref) {
1026
+ const generatedId = useId();
1027
+ const switchId = idProp ?? generatedId;
1028
+ const hasText = label !== void 0 || description !== void 0;
1029
+ const hasDescription = description !== void 0;
1030
+ const size = sizeProp ?? (hasText ? "sm" : "md");
1031
+ const trackBg = disabled ? checked ? "bg-switch-on-disabled" : "bg-switch-background" : checked ? "bg-primary-action" : "bg-switch-background";
1032
+ const thumbBg = disabled && !checked ? "bg-switch-background" : "bg-[var(--fill-white-1000)]";
1033
+ const switchEl = /* @__PURE__ */ jsx(
1034
+ "button",
1035
+ {
1036
+ ref,
1037
+ id: switchId,
1038
+ type: "button",
1039
+ role: "switch",
1040
+ "aria-checked": checked,
1041
+ "aria-label": hasText ? void 0 : ariaLabel,
1042
+ disabled,
1043
+ onClick: () => onChange == null ? void 0 : onChange(!checked),
1044
+ className: cn(
1045
+ "relative shrink-0 rounded-full p-0 transition-colors duration-200 ease-out",
1046
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
1047
+ disabled ? "cursor-not-allowed" : "cursor-pointer",
1048
+ trackClass[size],
1049
+ trackBg
1050
+ ),
1051
+ children: /* @__PURE__ */ jsx(
1052
+ "span",
1053
+ {
1054
+ "aria-hidden": "true",
1055
+ className: cn(
1056
+ "pointer-events-none absolute rounded-full transition-transform duration-200 ease-out",
1057
+ "shadow-[var(--toggle-knob-shadow)]",
1058
+ thumbClass[size],
1059
+ thumbBg,
1060
+ checked && thumbTranslate[size]
1061
+ )
1062
+ }
1063
+ )
1064
+ }
1065
+ );
1066
+ if (!hasText) {
1067
+ return /* @__PURE__ */ jsx("span", { className: cn("inline-flex", className), children: switchEl });
1068
+ }
1069
+ return /* @__PURE__ */ jsxs(
1070
+ "label",
1071
+ {
1072
+ className: cn(
1073
+ "flex w-full min-w-0 gap-4 select-none",
1074
+ hasDescription ? "items-start" : "items-center",
1075
+ disabled ? "cursor-not-allowed" : "cursor-pointer",
1076
+ className
1077
+ ),
1078
+ children: [
1079
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0 text-sm font-normal leading-5", children: [
1080
+ label !== void 0 && /* @__PURE__ */ jsx(
1081
+ "span",
1082
+ {
1083
+ className: cn(
1084
+ disabled ? "text-disabled" : "text-foreground"
1085
+ ),
1086
+ children: label
1087
+ }
1088
+ ),
1089
+ hasDescription && /* @__PURE__ */ jsx(
1090
+ "span",
1091
+ {
1092
+ className: cn(
1093
+ "whitespace-pre-wrap font-normal",
1094
+ disabled ? "text-disabled" : "text-[color:var(--text-default-secondary)]"
1095
+ ),
1096
+ children: description
1097
+ }
1098
+ )
1099
+ ] }),
1100
+ /* @__PURE__ */ jsx("span", { className: "shrink-0", children: switchEl })
1101
+ ]
1102
+ }
1103
+ );
1104
+ });
1105
+ Toggle.displayName = "Toggle";
986
1106
  function RadioVisual({ checked, disabled }) {
987
1107
  return /* @__PURE__ */ jsx(
988
1108
  "span",
@@ -5273,6 +5393,7 @@ export {
5273
5393
  Tag,
5274
5394
  TextArea,
5275
5395
  TimeInput,
5396
+ Toggle,
5276
5397
  cn,
5277
5398
  useIsMobile
5278
5399
  };