@m4l/components 9.1.19 → 9.1.20
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/@types/types.d.ts +9 -1
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index.js +1 -1
- package/components/formatters/BooleanFormatter/BooleanFormatter.d.ts +29 -0
- package/components/formatters/BooleanFormatter/BooleanFormatter.js +48 -0
- package/components/formatters/BooleanFormatter/BooleanFormatter.styles.d.ts +2 -0
- package/components/formatters/BooleanFormatter/BooleanFormatter.styles.js +18 -0
- package/components/formatters/BooleanFormatter/constants.d.ts +1 -0
- package/components/formatters/BooleanFormatter/constants.js +4 -0
- package/components/formatters/BooleanFormatter/dictionary.d.ts +1 -1
- package/components/formatters/BooleanFormatter/index.d.ts +7 -5
- package/components/formatters/BooleanFormatter/slots/BooleanFormatterEnum.d.ts +6 -0
- package/components/formatters/BooleanFormatter/slots/BooleanFormatterEnum.js +10 -0
- package/components/formatters/BooleanFormatter/slots/BooleanFormatterSlots.d.ts +12 -0
- package/components/formatters/BooleanFormatter/slots/BooleanFormatterSlots.js +29 -0
- package/components/formatters/BooleanFormatter/slots/index.d.ts +2 -0
- package/components/formatters/BooleanFormatter/slots/index.js +1 -0
- package/components/formatters/BooleanFormatter/tests/BooleanFormatter.test.d.ts +1 -0
- package/components/formatters/BooleanFormatter/types.d.ts +32 -0
- package/components/formatters/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/storybook/components/formatters/BooleanFormatter/BooleanFormatter.stories.d.ts +41 -0
- package/components/formatters/BooleanFormatter/index.js +0 -40
package/@types/types.d.ts
CHANGED
|
@@ -135,6 +135,7 @@ import { AppBarSlotsType, AppBarOwnerState } from '../components/AppBar/types';
|
|
|
135
135
|
import { DialogOwnerState, DialogType } from '../components/mui_extended/Dialog/types';
|
|
136
136
|
import { LoadingButtonOwnerState, LoadingButtonSlotsType } from '../components/mui_extended/LoadingButton/types';
|
|
137
137
|
|
|
138
|
+
import { BooleanFormatterOwnerState, PresentationType } from '../components/formatters/BooleanFormatter/types';
|
|
138
139
|
|
|
139
140
|
declare module '@mui/material/styles' {
|
|
140
141
|
// Define the slots in the theme
|
|
@@ -175,6 +176,7 @@ declare module '@mui/material/styles' {
|
|
|
175
176
|
M4LAppBar: AppBarSlotsType;
|
|
176
177
|
M4LWiDialog: DialogType;
|
|
177
178
|
M4LLoadingButton: LoadingButtonSlotsType;
|
|
179
|
+
M4LBooleanFormatter: PresentationType;
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
interface ComponentsPropsList {
|
|
@@ -215,6 +217,7 @@ declare module '@mui/material/styles' {
|
|
|
215
217
|
M4LAppBar: Partial<AppBarOwnerState>;
|
|
216
218
|
M4LWiDialog: Partial<DialogOwnerState>;
|
|
217
219
|
M4LLoadingButton: Partial<LoadingButtonOwnerState>;
|
|
220
|
+
M4LBooleanFormatter: Partial<BooleanFormatterOwnerState>;
|
|
218
221
|
}
|
|
219
222
|
|
|
220
223
|
interface Components {
|
|
@@ -493,5 +496,10 @@ declare module '@mui/material/styles' {
|
|
|
493
496
|
styleOverrides?: ComponentsOverrides<Theme>['M4LLoadingButton'];
|
|
494
497
|
variants?: ComponentsVariants['M4LLoadingButton'];
|
|
495
498
|
};
|
|
499
|
+
M4LBooleanFormatter?: {
|
|
500
|
+
defaultProps?: ComponentsPropsList['M4LBooleanFormatter'];
|
|
501
|
+
styleOverrides?: ComponentsOverrides<Theme>['M4LBooleanFormatter'];
|
|
502
|
+
variants?: ComponentsVariants['M4LBooleanFormatter'];
|
|
503
|
+
};
|
|
496
504
|
}
|
|
497
|
-
}
|
|
505
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getPropertyByString } from "@m4l/core";
|
|
3
|
-
import { B as BooleanFormatter } from "../../../formatters/BooleanFormatter/
|
|
3
|
+
import { B as BooleanFormatter } from "../../../formatters/BooleanFormatter/BooleanFormatter.js";
|
|
4
4
|
function ColumnBooleanFormatter(props) {
|
|
5
5
|
const { fieldValue, presentationType, Component } = props;
|
|
6
6
|
return (obProps) => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BooleanFormatterProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* BooleanFormatter
|
|
4
|
+
* A component for formatting boolean values (`true` or `false`) into various presentation styles such as text or checkbox.
|
|
5
|
+
* @param {BooleanFormatterProps} props - The properties for the component.
|
|
6
|
+
* presentationType
|
|
7
|
+
* Specifies how the boolean value should be represented:
|
|
8
|
+
* - `'string_yes_no'`: Displays "Yes" for `true` and "No" for `false`.
|
|
9
|
+
* - `'string_true_false'`: Displays "True" for `true` and "False" for `false`.
|
|
10
|
+
* - `'check'`: Displays an icon representing `true` or `false`.
|
|
11
|
+
* [value=false]
|
|
12
|
+
* The boolean value to be formatted.
|
|
13
|
+
* [Component=WrapperComponent]
|
|
14
|
+
* A custom wrapper component for the formatted output.
|
|
15
|
+
* [dataTestId]
|
|
16
|
+
* A unique identifier for testing purposes, used as a `data-testid` attribute.
|
|
17
|
+
* @example
|
|
18
|
+
* <BooleanFormatter presentationType="string_yes_no" value={true} />
|
|
19
|
+
* // Renders "Yes"
|
|
20
|
+
*
|
|
21
|
+
* <BooleanFormatter presentationType="check" value={false} />
|
|
22
|
+
* // Renders a false icon
|
|
23
|
+
* @returns JSX.Element
|
|
24
|
+
* @author cesar - automatic
|
|
25
|
+
* @createdAt 2024-12-06 15:57:50 - automatic
|
|
26
|
+
* @updatedAt 2024-12-10 14:11:20 - automatic
|
|
27
|
+
* @updatedUser cesar - automatic
|
|
28
|
+
*/
|
|
29
|
+
export declare function BooleanFormatter(props: BooleanFormatterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
4
|
+
import { W as WrapperComponent } from "../../WrapperComponent/index.js";
|
|
5
|
+
import { L as LABEL_BOOLEAN_YES, a as LABEL_BOOLEAN_NO, b as LABEL_BOOLEAN_TRUE, c as LABEL_BOOLEAN_FALSE } from "./dictionary.js";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { g as getComponentSlotRoot } from "../../../utils/getComponentSlotRoot.js";
|
|
8
|
+
import { B as BOOLEAN_FORMATTER_KEY_COMPONENT } from "./constants.js";
|
|
9
|
+
import { a as getPropDataTestId } from "../../../test/getNameDataTestId.js";
|
|
10
|
+
import { T as TextStyled, F as FormatterRootStyled, B as BooleanFormatterIconStyled } from "./slots/BooleanFormatterSlots.js";
|
|
11
|
+
import { B as BooleanFormatterSlots } from "./slots/BooleanFormatterEnum.js";
|
|
12
|
+
function BooleanFormatter(props) {
|
|
13
|
+
const { presentationType, value, Component = WrapperComponent, dataTestId } = props;
|
|
14
|
+
const { getLabel } = useModuleDictionary();
|
|
15
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
16
|
+
const final_value = value ?? false;
|
|
17
|
+
const srcCheckTrue = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_true.svg`;
|
|
18
|
+
const srcCheckFalse = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_false.svg`;
|
|
19
|
+
const ownerState = { isTrue: final_value };
|
|
20
|
+
const memoComponent = useMemo(() => {
|
|
21
|
+
if (presentationType === "string_yes_no") {
|
|
22
|
+
return /* @__PURE__ */ jsx(Component, { children: /* @__PURE__ */ jsx(TextStyled, { ownerState, children: final_value ? getLabel(LABEL_BOOLEAN_YES) : getLabel(LABEL_BOOLEAN_NO) }) });
|
|
23
|
+
}
|
|
24
|
+
if (presentationType === "string_true_false") {
|
|
25
|
+
return /* @__PURE__ */ jsx(Component, { children: /* @__PURE__ */ jsx(TextStyled, { ownerState, children: final_value ? getLabel(LABEL_BOOLEAN_TRUE) : getLabel(LABEL_BOOLEAN_FALSE) }) });
|
|
26
|
+
}
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
FormatterRootStyled,
|
|
29
|
+
{
|
|
30
|
+
className: clsx(getComponentSlotRoot(BOOLEAN_FORMATTER_KEY_COMPONENT)),
|
|
31
|
+
...getPropDataTestId(BOOLEAN_FORMATTER_KEY_COMPONENT, BooleanFormatterSlots.booleanFormatterRoot, dataTestId),
|
|
32
|
+
role: "booleanStyled-role",
|
|
33
|
+
ownerState,
|
|
34
|
+
children: /* @__PURE__ */ jsx(Component, { children: /* @__PURE__ */ jsx(
|
|
35
|
+
BooleanFormatterIconStyled,
|
|
36
|
+
{
|
|
37
|
+
ownerState,
|
|
38
|
+
src: final_value ? srcCheckTrue : srcCheckFalse
|
|
39
|
+
}
|
|
40
|
+
) })
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}, [final_value, getLabel, presentationType, srcCheckTrue, srcCheckFalse]);
|
|
44
|
+
return memoComponent;
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
BooleanFormatter as B
|
|
48
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const booleanFormatterStyles = {
|
|
2
|
+
/**
|
|
3
|
+
* Modal Dialog Root style
|
|
4
|
+
* @author cesar - automatic
|
|
5
|
+
* @createdAt 2024-12-10 14:11:55 - automatic
|
|
6
|
+
* @updatedAt 2024-12-10 14:11:55 - automatic
|
|
7
|
+
* @updatedUser cesar - automatic
|
|
8
|
+
*/
|
|
9
|
+
text: ({ theme }) => ({
|
|
10
|
+
"& .MuiSkeleton-text": {
|
|
11
|
+
width: `${theme.vars.size.baseSpacings.sp7} !important`,
|
|
12
|
+
borderRadius: theme.vars.size.borderRadius.r1
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
booleanFormatterStyles as b
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BOOLEAN_FORMATTER_KEY_COMPONENT = "M4LBooleanFormatter";
|
|
@@ -3,5 +3,5 @@ export declare const LABEL_BOOLEAN_YES = "boolean_formatter.boolean_yes";
|
|
|
3
3
|
export declare const LABEL_BOOLEAN_NO = "boolean_formatter.boolean_no";
|
|
4
4
|
export declare const LABEL_BOOLEAN_TRUE = "boolean_formatter.boolean_true";
|
|
5
5
|
export declare const LABEL_BOOLEAN_FALSE = "boolean_formatter.boolean_false";
|
|
6
|
-
export declare function getFormattersComponentsDictionary(): string;
|
|
6
|
+
export declare function getFormattersComponentsDictionary(): string[];
|
|
7
7
|
export declare const BOOLEAN_FORMATTER_DICTIONARY_LABELS: string[];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
export
|
|
1
|
+
export * from './BooleanFormatter.styles';
|
|
2
|
+
export { BooleanFormatter } from './BooleanFormatter';
|
|
3
|
+
export * from './constants';
|
|
4
|
+
export * from './dictionary';
|
|
5
|
+
export * from './slots/BooleanFormatterSlots';
|
|
6
|
+
export * from './slots/BooleanFormatterEnum';
|
|
7
|
+
export * from './types';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var BooleanFormatterSlots = /* @__PURE__ */ ((BooleanFormatterSlots2) => {
|
|
2
|
+
BooleanFormatterSlots2["booleanFormatterRoot"] = "booleanFormatterRoot";
|
|
3
|
+
BooleanFormatterSlots2["booleanFormatterSkeleton"] = "booleanFormatterSkeleton";
|
|
4
|
+
BooleanFormatterSlots2["booleanFormatterIcon"] = "booleanFormatterIcon";
|
|
5
|
+
BooleanFormatterSlots2["text"] = "text";
|
|
6
|
+
return BooleanFormatterSlots2;
|
|
7
|
+
})(BooleanFormatterSlots || {});
|
|
8
|
+
export {
|
|
9
|
+
BooleanFormatterSlots as B
|
|
10
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const FormatterRootStyled: import('@emotion/styled').StyledComponent<Pick<import('../../FormatterRoot/types').FormatterRootProps, "children"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
|
|
2
|
+
ownerState: Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown>;
|
|
3
|
+
}, {}, {}>;
|
|
4
|
+
export declare const BooleanFormatterIconStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../Icon/types').IconProps, keyof import('../../../Icon/types').IconProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
|
|
5
|
+
ownerState: Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown>;
|
|
6
|
+
}, {}, {}>;
|
|
7
|
+
export declare const BooleanFormatterSkeletonStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../mui_extended/Skeleton/types').SkeletonProps, keyof import('../../../mui_extended/Skeleton/types').SkeletonProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
|
|
8
|
+
ownerState: Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown>;
|
|
9
|
+
}, {}, {}>;
|
|
10
|
+
export declare const TextStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../mui_extended/Typography/types').TypographyProps, keyof import('../../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
|
|
11
|
+
ownerState: Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown>;
|
|
12
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { styled } from "@mui/material/styles";
|
|
2
|
+
import { B as BOOLEAN_FORMATTER_KEY_COMPONENT } from "../constants.js";
|
|
3
|
+
import { B as BooleanFormatterSlots } from "./BooleanFormatterEnum.js";
|
|
4
|
+
import { b as booleanFormatterStyles } from "../BooleanFormatter.styles.js";
|
|
5
|
+
import { F as FormatterRoot } from "../../FormatterRoot/index.js";
|
|
6
|
+
import { S as Skeleton } from "../../../mui_extended/Skeleton/Skeleton.js";
|
|
7
|
+
import { I as Icon } from "../../../Icon/Icon.js";
|
|
8
|
+
import { T as Typography } from "../../../mui_extended/Typography/Typography.js";
|
|
9
|
+
const FormatterRootStyled = styled(FormatterRoot, {
|
|
10
|
+
name: BOOLEAN_FORMATTER_KEY_COMPONENT,
|
|
11
|
+
slot: BooleanFormatterSlots.booleanFormatterRoot
|
|
12
|
+
})(booleanFormatterStyles?.booleanFormatterRoot);
|
|
13
|
+
const BooleanFormatterIconStyled = styled(Icon, {
|
|
14
|
+
name: BOOLEAN_FORMATTER_KEY_COMPONENT,
|
|
15
|
+
slot: BooleanFormatterSlots.booleanFormatterIcon
|
|
16
|
+
})(booleanFormatterStyles?.booleanFormatterIcon);
|
|
17
|
+
styled(Skeleton, {
|
|
18
|
+
name: BOOLEAN_FORMATTER_KEY_COMPONENT,
|
|
19
|
+
slot: BooleanFormatterSlots.booleanFormatterSkeleton
|
|
20
|
+
})(booleanFormatterStyles?.booleanFormatterSkeleton);
|
|
21
|
+
const TextStyled = styled(Typography, {
|
|
22
|
+
name: BOOLEAN_FORMATTER_KEY_COMPONENT,
|
|
23
|
+
slot: BooleanFormatterSlots.text
|
|
24
|
+
})(booleanFormatterStyles?.text);
|
|
25
|
+
export {
|
|
26
|
+
BooleanFormatterIconStyled as B,
|
|
27
|
+
FormatterRootStyled as F,
|
|
28
|
+
TextStyled as T
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,38 @@
|
|
|
1
|
+
import { OverridesStyleRules } from '@mui/material/styles/overrides';
|
|
2
|
+
import { BooleanFormatterSlots } from './slots';
|
|
3
|
+
import { BOOLEAN_FORMATTER_KEY_COMPONENT } from './constants';
|
|
4
|
+
import { Theme } from '@mui/material';
|
|
5
|
+
/**
|
|
6
|
+
* Defines the presentation type for the BooleanFormatter component.
|
|
7
|
+
* - `'string_yes_no'`: Displays "Yes" for `true` and "No" for `false`.
|
|
8
|
+
* - `'string_true_false'`: Displays "True" for `true` and "False" for `false`.
|
|
9
|
+
* - `'check'`: Displays an icon to represent the boolean value.
|
|
10
|
+
*/
|
|
1
11
|
export type PresentationType = 'string_yes_no' | 'string_true_false' | 'check';
|
|
12
|
+
/**
|
|
13
|
+
* Maps to the keys in `BooleanFormatterSlots`, defining slot-specific styling or customization.
|
|
14
|
+
*/
|
|
15
|
+
export type BooleanFormatter = keyof typeof BooleanFormatterSlots;
|
|
16
|
+
/**
|
|
17
|
+
* Properties for the `BooleanFormatter` component.
|
|
18
|
+
*/
|
|
2
19
|
export interface BooleanFormatterProps {
|
|
3
20
|
Component?: React.ElementType;
|
|
4
21
|
presentationType: PresentationType;
|
|
5
22
|
value?: boolean;
|
|
23
|
+
dataTestId?: string;
|
|
6
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* State properties for the `BooleanFormatter` component.
|
|
27
|
+
*/
|
|
28
|
+
export interface BooleanFormatterOwnerState {
|
|
29
|
+
isTrue?: boolean;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Styles for customizing the `BooleanFormatter` component.
|
|
34
|
+
*
|
|
35
|
+
* This type allows partial overriding of the default styles through Material-UI's `OverridesStyleRules`.
|
|
36
|
+
* It integrates with the Material-UI `Theme` to ensure consistent theming.
|
|
37
|
+
*/
|
|
38
|
+
export type BooleanFormatterStyles = Partial<OverridesStyleRules<BooleanFormatter, typeof BOOLEAN_FORMATTER_KEY_COMPONENT, Theme> | undefined> | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BooleanFormatter } from './BooleanFormatter';
|
|
1
|
+
export { BooleanFormatter } from './BooleanFormatter/BooleanFormatter';
|
|
2
2
|
export { useFormatDate as getFormatDate, DateFormatter } from './DateFormatter';
|
|
3
3
|
export { UncertaintyFormatter, getUncertaintyFormat } from './UncertaintyFormatter';
|
|
4
4
|
export { PointsFormatter, getFormatPoints } from './PointsFormatter';
|
package/index.js
CHANGED
|
@@ -42,7 +42,7 @@ import { R as R10 } from "./components/hook-form/RHFCheckbox/RHFCheckbox.js";
|
|
|
42
42
|
import { R as R11 } from "./components/hook-form/RHFTextField/RHFTextField.js";
|
|
43
43
|
import { R as R12 } from "./components/hook-form/RHFTextFieldPassword/RHFTextFieldPassword.js";
|
|
44
44
|
import { R as R13 } from "./components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.js";
|
|
45
|
-
import { B } from "./components/formatters/BooleanFormatter/
|
|
45
|
+
import { B } from "./components/formatters/BooleanFormatter/BooleanFormatter.js";
|
|
46
46
|
import { D as D2, u as u4 } from "./components/formatters/DateFormatter/index.js";
|
|
47
47
|
import { U, g as g8 } from "./components/formatters/UncertaintyFormatter/index.js";
|
|
48
48
|
import { P as P2, g as g9 } from "./components/formatters/PointsFormatter/index.js";
|
package/package.json
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { BooleanFormatter } from '../../../../src/components/formatters/BooleanFormatter';
|
|
3
|
+
declare const meta: Meta<typeof BooleanFormatter>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof BooleanFormatter>;
|
|
6
|
+
/**
|
|
7
|
+
* Default story for the BooleanFormatter component.
|
|
8
|
+
*/
|
|
9
|
+
export declare const Default: Story;
|
|
10
|
+
/**
|
|
11
|
+
* Stories for the BooleanFormatter component with different values and presentation types.
|
|
12
|
+
*/
|
|
13
|
+
export declare const StringYes: Story;
|
|
14
|
+
/**
|
|
15
|
+
* Stories for the BooleanFormatter component with different values and presentation types.
|
|
16
|
+
*/
|
|
17
|
+
export declare const StringNo: Story;
|
|
18
|
+
/**
|
|
19
|
+
* Stories for the BooleanFormatter component with different values and presentation types.
|
|
20
|
+
*/
|
|
21
|
+
export declare const StringTrue: Story;
|
|
22
|
+
/**
|
|
23
|
+
* Stories for the BooleanFormatter component with different values and presentation types.
|
|
24
|
+
*/
|
|
25
|
+
export declare const StringFalse: Story;
|
|
26
|
+
/**
|
|
27
|
+
* Stories for the BooleanFormatter component with different values and presentation types.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CheckTrue: Story;
|
|
30
|
+
/**
|
|
31
|
+
* Stories for the BooleanFormatter component with different values and presentation types.
|
|
32
|
+
*/
|
|
33
|
+
export declare const CheckFalse: Story;
|
|
34
|
+
/**
|
|
35
|
+
* Stories for the BooleanFormatter component with different values and presentation types.
|
|
36
|
+
*/
|
|
37
|
+
export declare const SkeletonCheck: Story;
|
|
38
|
+
/**
|
|
39
|
+
* Stories for the BooleanFormatter component with different values and presentation types.
|
|
40
|
+
*/
|
|
41
|
+
export declare const SkeletonString: Story;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
4
|
-
import { I as Icon } from "../../Icon/Icon.js";
|
|
5
|
-
import { W as WrapperComponent } from "../../WrapperComponent/index.js";
|
|
6
|
-
import { L as LABEL_BOOLEAN_YES, a as LABEL_BOOLEAN_NO, b as LABEL_BOOLEAN_TRUE, c as LABEL_BOOLEAN_FALSE } from "./dictionary.js";
|
|
7
|
-
import { f as formatterClasses } from "../classes/index.js";
|
|
8
|
-
import clsx from "clsx";
|
|
9
|
-
import { F as FormatterRoot } from "../FormatterRoot/index.js";
|
|
10
|
-
function BooleanFormatter(props) {
|
|
11
|
-
const { presentationType, value, Component = WrapperComponent } = props;
|
|
12
|
-
const { getLabel } = useModuleDictionary();
|
|
13
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
14
|
-
const final_value = value ?? false;
|
|
15
|
-
const srcCheckTrue = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_true.svg`;
|
|
16
|
-
const srcCheckFalse = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_false.svg`;
|
|
17
|
-
const memoComponent = useMemo(() => {
|
|
18
|
-
if (presentationType === "string_yes_no") {
|
|
19
|
-
return /* @__PURE__ */ jsx(Component, { children: final_value ? getLabel(LABEL_BOOLEAN_YES) : getLabel(LABEL_BOOLEAN_NO) });
|
|
20
|
-
}
|
|
21
|
-
if (presentationType === "string_true_false") {
|
|
22
|
-
return /* @__PURE__ */ jsx(Component, { children: final_value ? getLabel(LABEL_BOOLEAN_TRUE) : getLabel(LABEL_BOOLEAN_FALSE) });
|
|
23
|
-
}
|
|
24
|
-
return /* @__PURE__ */ jsx(FormatterRoot, { children: /* @__PURE__ */ jsx(Component, { children: /* @__PURE__ */ jsx(
|
|
25
|
-
Icon,
|
|
26
|
-
{
|
|
27
|
-
src: final_value ? srcCheckTrue : srcCheckFalse,
|
|
28
|
-
className: clsx(
|
|
29
|
-
formatterClasses.root,
|
|
30
|
-
formatterClasses.booleanFormatterIcon,
|
|
31
|
-
final_value && formatterClasses.booleanFormatterCheck
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
) }) });
|
|
35
|
-
}, [final_value]);
|
|
36
|
-
return memoComponent;
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
BooleanFormatter as B
|
|
40
|
-
};
|