blue-react 12.0.0 → 13.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.
package/README.md CHANGED
@@ -21,44 +21,57 @@ npm i blue-react
21
21
 
22
22
  `blue-react` has `blue-web` and `bootstrap` as dependencies, so these will be installed automatically.
23
23
 
24
+ ## Breaking changes between v11 and v12
25
+
26
+ ### Changes in Layout component
27
+
28
+ `children` doesn't get wrapped around a `div.blue-layout-body` anymore. Put your page's content into the `page` slot instead:
29
+
30
+ ```diff
31
+ - <Layout><h1>Hello World</h1></Layout>
32
+ + <Layout page={<h1>Hello World</h1>} />
33
+ ```
34
+
35
+ This lets you place other elements, such as the new `LayoutSplitter` component, in the layout's main area through `children`.
36
+
24
37
  ## Breaking changes between v10 and v11
25
38
 
26
39
  ### Fundamental changes in `MenuItem`
27
40
 
28
- - Removed props
29
- - onClickAttached
30
- - iconClassName
31
- - labelClassName
32
- - caretClassName
33
- - caretStyle
34
- - isHome
35
- - dropdownClassName
36
- - dropdownStyle
37
- - showDropdown
38
- - onShowDropdown
39
- - supportOutside
40
- - outsideIgnoreClasses
41
- - Renamed
42
- - iconForActive -> iconForCurrent
43
- - isActive -> current
44
- - highlighted -> active
45
- - Changed behviour. Menu item no longer has built in styling if `draggable`. But since Menu item extends HTML Button or A element, props `draggable`, `onDragStart` etc. should still work.
46
- - Added
47
- - sm
48
- - lg
49
- - iconBefore
50
- - iconAfter
51
- - labelHidden
52
- - busy
53
- - success
54
- - defaultDisplay
55
- - buttonContent
56
- - as
41
+ - Removed props
42
+ - onClickAttached
43
+ - iconClassName
44
+ - labelClassName
45
+ - caretClassName
46
+ - caretStyle
47
+ - isHome
48
+ - dropdownClassName
49
+ - dropdownStyle
50
+ - showDropdown
51
+ - onShowDropdown
52
+ - supportOutside
53
+ - outsideIgnoreClasses
54
+ - Renamed
55
+ - iconForActive -> iconForCurrent
56
+ - isActive -> current
57
+ - highlighted -> active
58
+ - Changed behviour. Menu item no longer has built in styling if `draggable`. But since Menu item extends HTML Button or A element, props `draggable`, `onDragStart` etc. should still work.
59
+ - Added
60
+ - sm
61
+ - lg
62
+ - iconBefore
63
+ - iconAfter
64
+ - labelHidden
65
+ - busy
66
+ - success
67
+ - defaultDisplay
68
+ - buttonContent
69
+ - as
57
70
 
58
71
  The previous Menu Item with the older API is still available as `LegacyMenuItem`, but will be removed in a future release. Because of styling changes in Blue Web, it might not behave the same.
59
72
 
60
73
  ### Removed deprecated components
61
74
 
62
- - Body
63
- - Page
64
- - SidebarToggler
75
+ - Body
76
+ - Page
77
+ - SidebarToggler
package/dist/A.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ export interface AProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
3
+ }
4
+ /**
5
+ * The `<a>` element automatically sets `rel="noreferrer"` for external links with `target="_blank"`.\
6
+ * `A` allows all props of the `<a>` element.\
7
+ * `<A href="https://example.com" target="_blank">Example</A>` ➡️ `<a href="https://example.com" target="_blank" rel="noreferrer">Example</a>`
8
+ */
9
+ export default function A({ children, rel, ...rest }: AProps): React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { ComponentProps } from "react";
2
+ export type AccordionProps = ComponentProps<"div">;
3
+ export default function Accordion({ className, children, ...props }: AccordionProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+ export type AccordionItemProps = {
3
+ header?: ReactNode;
4
+ headerClassName?: string;
5
+ headerButtonClassName?: string;
6
+ bodyClassName?: string;
7
+ } & ComponentProps<"details">;
8
+ export default function AccordionItem({ header, headerClassName, headerButtonClassName, bodyClassName, className, children, ...props }: AccordionItemProps): import("react").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { breakOption } from "./shared";
3
+ export declare const ActionMenuContext: React.Context<{
4
+ breakOption: breakOption | "none";
5
+ }>;
6
+ export interface ActionMenuProps {
7
+ /**
8
+ * Hides the toggle button in mobile view. Can be useful when using multiple ActionMenus and not show the toggle button for each menu.
9
+ */
10
+ hideToggleAction?: boolean;
11
+ children?: any;
12
+ /**
13
+ * Icon component for the toggle icon.
14
+ */
15
+ toggleIcon?: any;
16
+ className?: string;
17
+ /**
18
+ * "sm" | "md" | "lg" | "xl" | "none". Default is "lg". The responsive breakpoint at which the menu will be shown as a dropdown.
19
+ */
20
+ break?: breakOption | "none";
21
+ }
22
+ /**
23
+ * @deprecated Use the new `Actions` instead, which is more flexible.
24
+ * The Action Menu on the top right of a page. You can place Actions here which are in context of the current page.
25
+ */
26
+ export default function ActionMenu(props: ActionMenuProps): React.JSX.Element;
@@ -0,0 +1,16 @@
1
+ import React, { CSSProperties, ReactNode } from "react";
2
+ export interface ActionsProps {
3
+ children?: ReactNode;
4
+ className?: string;
5
+ menuClassName?: string;
6
+ collapseClassName?: string;
7
+ collapseStyle?: CSSProperties;
8
+ collapseMenuClassName?: string;
9
+ collapseMenuStyle?: CSSProperties;
10
+ }
11
+ /**
12
+ * Combination of toolbar and a dropdown menu. Items in toolbar will only be shown if there is enough space.
13
+ * Otherwise they will be visible in the dropdown menu. JavaScript detects if space is changing and rearranges.
14
+ * IMPORTANT: As of right now, children you pass will be rendered twice. Once in the toolbar and once in the dropdown.
15
+ */
16
+ export default function Actions({ children, className, menuClassName, collapseClassName, collapseStyle, collapseMenuClassName, collapseMenuStyle }: ActionsProps): React.JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { ComponentProps, ReactNode, ElementType } from "react";
2
+ export type ButtonVariant = "filled" | "soft" | "plain" | "outline" | "link" | "menu-item";
3
+ export type ButtonColor = "theme" | "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
4
+ export type ButtonProps = ComponentProps<"a"> & ComponentProps<"button"> & {
5
+ elementType?: ElementType;
6
+ variant?: ButtonVariant;
7
+ color?: ButtonColor;
8
+ sm?: boolean;
9
+ lg?: boolean;
10
+ iconBefore?: ReactNode;
11
+ iconAfter?: ReactNode;
12
+ label?: string;
13
+ labelHidden?: boolean;
14
+ busy?: boolean;
15
+ /** Button will be displayed as successful for 3 seconds. */
16
+ success?: boolean;
17
+ active?: boolean;
18
+ /** Button's width and height should be equal. Useful, if you want your body only to have one symbol.
19
+ * When your body only has an icon and hidden label, this will be set automatically. */
20
+ square?: boolean;
21
+ } & {
22
+ /**
23
+ * For compatibility with React Router NavLink
24
+ */
25
+ to?: string;
26
+ /**
27
+ * For compatibility with React Router NavLink
28
+ */
29
+ exact?: boolean;
30
+ };
31
+ export default function Button({ elementType, className, type, variant, color, sm, lg, iconBefore, iconAfter, label, labelHidden, busy: busyProp, success: successProp, active, square, ...props }: ButtonProps): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import React, { CSSProperties } from "react";
2
+ export interface ChevronProps {
3
+ /**
4
+ * Indicates if open or not.
5
+ */
6
+ open?: boolean;
7
+ /**
8
+ * By default the chevron points to the right when closed. Set mirrored and it will point to the left.
9
+ */
10
+ mirrored?: boolean;
11
+ className?: string;
12
+ style?: CSSProperties;
13
+ }
14
+ /**
15
+ * Chevron icon component with open state.
16
+ */
17
+ export default function Chevron({ open, mirrored, className, style }: ChevronProps): React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+ export type FieldGroupProps = ComponentProps<"details"> & {
3
+ header?: ReactNode;
4
+ isExpanded?: boolean;
5
+ headerClassName?: string;
6
+ id?: string;
7
+ heading?: number;
8
+ pageHeader?: boolean;
9
+ };
10
+ export default function FieldGroup({ className, children, open, header, isExpanded, headerClassName, id, heading, pageHeader, ...rest }: FieldGroupProps): import("react").JSX.Element;
@@ -0,0 +1,76 @@
1
+ import React, { Component, ReactNode } from "react";
2
+ declare global {
3
+ interface Window {
4
+ blueHashRouterRef: any;
5
+ }
6
+ }
7
+ export interface HashRouterProps {
8
+ /**
9
+ * Registers pages for the built-in routing system. Example: `[{name: "home", component: <HomePage />}]`
10
+ */
11
+ pages?: {
12
+ name: string;
13
+ component: ReactNode;
14
+ }[];
15
+ /**
16
+ * When `true`, always the "home" route will be rendered.
17
+ */
18
+ unrouteable?: boolean;
19
+ /**
20
+ * By default, the document title will automatically set. Set this prop to `true` to disable this behaviour.
21
+ */
22
+ disableTitleSet?: boolean;
23
+ /**
24
+ * Define a function, that will be fired when switching routes. When your function returns `true`, the default route behaviour will be blocked.
25
+ * You can use something like `window.blueHashRouterRef.setState({ blockRouting: onHashChange })` globally to set the value from anywhere in your app.
26
+ */
27
+ blockRouting?: (newMatch: string[], currentMatch: string[]) => void | boolean;
28
+ children?: any;
29
+ }
30
+ export interface HashRouterState {
31
+ match: any;
32
+ history: string[];
33
+ hash: string;
34
+ hashHistory: string[];
35
+ blockRouting?: (newMatch: string[], currentMatch: string[]) => void | boolean;
36
+ }
37
+ /**
38
+ * Component for simple hash routing. It's recommended to use solutions like `react-router-dom` for more complex routing.
39
+ *
40
+ * As soon this component is mounted, it is globally available under `window.blueHashRouterRef`.
41
+ * You can also append your own event listeners.
42
+ *
43
+ * Allowed events:
44
+ *
45
+ * * **componentDidUpdate** - Component was updated.
46
+ * Example: `window.blueHashRouterRef.addEventListener("componentDidUpdate", (prevProps, prevState) => { })`
47
+ * * **pageDidShowAgain** - Page appeared again with the same old state. In the callback function you can reinitialize things.
48
+ * Example: `window.blueHashRouterRef.addEventListener("pageDidShowAgain", "home", (prevProps, prevState) => { })`
49
+ * * **pageDidHide** - This page disappeared and another page appears instead.
50
+ * Example: `window.blueHashRouterRef.addEventListener("pageDidHide", "home", (prevProps, prevState) => { })`
51
+ *
52
+ * Method to add event listeners:
53
+ * * `window.blueHashRouterRef.`**addEventListener**`(eventName: string, param2: any, param3: any, listenerId?: string)`
54
+ *
55
+ * Methods to remove event listeners:
56
+ * * `window.blueHashRouterRef.`**removeEventListener**`(eventName: string, listenerId: string)`
57
+ * * `window.blueHashRouterRef.`**removeDuplicatedEventListeners**`()` - Will automatically be called when running `addEventListener`
58
+ */
59
+ export default class HashRouter extends Component<HashRouterProps, HashRouterState> {
60
+ defaultMatch: string[];
61
+ eventListeners: any[];
62
+ constructor(props: HashRouterProps);
63
+ onHashChange(): void;
64
+ static get defaultProps(): {
65
+ unrouteable: boolean;
66
+ disableTitleSet: boolean;
67
+ };
68
+ componentDidMount(): void;
69
+ componentWillUnmount(): void;
70
+ componentDidUpdate(prevProps: HashRouterProps, prevState: HashRouterState): void;
71
+ initMatch(): void;
72
+ addEventListener(param1: any, param2: any, param3: any, listenerId?: string): void;
73
+ removeEventListener(type: string, listenerId: string): void;
74
+ removeDuplicatedEventListeners(): void;
75
+ render(): React.JSX.Element;
76
+ }
@@ -0,0 +1,9 @@
1
+ import React, { ReactNode } from "react";
2
+ export interface HeaderProps {
3
+ children?: ReactNode;
4
+ className?: string;
5
+ }
6
+ /**
7
+ * The top of a page.
8
+ */
9
+ export default function Header({ children, className }: HeaderProps): React.JSX.Element;
@@ -0,0 +1,40 @@
1
+ import React, { ReactNode } from "react";
2
+ export interface HeaderTitleProps {
3
+ /**
4
+ * Can be an image. Will be placed inside of the `src` attribute.
5
+ */
6
+ logo?: string;
7
+ logoAlt?: string;
8
+ /**
9
+ * Text next to the logo.
10
+ */
11
+ appTitle?: string;
12
+ children?: ReactNode;
13
+ /**
14
+ * Extends `className` from parent element.
15
+ */
16
+ className?: string;
17
+ /**
18
+ * Is the component used on the sidebar?
19
+ */
20
+ sidebar?: boolean;
21
+ /**
22
+ * By default, MenuItem is a `"a"`.
23
+ * If you want to have it another type, you can pass a component reference with this prop (e.g. `Link`).
24
+ */
25
+ elementType?: any;
26
+ /**
27
+ * Sets `to` prop, e.g. when you use the `Link` component from React Router.
28
+ */
29
+ to?: string;
30
+ href?: string;
31
+ /**
32
+ * Breadcrumb items to be shown.
33
+ */
34
+ breadcrumb?: ReactNode[];
35
+ }
36
+ /**
37
+ * The title area at the header bar.
38
+ * Depending on its content, the document's title will be set aswell (what will be shown in the browser title bar).
39
+ */
40
+ export default function HeaderTitle({ logo, logoAlt, appTitle, children, className, sidebar, elementType, to, href, breadcrumb }: HeaderTitleProps): React.JSX.Element;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { LegacyMenuItemProps } from "./LegacyMenuItem";
3
+ export interface IconMenuItemProps extends LegacyMenuItemProps {
4
+ outerClass?: string;
5
+ /**
6
+ * Tooltip will be placed to the end/right by default. You can change the direction with this prop.
7
+ */
8
+ tooltipClass?: string;
9
+ /**
10
+ * When used inside of the sidebar: active indicator will be displayed underneath instead of before.
11
+ * The prop to `false` to disable this behavior.
12
+ */
13
+ horizontalOnOpenSidebar?: boolean;
14
+ }
15
+ /**
16
+ * @deprecated
17
+ * Variant of `MenuItem` to primarily display an icon without a label.
18
+ * The label prop will be displayed as a tooltip.
19
+ */
20
+ export default function IconMenuItem({ label, outerClass, tooltipClass, horizontalOnOpenSidebar, className, ...props }: IconMenuItemProps): React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ export interface IntroProps {
3
+ /**
4
+ * Can be an image. Will be placed inside of the `src` attribute.
5
+ */
6
+ logo?: string;
7
+ /**
8
+ * Max width from the logo.
9
+ */
10
+ logoMaxWidth?: string;
11
+ /**
12
+ * Text which will be placed under the logo.
13
+ */
14
+ title?: string;
15
+ /**
16
+ * Content
17
+ */
18
+ children?: any;
19
+ }
20
+ /**
21
+ * Can be used for a sign-in page.
22
+ */
23
+ export default function Intro({ logo, logoMaxWidth, title, children }: IntroProps): React.JSX.Element;
@@ -0,0 +1,26 @@
1
+ import React, { ComponentProps, ReactNode, RefObject } from "react";
2
+ export type LayoutProps = {
3
+ header?: React.ReactNode;
4
+ side?: React.ReactNode;
5
+ noPageBorder?: boolean;
6
+ /**
7
+ * If you don't use `LayoutSplitter`, put page's body content in here.
8
+ */
9
+ page?: React.ReactNode;
10
+ drawerTitle?: ReactNode;
11
+ /**
12
+ * For SSR you can pass server's country code to solve hydration problems.
13
+ */
14
+ countryCode?: string;
15
+ /**
16
+ * If set, an event listener will be added to the Blue Web Layout element.
17
+ * This callback function helps you get the current state of the inspector. To control the
18
+ * inspector, use the `toggleInspector`, `openInspector`, `closeInspector` by Blue Web.
19
+ */
20
+ onInspectorChange?: (open: boolean) => void;
21
+ ref?: RefObject<HTMLDivElement | null>;
22
+ } & ComponentProps<"div">;
23
+ /**
24
+ * A layout with header, side and main content area. Side is collapsible.
25
+ */
26
+ export default function Layout({ children, className, header, side, noPageBorder, page, drawerTitle, countryCode, onInspectorChange, ref, ...props }: LayoutProps): React.JSX.Element;
@@ -0,0 +1,37 @@
1
+ import "@spectrum-web-components/split-view/sp-split-view.js";
2
+ import { ComponentProps, ReactNode } from "react";
3
+ declare module "react" {
4
+ namespace JSX {
5
+ interface IntrinsicElements {
6
+ "sp-split-view": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
7
+ vertical?: boolean;
8
+ resizable?: boolean;
9
+ collapsible?: boolean;
10
+ label?: string;
11
+ "primary-size"?: string;
12
+ "primary-min"?: string;
13
+ "primary-max"?: string;
14
+ "secondary-min"?: string;
15
+ "secondary-max"?: string;
16
+ "splitter-pos"?: string;
17
+ };
18
+ }
19
+ }
20
+ }
21
+ export type LayoutSplitterProps = Omit<ComponentProps<"sp-split-view">, "children"> & {
22
+ inspectorId?: string;
23
+ start?: ReactNode;
24
+ end?: ReactNode;
25
+ drawerTitle?: ReactNode;
26
+ noPageBorder?: boolean;
27
+ /**
28
+ * For SSR you can pass server's country code to solve hydration problems.
29
+ */
30
+ countryCode?: string;
31
+ };
32
+ /**
33
+ * Might require React 19 or higher!
34
+ * Allows to create a split view between the layout's main content and an inspector next to it.
35
+ * Doesn't support SSR out of the box.
36
+ */
37
+ export default function LayoutSplitter({ inspectorId, start, end, drawerTitle, noPageBorder, countryCode, className, ...props }: LayoutSplitterProps): import("react").JSX.Element;
@@ -0,0 +1,150 @@
1
+ import React, { CSSProperties } from "react";
2
+ export interface LegacyMenuItemProps {
3
+ /**
4
+ * Sets `to` prop, e.g. when you use the `NavLink` component from React Router.
5
+ */
6
+ to?: string;
7
+ /**
8
+ * Prop for components by React Router.
9
+ */
10
+ exact?: boolean;
11
+ href?: string;
12
+ onClick?: (event: React.MouseEvent) => void;
13
+ /**
14
+ * Will be fired after `onClick`
15
+ */
16
+ onClickAttached?: (event: React.MouseEvent) => void;
17
+ /**
18
+ * Icon component or a class name.
19
+ */
20
+ icon?: any;
21
+ /**
22
+ * Addition to class name of icon wrapper element
23
+ */
24
+ iconClassName?: string;
25
+ /**
26
+ * Icon component or a class name when the MenuItem is active.
27
+ */
28
+ iconForActive?: any;
29
+ /**
30
+ * Label of the link.
31
+ */
32
+ label?: any;
33
+ /**
34
+ * Addition to class name of label wrapper element
35
+ */
36
+ labelClassName?: string;
37
+ /**
38
+ * Addition to class name of caret
39
+ */
40
+ caretClassName?: string;
41
+ /**
42
+ * Addition to style of caret
43
+ */
44
+ caretStyle?: CSSProperties;
45
+ /**
46
+ * Should be set as active.
47
+ */
48
+ isActive?: boolean;
49
+ /**
50
+ * Set true to highlight the current menu item.
51
+ */
52
+ highlighted?: boolean;
53
+ /**
54
+ * When using Blue React's routing system: define this link as home page link.
55
+ */
56
+ isHome?: boolean;
57
+ /**
58
+ * Extends class name of the dropdown menu.
59
+ */
60
+ dropdownClassName?: string;
61
+ /**
62
+ * Extends style of the dropdown menu.
63
+ */
64
+ dropdownStyle?: CSSProperties;
65
+ /**
66
+ * Set children to create a nested `MenuItem` as a dropdown.
67
+ */
68
+ children?: any;
69
+ /**
70
+ * Defines class name.
71
+ */
72
+ className?: any;
73
+ /**
74
+ * Defines dropdown status from outside.
75
+ */
76
+ showDropdown?: boolean;
77
+ /**
78
+ * Callback when `showDropdown` changes.
79
+ */
80
+ onShowDropdown?: (showDropdown: boolean) => void;
81
+ /**
82
+ * Close on click outside.
83
+ */
84
+ supportOutside?: boolean;
85
+ /**
86
+ * Overrides default class list to be ignored on click outside.
87
+ * Hint: If you want this menu item to stay open when others will open, set:
88
+ * `outsideIgnoreClasses={["blue-menu-item-wrapper"]}`.
89
+ */
90
+ outsideIgnoreClasses?: string[];
91
+ /**
92
+ * By default, MenuItem is a `"button"`. If you set a `href`, it's a `"a"`.
93
+ * If you want to have it another type, you can pass a component reference with this prop (e.g. `Link`).
94
+ */
95
+ elementType?: any;
96
+ target?: string;
97
+ rel?: string;
98
+ title?: string;
99
+ type?: string;
100
+ /**
101
+ * Fired on the draggable target (the source element): occurs when the user starts to drag an element
102
+ */
103
+ onDragStart?: (event: React.DragEvent) => void | React.DragEventHandler;
104
+ /**
105
+ * Fired on the draggable target (the source element): occurs when an element is being dragged
106
+ */
107
+ onDrag?: (event: React.DragEvent) => void | React.DragEventHandler;
108
+ /**
109
+ * Fired on the draggable target (the source element): occurs when the user has finished dragging the element
110
+ */
111
+ onDragEnd?: (event: React.DragEvent) => void | React.DragEventHandler;
112
+ /**
113
+ * Fired on the drop target: occurs when the dragged element enters the drop target
114
+ */
115
+ onDragEnter?: (event: React.DragEvent) => void | React.DragEventHandler;
116
+ /**
117
+ * Fired on the drop target: occurs when the dragged element is over the drop target
118
+ */
119
+ onDragOver?: (event: React.DragEvent) => void | React.DragEventHandler;
120
+ /**
121
+ * Fired on the drop target: occurs when the dragged element leaves the drop target
122
+ */
123
+ onDragLeave?: (event: React.DragEvent) => void | React.DragEventHandler;
124
+ /**
125
+ * Fired on the drop target: occurs when the dragged element is dropped on the drop target
126
+ */
127
+ onDrop?: (event: React.DragEvent) => void | React.DragEventHandler;
128
+ /**
129
+ * Specifies whether an element is draggable or not.
130
+ *
131
+ * **Important:** To make draggable menu items work in Firefox, the elementType must not be `"button"`. Set it to something else, like `"div"`.
132
+ */
133
+ draggable?: boolean;
134
+ hideDraggableIcon?: boolean;
135
+ "data-tooltip"?: string;
136
+ /**
137
+ * Specifies whether an element is disabled or not.
138
+ */
139
+ disabled?: boolean;
140
+ /**
141
+ * Specifies style of an element.
142
+ */
143
+ style?: React.CSSProperties;
144
+ id?: string;
145
+ }
146
+ /**
147
+ * @deprecated
148
+ * Link, button or custom component for Sidebar, Actions or ActionMenu
149
+ */
150
+ export default function LegacyMenuItem(props: LegacyMenuItemProps): React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from "react";
2
+ import { ButtonProps } from "./Button";
3
+ export type MenuItemProps = ButtonProps & {
4
+ current?: boolean;
5
+ defaultDisplay?: boolean;
6
+ buttonContent?: ReactNode;
7
+ /** Uses `iconBefore` slot. If `iconForCurrent` and menu item is current, this will be hidden. */
8
+ icon?: ReactNode;
9
+ /** Uses `iconBefore` slot. If menu item is current, this will be visible. */
10
+ iconForCurrent?: ReactNode;
11
+ as?: "collapse" | "collapse-group" | "popover-group";
12
+ };
13
+ export default function MenuItem({ as, ...props }: MenuItemProps): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import React, { 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): React.JSX.Element;
@@ -0,0 +1,21 @@
1
+ import React, { 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) => React.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 };
@@ -0,0 +1,17 @@
1
+ import React, { 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 | null>;
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): React.JSX.Element;
@@ -0,0 +1,46 @@
1
+ import React, { ReactNode, RefObject } from "react";
2
+ export interface SearchProps {
3
+ autoFocus?: boolean;
4
+ /**
5
+ * @deprecated
6
+ * Doesn't have an effect anymore. Prop will be removed in a future version.
7
+ */
8
+ body?: boolean;
9
+ className?: string;
10
+ icon?: any;
11
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
12
+ onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;
13
+ placeholder?: string;
14
+ /**
15
+ * Allow reset?
16
+ */
17
+ reset?: boolean;
18
+ /**
19
+ * Define custom icon for the reset button.
20
+ */
21
+ resetIcon?: any;
22
+ /**
23
+ * @deprecated
24
+ * Doesn't have an effect anymore. Prop will be removed in a future version.
25
+ */
26
+ sidebar?: boolean;
27
+ value?: string;
28
+ children?: ReactNode;
29
+ id?: string;
30
+ /**
31
+ * Set `ref` prop of the input element. Let's you take control of it from the outside, e.g. to set focus.
32
+ */
33
+ inputRef?: RefObject<HTMLInputElement | null>;
34
+ /**
35
+ * Adds additional class name to input element.
36
+ */
37
+ inputClassName?: string;
38
+ /**
39
+ * Disables default pill rounding.
40
+ */
41
+ noRounding?: boolean;
42
+ }
43
+ /**
44
+ * A search bar that can be placed to the sidebar or on a page.
45
+ */
46
+ export default function Search(props: SearchProps): React.JSX.Element;
@@ -0,0 +1,32 @@
1
+ import React, { CSSProperties, ReactNode } from "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?: CSSProperties;
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?: CSSProperties;
19
+ /**
20
+ * Content on top of the menu.
21
+ */
22
+ topContent?: ReactNode;
23
+ /**
24
+ * Content for the bottom part of the sidebar.
25
+ */
26
+ bottomContent?: ReactNode;
27
+ children?: ReactNode;
28
+ }
29
+ /**
30
+ * Sidebar for the `Layout` component.
31
+ */
32
+ export default function SidebarMenu(props: SidebarMenuProps): React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React, { CSSProperties } from "react";
2
+ export interface SimpleLayoutProps {
3
+ children?: React.ReactNode;
4
+ className?: string;
5
+ style?: CSSProperties;
6
+ header?: React.ReactNode;
7
+ noPageBorder?: boolean;
8
+ }
9
+ /**
10
+ * A simple layout with header and main content area.
11
+ */
12
+ export default function SimpleLayout({ children, className, style, header, noPageBorder }: SimpleLayoutProps): React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import React, { 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): React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React, { 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): React.JSX.Element;
@@ -0,0 +1,15 @@
1
+ import React, { 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) => React.JSX.Element;
11
+ declare const useStatus: () => {
12
+ setAlert: (alert: StatusAlert | null) => void;
13
+ setStatus: (status: StatusType) => void;
14
+ };
15
+ export { useStatus, StatusProvider };
package/dist/Tab.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from "react";
2
+ export interface TabProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
+ label: string;
4
+ children?: ReactNode;
5
+ className?: string;
6
+ contentClassName?: string;
7
+ active?: boolean;
8
+ }
9
+ /**
10
+ * Always use together with `Tabs`.
11
+ */
12
+ export default function Tab({ label, children, className, contentClassName, active, ...rest }: TabProps): import("react").JSX.Element;
package/dist/Tabs.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { type ReactNode } from "react";
2
+ export declare const TabsNameContext: import("react").Context<string>;
3
+ export interface TabsProps {
4
+ children?: ReactNode;
5
+ className?: string;
6
+ /**
7
+ * By default, tabs will have styling of Bootstrap `.nav.nav-tabs`.
8
+ * Set this property to `true` to use `.nav.nav-underline` instead.
9
+ */
10
+ underline?: boolean;
11
+ }
12
+ /**
13
+ * Implementation of Blue Web Tabs. Allows to use tabs without JavaScript.
14
+ * Use together with `Tab`.
15
+ */
16
+ export default function Tabs({ children, className, underline }: TabsProps): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import React, { 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 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): React.JSX.Element;
19
+ export declare const useToast: () => {
20
+ addToast: (toastItem: ToastItem) => void;
21
+ clearToasts: () => void;
22
+ };
@@ -0,0 +1,41 @@
1
+ import { startLoading, finishLoading, showSuccess, hideSuccess, resetAlertMessage, setAlertMessage, scrollToTop, fetchData } from "blue-web/dist/js/utils.js";
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;
@@ -0,0 +1,21 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["className", "children"];
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
9
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
10
+ import clsx from "clsx";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ export default function Accordion(_ref) {
13
+ var className = _ref.className,
14
+ children = _ref.children,
15
+ props = _objectWithoutProperties(_ref, _excluded);
16
+ return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
17
+ className: clsx("blue-accordion accordion", className)
18
+ }, props), {}, {
19
+ children: children
20
+ }));
21
+ }
@@ -0,0 +1,34 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["header", "headerClassName", "headerButtonClassName", "bodyClassName", "className", "children"];
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
9
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
10
+ import clsx from "clsx";
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ export default function AccordionItem(_ref) {
13
+ var header = _ref.header,
14
+ headerClassName = _ref.headerClassName,
15
+ headerButtonClassName = _ref.headerButtonClassName,
16
+ bodyClassName = _ref.bodyClassName,
17
+ className = _ref.className,
18
+ children = _ref.children,
19
+ props = _objectWithoutProperties(_ref, _excluded);
20
+ return /*#__PURE__*/_jsxs("details", _objectSpread(_objectSpread({
21
+ className: clsx("accordion-item blue-collapse", className)
22
+ }, props), {}, {
23
+ children: [/*#__PURE__*/_jsx("summary", {
24
+ className: clsx("accordion-header", headerClassName),
25
+ children: /*#__PURE__*/_jsx("div", {
26
+ className: clsx("accordion-button collapsed", headerButtonClassName),
27
+ children: header
28
+ })
29
+ }), /*#__PURE__*/_jsx("div", {
30
+ className: clsx("accordion-body", bodyClassName),
31
+ children: children
32
+ })]
33
+ }));
34
+ }
@@ -0,0 +1,15 @@
1
+ export type breakOption = "sm" | "md" | "lg" | "xl";
2
+ export type ModalType = "ask" | "tell" | "verify";
3
+ export 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 {};
package/index.d.ts CHANGED
@@ -15,6 +15,12 @@ export { LayoutSplitterProps } from "./dist/components/LayoutSplitter"
15
15
  export { default as A } from "./dist/components/A"
16
16
  export { AProps } from "./dist/components/A"
17
17
 
18
+ export { default as Accordion } from "./dist/components/Accordion"
19
+ export { AccordionProps } from "./dist/components/Accordion"
20
+
21
+ export { default as AccordionItem } from "./dist/components/AccordionItem"
22
+ export { AccordionItemProps } from "./dist/components/AccordionItem"
23
+
18
24
  export { default as ActionMenu } from "./dist/components/ActionMenu"
19
25
  export { ActionMenuProps } from "./dist/components/ActionMenu"
20
26
 
package/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export { default as A } from "./dist/components/A.js"
2
+ export { default as Accordion } from "./dist/components/Accordion.js"
3
+ export { default as AccordionItem } from "./dist/components/AccordionItem.js"
2
4
  export { default as ActionMenu } from "./dist/components/ActionMenu.js"
3
5
  export { default as Actions } from "./dist/components/Actions.js"
4
6
  export { default as Button } from "./dist/components/Button.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blue-react",
3
- "version": "12.0.0",
3
+ "version": "13.0.0",
4
4
  "description": "Blue React Components",
5
5
  "license": "LGPL-3.0-or-later",
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@popperjs/core": "^2.11.5",
19
19
  "@spectrum-web-components/split-view": "^1.12.2",
20
- "blue-web": "1.31.0",
20
+ "blue-web": "1.32.0",
21
21
  "bootstrap": "~5.3.3",
22
22
  "clsx": "^1.1.1"
23
23
  },
@@ -49,7 +49,6 @@
49
49
  "build-types": "tsc -p tsconfig.app.json --declaration --emitDeclarationOnly --declarationDir ./dist --noEmit false --composite false",
50
50
  "build": "babel ./src/components --out-dir ./dist/components --extensions \".tsx,.js,.ts\"",
51
51
  "build-release": "npm run build-types && npm run build",
52
- "NOT_prepublishOnly": "npm i && npm run build-release",
53
52
  "release": "npm publish && npm run deploy"
54
53
  }
55
54
  }