@allxsmith/bestax-bulma 5.40.0 → 5.41.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/dist/bestax.css +1 -1
- package/dist/bestax.css.map +1 -1
- package/dist/esm/components/Menu.js +77 -2
- package/dist/esm/components/Menu.js.map +1 -1
- package/dist/esm/components/Modal.js +3 -3
- package/dist/esm/components/Modal.js.map +1 -1
- package/dist/esm/components/Popover.js +2 -2
- package/dist/esm/components/Popover.js.map +1 -1
- package/dist/esm/components/Sidebar.js +2 -2
- package/dist/esm/components/Sidebar.js.map +1 -1
- package/dist/esm/elements/Image.js +4 -12
- package/dist/esm/elements/Image.js.map +1 -1
- package/dist/esm/helpers/useFocusTrap.js +60 -41
- package/dist/esm/helpers/useFocusTrap.js.map +1 -1
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +162 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/types/components/Menu.d.ts +49 -0
- package/dist/types/elements/Image.d.ts +6 -1
- package/dist/types/helpers/useFocusTrap.d.ts +16 -8
- package/dist/types-cjs/components/Menu.d.ts +49 -0
- package/dist/types-cjs/elements/Image.d.ts +6 -1
- package/dist/types-cjs/helpers/useFocusTrap.d.ts +16 -8
- package/dist/versions/bestax-no-dark-mode.css +1 -1
- package/dist/versions/bestax-no-dark-mode.css.map +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
- package/dist/versions/bestax-no-helpers.css +1 -1
- package/dist/versions/bestax-no-helpers.css.map +1 -1
- package/dist/versions/bestax-prefixed.css +1 -1
- package/dist/versions/bestax-prefixed.css.map +1 -1
- package/package.json +1 -1
- package/src/scss/components/_menu.scss +130 -3
package/dist/index.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ export { Breadcrumb } from './esm/components/Breadcrumb.js';
|
|
|
8
8
|
export { Card } from './esm/components/Card.js';
|
|
9
9
|
export { Dropdown, DropdownDivider, DropdownItem, isBrowser } from './esm/components/Dropdown.js';
|
|
10
10
|
export { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIndicator, EmptyStateTitle } from './esm/components/EmptyState.js';
|
|
11
|
-
export { Menu, MenuItem, MenuLabel, MenuList } from './esm/components/Menu.js';
|
|
11
|
+
export { Menu, MenuItem, MenuLabel, MenuList, MenuSection } from './esm/components/Menu.js';
|
|
12
12
|
export { Message } from './esm/components/Message.js';
|
|
13
13
|
export { Modal } from './esm/components/Modal.js';
|
|
14
14
|
export { Navbar, NavbarBrand, NavbarBurger, NavbarDivider, NavbarDropdown, NavbarDropdownMenu, NavbarEnd, NavbarItem, NavbarLink, NavbarMenu, NavbarStart } from './esm/components/Navbar.js';
|
|
@@ -115,9 +115,58 @@ export type MenuItemProps<T extends React.ElementType = 'a'> = MenuItemOwnProps
|
|
|
115
115
|
* @returns {JSX.Element} The rendered menu item.
|
|
116
116
|
*/
|
|
117
117
|
export declare const MenuItem: PolymorphicComponent<MenuItemOwnProps, "a">;
|
|
118
|
+
/**
|
|
119
|
+
* Props for the MenuSection component. The helper props and the other
|
|
120
|
+
* attributes land on the wrapping `<div>`.
|
|
121
|
+
*/
|
|
122
|
+
export interface MenuSectionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, keyof BulmaClassesProps>, BulmaClassesProps {
|
|
123
|
+
/** Additional CSS classes for the wrapping `<div>`. */
|
|
124
|
+
className?: string;
|
|
125
|
+
/** **Required.** The section's heading, drawn like `Menu.Label` inside the button that opens and closes it. Keep links and buttons out of it, since it's inside one. */
|
|
126
|
+
label: React.ReactNode;
|
|
127
|
+
/**
|
|
128
|
+
* The `Menu.List` of links the section shows while it's open. The section
|
|
129
|
+
* itself goes directly in `Menu`, beside its labels and lists: inside a
|
|
130
|
+
* `Menu.Item` it would render inside the item's link, and inside a
|
|
131
|
+
* `Menu.List` it wouldn't be a list item.
|
|
132
|
+
*/
|
|
133
|
+
children: React.ReactNode;
|
|
134
|
+
/** Controlled open state. If provided, the section is controlled, and its button only reports through `onOpenChange`. */
|
|
135
|
+
open?: boolean;
|
|
136
|
+
/** Initial open state for uncontrolled usage. Open the section that holds the current page, so the reader sees where they are. */
|
|
137
|
+
defaultOpen?: boolean;
|
|
138
|
+
/** Called with the state the button asks for (`true` to open) each time it is clicked or activated with Enter or Space, in every mode. Pair it with `open` to let the button drive a controlled section. */
|
|
139
|
+
onOpenChange?: (open: boolean) => void;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A section of the menu that opens and closes: its heading is a button drawn like `Menu.Label`, and its `Menu.List` of links shows while it's open.
|
|
143
|
+
*
|
|
144
|
+
* It's APG's disclosure navigation, for a sidebar of link groups: the links
|
|
145
|
+
* stay ordinary links, each its own tab stop, and a closed section's list is
|
|
146
|
+
* `hidden` and `inert`, so Tab and assistive tech skip it. It goes directly in
|
|
147
|
+
* `Menu`, holding a `Menu.List`. Closing it while focus is on one of its links
|
|
148
|
+
* moves focus to its heading.
|
|
149
|
+
*
|
|
150
|
+
* @function
|
|
151
|
+
* @param {MenuSectionProps} props - Props for the MenuSection component.
|
|
152
|
+
* @returns {JSX.Element} The rendered menu section.
|
|
153
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/ | APG Disclosure Navigation Menu example}
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* <Menu>
|
|
157
|
+
* <Menu.Section label="Components" defaultOpen>
|
|
158
|
+
* <Menu.List>
|
|
159
|
+
* <Menu.Item href="/button" active>Button</Menu.Item>
|
|
160
|
+
* <Menu.Item href="/card">Card</Menu.Item>
|
|
161
|
+
* </Menu.List>
|
|
162
|
+
* </Menu.Section>
|
|
163
|
+
* </Menu>
|
|
164
|
+
*/
|
|
165
|
+
export declare const MenuSection: React.FC<MenuSectionProps>;
|
|
118
166
|
export declare const Menu: React.FC<MenuProps> & {
|
|
119
167
|
Label: React.FC<MenuLabelProps>;
|
|
120
168
|
List: React.FC<MenuListProps>;
|
|
121
169
|
Item: PolymorphicComponent<MenuItemOwnProps, "a", never>;
|
|
170
|
+
Section: React.FC<MenuSectionProps>;
|
|
122
171
|
};
|
|
123
172
|
export default Menu;
|
|
@@ -17,7 +17,12 @@ export interface ImageProps extends React.HTMLAttributes<HTMLElement>, Omit<Bulm
|
|
|
17
17
|
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
|
|
18
18
|
/** Background color helper for the container. */
|
|
19
19
|
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Fixed size or aspect ratio modifier for the image container. A ratio
|
|
22
|
+
* (`16by9` and the rest) renders only its `is-<ratio>` class there. Bulma
|
|
23
|
+
* stretches an `<img>` inside to fill the ratio, but any other child, such
|
|
24
|
+
* as an `iframe`, fills it only with `className="has-ratio"` of its own.
|
|
25
|
+
*/
|
|
21
26
|
size?: '16x16' | '24x24' | '32x32' | '48x48' | '64x64' | '96x96' | '128x128' | 'square' | '1by1' | '5by4' | '4by3' | '3by2' | '5by3' | '16by9' | '2by1' | '3by1' | '4by5' | '3by4' | '2by3' | '3by5' | '9by16' | '1by2' | '1by3';
|
|
22
27
|
/** Renders the image with rounded corners. */
|
|
23
28
|
isRounded?: boolean;
|
|
@@ -5,16 +5,24 @@ import type { RefObject } from 'react';
|
|
|
5
5
|
* can read `-1` for an editable region or an `<embed>` that Tab still visits,
|
|
6
6
|
* and `0` for a `<video>` without controls that it doesn't. So a valid
|
|
7
7
|
* `tabindex` attribute decides, and otherwise the element's kind does.
|
|
8
|
-
* Internal like `
|
|
8
|
+
* Internal like `focusTabStop`: `src/index.ts` names what it takes from here.
|
|
9
9
|
*/
|
|
10
10
|
export declare function isTabbableKind(el: Element): boolean;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
14
|
-
*
|
|
12
|
+
* Moves focus to the first tab stop inside `container`, or the last when
|
|
13
|
+
* `fromLast`, and to the container when there is none. Every move a trap
|
|
14
|
+
* makes goes through here: into the container as it opens, to the other end
|
|
15
|
+
* on a wrap, and back in after a Tab the browser carried out.
|
|
16
|
+
*
|
|
17
|
+
* A stop that doesn't take focus is passed over for the next one in. An
|
|
18
|
+
* `<object>` or `<embed>` with nothing to show is one: it counts as a stop by
|
|
19
|
+
* its kind, but browsers refuse to focus it, and which ones they refuse
|
|
20
|
+
* depends on the browser and on what has loaded, so only trying tells. A
|
|
21
|
+
* stop took focus when focus moved, wherever it went (a stop can hand focus
|
|
22
|
+
* on), or when focus was on it already. `src/index.ts` names its exports from
|
|
15
23
|
* this module, so this one stays internal.
|
|
16
24
|
*/
|
|
17
|
-
export declare function
|
|
25
|
+
export declare function focusTabStop(container: HTMLElement, fromLast?: boolean): void;
|
|
18
26
|
/**
|
|
19
27
|
* Holds Tab inside the element `container` returns until the returned
|
|
20
28
|
* function is called. Tab and Shift+Tab heard on `keyTarget` wrap at the
|
|
@@ -25,7 +33,7 @@ export declare function firstTabStop(container: HTMLElement): HTMLElement | null
|
|
|
25
33
|
* overlay whose nodes are remounted while it's open, as moving to another
|
|
26
34
|
* portal target does, stays trapped without attaching again. `holds` is asked
|
|
27
35
|
* on every Tab, and the trap leaves the key alone while it says no. Internal
|
|
28
|
-
* like `
|
|
36
|
+
* like `focusTabStop`. It's for an overlay that holds Tab from a listener of
|
|
29
37
|
* its own on `window` and asks the overlay stack first, so it stands aside
|
|
30
38
|
* while another overlay is open over it, which a trap listening on the
|
|
31
39
|
* container can't do.
|
|
@@ -46,8 +54,8 @@ export interface UseFocusTrapOptions {
|
|
|
46
54
|
* to be one that can take focus, so a heading needs `tabIndex={-1}`. When
|
|
47
55
|
* focusing it doesn't put focus inside the container (the ref is empty, or
|
|
48
56
|
* its element is outside, disabled, hidden or can't take focus), focus goes
|
|
49
|
-
* to the first tab stop inside the container, and to the
|
|
50
|
-
*
|
|
57
|
+
* to the first tab stop inside the container that takes focus, and to the
|
|
58
|
+
* container itself when none does.
|
|
51
59
|
*/
|
|
52
60
|
initialFocusRef?: RefObject<HTMLElement | null>;
|
|
53
61
|
/**
|
|
@@ -115,9 +115,58 @@ export type MenuItemProps<T extends React.ElementType = 'a'> = MenuItemOwnProps
|
|
|
115
115
|
* @returns {JSX.Element} The rendered menu item.
|
|
116
116
|
*/
|
|
117
117
|
export declare const MenuItem: PolymorphicComponent<MenuItemOwnProps, "a">;
|
|
118
|
+
/**
|
|
119
|
+
* Props for the MenuSection component. The helper props and the other
|
|
120
|
+
* attributes land on the wrapping `<div>`.
|
|
121
|
+
*/
|
|
122
|
+
export interface MenuSectionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, keyof BulmaClassesProps>, BulmaClassesProps {
|
|
123
|
+
/** Additional CSS classes for the wrapping `<div>`. */
|
|
124
|
+
className?: string;
|
|
125
|
+
/** **Required.** The section's heading, drawn like `Menu.Label` inside the button that opens and closes it. Keep links and buttons out of it, since it's inside one. */
|
|
126
|
+
label: React.ReactNode;
|
|
127
|
+
/**
|
|
128
|
+
* The `Menu.List` of links the section shows while it's open. The section
|
|
129
|
+
* itself goes directly in `Menu`, beside its labels and lists: inside a
|
|
130
|
+
* `Menu.Item` it would render inside the item's link, and inside a
|
|
131
|
+
* `Menu.List` it wouldn't be a list item.
|
|
132
|
+
*/
|
|
133
|
+
children: React.ReactNode;
|
|
134
|
+
/** Controlled open state. If provided, the section is controlled, and its button only reports through `onOpenChange`. */
|
|
135
|
+
open?: boolean;
|
|
136
|
+
/** Initial open state for uncontrolled usage. Open the section that holds the current page, so the reader sees where they are. */
|
|
137
|
+
defaultOpen?: boolean;
|
|
138
|
+
/** Called with the state the button asks for (`true` to open) each time it is clicked or activated with Enter or Space, in every mode. Pair it with `open` to let the button drive a controlled section. */
|
|
139
|
+
onOpenChange?: (open: boolean) => void;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A section of the menu that opens and closes: its heading is a button drawn like `Menu.Label`, and its `Menu.List` of links shows while it's open.
|
|
143
|
+
*
|
|
144
|
+
* It's APG's disclosure navigation, for a sidebar of link groups: the links
|
|
145
|
+
* stay ordinary links, each its own tab stop, and a closed section's list is
|
|
146
|
+
* `hidden` and `inert`, so Tab and assistive tech skip it. It goes directly in
|
|
147
|
+
* `Menu`, holding a `Menu.List`. Closing it while focus is on one of its links
|
|
148
|
+
* moves focus to its heading.
|
|
149
|
+
*
|
|
150
|
+
* @function
|
|
151
|
+
* @param {MenuSectionProps} props - Props for the MenuSection component.
|
|
152
|
+
* @returns {JSX.Element} The rendered menu section.
|
|
153
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/ | APG Disclosure Navigation Menu example}
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* <Menu>
|
|
157
|
+
* <Menu.Section label="Components" defaultOpen>
|
|
158
|
+
* <Menu.List>
|
|
159
|
+
* <Menu.Item href="/button" active>Button</Menu.Item>
|
|
160
|
+
* <Menu.Item href="/card">Card</Menu.Item>
|
|
161
|
+
* </Menu.List>
|
|
162
|
+
* </Menu.Section>
|
|
163
|
+
* </Menu>
|
|
164
|
+
*/
|
|
165
|
+
export declare const MenuSection: React.FC<MenuSectionProps>;
|
|
118
166
|
export declare const Menu: React.FC<MenuProps> & {
|
|
119
167
|
Label: React.FC<MenuLabelProps>;
|
|
120
168
|
List: React.FC<MenuListProps>;
|
|
121
169
|
Item: PolymorphicComponent<MenuItemOwnProps, "a", never>;
|
|
170
|
+
Section: React.FC<MenuSectionProps>;
|
|
122
171
|
};
|
|
123
172
|
export default Menu;
|
|
@@ -17,7 +17,12 @@ export interface ImageProps extends React.HTMLAttributes<HTMLElement>, Omit<Bulm
|
|
|
17
17
|
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
|
|
18
18
|
/** Background color helper for the container. */
|
|
19
19
|
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Fixed size or aspect ratio modifier for the image container. A ratio
|
|
22
|
+
* (`16by9` and the rest) renders only its `is-<ratio>` class there. Bulma
|
|
23
|
+
* stretches an `<img>` inside to fill the ratio, but any other child, such
|
|
24
|
+
* as an `iframe`, fills it only with `className="has-ratio"` of its own.
|
|
25
|
+
*/
|
|
21
26
|
size?: '16x16' | '24x24' | '32x32' | '48x48' | '64x64' | '96x96' | '128x128' | 'square' | '1by1' | '5by4' | '4by3' | '3by2' | '5by3' | '16by9' | '2by1' | '3by1' | '4by5' | '3by4' | '2by3' | '3by5' | '9by16' | '1by2' | '1by3';
|
|
22
27
|
/** Renders the image with rounded corners. */
|
|
23
28
|
isRounded?: boolean;
|
|
@@ -5,16 +5,24 @@ import type { RefObject } from 'react';
|
|
|
5
5
|
* can read `-1` for an editable region or an `<embed>` that Tab still visits,
|
|
6
6
|
* and `0` for a `<video>` without controls that it doesn't. So a valid
|
|
7
7
|
* `tabindex` attribute decides, and otherwise the element's kind does.
|
|
8
|
-
* Internal like `
|
|
8
|
+
* Internal like `focusTabStop`: `src/index.ts` names what it takes from here.
|
|
9
9
|
*/
|
|
10
10
|
export declare function isTabbableKind(el: Element): boolean;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
14
|
-
*
|
|
12
|
+
* Moves focus to the first tab stop inside `container`, or the last when
|
|
13
|
+
* `fromLast`, and to the container when there is none. Every move a trap
|
|
14
|
+
* makes goes through here: into the container as it opens, to the other end
|
|
15
|
+
* on a wrap, and back in after a Tab the browser carried out.
|
|
16
|
+
*
|
|
17
|
+
* A stop that doesn't take focus is passed over for the next one in. An
|
|
18
|
+
* `<object>` or `<embed>` with nothing to show is one: it counts as a stop by
|
|
19
|
+
* its kind, but browsers refuse to focus it, and which ones they refuse
|
|
20
|
+
* depends on the browser and on what has loaded, so only trying tells. A
|
|
21
|
+
* stop took focus when focus moved, wherever it went (a stop can hand focus
|
|
22
|
+
* on), or when focus was on it already. `src/index.ts` names its exports from
|
|
15
23
|
* this module, so this one stays internal.
|
|
16
24
|
*/
|
|
17
|
-
export declare function
|
|
25
|
+
export declare function focusTabStop(container: HTMLElement, fromLast?: boolean): void;
|
|
18
26
|
/**
|
|
19
27
|
* Holds Tab inside the element `container` returns until the returned
|
|
20
28
|
* function is called. Tab and Shift+Tab heard on `keyTarget` wrap at the
|
|
@@ -25,7 +33,7 @@ export declare function firstTabStop(container: HTMLElement): HTMLElement | null
|
|
|
25
33
|
* overlay whose nodes are remounted while it's open, as moving to another
|
|
26
34
|
* portal target does, stays trapped without attaching again. `holds` is asked
|
|
27
35
|
* on every Tab, and the trap leaves the key alone while it says no. Internal
|
|
28
|
-
* like `
|
|
36
|
+
* like `focusTabStop`. It's for an overlay that holds Tab from a listener of
|
|
29
37
|
* its own on `window` and asks the overlay stack first, so it stands aside
|
|
30
38
|
* while another overlay is open over it, which a trap listening on the
|
|
31
39
|
* container can't do.
|
|
@@ -46,8 +54,8 @@ export interface UseFocusTrapOptions {
|
|
|
46
54
|
* to be one that can take focus, so a heading needs `tabIndex={-1}`. When
|
|
47
55
|
* focusing it doesn't put focus inside the container (the ref is empty, or
|
|
48
56
|
* its element is outside, disabled, hidden or can't take focus), focus goes
|
|
49
|
-
* to the first tab stop inside the container, and to the
|
|
50
|
-
*
|
|
57
|
+
* to the first tab stop inside the container that takes focus, and to the
|
|
58
|
+
* container itself when none does.
|
|
51
59
|
*/
|
|
52
60
|
initialFocusRef?: RefObject<HTMLElement | null>;
|
|
53
61
|
/**
|