hds-web 1.25.4 → 1.25.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hds-web",
3
- "version": "1.25.4",
3
+ "version": "1.25.5",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -5,7 +5,7 @@ import { Icon } from '../common-components/Icon';
5
5
  import {Typography} from '../../foundation/Typography'
6
6
  import { HDSColor } from '../../foundation/ColorPalette';
7
7
  const sizeClasses = {
8
- sm: 'py-0.5 px-2 hds-d-body3c',
8
+ sm: 'py-0.5 px-3 hds-d-body3c',
9
9
  default: 'py-1 px-3',
10
10
  };
11
11
 
@@ -0,0 +1,36 @@
1
+ import React, { useState } from "react";
2
+
3
+ function LiveSearch({ wordArray }) {
4
+ const [input, setInput] = useState("");
5
+ const [filteredWords, setFilteredWords] = useState([]);
6
+
7
+ const handleInputChange = (event) => {
8
+ const inputValue = event.target.value.toLowerCase();
9
+ setInput(inputValue);
10
+
11
+ const newFilteredWords = searchWords(wordArray, inputValue);
12
+ setFilteredWords(newFilteredWords);
13
+ };
14
+
15
+ return (
16
+ <div>
17
+ <input
18
+ type="text"
19
+ placeholder="Search..."
20
+ value={input}
21
+ onChange={handleInputChange}
22
+ />
23
+ <div id="results">
24
+ {filteredWords.map((word, index) => (
25
+ <div key={index}>{word}</div>
26
+ ))}
27
+ </div>
28
+ </div>
29
+ );
30
+ }
31
+
32
+ function searchWords(words, inputLetter) {
33
+ return words.filter((word) => word.toLowerCase().includes(inputLetter));
34
+ }
35
+
36
+ export default LiveSearch;
@@ -0,0 +1,2 @@
1
+ export { default as HDSSearch } from './hdssearch';
2
+ export { default as TagFilter } from './invertedIndex';
@@ -0,0 +1,47 @@
1
+ function buildInvertedIndex(data) {
2
+ const invertedIndex = {};
3
+
4
+ for (const item of data) {
5
+ const key = Object.keys(item)[0];
6
+ const tags = item[key];
7
+
8
+ for (const tag of tags) {
9
+ if (!invertedIndex[tag]) {
10
+ invertedIndex[tag] = new Set();
11
+ }
12
+ invertedIndex[tag].add(key);
13
+ }
14
+ }
15
+
16
+ return invertedIndex;
17
+ }
18
+
19
+ export default function getSimilarAndRemainingKeys(data, inputKey) {
20
+ const invertedIndex = buildInvertedIndex(data);
21
+ const inputTags = data.find(item => item[inputKey]);
22
+ const similarKeys = new Set();
23
+ const allKeys = new Set();
24
+
25
+ if (inputTags) {
26
+ for (const tag of inputTags[inputKey]) {
27
+ const keysWithSimilarTag = invertedIndex[tag];
28
+ if (keysWithSimilarTag) {
29
+ keysWithSimilarTag.forEach(key => {
30
+ if (key !== inputKey) {
31
+ similarKeys.add(key);
32
+ }
33
+ });
34
+ }
35
+ }
36
+ }
37
+
38
+ for (const item of data) {
39
+ const key = Object.keys(item)[0];
40
+ allKeys.add(key);
41
+ }
42
+
43
+ const remainingKeys = [...allKeys].filter(key => !similarKeys.has(key));
44
+
45
+ return [...similarKeys, ...remainingKeys];
46
+ }
47
+
@@ -3,4 +3,5 @@ export * from './Media';
3
3
  export * from './Effects';
4
4
  export * from './AlgoliaSearch';
5
5
  export * from './Paperform';
6
- export * from './MarketoForm';
6
+ export * from './MarketoForm';
7
+ export * from './Algorithms';