@sarunyu/system-one 4.1.1 → 4.2.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
@@ -4,7 +4,7 @@ import * as React from "react";
4
4
  import React__default, { forwardRef, useState, useRef, useEffect, useCallback, useMemo, useLayoutEffect, useContext, createContext } from "react";
5
5
  import { clsx } from "clsx";
6
6
  import { twMerge } from "tailwind-merge";
7
- import { BookmarkSimpleIcon, BroadcastIcon, CalendarBlank, MapPin, Users, XCircle, CheckCircle, Lock, Check, Plus, Minus, CaretLeft, CaretRight, CaretDoubleLeft, CaretDoubleRight, CaretUp, CaretDown, X, MagnifyingGlass, Circle, ArrowUp, ArrowDown, ArrowsDownUp, Clock } from "@phosphor-icons/react";
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";
8
8
  import { DayPicker, useNavigation } from "react-day-picker";
9
9
  import * as Popover from "@radix-ui/react-popover";
10
10
  import { Drawer as Drawer$1 } from "vaul";
@@ -1173,6 +1173,11 @@ function DrawerPortal({
1173
1173
  }) {
1174
1174
  return /* @__PURE__ */ jsx(Drawer$1.Portal, { "data-slot": "drawer-portal", ...props });
1175
1175
  }
1176
+ function DrawerClose({
1177
+ ...props
1178
+ }) {
1179
+ return /* @__PURE__ */ jsx(Drawer$1.Close, { "data-slot": "drawer-close", ...props });
1180
+ }
1176
1181
  function DrawerOverlay({
1177
1182
  className,
1178
1183
  ...props
@@ -1230,6 +1235,126 @@ function DrawerTitle({
1230
1235
  }
1231
1236
  );
1232
1237
  }
1238
+ function BottomSheet({
1239
+ open,
1240
+ onOpenChange,
1241
+ trigger,
1242
+ headerType = "text",
1243
+ showHeader = true,
1244
+ rightSide = "icon",
1245
+ title = "Title",
1246
+ actionLabel = "Action",
1247
+ imageSrc,
1248
+ leftIcon,
1249
+ rightIcon,
1250
+ onActionClick,
1251
+ showHandle = true,
1252
+ children,
1253
+ className,
1254
+ contentClassName
1255
+ }) {
1256
+ return /* @__PURE__ */ jsxs(Drawer, { direction: "bottom", open, onOpenChange, children: [
1257
+ trigger ? /* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: trigger }) : null,
1258
+ /* @__PURE__ */ jsxs(
1259
+ DrawerContent,
1260
+ {
1261
+ className: cn(
1262
+ "[&>div:first-child]:hidden rounded-t-[24px] border-t-0 px-4 pb-6 pt-2",
1263
+ className
1264
+ ),
1265
+ children: [
1266
+ /* @__PURE__ */ jsx(DrawerTitle, { className: "sr-only", children: title }),
1267
+ showHandle ? /* @__PURE__ */ jsx("div", { className: "mb-2 flex justify-center", children: /* @__PURE__ */ jsx("div", { className: "h-1 w-10 rounded-full bg-muted" }) }) : null,
1268
+ showHeader ? /* @__PURE__ */ jsx(
1269
+ Header,
1270
+ {
1271
+ headerType,
1272
+ rightSide,
1273
+ title,
1274
+ actionLabel,
1275
+ imageSrc,
1276
+ leftIcon,
1277
+ rightIcon,
1278
+ onActionClick
1279
+ }
1280
+ ) : null,
1281
+ children ? /* @__PURE__ */ jsx("div", { className: cn("pt-2", contentClassName), children }) : null
1282
+ ]
1283
+ }
1284
+ )
1285
+ ] });
1286
+ }
1287
+ function Header({
1288
+ headerType,
1289
+ rightSide,
1290
+ title,
1291
+ actionLabel,
1292
+ imageSrc,
1293
+ leftIcon,
1294
+ rightIcon,
1295
+ onActionClick
1296
+ }) {
1297
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-3", rightSide === "action" ? "pr-2" : void 0), children: [
1298
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
1299
+ /* @__PURE__ */ jsx(Leading, { headerType, imageSrc, leftIcon }),
1300
+ /* @__PURE__ */ jsx("p", { className: "truncate text-base leading-6 font-bold text-foreground", children: title })
1301
+ ] }),
1302
+ /* @__PURE__ */ jsx(
1303
+ Trailing,
1304
+ {
1305
+ rightSide,
1306
+ actionLabel,
1307
+ rightIcon,
1308
+ onActionClick
1309
+ }
1310
+ )
1311
+ ] });
1312
+ }
1313
+ function Leading({
1314
+ headerType,
1315
+ imageSrc,
1316
+ leftIcon
1317
+ }) {
1318
+ if (headerType === "image") {
1319
+ return imageSrc ? /* @__PURE__ */ jsx("img", { alt: "", className: "size-8 shrink-0 rounded-md object-cover", src: imageSrc }) : /* @__PURE__ */ jsx("div", { className: "size-8 shrink-0 rounded-md bg-muted" });
1320
+ }
1321
+ if (headerType === "icon") {
1322
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-foreground", children: leftIcon ?? /* @__PURE__ */ jsx(Circle, { size: 22 }) });
1323
+ }
1324
+ return null;
1325
+ }
1326
+ function Trailing({
1327
+ rightSide,
1328
+ actionLabel,
1329
+ rightIcon,
1330
+ onActionClick
1331
+ }) {
1332
+ if (rightSide === "action") {
1333
+ return /* @__PURE__ */ jsx(
1334
+ Button,
1335
+ {
1336
+ className: "px-0 py-0 text-base leading-6 font-bold",
1337
+ onClick: onActionClick,
1338
+ size: "md",
1339
+ variant: "plain",
1340
+ children: actionLabel
1341
+ }
1342
+ );
1343
+ }
1344
+ if (rightSide === "icon") {
1345
+ return /* @__PURE__ */ jsx(DrawerClose, { asChild: true, children: /* @__PURE__ */ jsx(
1346
+ Button,
1347
+ {
1348
+ "aria-label": "Close bottom sheet",
1349
+ className: "text-foreground",
1350
+ size: "icon-xs",
1351
+ variant: "plain-black",
1352
+ children: rightIcon ?? /* @__PURE__ */ jsx(Circle, { size: 22 })
1353
+ }
1354
+ ) });
1355
+ }
1356
+ return null;
1357
+ }
1233
1358
  const THAI_MONTHS_SHORT = [
1234
1359
  "ม.ค.",
1235
1360
  "ก.พ.",
@@ -2160,16 +2285,22 @@ const DateInput = forwardRef(
2160
2285
  ref,
2161
2286
  className: cn("flex flex-col gap-[4px] w-full", className),
2162
2287
  children: [
2163
- isMobile ? /* @__PURE__ */ jsxs(Drawer, { open, onOpenChange: handleOpenChange, children: [
2164
- /* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: triggerButton }),
2165
- /* @__PURE__ */ jsxs(DrawerContent, { children: [
2166
- /* @__PURE__ */ jsx(DrawerTitle, { className: "sr-only", children: "เลือกวันที่" }),
2167
- /* @__PURE__ */ jsxs("div", { className: "overflow-auto px-4 pt-2 pb-8 w-full", children: [
2288
+ isMobile ? /* @__PURE__ */ jsx(
2289
+ BottomSheet,
2290
+ {
2291
+ open,
2292
+ onOpenChange: handleOpenChange,
2293
+ trigger: triggerButton,
2294
+ title: "เลือกวันที่",
2295
+ showHeader: false,
2296
+ rightSide: "none",
2297
+ contentClassName: "pt-0",
2298
+ children: /* @__PURE__ */ jsxs("div", { className: "overflow-auto px-4 pt-2 pb-8 w-full", children: [
2168
2299
  /* @__PURE__ */ jsx(DrawerRangeCtx.Provider, { value: mode === "range", children: calendarContent }),
2169
2300
  actionButtons
2170
2301
  ] })
2171
- ] })
2172
- ] }) : /* @__PURE__ */ jsxs(
2302
+ }
2303
+ ) : /* @__PURE__ */ jsxs(
2173
2304
  Popover.Root,
2174
2305
  {
2175
2306
  open,
@@ -3275,6 +3406,216 @@ const Input = forwardRef(function Input2({
3275
3406
  ] });
3276
3407
  });
3277
3408
  Input.displayName = "Input";
3409
+ const ALERT_CONFIG = {
3410
+ warning: {
3411
+ titleColor: "var(--accent-orange)",
3412
+ background: "https://www.figma.com/api/mcp/asset/f4ca68ad-5732-4124-9ff4-cfb69330cc02",
3413
+ layers: [
3414
+ {
3415
+ inset: "12.5%",
3416
+ src: "https://www.figma.com/api/mcp/asset/7052a092-a432-4e8c-b559-6b51d28d878f"
3417
+ },
3418
+ {
3419
+ inset: "22.5%",
3420
+ src: "https://www.figma.com/api/mcp/asset/a291a1b2-06c8-455c-8e21-29755aa05c57"
3421
+ },
3422
+ {
3423
+ inset: "28.57% 30.71% 32.86% 30.71%",
3424
+ src: "https://www.figma.com/api/mcp/asset/a22c7520-55fe-4003-ba78-65dab40b9e23"
3425
+ }
3426
+ ]
3427
+ },
3428
+ success: {
3429
+ titleColor: "var(--success)",
3430
+ background: "https://www.figma.com/api/mcp/asset/2a865e6f-8a92-4496-88b5-71ac99e2c385",
3431
+ layers: [
3432
+ {
3433
+ inset: "12.77%",
3434
+ src: "https://www.figma.com/api/mcp/asset/5878ce35-4f9a-4203-97a8-70a2f17b182c"
3435
+ },
3436
+ {
3437
+ inset: "22.55%",
3438
+ src: "https://www.figma.com/api/mcp/asset/cea74180-b261-4db7-8712-6d32c4ccdeaf"
3439
+ }
3440
+ ]
3441
+ },
3442
+ danger: {
3443
+ titleColor: "var(--destructive)",
3444
+ background: "https://www.figma.com/api/mcp/asset/c7a65595-684e-4a04-b7fd-d443951f680a",
3445
+ layers: [
3446
+ {
3447
+ inset: "12.77%",
3448
+ src: "https://www.figma.com/api/mcp/asset/10090345-ae32-4fc4-aff6-cba04ea93700"
3449
+ },
3450
+ {
3451
+ inset: "22.55%",
3452
+ src: "https://www.figma.com/api/mcp/asset/3aa1156e-e48b-411f-ab98-93e1da98ecc1"
3453
+ }
3454
+ ]
3455
+ }
3456
+ };
3457
+ function Modal({
3458
+ variant = "dialog",
3459
+ actionLayout = "none",
3460
+ responsive = "mobile",
3461
+ alertStatus = "warning",
3462
+ showClose = true,
3463
+ title = "Text label",
3464
+ description = "Lorem ipsum dolor sit amet consectetur. Mi id nunc ac tempus turpis. Ipsum consectetur dictum volutpat viverra arcu rhoncus sit arcu.",
3465
+ primaryLabel = "Accept",
3466
+ secondaryLabel = "Cancel",
3467
+ children,
3468
+ className,
3469
+ onClose,
3470
+ onPrimaryClick,
3471
+ onSecondaryClick
3472
+ }) {
3473
+ const isContent = variant === "content";
3474
+ const isAlert = variant === "alert";
3475
+ const isDesktop = responsive === "desktop";
3476
+ const alert = ALERT_CONFIG[alertStatus];
3477
+ return /* @__PURE__ */ jsxs(
3478
+ "div",
3479
+ {
3480
+ className: cn(
3481
+ "w-auto overflow-hidden border border-border bg-background",
3482
+ isAlert ? "w-[343px] rounded-2xl" : "rounded-xl",
3483
+ isContent ? "min-w-[343px] max-w-[500px] " : isAlert ? void 0 : "min-w-[375px] max-w-[500px]",
3484
+ className
3485
+ ),
3486
+ children: [
3487
+ /* @__PURE__ */ jsxs(
3488
+ "div",
3489
+ {
3490
+ className: cn(
3491
+ "flex items-center px-4 pt-4",
3492
+ isAlert ? "justify-end" : "justify-between gap-4"
3493
+ ),
3494
+ children: [
3495
+ !isAlert ? /* @__PURE__ */ jsx("p", { className: "text-[18px] leading-7 font-bold text-foreground", children: title }) : null,
3496
+ showClose ? /* @__PURE__ */ jsx(
3497
+ Button,
3498
+ {
3499
+ "aria-label": "Close dialog",
3500
+ className: "h-5 w-5 shrink-0 rounded-none text-subtle-text",
3501
+ onClick: onClose,
3502
+ size: "icon-xs",
3503
+ variant: "plain-black",
3504
+ children: /* @__PURE__ */ jsx(X, { size: 20, weight: "regular" })
3505
+ }
3506
+ ) : null
3507
+ ]
3508
+ }
3509
+ ),
3510
+ /* @__PURE__ */ jsx("div", { className: cn("px-4 pb-6", isAlert ? "pt-0" : "pt-4"), children: isAlert ? /* @__PURE__ */ jsx(AlertBody, { config: alert, title, description }) : isContent ? /* @__PURE__ */ jsx("div", { className: "w-full", children: children ?? null }) : children ?? /* @__PURE__ */ jsx("p", { className: "text-sm leading-5 text-muted-foreground", children: description }) }),
3511
+ actionLayout !== "none" ? /* @__PURE__ */ jsx("div", { className: "px-4 pb-4", children: /* @__PURE__ */ jsx(
3512
+ ModalActions,
3513
+ {
3514
+ layout: actionLayout,
3515
+ isContent,
3516
+ isDesktop,
3517
+ primaryLabel,
3518
+ secondaryLabel,
3519
+ onPrimaryClick,
3520
+ onSecondaryClick
3521
+ }
3522
+ ) }) : null
3523
+ ]
3524
+ }
3525
+ );
3526
+ }
3527
+ function AlertBody({
3528
+ config,
3529
+ title,
3530
+ description
3531
+ }) {
3532
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-4 text-center", children: [
3533
+ /* @__PURE__ */ jsxs("div", { className: "relative size-[100px]", children: [
3534
+ /* @__PURE__ */ jsx(
3535
+ "img",
3536
+ {
3537
+ alt: "",
3538
+ className: "absolute inset-0 size-full",
3539
+ src: config.background
3540
+ }
3541
+ ),
3542
+ config.layers.map((layer) => /* @__PURE__ */ jsx(
3543
+ "div",
3544
+ {
3545
+ className: "absolute",
3546
+ style: { inset: layer.inset },
3547
+ children: /* @__PURE__ */ jsx(
3548
+ "img",
3549
+ {
3550
+ alt: "",
3551
+ className: "absolute inset-0 size-full",
3552
+ src: layer.src
3553
+ }
3554
+ )
3555
+ },
3556
+ layer.src
3557
+ ))
3558
+ ] }),
3559
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
3560
+ /* @__PURE__ */ jsx(
3561
+ "p",
3562
+ {
3563
+ className: "text-[18px] leading-7 font-bold",
3564
+ style: { color: config.titleColor },
3565
+ children: title
3566
+ }
3567
+ ),
3568
+ /* @__PURE__ */ jsx("p", { className: "text-sm leading-5 text-muted-foreground", children: description })
3569
+ ] })
3570
+ ] });
3571
+ }
3572
+ function ModalActions({
3573
+ layout,
3574
+ isContent,
3575
+ isDesktop,
3576
+ primaryLabel,
3577
+ secondaryLabel,
3578
+ onPrimaryClick,
3579
+ onSecondaryClick
3580
+ }) {
3581
+ const desktopInline = isContent && isDesktop;
3582
+ if (layout === "single") {
3583
+ return /* @__PURE__ */ jsx("div", { className: cn(desktopInline ? "flex justify-end" : void 0), children: /* @__PURE__ */ jsx(
3584
+ Button,
3585
+ {
3586
+ className: cn(desktopInline ? void 0 : "w-full"),
3587
+ onClick: onPrimaryClick,
3588
+ size: "xl",
3589
+ variant: "primary",
3590
+ children: primaryLabel
3591
+ }
3592
+ ) });
3593
+ }
3594
+ const containerClass = isContent ? cn("flex gap-4", isDesktop ? "justify-end" : "flex-col") : "flex items-center gap-4";
3595
+ const buttonClass = isContent ? isDesktop ? void 0 : "w-full" : "min-w-0 flex-1";
3596
+ return /* @__PURE__ */ jsxs("div", { className: containerClass, children: [
3597
+ /* @__PURE__ */ jsx(
3598
+ Button,
3599
+ {
3600
+ className: buttonClass,
3601
+ onClick: onSecondaryClick,
3602
+ size: "xl",
3603
+ variant: "outline",
3604
+ children: secondaryLabel
3605
+ }
3606
+ ),
3607
+ /* @__PURE__ */ jsx(
3608
+ Button,
3609
+ {
3610
+ className: buttonClass,
3611
+ onClick: onPrimaryClick,
3612
+ size: "xl",
3613
+ variant: "primary",
3614
+ children: primaryLabel
3615
+ }
3616
+ )
3617
+ ] });
3618
+ }
3278
3619
  const OptionList = forwardRef(
3279
3620
  function OptionList2({
3280
3621
  options,
@@ -4857,16 +5198,22 @@ const TimeInput = forwardRef(
4857
5198
  className
4858
5199
  ),
4859
5200
  children: [
4860
- isMobile ? /* @__PURE__ */ jsxs(Drawer, { open, onOpenChange: handleOpenChange, children: [
4861
- /* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: triggerButton }),
4862
- /* @__PURE__ */ jsxs(DrawerContent, { children: [
4863
- /* @__PURE__ */ jsx(DrawerTitle, { className: "sr-only", children: "เลือกเวลา" }),
4864
- /* @__PURE__ */ jsxs("div", { className: "overflow-auto px-4 pt-2 pb-8 w-full", children: [
5201
+ isMobile ? /* @__PURE__ */ jsx(
5202
+ BottomSheet,
5203
+ {
5204
+ open,
5205
+ onOpenChange: handleOpenChange,
5206
+ trigger: triggerButton,
5207
+ title: "เลือกเวลา",
5208
+ showHeader: false,
5209
+ rightSide: "none",
5210
+ contentClassName: "pt-0",
5211
+ children: /* @__PURE__ */ jsxs("div", { className: "overflow-auto px-4 pt-2 pb-8 w-full", children: [
4865
5212
  pickerContent,
4866
5213
  actionButtons
4867
5214
  ] })
4868
- ] })
4869
- ] }) : /* @__PURE__ */ jsxs(
5215
+ }
5216
+ ) : /* @__PURE__ */ jsxs(
4870
5217
  Popover.Root,
4871
5218
  {
4872
5219
  open,
@@ -4902,6 +5249,7 @@ const TimeInput = forwardRef(
4902
5249
  );
4903
5250
  TimeInput.displayName = "TimeInput";
4904
5251
  export {
5252
+ BottomSheet,
4905
5253
  Button,
4906
5254
  Card,
4907
5255
  Checkbox,
@@ -4910,6 +5258,7 @@ export {
4910
5258
  Dropdown,
4911
5259
  DropdownMultiple,
4912
5260
  Input,
5261
+ Modal,
4913
5262
  OptionList,
4914
5263
  Radio,
4915
5264
  SearchInput,
@@ -4923,6 +5272,7 @@ export {
4923
5272
  Tag,
4924
5273
  TextArea,
4925
5274
  TimeInput,
4926
- cn
5275
+ cn,
5276
+ useIsMobile
4927
5277
  };
4928
5278
  //# sourceMappingURL=index.js.map