@omnsight/osint-entity-components 0.1.2 → 0.1.4

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
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.2",
6
+ "version": "0.1.4",
7
7
  "engines": {
8
8
  "node": ">=24.0.0"
9
9
  },
@@ -4,16 +4,45 @@ import { Group, Select, ColorInput } from "@mantine/core";
4
4
  import { ICON_OPTIONS } from "./icons";
5
5
  import { EventIcon } from "./Icon";
6
6
 
7
- interface EventIconSelectProps {
8
- value: Event;
9
- onChange: (value: Event) => void;
7
+ interface EventIconSelectorProps {
8
+ data: Event;
9
+ value?: string | null;
10
+ onChange: (value: string | null) => void;
10
11
  }
11
12
 
12
- export const EventIconSelect: React.FC<EventIconSelectProps> = ({
13
+ export const EventIconSelector: React.FC<EventIconSelectorProps> = ({
14
+ data,
13
15
  value,
14
16
  onChange,
15
17
  }) => {
16
18
  const { t } = useTranslation();
19
+
20
+ const translatedOptions = ICON_OPTIONS.map((option) => ({
21
+ ...option,
22
+ label: t(`event.type.${option.label}`),
23
+ }));
24
+
25
+ return (
26
+ <Select
27
+ leftSection={<EventIcon event={data} />}
28
+ defaultValue={translatedOptions[0].value}
29
+ value={value}
30
+ onChange={onChange}
31
+ data={translatedOptions}
32
+ style={{ flex: 1 }}
33
+ />
34
+ );
35
+ };
36
+
37
+ interface EventColorSelectorProps {
38
+ value?: string | null;
39
+ onChange: (value: string | null) => void;
40
+ }
41
+
42
+ export const EventColorSelector: React.FC<EventColorSelectorProps> = ({
43
+ value,
44
+ onChange,
45
+ }) => {
17
46
  const colors = [
18
47
  "#0089ff",
19
48
  "#ff0000",
@@ -24,37 +53,46 @@ export const EventIconSelect: React.FC<EventIconSelectProps> = ({
24
53
  "#7950f2",
25
54
  ];
26
55
 
56
+ return (
57
+ <ColorInput
58
+ value={value || colors[0]}
59
+ onChange={onChange}
60
+ swatches={colors}
61
+ style={{ flex: 1 }}
62
+ />
63
+ );
64
+ };
65
+
66
+ interface EventIconSelectProps {
67
+ value: Event;
68
+ onChange: (value: Event) => void;
69
+ }
70
+
71
+ export const EventIconSelect: React.FC<EventIconSelectProps> = ({
72
+ value,
73
+ onChange,
74
+ }) => {
27
75
  const handleTypeChange = (type: string | null) => {
28
76
  onChange({ ...value, type: type || undefined });
29
77
  };
30
78
 
31
- const handleColorChange = (color: string) => {
79
+ const handleColorChange = (color: string | null) => {
32
80
  onChange({
33
81
  ...value,
34
82
  attributes: { ...(value.attributes || {}), icon_color: color },
35
83
  });
36
84
  };
37
85
 
38
- const translatedOptions = ICON_OPTIONS.map((option) => ({
39
- ...option,
40
- label: t(`event.type.${option.label}`),
41
- }));
42
-
43
86
  return (
44
87
  <Group>
45
- <Select
46
- leftSection={<EventIcon event={value} />}
47
- defaultValue={translatedOptions[0].value}
88
+ <EventIconSelector
89
+ data={value}
48
90
  value={value.type}
49
91
  onChange={handleTypeChange}
50
- data={translatedOptions}
51
- style={{ flex: 1 }}
52
92
  />
53
- <ColorInput
54
- value={String((value.attributes || {}).icon_color || colors[0])}
93
+ <EventColorSelector
94
+ value={String(value.attributes?.icon_color)}
55
95
  onChange={handleColorChange}
56
- swatches={colors}
57
- style={{ flex: 1 }}
58
96
  />
59
97
  </Group>
60
98
  );
@@ -4,16 +4,42 @@ import { Group, Select, ColorInput } from "@mantine/core";
4
4
  import { ICON_OPTIONS } from "./icons";
5
5
  import { OrganizationIcon } from "./Icon";
6
6
 
7
- interface OrganizationIconSelectProps {
8
- value: Organization;
9
- onChange: (value: Organization) => void;
7
+ interface OrganizationIconSelectorProps {
8
+ data: Organization;
9
+ value?: string | null;
10
+ onChange: (value: string | null) => void;
10
11
  }
11
12
 
12
- export const OrganizationIconSelect: React.FC<OrganizationIconSelectProps> = ({
13
- value,
14
- onChange,
15
- }) => {
13
+ export const OrganizationIconSelector: React.FC<
14
+ OrganizationIconSelectorProps
15
+ > = ({ data, value, onChange }) => {
16
16
  const { t } = useTranslation();
17
+
18
+ const translatedOptions = ICON_OPTIONS.map((option) => ({
19
+ ...option,
20
+ label: t(`organization.type.${option.label}`),
21
+ }));
22
+
23
+ return (
24
+ <Select
25
+ leftSection={<OrganizationIcon organization={data} />}
26
+ defaultValue={translatedOptions[0].value}
27
+ value={value}
28
+ onChange={onChange}
29
+ data={translatedOptions}
30
+ style={{ flex: 1 }}
31
+ />
32
+ );
33
+ };
34
+
35
+ interface OrganizationColorSelectorProps {
36
+ value?: string | null;
37
+ onChange: (value: string | null) => void;
38
+ }
39
+
40
+ export const OrganizationColorSelector: React.FC<
41
+ OrganizationColorSelectorProps
42
+ > = ({ value, onChange }) => {
17
43
  const colors = [
18
44
  "#0089ff",
19
45
  "#ff0000",
@@ -24,37 +50,46 @@ export const OrganizationIconSelect: React.FC<OrganizationIconSelectProps> = ({
24
50
  "#7950f2",
25
51
  ];
26
52
 
53
+ return (
54
+ <ColorInput
55
+ value={value || colors[0]}
56
+ onChange={onChange}
57
+ swatches={colors}
58
+ style={{ flex: 1 }}
59
+ />
60
+ );
61
+ };
62
+
63
+ interface OrganizationIconSelectProps {
64
+ value: Organization;
65
+ onChange: (value: Organization) => void;
66
+ }
67
+
68
+ export const OrganizationIconSelect: React.FC<OrganizationIconSelectProps> = ({
69
+ value,
70
+ onChange,
71
+ }) => {
27
72
  const handleTypeChange = (type: string | null) => {
28
73
  onChange({ ...value, type: type || undefined });
29
74
  };
30
75
 
31
- const handleColorChange = (color: string) => {
76
+ const handleColorChange = (color: string | null) => {
32
77
  onChange({
33
78
  ...value,
34
79
  attributes: { ...(value.attributes || {}), icon_color: color },
35
80
  });
36
81
  };
37
82
 
38
- const translatedOptions = ICON_OPTIONS.map((option) => ({
39
- ...option,
40
- label: t(`organization.type.${option.label}`),
41
- }));
42
-
43
83
  return (
44
84
  <Group>
45
- <Select
46
- leftSection={<OrganizationIcon organization={value} />}
47
- defaultValue={translatedOptions[0].value}
85
+ <OrganizationIconSelector
86
+ data={value}
48
87
  value={value.type}
49
88
  onChange={handleTypeChange}
50
- data={translatedOptions}
51
- style={{ flex: 1 }}
52
89
  />
53
- <ColorInput
54
- value={String((value.attributes || {}).icon_color || colors[0])}
90
+ <OrganizationColorSelector
91
+ value={String(value.attributes?.icon_color)}
55
92
  onChange={handleColorChange}
56
- swatches={colors}
57
- style={{ flex: 1 }}
58
93
  />
59
94
  </Group>
60
95
  );
@@ -4,13 +4,45 @@ import { Group, Select, ColorInput } from '@mantine/core';
4
4
  import { ICON_OPTIONS } from './icons';
5
5
  import { PersonIcon } from './Icon';
6
6
 
7
- interface PersonIconSelectProps {
8
- value: Person;
9
- onChange: (value: Person) => void;
7
+ interface PersonIconSelectorProps {
8
+ data: Person;
9
+ value?: string | null;
10
+ onChange: (value: string | null) => void;
10
11
  }
11
12
 
12
- export const PersonIconSelect: React.FC<PersonIconSelectProps> = ({ value, onChange }) => {
13
+ export const PersonIconSelector: React.FC<PersonIconSelectorProps> = ({
14
+ data,
15
+ value,
16
+ onChange,
17
+ }) => {
13
18
  const { t } = useTranslation();
19
+
20
+ const translatedOptions = ICON_OPTIONS.map((option) => ({
21
+ ...option,
22
+ label: t(`person.type.${option.label}`),
23
+ }));
24
+
25
+ return (
26
+ <Select
27
+ leftSection={<PersonIcon person={data} />}
28
+ defaultValue={translatedOptions[0].value}
29
+ value={value}
30
+ onChange={onChange}
31
+ data={translatedOptions}
32
+ style={{ flex: 1 }}
33
+ />
34
+ );
35
+ };
36
+
37
+ interface PersonColorSelectorProps {
38
+ value?: string | null;
39
+ onChange: (value: string | null) => void;
40
+ }
41
+
42
+ export const PersonColorSelector: React.FC<PersonColorSelectorProps> = ({
43
+ value,
44
+ onChange,
45
+ }) => {
14
46
  const colors = [
15
47
  "#0089ff",
16
48
  "#ff0000",
@@ -21,34 +53,46 @@ export const PersonIconSelect: React.FC<PersonIconSelectProps> = ({ value, onCha
21
53
  "#7950f2",
22
54
  ];
23
55
 
56
+ return (
57
+ <ColorInput
58
+ value={value || colors[0]}
59
+ onChange={onChange}
60
+ swatches={colors}
61
+ style={{ flex: 1 }}
62
+ />
63
+ );
64
+ };
65
+
66
+ interface PersonIconSelectProps {
67
+ value: Person;
68
+ onChange: (value: Person) => void;
69
+ }
70
+
71
+ export const PersonIconSelect: React.FC<PersonIconSelectProps> = ({
72
+ value,
73
+ onChange,
74
+ }) => {
24
75
  const handleTypeChange = (type: string | null) => {
25
76
  onChange({ ...value, type: type || undefined });
26
77
  };
27
78
 
28
- const handleColorChange = (color: string) => {
29
- onChange({ ...value, attributes: { ...(value.attributes || {}), icon_color: color } });
79
+ const handleColorChange = (color: string | null) => {
80
+ onChange({
81
+ ...value,
82
+ attributes: { ...(value.attributes || {}), icon_color: color },
83
+ });
30
84
  };
31
85
 
32
- const translatedOptions = ICON_OPTIONS.map((option) => ({
33
- ...option,
34
- label: t(`person.type.${option.label}`),
35
- }));
36
-
37
86
  return (
38
87
  <Group>
39
- <Select
40
- leftSection={<PersonIcon person={value} />}
41
- defaultValue={translatedOptions[0].value}
88
+ <PersonIconSelector
89
+ data={value}
42
90
  value={value.type}
43
91
  onChange={handleTypeChange}
44
- data={translatedOptions}
45
- style={{ flex: 1 }}
46
92
  />
47
- <ColorInput
48
- value={String((value.attributes || {}).icon_color || colors[0])}
93
+ <PersonColorSelector
94
+ value={String(value.attributes?.icon_color)}
49
95
  onChange={handleColorChange}
50
- swatches={colors}
51
- style={{ flex: 1 }}
52
96
  />
53
97
  </Group>
54
98
  );
@@ -4,16 +4,45 @@ import { Group, Select, ColorInput } from "@mantine/core";
4
4
  import { ICON_OPTIONS } from "./icons";
5
5
  import { SourceIcon } from "./Icon";
6
6
 
7
- interface SourceIconSelectProps {
8
- value: Source;
9
- onChange: (value: Source) => void;
7
+ interface SourceIconSelectorProps {
8
+ data: Source;
9
+ value?: string | null;
10
+ onChange: (value: string | null) => void;
10
11
  }
11
12
 
12
- export const SourceIconSelect: React.FC<SourceIconSelectProps> = ({
13
+ export const SourceIconSelector: React.FC<SourceIconSelectorProps> = ({
14
+ data,
13
15
  value,
14
16
  onChange,
15
17
  }) => {
16
18
  const { t } = useTranslation();
19
+
20
+ const translatedOptions = ICON_OPTIONS.map((option) => ({
21
+ ...option,
22
+ label: t(`source.type.${option.label}`),
23
+ }));
24
+
25
+ return (
26
+ <Select
27
+ leftSection={<SourceIcon source={data} />}
28
+ defaultValue={translatedOptions[0].value}
29
+ value={value}
30
+ onChange={onChange}
31
+ data={translatedOptions}
32
+ style={{ flex: 1 }}
33
+ />
34
+ );
35
+ };
36
+
37
+ interface SourceColorSelectorProps {
38
+ value?: string | null;
39
+ onChange: (value: string | null) => void;
40
+ }
41
+
42
+ export const SourceColorSelector: React.FC<SourceColorSelectorProps> = ({
43
+ value,
44
+ onChange,
45
+ }) => {
17
46
  const colors = [
18
47
  "#ababab",
19
48
  "#0089ff",
@@ -24,37 +53,46 @@ export const SourceIconSelect: React.FC<SourceIconSelectProps> = ({
24
53
  "#7950f2",
25
54
  ];
26
55
 
56
+ return (
57
+ <ColorInput
58
+ value={value || colors[0]}
59
+ onChange={onChange}
60
+ swatches={colors}
61
+ style={{ flex: 1 }}
62
+ />
63
+ );
64
+ };
65
+
66
+ interface SourceIconSelectProps {
67
+ value: Source;
68
+ onChange: (value: Source) => void;
69
+ }
70
+
71
+ export const SourceIconSelect: React.FC<SourceIconSelectProps> = ({
72
+ value,
73
+ onChange,
74
+ }) => {
27
75
  const handleTypeChange = (type: string | null) => {
28
76
  onChange({ ...value, type: type || undefined });
29
77
  };
30
78
 
31
- const handleColorChange = (color: string) => {
79
+ const handleColorChange = (color: string | null) => {
32
80
  onChange({
33
81
  ...value,
34
82
  attributes: { ...(value.attributes || {}), icon_color: color },
35
83
  });
36
84
  };
37
85
 
38
- const translatedOptions = ICON_OPTIONS.map((option) => ({
39
- ...option,
40
- label: t(`source.type.${option.label}`),
41
- }));
42
-
43
86
  return (
44
87
  <Group>
45
- <Select
46
- leftSection={<SourceIcon source={value} />}
47
- defaultValue={translatedOptions[0].value}
88
+ <SourceIconSelector
89
+ data={value}
48
90
  value={value.type}
49
91
  onChange={handleTypeChange}
50
- data={translatedOptions}
51
- style={{ flex: 1 }}
52
92
  />
53
- <ColorInput
54
- value={String((value.attributes || {}).icon_color || colors[0])}
93
+ <SourceColorSelector
94
+ value={String(value.attributes?.icon_color)}
55
95
  onChange={handleColorChange}
56
- swatches={colors}
57
- style={{ flex: 1 }}
58
96
  />
59
97
  </Group>
60
98
  );
@@ -4,16 +4,45 @@ import { Group, Select, ColorInput } from "@mantine/core";
4
4
  import { ICON_OPTIONS } from "./icons";
5
5
  import { WebsiteIcon } from "./Icon";
6
6
 
7
- interface WebsiteIconSelectProps {
8
- value: Website;
9
- onChange: (value: Website) => void;
7
+ interface WebsiteIconSelectorProps {
8
+ data: Website;
9
+ value?: string | null;
10
+ onChange: (value: string | null) => void;
10
11
  }
11
12
 
12
- export const WebsiteIconSelect: React.FC<WebsiteIconSelectProps> = ({
13
+ export const WebsiteIconSelector: React.FC<WebsiteIconSelectorProps> = ({
14
+ data,
13
15
  value,
14
16
  onChange,
15
17
  }) => {
16
18
  const { t } = useTranslation();
19
+
20
+ const translatedOptions = ICON_OPTIONS.map((option) => ({
21
+ ...option,
22
+ label: t(`website.type.${option.label}`),
23
+ }));
24
+
25
+ return (
26
+ <Select
27
+ leftSection={<WebsiteIcon website={data} />}
28
+ defaultValue={translatedOptions[0].value}
29
+ value={value}
30
+ onChange={onChange}
31
+ data={translatedOptions}
32
+ style={{ flex: 1 }}
33
+ />
34
+ );
35
+ };
36
+
37
+ interface WebsiteColorSelectorProps {
38
+ value?: string | null;
39
+ onChange: (value: string | null) => void;
40
+ }
41
+
42
+ export const WebsiteColorSelector: React.FC<WebsiteColorSelectorProps> = ({
43
+ value,
44
+ onChange,
45
+ }) => {
17
46
  const colors = [
18
47
  "#0089ff",
19
48
  "#ff0000",
@@ -24,37 +53,46 @@ export const WebsiteIconSelect: React.FC<WebsiteIconSelectProps> = ({
24
53
  "#7950f2",
25
54
  ];
26
55
 
56
+ return (
57
+ <ColorInput
58
+ value={value || colors[0]}
59
+ onChange={onChange}
60
+ swatches={colors}
61
+ style={{ flex: 1 }}
62
+ />
63
+ );
64
+ };
65
+
66
+ interface WebsiteIconSelectProps {
67
+ value: Website;
68
+ onChange: (value: Website) => void;
69
+ }
70
+
71
+ export const WebsiteIconSelect: React.FC<WebsiteIconSelectProps> = ({
72
+ value,
73
+ onChange,
74
+ }) => {
27
75
  const handleTypeChange = (type: string | null) => {
28
76
  onChange({ ...value, title: type || undefined });
29
77
  };
30
78
 
31
- const handleColorChange = (color: string) => {
79
+ const handleColorChange = (color: string | null) => {
32
80
  onChange({
33
81
  ...value,
34
82
  attributes: { ...(value.attributes || {}), icon_color: color },
35
83
  });
36
84
  };
37
85
 
38
- const translatedOptions = ICON_OPTIONS.map((option) => ({
39
- ...option,
40
- label: t(`website.type.${option.label}`),
41
- }));
42
-
43
86
  return (
44
87
  <Group>
45
- <Select
46
- leftSection={<WebsiteIcon website={value} />}
47
- defaultValue={translatedOptions[0].value}
48
- value={value.type}
88
+ <WebsiteIconSelector
89
+ data={value}
90
+ value={value.title}
49
91
  onChange={handleTypeChange}
50
- data={translatedOptions}
51
- style={{ flex: 1 }}
52
92
  />
53
- <ColorInput
54
- value={String((value.attributes || {}).icon_color || colors[0])}
93
+ <WebsiteColorSelector
94
+ value={String(value.attributes?.icon_color)}
55
95
  onChange={handleColorChange}
56
- swatches={colors}
57
- style={{ flex: 1 }}
58
96
  />
59
97
  </Group>
60
98
  );
@@ -1,10 +1,10 @@
1
1
  export { EventIcon} from './Event/Icon';
2
- export { EventIconSelect } from './Event/Select';
2
+ export { EventIconSelect, EventColorSelector, EventIconSelector } from './Event/Select';
3
3
  export { OrganizationIcon } from './Organization/Icon';
4
- export { OrganizationIconSelect } from './Organization/Select';
4
+ export { OrganizationIconSelect, OrganizationColorSelector, OrganizationIconSelector } from './Organization/Select';
5
5
  export { PersonIcon } from './Person/Icon';
6
- export { PersonIconSelect } from './Person/Select';
6
+ export { PersonIconSelect, PersonColorSelector, PersonIconSelector } from './Person/Select';
7
7
  export { SourceIcon } from './Source/Icon';
8
- export { SourceIconSelect } from './Source/Select';
8
+ export { SourceIconSelect, SourceColorSelector, SourceIconSelector } from './Source/Select';
9
9
  export { WebsiteIcon } from './Website/Icon';
10
- export { WebsiteIconSelect } from './Website/Select';
10
+ export { WebsiteIconSelect, WebsiteColorSelector, WebsiteIconSelector } from './Website/Select';