@devopness/ui-react 2.145.0

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/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Devopness UI - React
2
+
3
+ The official Devopness UI components for React
4
+
5
+ <!-- TODO: enable this section once package is available in npm registry
6
+
7
+ ## Usage
8
+
9
+ ### Install/Upgrade
10
+
11
+ Use your favourite package manager to install Devopness UI as a dependency of your project:
12
+
13
+ ```bash
14
+ # Using npm
15
+ npm install @devopness/ui-react
16
+
17
+ # Using yarn
18
+ yarn add @devopness/ui-react
19
+ ```
20
+
21
+ -->
22
+
23
+ ## Dependencies
24
+
25
+ This component library uses:
26
+
27
+ - โš›๏ธ [React](https://react.dev/) โ€” JavaScript library for user interfaces
28
+ - ๐Ÿ“– [Storybook](https://storybook.js.org/) โ€” Frontend workshop for UI development
29
+ - ๐Ÿ’… [Styled Components](https://styled-components.com/) - CSS-in-JS library for styling components
30
+ - โšก [Vite](https://vite.dev/) โ€” The build tool for the web
31
+ - ๐Ÿ“ฆ [SWC (Speedy Web Compiler)](https://swc.rs/) โ€” Rust based compiler used to speed up Vite dev server
32
+ - ๐Ÿงช [Vitest](https://vitest.dev/) โ€” Vite-native testing framework
33
+ - ๐Ÿ™ [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) - A light-weight solution for testing React components
34
+
35
+ As well as a few others tools configured:
36
+
37
+ - [TypeScript](https://www.typescriptlang.org/) for static type checking
38
+ - [ESLint](https://eslint.org/) for code linting
39
+ - [Prettier](https://prettier.io) for code formatting
40
+
41
+ ## Development & Testing
42
+
43
+ Installing on `Linux` or `macOS` systems.
44
+
45
+ #### 1. Navigate to the project directory
46
+
47
+ ```shell
48
+ cd packages/ui/react/
49
+ ```
50
+
51
+ #### 2. Install missing dependencies
52
+
53
+ This command will install all modules listed as dependencies in [package.json](package.json).
54
+
55
+ ```
56
+ npm install
57
+ ```
58
+
59
+ #### 3. Build UI package
60
+
61
+ ```
62
+ npm run build
63
+ ```
64
+
65
+ #### 4. Run tests
66
+
67
+ ```
68
+ npm run test
69
+ ```
70
+
71
+ #### 5. Run storybook
72
+
73
+ ```
74
+ npm run storybook
75
+ ```
@@ -0,0 +1,127 @@
1
+ import { Flatten } from './types';
2
+ declare const colors: {
3
+ readonly amber: {
4
+ readonly 800: "#a39015";
5
+ readonly 500: "#fab01c";
6
+ readonly 400: "#fdb762";
7
+ readonly 300: "#fdd88e";
8
+ readonly 200: "#fee2c0";
9
+ readonly 150: "#feebc6";
10
+ readonly 100: "#fff1e0";
11
+ readonly 50: "#fff6ef";
12
+ readonly 10: "#fffcf5";
13
+ };
14
+ readonly black: "#000000";
15
+ readonly blue: {
16
+ readonly 950: "#2e374e";
17
+ readonly 800: "#2e364e";
18
+ readonly 750: "#37436b";
19
+ readonly 700: "#0064a5";
20
+ readonly 600: "#016ee9";
21
+ readonly 500: "#0496f5";
22
+ readonly 400: "#96c7fe";
23
+ readonly 300: "#b9daff";
24
+ readonly 100: "#dcecff";
25
+ readonly 50: "#e8f6ff";
26
+ readonly 25: "#eef2ff";
27
+ };
28
+ readonly brown: {
29
+ readonly 400: "#b5a7a2";
30
+ readonly 50: "#faf8f1";
31
+ };
32
+ readonly cyan: {
33
+ readonly 800: "#537e8c";
34
+ readonly 400: "#00d7d7";
35
+ readonly 300: "#02e0d1";
36
+ readonly 200: "#e0f7fa";
37
+ readonly 100: "#ebfafb";
38
+ readonly 50: "#f6fffe";
39
+ };
40
+ readonly fuchsia: {
41
+ readonly 600: "#d000ff";
42
+ readonly 10: "#fdf5ff";
43
+ };
44
+ readonly gray: {
45
+ readonly 900: "#42495a";
46
+ readonly 800: "#828795";
47
+ readonly 615: "#9198a5";
48
+ readonly 600: "#9196a4";
49
+ readonly 500: "#b0b3bc";
50
+ readonly 400: "#afb8c9";
51
+ readonly 300: "#bdc4d3";
52
+ readonly 200: "#f3f7fe";
53
+ };
54
+ readonly green: {
55
+ readonly 800: "#57b261";
56
+ readonly 600: "#0cd356";
57
+ readonly 300: "#9eedbb";
58
+ readonly 200: "#b6f2cc";
59
+ readonly 150: "#cef6dd";
60
+ readonly 125: "#effff1";
61
+ readonly 100: "#edf9ee";
62
+ };
63
+ readonly indigo: {
64
+ readonly 100: "#f5f6ff";
65
+ readonly 50: "#f6f8ff";
66
+ readonly 10: "#f8faff";
67
+ };
68
+ readonly orange: {
69
+ readonly 700: "#f89532";
70
+ readonly 600: "#ff8700";
71
+ readonly 500: "#f8bf4d";
72
+ readonly 400: "#fdba62";
73
+ readonly 100: "#f6f4e7";
74
+ readonly 50: "#fff6f0";
75
+ readonly 10: "#fff9f0";
76
+ };
77
+ readonly purple: {
78
+ readonly 800: "#786efd";
79
+ readonly 400: "#cac7fc";
80
+ readonly 300: "#dfe4fd";
81
+ readonly 275: "#dfe6ff";
82
+ readonly 250: "#e6ecff";
83
+ readonly 100: "#f2f1ff";
84
+ readonly 50: "#f2f2fa";
85
+ };
86
+ readonly red: {
87
+ readonly 500: "#fd595c";
88
+ readonly 450: "#ff6666";
89
+ readonly 400: "#f67771";
90
+ readonly 300: "#febdbe";
91
+ readonly 200: "#fecdce";
92
+ readonly 150: "#ffdede";
93
+ readonly 100: "#ffe8e8";
94
+ readonly 50: "#fff3f3";
95
+ };
96
+ readonly slate: {
97
+ readonly 600: "#4a526a";
98
+ readonly 450: "#72798f";
99
+ readonly 400: "#abb4c5";
100
+ readonly 300: "#e3e8f9";
101
+ };
102
+ readonly stone: {
103
+ readonly 100: "#f6f6f6";
104
+ readonly 50: "#edf2f3";
105
+ };
106
+ readonly transparent: "transparent";
107
+ readonly white: "#ffffff";
108
+ readonly yellow: {
109
+ readonly 300: "#fff793";
110
+ };
111
+ };
112
+ /**
113
+ * Maps Color paths on format <color>.<shade> to its value in hex, based on colors object
114
+ */
115
+ type ColorToHexMapper = Flatten<typeof colors>;
116
+ /**
117
+ * Lists all valid color codes, following format <color>.<shade>
118
+ */
119
+ type Color = keyof ColorToHexMapper;
120
+ /**
121
+ * Gets the color' hex value
122
+ *
123
+ * @param name Color name on format <color>.<shade>
124
+ */
125
+ declare const getColor: <TColor extends Color>(name: TColor) => ColorToHexMapper[TColor];
126
+ export type { Color };
127
+ export { getColor };
@@ -0,0 +1,2 @@
1
+ export * from './getColor';
2
+ export * from './types';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Flatten an object while retaining types for all paths
3
+ *
4
+ * The mapped type keys are useful to work with loadash.get
5
+ *
6
+ * Examples:
7
+ *
8
+ * Flatten<{ red: 'red', green: { 50: 'light-green' }}>
9
+ * // ^? { red: 'red', 'green.50': 'light-green' }
10
+ *
11
+ * @see {@link https://docs-lodash.com/v4/get/}
12
+ *
13
+ * Code obtained from StackOverflow: https://stackoverflow.com/a/66620803
14
+ * Source code from jcalz @ https://stackoverflow.com/users/2887218/jcalz
15
+ */
16
+ type Flatten<T extends object> = object extends T ? object : {
17
+ [K in keyof T]-?: (x: NonNullable<T[K]> extends infer V ? V extends object ? V extends readonly unknown[] ? Pick<T, K> : Flatten<V> extends infer FV ? {
18
+ [P in keyof FV as `${Extract<K, string | number>}.${Extract<P, string | number>}`]: FV[P];
19
+ } : never : Pick<T, K> : never) => void;
20
+ } extends Record<keyof T, (y: infer O) => void> ? O extends infer _ ? {
21
+ [K in keyof O]: O[K];
22
+ } : never : never;
23
+ export type { Flatten };
@@ -0,0 +1,64 @@
1
+ import { ButtonHTMLAttributes } from 'react';
2
+ import { getColor } from 'src/colors';
3
+ import { Icon } from 'src/icons';
4
+ type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
5
+ /**
6
+ * By default the button component is 34px high, the "typeSize" property contains
7
+ * the "medium" variation that changes to 27px
8
+ */
9
+ typeSize?: 'default' | 'medium' | 'auto';
10
+ /** Icon name */
11
+ icon?: Icon;
12
+ /** Enable button loading animation */
13
+ loading?: boolean;
14
+ /**
15
+ * With the property "revertOrientation" it is possible to change the positioning of
16
+ * the elements inside the button as "icon" or "loading"
17
+ */
18
+ revertOrientation?: boolean;
19
+ /** Predefined style variations for the button */
20
+ buttonType?: 'borderless' | 'outlinedSecondary' | 'outlinedAuxiliary' | 'Default';
21
+ /** `Warning`: This property overrides the style defined by the `buttonType` property!
22
+ *
23
+ * Customize elements color
24
+ */
25
+ color?: string;
26
+ /** `Warning`: This property overrides the style defined by the `buttonType` property!
27
+ *
28
+ * Customize background color
29
+ */
30
+ backgroundColor?: string;
31
+ /** `Warning`: This property overrides the style defined by the `buttonType` property!
32
+ *
33
+ * Customize border color
34
+ */
35
+ borderColor?: string;
36
+ /**
37
+ * The button component has a 15px margin on its sides, to remove activate the "noMargin" property
38
+ */
39
+ noMargin?: boolean;
40
+ /**
41
+ * The button component has a 10px margin on its sides, to remove activate the "noIconMargin" property
42
+ */
43
+ noIconMargin?: boolean;
44
+ /**
45
+ * The button component has a 15px padding on its sides, to remove activate the "noPadding" property
46
+ */
47
+ noPadding?: boolean;
48
+ /**
49
+ * It should be true if the button is wrapped in a tooltip
50
+ */
51
+ noPointerEvents?: boolean;
52
+ /**
53
+ * By default the icon component is 16px high, use this prop to customize "iconSize"
54
+ */
55
+ iconSize?: number;
56
+ /**
57
+ * By default the icon color is primary, use this prop to customize "iconColor"
58
+ */
59
+ iconColor?: ReturnType<typeof getColor>;
60
+ };
61
+ /** Primary UI component for user interaction */
62
+ declare const Button: ({ type, typeSize, buttonType, color, backgroundColor, borderColor, disabled, onClick, tabIndex, loading: isLoading, icon, children, revertOrientation, noMargin, noIconMargin, noPointerEvents, iconSize, iconColor, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
63
+ export type { ButtonProps };
64
+ export { Button };
@@ -0,0 +1,26 @@
1
+ import { ButtonProps } from '.';
2
+ type CustomButton = {
3
+ backgroundColor?: string;
4
+ color?: string;
5
+ borderColor?: string;
6
+ };
7
+ type StyledProps = {
8
+ noMargin?: boolean;
9
+ noPadding?: boolean;
10
+ size: NonNullable<ButtonProps['typeSize']>;
11
+ variant?: string;
12
+ custom?: CustomButton;
13
+ icon?: boolean;
14
+ alignEnd?: boolean;
15
+ reversed: boolean;
16
+ noPointerEvents?: boolean;
17
+ };
18
+ declare const ContentIcon: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<ButtonProps, "noIconMargin"> & {
19
+ reversed: ButtonProps["revertOrientation"];
20
+ size: Required<ButtonProps["iconSize"]>;
21
+ }>> & string;
22
+ declare const Label: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
23
+ declare const WrapperButtons: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledProps>> & string;
24
+ declare const BaseButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, StyledProps>> & string;
25
+ declare const SmallWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledProps>> & string;
26
+ export { ContentIcon, Label, WrapperButtons, BaseButton, SmallWrapper };
@@ -0,0 +1 @@
1
+ export * from './Button';
@@ -0,0 +1 @@
1
+ export * from './Button';
@@ -0,0 +1,41 @@
1
+ import { TooltipProps } from '@mui/material/Tooltip';
2
+ type Nullable<T extends object> = {
3
+ [K in keyof T]: T[K] | null | undefined;
4
+ };
5
+ type TooltipComponentProps = {
6
+ /**
7
+ * Tooltip reference element.
8
+ */
9
+ children: React.ReactNode;
10
+ /**
11
+ * Define component styles
12
+ */
13
+ styles?: {
14
+ /**
15
+ * Tooltip background color.
16
+ * (Does not work with JSX children)
17
+ */
18
+ backgroundColor?: string;
19
+ /**
20
+ * font color
21
+ */
22
+ color?: string;
23
+ };
24
+ /**
25
+ * If `true`, hover in the tooltip is disabled.
26
+ */
27
+ disableHover?: boolean;
28
+ /**
29
+ * If `true`, hover in the tooltip is disabled and enabled only when the
30
+ * element reaches the limit of the width of the contained element.
31
+ */
32
+ enableOnlyWithEllipsisPoints?: boolean;
33
+ /**
34
+ * It should be defined when the component is going to be used
35
+ * in the controlled way
36
+ */
37
+ open?: boolean;
38
+ } & Omit<TooltipProps, 'title' | 'children'> & Nullable<Pick<TooltipProps, 'title'>>;
39
+ /** Display informative text when users hover over a child element */
40
+ declare const Tooltip: ({ disableHover, enableOnlyWithEllipsisPoints, title, children, ...props }: TooltipComponentProps) => import("react/jsx-runtime").JSX.Element;
41
+ export { Tooltip };
@@ -0,0 +1,2 @@
1
+ declare const ContentChildren: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
2
+ export { ContentChildren };
@@ -0,0 +1 @@
1
+ export * from './Tooltip';
@@ -0,0 +1 @@
1
+ export * from './Tooltip';
@@ -0,0 +1,20 @@
1
+ type TabsProps = {
2
+ /**
3
+ * Tabs to be rendered
4
+ *
5
+ * - When data has only one tab, Tabs selector becomes hidden
6
+ * - When data is empty, this component returns null
7
+ */
8
+ data: {
9
+ label: string;
10
+ component: React.ReactNode;
11
+ }[];
12
+ currentTabIndex: number;
13
+ onTabClick?: (event: {
14
+ index: number;
15
+ label: string;
16
+ }) => void;
17
+ };
18
+ /** Switch between different views on the same page */
19
+ declare const Tabs: ({ data: tabsData, currentTabIndex, onTabClick, }: TabsProps) => string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import('react').ReactNode> | null | undefined;
20
+ export { Tabs };
@@ -0,0 +1,7 @@
1
+ declare const StyledTabs: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('@mui/material').TabsOwnProps & import('@mui/material/OverridableComponent').CommonProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
2
+ ref?: ((instance: HTMLDivElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLDivElement> | null | undefined;
3
+ }, "value" | "className" | "style" | "aria-label" | "aria-labelledby" | "children" | "onChange" | "variant" | "action" | "orientation" | "classes" | "slotProps" | "slots" | "sx" | "allowScrollButtonsMobile" | "centered" | "indicatorColor" | "ScrollButtonComponent" | "scrollButtons" | "selectionFollowsFocus" | "TabIndicatorProps" | "TabScrollButtonProps" | "textColor" | "visibleScrollbar">, never>> & string & Omit<import('@mui/material/OverridableComponent').OverridableComponent<import('@mui/material').TabsTypeMap<{}, "div">>, keyof import('react').Component<any, {}, any>>;
4
+ declare const StyledTab: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('@mui/material').TabOwnProps & Omit<import('@mui/material').ButtonBaseOwnProps, "classes"> & import('@mui/material/OverridableComponent').CommonProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
5
+ ref?: ((instance: HTMLDivElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLDivElement> | null | undefined;
6
+ }, "disabled" | "value" | "className" | "style" | "tabIndex" | "children" | "icon" | "label" | "action" | "classes" | "sx" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "iconPosition" | "wrapped">, never>> & string & Omit<import('@mui/material').ExtendButtonBase<import('@mui/material').TabTypeMap<{}, "div">>, keyof import('react').Component<any, {}, any>>;
7
+ export { StyledTabs, StyledTab };
@@ -0,0 +1 @@
1
+ export * from './Tabs';
@@ -0,0 +1 @@
1
+ export * from './Tabs';
@@ -0,0 +1,3 @@
1
+ export * from './Buttons';
2
+ export * from './Primitives';
3
+ export * from './Templates';
@@ -0,0 +1,15 @@
1
+ declare const fonts: {
2
+ readonly roboto: "Roboto";
3
+ readonly montserrat: "Montserrat";
4
+ readonly mono: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace";
5
+ };
6
+ /**
7
+ * Lists all valid font codes
8
+ */
9
+ type Font = keyof typeof fonts;
10
+ /**
11
+ * Gets the font' CSS Font Family list
12
+ */
13
+ declare const getFont: <TFont extends Font>(name: TFont) => (typeof fonts)[TFont];
14
+ export type { Font };
15
+ export { getFont };
@@ -0,0 +1 @@
1
+ export * from './getFont';
@@ -0,0 +1 @@
1
+ export * from './useWindowSize';
@@ -0,0 +1,2 @@
1
+ declare const useWindowSize: () => number[];
2
+ export { useWindowSize };
@@ -0,0 +1,5 @@
1
+ declare const CircleBubble: ({ color, size }: {
2
+ color: string;
3
+ size: number;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export { CircleBubble };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get URL for the given image asset on Devopness' CDN.
3
+ *
4
+ * @param imageAssetPath - Image asset path relative to CDN /images/ path.
5
+ */
6
+ declare function getImageAssetUrl(imageAssetPath: string): string;
7
+ export { getImageAssetUrl };