@allxsmith/bestax-bulma 5.10.0 → 5.11.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/index.cjs.js CHANGED
@@ -246,6 +246,22 @@ const validColorShades = [
246
246
  'bold',
247
247
  'on-scheme',
248
248
  ];
249
+ /**
250
+ * Valid Bulma scheme color names for scheme-aware backgrounds.
251
+ *
252
+ * Bulma ships no `has-background-scheme-*` helper classes, so these values
253
+ * never emit a class — components render them as a dark-mode-safe inline
254
+ * `background-color: var(--bulma-<value>)` style instead.
255
+ * @example 'scheme-main', 'scheme-main-bis', 'scheme-invert'
256
+ */
257
+ const validSchemeColors = [
258
+ 'scheme-main',
259
+ 'scheme-main-bis',
260
+ 'scheme-main-ter',
261
+ 'scheme-invert',
262
+ 'scheme-invert-bis',
263
+ 'scheme-invert-ter',
264
+ ];
249
265
  /**
250
266
  * Valid Bulma size classes for margins and paddings.
251
267
  * @example '0', '1', 'auto'
@@ -437,6 +453,10 @@ const createBulmaClassHelpers = (classPrefix, viewport) => {
437
453
  /**
438
454
  * A hook that generates Bulma text and background color helper classes.
439
455
  *
456
+ * Scheme background values (`scheme-main`, `scheme-main-bis`, …) are dropped
457
+ * from class emission — Bulma ships no `has-background-scheme-*` classes; use
458
+ * {@link useColorStyles} to render them as an inline style.
459
+ *
440
460
  * @function useColorClasses
441
461
  * @param props - Color-related Bulma helper props.
442
462
  * @returns A space-separated string of color helper classes.
@@ -473,6 +493,38 @@ const useColorClasses = (props) => {
473
493
  return classNames(classes);
474
494
  }, [classPrefix, color, colorShade, backgroundColor, backgroundColorShade]);
475
495
  };
496
+ /**
497
+ * A hook that generates inline styles for scheme-aware color props.
498
+ *
499
+ * When `backgroundColor` is one of the scheme color names in
500
+ * `validSchemeColors`, returns `{ backgroundColor: 'var(--bulma-<value>)' }` —
501
+ * an inline style that tracks Bulma's scheme CSS variables, so it adapts to
502
+ * light/dark mode with no bestax-shipped CSS. For every other input it
503
+ * returns `undefined` (never `{}`), so components that don't use scheme
504
+ * values produce identical DOM to before.
505
+ *
506
+ * `backgroundColorShade` is ignored for scheme values — Bulma defines no
507
+ * shaded scheme variables. Only the background is set: the `scheme-invert*`
508
+ * values do not change text color, so pair them with a contrasting
509
+ * foreground.
510
+ *
511
+ * @function useColorStyles
512
+ * @param props - Color-related Bulma helper props (scheme-aware).
513
+ * @returns An inline style object for scheme backgrounds, or `undefined`.
514
+ * @example
515
+ * const colorStyles = useColorStyles({ backgroundColor: 'scheme-main-bis' });
516
+ * // colorStyles: { backgroundColor: 'var(--bulma-scheme-main-bis)' }
517
+ */
518
+ const useColorStyles = (props) => {
519
+ const { backgroundColor } = props;
520
+ return React.useMemo(() => {
521
+ if (backgroundColor &&
522
+ validSchemeColors.includes(backgroundColor)) {
523
+ return { backgroundColor: `var(--bulma-${backgroundColor})` };
524
+ }
525
+ return undefined;
526
+ }, [backgroundColor]);
527
+ };
476
528
 
477
529
  /**
478
530
  * A hook that generates Bulma margin and padding helper classes.
@@ -843,16 +895,23 @@ const useOtherClasses = (props) => {
843
895
  * useTypographyClasses, useVisibilityClasses, useFlexboxClasses, and
844
896
  * useOtherClasses), which can also be used individually.
845
897
  *
898
+ * Scheme background values (`backgroundColor: 'scheme-main-bis'`, …) emit no
899
+ * class; they are returned as `bulmaHelperStyles` — a dark-mode-safe inline
900
+ * `background-color: var(--bulma-scheme-*)` style (`undefined` for all other
901
+ * inputs). Merge it with a user `style` prop via `mergeBulmaStyles`.
902
+ *
846
903
  * @function useBulmaClasses
847
- * @param props - Combination of BulmaClassesProps and additional props.
848
- * @returns An object containing the Bulma helper classes and unhandled props.
904
+ * @param props - Combination of BulmaClassesPropsWithScheme and additional props.
905
+ * @returns An object containing the Bulma helper classes, optional helper
906
+ * styles, and unhandled props.
849
907
  * @example
850
- * const { bulmaHelperClasses, rest } = useBulmaClasses({
908
+ * const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
851
909
  * color: 'primary',
852
- * textSize: '3',
910
+ * backgroundColor: 'scheme-main-bis',
853
911
  * className: 'custom-class'
854
912
  * });
855
- * // bulmaHelperClasses: 'has-text-primary is-size-3'
913
+ * // bulmaHelperClasses: 'has-text-primary'
914
+ * // bulmaHelperStyles: { backgroundColor: 'var(--bulma-scheme-main-bis)' }
856
915
  * // rest: { className: 'custom-class' }
857
916
  */
858
917
  const useBulmaClasses = (props) => {
@@ -863,6 +922,7 @@ const useBulmaClasses = (props) => {
863
922
  backgroundColor,
864
923
  backgroundColorShade,
865
924
  });
925
+ const bulmaHelperStyles = useColorStyles({ backgroundColor });
866
926
  const spacingClasses = useSpacingClasses({
867
927
  m,
868
928
  mt,
@@ -950,7 +1010,7 @@ const useBulmaClasses = (props) => {
950
1010
  flexboxClasses,
951
1011
  otherClasses,
952
1012
  ]);
953
- return { bulmaHelperClasses, rest };
1013
+ return { bulmaHelperClasses, bulmaHelperStyles, rest };
954
1014
  };
955
1015
 
956
1016
  /**
@@ -1413,6 +1473,23 @@ const Breadcrumb = ({ className, alignment, separator, size, children, ...props
1413
1473
  return (jsxRuntime.jsx("nav", { className: breadcrumbClasses, "aria-label": "breadcrumbs", ...rest, children: jsxRuntime.jsx("ul", { children: children }) }));
1414
1474
  };
1415
1475
 
1476
+ /**
1477
+ * Merges helper-emitted inline styles (e.g., `bulmaHelperStyles` from
1478
+ * `useBulmaClasses`) with a user-supplied `style` prop.
1479
+ *
1480
+ * The user's `style` wins on conflicting properties, and when both inputs are
1481
+ * absent the result is `undefined` — so components that receive neither
1482
+ * render with no `style` attribute at all, exactly as before.
1483
+ *
1484
+ * @function mergeBulmaStyles
1485
+ * @param helperStyles - Inline styles emitted by the Bulma helper hooks.
1486
+ * @param style - The component consumer's `style` prop.
1487
+ * @returns The merged style object, or `undefined` when both are absent.
1488
+ * @example
1489
+ * <section style={mergeBulmaStyles(bulmaHelperStyles, style)} />
1490
+ */
1491
+ const mergeBulmaStyles = (helperStyles, style) => helperStyles || style ? { ...helperStyles, ...style } : undefined;
1492
+
1416
1493
  /**
1417
1494
  * Wrap each footer item in a `.card-footer-item` span.
1418
1495
  * @param {CardProps['footer']} footer - Footer content (single node or array).
@@ -1451,9 +1528,9 @@ const hasCompoundComponents = (children) => {
1451
1528
  * @returns {JSX.Element} The rendered card element.
1452
1529
  * @see {@link https://bulma.io/documentation/components/card/ | Bulma Card documentation}
1453
1530
  */
1454
- const CardComponent = ({ className, children, textColor, color, bgColor, hasShadow = true, header, headerCentered, headerIcon, footer, image, imageAlt, ...props }) => {
1531
+ const CardComponent = ({ className, children, textColor, color, bgColor, hasShadow = true, header, headerCentered, headerIcon, footer, image, imageAlt, style, ...props }) => {
1455
1532
  const { classPrefix } = useConfig();
1456
- const { bulmaHelperClasses, rest } = useBulmaClasses({
1533
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
1457
1534
  color: textColor ?? color,
1458
1535
  backgroundColor: bgColor,
1459
1536
  ...props,
@@ -1472,7 +1549,7 @@ const CardComponent = ({ className, children, textColor, color, bgColor, hasShad
1472
1549
  'is-centered': headerCentered,
1473
1550
  }), children: header })), headerIcon] }));
1474
1551
  };
1475
- return (jsxRuntime.jsxs("div", { className: cardClasses, ...rest, children: [renderHeader(header, headerIcon, headerCentered, classPrefix), image && (jsxRuntime.jsx("div", { className: prefixedClassNames(classPrefix, 'card-image'), children: typeof image === 'string' ? (jsxRuntime.jsx("figure", { className: prefixedClassNames(classPrefix, 'image'), children: jsxRuntime.jsx("img", { src: image, alt: imageAlt ?? 'Card image' }) })) : (image) })), typeof children !== 'undefined' &&
1552
+ return (jsxRuntime.jsxs("div", { className: cardClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: [renderHeader(header, headerIcon, headerCentered, classPrefix), image && (jsxRuntime.jsx("div", { className: prefixedClassNames(classPrefix, 'card-image'), children: typeof image === 'string' ? (jsxRuntime.jsx("figure", { className: prefixedClassNames(classPrefix, 'image'), children: jsxRuntime.jsx("img", { src: image, alt: imageAlt ?? 'Card image' }) })) : (image) })), typeof children !== 'undefined' &&
1476
1553
  children !== null &&
1477
1554
  children !== '' &&
1478
1555
  !hasCompoundComponents(children) && (jsxRuntime.jsx("div", { className: prefixedClassNames(classPrefix, 'card-content'), children: children })), typeof children !== 'undefined' &&
@@ -4570,11 +4647,11 @@ const Block = ({ className, textColor, color, bgColor, children, ...props }) =>
4570
4647
  * @returns {JSX.Element} The rendered box element.
4571
4648
  * @see {@link https://bulma.io/documentation/elements/box/ | Bulma Box documentation}
4572
4649
  */
4573
- const Box = ({ className, textColor, color, bgColor, hasShadow = true, children, ...props }) => {
4650
+ const Box = ({ className, textColor, color, bgColor, hasShadow = true, children, style, ...props }) => {
4574
4651
  /**
4575
4652
  * Generates Bulma helper classes and separates out remaining props.
4576
4653
  */
4577
- const { bulmaHelperClasses, rest } = useBulmaClasses({
4654
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
4578
4655
  color: textColor ?? color,
4579
4656
  backgroundColor: bgColor,
4580
4657
  ...props,
@@ -4583,7 +4660,7 @@ const Box = ({ className, textColor, color, bgColor, hasShadow = true, children,
4583
4660
  'is-shadowless': !hasShadow,
4584
4661
  });
4585
4662
  const boxClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
4586
- return (jsxRuntime.jsx("div", { className: boxClasses, ...rest, children: children }));
4663
+ return (jsxRuntime.jsx("div", { className: boxClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
4587
4664
  };
4588
4665
 
4589
4666
  /**
@@ -11175,6 +11252,12 @@ const bulmaCssVars = [
11175
11252
  // scheme
11176
11253
  '--bulma-scheme-h',
11177
11254
  '--bulma-scheme-s',
11255
+ '--bulma-scheme-main',
11256
+ '--bulma-scheme-main-bis',
11257
+ '--bulma-scheme-main-ter',
11258
+ '--bulma-scheme-invert',
11259
+ '--bulma-scheme-invert-bis',
11260
+ '--bulma-scheme-invert-ter',
11178
11261
  '--bulma-light-l',
11179
11262
  '--bulma-light-invert-l',
11180
11263
  '--bulma-dark-l',
@@ -11858,8 +11941,8 @@ const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode,
11858
11941
  * @returns {JSX.Element} The rendered container.
11859
11942
  * @see {@link https://bulma.io/documentation/layout/container/ | Bulma Container documentation}
11860
11943
  */
11861
- const Container = ({ className, textColor, color, bgColor, fluid, widescreen, fullhd, breakpoint, isMax, children, ...props }) => {
11862
- const { bulmaHelperClasses, rest } = useBulmaClasses({
11944
+ const Container = ({ className, textColor, color, bgColor, fluid, widescreen, fullhd, breakpoint, isMax, children, style, ...props }) => {
11945
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
11863
11946
  color: textColor ?? color,
11864
11947
  backgroundColor: bgColor,
11865
11948
  ...props,
@@ -11887,7 +11970,7 @@ const Container = ({ className, textColor, color, bgColor, fluid, widescreen, fu
11887
11970
  });
11888
11971
  const prefixedBreakpointClass = usePrefixedClassNames(breakpointClass || '');
11889
11972
  const containerClasses = classNames(mainClass, containerModifiers, prefixedBreakpointClass, className, bulmaHelperClasses);
11890
- return (jsxRuntime.jsx("div", { className: containerClasses, ...rest, children: children }));
11973
+ return (jsxRuntime.jsx("div", { className: containerClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
11891
11974
  };
11892
11975
 
11893
11976
  /**
@@ -11903,8 +11986,8 @@ const Container = ({ className, textColor, color, bgColor, fluid, widescreen, fu
11903
11986
  * <div className="content has-text-centered">...</div>
11904
11987
  * </Footer>
11905
11988
  */
11906
- const Footer = ({ as = 'footer', className, children, color, bgColor, textColor, ...props }) => {
11907
- const { bulmaHelperClasses, rest } = useBulmaClasses({
11989
+ const Footer = ({ as = 'footer', className, children, color, bgColor, textColor, style, ...props }) => {
11990
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
11908
11991
  color: textColor ?? color,
11909
11992
  backgroundColor: bgColor,
11910
11993
  ...props,
@@ -11912,7 +11995,7 @@ const Footer = ({ as = 'footer', className, children, color, bgColor, textColor,
11912
11995
  const Tag = as;
11913
11996
  const mainClass = usePrefixedClassNames('footer');
11914
11997
  const footerClasses = classNames(mainClass, bulmaHelperClasses, className);
11915
- return (jsxRuntime.jsx(Tag, { className: footerClasses, ...rest, children: children }));
11998
+ return (jsxRuntime.jsx(Tag, { className: footerClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
11916
11999
  };
11917
12000
 
11918
12001
  /**
@@ -11923,9 +12006,9 @@ const Footer = ({ as = 'footer', className, children, color, bgColor, textColor,
11923
12006
  * @returns {JSX.Element} The rendered hero.
11924
12007
  * @see {@link https://bulma.io/documentation/layout/hero/ | Bulma Hero documentation}
11925
12008
  */
11926
- const HeroComponent = ({ className, color, size, bgColor, fullheightWithNavbar, children, ...props }) => {
12009
+ const HeroComponent = ({ className, color, size, bgColor, fullheightWithNavbar, children, style, ...props }) => {
11927
12010
  warnUnstyledColor('Hero', color, ['inherit', 'current']);
11928
- const { bulmaHelperClasses, rest } = useBulmaClasses({
12011
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
11929
12012
  backgroundColor: bgColor,
11930
12013
  ...props,
11931
12014
  });
@@ -11935,7 +12018,7 @@ const HeroComponent = ({ className, color, size, bgColor, fullheightWithNavbar,
11935
12018
  'is-fullheight-with-navbar': fullheightWithNavbar || size === 'fullheight-with-navbar',
11936
12019
  });
11937
12020
  const heroClasses = classNames(mainClass, bulmaHelperClasses, className);
11938
- return (jsxRuntime.jsx("section", { className: heroClasses, ...rest, children: children }));
12021
+ return (jsxRuntime.jsx("section", { className: heroClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
11939
12022
  };
11940
12023
  /**
11941
12024
  * Top bar for navigation or branding.
@@ -11944,15 +12027,15 @@ const HeroComponent = ({ className, color, size, bgColor, fullheightWithNavbar,
11944
12027
  * @param {HeroHeadProps} props - Props for the HeroHead component.
11945
12028
  * @returns {JSX.Element} The rendered hero head.
11946
12029
  */
11947
- const HeroHead = ({ className, children, color, bgColor, textColor, ...props }) => {
11948
- const { bulmaHelperClasses, rest } = useBulmaClasses({
12030
+ const HeroHead = ({ className, children, color, bgColor, textColor, style, ...props }) => {
12031
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
11949
12032
  color: textColor ?? color,
11950
12033
  backgroundColor: bgColor,
11951
12034
  ...props,
11952
12035
  });
11953
12036
  const mainClass = usePrefixedClassNames('hero-head');
11954
12037
  const heroHeadClasses = classNames(mainClass, bulmaHelperClasses, className);
11955
- return (jsxRuntime.jsx("div", { className: heroHeadClasses, ...rest, children: children }));
12038
+ return (jsxRuntime.jsx("div", { className: heroHeadClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
11956
12039
  };
11957
12040
  /**
11958
12041
  * Main content area, vertically centered by default.
@@ -11961,15 +12044,15 @@ const HeroHead = ({ className, children, color, bgColor, textColor, ...props })
11961
12044
  * @param {HeroBodyProps} props - Props for the HeroBody component.
11962
12045
  * @returns {JSX.Element} The rendered hero body.
11963
12046
  */
11964
- const HeroBody = ({ className, children, color, bgColor, textColor, ...props }) => {
11965
- const { bulmaHelperClasses, rest } = useBulmaClasses({
12047
+ const HeroBody = ({ className, children, color, bgColor, textColor, style, ...props }) => {
12048
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
11966
12049
  color: textColor ?? color,
11967
12050
  backgroundColor: bgColor,
11968
12051
  ...props,
11969
12052
  });
11970
12053
  const mainClass = usePrefixedClassNames('hero-body');
11971
12054
  const heroBodyClasses = classNames(mainClass, bulmaHelperClasses, className);
11972
- return (jsxRuntime.jsx("div", { className: heroBodyClasses, ...rest, children: children }));
12055
+ return (jsxRuntime.jsx("div", { className: heroBodyClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
11973
12056
  };
11974
12057
  /**
11975
12058
  * Bottom bar for tabs or actions.
@@ -11978,15 +12061,15 @@ const HeroBody = ({ className, children, color, bgColor, textColor, ...props })
11978
12061
  * @param {HeroFootProps} props - Props for the HeroFoot component.
11979
12062
  * @returns {JSX.Element} The rendered hero foot.
11980
12063
  */
11981
- const HeroFoot = ({ className, children, color, bgColor, textColor, ...props }) => {
11982
- const { bulmaHelperClasses, rest } = useBulmaClasses({
12064
+ const HeroFoot = ({ className, children, color, bgColor, textColor, style, ...props }) => {
12065
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
11983
12066
  color: textColor ?? color,
11984
12067
  backgroundColor: bgColor,
11985
12068
  ...props,
11986
12069
  });
11987
12070
  const mainClass = usePrefixedClassNames('hero-foot');
11988
12071
  const heroFootClasses = classNames(mainClass, bulmaHelperClasses, className);
11989
- return (jsxRuntime.jsx("div", { className: heroFootClasses, ...rest, children: children }));
12072
+ return (jsxRuntime.jsx("div", { className: heroFootClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
11990
12073
  };
11991
12074
  // Attach subcomponents
11992
12075
  const Hero = withSubComponents(HeroComponent, {
@@ -12165,8 +12248,8 @@ const Media = withSubComponents(MediaComponent, {
12165
12248
  * @returns {JSX.Element} The rendered section.
12166
12249
  * @see {@link https://bulma.io/documentation/layout/section/ | Bulma Section documentation}
12167
12250
  */
12168
- const Section = ({ size, className, children, color, bgColor, textColor, ...props }) => {
12169
- const { bulmaHelperClasses, rest } = useBulmaClasses({
12251
+ const Section = ({ size, className, children, color, bgColor, textColor, style, ...props }) => {
12252
+ const { bulmaHelperClasses, bulmaHelperStyles, rest } = useBulmaClasses({
12170
12253
  color: textColor ?? color,
12171
12254
  backgroundColor: bgColor,
12172
12255
  ...props,
@@ -12176,7 +12259,7 @@ const Section = ({ size, className, children, color, bgColor, textColor, ...prop
12176
12259
  [`is-${size}`]: size,
12177
12260
  });
12178
12261
  const sectionClasses = classNames(mainClass, sectionModifiers, className, bulmaHelperClasses);
12179
- return (jsxRuntime.jsx("section", { className: sectionClasses, ...rest, children: children }));
12262
+ return (jsxRuntime.jsx("section", { className: sectionClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
12180
12263
  };
12181
12264
 
12182
12265
  exports.Autocomplete = Autocomplete;
@@ -12331,6 +12414,7 @@ exports.classNames = classNames;
12331
12414
  exports.createPrefixedClassNames = createPrefixedClassNames;
12332
12415
  exports.dialog = dialog;
12333
12416
  exports.isBrowser = isBrowser$1;
12417
+ exports.mergeBulmaStyles = mergeBulmaStyles;
12334
12418
  exports.notification = notification;
12335
12419
  exports.prefixedClassNames = prefixedClassNames;
12336
12420
  exports.radioColors = radioColors;
@@ -12341,6 +12425,7 @@ exports.toast = toast;
12341
12425
  exports.useBulmaClasses = useBulmaClasses;
12342
12426
  exports.useClassPrefix = useClassPrefix;
12343
12427
  exports.useColorClasses = useColorClasses;
12428
+ exports.useColorStyles = useColorStyles;
12344
12429
  exports.useConfig = useConfig;
12345
12430
  exports.useFlexboxClasses = useFlexboxClasses;
12346
12431
  exports.useIconLibrary = useIconLibrary;
@@ -12364,6 +12449,7 @@ exports.validFlexGrowShrink = validFlexGrowShrink;
12364
12449
  exports.validFlexWraps = validFlexWraps;
12365
12450
  exports.validFontFamilies = validFontFamilies;
12366
12451
  exports.validJustifyContents = validJustifyContents;
12452
+ exports.validSchemeColors = validSchemeColors;
12367
12453
  exports.validSizes = validSizes$1;
12368
12454
  exports.validTableColors = validTableColors;
12369
12455
  exports.validTextSizes = validTextSizes;