@allxsmith/bestax-bulma 5.18.0 → 5.18.1
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/bestax.css +1 -1
- package/dist/bestax.css.map +1 -1
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +418 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +418 -93
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Avatar.d.ts +14 -3
- package/dist/types/components/Dropdown.d.ts +1 -1
- package/dist/types/elements/Notification.d.ts +1 -3
- package/dist/types/form/Checkbox.d.ts +26 -2
- package/dist/types/form/DateTimeInputBase.d.ts +6 -1
- package/dist/types/form/Radio.d.ts +28 -2
- package/dist/types/form/Switch.d.ts +26 -2
- package/dist/types/form/TimeInputBase.d.ts +5 -1
- package/dist/types/helpers/Theme.d.ts +27 -1
- package/dist/types/helpers/colorDeprecations.d.ts +4 -1
- package/dist/types/helpers/devWarnings.d.ts +8 -0
- package/dist/types-cjs/components/Avatar.d.ts +14 -3
- package/dist/types-cjs/components/Dropdown.d.ts +1 -1
- package/dist/types-cjs/elements/Notification.d.ts +1 -3
- package/dist/types-cjs/form/Checkbox.d.ts +26 -2
- package/dist/types-cjs/form/DateTimeInputBase.d.ts +6 -1
- package/dist/types-cjs/form/Radio.d.ts +28 -2
- package/dist/types-cjs/form/Switch.d.ts +26 -2
- package/dist/types-cjs/form/TimeInputBase.d.ts +5 -1
- package/dist/types-cjs/helpers/Theme.d.ts +27 -1
- package/dist/types-cjs/helpers/colorDeprecations.d.ts +4 -1
- package/dist/types-cjs/helpers/devWarnings.d.ts +8 -0
- package/dist/versions/bestax-no-dark-mode.css +1 -1
- package/dist/versions/bestax-no-dark-mode.css.map +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
- package/dist/versions/bestax-no-helpers.css +1 -1
- package/dist/versions/bestax-no-helpers.css.map +1 -1
- package/dist/versions/bestax-prefixed.css +1 -1
- package/dist/versions/bestax-prefixed.css.map +1 -1
- package/package.json +1 -1
- package/src/scss/form/_timeinput.scss +42 -14
package/dist/index.esm.js
CHANGED
|
@@ -1250,6 +1250,30 @@ function isCustomElement(as) {
|
|
|
1250
1250
|
return typeof as === 'string' && as.includes('-');
|
|
1251
1251
|
}
|
|
1252
1252
|
|
|
1253
|
+
// INTERNAL: deliberately not exported from src/index.ts.
|
|
1254
|
+
const warnedKeys = new Set();
|
|
1255
|
+
// Fail closed: with no bundler and no Node (raw CDN ESM), reading `process`
|
|
1256
|
+
// throws and warnings stay off, so production can never warn by accident.
|
|
1257
|
+
const isDev = () => {
|
|
1258
|
+
try {
|
|
1259
|
+
return process.env.NODE_ENV !== 'production';
|
|
1260
|
+
}
|
|
1261
|
+
catch {
|
|
1262
|
+
return false;
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
/**
|
|
1266
|
+
* Logs a console warning in development, once per `key` for the life of the
|
|
1267
|
+
* page. Safe to call during render: a re-render, or a second instance hitting
|
|
1268
|
+
* the same case, finds the key already recorded and stays quiet.
|
|
1269
|
+
*/
|
|
1270
|
+
const warnOnce = (key, message) => {
|
|
1271
|
+
if (!isDev() || warnedKeys.has(key))
|
|
1272
|
+
return;
|
|
1273
|
+
warnedKeys.add(key);
|
|
1274
|
+
console.warn(message);
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1253
1277
|
const avatarColors = [
|
|
1254
1278
|
'primary',
|
|
1255
1279
|
'link',
|
|
@@ -1295,6 +1319,18 @@ const NON_INTERACTIVE_ROLES = [
|
|
|
1295
1319
|
'presentation',
|
|
1296
1320
|
'none',
|
|
1297
1321
|
];
|
|
1322
|
+
/**
|
|
1323
|
+
* Elements other than `a` that declare `target` themselves, so on them it is
|
|
1324
|
+
* the element's own attribute and not a link attribute Avatar withholds for
|
|
1325
|
+
* want of one. The link attribute warning leaves `target` out on these, the way
|
|
1326
|
+
* it leaves `rel` out everywhere. `area` and `base` are void elements, which
|
|
1327
|
+
* Avatar's content rules out, so `form` is the one a caller can reach.
|
|
1328
|
+
*/
|
|
1329
|
+
const ELEMENTS_WITH_OWN_TARGET = [
|
|
1330
|
+
'form',
|
|
1331
|
+
'area',
|
|
1332
|
+
'base',
|
|
1333
|
+
];
|
|
1298
1334
|
/**
|
|
1299
1335
|
* Derives a small set of initials from a name (e.g. "Ada Lovelace" -> "AL").
|
|
1300
1336
|
*/
|
|
@@ -1430,6 +1466,50 @@ const Avatar = forwardRef(function Avatar(avatarProps, ref) {
|
|
|
1430
1466
|
// Only forward link attributes when rendering an anchor or a custom (non-DOM)
|
|
1431
1467
|
// component; a plain `as="div"` must not receive a stray `href`/`target`/`rel`.
|
|
1432
1468
|
const isLinkLike = Tag === 'a' || typeof Tag !== 'string' || isCustomElement(Tag);
|
|
1469
|
+
// A plain element like a `div` declares no `href` or `target`, so the type
|
|
1470
|
+
// accepts them as Avatar's own while the drop below withholds them, and
|
|
1471
|
+
// without this they would vanish in silence (#733). Forwarding them would put
|
|
1472
|
+
// them where HTML has no such attribute, so the drop stays and development
|
|
1473
|
+
// reports it instead, naming only the ones actually passed.
|
|
1474
|
+
//
|
|
1475
|
+
// `rel` is withheld too but left out here. React declares it on every
|
|
1476
|
+
// element, so on a plain `as` it is that element's own attribute, and
|
|
1477
|
+
// "render it as a link" would be the wrong advice for it. `target` is the
|
|
1478
|
+
// same on an element that declares it, such as `form`, so it is left out
|
|
1479
|
+
// there. Whether to forward either one to such an element is a separate
|
|
1480
|
+
// question from this warning.
|
|
1481
|
+
//
|
|
1482
|
+
// Only for an `as` the caller wrote. Without one the element is Avatar's own
|
|
1483
|
+
// choice, and a message naming an `as` they never passed sends them looking
|
|
1484
|
+
// for it. A value counts when it is truthy, the same test that picks `'a'`
|
|
1485
|
+
// over `'figure'`, so an empty `href` from data asks for no link and draws no
|
|
1486
|
+
// warning. The key is the element plus the attributes passed, so a re-render
|
|
1487
|
+
// or a list of avatars warns once, while a different combination on the same
|
|
1488
|
+
// element still gets its own warning rather than hiding behind the first.
|
|
1489
|
+
//
|
|
1490
|
+
// Development-only is `warnOnce`'s job, as it is for the colour warnings, so
|
|
1491
|
+
// this block has no production check of its own. One here would have to read
|
|
1492
|
+
// `process` safely, and a `typeof process` test is not something a bundler
|
|
1493
|
+
// replaces: in a browser it is false, and the warning never fired in the
|
|
1494
|
+
// development builds it exists for. The cost is that production still
|
|
1495
|
+
// collects the attributes and builds the message for an avatar that needs
|
|
1496
|
+
// it, which is small and limited to the case the warning is about.
|
|
1497
|
+
if (as != null && !isLinkLike) {
|
|
1498
|
+
const dropped = Object.entries({
|
|
1499
|
+
href,
|
|
1500
|
+
target: ELEMENTS_WITH_OWN_TARGET.includes(as) ? undefined : target,
|
|
1501
|
+
})
|
|
1502
|
+
.filter(([, value]) => value)
|
|
1503
|
+
.map(([key]) => key);
|
|
1504
|
+
if (dropped.length > 0) {
|
|
1505
|
+
warnOnce(`Avatar:link-props-on-${as}:${dropped.join('+')}`, `[bestax-bulma] <Avatar as="${as}" ${dropped.join(' ')}>: this ` +
|
|
1506
|
+
`<${as}> renders without ` +
|
|
1507
|
+
`${dropped.map(key => `"${key}"`).join(' and ')}, because Avatar ` +
|
|
1508
|
+
`passes link attributes on only to a target that can be a link (an ` +
|
|
1509
|
+
`"a", a custom element, or a component). To make it a link, render ` +
|
|
1510
|
+
`it as="a" or pass a link component to "as".`);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1433
1513
|
// Present-only, not `{ href, target, rel }`. An unconditional spread hands the
|
|
1434
1514
|
// target these keys whatever the caller passed, and a key existing is not free:
|
|
1435
1515
|
// a target that tests for one sees a link where there is none, and one that
|
|
@@ -1820,12 +1900,12 @@ const CardComponent = ({ className, children, textColor, color, bgColor, hasShad
|
|
|
1820
1900
|
* The set withheld from a non-anchor `Card.FooterItem` (`span`/`button`): the
|
|
1821
1901
|
* derived anchor-only attributes, minus `type` (also valid on a `<button>` as
|
|
1822
1902
|
* `submit`/`button`/`reset`, so stripping it there would remove a working
|
|
1823
|
-
* attribute
|
|
1824
|
-
*
|
|
1825
|
-
* `HTMLAttributes` for every element, so the derived set alone
|
|
1826
|
-
* withhold it — the same addition `Level.Item` makes).
|
|
1903
|
+
* attribute; one set for both tags means a `type` also reaches a `<span>`,
|
|
1904
|
+
* which `Dropdown.Item` avoids by choosing its set per tag), plus `rel` (React
|
|
1905
|
+
* declares it on `HTMLAttributes` for every element, so the derived set alone
|
|
1906
|
+
* would not withhold it — the same addition `Level.Item` makes).
|
|
1827
1907
|
*/
|
|
1828
|
-
const STRIP_FROM_NON_ANCHOR$
|
|
1908
|
+
const STRIP_FROM_NON_ANCHOR$1 = (() => {
|
|
1829
1909
|
const { type: _type, ...rest } = ANCHOR_ONLY_ATTRS;
|
|
1830
1910
|
return { ...rest, rel: true };
|
|
1831
1911
|
})();
|
|
@@ -1965,7 +2045,7 @@ const CardFooterItem = ({ as = 'span', className, children, color, bgColor, text
|
|
|
1965
2045
|
if (as === 'a') {
|
|
1966
2046
|
return (jsx("a", { className: itemClasses, ...omitAttrs(rest, STRIP_FROM_NON_BUTTON), children: children }));
|
|
1967
2047
|
}
|
|
1968
|
-
const forwarded = omitAttrs(rest, STRIP_FROM_NON_ANCHOR$
|
|
2048
|
+
const forwarded = omitAttrs(rest, STRIP_FROM_NON_ANCHOR$1);
|
|
1969
2049
|
if (as === 'button') {
|
|
1970
2050
|
const forwardedType = forwarded.type;
|
|
1971
2051
|
return (jsx("button", { className: itemClasses, ...forwarded,
|
|
@@ -2223,6 +2303,35 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
|
|
|
2223
2303
|
e.preventDefault();
|
|
2224
2304
|
items[items.length - 1].focus();
|
|
2225
2305
|
break;
|
|
2306
|
+
case 'Enter':
|
|
2307
|
+
case ' ': {
|
|
2308
|
+
// Activate the focused item by clicking it, so its `onClick` runs and
|
|
2309
|
+
// closing follows `closeOnClick` as it does for the mouse. A caller's
|
|
2310
|
+
// own key handler that prevented the default has claimed the key, and
|
|
2311
|
+
// is left to it rather than followed by a second activation.
|
|
2312
|
+
if (currentIndex < 0 || e.defaultPrevented)
|
|
2313
|
+
break;
|
|
2314
|
+
const item = items[currentIndex];
|
|
2315
|
+
// Leave the browser's own activation alone, or the item runs twice: a
|
|
2316
|
+
// `<button>` answers both keys, and a link with an `href` answers
|
|
2317
|
+
// Enter. A link does not answer Space, so Space on a link is handled
|
|
2318
|
+
// here too, which also keeps the page from scrolling.
|
|
2319
|
+
if (item.tagName === 'BUTTON')
|
|
2320
|
+
break;
|
|
2321
|
+
if (e.key === 'Enter' &&
|
|
2322
|
+
item.tagName === 'A' &&
|
|
2323
|
+
item.hasAttribute('href')) {
|
|
2324
|
+
break;
|
|
2325
|
+
}
|
|
2326
|
+
e.preventDefault();
|
|
2327
|
+
// A held key sends a keydown per auto-repeat. Clicking on each would
|
|
2328
|
+
// toggle a checkbox item over and over while `closeOnClick` is off,
|
|
2329
|
+
// so only the first press activates. The default is still prevented
|
|
2330
|
+
// on the repeats above, so a held Space does not scroll the page.
|
|
2331
|
+
if (!e.repeat)
|
|
2332
|
+
item.click();
|
|
2333
|
+
break;
|
|
2334
|
+
}
|
|
2226
2335
|
}
|
|
2227
2336
|
};
|
|
2228
2337
|
const dropdownClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
|
|
@@ -2232,19 +2341,16 @@ const DropdownComponent = forwardRef(function DropdownComponent({ label, childre
|
|
|
2232
2341
|
* The anchor's attributes, minus the one a `<button>` legitimately takes.
|
|
2233
2342
|
*
|
|
2234
2343
|
* `type` stays: `as="button"` is a supported form and `type="submit"` is valid
|
|
2235
|
-
* there, so stripping it would remove a working attribute.
|
|
2236
|
-
*
|
|
2237
|
-
*
|
|
2238
|
-
*
|
|
2239
|
-
*
|
|
2240
|
-
* This set differs from `Level.Item`'s in both directions, not just one. The
|
|
2241
|
-
* `type` above, which Level strips and this component keeps, and `rel`, which
|
|
2242
|
-
* Level adds and this component does not: React declares `rel` on
|
|
2344
|
+
* there, so stripping it would remove a working attribute. A `<div>` takes no
|
|
2345
|
+
* `type`, so it gets the whole `ANCHOR_ONLY_ATTRS` set instead. The set is
|
|
2346
|
+
* chosen by the rendered tag because that is where the reason lives (#692).
|
|
2347
|
+
*
|
|
2348
|
+
* Neither set withholds `rel`, which `Level.Item` does: React declares `rel` on
|
|
2243
2349
|
* `HTMLAttributes` for every element, so withholding it would diverge from
|
|
2244
|
-
* React's own typing
|
|
2350
|
+
* React's own typing, the call #641 recorded for `Navbar.Link`. Level
|
|
2245
2351
|
* withholds it anyway, because it always has.
|
|
2246
2352
|
*/
|
|
2247
|
-
const
|
|
2353
|
+
const STRIP_FROM_BUTTON = (() => {
|
|
2248
2354
|
const { type: _type, ...rest } = ANCHOR_ONLY_ATTRS;
|
|
2249
2355
|
return rest;
|
|
2250
2356
|
})();
|
|
@@ -2274,12 +2380,22 @@ const DropdownItem = ((itemProps) => {
|
|
|
2274
2380
|
// are not interchangeable and neither derives from the other.
|
|
2275
2381
|
//
|
|
2276
2382
|
// Menu's condition also admits a custom component and a custom element, which
|
|
2277
|
-
// own their prop contracts.
|
|
2278
|
-
//
|
|
2279
|
-
const forwarded = Component === 'a'
|
|
2383
|
+
// own their prop contracts. Here the set follows the tag: an `<a>` keeps all
|
|
2384
|
+
// of them, a `<button>` keeps `type`, and any other `as` keeps none of them.
|
|
2385
|
+
const forwarded = Component === 'a'
|
|
2386
|
+
? rest
|
|
2387
|
+
: Component === 'button'
|
|
2388
|
+
? omitAttrs(rest, STRIP_FROM_BUTTON)
|
|
2389
|
+
: omitAttrs(rest, ANCHOR_ONLY_ATTRS);
|
|
2280
2390
|
return (jsx(Component, { className: classNames(usePrefixedClassNames('dropdown-item', {
|
|
2281
2391
|
'is-active': active,
|
|
2282
|
-
}), bulmaHelperClasses, className),
|
|
2392
|
+
}), bulmaHelperClasses, className), "data-testid": "dropdown-item", ...forwarded,
|
|
2393
|
+
// After `forwarded` for the same reason as `role` and `type` below: a
|
|
2394
|
+
// spread carrying `tabIndex: undefined` would otherwise erase the
|
|
2395
|
+
// default. The item keeps its menu role and its place in the arrow-key
|
|
2396
|
+
// order, but a `<div>` or an anchor without an `href` cannot take focus
|
|
2397
|
+
// without a tabindex, so the arrow keys stall on it.
|
|
2398
|
+
tabIndex: forwarded.tabIndex ?? 0,
|
|
2283
2399
|
// After `forwarded` for the same reason as `type` below: a spread
|
|
2284
2400
|
// carrying `role: undefined` would otherwise erase the default, and an
|
|
2285
2401
|
// item with no role drops out of the menu and its arrow-key order.
|
|
@@ -3161,23 +3277,6 @@ const UNSTYLED_MODIFIER_COLORS = [
|
|
|
3161
3277
|
'grey-lighter',
|
|
3162
3278
|
];
|
|
3163
3279
|
const CSS_BACKED = 'primary, link, info, success, warning, danger, black, white, light, dark';
|
|
3164
|
-
const warnedKeys = new Set();
|
|
3165
|
-
// Fail closed: with no bundler and no Node (raw CDN ESM), reading `process`
|
|
3166
|
-
// throws and warnings stay off, so production can never warn by accident.
|
|
3167
|
-
const isDev = () => {
|
|
3168
|
-
try {
|
|
3169
|
-
return process.env.NODE_ENV !== 'production';
|
|
3170
|
-
}
|
|
3171
|
-
catch {
|
|
3172
|
-
return false;
|
|
3173
|
-
}
|
|
3174
|
-
};
|
|
3175
|
-
const warnOnce = (key, message) => {
|
|
3176
|
-
if (!isDev() || warnedKeys.has(key))
|
|
3177
|
-
return;
|
|
3178
|
-
warnedKeys.add(key);
|
|
3179
|
-
console.warn(message);
|
|
3180
|
-
};
|
|
3181
3280
|
/**
|
|
3182
3281
|
* Dev warning for a `color` value whose `is-<color>` modifier has no shipped
|
|
3183
3282
|
* CSS. `extraUnstyled` covers per-component dead values beyond the shared
|
|
@@ -4766,11 +4865,26 @@ let toasts = [];
|
|
|
4766
4865
|
// Queued toasts: FIFO queue, one at a time
|
|
4767
4866
|
let queuedToasts = [];
|
|
4768
4867
|
let currentQueuedToast = null;
|
|
4868
|
+
// The server has nowhere to portal a toast to, and its copy of this module is
|
|
4869
|
+
// shared by every request, so server rendering reads an empty list. Hydration
|
|
4870
|
+
// reads it too, which keeps the first client render matching the server's.
|
|
4871
|
+
const noToasts = [];
|
|
4872
|
+
const getServerToasts = () => noToasts;
|
|
4873
|
+
// What a container shows right now: the stacked toasts, then the queued one on
|
|
4874
|
+
// screen. ToastContainer renders from this rather than from updates alone, so
|
|
4875
|
+
// toasts raised before it mounted still appear. It is replaced rather than
|
|
4876
|
+
// mutated, and only when listeners are notified, because useSyncExternalStore
|
|
4877
|
+
// needs the same array back between changes. An empty list is `noToasts`
|
|
4878
|
+
// itself, so a container that hydrates with nothing to show reads the same
|
|
4879
|
+
// snapshot the server did and has no reason to render again.
|
|
4880
|
+
let visibleToasts = noToasts;
|
|
4881
|
+
const getVisibleToasts = () => visibleToasts;
|
|
4769
4882
|
const notifyListeners = () => {
|
|
4770
4883
|
const allVisible = [...toasts];
|
|
4771
4884
|
if (currentQueuedToast) {
|
|
4772
4885
|
allVisible.push(currentQueuedToast);
|
|
4773
4886
|
}
|
|
4887
|
+
visibleToasts = allVisible.length > 0 ? allVisible : noToasts;
|
|
4774
4888
|
toastListeners.forEach(listener => listener([...allVisible]));
|
|
4775
4889
|
};
|
|
4776
4890
|
const processQueuedToast = () => {
|
|
@@ -4882,10 +4996,9 @@ const toast = {
|
|
|
4882
4996
|
* @returns {JSX.Element | null} The rendered toast container, or null if empty.
|
|
4883
4997
|
*/
|
|
4884
4998
|
const ToastContainer = ({ position = 'top-right', }) => {
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
}, []);
|
|
4999
|
+
// Starts from the toasts already showing instead of an empty list, then
|
|
5000
|
+
// follows changes.
|
|
5001
|
+
const toastList = useSyncExternalStore(toast.subscribe, getVisibleToasts, getServerToasts);
|
|
4889
5002
|
if (typeof document === 'undefined' || toastList.length === 0) {
|
|
4890
5003
|
return null;
|
|
4891
5004
|
}
|
|
@@ -5037,6 +5150,14 @@ const Dialog = forwardRef(({ isOpen, title, message, type = 'default', confirmTe
|
|
|
5037
5150
|
Dialog.displayName = 'Dialog';
|
|
5038
5151
|
let dialogListeners = new Set();
|
|
5039
5152
|
let currentDialog = null;
|
|
5153
|
+
// DialogContainer renders from the open dialog rather than from updates alone,
|
|
5154
|
+
// so a dialog raised before it mounted still opens once it does.
|
|
5155
|
+
const getCurrentDialog = () => currentDialog;
|
|
5156
|
+
// The server renders no dialog: its copy of this module is shared by every
|
|
5157
|
+
// request, so the dialog it holds may belong to another page. Hydration reads
|
|
5158
|
+
// the same empty value, which keeps the first client render matching the
|
|
5159
|
+
// server's, and the dialog opens right after.
|
|
5160
|
+
const getServerDialog = () => null;
|
|
5040
5161
|
const notifyDialogListeners = () => {
|
|
5041
5162
|
dialogListeners.forEach(listener => listener(currentDialog));
|
|
5042
5163
|
};
|
|
@@ -5098,10 +5219,8 @@ const dialog = {
|
|
|
5098
5219
|
* @returns {JSX.Element | null} The rendered dialog, or null if none is active.
|
|
5099
5220
|
*/
|
|
5100
5221
|
const DialogContainer = () => {
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
return dialog.subscribe(setCurrent);
|
|
5104
|
-
}, []);
|
|
5222
|
+
// Starts from the dialog already open instead of none, then follows changes.
|
|
5223
|
+
const current = useSyncExternalStore(dialog.subscribe, getCurrentDialog, getServerDialog);
|
|
5105
5224
|
if (!current) {
|
|
5106
5225
|
return null;
|
|
5107
5226
|
}
|
|
@@ -6175,11 +6294,28 @@ let notifications = [];
|
|
|
6175
6294
|
// Queue support
|
|
6176
6295
|
let queuedNotifications = [];
|
|
6177
6296
|
let currentQueuedNotification = null;
|
|
6297
|
+
// The server has nowhere to portal a notification to, and its copy of this
|
|
6298
|
+
// module is shared by every request, so server rendering reads an empty list.
|
|
6299
|
+
// Hydration reads it too, which keeps the first client render matching the
|
|
6300
|
+
// server's.
|
|
6301
|
+
const noNotifications = [];
|
|
6302
|
+
const getServerNotifications = () => noNotifications;
|
|
6303
|
+
// What a container shows right now: the stacked notifications, then the queued
|
|
6304
|
+
// one on screen. NotificationContainer renders from this rather than from
|
|
6305
|
+
// updates alone, so notifications raised before it mounted still appear. It is
|
|
6306
|
+
// replaced rather than mutated, and only when listeners are notified, because
|
|
6307
|
+
// useSyncExternalStore needs the same array back between changes. An empty
|
|
6308
|
+
// list is `noNotifications` itself, so a container that hydrates with nothing
|
|
6309
|
+
// to show reads the same snapshot the server did and has no reason to render
|
|
6310
|
+
// again.
|
|
6311
|
+
let visibleNotifications = noNotifications;
|
|
6312
|
+
const getVisibleNotifications = () => visibleNotifications;
|
|
6178
6313
|
const notifyNotificationListeners = () => {
|
|
6179
6314
|
const allVisible = [...notifications];
|
|
6180
6315
|
if (currentQueuedNotification) {
|
|
6181
6316
|
allVisible.push(currentQueuedNotification);
|
|
6182
6317
|
}
|
|
6318
|
+
visibleNotifications = allVisible.length > 0 ? allVisible : noNotifications;
|
|
6183
6319
|
notificationListeners.forEach(listener => listener([...allVisible]));
|
|
6184
6320
|
};
|
|
6185
6321
|
const processQueuedNotification = () => {
|
|
@@ -6315,19 +6451,16 @@ const NotificationItem = ({ instance, onClose }) => {
|
|
|
6315
6451
|
};
|
|
6316
6452
|
/**
|
|
6317
6453
|
* Container component for rendering programmatic notifications.
|
|
6318
|
-
* Place once at your app root to enable the notification API.
|
|
6319
|
-
* before calling `notification`: a notification shown while no container is
|
|
6320
|
-
* mounted doesn't appear when one mounts, only alongside the next call.
|
|
6454
|
+
* Place once at your app root to enable the notification API.
|
|
6321
6455
|
*
|
|
6322
6456
|
* @function
|
|
6323
6457
|
* @param {{ position?: NotificationPosition }} props - Container props.
|
|
6324
6458
|
* @returns {JSX.Element | null} The rendered notification container, or null if empty.
|
|
6325
6459
|
*/
|
|
6326
6460
|
const NotificationContainer = ({ position = 'top-right' }) => {
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
}, []);
|
|
6461
|
+
// Starts from the notifications already showing instead of an empty list,
|
|
6462
|
+
// then follows changes.
|
|
6463
|
+
const items = useSyncExternalStore(notification.subscribe, getVisibleNotifications, getServerNotifications);
|
|
6331
6464
|
if (typeof document === 'undefined' || items.length === 0) {
|
|
6332
6465
|
return null;
|
|
6333
6466
|
}
|
|
@@ -6893,7 +7026,21 @@ const RadiosProvider = RadiosContext.Provider;
|
|
|
6893
7026
|
const CheckboxesProvider = CheckboxesContext.Provider;
|
|
6894
7027
|
|
|
6895
7028
|
/**
|
|
6896
|
-
*
|
|
7029
|
+
* The values the Checkbox `color` prop accepts, as a readonly tuple.
|
|
7030
|
+
*
|
|
7031
|
+
* `CheckboxProps['color']` is typed from it, so the two list the same values.
|
|
7032
|
+
* Map over it to build a color picker, or check a value that arrives at
|
|
7033
|
+
* runtime before passing it in: the component adds no color class for a value
|
|
7034
|
+
* outside the tuple.
|
|
7035
|
+
*
|
|
7036
|
+
* @example
|
|
7037
|
+
* import { Checkbox, checkboxColors } from '@allxsmith/bestax-bulma';
|
|
7038
|
+
*
|
|
7039
|
+
* checkboxColors.map(color => (
|
|
7040
|
+
* <Checkbox key={color} color={color}>
|
|
7041
|
+
* {color}
|
|
7042
|
+
* </Checkbox>
|
|
7043
|
+
* ));
|
|
6897
7044
|
*/
|
|
6898
7045
|
const checkboxColors = [
|
|
6899
7046
|
'primary',
|
|
@@ -6904,7 +7051,17 @@ const checkboxColors = [
|
|
|
6904
7051
|
'danger',
|
|
6905
7052
|
];
|
|
6906
7053
|
/**
|
|
6907
|
-
*
|
|
7054
|
+
* The values the Checkbox `size` prop accepts, as a readonly tuple.
|
|
7055
|
+
*
|
|
7056
|
+
* `CheckboxProps['size']` is typed from it, so the two list the same values.
|
|
7057
|
+
* Use it to offer a size choice or to check a value that arrives at runtime:
|
|
7058
|
+
* the component adds no size class for a value outside the tuple. These are
|
|
7059
|
+
* element sizes, not the spacing scale in `validSizes`.
|
|
7060
|
+
*
|
|
7061
|
+
* @example
|
|
7062
|
+
* import { checkboxSizes } from '@allxsmith/bestax-bulma';
|
|
7063
|
+
*
|
|
7064
|
+
* type CheckboxSize = (typeof checkboxSizes)[number];
|
|
6908
7065
|
*/
|
|
6909
7066
|
const checkboxSizes = ['small', 'normal', 'medium', 'large'];
|
|
6910
7067
|
/**
|
|
@@ -7349,7 +7506,23 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7349
7506
|
File.displayName = 'File';
|
|
7350
7507
|
|
|
7351
7508
|
/**
|
|
7352
|
-
*
|
|
7509
|
+
* The values the Radio `color` prop accepts, as a readonly tuple.
|
|
7510
|
+
*
|
|
7511
|
+
* `RadioProps['color']` is typed from it, so the two list the same values.
|
|
7512
|
+
* Map over it to build a color picker, or check a value that arrives at
|
|
7513
|
+
* runtime before passing it in: the component adds no color class for a value
|
|
7514
|
+
* outside the tuple.
|
|
7515
|
+
*
|
|
7516
|
+
* @example
|
|
7517
|
+
* import { Radio, Radios, radioColors } from '@allxsmith/bestax-bulma';
|
|
7518
|
+
*
|
|
7519
|
+
* <Radios name="accent" defaultValue="primary">
|
|
7520
|
+
* {radioColors.map(color => (
|
|
7521
|
+
* <Radio key={color} value={color} color={color}>
|
|
7522
|
+
* {color}
|
|
7523
|
+
* </Radio>
|
|
7524
|
+
* ))}
|
|
7525
|
+
* </Radios>;
|
|
7353
7526
|
*/
|
|
7354
7527
|
const radioColors = [
|
|
7355
7528
|
'primary',
|
|
@@ -7360,7 +7533,17 @@ const radioColors = [
|
|
|
7360
7533
|
'danger',
|
|
7361
7534
|
];
|
|
7362
7535
|
/**
|
|
7363
|
-
*
|
|
7536
|
+
* The values the Radio `size` prop accepts, as a readonly tuple.
|
|
7537
|
+
*
|
|
7538
|
+
* `RadioProps['size']` is typed from it, so the two list the same values. Use
|
|
7539
|
+
* it to offer a size choice or to check a value that arrives at runtime: the
|
|
7540
|
+
* component adds no size class for a value outside the tuple. These are
|
|
7541
|
+
* element sizes, not the spacing scale in `validSizes`.
|
|
7542
|
+
*
|
|
7543
|
+
* @example
|
|
7544
|
+
* import { radioSizes } from '@allxsmith/bestax-bulma';
|
|
7545
|
+
*
|
|
7546
|
+
* type RadioSize = (typeof radioSizes)[number];
|
|
7364
7547
|
*/
|
|
7365
7548
|
const radioSizes = ['small', 'normal', 'medium', 'large'];
|
|
7366
7549
|
/**
|
|
@@ -7491,7 +7674,21 @@ const RadiosComponent = ({ label, labelSize, labelProps, horizontal, message, me
|
|
|
7491
7674
|
const Radios = withSubComponents(RadiosComponent, { Radio }, 'Radios');
|
|
7492
7675
|
|
|
7493
7676
|
/**
|
|
7494
|
-
*
|
|
7677
|
+
* The values the Switch `color` and `passiveType` props accept, as a readonly
|
|
7678
|
+
* tuple.
|
|
7679
|
+
*
|
|
7680
|
+
* Both props are typed from it, so they list the same values. Map over it to
|
|
7681
|
+
* build a color picker, or check a value that arrives at runtime before
|
|
7682
|
+
* passing it in: the component adds no class for a value outside the tuple.
|
|
7683
|
+
*
|
|
7684
|
+
* @example
|
|
7685
|
+
* import { Switch, switchColors } from '@allxsmith/bestax-bulma';
|
|
7686
|
+
*
|
|
7687
|
+
* switchColors.map(color => (
|
|
7688
|
+
* <Switch key={color} color={color} defaultChecked>
|
|
7689
|
+
* {color}
|
|
7690
|
+
* </Switch>
|
|
7691
|
+
* ));
|
|
7495
7692
|
*/
|
|
7496
7693
|
const switchColors = [
|
|
7497
7694
|
'primary',
|
|
@@ -7502,7 +7699,17 @@ const switchColors = [
|
|
|
7502
7699
|
'danger',
|
|
7503
7700
|
];
|
|
7504
7701
|
/**
|
|
7505
|
-
*
|
|
7702
|
+
* The values the Switch `size` prop accepts, as a readonly tuple.
|
|
7703
|
+
*
|
|
7704
|
+
* `SwitchProps['size']` is typed from it, so the two list the same values. Use
|
|
7705
|
+
* it to offer a size choice or to check a value that arrives at runtime: the
|
|
7706
|
+
* component adds no size class for a value outside the tuple. These are
|
|
7707
|
+
* element sizes, not the spacing scale in `validSizes`.
|
|
7708
|
+
*
|
|
7709
|
+
* @example
|
|
7710
|
+
* import { switchSizes } from '@allxsmith/bestax-bulma';
|
|
7711
|
+
*
|
|
7712
|
+
* type SwitchSize = (typeof switchSizes)[number];
|
|
7506
7713
|
*/
|
|
7507
7714
|
const switchSizes = ['small', 'normal', 'medium', 'large'];
|
|
7508
7715
|
/**
|
|
@@ -12998,17 +13205,130 @@ function cssVarToProp(varName) {
|
|
|
12998
13205
|
.join('');
|
|
12999
13206
|
}
|
|
13000
13207
|
/**
|
|
13001
|
-
*
|
|
13208
|
+
* Prop names `cssVarToProp` would mint that are already `BulmaOtherProps`
|
|
13209
|
+
* helper props: `--bulma-shadow` becomes `shadow` and `--bulma-radius` becomes
|
|
13210
|
+
* `radius`. They stay out of `bulmaVarPropMap`, so on Theme each is the helper
|
|
13211
|
+
* prop it is on every other component, and both variables are still reachable
|
|
13212
|
+
* through `bulmaVars`.
|
|
13002
13213
|
*
|
|
13003
|
-
*
|
|
13004
|
-
*
|
|
13005
|
-
*
|
|
13006
|
-
|
|
13007
|
-
|
|
13214
|
+
* `radius` was missed here once and set `--bulma-radius` while typed as the
|
|
13215
|
+
* helper (#694). It still writes that variable, so what it did then keeps
|
|
13216
|
+
* working; see `themeRadiusVar`.
|
|
13217
|
+
*/
|
|
13218
|
+
const helperPropNames = ['shadow', 'radius'];
|
|
13219
|
+
/**
|
|
13220
|
+
* Mapping of camelCase prop names to their Bulma CSS variable counterparts,
|
|
13221
|
+
* minus the `helperPropNames` above.
|
|
13008
13222
|
*/
|
|
13009
13223
|
const bulmaVarPropMap = Object.fromEntries(bulmaCssVars
|
|
13010
13224
|
.map(cssVar => [cssVarToProp(cssVar), cssVar])
|
|
13011
|
-
.filter(([prop]) => prop
|
|
13225
|
+
.filter(([prop]) => !helperPropNames.includes(prop)));
|
|
13226
|
+
/**
|
|
13227
|
+
* What each helper value of `radius` writes to `--bulma-radius` on a Theme,
|
|
13228
|
+
* alongside its class.
|
|
13229
|
+
*
|
|
13230
|
+
* Before #694, `radius="radiusless"` wrote `--bulma-radius: radiusless`. That
|
|
13231
|
+
* is not a length, and a declaration reading an invalid variable falls back
|
|
13232
|
+
* to its property's initial value, which for a border radius is 0. So
|
|
13233
|
+
* everything inside the Theme that takes its radius from that variable lost
|
|
13234
|
+
* it, and under `isRoot` so did everything on the page that does. Writing a
|
|
13235
|
+
* real 0 keeps what
|
|
13236
|
+
* people see and makes it valid CSS. Keyed by the helper values, so adding
|
|
13237
|
+
* one means saying what it writes.
|
|
13238
|
+
*/
|
|
13239
|
+
const radiusHelperVars = {
|
|
13240
|
+
radiusless: '0',
|
|
13241
|
+
};
|
|
13242
|
+
/**
|
|
13243
|
+
* What `radius` writes to `--bulma-radius` on a Theme, or `undefined` when it
|
|
13244
|
+
* writes nothing.
|
|
13245
|
+
*
|
|
13246
|
+
* A helper value writes its `radiusHelperVars` entry. Any other non-empty
|
|
13247
|
+
* string is written as given: before #694 every `radius` on Theme set the
|
|
13248
|
+
* variable whatever its type said, and a JavaScript caller passing a length
|
|
13249
|
+
* got the radius it asked for. That keeps working so nothing breaks, but the
|
|
13250
|
+
* type rejects it, so it warns in development and points at `bulmaVars`.
|
|
13251
|
+
*
|
|
13252
|
+
* Only a string writes anything, because only a string ever set the variable
|
|
13253
|
+
* to something usable: an empty value or zero was dropped, and a boolean or
|
|
13254
|
+
* any other bare number is not a length. The helper ignores those too, the
|
|
13255
|
+
* way it does on every other component.
|
|
13256
|
+
*/
|
|
13257
|
+
const themeRadiusVar = (radius) => {
|
|
13258
|
+
if (typeof radius !== 'string' || radius === '') {
|
|
13259
|
+
return undefined;
|
|
13260
|
+
}
|
|
13261
|
+
if (validRadii.includes(radius)) {
|
|
13262
|
+
return radiusHelperVars[radius];
|
|
13263
|
+
}
|
|
13264
|
+
warnOnce('Theme:radius-variable', `[bestax-bulma] <Theme radius="${radius}">: setting --bulma-radius ` +
|
|
13265
|
+
'through the radius prop is deprecated and will stop working in a ' +
|
|
13266
|
+
'future major version. On Theme, as on every other component, radius ' +
|
|
13267
|
+
`is the "${validRadii.join('", "')}" helper. Set the variable with ` +
|
|
13268
|
+
`bulmaVars={{ '--bulma-radius': '${radius}' }} instead.`);
|
|
13269
|
+
return radius;
|
|
13270
|
+
};
|
|
13271
|
+
/** The one `<style>` element every `isRoot` Theme writes into. */
|
|
13272
|
+
const ROOT_STYLE_ID = 'bestax-bulma-theme-vars';
|
|
13273
|
+
/**
|
|
13274
|
+
* The `:root` rules of every mounted `isRoot` Theme that has any, keyed by the
|
|
13275
|
+
* Theme's render order.
|
|
13276
|
+
*
|
|
13277
|
+
* Root Themes share one `<style>` element, so each keeps its rules here and
|
|
13278
|
+
* the element is rebuilt from all of them whenever one mounts, changes or
|
|
13279
|
+
* unmounts. Before this each Theme overwrote the element with only its own
|
|
13280
|
+
* rules, and the first to unmount removed it for all of them (#736).
|
|
13281
|
+
*
|
|
13282
|
+
* The key is a number each Theme takes when it first renders. React renders a
|
|
13283
|
+
* parent before its children and an earlier sibling before a later one, so an
|
|
13284
|
+
* inner or later-mounted root Theme sorts later, comes later in the
|
|
13285
|
+
* stylesheet, and wins a variable two of them set, as an inner scoped Theme
|
|
13286
|
+
* does. Effects would give the wrong answer for nesting: React runs a child's
|
|
13287
|
+
* effects before its parent's. Only the relative order matters, so a number
|
|
13288
|
+
* skipped by StrictMode calling the initializer twice, or by a render React
|
|
13289
|
+
* throws away, is harmless. The key never changes, so an update keeps its
|
|
13290
|
+
* place and re-rendering one Theme never changes which one wins.
|
|
13291
|
+
*/
|
|
13292
|
+
const rootThemeRules = new Map();
|
|
13293
|
+
let nextRootOrder = 0;
|
|
13294
|
+
/**
|
|
13295
|
+
* Write every registered root Theme's rules into the shared element, creating
|
|
13296
|
+
* it when needed and removing it once no Theme has any rules left.
|
|
13297
|
+
*/
|
|
13298
|
+
const renderRootThemeRules = () => {
|
|
13299
|
+
let element = document.getElementById(ROOT_STYLE_ID);
|
|
13300
|
+
if (rootThemeRules.size === 0) {
|
|
13301
|
+
element?.remove();
|
|
13302
|
+
return;
|
|
13303
|
+
}
|
|
13304
|
+
if (!element) {
|
|
13305
|
+
element = document.createElement('style');
|
|
13306
|
+
element.id = ROOT_STYLE_ID;
|
|
13307
|
+
document.head.appendChild(element);
|
|
13308
|
+
}
|
|
13309
|
+
element.textContent = [...rootThemeRules]
|
|
13310
|
+
.sort(([a], [b]) => a - b)
|
|
13311
|
+
.map(([, rules]) => rules)
|
|
13312
|
+
.join('\n');
|
|
13313
|
+
};
|
|
13314
|
+
/**
|
|
13315
|
+
* Record one Theme's `:root` rules, where an empty string means it has none,
|
|
13316
|
+
* and rebuild the shared element if that changed anything. A Theme with no
|
|
13317
|
+
* rules never touches the element, which is what it did before the registry
|
|
13318
|
+
* too.
|
|
13319
|
+
*/
|
|
13320
|
+
const setRootThemeRules = (order, rules) => {
|
|
13321
|
+
if ((rootThemeRules.get(order) ?? '') === rules) {
|
|
13322
|
+
return;
|
|
13323
|
+
}
|
|
13324
|
+
if (rules) {
|
|
13325
|
+
rootThemeRules.set(order, rules);
|
|
13326
|
+
}
|
|
13327
|
+
else {
|
|
13328
|
+
rootThemeRules.delete(order);
|
|
13329
|
+
}
|
|
13330
|
+
renderRootThemeRules();
|
|
13331
|
+
};
|
|
13012
13332
|
/**
|
|
13013
13333
|
* Theme component that injects Bulma CSS variables either globally or locally.
|
|
13014
13334
|
*
|
|
@@ -13025,7 +13345,11 @@ const bulmaVarPropMap = Object.fromEntries(bulmaCssVars
|
|
|
13025
13345
|
* <Button color="primary">Themed</Button>
|
|
13026
13346
|
* </Theme>
|
|
13027
13347
|
*/
|
|
13028
|
-
const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode, ...restProps }) => {
|
|
13348
|
+
const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode, radius, ...restProps }) => {
|
|
13349
|
+
const radiusVar = themeRadiusVar(radius);
|
|
13350
|
+
const radiusHelper = validRadii.includes(radius)
|
|
13351
|
+
? radius
|
|
13352
|
+
: undefined;
|
|
13029
13353
|
// Extract Bulma variable props from restProps
|
|
13030
13354
|
const { bulmaVarProps, otherProps } = useMemo(() => {
|
|
13031
13355
|
const varProps = {};
|
|
@@ -13040,8 +13364,12 @@ const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode,
|
|
|
13040
13364
|
}
|
|
13041
13365
|
return { bulmaVarProps: varProps, otherProps: otherPropsObj };
|
|
13042
13366
|
}, [restProps]);
|
|
13043
|
-
// Use Bulma classes for styling (only when not isRoot)
|
|
13044
|
-
|
|
13367
|
+
// Use Bulma classes for styling (only when not isRoot). Only a helper value
|
|
13368
|
+
// of `radius` reaches the helper; a legacy string went to the variable.
|
|
13369
|
+
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
13370
|
+
...otherProps,
|
|
13371
|
+
radius: radiusHelper,
|
|
13372
|
+
});
|
|
13045
13373
|
// Merge bulmaVars and individual props, with props taking precedence
|
|
13046
13374
|
const mergedVars = useMemo(() => {
|
|
13047
13375
|
const vars = { ...bulmaVars };
|
|
@@ -13050,37 +13378,34 @@ const Theme = ({ bulmaVars = {}, children, className, isRoot = false, colorMode,
|
|
|
13050
13378
|
vars[cssVar] = bulmaVarProps[propName];
|
|
13051
13379
|
}
|
|
13052
13380
|
}
|
|
13381
|
+
if (radiusVar !== undefined) {
|
|
13382
|
+
vars['--bulma-radius'] = radiusVar;
|
|
13383
|
+
}
|
|
13053
13384
|
return vars;
|
|
13054
|
-
}, [bulmaVars, bulmaVarProps]);
|
|
13055
|
-
//
|
|
13056
|
-
|
|
13385
|
+
}, [bulmaVars, bulmaVarProps, radiusVar]);
|
|
13386
|
+
// This Theme's place among root Themes; see `rootThemeRules`.
|
|
13387
|
+
const [rootOrder] = useState(() => nextRootOrder++);
|
|
13388
|
+
// The `:root` rules this Theme contributes, or '' when it contributes none.
|
|
13389
|
+
const rootRules = useMemo(() => {
|
|
13057
13390
|
if (!isRoot) {
|
|
13058
|
-
return;
|
|
13059
|
-
}
|
|
13060
|
-
const validVars = Object.entries(mergedVars).filter(([key, value]) => bulmaCssVars.includes(key) && value);
|
|
13061
|
-
if (validVars.length === 0) {
|
|
13062
|
-
return;
|
|
13063
|
-
}
|
|
13064
|
-
// Create and inject a style element for global CSS variables
|
|
13065
|
-
const styleId = 'bestax-bulma-theme-vars';
|
|
13066
|
-
let styleElement = document.getElementById(styleId);
|
|
13067
|
-
if (!styleElement) {
|
|
13068
|
-
styleElement = document.createElement('style');
|
|
13069
|
-
styleElement.id = styleId;
|
|
13070
|
-
document.head.appendChild(styleElement);
|
|
13391
|
+
return '';
|
|
13071
13392
|
}
|
|
13072
|
-
const cssRules =
|
|
13393
|
+
const cssRules = Object.entries(mergedVars)
|
|
13394
|
+
.filter(([key, value]) => bulmaCssVars.includes(key) && value)
|
|
13073
13395
|
.map(([key, value]) => `${key}: ${value};`)
|
|
13074
13396
|
.join(' ');
|
|
13075
|
-
|
|
13076
|
-
// Cleanup function to remove the style element when component unmounts
|
|
13077
|
-
return () => {
|
|
13078
|
-
const element = document.getElementById(styleId);
|
|
13079
|
-
if (element) {
|
|
13080
|
-
element.remove();
|
|
13081
|
-
}
|
|
13082
|
-
};
|
|
13397
|
+
return cssRules ? `:root { ${cssRules} }` : '';
|
|
13083
13398
|
}, [mergedVars, isRoot]);
|
|
13399
|
+
// Inject CSS variables globally at :root level, alongside any other root
|
|
13400
|
+
// Themes. Clearing `isRoot` or every variable passes '', which withdraws
|
|
13401
|
+
// this Theme's rules.
|
|
13402
|
+
useEffect(() => {
|
|
13403
|
+
setRootThemeRules(rootOrder, rootRules);
|
|
13404
|
+
}, [rootOrder, rootRules]);
|
|
13405
|
+
// Withdraw them on unmount. Kept apart from the effect above so a change
|
|
13406
|
+
// rewrites the shared element in place rather than removing and recreating
|
|
13407
|
+
// it between the cleanup and the next run.
|
|
13408
|
+
useEffect(() => () => setRootThemeRules(rootOrder, ''), [rootOrder]);
|
|
13084
13409
|
// Toggle Bulma's light/dark scheme by writing the `data-theme` attribute on
|
|
13085
13410
|
// the document root (<html>). This is always global, even on a scoped Theme.
|
|
13086
13411
|
// `'system'` removes the attribute so Bulma follows the OS preference.
|