@m4l/components 9.1.114 → 9.1.116

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.
Files changed (23) hide show
  1. package/@types/types.d.ts +10 -3
  2. package/components/formatters/CourseFormatter/CourseFormatter.d.ts +10 -1
  3. package/components/formatters/CourseFormatter/CourseFormatter.js +24 -24
  4. package/components/formatters/CourseFormatter/CourseFormatter.styles.js +18 -1
  5. package/components/formatters/CourseFormatter/constants.d.ts +1 -0
  6. package/components/formatters/CourseFormatter/constants.js +3 -1
  7. package/components/formatters/CourseFormatter/dictionary.d.ts +9 -9
  8. package/components/formatters/CourseFormatter/dictionary.js +1 -1
  9. package/components/formatters/CourseFormatter/helper.d.ts +4 -0
  10. package/components/formatters/CourseFormatter/helper.js +28 -0
  11. package/components/formatters/CourseFormatter/slots/CourseFormatterSlots.d.ts +3 -1
  12. package/components/formatters/CourseFormatter/slots/CourseFormatterSlots.js +3 -2
  13. package/components/formatters/CourseFormatter/test/CourserFormatter.test.d.ts +1 -0
  14. package/components/formatters/CourseFormatter/types.d.ts +16 -10
  15. package/package.json +1 -1
  16. package/storybook/components/formatters/CourseFormatter/CourseFormatter.stories.d.ts +25 -0
  17. package/{components/formatters/CourseFormatter/stories → storybook/components/formatters/CourseFormatter}/types.d.ts +1 -1
  18. package/components/formatters/CourseFormatter/stories/basic.stories.d.ts +0 -45
  19. package/components/formatters/CourseFormatter/stories/dictionary.d.ts +0 -0
  20. package/components/formatters/CourseFormatter/stories/subcomponents/WithCFProvider.d.ts +0 -5
  21. /package/components/formatters/CourseFormatter/slots/{slots.d.ts → CourseFormatterEnum.d.ts} +0 -0
  22. /package/components/formatters/CourseFormatter/slots/{slots.js → CourseFormatterEnum.js} +0 -0
  23. /package/{components/formatters/CourseFormatter/stories → storybook/components/formatters/CourseFormatter}/constants.d.ts +0 -0
package/@types/types.d.ts CHANGED
@@ -133,6 +133,7 @@ import { RHFCheckBoxOwnerState, RHFCheckBoxSlotsType } from '../components/hook-
133
133
  import { AreasAdminOwnerState, AreasAdminType } from '../components/areas/components/AreasAdmin/types';
134
134
  import { DateTimePickerOwnerState, DateTimePickerSlotsType } from '../components/mui_extended/DateTimePicker/types';
135
135
  import { DividerOwnerState, DividerSlotsType } from '../components/mui_extended/Divider/types';
136
+ import { CourseFormatterOwnerState, CourseFormatterSlotsType } from '../components/formatters/CourseFormatter/types';
136
137
  import { NoItemSelectedOwnerState, NoItemSelectedSlotsType } from '../components/NoItemSelected/types';
137
138
  import { ActionFormIntroOwnerState, ActionFormIntroSlotsType } from '../components/CommonActions/components/ActionFormIntro/types';
138
139
 
@@ -201,6 +202,7 @@ declare module '@mui/material/styles' {
201
202
  M4LStack: StackSlotsType;
202
203
  M4LDateTimePicker: DateTimePickerSlotsType;
203
204
  M4LDivider: DividerSlotsType;
205
+ M4LCourseFormatter: CourseFormatterSlotsType;
204
206
  M4LNoItemSelected: NoItemSelectedSlotsType;
205
207
  M4LActionFormIntro: ActionFormIntroSlotsType;
206
208
  }
@@ -267,6 +269,7 @@ declare module '@mui/material/styles' {
267
269
  M4LStack: Partial<StackOwnerState>;
268
270
  M4LDateTimePicker: Partial<DateTimePickerOwnerState>;
269
271
  M4LDivider: Partial<DividerOwnerState>;
272
+ M4LCourseFormatter: Partial<CourseFormatterOwnerState>;
270
273
  M4LNoItemSelected: Partial<NoItemSelectedOwnerState>;
271
274
  M4LActionFormIntro : Partial<ActionFormIntroOwnerState>;
272
275
  }
@@ -586,6 +589,10 @@ declare module '@mui/material/styles' {
586
589
  styleOverrides?: ComponentsOverrides<Theme>['M4LDivider'];
587
590
  variants?: ComponentsVariants['M4LDivider'];
588
591
  };
589
- }
590
-
591
- }
592
+ M4LCourseFormatter?: {
593
+ defaultProps?: ComponentsPropsList['M4LCourseFormatter'];
594
+ styleOverrides?: ComponentsOverrides<Theme>['M4LCourseFormatter'];
595
+ variants?: ComponentsVariants['M4LCourseFormatter'];
596
+ };
597
+ }
598
+ }
@@ -1,5 +1,14 @@
1
1
  import { CourseFormatterProps } from './types';
2
2
  /**
3
- * TODO: Documentar
3
+ * "CourseFormatter" que se encarga de visualizar el Curse Over Ground (Sentido manecilla del reloj, 0grados = Norte )
4
+ * a (Sentido contrario manecillas del reloj 0grados = East).
5
+ * Curso: 0 => 90 - Norte
6
+ * Curso: 90 => 0 - Este
7
+ * Curso: 180 => 270 - Sur
8
+ * Curso: 270 => 180 - Oeste
9
+ *
10
+ */
11
+ /**
12
+ * CourseFormatter Component
4
13
  */
5
14
  export declare const CourseFormatter: (props: CourseFormatterProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,32 +1,32 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useModuleDictionary } from "@m4l/core";
3
2
  import { C as CFRootStyled } from "./slots/CourseFormatterSlots.js";
4
- import { C as CF_DICCTIONARY } from "./dictionary.js";
3
+ import { g as getCardinalDirection } from "./helper.js";
4
+ import { g as getPropDataTestId } from "../../../test/getNameDataTestId.js";
5
+ import { C as CourseFormatterSlots } from "./slots/CourseFormatterEnum.js";
6
+ import { C as COMPONET_KEY_COMPONENT, D as DEFAULT_GAP_ANGLE } from "./constants.js";
5
7
  import { c as courseToCartesianAngle } from "../../maps/utils/courseToCartesianAngle.js";
6
- const DEFAULT_GAP_ANGLE = 5;
7
8
  const CourseFormatter = (props) => {
8
- const { course, gapAngle: gap = DEFAULT_GAP_ANGLE } = props;
9
- const { getLabel } = useModuleDictionary();
9
+ const {
10
+ course,
11
+ gapAngle: gap = DEFAULT_GAP_ANGLE,
12
+ size = "medium",
13
+ dataTestId
14
+ } = props;
15
+ const ownerState = {
16
+ size,
17
+ variant: "standard"
18
+ };
10
19
  const angle = courseToCartesianAngle(course);
11
- let ret;
12
- if (angle >= 0 + gap && angle < 90 - gap) {
13
- ret = getLabel(CF_DICCTIONARY.LABEL_NORTH_EAST);
14
- } else if (angle >= 90 - gap && angle < 90 + gap) {
15
- ret = getLabel(CF_DICCTIONARY.LABEL_NORTH);
16
- } else if (angle >= 90 + gap && angle < 180 - gap) {
17
- ret = getLabel(CF_DICCTIONARY.LABEL_NORTH_WEST);
18
- } else if (angle >= 180 - gap && angle < 180 + gap) {
19
- ret = getLabel(CF_DICCTIONARY.LABEL_WEST);
20
- } else if (angle >= 180 + gap && angle < 270 - gap) {
21
- ret = getLabel(CF_DICCTIONARY.LABEL_SOUTH_WEST);
22
- } else if (angle >= 270 - gap && angle < 270 + gap) {
23
- ret = getLabel(CF_DICCTIONARY.LABEL_SOUTH);
24
- } else if (angle >= 270 + gap && angle < 360 - gap) {
25
- ret = getLabel(CF_DICCTIONARY.LABEL_SOUTH_EAST);
26
- } else {
27
- ret = getLabel(CF_DICCTIONARY.LABEL_EAST);
28
- }
29
- return /* @__PURE__ */ jsx(CFRootStyled, { children: ret });
20
+ const ret = getCardinalDirection(angle, gap);
21
+ return /* @__PURE__ */ jsx(
22
+ CFRootStyled,
23
+ {
24
+ ownerState: { ...ownerState },
25
+ ...getPropDataTestId(COMPONET_KEY_COMPONENT, CourseFormatterSlots.root, dataTestId),
26
+ skeletonWidth: "10%",
27
+ children: ret
28
+ }
29
+ );
30
30
  };
31
31
  export {
32
32
  CourseFormatter as C
@@ -1,5 +1,22 @@
1
+ import { g as getTypographyStyles } from "../../../utils/getTypographyStyles.js";
1
2
  const courseFormatterStyles = {
2
- root: () => ({})
3
+ /** Styles applied to the root element. */
4
+ root: ({ theme, ownerState }) => ({
5
+ "&.MuiTypography-root": {
6
+ "&.M4lclassCssSpecificity": {
7
+ ...getTypographyStyles(
8
+ theme.generalSettings.isMobile,
9
+ ownerState.size || "medium",
10
+ "body"
11
+ ),
12
+ ...getTypographyStyles(
13
+ theme.generalSettings.isMobile,
14
+ ownerState.size || "small",
15
+ "body"
16
+ )
17
+ }
18
+ }
19
+ })
3
20
  };
4
21
  export {
5
22
  courseFormatterStyles as c
@@ -1,2 +1,3 @@
1
1
  export declare const COMPONENT_TEST_ID = "M4LCourseFormatter";
2
2
  export declare const COMPONET_KEY_COMPONENT = "M4LCourseFormatter";
3
+ export declare const DEFAULT_GAP_ANGLE = 5;
@@ -1,4 +1,6 @@
1
1
  const COMPONET_KEY_COMPONENT = "M4LCourseFormatter";
2
+ const DEFAULT_GAP_ANGLE = 5;
2
3
  export {
3
- COMPONET_KEY_COMPONENT as C
4
+ COMPONET_KEY_COMPONENT as C,
5
+ DEFAULT_GAP_ANGLE as D
4
6
  };
@@ -1,12 +1,12 @@
1
- export declare const CF_DICTIONARY_ID = "course_formmater";
1
+ export declare const CF_DICTIONARY_ID = "course_formatter";
2
2
  export declare function getCourseFormatterComponentsDictionary(): string[];
3
3
  export declare const CF_DICCTIONARY: {
4
- readonly LABEL_NORTH: "course_formmater.label_north";
5
- readonly LABEL_SOUTH: "course_formmater.label_south";
6
- readonly LABEL_EAST: "course_formmater.label_east";
7
- readonly LABEL_WEST: "course_formmater.label_west";
8
- readonly LABEL_NORTH_EAST: "course_formmater.label_north_east";
9
- readonly LABEL_NORTH_WEST: "course_formmater.label_north_west";
10
- readonly LABEL_SOUTH_EAST: "course_formmater.label_south_east";
11
- readonly LABEL_SOUTH_WEST: "course_formmater.label_south_west";
4
+ readonly LABEL_NORTH: "course_formatter.label_north";
5
+ readonly LABEL_SOUTH: "course_formatter.label_south";
6
+ readonly LABEL_EAST: "course_formatter.label_east";
7
+ readonly LABEL_WEST: "course_formatter.label_west";
8
+ readonly LABEL_NORTH_EAST: "course_formatter.label_north_east";
9
+ readonly LABEL_NORTH_WEST: "course_formatter.label_north_west";
10
+ readonly LABEL_SOUTH_EAST: "course_formatter.label_south_east";
11
+ readonly LABEL_SOUTH_WEST: "course_formatter.label_south_west";
12
12
  };
@@ -1,4 +1,4 @@
1
- const CF_DICTIONARY_ID = "course_formmater";
1
+ const CF_DICTIONARY_ID = "course_formatter";
2
2
  function getCourseFormatterComponentsDictionary() {
3
3
  return [CF_DICTIONARY_ID];
4
4
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Helper function to get the cardinal direction from an angle.
3
+ */
4
+ export declare const getCardinalDirection: (angle: number, gap?: number) => string;
@@ -0,0 +1,28 @@
1
+ import { useModuleDictionary } from "@m4l/core";
2
+ import { C as CF_DICCTIONARY } from "./dictionary.js";
3
+ import { D as DEFAULT_GAP_ANGLE } from "./constants.js";
4
+ const getCardinalDirection = (angle, gap = DEFAULT_GAP_ANGLE) => {
5
+ const { getLabel } = useModuleDictionary();
6
+ let ret;
7
+ if (angle >= 0 + gap && angle < 90 - gap) {
8
+ ret = getLabel(CF_DICCTIONARY.LABEL_NORTH_EAST);
9
+ } else if (angle >= 90 - gap && angle < 90 + gap) {
10
+ ret = getLabel(CF_DICCTIONARY.LABEL_NORTH);
11
+ } else if (angle >= 90 + gap && angle < 180 - gap) {
12
+ ret = getLabel(CF_DICCTIONARY.LABEL_NORTH_WEST);
13
+ } else if (angle >= 180 - gap && angle < 180 + gap) {
14
+ ret = getLabel(CF_DICCTIONARY.LABEL_WEST);
15
+ } else if (angle >= 180 + gap && angle < 270 - gap) {
16
+ ret = getLabel(CF_DICCTIONARY.LABEL_SOUTH_WEST);
17
+ } else if (angle >= 270 - gap && angle < 270 + gap) {
18
+ ret = getLabel(CF_DICCTIONARY.LABEL_SOUTH);
19
+ } else if (angle >= 270 + gap && angle < 360 - gap) {
20
+ ret = getLabel(CF_DICCTIONARY.LABEL_SOUTH_EAST);
21
+ } else {
22
+ ret = getLabel(CF_DICCTIONARY.LABEL_EAST);
23
+ }
24
+ return ret;
25
+ };
26
+ export {
27
+ getCardinalDirection as g
28
+ };
@@ -1 +1,3 @@
1
- export declare const CFRootStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof import('react').ClassAttributes<HTMLSpanElement> | keyof import('react').HTMLAttributes<HTMLSpanElement>>, {}>;
1
+ export declare const CFRootStyled: 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('../types').CourseFormatterOwnerState> & Record<string, unknown> & {
2
+ ownerState: Partial<import('../types').CourseFormatterOwnerState> & Record<string, unknown>;
3
+ }, {}, {}>;
@@ -1,8 +1,9 @@
1
1
  import { styled } from "@mui/material/styles";
2
2
  import { C as COMPONET_KEY_COMPONENT } from "../constants.js";
3
3
  import { c as courseFormatterStyles } from "../CourseFormatter.styles.js";
4
- import { C as CourseFormatterSlots } from "./slots.js";
5
- const CFRootStyled = styled("span", {
4
+ import { C as CourseFormatterSlots } from "./CourseFormatterEnum.js";
5
+ import { T as Typography } from "../../../mui_extended/Typography/Typography.js";
6
+ const CFRootStyled = styled(Typography, {
6
7
  name: COMPONET_KEY_COMPONENT,
7
8
  slot: CourseFormatterSlots.root
8
9
  })(courseFormatterStyles?.root);
@@ -1,18 +1,24 @@
1
1
  import { Theme } from '@mui/material/styles';
2
2
  import { COMPONET_KEY_COMPONENT } from './constants';
3
- import { CourseFormatterSlots } from './slots/slots';
3
+ import { CourseFormatterSlots } from './slots/CourseFormatterEnum';
4
4
  import { OverridesStyleRules } from '@mui/material/styles/overrides';
5
+ import { Sizes } from '@m4l/styles';
5
6
  export type CourseFormatterProps = {
6
- /**
7
- * "course" curso sobre tierra donde el norte es 0 grados, y el sur es 180 grados.
8
- */
7
+ /** "course" curso sobre tierra donde el norte es 0 grados, y el sur es 180 grados en sentido horario */
9
8
  course: number;
10
- /**
11
- * "gapAngle" es el angulo que permite definir un estado Norte,Este,Oeste,etc no necesariamente
12
- * por que el valor es exacto, si no por que se encuentra en un rango de valores, dado por el gap.
13
- */
9
+ /** "gapAngle" es el angulo que permite definir un estado Norte,Este,Oeste,etc no necesariamente por que el valor es exacto, si no por que se encuentra en un rango de valores, dado por el gap. */
14
10
  gapAngle?: number;
11
+ /** Define el tamaño de la etiqueta. Puede ser 'small' o 'medium'. Por defecto es 'medium'. */
12
+ size?: Extract<Sizes, 'small' | 'medium'>;
13
+ /** Define el tamaño del skeleton. */
14
+ skeletonWidth?: string | number;
15
+ /** data-testid para pruebas unitarias. */
16
+ dataTestId?: string;
15
17
  };
16
18
  export type CourseFormatterSlotsType = keyof typeof CourseFormatterSlots;
17
- export type CourseFormatterOwnerState = {};
18
- export type CourseFormatterStyles = Partial<OverridesStyleRules<CourseFormatterSlotsType, typeof COMPONET_KEY_COMPONENT, Theme> | undefined> | undefined;
19
+ export type CourseFormatterOwnerState = {
20
+ variant: 'standard';
21
+ color?: 'default';
22
+ size?: Extract<Sizes, 'small' | 'medium'>;
23
+ };
24
+ export type CourseFormatterStyles = OverridesStyleRules<CourseFormatterSlotsType, typeof COMPONET_KEY_COMPONENT, Theme>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.1.114",
3
+ "version": "9.1.116",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0"
@@ -0,0 +1,25 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { CourseFormatter } from '../../../../src/components/formatters/CourseFormatter/CourseFormatter';
3
+ import { StoryCourseFormatterType } from './types';
4
+ declare const meta: Meta<typeof CourseFormatter>;
5
+ export default meta;
6
+ /**
7
+ * Norte: curso entre 95° - 85° -> 0°
8
+ */
9
+ export declare const Norte: StoryCourseFormatterType;
10
+ /**
11
+ * Oriente: curso entre 85° - 95° -> 90°
12
+ */
13
+ export declare const Oriente: StoryCourseFormatterType;
14
+ /**
15
+ * Sur: curso entre 175° - 185° -> 180°
16
+ */
17
+ export declare const Sur: StoryCourseFormatterType;
18
+ /**
19
+ * Occidente: curso entre 265° - 275° -> 270°
20
+ */
21
+ export declare const Occidente: StoryCourseFormatterType;
22
+ /**
23
+ * Skeleton del CourseFormatter
24
+ */
25
+ export declare const Esqueleto: StoryCourseFormatterType;
@@ -1,3 +1,3 @@
1
1
  import { StoryObj } from '@storybook/react';
2
- import { CourseFormatter } from '../CourseFormatter';
2
+ import { CourseFormatter } from '../../../../src/components/formatters/CourseFormatter/CourseFormatter';
3
3
  export type StoryCourseFormatterType = StoryObj<typeof CourseFormatter>;
@@ -1,45 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- import { CourseFormatter } from '../CourseFormatter';
3
- import { StoryCourseFormatterType } from './types';
4
- declare const meta: Meta<typeof CourseFormatter>;
5
- export default meta;
6
- /**
7
- * CourseFormatter , con Course: 3 grados -> 87 Grados cartesianos, gapAngle: 5grados
8
- *
9
- */
10
- export declare const BaseNorth: StoryCourseFormatterType;
11
- /**
12
- * CourseFormatter , con Course 25 grados -> 65 Grados cartesianos, gapAngle: 5grados
13
- *
14
- */
15
- export declare const BaseNorthEast: StoryCourseFormatterType;
16
- /**
17
- * CourseFormatter , con Course 87 grados -> 3 Grados cartesianos, gapAngle: 5grados
18
- *
19
- */
20
- export declare const BaseEast: StoryCourseFormatterType;
21
- /**
22
- * CourseFormatter , con Course 96 grados -> 65 Grados cartesianos, gapAngle: 5grados
23
- *
24
- */
25
- export declare const BaseSouthEast: StoryCourseFormatterType;
26
- /**
27
- * CourseFormatter , con Course 178 grados -> -78 Grados cartesianos, gapAngle: 5grados
28
- *
29
- */
30
- export declare const BaseSouth: StoryCourseFormatterType;
31
- /**
32
- * CourseFormatter , con Course 200 grados -> 250 Grados cartesianos, gapAngle: 5grados
33
- *
34
- */
35
- export declare const BaseSouthWest: StoryCourseFormatterType;
36
- /**
37
- * CourseFormatter , con Course 271 grados -> 179 Grados cartesianos, gapAngle: 5grados
38
- *
39
- */
40
- export declare const BaseWest: StoryCourseFormatterType;
41
- /**
42
- * CourseFormatter , con Course 325 grados -> 125 Grados cartesianos, gapAngle: 5grados
43
- *
44
- */
45
- export declare const BaseNorthWest: StoryCourseFormatterType;
@@ -1,5 +0,0 @@
1
- import { StoryContext, StoryFn } from '@storybook/react';
2
- /**
3
- * TODO: Documentar
4
- */
5
- export declare const WithCFProvider: (MyStory: StoryFn, { args }: StoryContext) => import("react/jsx-runtime").JSX.Element;