@bbki.ng/components 1.5.13 → 1.5.16

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.d.ts CHANGED
@@ -86,7 +86,25 @@ declare type PageProps = {
86
86
  declare const Page: (props: PageProps) => JSX.Element;
87
87
  declare const NotFound: (props: {
88
88
  children?: any;
89
- }) => JSX.Element;
89
+ }) => JSX.Element;
90
+ declare const Error: (props: {
91
+ error: Error;
92
+ }) => JSX.Element;
93
+ declare class ErrorBoundary extends React.Component<{
94
+ children: any;
95
+ }, {
96
+ error?: Error;
97
+ hasError: boolean;
98
+ }> {
99
+ constructor(props: {
100
+ children: any;
101
+ });
102
+ static getDerivedStateFromError(error: Error): {
103
+ hasError: boolean;
104
+ error: Error;
105
+ };
106
+ render(): any;
107
+ }
90
108
 
91
109
  declare type PopConfirmProps = {
92
110
  onOk?: EventHandler<React.MouseEvent<HTMLButtonElement>> | (() => Promise<void>);
@@ -128,7 +146,7 @@ interface SkeletonProps {
128
146
  bgColor?: SkeletonColor;
129
147
  }
130
148
  interface ArticleSkeletonProps extends SkeletonProps {
131
- titleLength: number;
149
+ titleLength?: number;
132
150
  descriptionLength?: number;
133
151
  children?: any;
134
152
  }
@@ -205,4 +223,4 @@ interface NoiseCoverProps {
205
223
  }
206
224
  declare const NoiseCover: (props: NoiseCoverProps) => JSX.Element;
207
225
 
208
- export { Article, ArticleProps, ArticleSkeleton, ArticleSkeletonProps, BLinkDotProps, BlinkDot, Breadcrumb, BreadcrumbProps, Button, ButtonProps, ButtonType, DropImage, ImageDropProps, ImagePreviewerProps, Link, LinkColor, LinkList, LinkListProps, LinkListSkeleton, LinkListSkeletonProps, LinkProps, List, Logo, LogoProps, Nav, NavProps, NoiseCover, NoiseCoverProps, NotFound, Page, Panel, PanelProps, PathObj, PopConfirm, PopConfirmProps, Skeleton, SkeletonColor, SkeletonProps, Table, TableProps, Tag, TagProps, Tags, ThreeColLayout, TitledList, TitledListProps, listProps, threeColLayoutProps };
226
+ export { Article, ArticleProps, ArticleSkeleton, ArticleSkeletonProps, BLinkDotProps, BlinkDot, Breadcrumb, BreadcrumbProps, Button, ButtonProps, ButtonType, DropImage, Error, ErrorBoundary, ImageDropProps, ImagePreviewerProps, Link, LinkColor, LinkList, LinkListProps, LinkListSkeleton, LinkListSkeletonProps, LinkProps, List, Logo, LogoProps, Nav, NavProps, NoiseCover, NoiseCoverProps, NotFound, Page, Panel, PanelProps, PathObj, PopConfirm, PopConfirmProps, Skeleton, SkeletonColor, SkeletonProps, Table, TableProps, Tag, TagProps, Tags, ThreeColLayout, TitledList, TitledListProps, listProps, threeColLayoutProps };
package/dist/index.js CHANGED
@@ -65,6 +65,8 @@ __export(src_exports, {
65
65
  Button: () => Button,
66
66
  ButtonType: () => ButtonType,
67
67
  DropImage: () => DropImage,
68
+ Error: () => Error2,
69
+ ErrorBoundary: () => ErrorBoundary,
68
70
  Link: () => Link,
69
71
  LinkColor: () => LinkColor,
70
72
  LinkList: () => LinkList,
@@ -229,7 +231,8 @@ var Breadcrumb = (props) => {
229
231
  const isNonEnName = !/^[a-zA-Z~]+$/.test(name);
230
232
  const offsetCls = (0, import_classnames3.default)({ "relative top-[2px]": isNonEnName });
231
233
  const link = path ? /* @__PURE__ */ import_react4.default.createElement(Link, {
232
- to: path
234
+ to: path,
235
+ className: offsetCls
233
236
  }, name) : /* @__PURE__ */ import_react4.default.createElement("span", {
234
237
  className: (0, import_classnames3.default)("text-gray-400", offsetCls)
235
238
  }, name);
@@ -351,6 +354,30 @@ var NotFound = (props) => {
351
354
  className: "flex justify-center items-center text-white"
352
355
  }, props.children || 404);
353
356
  };
357
+ var Error2 = (props) => {
358
+ const { error } = props;
359
+ return /* @__PURE__ */ import_react9.default.createElement(NoiseCover, {
360
+ color: "#ef4444",
361
+ className: "flex justify-center items-center text-white"
362
+ }, /* @__PURE__ */ import_react9.default.createElement("code", null, error.name, ": ", error.message));
363
+ };
364
+ var ErrorBoundary = class extends import_react9.default.Component {
365
+ constructor(props) {
366
+ super(props);
367
+ this.state = { hasError: false };
368
+ }
369
+ static getDerivedStateFromError(error) {
370
+ return { hasError: true, error };
371
+ }
372
+ render() {
373
+ if (this.state.error && this.state.hasError) {
374
+ return /* @__PURE__ */ import_react9.default.createElement(Error2, {
375
+ error: this.state.error
376
+ });
377
+ }
378
+ return this.props.children;
379
+ }
380
+ };
354
381
 
355
382
  // src/pop-confirm/PopConfirm.tsx
356
383
  var import_react11 = __toESM(require("react"));
@@ -480,7 +507,7 @@ var Skeleton = (props) => {
480
507
  });
481
508
  };
482
509
  var ArticleSkeleton = (props) => {
483
- const { children, titleLength, descriptionLength } = props;
510
+ const { children, titleLength = 0, descriptionLength } = props;
484
511
  return /* @__PURE__ */ import_react14.default.createElement(Article, {
485
512
  title: /* @__PURE__ */ import_react14.default.createElement(Skeleton, {
486
513
  width: 36 * titleLength,
@@ -500,6 +527,12 @@ var LinkListSkeleton = (props) => {
500
527
  bgColor: "blue" /* BLUE */
501
528
  });
502
529
  };
530
+ if (!rest.titleLength) {
531
+ return /* @__PURE__ */ import_react14.default.createElement(List, {
532
+ items: linksLength,
533
+ itemRenderer: renderSkeleton
534
+ });
535
+ }
503
536
  return /* @__PURE__ */ import_react14.default.createElement(ArticleSkeleton, __spreadValues({}, rest), /* @__PURE__ */ import_react14.default.createElement(List, {
504
537
  items: linksLength,
505
538
  itemRenderer: renderSkeleton
@@ -803,6 +836,8 @@ module.exports = __toCommonJS(src_exports);
803
836
  Button,
804
837
  ButtonType,
805
838
  DropImage,
839
+ Error,
840
+ ErrorBoundary,
806
841
  Link,
807
842
  LinkColor,
808
843
  LinkList,
package/dist/index.mjs CHANGED
@@ -173,7 +173,8 @@ var Breadcrumb = (props) => {
173
173
  const isNonEnName = !/^[a-zA-Z~]+$/.test(name);
174
174
  const offsetCls = classNames3({ "relative top-[2px]": isNonEnName });
175
175
  const link = path ? /* @__PURE__ */ React5.createElement(Link, {
176
- to: path
176
+ to: path,
177
+ className: offsetCls
177
178
  }, name) : /* @__PURE__ */ React5.createElement("span", {
178
179
  className: classNames3("text-gray-400", offsetCls)
179
180
  }, name);
@@ -295,6 +296,30 @@ var NotFound = (props) => {
295
296
  className: "flex justify-center items-center text-white"
296
297
  }, props.children || 404);
297
298
  };
299
+ var Error2 = (props) => {
300
+ const { error } = props;
301
+ return /* @__PURE__ */ React10.createElement(NoiseCover, {
302
+ color: "#ef4444",
303
+ className: "flex justify-center items-center text-white"
304
+ }, /* @__PURE__ */ React10.createElement("code", null, error.name, ": ", error.message));
305
+ };
306
+ var ErrorBoundary = class extends React10.Component {
307
+ constructor(props) {
308
+ super(props);
309
+ this.state = { hasError: false };
310
+ }
311
+ static getDerivedStateFromError(error) {
312
+ return { hasError: true, error };
313
+ }
314
+ render() {
315
+ if (this.state.error && this.state.hasError) {
316
+ return /* @__PURE__ */ React10.createElement(Error2, {
317
+ error: this.state.error
318
+ });
319
+ }
320
+ return this.props.children;
321
+ }
322
+ };
298
323
 
299
324
  // src/pop-confirm/PopConfirm.tsx
300
325
  import React12, { useState as useState2 } from "react";
@@ -424,7 +449,7 @@ var Skeleton = (props) => {
424
449
  });
425
450
  };
426
451
  var ArticleSkeleton = (props) => {
427
- const { children, titleLength, descriptionLength } = props;
452
+ const { children, titleLength = 0, descriptionLength } = props;
428
453
  return /* @__PURE__ */ React15.createElement(Article, {
429
454
  title: /* @__PURE__ */ React15.createElement(Skeleton, {
430
455
  width: 36 * titleLength,
@@ -444,6 +469,12 @@ var LinkListSkeleton = (props) => {
444
469
  bgColor: "blue" /* BLUE */
445
470
  });
446
471
  };
472
+ if (!rest.titleLength) {
473
+ return /* @__PURE__ */ React15.createElement(List, {
474
+ items: linksLength,
475
+ itemRenderer: renderSkeleton
476
+ });
477
+ }
447
478
  return /* @__PURE__ */ React15.createElement(ArticleSkeleton, __spreadValues({}, rest), /* @__PURE__ */ React15.createElement(List, {
448
479
  items: linksLength,
449
480
  itemRenderer: renderSkeleton
@@ -748,6 +779,8 @@ export {
748
779
  Button,
749
780
  ButtonType,
750
781
  DropImage,
782
+ Error2 as Error,
783
+ ErrorBoundary,
751
784
  Link,
752
785
  LinkColor,
753
786
  LinkList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/components",
3
- "version": "1.5.13",
3
+ "version": "1.5.16",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",