@allxsmith/bestax-bulma 5.15.3 → 5.16.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
@@ -211,6 +211,8 @@ const validColors = [
211
211
  'grey-light',
212
212
  'grey-lighter',
213
213
  'white',
214
+ 'white-bis',
215
+ 'white-ter',
214
216
  'light',
215
217
  'dark',
216
218
  ];
@@ -421,6 +423,57 @@ const validViewports = [
421
423
  'widescreen-only',
422
424
  'fullhd',
423
425
  ];
426
+ /**
427
+ * Valid Bulma float classes.
428
+ * @example 'left', 'right'
429
+ */
430
+ const validFloats = ['left', 'right'];
431
+ /**
432
+ * Valid Bulma overflow classes.
433
+ * @example 'clipped'
434
+ */
435
+ const validOverflows = ['clipped'];
436
+ /**
437
+ * Valid Bulma interaction classes.
438
+ * @example 'unselectable', 'clickable'
439
+ */
440
+ const validInteractions = ['unselectable', 'clickable'];
441
+ /**
442
+ * Valid Bulma cursor helper values.
443
+ *
444
+ * These share no class stem: `pointer` renders `is-clickable` and `help`
445
+ * renders `is-cursor-help`, so the class each one emits lives in
446
+ * `cursorClasses` rather than being built from the value.
447
+ * @example 'pointer', 'help'
448
+ */
449
+ const validCursors = ['pointer', 'help'];
450
+ /**
451
+ * Cursor helper value to the class it renders.
452
+ *
453
+ * A `Record` over `validCursors` on purpose: TypeScript then rejects a value
454
+ * added to the tuple with no class for it, and a class for a value the tuple
455
+ * does not carry, so the accepted set and the rendered classes cannot drift
456
+ * apart.
457
+ */
458
+ const cursorClasses = {
459
+ pointer: 'is-clickable',
460
+ help: 'is-cursor-help',
461
+ };
462
+ /**
463
+ * Valid Bulma border-radius helper classes.
464
+ * @example 'radiusless'
465
+ */
466
+ const validRadii = ['radiusless'];
467
+ /**
468
+ * Valid Bulma shadow helper classes.
469
+ * @example 'shadowless'
470
+ */
471
+ const validShadows = ['shadowless'];
472
+ /**
473
+ * Valid Bulma responsive helper classes.
474
+ * @example 'mobile', 'narrow'
475
+ */
476
+ const validResponsives = ['mobile', 'narrow'];
424
477
  /**
425
478
  * Creates the shared class-building helpers used by the Bulma helper hooks.
426
479
  *
@@ -887,33 +940,28 @@ const useOtherClasses = (props) => {
887
940
  const { classes, addPrefixedClass, addClassNoViewport } = createBulmaClassHelpers(classPrefix);
888
941
  // Other Helpers (no viewport support)
889
942
  if (float) {
890
- addClassNoViewport('is-pulled', float, ['left', 'right']);
943
+ addClassNoViewport('is-pulled', float, validFloats);
891
944
  }
892
945
  if (overflow) {
893
- addClassNoViewport('is', overflow, ['clipped']);
946
+ addClassNoViewport('is', overflow, validOverflows);
894
947
  }
895
948
  if (overlay) {
896
949
  addPrefixedClass('is-overlay');
897
950
  }
898
951
  if (interaction) {
899
- addClassNoViewport('is', interaction, ['unselectable', 'clickable']);
952
+ addClassNoViewport('is', interaction, validInteractions);
900
953
  }
901
- if (cursor) {
902
- if (cursor === 'pointer') {
903
- addPrefixedClass('is-clickable');
904
- }
905
- else if (cursor === 'help') {
906
- addPrefixedClass('is-cursor-help');
907
- }
954
+ if (cursor && validCursors.includes(cursor)) {
955
+ addPrefixedClass(cursorClasses[cursor]);
908
956
  }
909
957
  if (radius) {
910
- addClassNoViewport('is', radius, ['radiusless']);
958
+ addClassNoViewport('is', radius, validRadii);
911
959
  }
912
960
  if (shadow) {
913
- addClassNoViewport('is', shadow, ['shadowless']);
961
+ addClassNoViewport('is', shadow, validShadows);
914
962
  }
915
963
  if (responsive) {
916
- addClassNoViewport('is', responsive, ['mobile', 'narrow']);
964
+ addClassNoViewport('is', responsive, validResponsives);
917
965
  }
918
966
  // Bulma Skeleton Helper
919
967
  if (skeleton) {
@@ -1781,6 +1829,75 @@ const Card = withSubComponents(CardComponent, {
1781
1829
  /** Internal test-only exports. Not part of the public API. */
1782
1830
  const __test_exports__ = { renderFooter };
1783
1831
 
1832
+ /**
1833
+ * The runtime mirror of `AnchorOnlyAttributes`, keyed so the two cannot drift.
1834
+ *
1835
+ * `Record<keyof …, true>` is what links them: the day React adds an anchor
1836
+ * attribute, every component deriving its props from `as` accepts it and this
1837
+ * object stops compiling until it is named here. A plain array beside a derived
1838
+ * type drifts in the one direction that matters — the type accepts the new
1839
+ * attribute and the filter lets it leak onto a `<div>`.
1840
+ */
1841
+ const ANCHOR_ONLY_ATTRS = {
1842
+ href: true,
1843
+ target: true,
1844
+ download: true,
1845
+ hrefLang: true,
1846
+ ping: true,
1847
+ referrerPolicy: true,
1848
+ media: true,
1849
+ type: true,
1850
+ };
1851
+ /**
1852
+ * `props` without the keys named in `strip`.
1853
+ *
1854
+ * The SET is per component and deliberately not shared, because the right
1855
+ * answer differs and the differences are principled: how open the component's
1856
+ * `as` is, and which of these attributes its own tags legitimately take. What
1857
+ * IS shared is the derived source of truth above and this function. Each caller
1858
+ * declares its delta next to the set it passes, which is the only place that
1859
+ * stays true when a component's `as` changes.
1860
+ */
1861
+ function omitAttrs(props, strip) {
1862
+ const out = {};
1863
+ // `Reflect.ownKeys`, not `Object.entries`: the latter drops symbol-keyed props.
1864
+ // React enumerates props with `for...in`, which never reports a symbol, so
1865
+ // nothing renders differently either way. It is not the same change for all
1866
+ // three callers: Menu filtered by rest-destructure and kept them already,
1867
+ // while Dropdown and Level filtered through `Object.entries` and did not, so
1868
+ // this restores one and widens two. Symbols are the only shape where those
1869
+ // two disagreed, and keeping them is the side a spread is on.
1870
+ for (const key of Reflect.ownKeys(props)) {
1871
+ // Enumerability, for the same reason in the other direction: `Reflect.ownKeys`
1872
+ // also reports NON-enumerable own props, which every filter this replaced left
1873
+ // behind. Copying one out would both add a prop the old code dropped and make
1874
+ // it enumerable on the way, so widening the key source must not widen this.
1875
+ if (!Object.prototype.propertyIsEnumerable.call(props, key))
1876
+ continue;
1877
+ const value = props[key];
1878
+ // `hasOwnProperty`, not `key in strip`: `in` walks the prototype chain, so a
1879
+ // prop named `toString`, `valueOf`, `constructor` or `hasOwnProperty` was
1880
+ // stripped although no caller named it — and anything written to
1881
+ // `Object.prototype` would start deleting props that share its keys.
1882
+ if (typeof key === 'symbol' ||
1883
+ !Object.prototype.hasOwnProperty.call(strip, key)) {
1884
+ // `defineProperty`, not `out[key] = value`: assignment consults the
1885
+ // prototype chain for a setter, and `__proto__` has one. A prop named
1886
+ // `__proto__` would be swallowed by it — dropped from the result AND
1887
+ // replacing the result's prototype with its value. A spread and a rest
1888
+ // destructure both DEFINE, which is what makes them immune, so this has
1889
+ // to define too.
1890
+ Object.defineProperty(out, key, {
1891
+ value,
1892
+ writable: true,
1893
+ enumerable: true,
1894
+ configurable: true,
1895
+ });
1896
+ }
1897
+ }
1898
+ return out;
1899
+ }
1900
+
1784
1901
  /**
1785
1902
  * Checks if code is running in a browser environment.
1786
1903
  * @param win - Window object.
@@ -2003,32 +2120,25 @@ const DropdownComponent = React.forwardRef(function DropdownComponent({ label, c
2003
2120
  return (jsxRuntime.jsxs("div", { className: dropdownClasses, ref: setRefs, id: id, "data-testid": "dropdown-root", ...rest, children: [jsxRuntime.jsx("div", { className: usePrefixedClassNames('dropdown-trigger'), children: jsxRuntime.jsxs("button", { ref: triggerRef, className: buttonClass, "aria-haspopup": "true", "aria-controls": id ? `${id}-menu` : undefined, "aria-expanded": active, onClick: handleToggle, onKeyDown: handleTriggerKeyDown, disabled: disabled, type: "button", children: [jsxRuntime.jsx("span", { children: label }), jsxRuntime.jsx("span", { className: usePrefixedClassNames('icon', 'is-small'), "aria-hidden": "true", children: jsxRuntime.jsx("i", { className: "fas fa-angle-down" }) })] }) }), jsxRuntime.jsx("div", { className: classNames(usePrefixedClassNames('dropdown-menu'), menuClassName), id: id ? `${id}-menu` : undefined, role: "menu", "data-testid": "dropdown-menu", onKeyDown: handleMenuKeyDown, children: jsxRuntime.jsx("div", { className: usePrefixedClassNames('dropdown-content'), onClick: handleMenuClick, tabIndex: -1, children: children }) })] }));
2004
2121
  });
2005
2122
  /**
2006
- * The anchor-only attributes, withheld from a `<div>` or a `<button>`.
2007
- *
2008
- * Mirrors `LINK_ATTRS` in `bestax-migrate/src/sources/_shared/polymorphic.ts`,
2009
- * which drops the same set when a migration lands one on a non-anchor. `rel` is
2010
- * absent from both on purpose: React declares it on `HTMLAttributes<T>` — every
2011
- * element — so withholding it would diverge from React's own typing, the same
2012
- * call #641 recorded for `Navbar.Link`.
2013
- */
2014
- const LINK_ONLY_ATTRS = [
2015
- 'href',
2016
- 'target',
2017
- 'download',
2018
- 'hrefLang',
2019
- 'ping',
2020
- 'referrerPolicy',
2021
- 'media',
2022
- ];
2023
- /** `props` without any attribute only an anchor can carry. */
2024
- function omitLinkAttrs(props) {
2025
- const out = {};
2026
- for (const [key, value] of Object.entries(props)) {
2027
- if (!LINK_ONLY_ATTRS.includes(key))
2028
- out[key] = value;
2029
- }
2030
- return out;
2031
- }
2123
+ * The anchor's attributes, minus the one a `<button>` legitimately takes.
2124
+ *
2125
+ * `type` stays: `as="button"` is a supported form and `type="submit"` is valid
2126
+ * there, so stripping it would remove a working attribute. The exclusion is per
2127
+ * COMPONENT where the reason is per TAG, so it also lets a `type` reach a
2128
+ * `<div>`; selecting the set from the rendered element would close that, and
2129
+ * moves output.
2130
+ *
2131
+ * This set differs from `Level.Item`'s in both directions, not just one. The
2132
+ * `type` above, which Level strips and this component keeps, and `rel`, which
2133
+ * Level adds and this component does not: React declares `rel` on
2134
+ * `HTMLAttributes` for every element, so withholding it would diverge from
2135
+ * React's own typing — the call #641 recorded for `Navbar.Link`. Level
2136
+ * withholds it anyway, because it always has.
2137
+ */
2138
+ const STRIP_FROM_NON_ANCHOR$1 = (() => {
2139
+ const { type: _type, ...rest } = ANCHOR_ONLY_ATTRS;
2140
+ return rest;
2141
+ })();
2032
2142
  /**
2033
2143
  * Bulma Dropdown item.
2034
2144
  *
@@ -2046,16 +2156,18 @@ const DropdownItem = ((itemProps) => {
2046
2156
  // plain-JS one, a loose `{...props}` spread, and the genericity a wrapping HOC
2047
2157
  // erases.
2048
2158
  //
2049
- // The whole link set, not `href` alone. Menu strips only `href` because its
2050
- // props never gained the rest; here they all arrive together under `as="a"`,
2051
- // and `bestax-migrate` already removes exactly this set (`LINK_ATTRS`) when it
2052
- // migrates onto a non-anchor — so stripping less would leave the codemod
2053
- // stricter than the component it migrates to.
2159
+ // The whole link set, not `href` alone: they all arrive together under
2160
+ // `as="a"`. Menu strips `href` only, because its `as` is open and a flat set
2161
+ // would delete attributes legal on the element a caller named.
2162
+ //
2163
+ // `bestax-migrate` tracks the same question from the other side, per attribute
2164
+ // per element (`LINK_ATTR_ELEMENTS`) rather than as one set — so the two lists
2165
+ // are not interchangeable and neither derives from the other.
2054
2166
  //
2055
2167
  // Menu's condition also admits a custom component and a custom element, which
2056
2168
  // own their prop contracts. `as` is closed to three intrinsic tags here, so
2057
2169
  // neither can arrive and the anchor test is the whole rule.
2058
- const forwarded = Component === 'a' ? rest : omitLinkAttrs(rest);
2170
+ const forwarded = Component === 'a' ? rest : omitAttrs(rest, STRIP_FROM_NON_ANCHOR$1);
2059
2171
  return (jsxRuntime.jsx(Component, { className: classNames(usePrefixedClassNames('dropdown-item', {
2060
2172
  'is-active': active,
2061
2173
  }), bulmaHelperClasses, className), tabIndex: 0, role: "menuitem", "data-testid": "dropdown-item", ...forwarded, ...(Component === 'button'
@@ -2120,6 +2232,11 @@ const MenuList = ({ className, children, ...props }) => {
2120
2232
  // Increment level for nested MenuLists
2121
2233
  return (jsxRuntime.jsx(MenuListLevelContext.Provider, { value: level + 1, children: jsxRuntime.jsx("ul", { className: ulClass, ...rest, children: children }) }));
2122
2234
  };
2235
+ /**
2236
+ * `href` alone — annotated so a typo is a compile error rather than a silent
2237
+ * no-op, the way both siblings' sets are.
2238
+ */
2239
+ const STRIP_FROM_NON_LINK = { href: true };
2123
2240
  /**
2124
2241
  * MenuItem supports `as` prop for custom link components, e.g., react-router-dom Link.
2125
2242
  *
@@ -2139,8 +2256,20 @@ const MenuItem = React.forwardRef(function MenuItem(itemProps, ref) {
2139
2256
  const isLinkLike = Component === 'a' ||
2140
2257
  typeof Component !== 'string' ||
2141
2258
  isCustomElement(Component);
2142
- const { href: _href, ...withoutHref } = forwarded;
2143
- const linkProps = isLinkLike ? forwarded : withoutHref;
2259
+ // `href` ALONE. `Dropdown.Item` strips every anchor-only attribute except
2260
+ // `type`; `Level.Item` strips all of them, plus `rel`.
2261
+ //
2262
+ // Not because nothing else can arrive: `as` here is an open `React.ElementType`,
2263
+ // and a non-fresh spread skips excess-property checking, so a typed caller
2264
+ // CAN deliver `target` or `download` and they are forwarded. The set stays at
2265
+ // `href` because widening it would be wrong for an open `as` — `referrerPolicy`
2266
+ // on `as="img"`, `target` on `as="form"` and `media` on `as="source"` are all
2267
+ // legal, and a flat strip would delete them. Getting that right needs a
2268
+ // per-attribute-per-element rule, which `bestax-migrate` already models in
2269
+ // `LINK_ATTR_ELEMENTS`.
2270
+ const linkProps = isLinkLike
2271
+ ? forwarded
2272
+ : omitAttrs(forwarded, STRIP_FROM_NON_LINK);
2144
2273
  const itemClass = classNames({ [usePrefixedClassNames('is-active')]: active }, bulmaHelperClasses);
2145
2274
  // Split children into label and nested MenuList(s)
2146
2275
  const labelChildren = [];
@@ -2886,6 +3015,8 @@ const Navbar = withSubComponents(NavbarComponent, {
2886
3015
  const UNSTYLED_MODIFIER_COLORS = [
2887
3016
  'black-bis',
2888
3017
  'black-ter',
3018
+ 'white-bis',
3019
+ 'white-ter',
2889
3020
  'grey-darker',
2890
3021
  'grey-dark',
2891
3022
  'grey',
@@ -12662,8 +12793,8 @@ function cssVarToProp(varName) {
12662
12793
  * Mapping of camelCase prop names to their Bulma CSS variable counterparts.
12663
12794
  *
12664
12795
  * `--bulma-shadow` is excluded: `cssVarToProp` would mint it as `shadow`,
12665
- * which already exists as a `BulmaOtherProps` prop (`shadow?: 'shadowless'`,
12666
- * applied via `useBulmaClasses`) — keeping it out of this map means that
12796
+ * which already exists as a `BulmaOtherProps` prop applied via
12797
+ * `useBulmaClasses` — keeping it out of this map means that
12667
12798
  * prop keeps its existing class-based meaning, while `--bulma-shadow` is
12668
12799
  * still reachable through the `bulmaVars` object.
12669
12800
  */
@@ -12989,6 +13120,18 @@ const LevelRight = ({ className, children, color, bgColor, textColor, ...props }
12989
13120
  const levelRightClasses = classNames(mainClass, bulmaHelperClasses, className);
12990
13121
  return (jsxRuntime.jsx("div", { className: levelRightClasses, ...rest, children: children }));
12991
13122
  };
13123
+ /**
13124
+ * The derived set plus `rel`.
13125
+ *
13126
+ * `rel` is not an anchor-only attribute — React declares it on every element, so
13127
+ * `AnchorOnlyAttributes` excludes it — but this component has always withheld it
13128
+ * from a non-anchor, so it is named separately rather than folded into the shared
13129
+ * set. That separation is what says which names come from where.
13130
+ *
13131
+ * The annotation is load-bearing: without it a typo adds a key nobody strips, and
13132
+ * widening the key type to `string` also erases `omitAttrs`'s return type.
13133
+ */
13134
+ const STRIP_FROM_NON_ANCHOR = { ...ANCHOR_ONLY_ATTRS, rel: true };
12992
13135
  /**
12993
13136
  * Individual item, can be rendered as `div`, `p`, or `a`.
12994
13137
  *
@@ -13011,32 +13154,11 @@ const LevelItem = ({ as = 'div', hasTextCentered, className, children, color, bg
13011
13154
  // declares them at every `as` — narrowing that is source-breaking (#672) — so
13012
13155
  // the runtime is what keeps `<Level.Item as="p" download>` from rendering a
13013
13156
  // dead attribute.
13014
- //
13015
- // Keyed off `AnchorOnlyAttributes` rather than repeated as a list, because a
13016
- // hand list beside a derived type drifts in the one direction that matters:
13017
- // the day React adds an anchor attribute, the type would accept it at every
13018
- // `as` while the list let it leak onto a `<div>`. `Record` makes that a
13019
- // compile error here until this object catches up. #682 is the issue for
13020
- // sharing the rule with the two components that keep their own copies.
13021
- const ANCHOR_ONLY = {
13022
- href: true,
13023
- target: true,
13024
- download: true,
13025
- hrefLang: true,
13026
- ping: true,
13027
- referrerPolicy: true,
13028
- media: true,
13029
- type: true,
13030
- // `rel` is NOT in the subtraction: React declares it on `HTMLAttributes`,
13031
- // for every element. It is here because this component has always withheld
13032
- // it from a non-anchor, and it is named separately so the key set above
13033
- // stays honest about where each name comes from.
13034
- rel: true,
13035
- };
13157
+ // `STRIP_FROM_NON_ANCHOR` above names the set and why `rel` is in it.
13036
13158
  if (Tag === 'a') {
13037
13159
  return (jsxRuntime.jsx("a", { className: levelItemClasses, ...rest, children: children }));
13038
13160
  }
13039
- const withoutAnchorAttrs = Object.fromEntries(Object.entries(rest).filter(([key]) => !(key in ANCHOR_ONLY)));
13161
+ const withoutAnchorAttrs = omitAttrs(rest, STRIP_FROM_NON_ANCHOR);
13040
13162
  return (jsxRuntime.jsx(Tag, { className: levelItemClasses, ...withoutAnchorAttrs, children: children }));
13041
13163
  };
13042
13164
  const Level = withSubComponents(LevelComponent, {
@@ -13326,13 +13448,20 @@ exports.validAlignSelfs = validAlignSelfs;
13326
13448
  exports.validAlignments = validAlignments$1;
13327
13449
  exports.validColorShades = validColorShades;
13328
13450
  exports.validColors = validColors;
13451
+ exports.validCursors = validCursors;
13329
13452
  exports.validDisplays = validDisplays;
13330
13453
  exports.validFlexDirections = validFlexDirections;
13331
13454
  exports.validFlexGrowShrink = validFlexGrowShrink;
13332
13455
  exports.validFlexWraps = validFlexWraps;
13456
+ exports.validFloats = validFloats;
13333
13457
  exports.validFontFamilies = validFontFamilies;
13458
+ exports.validInteractions = validInteractions;
13334
13459
  exports.validJustifyContents = validJustifyContents;
13460
+ exports.validOverflows = validOverflows;
13461
+ exports.validRadii = validRadii;
13462
+ exports.validResponsives = validResponsives;
13335
13463
  exports.validSchemeColors = validSchemeColors;
13464
+ exports.validShadows = validShadows;
13336
13465
  exports.validSizes = validSizes$1;
13337
13466
  exports.validTableColors = validTableColors;
13338
13467
  exports.validTextSizes = validTextSizes;