@allxsmith/bestax-bulma 5.24.0 → 5.26.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.esm.js CHANGED
@@ -267,6 +267,35 @@ const validSchemeColors = [
267
267
  * @example '0', '1', 'auto'
268
268
  */
269
269
  const validSizes$1 = ['0', '1', '2', '3', '4', '5', '6', 'auto'];
270
+ /**
271
+ * Valid Bulma gap steps, taken by `gap`, `columnGap` and `rowGap`. Each whole
272
+ * step is 0.5rem, so `2` is 1rem and `8` is 4rem, and the half steps sit
273
+ * between them. They render `is-gap-<value>`, `is-column-gap-<value>` and
274
+ * `is-row-gap-<value>`.
275
+ *
276
+ * This is a different scale from `validSizes`: `gap="2"` is 1rem where
277
+ * `m="2"` is 0.5rem.
278
+ * @example '0', '0.5', '2', '8'
279
+ */
280
+ const validGaps = [
281
+ '0',
282
+ '0.5',
283
+ '1',
284
+ '1.5',
285
+ '2',
286
+ '2.5',
287
+ '3',
288
+ '3.5',
289
+ '4',
290
+ '4.5',
291
+ '5',
292
+ '5.5',
293
+ '6',
294
+ '6.5',
295
+ '7',
296
+ '7.5',
297
+ '8',
298
+ ];
270
299
  /**
271
300
  * Valid Bulma text size classes.
272
301
  * @example '1', '2', '3'
@@ -649,7 +678,13 @@ const useColorStyles = (props) => {
649
678
  };
650
679
 
651
680
  /**
652
- * A hook that generates Bulma margin and padding helper classes.
681
+ * A gap step as the class reads it. Numbers are accepted for the steps, so
682
+ * `2` and `'2'` both become `'2'`; anything else is checked against
683
+ * `validGaps` by the caller.
684
+ */
685
+ const gapValue = (value) => typeof value === 'number' ? String(value) : value;
686
+ /**
687
+ * A hook that generates Bulma margin, padding and gap helper classes.
653
688
  *
654
689
  * @function useSpacingClasses
655
690
  * @param props - Spacing-related Bulma helper props.
@@ -660,9 +695,9 @@ const useColorStyles = (props) => {
660
695
  */
661
696
  const useSpacingClasses = (props) => {
662
697
  const { classPrefix } = useConfig();
663
- const { m, mt, mr, mb, ml, mx, my, p, pt, pr, pb, pl, px, py } = props;
698
+ const { m, mt, mr, mb, ml, mx, my, p, pt, pr, pb, pl, px, py, gap, columnGap, rowGap, gapless, } = props;
664
699
  return useMemo(() => {
665
- const { classes, addClassNoViewport } = createBulmaClassHelpers(classPrefix);
700
+ const { classes, addClassNoViewport, addPrefixedClass } = createBulmaClassHelpers(classPrefix);
666
701
  // Spacing (no viewport support in Bulma)
667
702
  addClassNoViewport('m', m, validSizes$1);
668
703
  addClassNoViewport('mt', mt, validSizes$1);
@@ -678,8 +713,42 @@ const useSpacingClasses = (props) => {
678
713
  addClassNoViewport('pl', pl, validSizes$1);
679
714
  addClassNoViewport('px', px, validSizes$1);
680
715
  addClassNoViewport('py', py, validSizes$1);
716
+ // Gap (no viewport support in Bulma). `gapless` and `is-gap-*` both set
717
+ // the `gap` shorthand at one class of specificity, so beside each other
718
+ // the stylesheet's rule order would decide. A valid `gap` settles it on
719
+ // its own. The axis props need no such care: Bulma declares every
720
+ // `is-column-gap-*` and `is-row-gap-*` after the shorthands, so each wins
721
+ // its own axis over `gap` and `gapless` alike.
722
+ const gapStep = gapValue(gap);
723
+ const hasGap = validGaps.some(v => v === gapStep);
724
+ addClassNoViewport('is-gap', gapStep, validGaps);
725
+ if (gapless && !hasGap) {
726
+ addPrefixedClass('is-gapless');
727
+ }
728
+ addClassNoViewport('is-column-gap', gapValue(columnGap), validGaps);
729
+ addClassNoViewport('is-row-gap', gapValue(rowGap), validGaps);
681
730
  return classNames(classes);
682
- }, [classPrefix, m, mt, mr, mb, ml, mx, my, p, pt, pr, pb, pl, px, py]);
731
+ }, [
732
+ classPrefix,
733
+ m,
734
+ mt,
735
+ mr,
736
+ mb,
737
+ ml,
738
+ mx,
739
+ my,
740
+ p,
741
+ pt,
742
+ pr,
743
+ pb,
744
+ pl,
745
+ px,
746
+ py,
747
+ gap,
748
+ columnGap,
749
+ rowGap,
750
+ gapless,
751
+ ]);
683
752
  };
684
753
 
685
754
  /**
@@ -1111,7 +1180,7 @@ const useOtherClasses = (props) => {
1111
1180
  * // rest: { className: 'custom-class' }
1112
1181
  */
1113
1182
  const useBulmaClasses = (props) => {
1114
- const { color, backgroundColor, colorShade, backgroundColorShade, m, mt, mr, mb, ml, mx, my, p, pt, pr, pb, pl, px, py, textSize, textAlign, textTransform, textWeight, fontFamily, display, visibility, flexDirection, flexWrap, justifyContent, alignContent, alignItems, alignSelf, flexGrow, flexShrink, float, overflow, overflowX, overflowY, overlay, interaction, cursor, radius, shadow, responsive, viewport, displayMobile, displayTablet, displayTabletOnly, displayTouch, displayDesktop, displayDesktopOnly, displayWidescreen, displayWidescreenOnly, displayFullhd, textSizeMobile, textSizeTablet, textSizeDesktop, textSizeWidescreen, textSizeFullhd, textAlignMobile, textAlignTablet, textAlignDesktop, textAlignWidescreen, textAlignFullhd, visibilityMobile, visibilityTablet, visibilityTabletOnly, visibilityTouch, visibilityDesktop, visibilityDesktopOnly, visibilityWidescreen, visibilityWidescreenOnly, visibilityFullhd, skeleton, clearfix, pos, relative, fullHeight, aspectRatio, ...rest } = props;
1183
+ const { color, backgroundColor, colorShade, backgroundColorShade, m, mt, mr, mb, ml, mx, my, p, pt, pr, pb, pl, px, py, gap, columnGap, rowGap, gapless, textSize, textAlign, textTransform, textWeight, fontFamily, display, visibility, flexDirection, flexWrap, justifyContent, alignContent, alignItems, alignSelf, flexGrow, flexShrink, float, overflow, overflowX, overflowY, overlay, interaction, cursor, radius, shadow, responsive, viewport, displayMobile, displayTablet, displayTabletOnly, displayTouch, displayDesktop, displayDesktopOnly, displayWidescreen, displayWidescreenOnly, displayFullhd, textSizeMobile, textSizeTablet, textSizeDesktop, textSizeWidescreen, textSizeFullhd, textAlignMobile, textAlignTablet, textAlignDesktop, textAlignWidescreen, textAlignFullhd, visibilityMobile, visibilityTablet, visibilityTabletOnly, visibilityTouch, visibilityDesktop, visibilityDesktopOnly, visibilityWidescreen, visibilityWidescreenOnly, visibilityFullhd, skeleton, clearfix, pos, relative, fullHeight, aspectRatio, ...rest } = props;
1115
1184
  const colorClasses = useColorClasses({
1116
1185
  color,
1117
1186
  colorShade,
@@ -1134,6 +1203,10 @@ const useBulmaClasses = (props) => {
1134
1203
  pl,
1135
1204
  px,
1136
1205
  py,
1206
+ gap,
1207
+ columnGap,
1208
+ rowGap,
1209
+ gapless,
1137
1210
  });
1138
1211
  const typographyClasses = useTypographyClasses({
1139
1212
  textSize,
@@ -1302,10 +1375,13 @@ const ColumnsComponent = ({ className, textColor, color: _fieldColor, bgColor, i
1302
1375
  const resolvedGapDesktop = gapDesktop ?? gapSizeDesktop;
1303
1376
  const resolvedGapWidescreen = gapWidescreen ?? gapSizeWidescreen;
1304
1377
  const resolvedGapFullhd = gapFullhd ?? gapSizeFullhd;
1378
+ // Untyped code can still pass the gap helpers ColumnsProps leaves out. They
1379
+ // are dropped here, so they render no class and never reach the DOM.
1380
+ const { columnGap: _columnGap, rowGap: _rowGap, ...helperProps } = props;
1305
1381
  const { bulmaHelperClasses, rest } = useBulmaClasses({
1306
1382
  color: textColor,
1307
1383
  backgroundColor: bgColor,
1308
- ...props,
1384
+ ...helperProps,
1309
1385
  });
1310
1386
  const mainClass = usePrefixedClassNames('columns');
1311
1387
  // Build gap classes with prefixes
@@ -15222,17 +15298,20 @@ function cssVarToProp(varName) {
15222
15298
  .join('');
15223
15299
  }
15224
15300
  /**
15225
- * Prop names `cssVarToProp` would mint that are already `BulmaOtherProps`
15226
- * helper props: `--bulma-shadow` becomes `shadow` and `--bulma-radius` becomes
15227
- * `radius`. They stay out of `bulmaVarPropMap`, so on Theme each is the helper
15228
- * prop it is on every other component, and both variables are still reachable
15229
- * through `bulmaVars`.
15301
+ * Prop names `cssVarToProp` would mint that are already helper props:
15302
+ * `--bulma-shadow` becomes `shadow`, `--bulma-radius` becomes `radius` and
15303
+ * `--bulma-column-gap` becomes `columnGap`. They stay out of
15304
+ * `bulmaVarPropMap`, so on Theme each is the helper prop it is on every other
15305
+ * component, and every one of those variables is still reachable through
15306
+ * `bulmaVars`.
15230
15307
  *
15231
15308
  * `radius` was missed here once and set `--bulma-radius` while typed as the
15232
15309
  * helper (#694). It still writes that variable, so what it did then keeps
15233
- * working; see `themeRadiusVar`.
15310
+ * working; see `themeRadiusVar`. `columnGap` joined when the gap helpers
15311
+ * became shared helper props, and keeps its old variable route the same way;
15312
+ * see `themeColumnGapVar`.
15234
15313
  */
15235
- const helperPropNames = ['shadow', 'radius'];
15314
+ const helperPropNames = ['shadow', 'radius', 'columnGap'];
15236
15315
  /**
15237
15316
  * Mapping of camelCase prop names to their Bulma CSS variable counterparts,
15238
15317
  * minus the `helperPropNames` above.
@@ -15294,6 +15373,36 @@ const themeRadiusVar = (radius) => {
15294
15373
  `bulmaVars={{ '--bulma-radius': '${radius}' }} instead.`);
15295
15374
  return radius;
15296
15375
  };
15376
+ /**
15377
+ * What `columnGap` writes to `--bulma-column-gap` on a Theme, or `undefined`
15378
+ * when it writes nothing.
15379
+ *
15380
+ * Until the gap helpers were shared helper props, `columnGap` on Theme was
15381
+ * the camelCase prop Theme mints for `--bulma-column-gap`. It was never in
15382
+ * `ThemeProps`, so only untyped code reached it, but that code got the
15383
+ * columns gutter it asked for. It is the column gap helper now, as on every
15384
+ * other component, so a gap step goes to the helper and writes nothing here.
15385
+ * Any other non-empty string is still written as given, so a length such as
15386
+ * `'1rem'` keeps working, with a development warning pointing at `bulmaVars`.
15387
+ *
15388
+ * Only a string writes anything, for the reason `themeRadiusVar` gives: a
15389
+ * number or a boolean was never a usable length.
15390
+ */
15391
+ const themeColumnGapVar = (columnGap) => {
15392
+ if (typeof columnGap !== 'string' || columnGap === '') {
15393
+ return undefined;
15394
+ }
15395
+ if (validGaps.includes(columnGap)) {
15396
+ return undefined;
15397
+ }
15398
+ warnOnce('Theme:column-gap-variable', `[bestax-bulma] <Theme columnGap="${columnGap}">: setting ` +
15399
+ '--bulma-column-gap through the columnGap prop is deprecated and will ' +
15400
+ 'stop working in a future major version. On Theme, as on every other ' +
15401
+ 'component, columnGap is the column gap helper ' +
15402
+ `("${validGaps.join('", "')}"). Set the variable with ` +
15403
+ `bulmaVars={{ '--bulma-column-gap': '${columnGap}' }} instead.`);
15404
+ return columnGap;
15405
+ };
15297
15406
  /** The one `<style>` element every `isRoot` Theme writes into. */
15298
15407
  const ROOT_STYLE_ID = 'bestax-bulma-theme-vars';
15299
15408
  /**
@@ -15371,8 +15480,9 @@ const setRootThemeRules = (order, rules) => {
15371
15480
  * <Button color="primary">Themed</Button>
15372
15481
  * </Theme>
15373
15482
  */
15374
- const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode, radius, ...restProps }) => {
15483
+ const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode, radius, columnGap, ...restProps }) => {
15375
15484
  const radiusVar = themeRadiusVar(radius);
15485
+ const columnGapVar = themeColumnGapVar(columnGap);
15376
15486
  const radiusHelper = validRadii.includes(radius)
15377
15487
  ? radius
15378
15488
  : undefined;
@@ -15386,6 +15496,18 @@ const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode,
15386
15496
  `element, put radius="${radiusHelper}" on it. To change the radius ` +
15387
15497
  "across the page, set bulmaVars={{ '--bulma-radius': '…' }} instead.");
15388
15498
  }
15499
+ // The same for a gap step in `columnGap`, which reads like the columns
15500
+ // gutter it once set and, at the root, has no element for its class.
15501
+ const columnGapStep = typeof columnGap === 'number' ? String(columnGap) : columnGap;
15502
+ if (isRoot &&
15503
+ columnGapStep !== undefined &&
15504
+ validGaps.includes(columnGapStep)) {
15505
+ warnOnce('Theme:root-column-gap', `[bestax-bulma] <Theme isRoot columnGap="${columnGapStep}">: a root ` +
15506
+ `Theme has no wrapper element for is-column-gap-${columnGapStep}, ` +
15507
+ 'and a gap step sets no variable, so this does nothing. To change ' +
15508
+ 'the columns gutter across the page, set ' +
15509
+ "bulmaVars={{ '--bulma-column-gap': '…' }} instead.");
15510
+ }
15389
15511
  // Extract Bulma variable props from restProps
15390
15512
  const { bulmaVarProps, otherProps } = useMemo(() => {
15391
15513
  const varProps = {};
@@ -15405,6 +15527,7 @@ const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode,
15405
15527
  const { bulmaHelperClasses, rest } = useBulmaClasses({
15406
15528
  ...otherProps,
15407
15529
  radius: radiusHelper,
15530
+ columnGap,
15408
15531
  });
15409
15532
  // Merge bulmaVars and individual props, with props taking precedence
15410
15533
  const mergedVars = useMemo(() => {
@@ -15417,8 +15540,11 @@ const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode,
15417
15540
  if (radiusVar !== undefined) {
15418
15541
  vars['--bulma-radius'] = radiusVar;
15419
15542
  }
15543
+ if (columnGapVar !== undefined) {
15544
+ vars['--bulma-column-gap'] = columnGapVar;
15545
+ }
15420
15546
  return vars;
15421
- }, [bulmaVars, bulmaVarProps, radiusVar]);
15547
+ }, [bulmaVars, bulmaVarProps, radiusVar, columnGapVar]);
15422
15548
  // This Theme's place among root Themes; see `rootThemeRules`.
15423
15549
  const [rootOrder] = useState(() => nextRootOrder++);
15424
15550
  // The `:root` rules this Theme contributes, or '' when it contributes none.
@@ -15863,5 +15989,5 @@ const Section = ({ size, className, children, color, bgColor, textColor, style,
15863
15989
  return (jsx("section", { className: sectionClasses, style: mergeBulmaStyles(bulmaHelperStyles, style), ...rest, children: children }));
15864
15990
  };
15865
15991
 
15866
- export { Autocomplete, Avatar, Avatars, Badge, Block, Box, Breadcrumb, Button, Buttons, Card, Carousel, CarouselItem, Cell, Checkbox, Checkboxes, ClientOnly, Code, Collapse, Collapses, 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, Loader, 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, Popover, PopoverBody, PopoverClose, PopoverFooter, PopoverHeader, Portal, 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, useFocusTrap, useIconLibrary, useInsideControl, useInsideField, useIsHydrated, useOtherClasses, usePrefixedClass, usePrefixedClassNames, useSpacingClasses, useTypographyClasses, useVisibilityClasses, validAlignContents, validAlignItems, validAlignSelfs, validAlignments$1 as validAlignments, validAspectRatios, validAxisOverflows, validColorShades, validColors, validCursors, validDisplays, validFlexDirections, validFlexGrowShrink, validFlexWraps, validFloats, validFontFamilies, validInteractions, validJustifyContents, validOverflows, validPositions, validRadii, validResponsives, validSchemeColors, validShadows, validSizes$1 as validSizes, validTableColors, validTextSizes, validTextTransforms, validTextWeights, validViewports, validVisibilities };
15992
+ export { Autocomplete, Avatar, Avatars, Badge, Block, Box, Breadcrumb, Button, Buttons, Card, Carousel, CarouselItem, Cell, Checkbox, Checkboxes, ClientOnly, Code, Collapse, Collapses, 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, Loader, 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, Popover, PopoverBody, PopoverClose, PopoverFooter, PopoverHeader, Portal, 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, useFocusTrap, useIconLibrary, useInsideControl, useInsideField, useIsHydrated, useOtherClasses, usePrefixedClass, usePrefixedClassNames, useSpacingClasses, useTypographyClasses, useVisibilityClasses, validAlignContents, validAlignItems, validAlignSelfs, validAlignments$1 as validAlignments, validAspectRatios, validAxisOverflows, validColorShades, validColors, validCursors, validDisplays, validFlexDirections, validFlexGrowShrink, validFlexWraps, validFloats, validFontFamilies, validGaps, validInteractions, validJustifyContents, validOverflows, validPositions, validRadii, validResponsives, validSchemeColors, validShadows, validSizes$1 as validSizes, validTableColors, validTextSizes, validTextTransforms, validTextWeights, validViewports, validVisibilities };
15867
15993
  //# sourceMappingURL=index.esm.js.map