@takaro/lib-components 0.0.11 → 0.0.13

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takaro/lib-components",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "private": false,
5
5
  "description": "Takaro UI is a simple and customizable component library to build React apps faster within the Takaro eco system",
6
6
  "license": "AGPL-3.0-or-later",
@@ -15,58 +15,58 @@
15
15
  "test:update": "jest --updateSnapshot"
16
16
  },
17
17
  "devDependencies": {
18
- "@hookform/devtools": "^4.2.2",
19
- "@mdx-js/react": "^2.1.5",
20
- "@types/jest": "^29.0.0",
21
- "@types/react-window": "^1.8.5",
22
- "@types/styled-components": "^5.1.25",
23
- "@types/topojson-client": "^3.1.4",
24
- "react": "^18.2.0",
25
- "react-dom": "^18.2.0",
18
+ "@hookform/devtools": "4.3.1",
19
+ "@mdx-js/react": "3.0.1",
20
+ "@types/jest": "29.5.13",
21
+ "@types/react-window": "1.8.8",
22
+ "@types/styled-components": "5.1.34",
23
+ "@types/topojson-client": "3.1.5",
24
+ "react": "18.3.1",
25
+ "react-dom": "18.3.1",
26
26
  "storybook": "7.6.20"
27
27
  },
28
28
  "peerDependencies": {
29
- "@floating-ui/react": "^0.24.0 || ^0.26.0",
30
- "@monaco-editor/react": "^4.4.6",
31
- "@rjsf/core": "^5.6.2",
32
- "@rjsf/utils": "^5.6.2",
33
- "@rjsf/validator-ajv8": "^5.6.2",
34
- "@tanstack/react-table": "^8.7.9",
35
- "@tanstack/react-router": "1.35.3",
29
+ "@floating-ui/react": "0.26.24",
30
+ "@monaco-editor/react": "4.6.0",
31
+ "@rjsf/core": "5.20.0",
32
+ "@rjsf/utils": "5.20.0",
33
+ "@rjsf/validator-ajv8": "5.20.0",
34
+ "@tanstack/react-table": "8.20.5",
35
+ "@tanstack/react-router": "1.58.15",
36
36
  "@types/luxon": "3.4.2",
37
- "framer-motion": "^10.16.12 || ^11.0.0",
37
+ "framer-motion": "11.9.0",
38
38
  "luxon": "3.5.0",
39
- "notistack": "^3.0.1",
40
- "polished": "^4.1.3",
41
- "react": "^18.2.0",
42
- "react-dnd": "^16.0.1",
43
- "@sentry/react": "^8.5.0",
44
- "react-dnd-html5-backend": "^16.0.1",
45
- "react-dom": "^18.2.0",
46
- "react-hook-form": "^7.50.1",
47
- "react-icons": "^4.11.0 || ^5.0.0",
48
- "react-intersection-observer": "^9.5.1",
49
- "react-virtualized-auto-sizer": "^1.0.9",
50
- "react-window": "^1.8.8",
51
- "simplebar-react": "^3.2.4",
52
- "styled-components": "^5.3.5",
53
- "web-vitals": "^2.1.2 || ^4.0.0",
54
- "@visx/scale": "^3.5.0",
55
- "@visx/responsive": "^3.3.0",
56
- "@visx/group": "^3.3.0",
57
- "@visx/heatmap": "^3.3.0",
58
- "@visx/tooltip": "^3.3.0",
59
- "@visx/event": "^3.3.0",
60
- "@visx/shape": "^3.5.0",
61
- "@visx/grid": "^3.5.0",
62
- "@visx/vendor": "^3.5.0",
63
- "@visx/brush": "^3.6.1",
64
- "@visx/axis": "^3.5.0",
39
+ "notistack": "3.0.1",
40
+ "polished": "4.3.1",
41
+ "react": "18.3.1",
42
+ "react-dnd": "16.0.1",
43
+ "@sentry/react": "8.32.0",
44
+ "react-dnd-html5-backend": "16.0.1",
45
+ "react-dom": "18.3.1",
46
+ "react-hook-form": "7.53.0",
47
+ "react-icons": "5.3.0",
48
+ "react-intersection-observer": "9.13.1",
49
+ "react-virtualized-auto-sizer": "1.0.24",
50
+ "react-window": "1.8.10",
51
+ "simplebar-react": "3.2.6",
52
+ "styled-components": "5.3.11",
53
+ "web-vitals": "4.2.3",
54
+ "@visx/scale": "3.5.0",
55
+ "@visx/responsive": "3.10.2",
56
+ "@visx/group": "3.3.0",
57
+ "@visx/heatmap": "3.3.0",
58
+ "@visx/tooltip": "3.3.0",
59
+ "@visx/event": "3.3.0",
60
+ "@visx/shape": "3.5.0",
61
+ "@visx/grid": "3.5.0",
62
+ "@visx/vendor": "3.5.0",
63
+ "@visx/brush": "3.10.4",
64
+ "@visx/axis": "3.10.1",
65
65
  "@visx/pattern": "3.3.0",
66
- "@visx/curve": "^3.3.0",
67
- "@visx/gradient": "^3.3.0",
68
- "@visx/mock-data": "^3.3.0",
66
+ "@visx/curve": "3.3.0",
67
+ "@visx/gradient": "3.3.0",
68
+ "@visx/mock-data": "3.3.0",
69
69
  "@visx/geo": "3.5.0",
70
- "topojson-client": "^3.1.0"
70
+ "topojson-client": "3.1.0"
71
71
  }
72
72
  }
@@ -1,5 +1,6 @@
1
1
  import { cloneElement, forwardRef, ReactElement } from 'react';
2
2
  import { Color, Size } from '../../../styled/types';
3
+ import { Badge } from '../../../components';
3
4
  import { Default } from './style';
4
5
 
5
6
  export interface IconButtonProps {
@@ -35,7 +36,7 @@ export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(functio
35
36
  return (
36
37
  <Default type="button" color={color} onClick={onClick} ref={ref} disabled={disabled} aria-label={ariaLabel}>
37
38
  {cloneElement(icon, { size: getSize(size) })}
38
- {badge && <div>{badge}</div>}
39
+ {badge && <Badge>{badge}</Badge>}
39
40
  </Default>
40
41
  );
41
42
  });
@@ -51,25 +51,6 @@ export const Default = styled.button<{ color: Color }>`
51
51
  }
52
52
  }
53
53
 
54
- div {
55
- background-color: ${({ theme }) => theme.colors.background};
56
- color: ${({ theme }) => theme.colors.text};
57
- font-size: ${({ theme }) => theme.fontSize.tiny};
58
- font-weight: 600;
59
- border-radius: ${({ theme }) => theme.borderRadius.small};
60
- width: fit-content;
61
- height: 1.5rem;
62
- line-height: 1.1rem;
63
- display: flex;
64
- align-items: center;
65
- justify-content: center;
66
- position: absolute;
67
- top: -${({ theme }) => theme.spacing['0_75']};
68
- right: -${({ theme }) => theme.spacing['0_75']};
69
- padding: ${({ theme }) => theme.spacing['0_25']};
70
- border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
71
- }
72
-
73
54
  svg {
74
55
  cursor: pointer;
75
56
  fill: ${({ theme }) => theme.colors.text};
@@ -38,7 +38,7 @@ export interface TableProps<DataType extends object> {
38
38
  isLoading?: boolean;
39
39
 
40
40
  // currently not possible to type this properly: https://github.com/TanStack/table/issues/4241
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+
42
42
  columns: ColumnDef<DataType, any>[];
43
43
 
44
44
  /// Renders actions that are always visible
@@ -72,7 +72,7 @@ export function ColumnHeader<DataType extends object>({ header, table, isLoading
72
72
  const hoverMiddleX = (hoverBoundingRect.right - hoverBoundingRect.left) / 2;
73
73
 
74
74
  // Determine mouse position
75
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
75
+
76
76
  const clientOffset = monitor.getClientOffset()!;
77
77
 
78
78
  // Get pixels to the top
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Meta, StoryFn } from '@storybook/react';
3
+ import { Badge, BadgeProps } from '.';
4
+
5
+ export default {
6
+ title: 'Feedback/Badge',
7
+ component: Badge,
8
+ args: {
9
+ variant: 'warning',
10
+ animate: false,
11
+ },
12
+ } as Meta<BadgeProps>;
13
+
14
+ export const Default: StoryFn<BadgeProps> = (args) => (
15
+ <div>
16
+ <h2 style={{ backgroundColor: 'orange', position: 'relative', width: 'fit-content' }}>
17
+ this is the title{' '}
18
+ <Badge variant={args.variant} animate={args.animate}>
19
+ here
20
+ </Badge>
21
+ </h2>
22
+ </div>
23
+ );
@@ -0,0 +1,47 @@
1
+ import { forwardRef, PropsWithChildren } from 'react';
2
+ import { pulseAnimation, styled } from '../../../styled';
3
+ import { AlertVariants, Color } from '../../../styled';
4
+ import { shade } from 'polished';
5
+
6
+ type ColorVariant = AlertVariants | Color | 'default';
7
+
8
+ const Container = styled.div<{ variant: ColorVariant; animate: boolean }>`
9
+ background-color: ${({ theme, variant }) =>
10
+ variant === 'default' ? theme.colors.background : shade('0.8', theme.colors[variant])};
11
+ color: ${({ theme, variant }) => (variant === 'default' ? theme.colors.text : theme.colors[variant])};
12
+ font-size: ${({ theme }) => theme.fontSize.tiny};
13
+ font-weight: 600;
14
+ border-radius: ${({ theme }) => theme.borderRadius.small};
15
+ width: fit-content;
16
+ height: 1.5rem;
17
+ line-height: 1.1rem;
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ position: absolute;
22
+ top: -${({ theme }) => theme.spacing['1']};
23
+ right: -${({ theme }) => theme.spacing['0_75']};
24
+ padding: ${({ theme }) => theme.spacing['0_25']};
25
+ border: 1px solid
26
+ ${({ theme, variant }) => (variant === 'default' ? theme.colors.backgroundAccent : theme.colors[variant])};
27
+
28
+ animation: ${({ animate, variant, theme }) =>
29
+ animate ? pulseAnimation(variant === 'default' ? theme.colors.backgroundAccent : theme.colors[variant]) : 'none'}
30
+ 5s infinite ease-in-out;
31
+ `;
32
+
33
+ export interface BadgeProps {
34
+ variant?: ColorVariant;
35
+ animate?: boolean;
36
+ }
37
+
38
+ export const Badge = forwardRef<HTMLDivElement, PropsWithChildren<BadgeProps>>(function Badge(
39
+ { variant = 'default', children, animate = false },
40
+ ref,
41
+ ) {
42
+ return (
43
+ <Container ref={ref} variant={variant} animate={animate}>
44
+ {children}
45
+ </Container>
46
+ );
47
+ });
@@ -31,3 +31,6 @@ export type { ErrorPageProps } from './ErrorPage';
31
31
 
32
32
  export { FormError } from './FormError';
33
33
  export type { FormErrorProps } from './FormError';
34
+
35
+ export { Badge } from './Badge';
36
+ export type { BadgeProps } from './Badge';
@@ -3,6 +3,7 @@ import { DurationField, DurationFieldProps } from '../../../components';
3
3
  import { z } from 'zod';
4
4
  import { StoryFn, Meta } from '@storybook/react';
5
5
  import { useForm, SubmitHandler } from 'react-hook-form';
6
+ import { zodResolver } from '@hookform/resolvers/zod';
6
7
 
7
8
  export default {
8
9
  title: 'Inputs/DurationField',
@@ -26,7 +27,9 @@ export const Default: StoryFn<DurationFieldProps> = (args) => {
26
27
  duration: z.number().positive(),
27
28
  });
28
29
 
29
- const { control, handleSubmit } = useForm<z.infer<typeof validationSchema>>();
30
+ const { control, handleSubmit } = useForm<z.infer<typeof validationSchema>>({
31
+ resolver: zodResolver(validationSchema),
32
+ });
30
33
  const onSubmit: SubmitHandler<z.infer<typeof validationSchema>> = ({ duration }) => {
31
34
  setResult(duration);
32
35
  };
@@ -42,7 +42,6 @@ export const getLabelFromChildren = (children: ReactNode, value: string) => {
42
42
  }
43
43
  }
44
44
 
45
- // eslint-disable-next-line no-console
46
45
  console.error(
47
46
  `No label found for value ${value}. This occurs when a value is passed through the defaultValue prop of useForm, but the value is not present in the options.`,
48
47
  );
@@ -1,5 +1,6 @@
1
1
  // TODO: add custom replace option
2
2
  export function getInitials(name: string) {
3
+ if (!name) return '?';
3
4
  const replacedName = name.replace(/[._]/g, ' ');
4
5
  const parts = replacedName.split(' ');
5
6
 
@@ -8,7 +8,6 @@ export function useLocalStorage<T>(key: string, initialValue: T) {
8
8
  const item = window.localStorage.getItem(key);
9
9
  return item ? JSON.parse(item) : initialValue;
10
10
  } catch (e) {
11
- // eslint-disable-next-line no-console
12
11
  console.error('Error reading the local storage value', e);
13
12
  return initialValue;
14
13
  }
@@ -24,11 +23,9 @@ export function useLocalStorage<T>(key: string, initialValue: T) {
24
23
  } catch (e) {
25
24
  // DOMException code 22 for QuotaExceededError
26
25
  if (e instanceof DOMException && e.name === 'QuotaExceededError') {
27
- // eslint-disable-next-line no-console
28
26
  console.error('LocalStorage quota exceeded', e);
29
27
  setError(e);
30
28
  } else {
31
- // eslint-disable-next-line no-console
32
29
  console.error('Error setting the local storage value', e);
33
30
  }
34
31
  }