@allxsmith/bestax-bulma 5.16.8 → 5.16.10

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/index.esm.js CHANGED
@@ -1279,6 +1279,22 @@ const avatarSizes = [
1279
1279
  '96x96',
1280
1280
  '128x128',
1281
1281
  ];
1282
+ /**
1283
+ * The roles a caller can use to say "this avatar is not a control", and so claim
1284
+ * the non-interactive treatment for a custom `as` target we would otherwise have
1285
+ * to guess about.
1286
+ *
1287
+ * Read by VALUE, not by presence. Any role at all used to count, which let
1288
+ * `role="button"` — a claim of the opposite — route a real control into the
1289
+ * decorative branch and come out `aria-hidden` and nameless. `img` is what the
1290
+ * fallback itself applies; `presentation` and `none` are the standard ways to say
1291
+ * an element carries no semantics, which is what pairs with `alt=""`.
1292
+ */
1293
+ const NON_INTERACTIVE_ROLES = [
1294
+ 'img',
1295
+ 'presentation',
1296
+ 'none',
1297
+ ];
1282
1298
  /**
1283
1299
  * Derives a small set of initials from a name (e.g. "Ada Lovelace" -> "AL").
1284
1300
  */
@@ -1373,13 +1389,44 @@ const Avatar = forwardRef(function Avatar(avatarProps, ref) {
1373
1389
  const combinedClasses = classNames(avatarClasses, bulmaHelperClasses, className);
1374
1390
  const initialsClass = usePrefixedClassNames('avatar-initials');
1375
1391
  const Tag = as ?? (href ? 'a' : 'figure');
1376
- // A custom `as` component given an href is being used as a link — the same
1377
- // condition under which isLinkLike forwards href/target/rel below — so it
1378
- // counts as interactive too. Otherwise alt="" would mark a real link
1379
- // decorative (aria-hidden) and it could render nameless.
1392
+ // A custom component counts as interactive whether or not it was given OUR
1393
+ // href: a router link takes `to`, creates the anchor itself, and cannot be
1394
+ // classified from the props it arrives with (#668). Marking a real link as a
1395
+ // picture is the worse failure — and `alt=""` would go further and mark it
1396
+ // decorative (aria-hidden), leaving it nameless.
1397
+ //
1398
+ // A custom ELEMENT still needs the href. A hyphenated tag renders a real DOM
1399
+ // element of that name, so nothing is hidden from us: without a link to follow
1400
+ // it is still a picture. `Navbar.Link` draws the same line for `role="button"`.
1401
+ //
1402
+ // Where we are guessing, the caller settles it: an explicit `role` or
1403
+ // `aria-hidden` states the semantics, so a custom component that really is a
1404
+ // wrapper gets `role="img"` and its `alt=""` opt-out back. `role` alone would
1405
+ // be a half-override — interactivity also drives the decorative opt-out and the
1406
+ // name fallback, and overriding one of the three is worse than overriding none.
1407
+ //
1408
+ // An `href` ENDS the guess, so it outranks the signal. `as="a"`, `as="button"`
1409
+ // and a target we were handed an href for are known to be interactive, and there
1410
+ // the rule that an interactive element always carries an accessible name is not
1411
+ // the caller's to waive: without this, `as={RouterLink} href="/x" role="img"`
1412
+ // with `alt=""` rendered a real anchor as `aria-hidden` and nameless — the very
1413
+ // failure #668 is about. `Navbar.Link` orders the same two the same way.
1414
+ //
1415
+ // The signal has to MEAN what it is used for, so both halves read a value rather
1416
+ // than a presence — the way `Navbar.Link` reads `role === 'button'`. A role only
1417
+ // claims to be a picture if it says so: `role="button"` or `role="link"` is the
1418
+ // opposite claim, and taking any role as the signal handed an interactive-role
1419
+ // element `aria-hidden` and no name. Likewise `aria-hidden={false}` denies
1420
+ // hiding, so only a truthy one counts.
1421
+ const ariaHidden = rest['aria-hidden'];
1422
+ const statesItIsNotAControl = (rest.role !== undefined && NON_INTERACTIVE_ROLES.includes(rest.role)) ||
1423
+ ariaHidden === true ||
1424
+ ariaHidden === 'true';
1425
+ const customTargetStatesSemantics = typeof Tag !== 'string' && href == null && statesItIsNotAControl;
1380
1426
  const isInteractive = Tag === 'a' ||
1381
1427
  Tag === 'button' ||
1382
- ((typeof Tag !== 'string' || isCustomElement(Tag)) && href != null);
1428
+ (typeof Tag !== 'string' && !customTargetStatesSemantics) ||
1429
+ (isCustomElement(Tag) && href != null);
1383
1430
  // Only forward link attributes when rendering an anchor or a custom (non-DOM)
1384
1431
  // component; a plain `as="div"` must not receive a stray `href`/`target`/`rel`.
1385
1432
  const isLinkLike = Tag === 'a' || typeof Tag !== 'string' || isCustomElement(Tag);
@@ -1641,18 +1688,6 @@ const Breadcrumb = ({ className, alignment, separator, size, children, ...props
1641
1688
  */
1642
1689
  const mergeBulmaStyles = (helperStyles, style) => helperStyles || style ? { ...helperStyles, ...style } : undefined;
1643
1690
 
1644
- /**
1645
- * Wrap each footer item in a `.card-footer-item` span.
1646
- * @param {CardProps['footer']} footer - Footer content (single node or array).
1647
- * @param {string | undefined} classPrefix - Bulma class prefix.
1648
- * @returns {React.ReactNode[] | null} Wrapped footer items, or null if no footer.
1649
- */
1650
- const renderFooter = (footer, classPrefix) => {
1651
- if (!footer)
1652
- return null;
1653
- const items = Array.isArray(footer) ? footer : [footer];
1654
- return items.map((item, idx) => (jsx("span", { className: prefixedClassNames(classPrefix, 'card-footer-item'), children: item }, idx)));
1655
- };
1656
1691
  /**
1657
1692
  * Check if children contain any Card compound sub-components.
1658
1693
  * @param {React.ReactNode} children - The children to inspect.
@@ -1700,6 +1735,9 @@ const CardComponent = ({ className, children, textColor, color, bgColor, hasShad
1700
1735
  'is-centered': headerCentered,
1701
1736
  }), children: header })), headerIcon] }));
1702
1737
  };
1738
+ // Any falsy footer (including `0`) and an empty array render no footer bar,
1739
+ // rather than a stray `0` or an empty `.card-footer`.
1740
+ const hasFooter = Array.isArray(footer) ? footer.length > 0 : Boolean(footer);
1703
1741
  return (jsxs("div", { className: cardClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: [renderHeader(header, headerIcon, headerCentered, classPrefix), image && (jsx("div", { className: prefixedClassNames(classPrefix, 'card-image'), children: typeof image === 'string' ? (jsx("figure", { className: prefixedClassNames(classPrefix, 'image'), children: jsx("img", { src: image, alt: imageAlt ?? 'Card image' }) })) : (image) })), typeof children !== 'undefined' &&
1704
1742
  children !== null &&
1705
1743
  children !== '' &&
@@ -1707,9 +1745,7 @@ const CardComponent = ({ className, children, textColor, color, bgColor, hasShad
1707
1745
  children !== null &&
1708
1746
  children !== '' &&
1709
1747
  hasCompoundComponents(children) &&
1710
- children, footer && (jsx("footer", { className: prefixedClassNames(classPrefix, 'card-footer'), children: Array.isArray(footer)
1711
- ? footer.map((item, idx) => (jsx("span", { className: prefixedClassNames(classPrefix, 'card-footer-item'), children: item }, idx)))
1712
- : footer && (jsx("span", { className: prefixedClassNames(classPrefix, 'card-footer-item'), children: footer })) }))] }));
1748
+ children, hasFooter && (jsx("footer", { className: prefixedClassNames(classPrefix, 'card-footer'), children: Array.isArray(footer) ? (footer.map((item, idx) => (jsx("span", { className: prefixedClassNames(classPrefix, 'card-footer-item'), children: item }, idx)))) : (jsx("span", { className: prefixedClassNames(classPrefix, 'card-footer-item'), children: footer })) }))] }));
1713
1749
  };
1714
1750
  /**
1715
1751
  * Card header compound component. Wraps children in a `.card-header` element.
@@ -1839,8 +1875,6 @@ const Card = withSubComponents(CardComponent, {
1839
1875
  Footer: CardFooter,
1840
1876
  FooterItem: CardFooterItem,
1841
1877
  }, 'Card');
1842
- /** Internal test-only exports. Not part of the public API. */
1843
- const __test_exports__ = { renderFooter };
1844
1878
 
1845
1879
  /**
1846
1880
  * The runtime mirror of `AnchorOnlyAttributes`, keyed so the two cannot drift.
@@ -1913,6 +1947,9 @@ function omitAttrs(props, strip) {
1913
1947
 
1914
1948
  /**
1915
1949
  * Checks if code is running in a browser environment.
1950
+ * @deprecated Dropdown's internal SSR guard, exported by accident; it will
1951
+ * be removed in the next major. Check `typeof window !== 'undefined' &&
1952
+ * typeof document !== 'undefined'` instead.
1916
1953
  * @param win - Window object.
1917
1954
  * @param doc - Document object.
1918
1955
  * @returns {boolean} True if in browser, false otherwise.
@@ -2015,7 +2052,10 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
2015
2052
  /* istanbul ignore next: dropdownRef.current is never null once mounted */
2016
2053
  if (!dropdownRef.current)
2017
2054
  return [];
2018
- return Array.from(dropdownRef.current.querySelectorAll('[role="menuitem"]')).filter(el => !el.hasAttribute('disabled') &&
2055
+ return Array.from(
2056
+ // Every menu-item role, so an item a caller gives `menuitemcheckbox`
2057
+ // or `menuitemradio` (a filter or sort menu) stays reachable.
2058
+ dropdownRef.current.querySelectorAll('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]')).filter(el => !el.hasAttribute('disabled') &&
2019
2059
  el.getAttribute('aria-disabled') !== 'true');
2020
2060
  };
2021
2061
  // Focus the pending menu item once the menu becomes visible; the item is
@@ -2183,7 +2223,11 @@ const DropdownItem = ((itemProps) => {
2183
2223
  const forwarded = Component === 'a' ? rest : omitAttrs(rest, STRIP_FROM_NON_ANCHOR$1);
2184
2224
  return (jsx(Component, { className: classNames(usePrefixedClassNames('dropdown-item', {
2185
2225
  'is-active': active,
2186
- }), bulmaHelperClasses, className), tabIndex: 0, role: "menuitem", "data-testid": "dropdown-item", ...forwarded, ...(Component === 'button'
2226
+ }), bulmaHelperClasses, className), tabIndex: 0, "data-testid": "dropdown-item", ...forwarded,
2227
+ // After `forwarded` for the same reason as `type` below: a spread
2228
+ // carrying `role: undefined` would otherwise erase the default, and an
2229
+ // item with no role drops out of the menu and its arrow-key order.
2230
+ role: forwarded.role ?? 'menuitem', ...(Component === 'button'
2187
2231
  ? {
2188
2232
  type: forwarded.type ?? 'button',
2189
2233
  }
@@ -2838,7 +2882,7 @@ const NavbarBurger = forwardRef(function NavbarBurger({ className, active, child
2838
2882
  });
2839
2883
  return (jsxs("button", { ref: ref, type: "button", className: classNames(usePrefixedClassNames('navbar-burger', {
2840
2884
  'is-active': active,
2841
- }), bulmaHelperClasses, className), "aria-label": props['aria-label'] || 'menu', "aria-expanded": props['aria-expanded'] ?? !!active, ...rest, children: [jsx("span", { "aria-hidden": "true" }), jsx("span", { "aria-hidden": "true" }), jsx("span", { "aria-hidden": "true" }), children] }));
2885
+ }), bulmaHelperClasses, className), "aria-label": props['aria-label'] || 'menu', "aria-expanded": props['aria-expanded'] ?? !!active, ...rest, children: [jsx("span", { "aria-hidden": "true" }), jsx("span", { "aria-hidden": "true" }), jsx("span", { "aria-hidden": "true" }), jsx("span", { "aria-hidden": "true" }), children] }));
2842
2886
  });
2843
2887
  NavbarBurger.displayName = 'NavbarBurger';
2844
2888
  /**
@@ -2899,7 +2943,27 @@ const NavbarLink = forwardRef(function NavbarLink(linkProps, ref) {
2899
2943
  });
2900
2944
  const dropdownContext = useContext(NavbarDropdownContext);
2901
2945
  const hasHref = rest.href !== undefined;
2902
- const isNativeInteractive = Component === 'button' || hasHref;
2946
+ // What a custom component renders cannot be read off its input props, and the
2947
+ // prop that ends in an anchor belongs to the router, not to us — `to`, `state`,
2948
+ // `params` and a dozen further spellings all get there. Sniffing for more names
2949
+ // trades one wrong guess for another, so a non-string `as` counts as
2950
+ // interactive: announcing a real anchor as a button, and layering a synthetic
2951
+ // click over its navigation, is the worse of the two failures (#668).
2952
+ //
2953
+ // A custom ELEMENT stays out of it. A hyphenated tag is a real DOM element and
2954
+ // none of those is natively interactive, so `<x-trigger>` keeps the fallback
2955
+ // exactly like `as="span"` — the same line `Avatar` draws for `role="img"`.
2956
+ //
2957
+ // Where we are guessing, the caller settles it: a custom target that declares
2958
+ // `role="button"` is saying it is a button and not a link, so it takes the
2959
+ // whole fallback — including the click, which is the half it could not supply
2960
+ // itself. `Avatar` gives the same escape hatch to the same guess. An `href`
2961
+ // still wins: a target with somewhere to navigate is a link whatever role it
2962
+ // claims.
2963
+ const customTargetIsButton = typeof Component !== 'string' && rest.role === 'button';
2964
+ const isNativeInteractive = Component === 'button' ||
2965
+ (typeof Component !== 'string' && !customTargetIsButton) ||
2966
+ hasHref;
2903
2967
  // Guarded like Button's disabled blocker: these run on whatever `as` renders,
2904
2968
  // and a custom target's callback need not take a DOM event. One declaring
2905
2969
  // `onKeyDown: (k: {key: string}) => void` reaches `e.preventDefault()` and
@@ -6100,6 +6164,7 @@ const notification = {
6100
6164
  const NotificationItem = ({ instance, onClose }) => {
6101
6165
  const { message, color, isLight, duration = 3000, hasDelete = true, indefinite = false, pauseOnHover = true, } = instance.options;
6102
6166
  const [isPaused, setIsPaused] = useState(false);
6167
+ const urgent = color === 'danger' || color === 'warning';
6103
6168
  const handleClose = useCallback(() => {
6104
6169
  onClose(instance.id);
6105
6170
  }, [onClose, instance.id]);
@@ -6118,11 +6183,13 @@ const NotificationItem = ({ instance, onClose }) => {
6118
6183
  if (pauseOnHover)
6119
6184
  setIsPaused(false);
6120
6185
  }, [pauseOnHover]);
6121
- return (jsx(Notification, { color: color, isLight: isLight, hasDelete: hasDelete, onDelete: handleClose, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: { pointerEvents: 'auto' }, children: message }));
6186
+ return (jsx(Notification, { color: color, isLight: isLight, hasDelete: hasDelete, onDelete: handleClose, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: { pointerEvents: 'auto' }, children: urgent ? (jsx("span", { role: "alert", "aria-live": "assertive", children: message })) : (jsx("span", { role: "status", "aria-live": "polite", children: message })) }));
6122
6187
  };
6123
6188
  /**
6124
6189
  * Container component for rendering programmatic notifications.
6125
- * Place once at your app root to enable the notification API.
6190
+ * Place once at your app root to enable the notification API. Mount it
6191
+ * before calling `notification`: a notification shown while no container is
6192
+ * mounted doesn't appear when one mounts, only alongside the next call.
6126
6193
  *
6127
6194
  * @function
6128
6195
  * @param {{ position?: NotificationPosition }} props - Container props.
@@ -13280,5 +13347,5 @@ const Section = ({ size, className, children, color, bgColor, textColor, style,
13280
13347
  return (jsx("section", { className: sectionClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
13281
13348
  };
13282
13349
 
13283
- export { Autocomplete, Avatar, Avatars, Badge, Block, Box, Breadcrumb, Button, Buttons, Card, Carousel, CarouselItem, Cell, Checkbox, Checkboxes, Code, Collapse, Column, Columns, ConfigProvider, Container, Content, Control, DateInput, DateInputBase, DateTimeInput, DateTimeInputBase, Delete, Dialog, DialogContainer, Divider, Dropdown, DropdownDivider, DropdownItem, Emphasis, Field, FieldBody, FieldLabel, Figure, File, Footer, Grid, Hero, HeroBody, HeroFoot, HeroHead, Icon, IconText, Image, Input, InputBase, Level, LevelItem, LevelLeft, LevelRight, Link, LinkButton, ListItem, Loading, Media, MediaContent, MediaLeft, MediaRight, Menu, MenuItem, MenuLabel, MenuList, Message, Modal, Navbar, NavbarBrand, NavbarBurger, NavbarDivider, NavbarDropdown, NavbarDropdownMenu, NavbarEnd, NavbarItem, NavbarLink, NavbarMenu, NavbarStart, Notification, NotificationContainer, NumberInput, Numberinput, OrderedList, Pagination, PaginationEllipsis, PaginationLink, PaginationList, PaginationNext, PaginationPrevious, Panel, PanelBlock, PanelButtonBlock, PanelCheckboxBlock, PanelHeading, PanelIcon, PanelInputBlock, PanelTabs, Paragraph, Pre, Progress, Radio, Radios, Rate, Reveal, Section, Select, SelectBase, Sidebar, Skeleton, Slider, Span, Step, Steps, Strong, SubTitle, Switch, Tab, TabContentItem, TabItem, TabList, Table, Tabs, TabsContent, Tag, TagInput, Taginput, Tags, Tbody, Td, TextArea, TextAreaBase, Tfoot, Th, Thead, Theme, TimeInput, TimeInputBase, Title, Toast, ToastContainer, Tooltip, Tr, UnorderedList, __test_exports__, checkboxColors, checkboxSizes, classNames, createPrefixedClassNames, dialog, isBrowser$1 as isBrowser, mergeBulmaStyles, notification, prefixedClassNames, radioColors, radioSizes, switchColors, switchSizes, toast, useBulmaClasses, useClassPrefix, useColorClasses, useColorStyles, useConfig, useFlexboxClasses, useIconLibrary, useInsideControl, useInsideField, useOtherClasses, usePrefixedClass, usePrefixedClassNames, useSpacingClasses, useTypographyClasses, useVisibilityClasses, validAlignContents, validAlignItems, validAlignSelfs, validAlignments$1 as validAlignments, validColorShades, validColors, validCursors, validDisplays, validFlexDirections, validFlexGrowShrink, validFlexWraps, validFloats, validFontFamilies, validInteractions, validJustifyContents, validOverflows, validRadii, validResponsives, validSchemeColors, validShadows, validSizes$1 as validSizes, validTableColors, validTextSizes, validTextTransforms, validTextWeights, validViewports, validVisibilities };
13350
+ export { Autocomplete, Avatar, Avatars, Badge, Block, Box, Breadcrumb, Button, Buttons, Card, Carousel, CarouselItem, Cell, Checkbox, Checkboxes, Code, Collapse, Column, Columns, ConfigProvider, Container, Content, Control, DateInput, DateInputBase, DateTimeInput, DateTimeInputBase, Delete, Dialog, DialogContainer, Divider, Dropdown, DropdownDivider, DropdownItem, Emphasis, Field, FieldBody, FieldLabel, Figure, File, Footer, Grid, Hero, HeroBody, HeroFoot, HeroHead, Icon, IconText, Image, Input, InputBase, Level, LevelItem, LevelLeft, LevelRight, Link, LinkButton, ListItem, Loading, Media, MediaContent, MediaLeft, MediaRight, Menu, MenuItem, MenuLabel, MenuList, Message, Modal, Navbar, NavbarBrand, NavbarBurger, NavbarDivider, NavbarDropdown, NavbarDropdownMenu, NavbarEnd, NavbarItem, NavbarLink, NavbarMenu, NavbarStart, Notification, NotificationContainer, NumberInput, Numberinput, OrderedList, Pagination, PaginationEllipsis, PaginationLink, PaginationList, PaginationNext, PaginationPrevious, Panel, PanelBlock, PanelButtonBlock, PanelCheckboxBlock, PanelHeading, PanelIcon, PanelInputBlock, PanelTabs, Paragraph, Pre, Progress, Radio, Radios, Rate, Reveal, Section, Select, SelectBase, Sidebar, Skeleton, Slider, Span, Step, Steps, Strong, SubTitle, Switch, Tab, TabContentItem, TabItem, TabList, Table, Tabs, TabsContent, Tag, TagInput, Taginput, Tags, Tbody, Td, TextArea, TextAreaBase, Tfoot, Th, Thead, Theme, TimeInput, TimeInputBase, Title, Toast, ToastContainer, Tooltip, Tr, UnorderedList, checkboxColors, checkboxSizes, classNames, createPrefixedClassNames, dialog, isBrowser$1 as isBrowser, mergeBulmaStyles, notification, prefixedClassNames, radioColors, radioSizes, switchColors, switchSizes, toast, useBulmaClasses, useClassPrefix, useColorClasses, useColorStyles, useConfig, useFlexboxClasses, useIconLibrary, useInsideControl, useInsideField, useOtherClasses, usePrefixedClass, usePrefixedClassNames, useSpacingClasses, useTypographyClasses, useVisibilityClasses, validAlignContents, validAlignItems, validAlignSelfs, validAlignments$1 as validAlignments, validColorShades, validColors, validCursors, validDisplays, validFlexDirections, validFlexGrowShrink, validFlexWraps, validFloats, validFontFamilies, validInteractions, validJustifyContents, validOverflows, validRadii, validResponsives, validSchemeColors, validShadows, validSizes$1 as validSizes, validTableColors, validTextSizes, validTextTransforms, validTextWeights, validViewports, validVisibilities };
13284
13351
  //# sourceMappingURL=index.esm.js.map