@bbki.ng/components 2.5.11 → 2.6.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.js CHANGED
@@ -30,11 +30,12 @@ function Button(props) {
30
30
  ["disabled" /* DISABLED */]: "text-gray-400 cursor-not-allowed",
31
31
  ["normal" /* NORMAL */]: "text-black"
32
32
  };
33
- const { type = "normal" /* NORMAL */, className = "", onClick } = props;
33
+ const { type = "normal" /* NORMAL */, className = "", onClick, btnType } = props;
34
34
  const shadowTransCls = type === "disabled" /* DISABLED */ ? "" : "transition-all duration-200 ease-in-out shadow-button hover:shadow-button-hover active:shadow-empty";
35
35
  return /* @__PURE__ */ React2.createElement("button", {
36
36
  className: `${typeClsMap[type]} ${className} ${shadowTransCls} py-8 px-16 transition-all duration-200 ease-in-out`,
37
- onClick
37
+ onClick,
38
+ type: btnType
38
39
  }, props.children);
39
40
  }
40
41
  Button.displayName = "Button";
@@ -275,11 +276,11 @@ var Page = (props) => {
275
276
  }, main));
276
277
  };
277
278
  var NotFound = (props) => {
278
- return /* @__PURE__ */ React10.createElement(Error, {
279
+ return /* @__PURE__ */ React10.createElement(Error2, {
279
280
  error: { name: "404", message: "Not Found" }
280
281
  });
281
282
  };
282
- var Error = (props) => {
283
+ var Error2 = (props) => {
283
284
  const { error } = props;
284
285
  return /* @__PURE__ */ React10.createElement("div", {
285
286
  className: "prose"
@@ -301,7 +302,7 @@ var ErrorBoundary = class extends React10.Component {
301
302
  title: "\u51FA\u9519"
302
303
  }, /* @__PURE__ */ React10.createElement("div", {
303
304
  className: "relative h-256"
304
- }, /* @__PURE__ */ React10.createElement(Error, {
305
+ }, /* @__PURE__ */ React10.createElement(Error2, {
305
306
  error: this.state.error
306
307
  })));
307
308
  }
@@ -1272,7 +1273,7 @@ var ContextMenuSubTrigger = React22.forwardRef(({ className, inset, children, ..
1272
1273
  ),
1273
1274
  ...props
1274
1275
  }, children, /* @__PURE__ */ React22.createElement(ChevronRightIcon, {
1275
- className: "ml-auto h-4 w-4"
1276
+ className: "ml-auto"
1276
1277
  })));
1277
1278
  ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
1278
1279
  var ContextMenuSubContent = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React22.createElement(ContextMenuPrimitive.SubContent, {
@@ -1360,8 +1361,148 @@ var ContextMenuShortcut = ({
1360
1361
  };
1361
1362
  ContextMenuShortcut.displayName = "ContextMenuShortcut";
1362
1363
 
1364
+ // lib/form/index.tsx
1365
+ import * as React24 from "react";
1366
+ import { z } from "zod";
1367
+ import { Slot } from "@radix-ui/react-slot";
1368
+ import { zodResolver } from "@hookform/resolvers/zod";
1369
+ import {
1370
+ Controller,
1371
+ useForm,
1372
+ FormProvider,
1373
+ useFormContext
1374
+ } from "react-hook-form";
1375
+ import cn3 from "classnames";
1376
+
1377
+ // lib/label/index.tsx
1378
+ import * as React23 from "react";
1379
+ import * as LabelPrimitive from "@radix-ui/react-label";
1380
+ import { cva } from "class-variance-authority";
1381
+ import cn2 from "classnames";
1382
+ "use client";
1383
+ var labelVariants = cva(
1384
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
1385
+ );
1386
+ var Label2 = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React23.createElement(LabelPrimitive.Root, {
1387
+ ref,
1388
+ className: cn2(labelVariants(), className),
1389
+ ...props
1390
+ }));
1391
+ Label2.displayName = LabelPrimitive.Root.displayName;
1392
+
1393
+ // lib/form/index.tsx
1394
+ "use client";
1395
+ var Form = FormProvider;
1396
+ var FormFieldContext = React24.createContext(
1397
+ {}
1398
+ );
1399
+ var FormField = ({
1400
+ ...props
1401
+ }) => {
1402
+ return /* @__PURE__ */ React24.createElement(FormFieldContext.Provider, {
1403
+ value: { name: props.name }
1404
+ }, /* @__PURE__ */ React24.createElement(Controller, {
1405
+ ...props
1406
+ }));
1407
+ };
1408
+ var useFormField = () => {
1409
+ const fieldContext = React24.useContext(FormFieldContext);
1410
+ const itemContext = React24.useContext(FormItemContext);
1411
+ const { getFieldState, formState } = useFormContext();
1412
+ const fieldState = getFieldState(fieldContext.name, formState);
1413
+ if (!fieldContext) {
1414
+ throw new Error("useFormField should be used within <FormField>");
1415
+ }
1416
+ const { id } = itemContext;
1417
+ return {
1418
+ id,
1419
+ name: fieldContext.name,
1420
+ formItemId: `${id}-form-item`,
1421
+ formDescriptionId: `${id}-form-item-description`,
1422
+ formMessageId: `${id}-form-item-message`,
1423
+ ...fieldState
1424
+ };
1425
+ };
1426
+ var FormItemContext = React24.createContext(
1427
+ {}
1428
+ );
1429
+ var FormItem = React24.forwardRef(({ className, ...props }, ref) => {
1430
+ const id = React24.useId();
1431
+ return /* @__PURE__ */ React24.createElement(FormItemContext.Provider, {
1432
+ value: { id }
1433
+ }, /* @__PURE__ */ React24.createElement("div", {
1434
+ ref,
1435
+ className: cn3("space-y-2", className),
1436
+ ...props
1437
+ }));
1438
+ });
1439
+ FormItem.displayName = "FormItem";
1440
+ var FormLabel = React24.forwardRef(({ className, ...props }, ref) => {
1441
+ const { error, formItemId } = useFormField();
1442
+ return /* @__PURE__ */ React24.createElement(Label2, {
1443
+ ref,
1444
+ className: cn3(error && "text-destructive", className),
1445
+ htmlFor: formItemId,
1446
+ ...props
1447
+ });
1448
+ });
1449
+ FormLabel.displayName = "FormLabel";
1450
+ var FormControl = React24.forwardRef(({ ...props }, ref) => {
1451
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
1452
+ return /* @__PURE__ */ React24.createElement(Slot, {
1453
+ ref,
1454
+ id: formItemId,
1455
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
1456
+ "aria-invalid": !!error,
1457
+ ...props
1458
+ });
1459
+ });
1460
+ FormControl.displayName = "FormControl";
1461
+ var FormDescription = React24.forwardRef(({ className, ...props }, ref) => {
1462
+ const { formDescriptionId } = useFormField();
1463
+ return /* @__PURE__ */ React24.createElement("p", {
1464
+ ref,
1465
+ id: formDescriptionId,
1466
+ className: cn3("text-sm text-muted-foreground", className),
1467
+ ...props
1468
+ });
1469
+ });
1470
+ FormDescription.displayName = "FormDescription";
1471
+ var FormMessage = React24.forwardRef(({ className, children, ...props }, ref) => {
1472
+ const { error, formMessageId } = useFormField();
1473
+ const body = error ? String(error == null ? void 0 : error.message) : children;
1474
+ if (!body) {
1475
+ return null;
1476
+ }
1477
+ return /* @__PURE__ */ React24.createElement("p", {
1478
+ ref,
1479
+ id: formMessageId,
1480
+ className: cn3("text-sm font-medium text-destructive", className),
1481
+ ...props
1482
+ }, body);
1483
+ });
1484
+ FormMessage.displayName = "FormMessage";
1485
+
1486
+ // lib/input/index.tsx
1487
+ import * as React25 from "react";
1488
+ import cn4 from "classnames";
1489
+ var Input = React25.forwardRef(
1490
+ ({ className, type, ...props }, ref) => {
1491
+ return /* @__PURE__ */ React25.createElement("input", {
1492
+ type,
1493
+ className: cn4(
1494
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
1495
+ className
1496
+ ),
1497
+ ref,
1498
+ ...props
1499
+ });
1500
+ }
1501
+ );
1502
+ Input.displayName = "Input";
1503
+
1363
1504
  // lib/blur-cover/BlurCover.tsx
1364
- import React23 from "react";
1505
+ import React26 from "react";
1365
1506
  import cls5 from "classnames";
1366
1507
  var BlurCover = (props) => {
1367
1508
  const { status } = props;
@@ -1382,13 +1523,13 @@ var BlurCover = (props) => {
1382
1523
  },
1383
1524
  props.className
1384
1525
  );
1385
- return /* @__PURE__ */ React23.createElement("div", {
1526
+ return /* @__PURE__ */ React26.createElement("div", {
1386
1527
  className: coverCls
1387
1528
  });
1388
1529
  };
1389
1530
 
1390
1531
  // lib/canvas/Canvas.tsx
1391
- import React24, { useEffect as useEffect6 } from "react";
1532
+ import React27, { useEffect as useEffect6 } from "react";
1392
1533
 
1393
1534
  // lib/canvas/useRenderer.ts
1394
1535
  import { useEffect as useEffect5, useRef as useRef3, useState as useState7 } from "react";
@@ -1487,7 +1628,7 @@ var Canvas = (props) => {
1487
1628
  renderer.remove(instName);
1488
1629
  };
1489
1630
  }, [renderer]);
1490
- return /* @__PURE__ */ React24.createElement("canvas", {
1631
+ return /* @__PURE__ */ React27.createElement("canvas", {
1491
1632
  style: {
1492
1633
  ...props.style,
1493
1634
  imageRendering: "pixelated"
@@ -1522,10 +1663,19 @@ export {
1522
1663
  ContextMenuTrigger,
1523
1664
  DropImage,
1524
1665
  DropZone,
1525
- Error,
1666
+ Error2 as Error,
1526
1667
  ErrorBoundary,
1668
+ Form,
1669
+ FormControl,
1670
+ FormDescription,
1671
+ FormField,
1672
+ FormItem,
1673
+ FormLabel,
1674
+ FormMessage,
1527
1675
  Gallery,
1528
1676
  Img,
1677
+ Input,
1678
+ Label2 as Label,
1529
1679
  Link,
1530
1680
  LinkColor,
1531
1681
  LinkList,
@@ -1545,6 +1695,10 @@ export {
1545
1695
  Tags,
1546
1696
  ThreeColLayout,
1547
1697
  TitledList,
1548
- ossProcessType
1698
+ ossProcessType,
1699
+ useForm,
1700
+ useFormField,
1701
+ z,
1702
+ zodResolver
1549
1703
  };
1550
1704
  //# sourceMappingURL=index.js.map