@teselagen/ui 0.4.11 → 0.4.14
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/Tag.d.ts +14 -0
- package/TagSelect/index.d.ts +6 -0
- package/index.cjs.js +146 -156
- package/index.es.js +146 -156
- package/package.json +1 -1
- package/src/DataTable/dataTableEnhancer.js +5 -1
- package/src/Tag.js +112 -0
- package/src/TagSelect/index.js +69 -0
- package/src/TagSelect/style.css +13 -0
- package/src/TgSelect/index.js +0 -16
- package/src/TgSelect/style.css +7 -0
- package/src/utils/menuUtils.js +3 -2
- package/style.css +7 -0
- package/utils/menuUtils.d.ts +7 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Button, InputGroup, Popover } from "@blueprintjs/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import Tag from "../Tag";
|
|
5
|
+
import "./style.css";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { itemListPredicate } from "../TgSelect";
|
|
8
|
+
|
|
9
|
+
export default ({ value = {}, options = [], onChange }) => {
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
12
|
+
|
|
13
|
+
const filteredOptions = itemListPredicate(searchTerm, options, false);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Popover
|
|
17
|
+
isOpen={open}
|
|
18
|
+
onInteraction={setOpen}
|
|
19
|
+
content={
|
|
20
|
+
<div className="tag-select-popover">
|
|
21
|
+
<InputGroup
|
|
22
|
+
rightElement={
|
|
23
|
+
// clear button
|
|
24
|
+
searchTerm ? (
|
|
25
|
+
<Button
|
|
26
|
+
icon="cross"
|
|
27
|
+
minimal
|
|
28
|
+
onClick={() => setSearchTerm("")}
|
|
29
|
+
/>
|
|
30
|
+
) : null
|
|
31
|
+
}
|
|
32
|
+
type="text"
|
|
33
|
+
placeholder="Search..."
|
|
34
|
+
autoFocus
|
|
35
|
+
value={searchTerm}
|
|
36
|
+
onChange={e => setSearchTerm(e.target.value)}
|
|
37
|
+
/>
|
|
38
|
+
<div className="tag-select-popover-inner">
|
|
39
|
+
{filteredOptions.map(option => {
|
|
40
|
+
return (
|
|
41
|
+
<Tag
|
|
42
|
+
key={option.name}
|
|
43
|
+
onClick={() => {
|
|
44
|
+
onChange(option);
|
|
45
|
+
setOpen(false);
|
|
46
|
+
}}
|
|
47
|
+
clickable
|
|
48
|
+
style={{ maxWidth: 150 }}
|
|
49
|
+
{...convertTagVals(option)}
|
|
50
|
+
doNotFillWidth
|
|
51
|
+
></Tag>
|
|
52
|
+
);
|
|
53
|
+
})}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
<Tag style={{ maxWidth: 150 }} clickable {...convertTagVals(value)}></Tag>
|
|
59
|
+
</Popover>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function convertTagVals(tagVals) {
|
|
64
|
+
return {
|
|
65
|
+
...tagVals,
|
|
66
|
+
|
|
67
|
+
name: tagVals.name || tagVals.label
|
|
68
|
+
};
|
|
69
|
+
}
|
package/src/TgSelect/index.js
CHANGED
|
@@ -403,22 +403,6 @@ class TgSelect extends React.Component {
|
|
|
403
403
|
{...rest}
|
|
404
404
|
/>
|
|
405
405
|
);
|
|
406
|
-
if (backgroundColor) {
|
|
407
|
-
return (
|
|
408
|
-
<div
|
|
409
|
-
style={{
|
|
410
|
-
backgroundColor: backgroundColor,
|
|
411
|
-
borderRadius: "4px 4px 4px 4px",
|
|
412
|
-
overflow: "hidden",
|
|
413
|
-
width: "fit-content",
|
|
414
|
-
color: "white",
|
|
415
|
-
border: "2px solid white"
|
|
416
|
-
}}
|
|
417
|
-
>
|
|
418
|
-
{toRet}
|
|
419
|
-
</div>
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
406
|
return toRet;
|
|
423
407
|
}
|
|
424
408
|
}
|
package/src/TgSelect/style.css
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
width: 100%;
|
|
3
3
|
min-width: 170px;
|
|
4
4
|
}
|
|
5
|
+
.tg-select.tg-select-as-tag {
|
|
6
|
+
/* background-color: red; */
|
|
7
|
+
border-radius: 4px;
|
|
8
|
+
width: fit-content;
|
|
9
|
+
color: white;
|
|
10
|
+
border: 2px solid white;
|
|
11
|
+
}
|
|
5
12
|
.tg-select.tg-select-as-tag .bp3-tag.bp3-minimal.bp3-intent-primary {
|
|
6
13
|
color: white !important;
|
|
7
14
|
}
|
package/src/utils/menuUtils.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import fuzzysearch from "fuzzysearch";
|
|
24
24
|
import classNames from "classnames";
|
|
25
25
|
// https://github.com/palantir/blueprint/issues/2820
|
|
26
|
-
function MenuItemLink({ text, onClick, icon, navTo, active }) {
|
|
26
|
+
export function MenuItemLink({ text, onClick, icon, navTo, active }) {
|
|
27
27
|
const handleLinkClick = e => {
|
|
28
28
|
e.target.closest(`.${Classes.POPOVER_DISMISS}`).click();
|
|
29
29
|
};
|
|
@@ -34,7 +34,8 @@ function MenuItemLink({ text, onClick, icon, navTo, active }) {
|
|
|
34
34
|
onClick={handleLinkClick}
|
|
35
35
|
to={navTo}
|
|
36
36
|
className={classNames(Classes.MENU_ITEM, {
|
|
37
|
-
[Classes.ACTIVE]: active
|
|
37
|
+
[Classes.ACTIVE]: active,
|
|
38
|
+
[Classes.INTENT_PRIMARY]: active
|
|
38
39
|
})}
|
|
39
40
|
>
|
|
40
41
|
{icon && <Icon icon={icon} />}
|
package/style.css
CHANGED
|
@@ -9086,6 +9086,13 @@ button:not(:disabled):active {
|
|
|
9086
9086
|
width: 100%;
|
|
9087
9087
|
min-width: 170px;
|
|
9088
9088
|
}
|
|
9089
|
+
.tg-select.tg-select-as-tag {
|
|
9090
|
+
/* background-color: red; */
|
|
9091
|
+
border-radius: 4px;
|
|
9092
|
+
width: fit-content;
|
|
9093
|
+
color: white;
|
|
9094
|
+
border: 2px solid white;
|
|
9095
|
+
}
|
|
9089
9096
|
.tg-select.tg-select-as-tag .bp3-tag.bp3-minimal.bp3-intent-primary {
|
|
9090
9097
|
color: white !important;
|
|
9091
9098
|
}
|
package/utils/menuUtils.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export function MenuItemLink({ text, onClick, icon, navTo, active }: {
|
|
2
|
+
text: any;
|
|
3
|
+
onClick: any;
|
|
4
|
+
icon: any;
|
|
5
|
+
navTo: any;
|
|
6
|
+
active: any;
|
|
7
|
+
}): import('../../../../node_modules/react/jsx-runtime').JSX.Element;
|
|
1
8
|
export function showCommandContextMenu(menuDef: any, commands: any, config: any, event: any, onClose: any, context: any): void;
|
|
2
9
|
export function showContextMenu(menuDef: any, enhancers: any, event: any, onClose: any, context: any, menuComp?: typeof Menu): void;
|
|
3
10
|
export function getStringFromReactComponent(comp: any): any;
|