@kanda-libs/ks-component-ts 0.2.209 → 0.2.210
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/dist/index.d.ts +7767 -7688
- package/dist/index.esm.js +3 -3
- package/dist/index.esm.js.map +4 -4
- package/package.json +1 -1
- package/src/components/CompanyRiskFlag/constants.ts +11 -0
- package/src/components/CompanyRiskFlag/index.tsx +31 -0
- package/src/components/CompanyRiskFlag/useCompanyRiskFlag.ts +17 -0
- package/src/components/index.ts +1 -0
- package/src/generated/widget/index.tsx +40468 -40468
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StringIndexedObject } from "~/types";
|
|
2
|
+
|
|
3
|
+
// Without explicitly mentioning this class, it won't appear in the tailwind
|
|
4
|
+
// config build as COMPANY_RISK_FLAG_STROKES passes to Icon which uses string concatenation
|
|
5
|
+
export const COMPANY_RISK_YELLOW = "text-yellow";
|
|
6
|
+
|
|
7
|
+
export const COMPANY_RISK_FLAG_STROKES: StringIndexedObject<string> = {
|
|
8
|
+
red: "red-200",
|
|
9
|
+
yellow: "yellow",
|
|
10
|
+
green: "green-500",
|
|
11
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { type FunctionComponent } from "react";
|
|
2
|
+
import { Icon } from "@kanda-libs/ks-design-library";
|
|
3
|
+
import type { Monitor } from "generated/components/schemas";
|
|
4
|
+
import type { StringIndexedObject } from "~/types";
|
|
5
|
+
import { COMPANY_RISK_FLAG_STROKES } from "./constants";
|
|
6
|
+
import useCompanyRiskFlag from "./useCompanyRiskFlag";
|
|
7
|
+
|
|
8
|
+
export interface CompanyRiskFlagProps {
|
|
9
|
+
id?: string;
|
|
10
|
+
monitors?: StringIndexedObject<Monitor>;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const CompanyRiskFlag: FunctionComponent<CompanyRiskFlagProps> = function ({
|
|
15
|
+
id,
|
|
16
|
+
monitors = {},
|
|
17
|
+
className = "",
|
|
18
|
+
}) {
|
|
19
|
+
const { level } = useCompanyRiskFlag(id, monitors);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Icon
|
|
23
|
+
icon="flag"
|
|
24
|
+
size={18}
|
|
25
|
+
stroke={COMPANY_RISK_FLAG_STROKES[level as string]}
|
|
26
|
+
className={className}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default CompanyRiskFlag;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Flag, Monitor } from "@kanda-libs/ks-frontend-services";
|
|
2
|
+
import type { StringIndexedObject } from "~/types";
|
|
3
|
+
|
|
4
|
+
export interface CompanyRiskFlagHook {
|
|
5
|
+
level?: Flag["level"];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function useCompanyRiskFlag(
|
|
9
|
+
id: string = "",
|
|
10
|
+
monitors: StringIndexedObject<Monitor>
|
|
11
|
+
): CompanyRiskFlagHook {
|
|
12
|
+
const monitor = monitors[id];
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
level: monitor?.flag?.level || "green",
|
|
16
|
+
};
|
|
17
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as AddFieldButton } from "./AddFieldButton";
|
|
2
|
+
export { default as CompanyRiskFlag } from "./CompanyRiskFlag";
|
|
2
3
|
export { default as Dropzone } from "./Dropzone";
|
|
3
4
|
export { default as DropzoneContext } from "./Dropzone/DropzoneContext";
|
|
4
5
|
export { default as FieldHandle } from "./Handle";
|