@bbki.ng/components 1.5.49 → 1.5.52

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
@@ -1070,7 +1070,7 @@ var import_react23 = __toESM(require("react"));
1070
1070
 
1071
1071
  // src/loading-spiral/createSettings.ts
1072
1072
  var createSettings = (settings) => {
1073
- const { canvas, step = 0.1 } = settings;
1073
+ const { canvas, step = 0.09 } = settings;
1074
1074
  const uniforms = {
1075
1075
  uProgress: {
1076
1076
  type: "float",
@@ -1079,6 +1079,7 @@ var createSettings = (settings) => {
1079
1079
  };
1080
1080
  return {
1081
1081
  uniforms,
1082
+ devicePixelRatio: window.devicePixelRatio,
1082
1083
  shouldRender: true,
1083
1084
  canvas,
1084
1085
  onRender: (r) => {
@@ -1090,14 +1091,37 @@ var createSettings = (settings) => {
1090
1091
 
1091
1092
  // src/loading-spiral/constants.ts
1092
1093
  var VERTEX_SHADER = `
1093
- attribute vec3 ${"aPositionStart" /* POSITION_START */};
1094
1094
  attribute vec3 ${"aColor" /* COLOR */};
1095
1095
  attribute float ${"aOffsetY" /* OFFSET_Y */};
1096
+ attribute float ${"aPercent" /* PERCENT */};
1097
+ attribute float ${"aLength" /* LENGTH */};
1098
+
1096
1099
  uniform mat4 uProjectionMatrix;
1097
1100
  uniform mat4 uModelMatrix;
1098
1101
  uniform mat4 uViewMatrix;
1099
1102
  uniform float uProgress;
1103
+
1100
1104
  varying vec3 vColor;
1105
+
1106
+ vec3 curve(float _percent, float _length) {
1107
+ const float PI2 = 3.141592653589793 * 2.0;
1108
+ float radius = 0.028 / 0.15 * _length;
1109
+
1110
+ float t = mod(_percent, 0.25) / 0.25;
1111
+ t = mod(_percent, 0.25) - (2.0 * (1.0 - t) * t * -0.0185 + t * t * 0.25);
1112
+ float x = _length * sin(PI2 * _percent);
1113
+ float y = radius * cos(PI2 * 3.0 * _percent);
1114
+
1115
+ if (
1116
+ floor(_percent / 0.25) == 0.0
1117
+ || floor(_percent / 0.25) == 2.0
1118
+ ) {
1119
+ t = t * -1.0;
1120
+ }
1121
+ float z = radius * sin(PI2 * 2.0 * (_percent - t));
1122
+ return vec3(x, y, z);
1123
+ }
1124
+
1101
1125
  mat4 rotateX(float _angle){
1102
1126
  return mat4(
1103
1127
  1.0, 0.0, 0.0, 0.0,
@@ -1106,22 +1130,7 @@ var VERTEX_SHADER = `
1106
1130
  0.0, 0.0, 0.0, 1.0
1107
1131
  );
1108
1132
  }
1109
- mat4 rotateY(float _angle){
1110
- return mat4(
1111
- cos(_angle), 0.0, sin(_angle), 0.0,
1112
- 0.0, 1.0, 0.0, 0.0,
1113
- -sin(_angle), 0.0, cos(_angle), 0.0,
1114
- 0.0, 0.0, 0.0, 1.0
1115
- );
1116
- }
1117
- mat4 rotateZ(float _angle){
1118
- return mat4(
1119
- cos(_angle), -sin(_angle), 0.0, 0.0,
1120
- sin(_angle), cos(_angle), 0.0, 0.0,
1121
- 0.0, 0.0, 1.0, 0.0,
1122
- 0.0, 0.0, 0.0, 1.0
1123
- );
1124
- }
1133
+
1125
1134
  mat4 translateY(float _offset){
1126
1135
  return mat4(
1127
1136
  1.0, 0.0, 0.0, 0.0,
@@ -1130,16 +1139,22 @@ var VERTEX_SHADER = `
1130
1139
  0.0, 0.0, 0.0, 1.0
1131
1140
  );
1132
1141
  }
1142
+
1133
1143
  void main(){
1134
- gl_Position = uProjectionMatrix * uModelMatrix * uViewMatrix * rotateX(uProgress) * vec4(${"aPositionStart" /* POSITION_START */}, 1.0) * translateY(${"aOffsetY" /* OFFSET_Y */});
1135
- gl_PointSize = 1.0;
1144
+ gl_Position = uProjectionMatrix
1145
+ * uModelMatrix
1146
+ * uViewMatrix
1147
+ * rotateX(uProgress)
1148
+ * vec4(curve(${"aPercent" /* PERCENT */}, ${"aLength" /* LENGTH */}), 1.0)
1149
+ * translateY(${"aOffsetY" /* OFFSET_Y */});
1150
+
1151
+ gl_PointSize = 2.0;
1136
1152
  vColor = ${"aColor" /* COLOR */};
1137
1153
  }
1138
1154
  `;
1139
1155
  var FRAGMENT_SHADER = `
1140
1156
  precision mediump float;
1141
1157
  uniform float uProgress;
1142
-
1143
1158
  varying vec3 vColor;
1144
1159
  void main(){
1145
1160
  gl_FragColor = vec4(vColor, 1.0);
@@ -1154,30 +1169,23 @@ var rgba = (val) => {
1154
1169
 
1155
1170
  // src/loading-spiral/createOptions.ts
1156
1171
  var DEFAULT_OPT = {
1157
- multiplier: 5e4,
1172
+ multiplier: 5e3,
1158
1173
  color: [209, 213, 219, 1],
1159
1174
  offset: -0.3,
1160
- length: 0.15
1175
+ length: 0.3
1161
1176
  };
1162
1177
  var createOptions = (opt = DEFAULT_OPT) => {
1163
1178
  const { multiplier, color, length, offset = -1 * 0.3 } = opt;
1164
- const radius = 0.028 / 0.15 * length;
1165
1179
  const attributes = [
1166
1180
  {
1167
- name: "aPositionStart" /* POSITION_START */,
1168
- data: (index, total) => {
1169
- const percent = index / total;
1170
- const pi2 = Math.PI * 2;
1171
- let x = length * Math.sin(pi2 * percent), y = radius * Math.cos(pi2 * 3 * percent), z, t;
1172
- t = percent % 0.25 / 0.25;
1173
- t = percent % 0.25 - (2 * (1 - t) * t * -0.0185 + t * t * 0.25);
1174
- if (Math.floor(percent / 0.25) == 0 || Math.floor(percent / 0.25) == 2) {
1175
- t *= -1;
1176
- }
1177
- z = radius * Math.sin(pi2 * 2 * (percent - t));
1178
- return [x, y, z];
1179
- },
1180
- size: 3
1181
+ name: "aPercent" /* PERCENT */,
1182
+ data: (i, total) => [i / total],
1183
+ size: 1
1184
+ },
1185
+ {
1186
+ name: "aLength" /* LENGTH */,
1187
+ data: () => [length],
1188
+ size: 1
1181
1189
  },
1182
1190
  {
1183
1191
  name: "aColor" /* COLOR */,
@@ -1209,7 +1217,7 @@ var useResizedCanvasRef = (maxSize) => {
1209
1217
  if (!canvas || !container)
1210
1218
  return;
1211
1219
  const { width, height } = container.getBoundingClientRect();
1212
- const canvasSize = Math.max(width, height);
1220
+ const canvasSize = Math.min(width, height);
1213
1221
  const size = Math.min(canvasSize, maxSize);
1214
1222
  canvas.setAttribute("width", `${size}`);
1215
1223
  canvas.setAttribute("height", `${size}`);
@@ -1231,19 +1239,15 @@ var LoadingSpiral = (props) => {
1231
1239
  const phenomenon = new import_phenomenon.default({
1232
1240
  settings: createSettings({ canvas: canvasRef.current, step }),
1233
1241
  context: {
1234
- alpha: true,
1235
1242
  antialias: true
1236
1243
  }
1237
1244
  });
1238
1245
  phenomenon.add("spiral", createOptions(Object.assign({}, DEFAULT_OPT, rest)));
1239
1246
  }, []);
1240
- return /* @__PURE__ */ import_react23.default.createElement("div", {
1241
- className: (0, import_classnames13.default)("h-full w-full overflow-hidden flex justify-center items-center", className),
1242
- ref: containerRef
1243
- }, /* @__PURE__ */ import_react23.default.createElement("canvas", {
1247
+ return /* @__PURE__ */ import_react23.default.createElement("canvas", {
1244
1248
  ref: canvasRef,
1245
- className: "relative"
1246
- }));
1249
+ className: (0, import_classnames13.default)("h-full w-full overflow-hidden flex justify-center items-center", className)
1250
+ });
1247
1251
  };
1248
1252
  module.exports = __toCommonJS(src_exports);
1249
1253
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -1011,7 +1011,7 @@ import React21, { useEffect as useEffect4 } from "react";
1011
1011
 
1012
1012
  // src/loading-spiral/createSettings.ts
1013
1013
  var createSettings = (settings) => {
1014
- const { canvas, step = 0.1 } = settings;
1014
+ const { canvas, step = 0.09 } = settings;
1015
1015
  const uniforms = {
1016
1016
  uProgress: {
1017
1017
  type: "float",
@@ -1020,6 +1020,7 @@ var createSettings = (settings) => {
1020
1020
  };
1021
1021
  return {
1022
1022
  uniforms,
1023
+ devicePixelRatio: window.devicePixelRatio,
1023
1024
  shouldRender: true,
1024
1025
  canvas,
1025
1026
  onRender: (r) => {
@@ -1031,14 +1032,37 @@ var createSettings = (settings) => {
1031
1032
 
1032
1033
  // src/loading-spiral/constants.ts
1033
1034
  var VERTEX_SHADER = `
1034
- attribute vec3 ${"aPositionStart" /* POSITION_START */};
1035
1035
  attribute vec3 ${"aColor" /* COLOR */};
1036
1036
  attribute float ${"aOffsetY" /* OFFSET_Y */};
1037
+ attribute float ${"aPercent" /* PERCENT */};
1038
+ attribute float ${"aLength" /* LENGTH */};
1039
+
1037
1040
  uniform mat4 uProjectionMatrix;
1038
1041
  uniform mat4 uModelMatrix;
1039
1042
  uniform mat4 uViewMatrix;
1040
1043
  uniform float uProgress;
1044
+
1041
1045
  varying vec3 vColor;
1046
+
1047
+ vec3 curve(float _percent, float _length) {
1048
+ const float PI2 = 3.141592653589793 * 2.0;
1049
+ float radius = 0.028 / 0.15 * _length;
1050
+
1051
+ float t = mod(_percent, 0.25) / 0.25;
1052
+ t = mod(_percent, 0.25) - (2.0 * (1.0 - t) * t * -0.0185 + t * t * 0.25);
1053
+ float x = _length * sin(PI2 * _percent);
1054
+ float y = radius * cos(PI2 * 3.0 * _percent);
1055
+
1056
+ if (
1057
+ floor(_percent / 0.25) == 0.0
1058
+ || floor(_percent / 0.25) == 2.0
1059
+ ) {
1060
+ t = t * -1.0;
1061
+ }
1062
+ float z = radius * sin(PI2 * 2.0 * (_percent - t));
1063
+ return vec3(x, y, z);
1064
+ }
1065
+
1042
1066
  mat4 rotateX(float _angle){
1043
1067
  return mat4(
1044
1068
  1.0, 0.0, 0.0, 0.0,
@@ -1047,22 +1071,7 @@ var VERTEX_SHADER = `
1047
1071
  0.0, 0.0, 0.0, 1.0
1048
1072
  );
1049
1073
  }
1050
- mat4 rotateY(float _angle){
1051
- return mat4(
1052
- cos(_angle), 0.0, sin(_angle), 0.0,
1053
- 0.0, 1.0, 0.0, 0.0,
1054
- -sin(_angle), 0.0, cos(_angle), 0.0,
1055
- 0.0, 0.0, 0.0, 1.0
1056
- );
1057
- }
1058
- mat4 rotateZ(float _angle){
1059
- return mat4(
1060
- cos(_angle), -sin(_angle), 0.0, 0.0,
1061
- sin(_angle), cos(_angle), 0.0, 0.0,
1062
- 0.0, 0.0, 1.0, 0.0,
1063
- 0.0, 0.0, 0.0, 1.0
1064
- );
1065
- }
1074
+
1066
1075
  mat4 translateY(float _offset){
1067
1076
  return mat4(
1068
1077
  1.0, 0.0, 0.0, 0.0,
@@ -1071,16 +1080,22 @@ var VERTEX_SHADER = `
1071
1080
  0.0, 0.0, 0.0, 1.0
1072
1081
  );
1073
1082
  }
1083
+
1074
1084
  void main(){
1075
- gl_Position = uProjectionMatrix * uModelMatrix * uViewMatrix * rotateX(uProgress) * vec4(${"aPositionStart" /* POSITION_START */}, 1.0) * translateY(${"aOffsetY" /* OFFSET_Y */});
1076
- gl_PointSize = 1.0;
1085
+ gl_Position = uProjectionMatrix
1086
+ * uModelMatrix
1087
+ * uViewMatrix
1088
+ * rotateX(uProgress)
1089
+ * vec4(curve(${"aPercent" /* PERCENT */}, ${"aLength" /* LENGTH */}), 1.0)
1090
+ * translateY(${"aOffsetY" /* OFFSET_Y */});
1091
+
1092
+ gl_PointSize = 2.0;
1077
1093
  vColor = ${"aColor" /* COLOR */};
1078
1094
  }
1079
1095
  `;
1080
1096
  var FRAGMENT_SHADER = `
1081
1097
  precision mediump float;
1082
1098
  uniform float uProgress;
1083
-
1084
1099
  varying vec3 vColor;
1085
1100
  void main(){
1086
1101
  gl_FragColor = vec4(vColor, 1.0);
@@ -1095,30 +1110,23 @@ var rgba = (val) => {
1095
1110
 
1096
1111
  // src/loading-spiral/createOptions.ts
1097
1112
  var DEFAULT_OPT = {
1098
- multiplier: 5e4,
1113
+ multiplier: 5e3,
1099
1114
  color: [209, 213, 219, 1],
1100
1115
  offset: -0.3,
1101
- length: 0.15
1116
+ length: 0.3
1102
1117
  };
1103
1118
  var createOptions = (opt = DEFAULT_OPT) => {
1104
1119
  const { multiplier, color, length, offset = -1 * 0.3 } = opt;
1105
- const radius = 0.028 / 0.15 * length;
1106
1120
  const attributes = [
1107
1121
  {
1108
- name: "aPositionStart" /* POSITION_START */,
1109
- data: (index, total) => {
1110
- const percent = index / total;
1111
- const pi2 = Math.PI * 2;
1112
- let x = length * Math.sin(pi2 * percent), y = radius * Math.cos(pi2 * 3 * percent), z, t;
1113
- t = percent % 0.25 / 0.25;
1114
- t = percent % 0.25 - (2 * (1 - t) * t * -0.0185 + t * t * 0.25);
1115
- if (Math.floor(percent / 0.25) == 0 || Math.floor(percent / 0.25) == 2) {
1116
- t *= -1;
1117
- }
1118
- z = radius * Math.sin(pi2 * 2 * (percent - t));
1119
- return [x, y, z];
1120
- },
1121
- size: 3
1122
+ name: "aPercent" /* PERCENT */,
1123
+ data: (i, total) => [i / total],
1124
+ size: 1
1125
+ },
1126
+ {
1127
+ name: "aLength" /* LENGTH */,
1128
+ data: () => [length],
1129
+ size: 1
1122
1130
  },
1123
1131
  {
1124
1132
  name: "aColor" /* COLOR */,
@@ -1150,7 +1158,7 @@ var useResizedCanvasRef = (maxSize) => {
1150
1158
  if (!canvas || !container)
1151
1159
  return;
1152
1160
  const { width, height } = container.getBoundingClientRect();
1153
- const canvasSize = Math.max(width, height);
1161
+ const canvasSize = Math.min(width, height);
1154
1162
  const size = Math.min(canvasSize, maxSize);
1155
1163
  canvas.setAttribute("width", `${size}`);
1156
1164
  canvas.setAttribute("height", `${size}`);
@@ -1172,19 +1180,15 @@ var LoadingSpiral = (props) => {
1172
1180
  const phenomenon = new Phenomenon({
1173
1181
  settings: createSettings({ canvas: canvasRef.current, step }),
1174
1182
  context: {
1175
- alpha: true,
1176
1183
  antialias: true
1177
1184
  }
1178
1185
  });
1179
1186
  phenomenon.add("spiral", createOptions(Object.assign({}, DEFAULT_OPT, rest)));
1180
1187
  }, []);
1181
- return /* @__PURE__ */ React21.createElement("div", {
1182
- className: classNames7("h-full w-full overflow-hidden flex justify-center items-center", className),
1183
- ref: containerRef
1184
- }, /* @__PURE__ */ React21.createElement("canvas", {
1188
+ return /* @__PURE__ */ React21.createElement("canvas", {
1185
1189
  ref: canvasRef,
1186
- className: "relative"
1187
- }));
1190
+ className: classNames7("h-full w-full overflow-hidden flex justify-center items-center", className)
1191
+ });
1188
1192
  };
1189
1193
  export {
1190
1194
  Article,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/components",
3
- "version": "1.5.49",
3
+ "version": "1.5.52",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",