@bbki.ng/components 1.5.23 → 1.5.26

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
@@ -263,4 +263,21 @@ interface GalleryProps extends Omit<RandomRowsLayoutProps, "classNames" | "cells
263
263
  }
264
264
  declare const Gallery: (props: GalleryProps) => JSX.Element;
265
265
 
266
- export { Article, ArticleProps, ArticleSkeleton, ArticleSkeletonProps, BLinkDotProps, BlinkDot, Breadcrumb, BreadcrumbProps, Button, ButtonProps, ButtonType, DropImage, Error, ErrorBoundary, Gallery, GalleryProps, ImageDropProps, ImagePreviewerProps, ImageRenderer, Img, 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 };
266
+ interface ISettings {
267
+ canvas: HTMLCanvasElement;
268
+ step?: number;
269
+ }
270
+
271
+ interface IOpt {
272
+ multiplier: number;
273
+ color: number[];
274
+ spiralConstA: number;
275
+ spiralConstB: number;
276
+ }
277
+
278
+ interface LoadingSpiralProps extends IOpt, ISettings {
279
+ className?: "string";
280
+ }
281
+ declare const LoadingSpiral: (props: LoadingSpiralProps) => JSX.Element;
282
+
283
+ export { Article, ArticleProps, ArticleSkeleton, ArticleSkeletonProps, BLinkDotProps, BlinkDot, Breadcrumb, BreadcrumbProps, Button, ButtonProps, ButtonType, DropImage, Error, ErrorBoundary, Gallery, GalleryProps, ImageDropProps, ImagePreviewerProps, ImageRenderer, Img, Link, LinkColor, LinkList, LinkListProps, LinkListSkeleton, LinkListSkeletonProps, LinkProps, List, LoadingSpiral, LoadingSpiralProps, 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
@@ -74,6 +74,7 @@ __export(src_exports, {
74
74
  LinkList: () => LinkList,
75
75
  LinkListSkeleton: () => LinkListSkeleton,
76
76
  List: () => List,
77
+ LoadingSpiral: () => LoadingSpiral,
77
78
  Logo: () => Logo,
78
79
  Nav: () => Nav,
79
80
  NoiseCover: () => NoiseCover,
@@ -973,7 +974,7 @@ var RandomRowsLayout = (props) => {
973
974
  const {
974
975
  cellsCount,
975
976
  cellRenderer,
976
- classNames: classNames7 = "",
977
+ classNames: classNames8 = "",
977
978
  cellWrapperClsGenerator = defaultCellClsGenerator
978
979
  } = props;
979
980
  const colNums = generateRandomColNum(cellsCount);
@@ -982,7 +983,7 @@ var RandomRowsLayout = (props) => {
982
983
  indexRef.current = 0;
983
984
  });
984
985
  return /* @__PURE__ */ import_react20.default.createElement("div", {
985
- className: classNames7
986
+ className: classNames8
986
987
  }, colNums.map((colNum, row) => {
987
988
  const randBool = generateRandomBoolean(colNum < 2 ? 0.6 : 0.5);
988
989
  const randBoolArr = [randBool, !randBool];
@@ -1037,6 +1038,156 @@ var Gallery = (props) => {
1037
1038
  cellRenderer: renderImage
1038
1039
  }, rest)), children);
1039
1040
  };
1041
+
1042
+ // src/loading-spiral/LoadingSpiral.tsx
1043
+ var import_phenomenon = __toESM(require("phenomenon"));
1044
+ var import_classnames13 = __toESM(require("classnames"));
1045
+ var import_react23 = __toESM(require("react"));
1046
+
1047
+ // src/loading-spiral/createSettings.ts
1048
+ var createSettings = (settings) => {
1049
+ const { canvas, step = 0.1 } = settings;
1050
+ const uniforms = {
1051
+ uProgress: {
1052
+ type: "float",
1053
+ value: 0
1054
+ }
1055
+ };
1056
+ return {
1057
+ uniforms,
1058
+ shouldRender: true,
1059
+ canvas,
1060
+ onRender: (r) => {
1061
+ const { uProgress } = r.uniforms;
1062
+ uProgress.value += step;
1063
+ }
1064
+ };
1065
+ };
1066
+
1067
+ // src/loading-spiral/constants.ts
1068
+ var VERTEX_SHADER = `
1069
+ attribute vec3 ${"aPositionStart" /* POSITION_START */};
1070
+ attribute vec3 ${"aColor" /* COLOR */};
1071
+ uniform mat4 uProjectionMatrix;
1072
+ uniform mat4 uModelMatrix;
1073
+ uniform mat4 uViewMatrix;
1074
+ uniform float uProgress;
1075
+ varying vec3 vColor;
1076
+ mat4 rotate(float _angle){
1077
+ return mat4(
1078
+ cos(_angle),-sin(_angle), 0.0, 0.0,
1079
+ sin(_angle),cos(_angle), 0.0, 0.0,
1080
+ 0.0, 0.0, 0.0, 0.0,
1081
+ 0.0, 0.0, 0.0, 1.0
1082
+ );
1083
+ }
1084
+ void main(){
1085
+ gl_Position = rotate(uProgress) * uProjectionMatrix * uModelMatrix * uViewMatrix * vec4(${"aPositionStart" /* POSITION_START */}, 1.0);
1086
+ gl_PointSize = 2.0;
1087
+ vColor = ${"aColor" /* COLOR */};
1088
+ }
1089
+ `;
1090
+ var FRAGMENT_SHADER = `
1091
+ precision mediump float;
1092
+ uniform float uProgress;
1093
+
1094
+ varying vec3 vColor;
1095
+ void main(){
1096
+ gl_FragColor = vec4(vColor, 1.0);
1097
+ }
1098
+ `;
1099
+
1100
+ // src/loading-spiral/utils.ts
1101
+ var scaleIndex = (multiplier, max) => (index) => {
1102
+ return index / (multiplier / max);
1103
+ };
1104
+ var scaleIndex2ang = (multiplier) => scaleIndex(multiplier, 360);
1105
+ var rgba = (val) => {
1106
+ const [r, g, b, a] = val;
1107
+ return [r / 255, g / 255, b / 255, a];
1108
+ };
1109
+ var randOpacityRgb = (val) => {
1110
+ const [r, g, b] = val;
1111
+ return rgba([r, g, b, Math.random()]);
1112
+ };
1113
+
1114
+ // src/loading-spiral/createOptions.ts
1115
+ var DEFAULT_OPT = {
1116
+ multiplier: 3e4,
1117
+ color: [209, 213, 219, 1],
1118
+ spiralConstA: 0.04,
1119
+ spiralConstB: 0.16
1120
+ };
1121
+ var createOptions = (opt = DEFAULT_OPT) => {
1122
+ const { multiplier, spiralConstA, spiralConstB, color } = opt;
1123
+ const attributes = [
1124
+ {
1125
+ name: "aPositionStart" /* POSITION_START */,
1126
+ data: (index) => {
1127
+ const ang = scaleIndex2ang(multiplier)(index);
1128
+ const A = spiralConstA;
1129
+ const B = spiralConstB;
1130
+ const xPos = A * Math.pow(Math.E, B * ang) * Math.cos(ang);
1131
+ const yPos = A * Math.pow(Math.E, B * ang) * Math.sin(ang);
1132
+ return [xPos, yPos, 1];
1133
+ },
1134
+ size: 3
1135
+ },
1136
+ {
1137
+ name: "aColor" /* COLOR */,
1138
+ data: () => randOpacityRgb(color),
1139
+ size: 3
1140
+ }
1141
+ ];
1142
+ return {
1143
+ attributes,
1144
+ multiplier,
1145
+ vertex: VERTEX_SHADER,
1146
+ fragment: FRAGMENT_SHADER
1147
+ };
1148
+ };
1149
+
1150
+ // src/loading-spiral/useCanvasRef.ts
1151
+ var import_react22 = require("react");
1152
+ var useResizedCanvasRef = () => {
1153
+ const canvasRef = (0, import_react22.useRef)(null);
1154
+ const containerRef = (0, import_react22.useRef)(null);
1155
+ (0, import_react22.useEffect)(() => {
1156
+ const canvas = canvasRef.current;
1157
+ const container = containerRef.current;
1158
+ if (!canvas || !container)
1159
+ return;
1160
+ const { width, height } = container.getBoundingClientRect();
1161
+ const canvasSize = Math.max(width, height);
1162
+ canvas.setAttribute("width", `${canvasSize}`);
1163
+ canvas.setAttribute("height", `${canvasSize}`);
1164
+ }, []);
1165
+ return {
1166
+ canvasRef,
1167
+ containerRef
1168
+ };
1169
+ };
1170
+
1171
+ // src/loading-spiral/LoadingSpiral.tsx
1172
+ var LoadingSpiral = (props) => {
1173
+ const { canvasRef, containerRef } = useResizedCanvasRef();
1174
+ const _a = props, { className, canvas, step } = _a, rest = __objRest(_a, ["className", "canvas", "step"]);
1175
+ (0, import_react23.useEffect)(() => {
1176
+ if (!canvasRef.current) {
1177
+ return;
1178
+ }
1179
+ const phenomenon = new import_phenomenon.default({
1180
+ settings: createSettings({ canvas: canvasRef.current, step })
1181
+ });
1182
+ phenomenon.add("spiral", createOptions(Object.assign({}, DEFAULT_OPT, rest)));
1183
+ }, []);
1184
+ return /* @__PURE__ */ import_react23.default.createElement("div", {
1185
+ className: (0, import_classnames13.default)("fixed h-full w-full overflow-hidden flex justify-center items-center", className),
1186
+ ref: containerRef
1187
+ }, /* @__PURE__ */ import_react23.default.createElement("canvas", {
1188
+ ref: canvasRef
1189
+ }));
1190
+ };
1040
1191
  module.exports = __toCommonJS(src_exports);
1041
1192
  // Annotate the CommonJS export names for ESM import in node:
1042
1193
  0 && (module.exports = {
@@ -1056,6 +1207,7 @@ module.exports = __toCommonJS(src_exports);
1056
1207
  LinkList,
1057
1208
  LinkListSkeleton,
1058
1209
  List,
1210
+ LoadingSpiral,
1059
1211
  Logo,
1060
1212
  Nav,
1061
1213
  NoiseCover,
package/dist/index.mjs CHANGED
@@ -916,7 +916,7 @@ var RandomRowsLayout = (props) => {
916
916
  const {
917
917
  cellsCount,
918
918
  cellRenderer,
919
- classNames: classNames7 = "",
919
+ classNames: classNames8 = "",
920
920
  cellWrapperClsGenerator = defaultCellClsGenerator
921
921
  } = props;
922
922
  const colNums = generateRandomColNum(cellsCount);
@@ -925,7 +925,7 @@ var RandomRowsLayout = (props) => {
925
925
  indexRef.current = 0;
926
926
  });
927
927
  return /* @__PURE__ */ React19.createElement("div", {
928
- className: classNames7
928
+ className: classNames8
929
929
  }, colNums.map((colNum, row) => {
930
930
  const randBool = generateRandomBoolean(colNum < 2 ? 0.6 : 0.5);
931
931
  const randBoolArr = [randBool, !randBool];
@@ -980,6 +980,156 @@ var Gallery = (props) => {
980
980
  cellRenderer: renderImage
981
981
  }, rest)), children);
982
982
  };
983
+
984
+ // src/loading-spiral/LoadingSpiral.tsx
985
+ import Phenomenon from "phenomenon";
986
+ import classNames7 from "classnames";
987
+ import React21, { useEffect as useEffect4 } from "react";
988
+
989
+ // src/loading-spiral/createSettings.ts
990
+ var createSettings = (settings) => {
991
+ const { canvas, step = 0.1 } = settings;
992
+ const uniforms = {
993
+ uProgress: {
994
+ type: "float",
995
+ value: 0
996
+ }
997
+ };
998
+ return {
999
+ uniforms,
1000
+ shouldRender: true,
1001
+ canvas,
1002
+ onRender: (r) => {
1003
+ const { uProgress } = r.uniforms;
1004
+ uProgress.value += step;
1005
+ }
1006
+ };
1007
+ };
1008
+
1009
+ // src/loading-spiral/constants.ts
1010
+ var VERTEX_SHADER = `
1011
+ attribute vec3 ${"aPositionStart" /* POSITION_START */};
1012
+ attribute vec3 ${"aColor" /* COLOR */};
1013
+ uniform mat4 uProjectionMatrix;
1014
+ uniform mat4 uModelMatrix;
1015
+ uniform mat4 uViewMatrix;
1016
+ uniform float uProgress;
1017
+ varying vec3 vColor;
1018
+ mat4 rotate(float _angle){
1019
+ return mat4(
1020
+ cos(_angle),-sin(_angle), 0.0, 0.0,
1021
+ sin(_angle),cos(_angle), 0.0, 0.0,
1022
+ 0.0, 0.0, 0.0, 0.0,
1023
+ 0.0, 0.0, 0.0, 1.0
1024
+ );
1025
+ }
1026
+ void main(){
1027
+ gl_Position = rotate(uProgress) * uProjectionMatrix * uModelMatrix * uViewMatrix * vec4(${"aPositionStart" /* POSITION_START */}, 1.0);
1028
+ gl_PointSize = 2.0;
1029
+ vColor = ${"aColor" /* COLOR */};
1030
+ }
1031
+ `;
1032
+ var FRAGMENT_SHADER = `
1033
+ precision mediump float;
1034
+ uniform float uProgress;
1035
+
1036
+ varying vec3 vColor;
1037
+ void main(){
1038
+ gl_FragColor = vec4(vColor, 1.0);
1039
+ }
1040
+ `;
1041
+
1042
+ // src/loading-spiral/utils.ts
1043
+ var scaleIndex = (multiplier, max) => (index) => {
1044
+ return index / (multiplier / max);
1045
+ };
1046
+ var scaleIndex2ang = (multiplier) => scaleIndex(multiplier, 360);
1047
+ var rgba = (val) => {
1048
+ const [r, g, b, a] = val;
1049
+ return [r / 255, g / 255, b / 255, a];
1050
+ };
1051
+ var randOpacityRgb = (val) => {
1052
+ const [r, g, b] = val;
1053
+ return rgba([r, g, b, Math.random()]);
1054
+ };
1055
+
1056
+ // src/loading-spiral/createOptions.ts
1057
+ var DEFAULT_OPT = {
1058
+ multiplier: 3e4,
1059
+ color: [209, 213, 219, 1],
1060
+ spiralConstA: 0.04,
1061
+ spiralConstB: 0.16
1062
+ };
1063
+ var createOptions = (opt = DEFAULT_OPT) => {
1064
+ const { multiplier, spiralConstA, spiralConstB, color } = opt;
1065
+ const attributes = [
1066
+ {
1067
+ name: "aPositionStart" /* POSITION_START */,
1068
+ data: (index) => {
1069
+ const ang = scaleIndex2ang(multiplier)(index);
1070
+ const A = spiralConstA;
1071
+ const B = spiralConstB;
1072
+ const xPos = A * Math.pow(Math.E, B * ang) * Math.cos(ang);
1073
+ const yPos = A * Math.pow(Math.E, B * ang) * Math.sin(ang);
1074
+ return [xPos, yPos, 1];
1075
+ },
1076
+ size: 3
1077
+ },
1078
+ {
1079
+ name: "aColor" /* COLOR */,
1080
+ data: () => randOpacityRgb(color),
1081
+ size: 3
1082
+ }
1083
+ ];
1084
+ return {
1085
+ attributes,
1086
+ multiplier,
1087
+ vertex: VERTEX_SHADER,
1088
+ fragment: FRAGMENT_SHADER
1089
+ };
1090
+ };
1091
+
1092
+ // src/loading-spiral/useCanvasRef.ts
1093
+ import { useEffect as useEffect3, useRef as useRef2 } from "react";
1094
+ var useResizedCanvasRef = () => {
1095
+ const canvasRef = useRef2(null);
1096
+ const containerRef = useRef2(null);
1097
+ useEffect3(() => {
1098
+ const canvas = canvasRef.current;
1099
+ const container = containerRef.current;
1100
+ if (!canvas || !container)
1101
+ return;
1102
+ const { width, height } = container.getBoundingClientRect();
1103
+ const canvasSize = Math.max(width, height);
1104
+ canvas.setAttribute("width", `${canvasSize}`);
1105
+ canvas.setAttribute("height", `${canvasSize}`);
1106
+ }, []);
1107
+ return {
1108
+ canvasRef,
1109
+ containerRef
1110
+ };
1111
+ };
1112
+
1113
+ // src/loading-spiral/LoadingSpiral.tsx
1114
+ var LoadingSpiral = (props) => {
1115
+ const { canvasRef, containerRef } = useResizedCanvasRef();
1116
+ const _a = props, { className, canvas, step } = _a, rest = __objRest(_a, ["className", "canvas", "step"]);
1117
+ useEffect4(() => {
1118
+ if (!canvasRef.current) {
1119
+ return;
1120
+ }
1121
+ const phenomenon = new Phenomenon({
1122
+ settings: createSettings({ canvas: canvasRef.current, step })
1123
+ });
1124
+ phenomenon.add("spiral", createOptions(Object.assign({}, DEFAULT_OPT, rest)));
1125
+ }, []);
1126
+ return /* @__PURE__ */ React21.createElement("div", {
1127
+ className: classNames7("fixed h-full w-full overflow-hidden flex justify-center items-center", className),
1128
+ ref: containerRef
1129
+ }, /* @__PURE__ */ React21.createElement("canvas", {
1130
+ ref: canvasRef
1131
+ }));
1132
+ };
983
1133
  export {
984
1134
  Article,
985
1135
  ArticleSkeleton,
@@ -997,6 +1147,7 @@ export {
997
1147
  LinkList,
998
1148
  LinkListSkeleton,
999
1149
  List,
1150
+ LoadingSpiral,
1000
1151
  Logo,
1001
1152
  Nav,
1002
1153
  NoiseCover,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/components",
3
- "version": "1.5.23",
3
+ "version": "1.5.26",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -33,8 +33,11 @@
33
33
  "access": "public"
34
34
  },
35
35
  "peerDependencies": {
36
+ "@tailwindcss/typography": "^0.5.0",
36
37
  "classnames": "^2.3.1",
37
- "react-router-dom": "5.3.0",
38
- "@tailwindcss/typography": "^0.5.0"
38
+ "react-router-dom": "5.3.0"
39
+ },
40
+ "dependencies": {
41
+ "phenomenon": "^1.6.0"
39
42
  }
40
43
  }