squarified 0.3.3 → 0.3.6

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/README.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  `squarified` is a minimal and powerful treemap component.
4
4
 
5
- ![display](./data.gif)
5
+
6
+
7
+ https://github.com/user-attachments/assets/caf30d9d-0a5a-446a-b767-7927bf4387c9
8
+
9
+
6
10
 
7
11
  ## Install
8
12
 
@@ -0,0 +1,4 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ type Any = any
3
+
4
+ type AnyObject = Record<keyof Any, Any>
@@ -0,0 +1,4 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ type Any = any
3
+
4
+ type AnyObject = Record<keyof Any, Any>
package/dist/index.d.mts CHANGED
@@ -219,7 +219,6 @@ declare const defaultFontOptions: {
219
219
  };
220
220
  declare function presetDecorator(app: TreemapLayout): void;
221
221
 
222
- type AnyObject = Record<keyof Any, Any>;
223
222
  declare function sortChildrenByKey<T extends AnyObject, K extends keyof T = 'weight'>(data: T[], ...keys: K[]): T[];
224
223
  declare function c2m<T extends AnyObject & {
225
224
  groups: Any[];
package/dist/index.d.ts CHANGED
@@ -219,7 +219,6 @@ declare const defaultFontOptions: {
219
219
  };
220
220
  declare function presetDecorator(app: TreemapLayout): void;
221
221
 
222
- type AnyObject = Record<keyof Any, Any>;
223
222
  declare function sortChildrenByKey<T extends AnyObject, K extends keyof T = 'weight'>(data: T[], ...keys: K[]): T[];
224
223
  declare function c2m<T extends AnyObject & {
225
224
  groups: Any[];
package/dist/index.js CHANGED
@@ -874,7 +874,7 @@ function createEffectStop(c) {
874
874
  }
875
875
  };
876
876
  }
877
- function createEffectScope() {
877
+ function createSmoothFrame() {
878
878
  const c = {
879
879
  animationFrameID: null
880
880
  };
@@ -1024,8 +1024,8 @@ const INTERNAL_EVENT_MAPPINGS = {
1024
1024
  };
1025
1025
  const ANIMATION_DURATION = 300;
1026
1026
  const fill = { desc: { r: 255, g: 255, b: 255 }, mode: "rgb" };
1027
- function runEffect(callback, opts) {
1028
- const effect = createEffectScope();
1027
+ function smoothFrame(callback, opts) {
1028
+ const frame = createSmoothFrame();
1029
1029
  const startTime = Date.now();
1030
1030
  const condtion = (process) => {
1031
1031
  if (Array.isArray(opts.deps)) {
@@ -1033,17 +1033,17 @@ function runEffect(callback, opts) {
1033
1033
  }
1034
1034
  return process >= 1;
1035
1035
  };
1036
- effect.run(() => {
1036
+ frame.run(() => {
1037
1037
  const elapsed = Date.now() - startTime;
1038
1038
  const progress = Math.min(elapsed / opts.duration, 1);
1039
1039
  if (condtion(progress)) {
1040
- effect.stop();
1040
+ frame.stop();
1041
1041
  if (opts.onStop) {
1042
1042
  opts.onStop();
1043
1043
  }
1044
1044
  return true;
1045
1045
  }
1046
- return callback(progress, effect.stop);
1046
+ return callback(progress, frame.stop);
1047
1047
  });
1048
1048
  }
1049
1049
  const HIGH_LIGHT_OPACITY = 0.3;
@@ -1052,7 +1052,7 @@ function drawHighlight(treemap, evt) {
1052
1052
  const { currentNode } = evt.state;
1053
1053
  if (currentNode) {
1054
1054
  const [x, y, w, h] = currentNode.layout;
1055
- runEffect((_, cleanup) => {
1055
+ smoothFrame((_, cleanup) => {
1056
1056
  cleanup();
1057
1057
  highlight.reset();
1058
1058
  const mask = createRoundBlock(x, y, w, h, { fill, opacity: HIGH_LIGHT_OPACITY, radius: 4, padding: 2 });
@@ -1120,7 +1120,7 @@ class TreemapEvent extends DOMEvent {
1120
1120
  drawHighlight(ctx.treemap, this);
1121
1121
  } else {
1122
1122
  const { treemap } = ctx;
1123
- runEffect((_, cleanup) => {
1123
+ smoothFrame((_, cleanup) => {
1124
1124
  cleanup();
1125
1125
  const { offsetX: x, offsetY: y } = metadata.native;
1126
1126
  const { dragX: lastX, dragY: lastY } = this.state;
@@ -1191,13 +1191,11 @@ class TreemapEvent extends DOMEvent {
1191
1191
  const targetScaleRatio = this.matrix.a * delta;
1192
1192
  const translateX = offsetX - (offsetX - this.matrix.e) * delta;
1193
1193
  const translateY = offsetY - (offsetY - this.matrix.f) * delta;
1194
- runEffect((progress, cleanup) => {
1195
- this.silent("mousedown");
1194
+ smoothFrame((progress, cleanup) => {
1196
1195
  this.exposedEvent.silent("mousemove");
1197
1196
  this.silent("mousemove");
1198
1197
  this.silent("click");
1199
1198
  this.exposedEvent.silent("click");
1200
- cleanup();
1201
1199
  treemap.highlight.reset();
1202
1200
  treemap.highlight.setZIndexForHighlight();
1203
1201
  treemap.fontCache.flush(treemap, this.matrix);
@@ -1214,12 +1212,12 @@ class TreemapEvent extends DOMEvent {
1214
1212
  );
1215
1213
  stackMatrixTransformWithGraphAndLayer(treemap.elements, this.matrix.e, this.matrix.f, 1);
1216
1214
  treemap.update();
1215
+ cleanup();
1217
1216
  }, {
1218
1217
  duration: ANIMATION_DURATION,
1219
1218
  onStop: () => {
1220
1219
  this.state.forceDestroy = false;
1221
1220
  this.state.isWheeling = false;
1222
- this.active("mousedown");
1223
1221
  this.active("mousemove");
1224
1222
  this.exposedEvent.active("mousemove");
1225
1223
  this.active("click");
@@ -1256,7 +1254,7 @@ function createOnZoom(treemap, evt) {
1256
1254
  const targetScale = factor * evt.matrix.a;
1257
1255
  const translateX = boundingClientRect.width / 2 - (mx + mw / 2) * factor;
1258
1256
  const translateY = boundingClientRect.height / 2 - (my + mh / 2) * factor;
1259
- runEffect((progress, cleanup) => {
1257
+ smoothFrame((progress, cleanup) => {
1260
1258
  cleanup();
1261
1259
  evt.silent("mousemove");
1262
1260
  evt.exposedEvent.silent("mousemove");
@@ -1643,8 +1641,8 @@ function evaluateColorMappings(data) {
1643
1641
  const hash = Math.abs(hashCode(id));
1644
1642
  return hash % 360;
1645
1643
  };
1646
- const lightScale = (depth) => 60 - depth * 5;
1647
- const baseSaturation = 70;
1644
+ const lightScale = (depth) => 50 - depth * 5;
1645
+ const baseSaturation = 80;
1648
1646
  const siblingHueShift = 30;
1649
1647
  const rc = 0.2126;
1650
1648
  const gc = 0.7152;
@@ -1672,8 +1670,8 @@ function evaluateColorMappings(data) {
1672
1670
  const { r, g, b } = hslToRgb(hslColor.h, hslColor.s / 100, hslColor.l);
1673
1671
  const luminance = calculateLuminance(r, g, b);
1674
1672
  if (luminance < 0.6) {
1675
- hslColor.l += 0.15;
1676
- } else if (luminance > 0.65) {
1673
+ hslColor.l += 0.2;
1674
+ } else if (luminance > 0.8) {
1677
1675
  hslColor.l -= 0.1;
1678
1676
  }
1679
1677
  hslColor.l *= 100;
package/dist/index.mjs CHANGED
@@ -872,7 +872,7 @@ function createEffectStop(c) {
872
872
  }
873
873
  };
874
874
  }
875
- function createEffectScope() {
875
+ function createSmoothFrame() {
876
876
  const c = {
877
877
  animationFrameID: null
878
878
  };
@@ -1022,8 +1022,8 @@ const INTERNAL_EVENT_MAPPINGS = {
1022
1022
  };
1023
1023
  const ANIMATION_DURATION = 300;
1024
1024
  const fill = { desc: { r: 255, g: 255, b: 255 }, mode: "rgb" };
1025
- function runEffect(callback, opts) {
1026
- const effect = createEffectScope();
1025
+ function smoothFrame(callback, opts) {
1026
+ const frame = createSmoothFrame();
1027
1027
  const startTime = Date.now();
1028
1028
  const condtion = (process) => {
1029
1029
  if (Array.isArray(opts.deps)) {
@@ -1031,17 +1031,17 @@ function runEffect(callback, opts) {
1031
1031
  }
1032
1032
  return process >= 1;
1033
1033
  };
1034
- effect.run(() => {
1034
+ frame.run(() => {
1035
1035
  const elapsed = Date.now() - startTime;
1036
1036
  const progress = Math.min(elapsed / opts.duration, 1);
1037
1037
  if (condtion(progress)) {
1038
- effect.stop();
1038
+ frame.stop();
1039
1039
  if (opts.onStop) {
1040
1040
  opts.onStop();
1041
1041
  }
1042
1042
  return true;
1043
1043
  }
1044
- return callback(progress, effect.stop);
1044
+ return callback(progress, frame.stop);
1045
1045
  });
1046
1046
  }
1047
1047
  const HIGH_LIGHT_OPACITY = 0.3;
@@ -1050,7 +1050,7 @@ function drawHighlight(treemap, evt) {
1050
1050
  const { currentNode } = evt.state;
1051
1051
  if (currentNode) {
1052
1052
  const [x, y, w, h] = currentNode.layout;
1053
- runEffect((_, cleanup) => {
1053
+ smoothFrame((_, cleanup) => {
1054
1054
  cleanup();
1055
1055
  highlight.reset();
1056
1056
  const mask = createRoundBlock(x, y, w, h, { fill, opacity: HIGH_LIGHT_OPACITY, radius: 4, padding: 2 });
@@ -1118,7 +1118,7 @@ class TreemapEvent extends DOMEvent {
1118
1118
  drawHighlight(ctx.treemap, this);
1119
1119
  } else {
1120
1120
  const { treemap } = ctx;
1121
- runEffect((_, cleanup) => {
1121
+ smoothFrame((_, cleanup) => {
1122
1122
  cleanup();
1123
1123
  const { offsetX: x, offsetY: y } = metadata.native;
1124
1124
  const { dragX: lastX, dragY: lastY } = this.state;
@@ -1189,13 +1189,11 @@ class TreemapEvent extends DOMEvent {
1189
1189
  const targetScaleRatio = this.matrix.a * delta;
1190
1190
  const translateX = offsetX - (offsetX - this.matrix.e) * delta;
1191
1191
  const translateY = offsetY - (offsetY - this.matrix.f) * delta;
1192
- runEffect((progress, cleanup) => {
1193
- this.silent("mousedown");
1192
+ smoothFrame((progress, cleanup) => {
1194
1193
  this.exposedEvent.silent("mousemove");
1195
1194
  this.silent("mousemove");
1196
1195
  this.silent("click");
1197
1196
  this.exposedEvent.silent("click");
1198
- cleanup();
1199
1197
  treemap.highlight.reset();
1200
1198
  treemap.highlight.setZIndexForHighlight();
1201
1199
  treemap.fontCache.flush(treemap, this.matrix);
@@ -1212,12 +1210,12 @@ class TreemapEvent extends DOMEvent {
1212
1210
  );
1213
1211
  stackMatrixTransformWithGraphAndLayer(treemap.elements, this.matrix.e, this.matrix.f, 1);
1214
1212
  treemap.update();
1213
+ cleanup();
1215
1214
  }, {
1216
1215
  duration: ANIMATION_DURATION,
1217
1216
  onStop: () => {
1218
1217
  this.state.forceDestroy = false;
1219
1218
  this.state.isWheeling = false;
1220
- this.active("mousedown");
1221
1219
  this.active("mousemove");
1222
1220
  this.exposedEvent.active("mousemove");
1223
1221
  this.active("click");
@@ -1254,7 +1252,7 @@ function createOnZoom(treemap, evt) {
1254
1252
  const targetScale = factor * evt.matrix.a;
1255
1253
  const translateX = boundingClientRect.width / 2 - (mx + mw / 2) * factor;
1256
1254
  const translateY = boundingClientRect.height / 2 - (my + mh / 2) * factor;
1257
- runEffect((progress, cleanup) => {
1255
+ smoothFrame((progress, cleanup) => {
1258
1256
  cleanup();
1259
1257
  evt.silent("mousemove");
1260
1258
  evt.exposedEvent.silent("mousemove");
@@ -1641,8 +1639,8 @@ function evaluateColorMappings(data) {
1641
1639
  const hash = Math.abs(hashCode(id));
1642
1640
  return hash % 360;
1643
1641
  };
1644
- const lightScale = (depth) => 60 - depth * 5;
1645
- const baseSaturation = 70;
1642
+ const lightScale = (depth) => 50 - depth * 5;
1643
+ const baseSaturation = 80;
1646
1644
  const siblingHueShift = 30;
1647
1645
  const rc = 0.2126;
1648
1646
  const gc = 0.7152;
@@ -1670,8 +1668,8 @@ function evaluateColorMappings(data) {
1670
1668
  const { r, g, b } = hslToRgb(hslColor.h, hslColor.s / 100, hslColor.l);
1671
1669
  const luminance = calculateLuminance(r, g, b);
1672
1670
  if (luminance < 0.6) {
1673
- hslColor.l += 0.15;
1674
- } else if (luminance > 0.65) {
1671
+ hslColor.l += 0.2;
1672
+ } else if (luminance > 0.8) {
1675
1673
  hslColor.l -= 0.1;
1676
1674
  }
1677
1675
  hslColor.l *= 100;
package/package.json CHANGED
@@ -1,36 +1,42 @@
1
1
  {
2
2
  "name": "squarified",
3
- "version": "0.3.3",
3
+ "version": "0.3.6",
4
4
  "description": "squarified tree map",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "squarified/__source__": "./src/index.ts",
11
- "import": "./dist/index.mjs",
12
- "default": "./dist/index.js"
13
- }
14
- },
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": "./src/index.ts",
15
9
  "keywords": [
16
10
  "squarified",
17
11
  "tree-map"
18
12
  ],
13
+ "files": [
14
+ "dist",
15
+ "LICENSE",
16
+ "README.md"
17
+ ],
19
18
  "repository": {
20
19
  "type": "git",
21
20
  "url": "git+https://github.com/nonzzz/squarified.git"
22
21
  },
23
22
  "author": "Kanno",
24
23
  "license": "MIT",
25
- "typesVersions": {
26
- "<5.0": {
27
- "*": [
28
- "*",
29
- "./*",
30
- "./*/index.d.ts",
31
- "./*/index.d.mts",
32
- "./*/index.d.cts"
33
- ]
34
- }
24
+ "devDependencies": {
25
+ "@types/js-yaml": "^4.0.9",
26
+ "@types/markdown-it": "^14.1.2",
27
+ "@types/node": "^22.7.4",
28
+ "chokidar": "^4.0.3",
29
+ "dprint": "^0.47.2",
30
+ "esbuild": "^0.24.0",
31
+ "eslint": "^9.16.0",
32
+ "eslint-config-kagura": "^3.0.1",
33
+ "highlight.js": "^11.11.1",
34
+ "jiek": "^2.3.3",
35
+ "js-yaml": "^4.1.0",
36
+ "markdown-it": "^14.1.0",
37
+ "tinyexec": "^0.3.2",
38
+ "tsx": "^4.19.2",
39
+ "typescript": "^5.7.3",
40
+ "vite-bundle-analyzer": "^0.16.2"
35
41
  }
36
42
  }
File without changes