@parca/profile 0.16.485 → 0.16.486

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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.16.486](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.485...@parca/profile@0.16.486) (2025-03-12)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
6
10
  ## [0.16.485](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.484...@parca/profile@0.16.485) (2025-03-05)
7
11
 
8
12
  **Note:** Version bump only for package @parca/profile
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/SimpleMatchers/Select.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAOzD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,UAAU,iBAAiB;IACzB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,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a,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8Q7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -14,6 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
14
14
  import { useEffect, useRef, useState } from 'react';
15
15
  import { Icon } from '@iconify/react';
16
16
  import cx from 'classnames';
17
+ import levenshtein from 'fast-levenshtein';
17
18
  import { Button, useParcaContext } from '@parca/components';
18
19
  const CustomSelect = ({ items, selectedKey, onSelection, placeholder = 'Select an item', width, className = '', loading, primary = false, disabled = false, icon, id, optionsClassname = '', searchable = false, onButtonClick, editable = false, }) => {
19
20
  const { loader } = useParcaContext();
@@ -25,10 +26,17 @@ const CustomSelect = ({ items, selectedKey, onSelection, placeholder = 'Select a
25
26
  const searchInputRef = useRef(null);
26
27
  const optionRefs = useRef([]);
27
28
  const filteredItems = searchable
28
- ? items.filter(item => item.element.active.props.children
29
+ ? items
30
+ .filter(item => item.element.active.props.children
29
31
  .toString()
30
32
  .toLowerCase()
31
33
  .includes(searchTerm.toLowerCase()))
34
+ .sort((a, b) => {
35
+ if (searchTerm === '') {
36
+ return a.key.localeCompare(b.key);
37
+ }
38
+ return levenshtein.get(a.key, searchTerm) - levenshtein.get(b.key, searchTerm);
39
+ })
32
40
  : items;
33
41
  const selection = editable ? selectedKey : items.find(v => v.key === selectedKey);
34
42
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.485",
3
+ "version": "0.16.486",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@headlessui/react": "^1.7.19",
@@ -22,6 +22,7 @@
22
22
  "@types/d3": "^7.4.3",
23
23
  "@types/d3-scale": "^4.0.8",
24
24
  "@types/d3-selection": "^3.0.10",
25
+ "@types/fast-levenshtein": "^0.0.4",
25
26
  "@types/react-beautiful-dnd": "^13.1.8",
26
27
  "apache-arrow": "^12.0.1",
27
28
  "classnames": "^2.3.1",
@@ -33,6 +34,7 @@
33
34
  "d3-selection": "3.0.0",
34
35
  "d3-shape": "^3.2.0",
35
36
  "fast-deep-equal": "^3.1.3",
37
+ "fast-levenshtein": "^3.0.0",
36
38
  "framer-motion": "6.5.1",
37
39
  "graphviz-wasm": "3.0.2",
38
40
  "lodash.throttle": "^4.1.1",
@@ -75,5 +77,5 @@
75
77
  "access": "public",
76
78
  "registry": "https://registry.npmjs.org/"
77
79
  },
78
- "gitHead": "a873f929f4e16cb2c0e12f2321f4b429b617f20e"
80
+ "gitHead": "f970fa2046e730608d9591d04d39f17ed714aa54"
79
81
  }
@@ -15,6 +15,7 @@ import React, {useEffect, useRef, useState} from 'react';
15
15
 
16
16
  import {Icon} from '@iconify/react';
17
17
  import cx from 'classnames';
18
+ import levenshtein from 'fast-levenshtein';
18
19
 
19
20
  import {Button, useParcaContext} from '@parca/components';
20
21
 
@@ -74,12 +75,19 @@ const CustomSelect: React.FC<CustomSelectProps> = ({
74
75
  const optionRefs = useRef<Array<HTMLElement | null>>([]);
75
76
 
76
77
  const filteredItems = searchable
77
- ? items.filter(item =>
78
- item.element.active.props.children
79
- .toString()
80
- .toLowerCase()
81
- .includes(searchTerm.toLowerCase())
82
- )
78
+ ? items
79
+ .filter(item =>
80
+ item.element.active.props.children
81
+ .toString()
82
+ .toLowerCase()
83
+ .includes(searchTerm.toLowerCase())
84
+ )
85
+ .sort((a, b) => {
86
+ if (searchTerm === '') {
87
+ return a.key.localeCompare(b.key);
88
+ }
89
+ return levenshtein.get(a.key, searchTerm) - levenshtein.get(b.key, searchTerm);
90
+ })
83
91
  : items;
84
92
 
85
93
  const selection = editable ? selectedKey : items.find(v => v.key === selectedKey);