@bbki.ng/components 2.5.11 → 2.6.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
@@ -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
  }
@@ -896,6 +897,7 @@ var Img = (props) => {
896
897
  }
897
898
  handleImgLoad(input);
898
899
  },
900
+ crossOrigin: "anonymous",
899
901
  width,
900
902
  height,
901
903
  src: addOssWebpProcessStyle(src, processType || "webp" /* WEBP */),
@@ -926,6 +928,7 @@ var Img = (props) => {
926
928
  "opacity-0": decoded
927
929
  }
928
930
  ),
931
+ crossOrigin: "anonymous",
929
932
  style: { top: 0, left: 0 }
930
933
  }));
931
934
  };
@@ -1272,7 +1275,7 @@ var ContextMenuSubTrigger = React22.forwardRef(({ className, inset, children, ..
1272
1275
  ),
1273
1276
  ...props
1274
1277
  }, children, /* @__PURE__ */ React22.createElement(ChevronRightIcon, {
1275
- className: "ml-auto h-4 w-4"
1278
+ className: "ml-auto"
1276
1279
  })));
1277
1280
  ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
1278
1281
  var ContextMenuSubContent = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React22.createElement(ContextMenuPrimitive.SubContent, {
@@ -1360,8 +1363,148 @@ var ContextMenuShortcut = ({
1360
1363
  };
1361
1364
  ContextMenuShortcut.displayName = "ContextMenuShortcut";
1362
1365
 
1366
+ // lib/form/index.tsx
1367
+ import * as React24 from "react";
1368
+ import { z } from "zod";
1369
+ import { Slot } from "@radix-ui/react-slot";
1370
+ import { zodResolver } from "@hookform/resolvers/zod";
1371
+ import {
1372
+ Controller,
1373
+ useForm,
1374
+ FormProvider,
1375
+ useFormContext
1376
+ } from "react-hook-form";
1377
+ import cn3 from "classnames";
1378
+
1379
+ // lib/label/index.tsx
1380
+ import * as React23 from "react";
1381
+ import * as LabelPrimitive from "@radix-ui/react-label";
1382
+ import { cva } from "class-variance-authority";
1383
+ import cn2 from "classnames";
1384
+ "use client";
1385
+ var labelVariants = cva(
1386
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
1387
+ );
1388
+ var Label2 = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React23.createElement(LabelPrimitive.Root, {
1389
+ ref,
1390
+ className: cn2(labelVariants(), className),
1391
+ ...props
1392
+ }));
1393
+ Label2.displayName = LabelPrimitive.Root.displayName;
1394
+
1395
+ // lib/form/index.tsx
1396
+ "use client";
1397
+ var Form = FormProvider;
1398
+ var FormFieldContext = React24.createContext(
1399
+ {}
1400
+ );
1401
+ var FormField = ({
1402
+ ...props
1403
+ }) => {
1404
+ return /* @__PURE__ */ React24.createElement(FormFieldContext.Provider, {
1405
+ value: { name: props.name }
1406
+ }, /* @__PURE__ */ React24.createElement(Controller, {
1407
+ ...props
1408
+ }));
1409
+ };
1410
+ var useFormField = () => {
1411
+ const fieldContext = React24.useContext(FormFieldContext);
1412
+ const itemContext = React24.useContext(FormItemContext);
1413
+ const { getFieldState, formState } = useFormContext();
1414
+ const fieldState = getFieldState(fieldContext.name, formState);
1415
+ if (!fieldContext) {
1416
+ throw new Error("useFormField should be used within <FormField>");
1417
+ }
1418
+ const { id } = itemContext;
1419
+ return {
1420
+ id,
1421
+ name: fieldContext.name,
1422
+ formItemId: `${id}-form-item`,
1423
+ formDescriptionId: `${id}-form-item-description`,
1424
+ formMessageId: `${id}-form-item-message`,
1425
+ ...fieldState
1426
+ };
1427
+ };
1428
+ var FormItemContext = React24.createContext(
1429
+ {}
1430
+ );
1431
+ var FormItem = React24.forwardRef(({ className, ...props }, ref) => {
1432
+ const id = React24.useId();
1433
+ return /* @__PURE__ */ React24.createElement(FormItemContext.Provider, {
1434
+ value: { id }
1435
+ }, /* @__PURE__ */ React24.createElement("div", {
1436
+ ref,
1437
+ className: cn3("space-y-2", className),
1438
+ ...props
1439
+ }));
1440
+ });
1441
+ FormItem.displayName = "FormItem";
1442
+ var FormLabel = React24.forwardRef(({ className, ...props }, ref) => {
1443
+ const { error, formItemId } = useFormField();
1444
+ return /* @__PURE__ */ React24.createElement(Label2, {
1445
+ ref,
1446
+ className: cn3(error && "text-destructive", className),
1447
+ htmlFor: formItemId,
1448
+ ...props
1449
+ });
1450
+ });
1451
+ FormLabel.displayName = "FormLabel";
1452
+ var FormControl = React24.forwardRef(({ ...props }, ref) => {
1453
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
1454
+ return /* @__PURE__ */ React24.createElement(Slot, {
1455
+ ref,
1456
+ id: formItemId,
1457
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
1458
+ "aria-invalid": !!error,
1459
+ ...props
1460
+ });
1461
+ });
1462
+ FormControl.displayName = "FormControl";
1463
+ var FormDescription = React24.forwardRef(({ className, ...props }, ref) => {
1464
+ const { formDescriptionId } = useFormField();
1465
+ return /* @__PURE__ */ React24.createElement("p", {
1466
+ ref,
1467
+ id: formDescriptionId,
1468
+ className: cn3("text-sm text-muted-foreground", className),
1469
+ ...props
1470
+ });
1471
+ });
1472
+ FormDescription.displayName = "FormDescription";
1473
+ var FormMessage = React24.forwardRef(({ className, children, ...props }, ref) => {
1474
+ const { error, formMessageId } = useFormField();
1475
+ const body = error ? String(error == null ? void 0 : error.message) : children;
1476
+ if (!body) {
1477
+ return null;
1478
+ }
1479
+ return /* @__PURE__ */ React24.createElement("p", {
1480
+ ref,
1481
+ id: formMessageId,
1482
+ className: cn3("text-sm font-medium text-destructive", className),
1483
+ ...props
1484
+ }, body);
1485
+ });
1486
+ FormMessage.displayName = "FormMessage";
1487
+
1488
+ // lib/input/index.tsx
1489
+ import * as React25 from "react";
1490
+ import cn4 from "classnames";
1491
+ var Input = React25.forwardRef(
1492
+ ({ className, type, ...props }, ref) => {
1493
+ return /* @__PURE__ */ React25.createElement("input", {
1494
+ type,
1495
+ className: cn4(
1496
+ "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",
1497
+ className
1498
+ ),
1499
+ ref,
1500
+ ...props
1501
+ });
1502
+ }
1503
+ );
1504
+ Input.displayName = "Input";
1505
+
1363
1506
  // lib/blur-cover/BlurCover.tsx
1364
- import React23 from "react";
1507
+ import React26 from "react";
1365
1508
  import cls5 from "classnames";
1366
1509
  var BlurCover = (props) => {
1367
1510
  const { status } = props;
@@ -1382,13 +1525,13 @@ var BlurCover = (props) => {
1382
1525
  },
1383
1526
  props.className
1384
1527
  );
1385
- return /* @__PURE__ */ React23.createElement("div", {
1528
+ return /* @__PURE__ */ React26.createElement("div", {
1386
1529
  className: coverCls
1387
1530
  });
1388
1531
  };
1389
1532
 
1390
1533
  // lib/canvas/Canvas.tsx
1391
- import React24, { useEffect as useEffect6 } from "react";
1534
+ import React27, { useEffect as useEffect6 } from "react";
1392
1535
 
1393
1536
  // lib/canvas/useRenderer.ts
1394
1537
  import { useEffect as useEffect5, useRef as useRef3, useState as useState7 } from "react";
@@ -1487,7 +1630,7 @@ var Canvas = (props) => {
1487
1630
  renderer.remove(instName);
1488
1631
  };
1489
1632
  }, [renderer]);
1490
- return /* @__PURE__ */ React24.createElement("canvas", {
1633
+ return /* @__PURE__ */ React27.createElement("canvas", {
1491
1634
  style: {
1492
1635
  ...props.style,
1493
1636
  imageRendering: "pixelated"
@@ -1522,10 +1665,19 @@ export {
1522
1665
  ContextMenuTrigger,
1523
1666
  DropImage,
1524
1667
  DropZone,
1525
- Error,
1668
+ Error2 as Error,
1526
1669
  ErrorBoundary,
1670
+ Form,
1671
+ FormControl,
1672
+ FormDescription,
1673
+ FormField,
1674
+ FormItem,
1675
+ FormLabel,
1676
+ FormMessage,
1527
1677
  Gallery,
1528
1678
  Img,
1679
+ Input,
1680
+ Label2 as Label,
1529
1681
  Link,
1530
1682
  LinkColor,
1531
1683
  LinkList,
@@ -1545,6 +1697,10 @@ export {
1545
1697
  Tags,
1546
1698
  ThreeColLayout,
1547
1699
  TitledList,
1548
- ossProcessType
1700
+ ossProcessType,
1701
+ useForm,
1702
+ useFormField,
1703
+ z,
1704
+ zodResolver
1549
1705
  };
1550
1706
  //# sourceMappingURL=index.js.map