blue-react 10.2.0 → 11.0.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.
Files changed (76) hide show
  1. package/README.md +41 -84
  2. package/dist/components/A.js +13 -6
  3. package/dist/components/ActionMenu.js +27 -22
  4. package/dist/components/Actions.js +30 -22
  5. package/dist/components/Button.d.ts +31 -0
  6. package/dist/components/Button.js +119 -0
  7. package/dist/components/Chevron.js +11 -9
  8. package/dist/components/HashRouter.js +9 -6
  9. package/dist/components/Header.js +5 -3
  10. package/dist/components/HeaderTitle.js +31 -26
  11. package/dist/components/IconMenuItem.d.ts +2 -2
  12. package/dist/components/IconMenuItem.js +17 -10
  13. package/dist/components/Intro.js +23 -17
  14. package/dist/components/Layout.js +79 -71
  15. package/dist/{types/components/MenuItem.d.ts → components/LegacyMenuItem.d.ts} +150 -149
  16. package/dist/components/LegacyMenuItem.js +170 -0
  17. package/dist/components/MenuItem.d.ts +13 -149
  18. package/dist/components/MenuItem.js +168 -153
  19. package/dist/components/Modal.js +62 -49
  20. package/dist/components/ModalProvider.js +43 -35
  21. package/dist/components/Outside.js +5 -3
  22. package/dist/components/Search.js +69 -60
  23. package/dist/components/SidebarMenu.js +9 -6
  24. package/dist/components/SimpleLayout.js +16 -11
  25. package/dist/components/SlimContainer.js +8 -5
  26. package/dist/components/Status.js +56 -40
  27. package/dist/components/StatusProvider.js +22 -14
  28. package/dist/components/Tab.js +28 -19
  29. package/dist/components/Tabs.js +8 -5
  30. package/dist/components/ToastProvider.js +55 -44
  31. package/dist/components/shared.js +4 -1
  32. package/index.d.ts +5 -5
  33. package/index.js +4 -2
  34. package/package.json +14 -12
  35. package/dist/components/ActionMenuItem.js +0 -73
  36. package/dist/components/ActionMenuSwitch.js +0 -44
  37. package/dist/components/Body.d.ts +0 -21
  38. package/dist/components/Body.js +0 -25
  39. package/dist/components/Caret.js +0 -25
  40. package/dist/components/Layout/LayoutHeader.d.ts +0 -4
  41. package/dist/components/Layout/LayoutHeader.js +0 -25
  42. package/dist/components/Layout/LayoutMain.d.ts +0 -5
  43. package/dist/components/Layout/LayoutMain.js +0 -17
  44. package/dist/components/Page.d.ts +0 -13
  45. package/dist/components/Page.js +0 -39
  46. package/dist/components/SidebarMenuItem.js +0 -115
  47. package/dist/components/SidebarToggler.d.ts +0 -11
  48. package/dist/components/SidebarToggler.js +0 -24
  49. package/dist/components/Switch.js +0 -65
  50. package/dist/types/components/A.d.ts +0 -9
  51. package/dist/types/components/ActionMenu.d.ts +0 -25
  52. package/dist/types/components/ActionMenuItem.d.ts +0 -35
  53. package/dist/types/components/ActionMenuSwitch.d.ts +0 -12
  54. package/dist/types/components/Body.d.ts +0 -21
  55. package/dist/types/components/Caret.d.ts +0 -18
  56. package/dist/types/components/Chevron.d.ts +0 -17
  57. package/dist/types/components/Header.d.ts +0 -8
  58. package/dist/types/components/HeaderTitle.d.ts +0 -40
  59. package/dist/types/components/IconMenuItem.d.ts +0 -19
  60. package/dist/types/components/Intro.d.ts +0 -23
  61. package/dist/types/components/Layout.d.ts +0 -144
  62. package/dist/types/components/Modal.d.ts +0 -30
  63. package/dist/types/components/ModalProvider.d.ts +0 -21
  64. package/dist/types/components/Outside.d.ts +0 -17
  65. package/dist/types/components/Page.d.ts +0 -12
  66. package/dist/types/components/Search.d.ts +0 -36
  67. package/dist/types/components/SidebarMenu.d.ts +0 -32
  68. package/dist/types/components/SidebarMenuItem.d.ts +0 -22
  69. package/dist/types/components/SidebarToggler.d.ts +0 -10
  70. package/dist/types/components/SlimContainer.d.ts +0 -10
  71. package/dist/types/components/Status.d.ts +0 -12
  72. package/dist/types/components/StatusProvider.d.ts +0 -15
  73. package/dist/types/components/Switch.d.ts +0 -33
  74. package/dist/types/components/ToastProvider.d.ts +0 -22
  75. package/dist/types/components/Utilities.d.ts +0 -41
  76. package/dist/types/components/shared.d.ts +0 -15
@@ -1,144 +0,0 @@
1
- import { Component, CSSProperties } from "react";
2
- declare global {
3
- interface Window {
4
- blueLayoutRef: any;
5
- toggleSidebarEvent: any;
6
- }
7
- }
8
- export interface LayoutProps {
9
- id?: string;
10
- /**
11
- * By default, the side bar is "in".
12
- * You can control the state from outside, by also using `onChangeSidebarIn`.
13
- */
14
- sidebarIn?: boolean;
15
- /**
16
- * React to changes of the `sidebarIn` state.
17
- */
18
- onChangeSidebarIn?: (sidebarIn: boolean) => void;
19
- style?: CSSProperties;
20
- /**
21
- * Set `true` to hide button to toggle `expandSidebar` state.
22
- */
23
- hideToggleExpandSidebar?: boolean;
24
- /**
25
- * Sidebar is automatically expanded on wider views.
26
- */
27
- expandSidebar?: boolean;
28
- /**
29
- * React to changes of the `expandSidebar` state.
30
- */
31
- onChangeExpandSidebar?: (expandSidebar: boolean) => void;
32
- /**
33
- * Disables sidebar.
34
- */
35
- hideSidebarMenu?: boolean;
36
- /**
37
- * Registers pages for the built-in routing system. Example: `[{name: "home", component: <HomePage />}]`
38
- */
39
- pages?: {
40
- name: string;
41
- component: JSX.Element;
42
- }[];
43
- /**
44
- * When `true`, always the "home" route will be rendered.
45
- */
46
- unrouteable?: boolean;
47
- /**
48
- * Extends `className`.
49
- */
50
- className?: string;
51
- /**
52
- * By default, the document title will automatically set. Set this prop to `true` to disable this behaviour.
53
- */
54
- disableTitleSet?: boolean;
55
- /**
56
- * If you don't use blueicon, you can define another icon element for the sidebar toggle button.
57
- */
58
- sidebarToggleIconComponent?: any;
59
- /**
60
- * Set `true` if you want to use the Utilities functions for status and alert.
61
- * Set `false` if you want to use `StatusProvider` instead.
62
- */
63
- enableStatus?: boolean;
64
- /**
65
- * Will replace status icons with custom ones. This will also overwrite the `useBlueicons` option.
66
- * This can be a SVG component or a normal element component.
67
- */
68
- statusIcons?: {
69
- danger: any;
70
- info: any;
71
- success: any;
72
- warning: any;
73
- };
74
- /**
75
- * Disables the header bars on pages.
76
- */
77
- disableHeaders?: boolean;
78
- /**
79
- * Define a function, that will be fired when switching routes. When your function returns `true`, the default route behaviour will be blocked.
80
- * You can use something like `window.blueLayoutRef.setState({ blockRouting: onHashChange })` globally to set the value from anywhere in your app.
81
- */
82
- blockRouting?: (newMatch: string[], currentMatch: string[]) => void | boolean;
83
- children?: any;
84
- }
85
- export interface LayoutState {
86
- sidebarIn: boolean;
87
- expandSidebar: boolean;
88
- match: any;
89
- history: string[];
90
- hash: string;
91
- hashHistory: string[];
92
- blockRouting?: (newMatch: string[], currentMatch: string[]) => void | boolean;
93
- }
94
- /**
95
- * The main component. As soon this component is mounted, it is globally available under `window.blueLayoutRef`.
96
- * You can also append your own event listeners.
97
- *
98
- * Allowed events:
99
- *
100
- * * **componentDidUpdate** - Component was updated.
101
- * Example: `window.blueLayoutRef.addEventListener("componentDidUpdate", (prevProps, prevState) => { })`
102
- * * **pageDidShowAgain** - Page appeared again with the same old state. In the callback function you can reinitialize things.
103
- * Example: `window.blueLayoutRef.addEventListener("pageDidShowAgain", "home", (prevProps, prevState) => { })`
104
- * * **pageDidHide** - This page disappeared and another page appears instead.
105
- * Example: `window.blueLayoutRef.addEventListener("pageDidHide", "home", (prevProps, prevState) => { })`
106
- *
107
- * Method to add event listeners:
108
- * * `window.blueLayoutRef.`**addEventListener**`(eventName: string, param2: any, param3: any, listenerId?: string)`
109
- *
110
- * Methods to remove event listeners:
111
- * * `window.blueLayoutRef.`**removeEventListener**`(eventName: string, listenerId: string)`
112
- * * `window.blueLayoutRef.`**removeDuplicatedEventListeners**`()` - Will automatically be called when running `addEventListener`
113
- */
114
- export default class Layout extends Component<LayoutProps, LayoutState> {
115
- defaultMatch: string[];
116
- eventListeners: any[];
117
- constructor(props: LayoutProps);
118
- onHashChange(): void;
119
- static get defaultProps(): {
120
- hideSidebarMenu: boolean;
121
- unrouteable: boolean;
122
- disableTitleSet: boolean;
123
- sidebarToggleIconComponent: JSX.Element;
124
- enableStatus: boolean;
125
- statusIcons: {
126
- danger: JSX.Element;
127
- info: JSX.Element;
128
- success: JSX.Element;
129
- warning: JSX.Element;
130
- };
131
- hideToggleExpandSidebar: boolean;
132
- };
133
- componentDidMount(): void;
134
- componentWillUnmount(): void;
135
- componentDidUpdate(prevProps: LayoutProps, prevState: LayoutState): void;
136
- toggleSidebar(event: any): void;
137
- hideSidebar(e: any): void;
138
- initMatch(): void;
139
- addEventListener(param1: any, param2: any, param3: any, listenerId?: string): void;
140
- removeEventListener(type: string, listenerId: string): void;
141
- removeDuplicatedEventListeners(): void;
142
- toggleExpandSidebar(): void;
143
- render(): JSX.Element;
144
- }
@@ -1,30 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { ModalType } from "./shared";
3
- export interface ModalProps {
4
- modalContent?: string;
5
- modalTitle?: string;
6
- modalIcon?: ReactNode;
7
- unSetModalContent: (modalContent?: string) => void;
8
- /**
9
- * Type of `input` depends on `type` prop and which action occured.
10
- * When it's a string, the user entered something. When it's a boolean, the user clicked "Yes" or "No".
11
- * When it's `null`, the user cancelled the modal.
12
- */
13
- onSubmit?: (input: string | boolean | null) => void;
14
- defaultInput?: string;
15
- /**
16
- * `"ask"` | `"tell"` | `"verify"`
17
- */
18
- type: ModalType;
19
- inputType?: string;
20
- switchPrimaryBtn?: boolean;
21
- acceptBtnText?: string;
22
- cancelBtnText?: string;
23
- }
24
- /**
25
- * Simple modal/dialog. Designed to work as an alternative to JavaScript's native `alert()`, `prompt()` and `confirm()` functions.
26
- * It uses Bootstrap's Modal components.
27
- *
28
- * For easy use, you should use the hook `useModal` together with `ModalProvider`. See the example there.
29
- */
30
- export default function Modal({ modalContent, modalTitle, modalIcon, unSetModalContent, onSubmit, defaultInput, type, inputType, switchPrimaryBtn, acceptBtnText, cancelBtnText }: ModalProps): JSX.Element;
@@ -1,21 +0,0 @@
1
- import { ReactNode } from "react";
2
- interface ModelAlertOptions {
3
- title?: string;
4
- icon?: ReactNode;
5
- switchPrimaryBtn?: boolean;
6
- acceptBtnText?: string;
7
- cancelBtnText?: string;
8
- }
9
- interface ModelAskOptions extends ModelAlertOptions {
10
- inputType?: string;
11
- }
12
- export interface ModalProviderProps {
13
- children?: ReactNode;
14
- }
15
- declare const ModalProvider: ({ children, ...rest }: ModalProviderProps) => JSX.Element;
16
- declare const useModal: () => {
17
- ask: (text: string, options?: ModelAskOptions) => Promise<string | boolean>;
18
- tell: (text: string, options?: ModelAlertOptions) => Promise<boolean>;
19
- verify: (text: string, options?: ModelAlertOptions) => Promise<boolean>;
20
- };
21
- export { ModalProvider, useModal };
@@ -1,17 +0,0 @@
1
- import { CSSProperties, MouseEventHandler, MutableRefObject, RefObject } from "react";
2
- /**
3
- * Hook that alerts clicks outside of the passed ref
4
- */
5
- export declare function useOutside(ref: MutableRefObject<any>, callback?: (event: MouseEvent) => void): void;
6
- export interface OutsideProps {
7
- children: any;
8
- className?: string;
9
- onClickOutside?: (event: MouseEvent) => void;
10
- onClick?: MouseEventHandler<HTMLDivElement> | undefined;
11
- style?: CSSProperties;
12
- wrapperRef?: RefObject<HTMLDivElement>;
13
- }
14
- /**
15
- * Component that fires an event if you click outside of it
16
- */
17
- export default function Outside({ children, className, onClickOutside, onClick, style, wrapperRef }: OutsideProps): JSX.Element;
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- export interface PageProps {
3
- /**
4
- * Will be set to the document's `<title>` tag.
5
- */
6
- title?: string;
7
- children?: any;
8
- }
9
- /**
10
- * Main component for each page.
11
- */
12
- export default function Page({ children, title }: PageProps): JSX.Element;
@@ -1,36 +0,0 @@
1
- import React, { ReactNode, RefObject } from "react";
2
- export interface SearchProps {
3
- autoFocus?: boolean;
4
- /**
5
- * Is component inside of a page?
6
- */
7
- body?: boolean;
8
- className?: string;
9
- icon?: any;
10
- onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
11
- onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;
12
- placeholder?: string;
13
- /**
14
- * Allow reset?
15
- */
16
- reset?: boolean;
17
- /**
18
- * Define custom icon for the reset button.
19
- */
20
- resetIcon?: any;
21
- /**
22
- * Is component inside of the sidebar?
23
- */
24
- sidebar?: boolean;
25
- value?: string;
26
- children?: ReactNode;
27
- id?: string;
28
- /**
29
- * Set `ref` prop of the input element. Let's you take control of it from the outside, e.g. to set focus.
30
- */
31
- inputRef?: RefObject<HTMLInputElement>;
32
- }
33
- /**
34
- * A search bar that can be placed to the sidebar or on a page.
35
- */
36
- export default function Search(props: SearchProps): JSX.Element;
@@ -1,32 +0,0 @@
1
- /// <reference types="react" />
2
- export interface SidebarMenuProps {
3
- /**
4
- * Extends the class name by the sidebar.
5
- */
6
- sidebarClass?: string;
7
- /**
8
- * Sets the `style` prop by the sidebar.
9
- */
10
- sidebarStyle?: object;
11
- /**
12
- * Extends the class name by the menu.
13
- */
14
- menuClass?: string;
15
- /**
16
- * Sets the `style` prop by the menu.
17
- */
18
- menuStyle?: object;
19
- /**
20
- * Content on top of the menu.
21
- */
22
- topContent?: any;
23
- /**
24
- * Content for the bottom part of the sidebar.
25
- */
26
- bottomContent?: any;
27
- children?: any;
28
- }
29
- /**
30
- * Sidebar for the `Layout` component.
31
- */
32
- export default function SidebarMenu(props: SidebarMenuProps): JSX.Element;
@@ -1,22 +0,0 @@
1
- /// <reference types="react" />
2
- import { MenuItemProps } from "./MenuItem";
3
- export interface SidebarMenuItemProps extends MenuItemProps {
4
- outerClass?: string;
5
- }
6
- /**
7
- * @deprecated `MenuItem` now has all the features of `SidebarMenuItem`. Use `MenuItem` instead.
8
- * Extends `MenuItem` with following features:
9
- * * Shows provided label as tooltip if sidebar is closed.
10
- * * Children will be displayed on the right side of the parent item.
11
- *
12
- * **Important!** Set the following props to the surrounding `SidebarMenu` to provide problems with tooltips:
13
- * ```jsx
14
- * <SidebarMenu
15
- * sidebarClass="overflow-visible"
16
- * menuClass="overflow-visible"
17
- * >
18
- * ...
19
- * </SidebarMenu>
20
- * ```
21
- */
22
- export default function SidebarMenuItem({ outerClass, children, onClick, ...props }: SidebarMenuItemProps): JSX.Element;
@@ -1,10 +0,0 @@
1
- import { MouseEventHandler, ReactNode } from "react";
2
- export interface SidebarTogglerProps {
3
- className?: string;
4
- sidebarToggleIconComponent: ReactNode;
5
- onClick: MouseEventHandler<HTMLButtonElement>;
6
- }
7
- /**
8
- * Button to toggle sidebar state. Designed for internal use inside of `Layout`.
9
- */
10
- export default function SidebarToggler({ className, sidebarToggleIconComponent, onClick }: SidebarTogglerProps): JSX.Element;
@@ -1,10 +0,0 @@
1
- import { ReactNode } from "react";
2
- export interface SlimContainerProps {
3
- children?: ReactNode;
4
- className?: string;
5
- innerClassName?: string;
6
- }
7
- /**
8
- * Shortcut for a combination using Bootstrap's Grid System to create a slim responsive container.
9
- */
10
- export default function SlimContainer({ children, className, innerClassName }: SlimContainerProps): JSX.Element;
@@ -1,12 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { StatusAlert, StatusType } from "./shared";
3
- export interface StatusProps {
4
- alert?: StatusAlert;
5
- onUnsetAlert?: () => void;
6
- successIcon?: ReactNode;
7
- infoIcon?: ReactNode;
8
- warningIcon?: ReactNode;
9
- dangerIcon?: ReactNode;
10
- status?: StatusType;
11
- }
12
- export default function Status({ alert, onUnsetAlert, successIcon, infoIcon, warningIcon, dangerIcon, status }: StatusProps): JSX.Element;
@@ -1,15 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { StatusAlert, StatusType } from "./shared";
3
- export interface StatusProviderProps {
4
- children?: ReactNode;
5
- successIcon?: ReactNode;
6
- infoIcon?: ReactNode;
7
- warningIcon?: ReactNode;
8
- dangerIcon?: ReactNode;
9
- }
10
- declare const StatusProvider: ({ children, successIcon, infoIcon, warningIcon, dangerIcon, ...rest }: StatusProviderProps) => JSX.Element;
11
- declare const useStatus: () => {
12
- setAlert: (alert: StatusAlert | null) => void;
13
- setStatus: (status: StatusType) => void;
14
- };
15
- export { useStatus, StatusProvider };
@@ -1,33 +0,0 @@
1
- import React, { ReactNode } from "react";
2
- export interface SwitchProps {
3
- className?: string;
4
- checked?: boolean;
5
- onChange?: (event: React.ChangeEvent) => void;
6
- /**
7
- * Sets label inside of the switch. If you set this, you should also set the className "lg" to make the switch larger.
8
- */
9
- sliderLabel?: string;
10
- /**
11
- * You can change the type of the wrapper element. If you do, the `onChange` event might not be triggered.
12
- */
13
- elementType?: string;
14
- disabled?: boolean;
15
- /**
16
- * Set prop to use the older look and feel. Will disappear in future releases.
17
- */
18
- legacy?: boolean;
19
- label?: ReactNode | string;
20
- }
21
- /**
22
- * @deprecated
23
- * Use Bootstrap's `.form-check.form-switch` instead:
24
- * https://getbootstrap.com/docs/5.2/forms/checks-radios/#switches
25
- *
26
- * For now, this component acts as proxy for Bootstrap's Switch.
27
- * To place a label next to the switch, use the new `label` prop.
28
- *
29
- * Migrate to Blue React 8.4.0 and use legacy support: Set the `label` with a string. Or set the `legacy` prop to use the previous look and behaviour.
30
- */
31
- export default function Switch({ className, checked, onChange, sliderLabel, disabled, elementType, legacy, label }: SwitchProps): React.ReactElement<{
32
- className: string;
33
- }, string | React.JSXElementConstructor<any>>;
@@ -1,22 +0,0 @@
1
- import { ReactNode } from "react";
2
- export interface ToastProviderProps {
3
- children?: ReactNode;
4
- successIcon?: ReactNode;
5
- infoIcon?: ReactNode;
6
- warningIcon?: ReactNode;
7
- dangerIcon?: ReactNode;
8
- }
9
- export declare type ToastItemType = "success" | "danger" | "info" | "warning";
10
- export interface ToastItem {
11
- type: ToastItemType;
12
- title?: string;
13
- message?: string;
14
- }
15
- /**
16
- * Push notifications to your visitors using Bootstrap's toast component.
17
- */
18
- export declare function ToastProvider({ children, successIcon, infoIcon, warningIcon, dangerIcon }: ToastProviderProps): JSX.Element;
19
- export declare const useToast: () => {
20
- addToast: (toastItem: ToastItem) => void;
21
- clearToasts: () => void;
22
- };
@@ -1,41 +0,0 @@
1
- import { startLoading, finishLoading, showSuccess, hideSuccess, resetAlertMessage, setAlertMessage, scrollToTop, fetchData } from "blue-web/dist/js/utils";
2
- /**
3
- * @deprecated Use (el as HTMLElement).classList.contains("my-class") instead.
4
- */
5
- export declare function hasClass(el: HTMLElement | null, className: string): boolean;
6
- /**
7
- * @deprecated Use (el as HTMLElement).classList.add("my-class") instead.
8
- */
9
- export declare function addClass(el: HTMLElement | null, className: string): void;
10
- /**
11
- * @deprecated Use (el as HTMLElement).classList.remove("my-class") instead.
12
- */
13
- export declare function removeClass(el: HTMLElement | null, className: string): void;
14
- /**
15
- * @deprecated Use (el as HTMLElement).classList.toggle("my-class") instead.
16
- */
17
- export declare function toggleClass(element: HTMLElement | null, className: string): void;
18
- /**
19
- * @deprecated Is handled inside of `ActioMenu` component now
20
- */
21
- export declare function toggleActions(): void;
22
- /**
23
- * @deprecated In future versions of Blue React, you will need to use utils of Blue Web directly.
24
- */
25
- declare const _default: {
26
- hasClass: typeof hasClass;
27
- addClass: typeof addClass;
28
- removeClass: typeof removeClass;
29
- toggleClass: typeof toggleClass;
30
- startLoading: typeof startLoading;
31
- finishLoading: typeof finishLoading;
32
- showSuccess: typeof showSuccess;
33
- hideSuccess: typeof hideSuccess;
34
- toggleActions: typeof toggleActions;
35
- resetAlertMessage: typeof resetAlertMessage;
36
- setAlertMessage: typeof setAlertMessage;
37
- guid: () => string;
38
- scrollToTop: typeof scrollToTop;
39
- fetchData: typeof fetchData;
40
- };
41
- export default _default;
@@ -1,15 +0,0 @@
1
- export declare type breakOption = "sm" | "md" | "lg" | "xl";
2
- export declare type ModalType = "ask" | "tell" | "verify";
3
- export declare type StatusType = null | "loading" | "success" | "info" | "warning" | "danger";
4
- export interface StatusAlert {
5
- title?: string;
6
- alertClassName?: string;
7
- close?: boolean;
8
- detailText?: string;
9
- status?: StatusType;
10
- }
11
- interface Phrases {
12
- [key: string]: string[];
13
- }
14
- export declare function getPhrase(keyword: string, countryCode?: string | undefined, _phrases?: Phrases | undefined): string;
15
- export {};