@allxsmith/bestax-bulma 5.28.0 → 5.29.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 (43) hide show
  1. package/dist/esm/components/Dialog.js +8 -4
  2. package/dist/esm/components/Dialog.js.map +1 -1
  3. package/dist/esm/components/HoverCard.js.map +1 -1
  4. package/dist/esm/components/Modal.js +19 -11
  5. package/dist/esm/components/Modal.js.map +1 -1
  6. package/dist/esm/components/Popover.js.map +1 -1
  7. package/dist/esm/components/Sidebar.js +12 -3
  8. package/dist/esm/components/Sidebar.js.map +1 -1
  9. package/dist/esm/components/Toast.js +5 -3
  10. package/dist/esm/components/Toast.js.map +1 -1
  11. package/dist/esm/elements/Notification.js +3 -1
  12. package/dist/esm/elements/Notification.js.map +1 -1
  13. package/dist/esm/form/DateInputBase.js.map +1 -1
  14. package/dist/esm/form/DateRangeInputBase.js.map +1 -1
  15. package/dist/esm/form/DateTimeInputBase.js.map +1 -1
  16. package/dist/esm/form/TimeInputBase.js.map +1 -1
  17. package/dist/esm/form/_pickerInternals/PickerPopover.js +3 -1
  18. package/dist/esm/form/_pickerInternals/PickerPopover.js.map +1 -1
  19. package/dist/esm/helpers/Config.js +5 -2
  20. package/dist/esm/helpers/Config.js.map +1 -1
  21. package/dist/esm/helpers/portal.js +30 -5
  22. package/dist/esm/helpers/portal.js.map +1 -1
  23. package/dist/index.cjs +76 -27
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/types/components/HoverCard.d.ts +14 -12
  26. package/dist/types/components/Modal.d.ts +2 -1
  27. package/dist/types/components/Popover.d.ts +8 -7
  28. package/dist/types/form/DateInputBase.d.ts +4 -1
  29. package/dist/types/form/DateRangeInputBase.d.ts +4 -1
  30. package/dist/types/form/DateTimeInputBase.d.ts +4 -1
  31. package/dist/types/form/TimeInputBase.d.ts +2 -1
  32. package/dist/types/helpers/Config.d.ts +34 -3
  33. package/dist/types/helpers/portal.d.ts +27 -5
  34. package/dist/types-cjs/components/HoverCard.d.ts +14 -12
  35. package/dist/types-cjs/components/Modal.d.ts +2 -1
  36. package/dist/types-cjs/components/Popover.d.ts +8 -7
  37. package/dist/types-cjs/form/DateInputBase.d.ts +4 -1
  38. package/dist/types-cjs/form/DateRangeInputBase.d.ts +4 -1
  39. package/dist/types-cjs/form/DateTimeInputBase.d.ts +4 -1
  40. package/dist/types-cjs/form/TimeInputBase.d.ts +2 -1
  41. package/dist/types-cjs/helpers/Config.d.ts +34 -3
  42. package/dist/types-cjs/helpers/portal.d.ts +27 -5
  43. package/package.json +1 -1
@@ -80,18 +80,20 @@ export interface HoverCardProps extends Omit<React.HTMLAttributes<HTMLSpanElemen
80
80
  */
81
81
  position?: HoverCardPosition;
82
82
  /**
83
- * Render the card at the end of `document.body` through `Portal`, fixed to
84
- * the viewport, so an ancestor's `overflow`, `transform` or stacking
85
- * context can't clip it. A trigger in running text needs it too, since the
86
- * card's block content can't sit inside a `<p>`. The card then shows from
87
- * the commit after hydration, never in server markup, and it sits last in
88
- * the Tab order, at the end of `<body>`. Tab reaches it only after the rest
89
- * of the page, and focus leaving the trigger on the way closes it, so
90
- * keyboard users can open it, read it and close it with Escape, and
91
- * whatever it links to has to be reachable from the page as well. It is
92
- * measured against the trigger when it opens and on resize and scroll, so
93
- * it doesn't follow content that changes size while it is open. Theming
94
- * variables set on an ancestor of the trigger don't reach it there.
83
+ * Render the card through `Portal`, into the `portalContainer` a
84
+ * `ConfigProvider` sets, `document.body` by default, fixed to the viewport,
85
+ * so an ancestor's `overflow`, `transform` or stacking context can't clip
86
+ * it. A trigger in running text needs it too, since the card's block
87
+ * content can't sit inside a `<p>`. The card then shows from the commit
88
+ * after hydration, never in server markup, and it sits in the Tab order
89
+ * where its container is. At the end of `<body>`, the default, Tab reaches
90
+ * it only after the rest of the page, and focus leaving the trigger on the
91
+ * way closes it, so keyboard users can open it, read it and close it with
92
+ * Escape, and whatever it links to has to be reachable from the page as
93
+ * well. It is measured against the trigger when it opens and on resize and
94
+ * scroll, so it doesn't follow content that changes size while it is open.
95
+ * Theming variables set on an ancestor of the trigger reach it only when its
96
+ * container is inside that ancestor.
95
97
  * @defaultValue false
96
98
  */
97
99
  appendToBody?: boolean;
@@ -44,7 +44,8 @@ export interface ModalProps extends Omit<React.HTMLAttributes<HTMLDivElement>, '
44
44
  /**
45
45
  * Renders the modal into a portal target instead of inline, so it isn't
46
46
  * clipped by an ancestor with `overflow: hidden`, `filter` or `transform`.
47
- * `true` portals to `document.body`; a string is used as a
47
+ * `true` portals to the `portalContainer` a `ConfigProvider` sets,
48
+ * `document.body` by default; a string is used as a
48
49
  * `document.querySelector` selector; an element is used directly. Renders
49
50
  * inline on the server and while hydrating, moving into the portal once the
50
51
  * client takes over, so hydration matches.
@@ -53,13 +53,14 @@ export interface PopoverProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
53
53
  */
54
54
  position?: PopoverPosition;
55
55
  /**
56
- * Render the panel at the end of `document.body` through `Portal`, fixed to
57
- * the viewport, so an ancestor's `overflow`, `transform` or stacking context
58
- * can't clip it. The panel then shows from the commit after hydration,
59
- * never in server markup. It is measured against the trigger when it opens
60
- * and on resize and scroll, so it doesn't follow content that changes size
61
- * while it is open. Theming variables set on an ancestor of the trigger
62
- * don't reach it there.
56
+ * Render the panel through `Portal`, into the `portalContainer` a
57
+ * `ConfigProvider` sets, `document.body` by default, fixed to the viewport,
58
+ * so an ancestor's `overflow`, `transform` or stacking context can't clip
59
+ * it. The panel then shows from the commit after hydration, never in server
60
+ * markup. It is measured against the trigger when it opens and on resize
61
+ * and scroll, so it doesn't follow content that changes size while it is
62
+ * open. Theming variables set on an ancestor of the trigger reach it only
63
+ * when its container is inside that ancestor.
63
64
  * @defaultValue false
64
65
  */
65
66
  appendToBody?: boolean;
@@ -97,7 +97,10 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
97
97
  closeOnSelect?: boolean;
98
98
  /** Popover anchor position relative to the input. */
99
99
  position?: PickerPosition;
100
- /** Render the popover into `document.body` via portal. */
100
+ /**
101
+ * Render the popover through a portal, into the `portalContainer` a
102
+ * `ConfigProvider` sets, `document.body` by default.
103
+ */
101
104
  appendToBody?: boolean;
102
105
  /**
103
106
  * Bulma color modifier for the input, also carried by the calendar, where it
@@ -84,7 +84,10 @@ export interface DateRangeInputBaseProps extends Omit<React.HTMLAttributes<HTMLD
84
84
  closeOnSelect?: boolean;
85
85
  /** Popover anchor position relative to the field. */
86
86
  position?: PickerPosition;
87
- /** Render the popover into `document.body` via portal. */
87
+ /**
88
+ * Render the popover through a portal, into the `portalContainer` a
89
+ * `ConfigProvider` sets, `document.body` by default.
90
+ */
88
91
  appendToBody?: boolean;
89
92
  /**
90
93
  * Bulma color modifier for the field, also carried by the calendar, where it
@@ -70,7 +70,10 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
70
70
  closeOnSelect?: boolean;
71
71
  /** Popover anchor position. */
72
72
  position?: PickerPosition;
73
- /** Render the popover into `document.body` via portal. */
73
+ /**
74
+ * Render the popover through a portal, into the `portalContainer` a
75
+ * `ConfigProvider` sets, `document.body` by default.
76
+ */
74
77
  appendToBody?: boolean;
75
78
  /**
76
79
  * Bulma color modifier for the input, also carried by the calendar and the
@@ -64,7 +64,8 @@ export interface TimeInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
64
64
  /** Popover anchor position relative to the input. */
65
65
  position?: PickerPosition;
66
66
  /**
67
- * Render the popover into `document.body` via portal. On a narrow screen
67
+ * Render the popover through a portal, into the `portalContainer` a
68
+ * `ConfigProvider` sets, `document.body` by default. On a narrow screen
68
69
  * an in-place popover spans the bottom of the viewport, while a portaled
69
70
  * one stays on its `position` corner.
70
71
  */
@@ -3,13 +3,14 @@ import React, { ReactNode } from 'react';
3
3
  type IconLibrary = 'fa' | 'mdi' | 'ion' | 'material-icons' | 'material-symbols';
4
4
  /**
5
5
  * Shape of the configuration context value.
6
- *
7
- * @property {string} [classPrefix] - Prefix applied to all Bulma class names.
8
- * @property {IconLibrary} [iconLibrary] - Default icon library for Icon components.
9
6
  */
10
7
  export interface ConfigContextProps {
8
+ /** Prefix applied to all Bulma class names. */
11
9
  classPrefix?: string;
10
+ /** Default icon library for Icon components. */
12
11
  iconLibrary?: IconLibrary;
12
+ /** Where portaled content goes when it has no target of its own. */
13
+ portalContainer?: string | HTMLElement;
13
14
  }
14
15
  /**
15
16
  * Hook to access the bulma-ui configuration context.
@@ -28,10 +29,40 @@ export interface ConfigProviderProps {
28
29
  classPrefix?: string;
29
30
  /** Default icon library for Icon components. */
30
31
  iconLibrary?: IconLibrary;
32
+ /**
33
+ * Where portaled content goes when it has no target of its own: what a
34
+ * `Portal` without a `container` renders, and what the library's components
35
+ * portal, such as Popover's `appendToBody` panel, a `Modal` with `portal`
36
+ * set to `true`, or a `Toast`. An element, or a `document.querySelector`
37
+ * selector. Unset, or a selector that matches nothing, that content goes to
38
+ * `document.body`. A target a component is given, such as a `Toast`'s
39
+ * `container`, still wins, and nothing portals that would otherwise render
40
+ * in place.
41
+ *
42
+ * The overlays and panels this moves are `position: fixed`, so pick an
43
+ * element with no ancestor that has a `transform`, `filter`,
44
+ * `backdrop-filter`, `perspective`, `will-change: transform`, or a
45
+ * `contain` that includes `paint` or `layout`. That ancestor becomes their
46
+ * containing block, and they cover or line up against it instead of the
47
+ * viewport. An ancestor that starts a stacking context, with a `z-index` or
48
+ * `isolation: isolate`, keeps them inside it, under anything the page
49
+ * stacks above it. `NotificationContainer`'s status region moves too, so
50
+ * this also decides where its announcements come from, and an `aria-hidden`
51
+ * ancestor silences them.
52
+ *
53
+ * A selector can't find an element inside a shadow root, so pass the
54
+ * element itself there, held in state from a ref callback. Content that
55
+ * portals before the element is set goes to `document.body` and moves when
56
+ * it is, which remounts it, as `Portal`'s `container` describes.
57
+ */
58
+ portalContainer?: string | HTMLElement;
31
59
  }
32
60
  /**
33
61
  * ConfigProvider injects configuration into all child components via React context.
34
62
  *
63
+ * A nested provider replaces the outer one's settings rather than adding to
64
+ * them, so inside it any setting it leaves out is back to its default.
65
+ *
35
66
  * @function
36
67
  * @param {ConfigProviderProps} props - Provider props.
37
68
  * @returns {JSX.Element} The context provider wrapping children.
@@ -14,6 +14,22 @@ import React from 'react';
14
14
  * @returns The resolved DOM node to portal into.
15
15
  */
16
16
  export declare function resolvePortalContainer(container?: string | HTMLElement): HTMLElement;
17
+ /**
18
+ * Where a component's portal goes, as a function to call when the portal is
19
+ * created: the target the component was given, else the `portalContainer` a
20
+ * `ConfigProvider` sets, else `document.body`, each read as
21
+ * `resolvePortalContainer` reads it. A component that portals resolves its
22
+ * target through this, so the provider's default reaches it.
23
+ *
24
+ * The hook only reads context, so it is safe to call on the server, ahead of
25
+ * any early return. The function it returns reads the DOM, so call it only
26
+ * where the portal is created, which the server never reaches.
27
+ *
28
+ * @function usePortalContainer
29
+ * @returns A function that takes the component's own target, if any, and
30
+ * returns the DOM node to portal into.
31
+ */
32
+ export declare function usePortalContainer(): (container?: string | HTMLElement) => HTMLElement;
17
33
  /**
18
34
  * Props for the Portal component.
19
35
  */
@@ -22,8 +38,10 @@ export interface PortalProps {
22
38
  children?: React.ReactNode;
23
39
  /**
24
40
  * Where the content goes: an element, or a `document.querySelector`
25
- * selector. Omitted, empty, or a selector that matches nothing, it goes to
26
- * `document.body`. A selector is looked up again on each render, so the
41
+ * selector. Omitted or empty, it goes to the `portalContainer` a
42
+ * `ConfigProvider` sets, and to `document.body` when none is set. A
43
+ * selector that matches nothing means `document.body` too. A selector is
44
+ * looked up again on each render, so the
27
45
  * content follows the target when it changes. Moving to another target
28
46
  * remounts the children and resets their state, which includes a selector
29
47
  * that only starts matching after the content has shown in `document.body`.
@@ -39,7 +57,7 @@ export interface PortalProps {
39
57
  disabled?: boolean;
40
58
  }
41
59
  /**
42
- * Renders its children into another part of the page, `document.body` unless `container` says otherwise, so floating content escapes an ancestor's `overflow`, `transform` or stacking context.
60
+ * Renders its children into another part of the page, `document.body` unless `container` or a `ConfigProvider` says otherwise, so floating content escapes an ancestor's `overflow`, `transform` or stacking context.
43
61
  *
44
62
  * React's server renderer can't render a portal, so `Portal` renders nothing
45
63
  * on the server and during hydration, and mounts its children in the commit
@@ -50,8 +68,12 @@ export interface PortalProps {
50
68
  * portaled children, and their React events bubble through the React tree.
51
69
  * CSS inheritance follows the DOM instead: a scoped (non-`isRoot`) `Theme`
52
70
  * sets its variables on a wrapper element the portaled content has left, so
53
- * that content sees the page-level theme. Point `container` at an element
54
- * inside the themed area to keep it.
71
+ * that content sees the page-level theme, and styles scoped to a shadow root
72
+ * don't reach `document.body` at all. To keep them, portal into an element
73
+ * inside the themed area or the shadow root: pass it as `container`, or as
74
+ * the `portalContainer` of a `ConfigProvider` around that area. The second
75
+ * also reaches what the library's components portal, such as Popover's
76
+ * `appendToBody` panel or a `Modal` with `portal`.
55
77
  *
56
78
  * Tab order and focus follow the DOM too. Content portaled from inside a
57
79
  * focus trap is no longer inside the trapped element, so the trap neither
@@ -80,18 +80,20 @@ export interface HoverCardProps extends Omit<React.HTMLAttributes<HTMLSpanElemen
80
80
  */
81
81
  position?: HoverCardPosition;
82
82
  /**
83
- * Render the card at the end of `document.body` through `Portal`, fixed to
84
- * the viewport, so an ancestor's `overflow`, `transform` or stacking
85
- * context can't clip it. A trigger in running text needs it too, since the
86
- * card's block content can't sit inside a `<p>`. The card then shows from
87
- * the commit after hydration, never in server markup, and it sits last in
88
- * the Tab order, at the end of `<body>`. Tab reaches it only after the rest
89
- * of the page, and focus leaving the trigger on the way closes it, so
90
- * keyboard users can open it, read it and close it with Escape, and
91
- * whatever it links to has to be reachable from the page as well. It is
92
- * measured against the trigger when it opens and on resize and scroll, so
93
- * it doesn't follow content that changes size while it is open. Theming
94
- * variables set on an ancestor of the trigger don't reach it there.
83
+ * Render the card through `Portal`, into the `portalContainer` a
84
+ * `ConfigProvider` sets, `document.body` by default, fixed to the viewport,
85
+ * so an ancestor's `overflow`, `transform` or stacking context can't clip
86
+ * it. A trigger in running text needs it too, since the card's block
87
+ * content can't sit inside a `<p>`. The card then shows from the commit
88
+ * after hydration, never in server markup, and it sits in the Tab order
89
+ * where its container is. At the end of `<body>`, the default, Tab reaches
90
+ * it only after the rest of the page, and focus leaving the trigger on the
91
+ * way closes it, so keyboard users can open it, read it and close it with
92
+ * Escape, and whatever it links to has to be reachable from the page as
93
+ * well. It is measured against the trigger when it opens and on resize and
94
+ * scroll, so it doesn't follow content that changes size while it is open.
95
+ * Theming variables set on an ancestor of the trigger reach it only when its
96
+ * container is inside that ancestor.
95
97
  * @defaultValue false
96
98
  */
97
99
  appendToBody?: boolean;
@@ -44,7 +44,8 @@ export interface ModalProps extends Omit<React.HTMLAttributes<HTMLDivElement>, '
44
44
  /**
45
45
  * Renders the modal into a portal target instead of inline, so it isn't
46
46
  * clipped by an ancestor with `overflow: hidden`, `filter` or `transform`.
47
- * `true` portals to `document.body`; a string is used as a
47
+ * `true` portals to the `portalContainer` a `ConfigProvider` sets,
48
+ * `document.body` by default; a string is used as a
48
49
  * `document.querySelector` selector; an element is used directly. Renders
49
50
  * inline on the server and while hydrating, moving into the portal once the
50
51
  * client takes over, so hydration matches.
@@ -53,13 +53,14 @@ export interface PopoverProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
53
53
  */
54
54
  position?: PopoverPosition;
55
55
  /**
56
- * Render the panel at the end of `document.body` through `Portal`, fixed to
57
- * the viewport, so an ancestor's `overflow`, `transform` or stacking context
58
- * can't clip it. The panel then shows from the commit after hydration,
59
- * never in server markup. It is measured against the trigger when it opens
60
- * and on resize and scroll, so it doesn't follow content that changes size
61
- * while it is open. Theming variables set on an ancestor of the trigger
62
- * don't reach it there.
56
+ * Render the panel through `Portal`, into the `portalContainer` a
57
+ * `ConfigProvider` sets, `document.body` by default, fixed to the viewport,
58
+ * so an ancestor's `overflow`, `transform` or stacking context can't clip
59
+ * it. The panel then shows from the commit after hydration, never in server
60
+ * markup. It is measured against the trigger when it opens and on resize
61
+ * and scroll, so it doesn't follow content that changes size while it is
62
+ * open. Theming variables set on an ancestor of the trigger reach it only
63
+ * when its container is inside that ancestor.
63
64
  * @defaultValue false
64
65
  */
65
66
  appendToBody?: boolean;
@@ -97,7 +97,10 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
97
97
  closeOnSelect?: boolean;
98
98
  /** Popover anchor position relative to the input. */
99
99
  position?: PickerPosition;
100
- /** Render the popover into `document.body` via portal. */
100
+ /**
101
+ * Render the popover through a portal, into the `portalContainer` a
102
+ * `ConfigProvider` sets, `document.body` by default.
103
+ */
101
104
  appendToBody?: boolean;
102
105
  /**
103
106
  * Bulma color modifier for the input, also carried by the calendar, where it
@@ -84,7 +84,10 @@ export interface DateRangeInputBaseProps extends Omit<React.HTMLAttributes<HTMLD
84
84
  closeOnSelect?: boolean;
85
85
  /** Popover anchor position relative to the field. */
86
86
  position?: PickerPosition;
87
- /** Render the popover into `document.body` via portal. */
87
+ /**
88
+ * Render the popover through a portal, into the `portalContainer` a
89
+ * `ConfigProvider` sets, `document.body` by default.
90
+ */
88
91
  appendToBody?: boolean;
89
92
  /**
90
93
  * Bulma color modifier for the field, also carried by the calendar, where it
@@ -70,7 +70,10 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
70
70
  closeOnSelect?: boolean;
71
71
  /** Popover anchor position. */
72
72
  position?: PickerPosition;
73
- /** Render the popover into `document.body` via portal. */
73
+ /**
74
+ * Render the popover through a portal, into the `portalContainer` a
75
+ * `ConfigProvider` sets, `document.body` by default.
76
+ */
74
77
  appendToBody?: boolean;
75
78
  /**
76
79
  * Bulma color modifier for the input, also carried by the calendar and the
@@ -64,7 +64,8 @@ export interface TimeInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
64
64
  /** Popover anchor position relative to the input. */
65
65
  position?: PickerPosition;
66
66
  /**
67
- * Render the popover into `document.body` via portal. On a narrow screen
67
+ * Render the popover through a portal, into the `portalContainer` a
68
+ * `ConfigProvider` sets, `document.body` by default. On a narrow screen
68
69
  * an in-place popover spans the bottom of the viewport, while a portaled
69
70
  * one stays on its `position` corner.
70
71
  */
@@ -3,13 +3,14 @@ import React, { ReactNode } from 'react';
3
3
  type IconLibrary = 'fa' | 'mdi' | 'ion' | 'material-icons' | 'material-symbols';
4
4
  /**
5
5
  * Shape of the configuration context value.
6
- *
7
- * @property {string} [classPrefix] - Prefix applied to all Bulma class names.
8
- * @property {IconLibrary} [iconLibrary] - Default icon library for Icon components.
9
6
  */
10
7
  export interface ConfigContextProps {
8
+ /** Prefix applied to all Bulma class names. */
11
9
  classPrefix?: string;
10
+ /** Default icon library for Icon components. */
12
11
  iconLibrary?: IconLibrary;
12
+ /** Where portaled content goes when it has no target of its own. */
13
+ portalContainer?: string | HTMLElement;
13
14
  }
14
15
  /**
15
16
  * Hook to access the bulma-ui configuration context.
@@ -28,10 +29,40 @@ export interface ConfigProviderProps {
28
29
  classPrefix?: string;
29
30
  /** Default icon library for Icon components. */
30
31
  iconLibrary?: IconLibrary;
32
+ /**
33
+ * Where portaled content goes when it has no target of its own: what a
34
+ * `Portal` without a `container` renders, and what the library's components
35
+ * portal, such as Popover's `appendToBody` panel, a `Modal` with `portal`
36
+ * set to `true`, or a `Toast`. An element, or a `document.querySelector`
37
+ * selector. Unset, or a selector that matches nothing, that content goes to
38
+ * `document.body`. A target a component is given, such as a `Toast`'s
39
+ * `container`, still wins, and nothing portals that would otherwise render
40
+ * in place.
41
+ *
42
+ * The overlays and panels this moves are `position: fixed`, so pick an
43
+ * element with no ancestor that has a `transform`, `filter`,
44
+ * `backdrop-filter`, `perspective`, `will-change: transform`, or a
45
+ * `contain` that includes `paint` or `layout`. That ancestor becomes their
46
+ * containing block, and they cover or line up against it instead of the
47
+ * viewport. An ancestor that starts a stacking context, with a `z-index` or
48
+ * `isolation: isolate`, keeps them inside it, under anything the page
49
+ * stacks above it. `NotificationContainer`'s status region moves too, so
50
+ * this also decides where its announcements come from, and an `aria-hidden`
51
+ * ancestor silences them.
52
+ *
53
+ * A selector can't find an element inside a shadow root, so pass the
54
+ * element itself there, held in state from a ref callback. Content that
55
+ * portals before the element is set goes to `document.body` and moves when
56
+ * it is, which remounts it, as `Portal`'s `container` describes.
57
+ */
58
+ portalContainer?: string | HTMLElement;
31
59
  }
32
60
  /**
33
61
  * ConfigProvider injects configuration into all child components via React context.
34
62
  *
63
+ * A nested provider replaces the outer one's settings rather than adding to
64
+ * them, so inside it any setting it leaves out is back to its default.
65
+ *
35
66
  * @function
36
67
  * @param {ConfigProviderProps} props - Provider props.
37
68
  * @returns {JSX.Element} The context provider wrapping children.
@@ -14,6 +14,22 @@ import React from 'react';
14
14
  * @returns The resolved DOM node to portal into.
15
15
  */
16
16
  export declare function resolvePortalContainer(container?: string | HTMLElement): HTMLElement;
17
+ /**
18
+ * Where a component's portal goes, as a function to call when the portal is
19
+ * created: the target the component was given, else the `portalContainer` a
20
+ * `ConfigProvider` sets, else `document.body`, each read as
21
+ * `resolvePortalContainer` reads it. A component that portals resolves its
22
+ * target through this, so the provider's default reaches it.
23
+ *
24
+ * The hook only reads context, so it is safe to call on the server, ahead of
25
+ * any early return. The function it returns reads the DOM, so call it only
26
+ * where the portal is created, which the server never reaches.
27
+ *
28
+ * @function usePortalContainer
29
+ * @returns A function that takes the component's own target, if any, and
30
+ * returns the DOM node to portal into.
31
+ */
32
+ export declare function usePortalContainer(): (container?: string | HTMLElement) => HTMLElement;
17
33
  /**
18
34
  * Props for the Portal component.
19
35
  */
@@ -22,8 +38,10 @@ export interface PortalProps {
22
38
  children?: React.ReactNode;
23
39
  /**
24
40
  * Where the content goes: an element, or a `document.querySelector`
25
- * selector. Omitted, empty, or a selector that matches nothing, it goes to
26
- * `document.body`. A selector is looked up again on each render, so the
41
+ * selector. Omitted or empty, it goes to the `portalContainer` a
42
+ * `ConfigProvider` sets, and to `document.body` when none is set. A
43
+ * selector that matches nothing means `document.body` too. A selector is
44
+ * looked up again on each render, so the
27
45
  * content follows the target when it changes. Moving to another target
28
46
  * remounts the children and resets their state, which includes a selector
29
47
  * that only starts matching after the content has shown in `document.body`.
@@ -39,7 +57,7 @@ export interface PortalProps {
39
57
  disabled?: boolean;
40
58
  }
41
59
  /**
42
- * Renders its children into another part of the page, `document.body` unless `container` says otherwise, so floating content escapes an ancestor's `overflow`, `transform` or stacking context.
60
+ * Renders its children into another part of the page, `document.body` unless `container` or a `ConfigProvider` says otherwise, so floating content escapes an ancestor's `overflow`, `transform` or stacking context.
43
61
  *
44
62
  * React's server renderer can't render a portal, so `Portal` renders nothing
45
63
  * on the server and during hydration, and mounts its children in the commit
@@ -50,8 +68,12 @@ export interface PortalProps {
50
68
  * portaled children, and their React events bubble through the React tree.
51
69
  * CSS inheritance follows the DOM instead: a scoped (non-`isRoot`) `Theme`
52
70
  * sets its variables on a wrapper element the portaled content has left, so
53
- * that content sees the page-level theme. Point `container` at an element
54
- * inside the themed area to keep it.
71
+ * that content sees the page-level theme, and styles scoped to a shadow root
72
+ * don't reach `document.body` at all. To keep them, portal into an element
73
+ * inside the themed area or the shadow root: pass it as `container`, or as
74
+ * the `portalContainer` of a `ConfigProvider` around that area. The second
75
+ * also reaches what the library's components portal, such as Popover's
76
+ * `appendToBody` panel or a `Modal` with `portal`.
55
77
  *
56
78
  * Tab order and focus follow the DOM too. Content portaled from inside a
57
79
  * focus trap is no longer inside the trapped element, so the trap neither
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allxsmith/bestax-bulma",
3
- "version": "5.28.0",
3
+ "version": "5.29.0",
4
4
  "description": "A fully-typed React component library for the Bulma CSS framework. Build modern UIs quickly with reusable, accessible, and customizable Bulma-based React components.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.esm.js",