@allxsmith/bestax-bulma 3.0.2 → 5.0.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 +207 -240
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +208 -241
- package/dist/index.esm.js.map +1 -1
- package/package.json +8 -15
- package/dist/versions/bestax-bulma-prefixed.css +0 -3
- package/dist/versions/bestax-bulma-prefixed.css.map +0 -1
- package/dist/versions/bestax-bulma-prefixed.js +0 -1
- package/src/scss/versions/bestax-bulma-prefixed.scss +0 -15
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext, useContext, useMemo, useState, useRef, useEffect, useCallback, useLayoutEffect, forwardRef, Children, isValidElement, cloneElement
|
|
2
|
+
import React, { createContext, useContext, useMemo, useState, useRef, useEffect, useCallback, useId, useLayoutEffect, forwardRef, Children, isValidElement, cloneElement } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
|
|
5
5
|
const ConfigContext = createContext({});
|
|
@@ -760,7 +760,7 @@ const CardComponent = ({ className, children, textColor, bgColor, hasShadow = tr
|
|
|
760
760
|
'is-centered': headerCentered,
|
|
761
761
|
}), children: header })), headerIcon] }));
|
|
762
762
|
};
|
|
763
|
-
return (jsxs("div", { className: cardClasses, ...rest, children: [renderHeader(header, headerIcon, headerCentered, classPrefix), image && (jsx("div", { className: prefixedClassNames(classPrefix, 'card-image'), children: typeof image === 'string' ? (jsx("figure", { className: prefixedClassNames(classPrefix, 'image'), children: jsx("img", { src: image, alt: imageAlt
|
|
763
|
+
return (jsxs("div", { className: cardClasses, ...rest, children: [renderHeader(header, headerIcon, headerCentered, classPrefix), image && (jsx("div", { className: prefixedClassNames(classPrefix, 'card-image'), children: typeof image === 'string' ? (jsx("figure", { className: prefixedClassNames(classPrefix, 'image'), children: jsx("img", { src: image, alt: imageAlt ?? 'Card image' }) })) : (image) })), typeof children !== 'undefined' &&
|
|
764
764
|
children !== null &&
|
|
765
765
|
children !== '' &&
|
|
766
766
|
!hasCompoundComponents(children) && (jsx("div", { className: prefixedClassNames(classPrefix, 'card-content'), children: children })), typeof children !== 'undefined' &&
|
|
@@ -823,10 +823,9 @@ const DropdownComponent = ({ label, children, className, menuClassName, active:
|
|
|
823
823
|
if (!isBrowser$1(window, document))
|
|
824
824
|
return;
|
|
825
825
|
const handleClick = (e) => {
|
|
826
|
-
|
|
827
|
-
if (!((_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
826
|
+
if (!dropdownRef.current?.contains(e.target)) {
|
|
828
827
|
setActive(false);
|
|
829
|
-
onActiveChange
|
|
828
|
+
onActiveChange?.(false);
|
|
830
829
|
}
|
|
831
830
|
};
|
|
832
831
|
document.addEventListener('mousedown', handleClick);
|
|
@@ -837,12 +836,12 @@ const DropdownComponent = ({ label, children, className, menuClassName, active:
|
|
|
837
836
|
return;
|
|
838
837
|
const newActive = !active;
|
|
839
838
|
setActive(newActive);
|
|
840
|
-
onActiveChange
|
|
839
|
+
onActiveChange?.(newActive);
|
|
841
840
|
};
|
|
842
841
|
const handleMenuClick = () => {
|
|
843
842
|
if (closeOnClick) {
|
|
844
843
|
setActive(false);
|
|
845
|
-
onActiveChange
|
|
844
|
+
onActiveChange?.(false);
|
|
846
845
|
}
|
|
847
846
|
};
|
|
848
847
|
const dropdownClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
|
|
@@ -963,14 +962,13 @@ const ModalClose = ({ className, size = 'large', variant = 'delete', ...props })
|
|
|
963
962
|
return (jsx("button", { className: classes, "aria-label": "close", type: "button", ...props }));
|
|
964
963
|
};
|
|
965
964
|
const ModalRoot = ({ active, isActive, onClose, className, textColor, bgColor, modalCardTitle, modalCardFoot, type, children, ...props }) => {
|
|
966
|
-
var _a;
|
|
967
965
|
const { classPrefix } = useConfig();
|
|
968
966
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
969
967
|
color: textColor,
|
|
970
968
|
backgroundColor: bgColor,
|
|
971
969
|
...props,
|
|
972
970
|
});
|
|
973
|
-
const isModalActive =
|
|
971
|
+
const isModalActive = active ?? isActive ?? false;
|
|
974
972
|
const hasCompoundComponents = React.Children.toArray(children).some(child => React.isValidElement(child) &&
|
|
975
973
|
(child.type === ModalBackground ||
|
|
976
974
|
child.type === ModalContent ||
|
|
@@ -1031,13 +1029,12 @@ const NavbarItem = ({ className, as: Component = 'a', active, textColor, bgColor
|
|
|
1031
1029
|
}), bulmaHelperClasses, className), ...rest, children: children }));
|
|
1032
1030
|
};
|
|
1033
1031
|
const NavbarBurger = ({ className, active, children, ...props }) => {
|
|
1034
|
-
var _a;
|
|
1035
1032
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
1036
1033
|
...props,
|
|
1037
1034
|
});
|
|
1038
1035
|
return (jsxs("button", { type: "button", className: classNames(usePrefixedClassNames('navbar-burger', {
|
|
1039
1036
|
'is-active': active,
|
|
1040
|
-
}), bulmaHelperClasses, className), "aria-label": props['aria-label'] || 'menu', "aria-expanded":
|
|
1037
|
+
}), bulmaHelperClasses, className), "aria-label": props['aria-label'] || 'menu', "aria-expanded": props['aria-expanded'] ?? !!active, ...rest, children: [jsx("span", { "aria-hidden": "true" }), jsx("span", { "aria-hidden": "true" }), jsx("span", { "aria-hidden": "true" }), children] }));
|
|
1041
1038
|
};
|
|
1042
1039
|
const NavbarMenu = ({ className, active, children, ...props }) => {
|
|
1043
1040
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
@@ -1159,9 +1156,9 @@ Pagination.Previous = PaginationPrevious;
|
|
|
1159
1156
|
Pagination.Next = PaginationNext;
|
|
1160
1157
|
|
|
1161
1158
|
function getIconClasses(library, name, variant, features) {
|
|
1162
|
-
let baseClass
|
|
1163
|
-
let iconClass
|
|
1164
|
-
|
|
1159
|
+
let baseClass;
|
|
1160
|
+
let iconClass;
|
|
1161
|
+
const featureList = Array.isArray(features)
|
|
1165
1162
|
? features
|
|
1166
1163
|
: features
|
|
1167
1164
|
? [features]
|
|
@@ -1351,7 +1348,7 @@ const Tabs = ({ align, size, fullwidth, boxed, toggle, rounded, color, value, on
|
|
|
1351
1348
|
if (!isControlled) {
|
|
1352
1349
|
setInternalTab(index);
|
|
1353
1350
|
}
|
|
1354
|
-
onChange
|
|
1351
|
+
onChange?.(index);
|
|
1355
1352
|
}, [isControlled, onChange]);
|
|
1356
1353
|
const contextValue = { activeTab, setActiveTab };
|
|
1357
1354
|
const tabsClasses = usePrefixedClassNames('tabs', {
|
|
@@ -1486,7 +1483,8 @@ const Collapse = ({ open: controlledOpen, defaultOpen = false, onOpen, onClose,
|
|
|
1486
1483
|
const isControlled = controlledOpen !== undefined;
|
|
1487
1484
|
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
1488
1485
|
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
1489
|
-
const
|
|
1486
|
+
const generatedId = useId();
|
|
1487
|
+
const uniqueId = ariaId || generatedId;
|
|
1490
1488
|
useEffect(() => {
|
|
1491
1489
|
if (!contentRef.current)
|
|
1492
1490
|
return undefined;
|
|
@@ -1520,10 +1518,10 @@ const Collapse = ({ open: controlledOpen, defaultOpen = false, onOpen, onClose,
|
|
|
1520
1518
|
const newOpen = !internalOpen;
|
|
1521
1519
|
setInternalOpen(newOpen);
|
|
1522
1520
|
if (newOpen) {
|
|
1523
|
-
onOpen
|
|
1521
|
+
onOpen?.();
|
|
1524
1522
|
}
|
|
1525
1523
|
else {
|
|
1526
|
-
onClose
|
|
1524
|
+
onClose?.();
|
|
1527
1525
|
}
|
|
1528
1526
|
}
|
|
1529
1527
|
}, [isControlled, internalOpen, onOpen, onClose]);
|
|
@@ -1563,8 +1561,8 @@ const Collapse = ({ open: controlledOpen, defaultOpen = false, onOpen, onClose,
|
|
|
1563
1561
|
display: isOpen ? 'block' : 'none',
|
|
1564
1562
|
};
|
|
1565
1563
|
}
|
|
1566
|
-
const triggerElement = (jsx("div", { className: combinedTriggerClasses, onClick: handleToggle, onKeyDown: handleKeyDown, role: "button", tabIndex: 0, "aria-expanded": isOpen, "aria-controls": uniqueId
|
|
1567
|
-
const contentElement = (jsx("div", { style: contentWrapperStyle, children: jsx("div", { ref: contentRef, id: uniqueId
|
|
1564
|
+
const triggerElement = (jsx("div", { className: combinedTriggerClasses, onClick: handleToggle, onKeyDown: handleKeyDown, role: "button", tabIndex: 0, "aria-expanded": isOpen, "aria-controls": uniqueId, children: trigger }));
|
|
1565
|
+
const contentElement = (jsx("div", { style: contentWrapperStyle, children: jsx("div", { ref: contentRef, id: uniqueId, className: combinedContentClasses, "aria-hidden": !isOpen, children: children }) }));
|
|
1568
1566
|
return (jsx("div", { className: combinedClasses, ...rest, children: position === 'bottom' ? (jsxs(Fragment, { children: [contentElement, triggerElement] })) : (jsxs(Fragment, { children: [triggerElement, contentElement] })) }));
|
|
1569
1567
|
};
|
|
1570
1568
|
|
|
@@ -1742,7 +1740,7 @@ const Step = ({ isActive = false, isCompleted = false, label, icon, clickable =
|
|
|
1742
1740
|
const markerContent = icon ||
|
|
1743
1741
|
(isCompleted && resolvedCompletedIcon
|
|
1744
1742
|
? resolvedCompletedIcon
|
|
1745
|
-
: (stepNumber
|
|
1743
|
+
: (stepNumber ?? null));
|
|
1746
1744
|
return (jsx("li", { className: stepClasses, onClick: handleClick, onKeyDown: handleKeyDown, tabIndex: clickable ? 0 : undefined, role: clickable ? 'button' : undefined, "aria-current": isActive ? 'step' : undefined, ...rest, children: jsxs("div", { className: "steps-link", children: [jsx("span", { className: "steps-marker", children: markerContent }), (label || children) && (jsx("div", { className: "steps-content", children: jsx("p", { className: "steps-title", children: label || children }) }))] }) }));
|
|
1747
1745
|
};
|
|
1748
1746
|
const Steps = ({ value = 0, items, size, color, hasMarker = true, animated = true, rounded = true, vertical = false, labelPosition = 'bottom', mobileMode, showStepNumbers = true, hasNavigation = false, prevLabel, nextLabel, onPrev, onNext, onStepClick, className, children, ...props }) => {
|
|
@@ -1783,7 +1781,7 @@ const Steps = ({ value = 0, items, size, color, hasMarker = true, animated = tru
|
|
|
1783
1781
|
}
|
|
1784
1782
|
return null;
|
|
1785
1783
|
};
|
|
1786
|
-
return (jsxs("div", { className: combinedClasses, ...rest, children: [jsx("ul", { className: listClasses, children: renderSteps() }), hasNavigation && (jsxs("div", { className: "steps-navigation", children: [jsx("button", { className: "button", disabled: value === 0, onClick: onPrev
|
|
1784
|
+
return (jsxs("div", { className: combinedClasses, ...rest, children: [jsx("ul", { className: listClasses, children: renderSteps() }), hasNavigation && (jsxs("div", { className: "steps-navigation", children: [jsx("button", { className: "button", disabled: value === 0, onClick: onPrev ?? (() => onStepClick?.(value - 1)), children: prevLabel ?? 'Previous' }), jsx("button", { className: "button is-primary", disabled: value === totalSteps - 1, onClick: onNext ?? (() => onStepClick?.(value + 1)), children: nextLabel ?? 'Next' })] }))] }));
|
|
1787
1785
|
};
|
|
1788
1786
|
Steps.Step = Step;
|
|
1789
1787
|
|
|
@@ -1904,10 +1902,10 @@ const Toast = forwardRef(({ message, type = 'default', actionType, position = 't
|
|
|
1904
1902
|
const toastRef = useRef(null);
|
|
1905
1903
|
const handleClose = useCallback(() => {
|
|
1906
1904
|
setIsVisible(false);
|
|
1907
|
-
onClose
|
|
1905
|
+
onClose?.();
|
|
1908
1906
|
}, [onClose]);
|
|
1909
1907
|
const handleAction = useCallback(() => {
|
|
1910
|
-
onAction
|
|
1908
|
+
onAction?.();
|
|
1911
1909
|
handleClose();
|
|
1912
1910
|
}, [onAction, handleClose]);
|
|
1913
1911
|
useEffect(() => {
|
|
@@ -2094,11 +2092,11 @@ const Dialog = forwardRef(({ isOpen, title, message, type = 'default', confirmTe
|
|
|
2094
2092
|
const cancelRef = useRef(null);
|
|
2095
2093
|
const handleCancel = useCallback(() => {
|
|
2096
2094
|
if (canCancel) {
|
|
2097
|
-
onCancel
|
|
2095
|
+
onCancel?.();
|
|
2098
2096
|
}
|
|
2099
2097
|
}, [canCancel, onCancel]);
|
|
2100
2098
|
const handleConfirm = useCallback(() => {
|
|
2101
|
-
onConfirm
|
|
2099
|
+
onConfirm?.();
|
|
2102
2100
|
}, [onConfirm]);
|
|
2103
2101
|
const handleBackgroundClick = useCallback(() => {
|
|
2104
2102
|
if (canCancel) {
|
|
@@ -2119,7 +2117,7 @@ const Dialog = forwardRef(({ isOpen, title, message, type = 'default', confirmTe
|
|
|
2119
2117
|
useEffect(() => {
|
|
2120
2118
|
if (isOpen) {
|
|
2121
2119
|
const buttonToFocus = focusCancel && showCancel ? cancelRef.current : confirmRef.current;
|
|
2122
|
-
buttonToFocus
|
|
2120
|
+
buttonToFocus?.focus();
|
|
2123
2121
|
}
|
|
2124
2122
|
}, [isOpen, focusCancel, showCancel]);
|
|
2125
2123
|
useEffect(() => {
|
|
@@ -2319,7 +2317,7 @@ const Carousel = forwardRef(({ value: controlledValue, autoplay = false, interva
|
|
|
2319
2317
|
if (syncDisplay) {
|
|
2320
2318
|
setDisplayIndex(newIndex);
|
|
2321
2319
|
}
|
|
2322
|
-
onChange
|
|
2320
|
+
onChange?.(newIndex);
|
|
2323
2321
|
}, [controlledValue, itemCount, repeat, onChange]);
|
|
2324
2322
|
const goToPrev = useCallback(() => {
|
|
2325
2323
|
if (activeIndex === 0 && repeat && itemCount > 1) {
|
|
@@ -2407,8 +2405,7 @@ const Carousel = forwardRef(({ value: controlledValue, autoplay = false, interva
|
|
|
2407
2405
|
}, [handleDragEnd]);
|
|
2408
2406
|
useEffect(() => {
|
|
2409
2407
|
const handleKeyDown = (e) => {
|
|
2410
|
-
|
|
2411
|
-
if (!((_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)))
|
|
2408
|
+
if (!carouselRef.current?.contains(document.activeElement))
|
|
2412
2409
|
return;
|
|
2413
2410
|
switch (e.key) {
|
|
2414
2411
|
case 'ArrowLeft':
|
|
@@ -3114,17 +3111,16 @@ const Checkbox = forwardRef(({ color, size, className, children, textColor, disa
|
|
|
3114
3111
|
...props,
|
|
3115
3112
|
});
|
|
3116
3113
|
const group = useCheckboxesGroup();
|
|
3117
|
-
const effectiveName = name
|
|
3118
|
-
const groupManaged =
|
|
3114
|
+
const effectiveName = name ?? group?.name;
|
|
3115
|
+
const groupManaged = group?.value !== undefined && value !== undefined;
|
|
3119
3116
|
const groupHas = groupManaged && group.value.includes(String(value));
|
|
3120
3117
|
const effectiveChecked = checked !== undefined ? checked : groupManaged ? groupHas : undefined;
|
|
3121
3118
|
const effectiveDefaultChecked = groupManaged ? undefined : defaultChecked;
|
|
3122
3119
|
const handleChange = useCallback((e) => {
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
if ((group === null || group === void 0 ? void 0 : group.onChange) && value !== undefined) {
|
|
3120
|
+
onChange?.(e);
|
|
3121
|
+
if (group?.onChange && value !== undefined) {
|
|
3126
3122
|
const valStr = String(value);
|
|
3127
|
-
const currentArr =
|
|
3123
|
+
const currentArr = group.value ?? [];
|
|
3128
3124
|
const next = e.target.checked
|
|
3129
3125
|
? currentArr.includes(valStr)
|
|
3130
3126
|
? currentArr
|
|
@@ -3185,29 +3181,23 @@ const Field = ({ horizontal, grouped, hasAddons, narrow, label, labelSize, label
|
|
|
3185
3181
|
'is-grouped-multiline': grouped === 'multiline',
|
|
3186
3182
|
});
|
|
3187
3183
|
const fieldClass = classNames(mainClass, bulmaHelperClasses, className);
|
|
3188
|
-
const effectiveLabelSize = labelSize
|
|
3184
|
+
const effectiveLabelSize = labelSize ?? (horizontal ? 'normal' : undefined);
|
|
3189
3185
|
const labelClass = usePrefixedClassNames('label');
|
|
3190
3186
|
let renderedLabel = null;
|
|
3191
3187
|
if (label) {
|
|
3192
3188
|
if (horizontal) {
|
|
3193
|
-
renderedLabel = (jsx(FieldLabel, { size: effectiveLabelSize, children: jsx("label", { ...labelProps, className: classNames(labelClass, labelProps
|
|
3189
|
+
renderedLabel = (jsx(FieldLabel, { size: effectiveLabelSize, children: jsx("label", { ...labelProps, className: classNames(labelClass, labelProps?.className), style: labelProps?.style, children: label }) }));
|
|
3194
3190
|
}
|
|
3195
3191
|
else {
|
|
3196
|
-
renderedLabel = (jsx("label", { ...labelProps, className: classNames(labelClass, labelProps
|
|
3192
|
+
renderedLabel = (jsx("label", { ...labelProps, className: classNames(labelClass, labelProps?.className), style: { display: 'block', ...(labelProps?.style || {}) }, children: label }));
|
|
3197
3193
|
}
|
|
3198
3194
|
}
|
|
3199
3195
|
let content = children;
|
|
3200
3196
|
if (horizontal) {
|
|
3201
|
-
const isFieldBody = (c) =>
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
};
|
|
3206
|
-
const isFieldLabel = (c) => {
|
|
3207
|
-
var _a;
|
|
3208
|
-
return React.isValidElement(c) &&
|
|
3209
|
-
(c.type === FieldLabel || ((_a = c.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'FieldLabel');
|
|
3210
|
-
};
|
|
3197
|
+
const isFieldBody = (c) => React.isValidElement(c) &&
|
|
3198
|
+
(c.type === FieldBody || c.type?.displayName === 'FieldBody');
|
|
3199
|
+
const isFieldLabel = (c) => React.isValidElement(c) &&
|
|
3200
|
+
(c.type === FieldLabel || c.type?.displayName === 'FieldLabel');
|
|
3211
3201
|
const childArray = React.Children.toArray(children);
|
|
3212
3202
|
const userProvidedStructure = childArray.some(c => isFieldBody(c) || isFieldLabel(c));
|
|
3213
3203
|
if (userProvidedStructure) {
|
|
@@ -3285,7 +3275,7 @@ const Checkboxes = ({ label, labelSize, labelProps, horizontal, message, message
|
|
|
3285
3275
|
const handleChange = useCallback((newValues) => {
|
|
3286
3276
|
if (!isControlled)
|
|
3287
3277
|
setInternalValue(newValues);
|
|
3288
|
-
onChange
|
|
3278
|
+
onChange?.(newValues);
|
|
3289
3279
|
}, [isControlled, onChange]);
|
|
3290
3280
|
const ctx = useMemo(() => ({
|
|
3291
3281
|
name,
|
|
@@ -3354,8 +3344,8 @@ const Radio = forwardRef(({ color, size, className, children, textColor, disable
|
|
|
3354
3344
|
...props,
|
|
3355
3345
|
});
|
|
3356
3346
|
const group = useRadiosGroup();
|
|
3357
|
-
const effectiveName = name
|
|
3358
|
-
const groupManaged =
|
|
3347
|
+
const effectiveName = name ?? group?.name;
|
|
3348
|
+
const groupManaged = group?.value !== undefined && value !== undefined;
|
|
3359
3349
|
const effectiveChecked = checked !== undefined
|
|
3360
3350
|
? checked
|
|
3361
3351
|
: groupManaged
|
|
@@ -3363,8 +3353,8 @@ const Radio = forwardRef(({ color, size, className, children, textColor, disable
|
|
|
3363
3353
|
: undefined;
|
|
3364
3354
|
const effectiveDefaultChecked = groupManaged ? undefined : defaultChecked;
|
|
3365
3355
|
const handleChange = useCallback((e) => {
|
|
3366
|
-
onChange
|
|
3367
|
-
if (
|
|
3356
|
+
onChange?.(e);
|
|
3357
|
+
if (group?.onChange && value !== undefined) {
|
|
3368
3358
|
group.onChange(String(value));
|
|
3369
3359
|
}
|
|
3370
3360
|
}, [onChange, group, value]);
|
|
@@ -3396,7 +3386,7 @@ const Radios = ({ label, labelSize, labelProps, horizontal, message, messageColo
|
|
|
3396
3386
|
const handleChange = useCallback((newValue) => {
|
|
3397
3387
|
if (!isControlled)
|
|
3398
3388
|
setInternalValue(newValue);
|
|
3399
|
-
onChange
|
|
3389
|
+
onChange?.(newValue);
|
|
3400
3390
|
}, [isControlled, onChange]);
|
|
3401
3391
|
const ctx = useMemo(() => ({
|
|
3402
3392
|
name,
|
|
@@ -3462,7 +3452,6 @@ function getTickPositions(min, max, step, ticks, marks) {
|
|
|
3462
3452
|
return positions;
|
|
3463
3453
|
}
|
|
3464
3454
|
const Slider = forwardRef((props, ref) => {
|
|
3465
|
-
var _a, _b, _c;
|
|
3466
3455
|
let range;
|
|
3467
3456
|
let controlledValue;
|
|
3468
3457
|
let defaultValue;
|
|
@@ -3477,7 +3466,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
3477
3466
|
defaultValue = props.defaultValue;
|
|
3478
3467
|
onChange = props.onChange;
|
|
3479
3468
|
ariaLabel = props.ariaLabel;
|
|
3480
|
-
minDistance =
|
|
3469
|
+
minDistance = props.minDistance ?? 0;
|
|
3481
3470
|
nameLow = props.nameLow;
|
|
3482
3471
|
nameHigh = props.nameHigh;
|
|
3483
3472
|
}
|
|
@@ -3492,9 +3481,9 @@ const Slider = forwardRef((props, ref) => {
|
|
|
3492
3481
|
const insideField = useInsideField();
|
|
3493
3482
|
const insideControl = useInsideControl();
|
|
3494
3483
|
const { bulmaHelperClasses, rest } = useBulmaClasses(restProps);
|
|
3495
|
-
const tooltipMode = tooltip
|
|
3496
|
-
const [internalRange, setInternalRange] = useState(() =>
|
|
3497
|
-
const [internalSingle, setInternalSingle] = useState(() =>
|
|
3484
|
+
const tooltipMode = tooltip ?? (showOutput ? 'auto' : 'hidden');
|
|
3485
|
+
const [internalRange, setInternalRange] = useState(() => range ? (defaultValue ?? [min, max]) : [min, min]);
|
|
3486
|
+
const [internalSingle, setInternalSingle] = useState(() => !range ? (defaultValue ?? 0) : 0);
|
|
3498
3487
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
3499
3488
|
const [showTooltipHigh, setShowTooltipHigh] = useState(false);
|
|
3500
3489
|
const inputRef = useRef(null);
|
|
@@ -3536,7 +3525,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
3536
3525
|
const newValue = parseFloat(e.target.value);
|
|
3537
3526
|
if (!isControlled)
|
|
3538
3527
|
setInternalSingle(newValue);
|
|
3539
|
-
onChange
|
|
3528
|
+
onChange?.(newValue);
|
|
3540
3529
|
}, [isControlled, onChange]);
|
|
3541
3530
|
const handleRangeLowChange = useCallback((e) => {
|
|
3542
3531
|
const raw = parseFloat(e.target.value);
|
|
@@ -3544,7 +3533,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
3544
3533
|
const newRange = [clamped, currentRange[1]];
|
|
3545
3534
|
if (!isControlled)
|
|
3546
3535
|
setInternalRange(newRange);
|
|
3547
|
-
onChange
|
|
3536
|
+
onChange?.(newRange);
|
|
3548
3537
|
}, [isControlled, onChange, currentRange, minDistance]);
|
|
3549
3538
|
const handleRangeHighChange = useCallback((e) => {
|
|
3550
3539
|
const raw = parseFloat(e.target.value);
|
|
@@ -3552,7 +3541,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
3552
3541
|
const newRange = [currentRange[0], clamped];
|
|
3553
3542
|
if (!isControlled)
|
|
3554
3543
|
setInternalRange(newRange);
|
|
3555
|
-
onChange
|
|
3544
|
+
onChange?.(newRange);
|
|
3556
3545
|
}, [isControlled, onChange, currentRange, minDistance]);
|
|
3557
3546
|
const handleKeyDown = useCallback((e) => {
|
|
3558
3547
|
if (e.key === 'Home') {
|
|
@@ -3560,7 +3549,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
3560
3549
|
if (!range) {
|
|
3561
3550
|
if (!isControlled)
|
|
3562
3551
|
setInternalSingle(min);
|
|
3563
|
-
onChange
|
|
3552
|
+
onChange?.(min);
|
|
3564
3553
|
}
|
|
3565
3554
|
}
|
|
3566
3555
|
else if (e.key === 'End') {
|
|
@@ -3568,7 +3557,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
3568
3557
|
if (!range) {
|
|
3569
3558
|
if (!isControlled)
|
|
3570
3559
|
setInternalSingle(max);
|
|
3571
|
-
onChange
|
|
3560
|
+
onChange?.(max);
|
|
3572
3561
|
}
|
|
3573
3562
|
}
|
|
3574
3563
|
}, [range, isControlled, onChange, min, max]);
|
|
@@ -3755,7 +3744,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
3755
3744
|
: {
|
|
3756
3745
|
'--slider-progress-low': `${progressLow}%`,
|
|
3757
3746
|
'--slider-progress-high': `${progressHigh}%`,
|
|
3758
|
-
} }), jsx("input", { ref: combinedRef, type: "range", min: min, max: max, step: step, value: currentRange[0], disabled: disabled, onChange: handleRangeLowChange, onKeyDown: handleKeyDown, onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => setShowTooltip(true), onBlur: () => setShowTooltip(false), className: "slider-input slider-input-low", "aria-valuenow": currentRange[0], "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label":
|
|
3747
|
+
} }), jsx("input", { ref: combinedRef, type: "range", min: min, max: max, step: step, value: currentRange[0], disabled: disabled, onChange: handleRangeLowChange, onKeyDown: handleKeyDown, onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => setShowTooltip(true), onBlur: () => setShowTooltip(false), className: "slider-input slider-input-low", "aria-valuenow": currentRange[0], "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel?.[0] ?? 'Minimum value', ...getAriaProps(currentRange[0]), ...rest, ...(nameLow !== undefined ? { name: nameLow } : {}) }), jsx("input", { ref: inputHighRef, type: "range", min: min, max: max, step: step, value: currentRange[1], disabled: disabled, onChange: handleRangeHighChange, onMouseEnter: () => setShowTooltipHigh(true), onMouseLeave: () => setShowTooltipHigh(false), onFocus: () => setShowTooltipHigh(true), onBlur: () => setShowTooltipHigh(false), className: "slider-input slider-input-high", "aria-valuenow": currentRange[1], "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel?.[1] ?? 'Maximum value', ...getAriaProps(currentRange[1]), name: nameHigh }), tooltipMode !== 'hidden' && (jsx("output", { ref: outputRef, className: classNames('slider-output slider-output-low', {
|
|
3759
3748
|
'is-visible': showTipLow,
|
|
3760
3749
|
'is-flipped': flipped,
|
|
3761
3750
|
'is-flipped-left': isVertical && verticalFlippedLeft,
|
|
@@ -3811,7 +3800,7 @@ const ArrowDropUp = () => (jsx("svg", { viewBox: "0 0 24 24", fill: "none", stro
|
|
|
3811
3800
|
const ArrowDropDown = () => (jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: jsx("path", { d: "M7 9.5l5 5 5-5" }) }));
|
|
3812
3801
|
const Numberinput = forwardRef(({ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, value: controlledValue, defaultValue, min, max, step = 1, size, color, inputColor, controlsPosition = 'both', controlsRounded = false, compact = false, bare, variant = 'plusminus', disabled = false, editable = true, isLoading = false, exponential = false, onChange, className, ...props }, ref) => {
|
|
3813
3802
|
const insideField = useInsideField();
|
|
3814
|
-
const effectiveBare = bare
|
|
3803
|
+
const effectiveBare = bare ?? insideField;
|
|
3815
3804
|
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
3816
3805
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
3817
3806
|
const inputRef = useRef(null);
|
|
@@ -3833,18 +3822,18 @@ const Numberinput = forwardRef(({ label, labelSize, labelProps, horizontal, mess
|
|
|
3833
3822
|
if (!isControlled) {
|
|
3834
3823
|
setInternalValue(clampedValue);
|
|
3835
3824
|
}
|
|
3836
|
-
onChange
|
|
3825
|
+
onChange?.(clampedValue);
|
|
3837
3826
|
}, [isControlled, clampValue, onChange]);
|
|
3838
3827
|
const getEffectiveStep = useCallback(() => {
|
|
3839
3828
|
if (!exponential)
|
|
3840
3829
|
return step;
|
|
3841
|
-
return step * Math.max(1, Math.floor(Math.abs(currentValue
|
|
3830
|
+
return step * Math.max(1, Math.floor(Math.abs(currentValue ?? 0)));
|
|
3842
3831
|
}, [exponential, step, currentValue]);
|
|
3843
3832
|
const handleIncrement = useCallback(() => {
|
|
3844
|
-
updateValue((currentValue
|
|
3833
|
+
updateValue((currentValue ?? 0) + getEffectiveStep());
|
|
3845
3834
|
}, [currentValue, getEffectiveStep, updateValue]);
|
|
3846
3835
|
const handleDecrement = useCallback(() => {
|
|
3847
|
-
updateValue((currentValue
|
|
3836
|
+
updateValue((currentValue ?? 0) - getEffectiveStep());
|
|
3848
3837
|
}, [currentValue, getEffectiveStep, updateValue]);
|
|
3849
3838
|
const handleInputChange = useCallback((e) => {
|
|
3850
3839
|
const newValue = parseFloat(e.target.value);
|
|
@@ -3907,7 +3896,7 @@ const Numberinput = forwardRef(({ label, labelSize, labelProps, horizontal, mess
|
|
|
3907
3896
|
ref.current = node;
|
|
3908
3897
|
}
|
|
3909
3898
|
};
|
|
3910
|
-
const inputControl = (jsx("div", { className: expandedControlClasses, children: jsx("input", { ref: combinedRef, type: "number", className: inputClasses, value: currentValue
|
|
3899
|
+
const inputControl = (jsx("div", { className: expandedControlClasses, children: jsx("input", { ref: combinedRef, type: "number", className: inputClasses, value: currentValue ?? '', min: min, max: max, step: step, disabled: disabled, readOnly: !editable, onChange: handleInputChange, onKeyDown: handleKeyDown, "aria-valuenow": currentValue ?? undefined, "aria-valuemin": min, "aria-valuemax": max, ...rest }) }));
|
|
3911
3900
|
if (isStepper) {
|
|
3912
3901
|
const stepperElement = (jsxs("div", { className: combinedClasses, children: [inputControl, jsx("div", { className: controlClasses, children: jsxs("div", { className: stepperClasses, children: [jsx("button", { type: "button", className: stepperButtonClasses, onClick: handleIncrement, disabled: disabled || isAtMax, tabIndex: -1, "aria-label": "Increase value", children: jsx(ArrowDropUp, {}) }), jsx("button", { type: "button", className: stepperButtonClasses, onClick: handleDecrement, disabled: disabled || isAtMin, tabIndex: -1, "aria-label": "Decrease value", children: jsx(ArrowDropDown, {}) })] }) })] }));
|
|
3913
3902
|
if (!insideField) {
|
|
@@ -3975,7 +3964,7 @@ const Rate = forwardRef(({ label, labelSize, labelProps, horizontal, message, me
|
|
|
3975
3964
|
if (!isControlled) {
|
|
3976
3965
|
setInternalValue(finalValue);
|
|
3977
3966
|
}
|
|
3978
|
-
onChange
|
|
3967
|
+
onChange?.(finalValue);
|
|
3979
3968
|
}, [isControlled, currentValue, disabled, onChange]);
|
|
3980
3969
|
const handleClick = useCallback((iconIndex, e) => {
|
|
3981
3970
|
if (disabled)
|
|
@@ -4040,7 +4029,7 @@ const Rate = forwardRef(({ label, labelSize, labelProps, horizontal, message, me
|
|
|
4040
4029
|
if (!isControlled) {
|
|
4041
4030
|
setInternalValue(newValue);
|
|
4042
4031
|
}
|
|
4043
|
-
onChange
|
|
4032
|
+
onChange?.(newValue);
|
|
4044
4033
|
}
|
|
4045
4034
|
}, [currentValue, max, precision, disabled, isControlled, onChange]);
|
|
4046
4035
|
const getText = () => {
|
|
@@ -4090,7 +4079,7 @@ const Rate = forwardRef(({ label, labelSize, labelProps, horizontal, message, me
|
|
|
4090
4079
|
const iconProps = {
|
|
4091
4080
|
index: iconIndex,
|
|
4092
4081
|
isActive: fillPercent > 0,
|
|
4093
|
-
isHovered: hoverValue !== null && iconIndex < (hoverValue
|
|
4082
|
+
isHovered: hoverValue !== null && iconIndex < (hoverValue ?? 0),
|
|
4094
4083
|
value: displayValue,
|
|
4095
4084
|
fillPercent,
|
|
4096
4085
|
};
|
|
@@ -4173,7 +4162,7 @@ const Autocomplete = forwardRef(({ data = [], value: controlledValue, placeholde
|
|
|
4173
4162
|
if (controlledValue === undefined) {
|
|
4174
4163
|
setInternalValue(newValue);
|
|
4175
4164
|
}
|
|
4176
|
-
onInput
|
|
4165
|
+
onInput?.(newValue);
|
|
4177
4166
|
if (!isActive && newValue) {
|
|
4178
4167
|
setIsActive(true);
|
|
4179
4168
|
}
|
|
@@ -4185,21 +4174,20 @@ const Autocomplete = forwardRef(({ data = [], value: controlledValue, placeholde
|
|
|
4185
4174
|
if (controlledValue === undefined) {
|
|
4186
4175
|
setInternalValue(displayValue);
|
|
4187
4176
|
}
|
|
4188
|
-
onInput
|
|
4189
|
-
onSelect
|
|
4177
|
+
onInput?.(displayValue);
|
|
4178
|
+
onSelect?.(item);
|
|
4190
4179
|
if (!keepOpen) {
|
|
4191
4180
|
setIsActive(false);
|
|
4192
4181
|
}
|
|
4193
4182
|
setHighlightedIndex(-1);
|
|
4194
4183
|
}, [controlledValue, field, keepOpen, onInput, onSelect]);
|
|
4195
4184
|
const handleClear = useCallback(() => {
|
|
4196
|
-
var _a;
|
|
4197
4185
|
if (controlledValue === undefined) {
|
|
4198
4186
|
setInternalValue('');
|
|
4199
4187
|
}
|
|
4200
|
-
onInput
|
|
4201
|
-
onSelect
|
|
4202
|
-
|
|
4188
|
+
onInput?.('');
|
|
4189
|
+
onSelect?.(null);
|
|
4190
|
+
inputRef.current?.focus();
|
|
4203
4191
|
}, [controlledValue, onInput, onSelect]);
|
|
4204
4192
|
const handleFocus = useCallback(() => {
|
|
4205
4193
|
if (openOnFocus && !disabled) {
|
|
@@ -4231,7 +4219,7 @@ const Autocomplete = forwardRef(({ data = [], value: controlledValue, placeholde
|
|
|
4231
4219
|
handleSelect,
|
|
4232
4220
|
]);
|
|
4233
4221
|
useEffect(() => {
|
|
4234
|
-
onActiveChange
|
|
4222
|
+
onActiveChange?.(isActive);
|
|
4235
4223
|
}, [isActive, onActiveChange]);
|
|
4236
4224
|
useEffect(() => {
|
|
4237
4225
|
if (keepFirst && isActive && filteredData.length > 0) {
|
|
@@ -4279,7 +4267,7 @@ const Autocomplete = forwardRef(({ data = [], value: controlledValue, placeholde
|
|
|
4279
4267
|
return;
|
|
4280
4268
|
const { scrollTop, scrollHeight, clientHeight } = dropdownRef.current;
|
|
4281
4269
|
if (scrollHeight - scrollTop - clientHeight <= infiniteScrollDistance) {
|
|
4282
|
-
onInfiniteScroll
|
|
4270
|
+
onInfiniteScroll?.();
|
|
4283
4271
|
}
|
|
4284
4272
|
}, [checkInfiniteScroll, infiniteScrollDistance, onInfiniteScroll]);
|
|
4285
4273
|
useEffect(() => {
|
|
@@ -4385,7 +4373,7 @@ const Taginput = forwardRef(({ label, labelSize, labelProps, horizontal, message
|
|
|
4385
4373
|
if (controlledValue === undefined) {
|
|
4386
4374
|
setInternalTags(newTags);
|
|
4387
4375
|
}
|
|
4388
|
-
onChange
|
|
4376
|
+
onChange?.(newTags);
|
|
4389
4377
|
}, [controlledValue, onChange]);
|
|
4390
4378
|
const addTag = useCallback((value) => {
|
|
4391
4379
|
if (disabled || readonly)
|
|
@@ -4409,7 +4397,7 @@ const Taginput = forwardRef(({ label, labelSize, labelProps, horizontal, message
|
|
|
4409
4397
|
const finalTag = createTag ? createTag(displayValue) : tagValue;
|
|
4410
4398
|
const newTags = [...tags, finalTag];
|
|
4411
4399
|
updateTags(newTags);
|
|
4412
|
-
onAdd
|
|
4400
|
+
onAdd?.(finalTag);
|
|
4413
4401
|
setInputValue('');
|
|
4414
4402
|
if (!keepOpen) {
|
|
4415
4403
|
setIsActive(false);
|
|
@@ -4436,7 +4424,7 @@ const Taginput = forwardRef(({ label, labelSize, labelProps, horizontal, message
|
|
|
4436
4424
|
const removedTag = tags[index];
|
|
4437
4425
|
const newTags = tags.filter((_, i) => i !== index);
|
|
4438
4426
|
updateTags(newTags);
|
|
4439
|
-
onRemove
|
|
4427
|
+
onRemove?.(removedTag, index);
|
|
4440
4428
|
}, [disabled, readonly, tags, updateTags, onRemove]);
|
|
4441
4429
|
const handleInputChange = useCallback((e) => {
|
|
4442
4430
|
const newValue = e.target.value;
|
|
@@ -4449,7 +4437,7 @@ const Taginput = forwardRef(({ label, labelSize, labelProps, horizontal, message
|
|
|
4449
4437
|
return;
|
|
4450
4438
|
}
|
|
4451
4439
|
setInputValue(newValue);
|
|
4452
|
-
onTyping
|
|
4440
|
+
onTyping?.(newValue);
|
|
4453
4441
|
if (newValue && data.length > 0) {
|
|
4454
4442
|
setIsActive(true);
|
|
4455
4443
|
}
|
|
@@ -4554,8 +4542,7 @@ const Taginput = forwardRef(({ label, labelSize, labelProps, horizontal, message
|
|
|
4554
4542
|
}
|
|
4555
4543
|
}, [ref]);
|
|
4556
4544
|
const handleContainerClick = useCallback(() => {
|
|
4557
|
-
|
|
4558
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
4545
|
+
inputRef.current?.focus();
|
|
4559
4546
|
}, []);
|
|
4560
4547
|
const taginputClasses = pcn('taginput', {
|
|
4561
4548
|
'is-active': isActive,
|
|
@@ -4763,7 +4750,7 @@ const DEFAULT_PICKER_LABELS = {
|
|
|
4763
4750
|
};
|
|
4764
4751
|
const mergeLabels = (overrides) => ({
|
|
4765
4752
|
...DEFAULT_PICKER_LABELS,
|
|
4766
|
-
...(overrides
|
|
4753
|
+
...(overrides ?? {}),
|
|
4767
4754
|
});
|
|
4768
4755
|
|
|
4769
4756
|
const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
|
|
@@ -4821,19 +4808,19 @@ function formatWithIntl(d, options, locale) {
|
|
|
4821
4808
|
return new Intl.DateTimeFormat(locale, options).format(d);
|
|
4822
4809
|
}
|
|
4823
4810
|
function formatDate(d, fmt, locale) {
|
|
4824
|
-
const f = fmt
|
|
4811
|
+
const f = fmt ?? DEFAULT_DATE_FORMAT;
|
|
4825
4812
|
if (typeof f === 'string')
|
|
4826
4813
|
return formatTokenString(d, f);
|
|
4827
4814
|
return formatWithIntl(d, f, locale);
|
|
4828
4815
|
}
|
|
4829
4816
|
function formatTime(d, fmt, locale) {
|
|
4830
|
-
const f = fmt
|
|
4817
|
+
const f = fmt ?? DEFAULT_TIME_FORMAT_24;
|
|
4831
4818
|
if (typeof f === 'string')
|
|
4832
4819
|
return formatTokenString(d, f);
|
|
4833
4820
|
return formatWithIntl(d, f, locale);
|
|
4834
4821
|
}
|
|
4835
4822
|
function formatDateTime(d, fmt, locale) {
|
|
4836
|
-
const f = fmt
|
|
4823
|
+
const f = fmt ?? DEFAULT_DATETIME_FORMAT;
|
|
4837
4824
|
if (typeof f === 'string')
|
|
4838
4825
|
return formatTokenString(d, f);
|
|
4839
4826
|
return formatWithIntl(d, f, locale);
|
|
@@ -4850,19 +4837,18 @@ function hourCycleFromFormat(fmt) {
|
|
|
4850
4837
|
return null;
|
|
4851
4838
|
}
|
|
4852
4839
|
function parseDate(s, fmt, _locale) {
|
|
4853
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4854
4840
|
if (!s)
|
|
4855
4841
|
return null;
|
|
4856
|
-
const format = fmt
|
|
4842
|
+
const format = fmt ?? DEFAULT_DATE_FORMAT;
|
|
4857
4843
|
const parts = parseTokens(s, format);
|
|
4858
4844
|
if (!parts)
|
|
4859
4845
|
return null;
|
|
4860
|
-
const year =
|
|
4861
|
-
const month = (
|
|
4862
|
-
const day =
|
|
4863
|
-
const hours =
|
|
4864
|
-
const minutes =
|
|
4865
|
-
const seconds =
|
|
4846
|
+
const year = parts.year ?? new Date().getFullYear();
|
|
4847
|
+
const month = (parts.month ?? 1) - 1;
|
|
4848
|
+
const day = parts.day ?? 1;
|
|
4849
|
+
const hours = parts.hours ?? 0;
|
|
4850
|
+
const minutes = parts.minutes ?? 0;
|
|
4851
|
+
const seconds = parts.seconds ?? 0;
|
|
4866
4852
|
const d = new Date(year, month, day, hours, minutes, seconds, 0);
|
|
4867
4853
|
if (d.getFullYear() !== year ||
|
|
4868
4854
|
d.getMonth() !== month ||
|
|
@@ -4872,15 +4858,14 @@ function parseDate(s, fmt, _locale) {
|
|
|
4872
4858
|
return d;
|
|
4873
4859
|
}
|
|
4874
4860
|
function parseTime(s, fmt) {
|
|
4875
|
-
var _a, _b, _c;
|
|
4876
4861
|
if (!s)
|
|
4877
4862
|
return null;
|
|
4878
|
-
const format = fmt
|
|
4863
|
+
const format = fmt ?? DEFAULT_TIME_FORMAT_24;
|
|
4879
4864
|
const parts = parseTokens(s, format);
|
|
4880
4865
|
if (!parts)
|
|
4881
4866
|
return null;
|
|
4882
4867
|
const today = new Date();
|
|
4883
|
-
return new Date(today.getFullYear(), today.getMonth(), today.getDate(),
|
|
4868
|
+
return new Date(today.getFullYear(), today.getMonth(), today.getDate(), parts.hours ?? 0, parts.minutes ?? 0, parts.seconds ?? 0, 0);
|
|
4884
4869
|
}
|
|
4885
4870
|
function escapeRegExp(s) {
|
|
4886
4871
|
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
@@ -5154,9 +5139,9 @@ const Calendar = ({ value, focusedDate, onSelect, onFocusedDateChange, min, max,
|
|
|
5154
5139
|
const isDateUnselectable = useCallback((d) => {
|
|
5155
5140
|
if (!isWithin(d, min, max))
|
|
5156
5141
|
return true;
|
|
5157
|
-
if (shouldDisableDate
|
|
5142
|
+
if (shouldDisableDate?.(d))
|
|
5158
5143
|
return true;
|
|
5159
|
-
if (unselectableDates
|
|
5144
|
+
if (unselectableDates?.some(u => isSameDay(u, d)))
|
|
5160
5145
|
return true;
|
|
5161
5146
|
return false;
|
|
5162
5147
|
}, [min, max, shouldDisableDate, unselectableDates]);
|
|
@@ -5253,7 +5238,7 @@ const Calendar = ({ value, focusedDate, onSelect, onFocusedDateChange, min, max,
|
|
|
5253
5238
|
const focusedYear = focusedDate.getFullYear();
|
|
5254
5239
|
const minYear = min ? min.getFullYear() : focusedYear - 100;
|
|
5255
5240
|
const maxYear = max ? max.getFullYear() : focusedYear + 100;
|
|
5256
|
-
const [lo, hi] = yearsRange
|
|
5241
|
+
const [lo, hi] = yearsRange ?? [minYear, maxYear];
|
|
5257
5242
|
const start = Math.max(lo, minYear);
|
|
5258
5243
|
const end = Math.min(hi, maxYear);
|
|
5259
5244
|
const out = [];
|
|
@@ -5273,14 +5258,14 @@ const Calendar = ({ value, focusedDate, onSelect, onFocusedDateChange, min, max,
|
|
|
5273
5258
|
if (!autoFocusCell || !gridRef.current)
|
|
5274
5259
|
return;
|
|
5275
5260
|
const target = gridRef.current.querySelector('[data-focused="true"]');
|
|
5276
|
-
target
|
|
5261
|
+
target?.focus();
|
|
5277
5262
|
}, [autoFocusCell, focusedDate, view]);
|
|
5278
5263
|
useEffect(() => {
|
|
5279
5264
|
if (view !== 'years' || !yearGridRef.current)
|
|
5280
5265
|
return;
|
|
5281
5266
|
const sel = yearGridRef.current.querySelector('[data-focused-year="true"]');
|
|
5282
|
-
sel
|
|
5283
|
-
sel
|
|
5267
|
+
sel?.scrollIntoView({ block: 'center' });
|
|
5268
|
+
sel?.focus();
|
|
5284
5269
|
}, [view]);
|
|
5285
5270
|
const focusedYear = focusedDate.getFullYear();
|
|
5286
5271
|
const todayYear = new Date().getFullYear();
|
|
@@ -5339,13 +5324,12 @@ function useFocusTrap(containerRef, active, options = {}) {
|
|
|
5339
5324
|
? document.activeElement
|
|
5340
5325
|
: null;
|
|
5341
5326
|
const focusInitial = () => {
|
|
5342
|
-
|
|
5343
|
-
if (initialFocusRef === null || initialFocusRef === void 0 ? void 0 : initialFocusRef.current) {
|
|
5327
|
+
if (initialFocusRef?.current) {
|
|
5344
5328
|
initialFocusRef.current.focus();
|
|
5345
5329
|
return;
|
|
5346
5330
|
}
|
|
5347
5331
|
const focusables = Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter(el => !el.hasAttribute('disabled'));
|
|
5348
|
-
const target =
|
|
5332
|
+
const target = focusables[0] ?? container;
|
|
5349
5333
|
target.focus();
|
|
5350
5334
|
};
|
|
5351
5335
|
focusInitial();
|
|
@@ -5372,7 +5356,7 @@ function useFocusTrap(containerRef, active, options = {}) {
|
|
|
5372
5356
|
container.addEventListener('keydown', handleKeyDown);
|
|
5373
5357
|
return () => {
|
|
5374
5358
|
container.removeEventListener('keydown', handleKeyDown);
|
|
5375
|
-
if (restoreFocus &&
|
|
5359
|
+
if (restoreFocus && previouslyFocused?.focus) {
|
|
5376
5360
|
previouslyFocused.focus();
|
|
5377
5361
|
}
|
|
5378
5362
|
};
|
|
@@ -5746,13 +5730,12 @@ function setAmPm(currentDate, isPm) {
|
|
|
5746
5730
|
return next;
|
|
5747
5731
|
}
|
|
5748
5732
|
function segmentIndexAtCaret(map, caret) {
|
|
5749
|
-
var _a;
|
|
5750
5733
|
for (const idx of map.editable) {
|
|
5751
5734
|
const s = map.segments[idx];
|
|
5752
5735
|
if (caret >= s.start && caret <= s.end)
|
|
5753
5736
|
return idx;
|
|
5754
5737
|
}
|
|
5755
|
-
let bestIdx =
|
|
5738
|
+
let bestIdx = map.editable[0] ?? null;
|
|
5756
5739
|
let bestDist = Infinity;
|
|
5757
5740
|
for (const idx of map.editable) {
|
|
5758
5741
|
const s = map.segments[idx];
|
|
@@ -5772,8 +5755,8 @@ function useSegmentedEntry(params) {
|
|
|
5772
5755
|
const [activeSegmentIdx, setActiveSegmentIdx] = useState(null);
|
|
5773
5756
|
const typedDigitsRef = useRef('');
|
|
5774
5757
|
const segmentEditable = !!segmentMap && !!editable && !disabled && !readOnly;
|
|
5775
|
-
const segmentBaseDate = useCallback(() => value
|
|
5776
|
-
const isAllowed = useCallback((d) => isWithin(d, min, max) && !
|
|
5758
|
+
const segmentBaseDate = useCallback(() => value ?? makeBaseDate(), [value, makeBaseDate]);
|
|
5759
|
+
const isAllowed = useCallback((d) => isWithin(d, min, max) && !isBlocked?.(d), [min, max, isBlocked]);
|
|
5777
5760
|
const applyDateFromSegment = useCallback((next) => {
|
|
5778
5761
|
if (!isAllowed(next))
|
|
5779
5762
|
return;
|
|
@@ -5816,7 +5799,7 @@ function useSegmentedEntry(params) {
|
|
|
5816
5799
|
containerRef.current !== null &&
|
|
5817
5800
|
containerRef.current.contains(nextFocus);
|
|
5818
5801
|
if (stayingInPicker) {
|
|
5819
|
-
onBlur
|
|
5802
|
+
onBlur?.(e);
|
|
5820
5803
|
return;
|
|
5821
5804
|
}
|
|
5822
5805
|
setActiveSegmentIdx(null);
|
|
@@ -5828,7 +5811,7 @@ function useSegmentedEntry(params) {
|
|
|
5828
5811
|
else {
|
|
5829
5812
|
setText(value ? formatFn(value, format, locale) : '');
|
|
5830
5813
|
}
|
|
5831
|
-
onBlur
|
|
5814
|
+
onBlur?.(e);
|
|
5832
5815
|
}, [
|
|
5833
5816
|
containerRef,
|
|
5834
5817
|
tryParse,
|
|
@@ -5852,7 +5835,7 @@ function useSegmentedEntry(params) {
|
|
|
5852
5835
|
typedDigitsRef.current = '';
|
|
5853
5836
|
setActiveSegmentIdx(segmentMap.editable[0]);
|
|
5854
5837
|
}
|
|
5855
|
-
onFocus
|
|
5838
|
+
onFocus?.(e);
|
|
5856
5839
|
}, [
|
|
5857
5840
|
openOnFocus,
|
|
5858
5841
|
popover,
|
|
@@ -5870,18 +5853,17 @@ function useSegmentedEntry(params) {
|
|
|
5870
5853
|
onFocus,
|
|
5871
5854
|
]);
|
|
5872
5855
|
const handleClick = useCallback((e) => {
|
|
5873
|
-
var _a;
|
|
5874
5856
|
if (openOnFocus && popover && !disabled && !readOnly)
|
|
5875
5857
|
setOpen(true);
|
|
5876
5858
|
if (segmentEditable && segmentMap && inputRef.current) {
|
|
5877
|
-
const caret =
|
|
5859
|
+
const caret = inputRef.current.selectionStart ?? 0;
|
|
5878
5860
|
const idx = segmentIndexAtCaret(segmentMap, caret);
|
|
5879
5861
|
if (idx !== null && idx !== activeSegmentIdx) {
|
|
5880
5862
|
typedDigitsRef.current = '';
|
|
5881
5863
|
setActiveSegmentIdx(idx);
|
|
5882
5864
|
}
|
|
5883
5865
|
}
|
|
5884
|
-
onClick
|
|
5866
|
+
onClick?.(e);
|
|
5885
5867
|
}, [
|
|
5886
5868
|
openOnFocus,
|
|
5887
5869
|
popover,
|
|
@@ -5999,7 +5981,7 @@ function useSegmentedEntry(params) {
|
|
|
5999
5981
|
setOpen(false);
|
|
6000
5982
|
}
|
|
6001
5983
|
}
|
|
6002
|
-
onKeyDown
|
|
5984
|
+
onKeyDown?.(e);
|
|
6003
5985
|
}, [
|
|
6004
5986
|
inSegmentMode,
|
|
6005
5987
|
segmentMap,
|
|
@@ -6043,9 +6025,9 @@ const DateInputBase = forwardRef((props, ref) => {
|
|
|
6043
6025
|
const { value: controlledValue, defaultValue, onChange, onOpen, onClose, min, max, disabled, readOnly, placeholder, format, parse, locale, inline = false, mobileNative = 'auto', editable = true, popover = true, openOnFocus = true, closeOnSelect = true, position = 'bottom-left', appendToBody = false, color, size, isRounded, shouldDisableDate, unselectableDates, firstDayOfWeek = 0, dayNames, monthNames, nearbyMonthDays = true, className, name, form, required, id, onFocus, onClick, onKeyDown, onBlur, iconLeftName: _iconLeftName, triggerIcon = true, triggerIconName = 'chevron-down', labels, ...rest } = props;
|
|
6044
6026
|
const t = mergeLabels(labels);
|
|
6045
6027
|
const isControlled = controlledValue !== undefined;
|
|
6046
|
-
const [internalValue, setInternalValue] = useState(defaultValue
|
|
6047
|
-
const value = isControlled ? (controlledValue
|
|
6048
|
-
const initialFocused = useMemo(() => clampDate(value
|
|
6028
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? null);
|
|
6029
|
+
const value = isControlled ? (controlledValue ?? null) : internalValue;
|
|
6030
|
+
const initialFocused = useMemo(() => clampDate(value ?? new Date(), min, max), []);
|
|
6049
6031
|
const [focusedDate, setFocusedDate] = useState(initialFocused);
|
|
6050
6032
|
useEffect(() => {
|
|
6051
6033
|
setFocusedDate(prev => clampDate(prev, min, max));
|
|
@@ -6073,9 +6055,9 @@ const DateInputBase = forwardRef((props, ref) => {
|
|
|
6073
6055
|
if (prev === next)
|
|
6074
6056
|
return prev;
|
|
6075
6057
|
if (next)
|
|
6076
|
-
onOpen
|
|
6058
|
+
onOpen?.();
|
|
6077
6059
|
else
|
|
6078
|
-
onClose
|
|
6060
|
+
onClose?.();
|
|
6079
6061
|
return next;
|
|
6080
6062
|
});
|
|
6081
6063
|
}, [onOpen, onClose]);
|
|
@@ -6087,7 +6069,7 @@ const DateInputBase = forwardRef((props, ref) => {
|
|
|
6087
6069
|
setInternalValue(next);
|
|
6088
6070
|
if (next)
|
|
6089
6071
|
setFocusedDate(next);
|
|
6090
|
-
onChange
|
|
6072
|
+
onChange?.(next);
|
|
6091
6073
|
}, [isControlled, onChange]);
|
|
6092
6074
|
const handleSelect = useCallback((d) => {
|
|
6093
6075
|
if (!isWithin(d, min, max))
|
|
@@ -6104,7 +6086,7 @@ const DateInputBase = forwardRef((props, ref) => {
|
|
|
6104
6086
|
const fmt = typeof format === 'string' ? format : undefined;
|
|
6105
6087
|
return parse
|
|
6106
6088
|
? parse(trimmed)
|
|
6107
|
-
: parseDate(trimmed, fmt
|
|
6089
|
+
: parseDate(trimmed, fmt ?? DEFAULT_DATE_FORMAT);
|
|
6108
6090
|
}, [parse, format, locale]);
|
|
6109
6091
|
const makeBaseDate = useCallback(() => {
|
|
6110
6092
|
const d = new Date();
|
|
@@ -6114,13 +6096,13 @@ const DateInputBase = forwardRef((props, ref) => {
|
|
|
6114
6096
|
const inputReadOnlyAttr = !!readOnly || !editable;
|
|
6115
6097
|
const canOpen = !!popover && !disabled && !readOnly;
|
|
6116
6098
|
const isBlocked = useMemo(() => {
|
|
6117
|
-
if (!shouldDisableDate && !
|
|
6099
|
+
if (!shouldDisableDate && !unselectableDates?.length)
|
|
6118
6100
|
return undefined;
|
|
6119
|
-
return (d) => !!
|
|
6120
|
-
!!
|
|
6101
|
+
return (d) => !!shouldDisableDate?.(d) ||
|
|
6102
|
+
!!unselectableDates?.some(u => isSameDay(u, d));
|
|
6121
6103
|
}, [shouldDisableDate, unselectableDates]);
|
|
6122
6104
|
const { inputHandlers } = useSegmentedEntry({
|
|
6123
|
-
format: format
|
|
6105
|
+
format: format ?? DEFAULT_DATE_FORMAT,
|
|
6124
6106
|
value,
|
|
6125
6107
|
commitValue,
|
|
6126
6108
|
formatFn: formatDate,
|
|
@@ -6175,13 +6157,12 @@ const DateInputBase = forwardRef((props, ref) => {
|
|
|
6175
6157
|
DateInputBase.displayName = 'DateInputBase';
|
|
6176
6158
|
|
|
6177
6159
|
const DateInput = forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'calendar', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
6178
|
-
var _a;
|
|
6179
6160
|
const insideField = useInsideField();
|
|
6180
6161
|
const insideControl = useInsideControl();
|
|
6181
6162
|
const helpClass = usePrefixedClassNames('help', {
|
|
6182
6163
|
[`is-${messageColor}`]: !!messageColor,
|
|
6183
6164
|
});
|
|
6184
|
-
let content = (jsx(DateInputBase, { ref: ref, ...baseProps, triggerIcon:
|
|
6165
|
+
let content = (jsx(DateInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
6185
6166
|
if (!insideControl && !baseProps.inline) {
|
|
6186
6167
|
content = (jsx(Control, { iconLeft: iconLeft, iconRight: iconRight, iconLeftName: iconLeftName, iconRightName: iconRightName, iconLeftSize: iconLeftSize, iconRightSize: iconRightSize, hasIconsLeft: hasIconsLeft || !!iconLeftName, hasIconsRight: hasIconsRight, isLoading: isLoading, isExpanded: isExpanded, size: controlSize, className: controlClassName, children: content }));
|
|
6187
6168
|
}
|
|
@@ -6206,11 +6187,10 @@ const tickHaptic = () => {
|
|
|
6206
6187
|
|
|
6207
6188
|
let audioCtx = null;
|
|
6208
6189
|
const getAudioContextCtor = () => {
|
|
6209
|
-
var _a, _b;
|
|
6210
6190
|
if (typeof window === 'undefined')
|
|
6211
6191
|
return null;
|
|
6212
6192
|
const w = window;
|
|
6213
|
-
return
|
|
6193
|
+
return w.AudioContext ?? w.webkitAudioContext ?? null;
|
|
6214
6194
|
};
|
|
6215
6195
|
const ensureAudioCtx = () => {
|
|
6216
6196
|
if (audioCtx)
|
|
@@ -6290,11 +6270,10 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6290
6270
|
const audioTickEnabledRef = useRef(audioTick);
|
|
6291
6271
|
audioTickEnabledRef.current = audioTick;
|
|
6292
6272
|
const playBandPulse = useCallback(() => {
|
|
6293
|
-
var _a;
|
|
6294
6273
|
const el = bandRef.current;
|
|
6295
6274
|
if (!el || typeof el.animate !== 'function')
|
|
6296
6275
|
return;
|
|
6297
|
-
if (
|
|
6276
|
+
if (reducedMotionMqlRef.current?.matches)
|
|
6298
6277
|
return;
|
|
6299
6278
|
pulseAnimRef.current = el.animate([
|
|
6300
6279
|
{ transform: 'scale(1)', filter: 'brightness(1)' },
|
|
@@ -6330,15 +6309,13 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6330
6309
|
}
|
|
6331
6310
|
}, []);
|
|
6332
6311
|
useEffect(() => () => {
|
|
6333
|
-
var _a;
|
|
6334
6312
|
cancelRaf();
|
|
6335
|
-
|
|
6313
|
+
pulseAnimRef.current?.cancel();
|
|
6336
6314
|
pulseAnimRef.current = null;
|
|
6337
6315
|
}, [cancelRaf]);
|
|
6338
6316
|
React.useImperativeHandle(ref, () => ({
|
|
6339
|
-
focus: () =>
|
|
6317
|
+
focus: () => rootRef.current?.focus(),
|
|
6340
6318
|
startDrag: (pointerId, clientY) => {
|
|
6341
|
-
var _a;
|
|
6342
6319
|
if (disabled)
|
|
6343
6320
|
return;
|
|
6344
6321
|
cancelRaf();
|
|
@@ -6353,7 +6330,7 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6353
6330
|
samples: [{ t: now, y: clientY }],
|
|
6354
6331
|
};
|
|
6355
6332
|
try {
|
|
6356
|
-
|
|
6333
|
+
rootRef.current?.setPointerCapture(pointerId);
|
|
6357
6334
|
}
|
|
6358
6335
|
catch {
|
|
6359
6336
|
}
|
|
@@ -6443,15 +6420,15 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6443
6420
|
break;
|
|
6444
6421
|
case 'ArrowLeft':
|
|
6445
6422
|
e.preventDefault();
|
|
6446
|
-
onFocusPrev
|
|
6423
|
+
onFocusPrev?.();
|
|
6447
6424
|
break;
|
|
6448
6425
|
case 'ArrowRight':
|
|
6449
6426
|
e.preventDefault();
|
|
6450
|
-
onFocusNext
|
|
6427
|
+
onFocusNext?.();
|
|
6451
6428
|
break;
|
|
6452
6429
|
case 'Enter':
|
|
6453
6430
|
e.preventDefault();
|
|
6454
|
-
onCommit
|
|
6431
|
+
onCommit?.();
|
|
6455
6432
|
break;
|
|
6456
6433
|
}
|
|
6457
6434
|
}, [
|
|
@@ -6577,7 +6554,6 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6577
6554
|
};
|
|
6578
6555
|
};
|
|
6579
6556
|
const onPointerMove = (e) => {
|
|
6580
|
-
var _a;
|
|
6581
6557
|
const s = dragStateRef.current;
|
|
6582
6558
|
if (s.pointerId !== e.pointerId)
|
|
6583
6559
|
return;
|
|
@@ -6585,7 +6561,7 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6585
6561
|
if (!s.captured) {
|
|
6586
6562
|
if (Math.abs(dy) < DRAG_THRESHOLD_PX)
|
|
6587
6563
|
return;
|
|
6588
|
-
|
|
6564
|
+
rootRef.current?.setPointerCapture(e.pointerId);
|
|
6589
6565
|
s.captured = true;
|
|
6590
6566
|
setIsDragging(true);
|
|
6591
6567
|
}
|
|
@@ -6598,13 +6574,12 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6598
6574
|
commitPosition(s.startPosition - dy / itemHeight);
|
|
6599
6575
|
};
|
|
6600
6576
|
const onPointerUp = (e) => {
|
|
6601
|
-
var _a, _b;
|
|
6602
6577
|
const s = dragStateRef.current;
|
|
6603
6578
|
if (s.pointerId !== e.pointerId)
|
|
6604
6579
|
return;
|
|
6605
6580
|
if (s.captured) {
|
|
6606
|
-
|
|
6607
|
-
|
|
6581
|
+
rootRef.current?.releasePointerCapture(e.pointerId);
|
|
6582
|
+
rootRef.current?.focus();
|
|
6608
6583
|
const samples = s.samples;
|
|
6609
6584
|
let pxPerMs = 0;
|
|
6610
6585
|
if (samples.length >= 2) {
|
|
@@ -6671,15 +6646,13 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6671
6646
|
height: itemHeight,
|
|
6672
6647
|
top: `${top}px`,
|
|
6673
6648
|
}, disabled: itemDisabled, onClick: () => {
|
|
6674
|
-
var _a;
|
|
6675
6649
|
moveBy(vIdx - virtualIdx);
|
|
6676
|
-
|
|
6650
|
+
rootRef.current?.focus();
|
|
6677
6651
|
}, children: formatLabel(values[aIdx]) }, vIdx));
|
|
6678
6652
|
})] }));
|
|
6679
6653
|
};
|
|
6680
6654
|
const Wheel = React.forwardRef(WheelInner);
|
|
6681
6655
|
const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false, incrementHours = 1, incrementMinutes = 1, incrementSeconds = 1, unselectableTimes, size, color, disabled, className, id, labels, visibleCount = 5, itemHeight = 32, audioTick = false, onCommit, }) => {
|
|
6682
|
-
var _a;
|
|
6683
6656
|
const t = mergeLabels(labels);
|
|
6684
6657
|
const rootClass = usePrefixedClassNames('timeinput', {
|
|
6685
6658
|
[`is-${color}`]: !!color,
|
|
@@ -6702,29 +6675,27 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6702
6675
|
return !unselectableTimes(probe);
|
|
6703
6676
|
}, [unselectableTimes]);
|
|
6704
6677
|
const isHourDisabled = useCallback((display) => {
|
|
6705
|
-
var _a;
|
|
6706
6678
|
let h24 = display;
|
|
6707
6679
|
if (hourFormat === '12') {
|
|
6708
6680
|
const base = display % 12;
|
|
6709
6681
|
h24 = isPm ? base + 12 : base;
|
|
6710
6682
|
}
|
|
6711
|
-
return !isTimeAllowed(h24, value.minutes,
|
|
6683
|
+
return !isTimeAllowed(h24, value.minutes, value.seconds ?? 0);
|
|
6712
6684
|
}, [hourFormat, isPm, isTimeAllowed, value.minutes, value.seconds]);
|
|
6713
|
-
const isMinuteDisabled = useCallback((m) =>
|
|
6685
|
+
const isMinuteDisabled = useCallback((m) => !isTimeAllowed(value.hours, m, value.seconds ?? 0), [isTimeAllowed, value.hours, value.seconds]);
|
|
6714
6686
|
const isSecondDisabled = useCallback((s) => !isTimeAllowed(value.hours, value.minutes, s), [isTimeAllowed, value.hours, value.minutes]);
|
|
6715
6687
|
const hourDisabledFor = unselectableTimes ? isHourDisabled : undefined;
|
|
6716
6688
|
const minuteDisabledFor = unselectableTimes ? isMinuteDisabled : undefined;
|
|
6717
6689
|
const secondDisabledFor = unselectableTimes ? isSecondDisabled : undefined;
|
|
6718
6690
|
const commit = useCallback((next) => {
|
|
6719
|
-
var _a, _b, _c, _d, _e;
|
|
6720
6691
|
const merged = {
|
|
6721
|
-
hours:
|
|
6722
|
-
minutes:
|
|
6692
|
+
hours: next.hours ?? value.hours,
|
|
6693
|
+
minutes: next.minutes ?? value.minutes,
|
|
6723
6694
|
seconds: enableSeconds
|
|
6724
|
-
? (
|
|
6695
|
+
? (next.seconds ?? value.seconds ?? 0)
|
|
6725
6696
|
: undefined,
|
|
6726
6697
|
};
|
|
6727
|
-
if (!isTimeAllowed(merged.hours, merged.minutes,
|
|
6698
|
+
if (!isTimeAllowed(merged.hours, merged.minutes, merged.seconds ?? 0)) {
|
|
6728
6699
|
return;
|
|
6729
6700
|
}
|
|
6730
6701
|
onChange(merged);
|
|
@@ -6763,7 +6734,7 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6763
6734
|
: value.hours;
|
|
6764
6735
|
const hourIndex = Math.max(0, hourValues.indexOf(displayedHours));
|
|
6765
6736
|
const minuteIndex = Math.max(0, minuteValues.indexOf(value.minutes));
|
|
6766
|
-
const secondIndex = Math.max(0, secondValues.indexOf(
|
|
6737
|
+
const secondIndex = Math.max(0, secondValues.indexOf(value.seconds ?? 0));
|
|
6767
6738
|
const ampmIndex = isPm ? 1 : 0;
|
|
6768
6739
|
const hoursRef = useRef(null);
|
|
6769
6740
|
const minutesRef = useRef(null);
|
|
@@ -6776,7 +6747,7 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6776
6747
|
columnOrder.push(secondsRef);
|
|
6777
6748
|
if (hourFormat === '12')
|
|
6778
6749
|
columnOrder.push(ampmRef);
|
|
6779
|
-
const focusAt = (i) =>
|
|
6750
|
+
const focusAt = (i) => columnOrder[i]?.current?.focus();
|
|
6780
6751
|
const indexOf = (r) => columnOrder.indexOf(r);
|
|
6781
6752
|
const focusPrevOf = (r) => () => focusAt(indexOf(r) - 1);
|
|
6782
6753
|
const focusNextOf = (r) => () => focusAt(indexOf(r) + 1);
|
|
@@ -6787,18 +6758,17 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6787
6758
|
const baseHour = display % 12;
|
|
6788
6759
|
next24 = isPm ? baseHour + 12 : baseHour;
|
|
6789
6760
|
}
|
|
6790
|
-
const allowed = nextValid(next24, next24 >= value.hours ? 1 : -1, 24, h =>
|
|
6761
|
+
const allowed = nextValid(next24, next24 >= value.hours ? 1 : -1, 24, h => isTimeAllowed(h, value.minutes, value.seconds ?? 0));
|
|
6791
6762
|
commit({ hours: allowed });
|
|
6792
6763
|
};
|
|
6793
6764
|
const onMinuteIndex = (next) => {
|
|
6794
6765
|
const m = minuteValues[Math.max(0, Math.min(minuteValues.length - 1, next))];
|
|
6795
|
-
const allowed = nextValid(m, m >= value.minutes ? 1 : -1, 60, mm =>
|
|
6766
|
+
const allowed = nextValid(m, m >= value.minutes ? 1 : -1, 60, mm => isTimeAllowed(value.hours, mm, value.seconds ?? 0));
|
|
6796
6767
|
commit({ minutes: allowed });
|
|
6797
6768
|
};
|
|
6798
6769
|
const onSecondIndex = (next) => {
|
|
6799
|
-
var _a;
|
|
6800
6770
|
const s = secondValues[Math.max(0, Math.min(secondValues.length - 1, next))];
|
|
6801
|
-
const allowed = nextValid(s, s >= (
|
|
6771
|
+
const allowed = nextValid(s, s >= (value.seconds ?? 0) ? 1 : -1, 60, ss => isTimeAllowed(value.hours, value.minutes, ss));
|
|
6802
6772
|
commit({ seconds: allowed });
|
|
6803
6773
|
};
|
|
6804
6774
|
const onAmpmIndex = (next) => {
|
|
@@ -6807,7 +6777,6 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6807
6777
|
commit({ hours: (value.hours + 12) % 24 });
|
|
6808
6778
|
};
|
|
6809
6779
|
const onWheelsContainerPointerDown = (e) => {
|
|
6810
|
-
var _a, _b;
|
|
6811
6780
|
if (disabled)
|
|
6812
6781
|
return;
|
|
6813
6782
|
if (e.target.closest(`.${wheelSingleClass}`))
|
|
@@ -6830,7 +6799,7 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6830
6799
|
nearestIdx = i;
|
|
6831
6800
|
}
|
|
6832
6801
|
});
|
|
6833
|
-
|
|
6802
|
+
columnOrder[nearestIdx]?.current?.startDrag(e.pointerId, e.clientY);
|
|
6834
6803
|
};
|
|
6835
6804
|
return (jsx("div", { id: id, className: classNames(rootClass, className), "aria-disabled": disabled, children: jsxs("div", { className: wheelsClass, ref: wheelsContainerRef, onPointerDown: onWheelsContainerPointerDown, children: [jsx(Wheel, { ref: hoursRef, values: hourValues, index: hourIndex, onChange: onHourIndex, formatLabel: pad2, ariaLabel: t.hours, visibleCount: visibleCount, itemHeight: itemHeight, disabled: disabled, size: size, color: color, wrap: true, onCommit: onCommit, onFocusPrev: focusPrevOf(hoursRef), onFocusNext: focusNextOf(hoursRef), disabledFor: hourDisabledFor, audioTick: audioTick }), jsx("div", { className: sepClass, "aria-hidden": "true", children: ":" }), jsx(Wheel, { ref: minutesRef, values: minuteValues, index: minuteIndex, onChange: onMinuteIndex, formatLabel: pad2, ariaLabel: t.minutes, visibleCount: visibleCount, itemHeight: itemHeight, disabled: disabled, size: size, color: color, wrap: true, onCommit: onCommit, onFocusPrev: focusPrevOf(minutesRef), onFocusNext: focusNextOf(minutesRef), disabledFor: minuteDisabledFor, audioTick: audioTick }), enableSeconds && (jsxs(Fragment, { children: [jsx("div", { className: sepClass, "aria-hidden": "true", children: ":" }), jsx(Wheel, { ref: secondsRef, values: secondValues, index: secondIndex, onChange: onSecondIndex, formatLabel: pad2, ariaLabel: t.seconds, visibleCount: visibleCount, itemHeight: itemHeight, disabled: disabled, size: size, color: color, wrap: true, onFocusPrev: focusPrevOf(secondsRef), onFocusNext: focusNextOf(secondsRef), disabledFor: secondDisabledFor, audioTick: audioTick })] })), hourFormat === '12' && (jsx(Wheel, { ref: ampmRef, values: ['AM', 'PM'], index: ampmIndex, onChange: onAmpmIndex, formatLabel: v => v, ariaLabel: t.ampm, visibleCount: visibleCount, itemHeight: itemHeight, disabled: disabled, size: size, color: color, onCommit: onCommit, onFocusPrev: focusPrevOf(ampmRef), onFocusNext: focusNextOf(ampmRef), audioTick: audioTick }))] }) }));
|
|
6836
6805
|
};
|
|
@@ -6852,23 +6821,23 @@ const fromIsoTime = (s) => {
|
|
|
6852
6821
|
return new Date(today.getFullYear(), today.getMonth(), today.getDate(), Number(m[1]), Number(m[2]), m[3] ? Number(m[3]) : 0, 0);
|
|
6853
6822
|
};
|
|
6854
6823
|
const TimeInputBase = forwardRef((props, ref) => {
|
|
6855
|
-
var _a, _b, _c, _d;
|
|
6856
6824
|
const { value: controlledValue, defaultValue, onChange, onOpen, onClose, min, max, disabled, readOnly, placeholder, format, parse, locale, inline = false, mobileNative = 'auto', editable = true, popover = true, openOnFocus = true, closeOnSelect = false, position = 'bottom-left', appendToBody = false, color, size, isRounded, hourFormat = '24', enableSeconds = false, incrementHours = 1, incrementMinutes = 1, incrementSeconds = 1, unselectableTimes, className, name, form, required, id, onFocus, onClick, onKeyDown, onBlur, iconLeftName: _iconLeftName, triggerIcon = true, triggerIconName = 'chevron-down', labels, audioTick = false, haptics = false, ...rest } = props;
|
|
6857
6825
|
const hasVibrate = typeof navigator !== 'undefined' &&
|
|
6858
6826
|
typeof navigator.vibrate === 'function';
|
|
6859
6827
|
const effectiveAudioTick = audioTick || (haptics && !hasVibrate);
|
|
6860
6828
|
const t = mergeLabels(labels);
|
|
6861
6829
|
const isControlled = controlledValue !== undefined;
|
|
6862
|
-
const [internalValue, setInternalValue] = useState(defaultValue
|
|
6863
|
-
const value = isControlled ? (controlledValue
|
|
6864
|
-
const defaultFormat = format
|
|
6865
|
-
|
|
6866
|
-
?
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6830
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? null);
|
|
6831
|
+
const value = isControlled ? (controlledValue ?? null) : internalValue;
|
|
6832
|
+
const defaultFormat = format ??
|
|
6833
|
+
(hourFormat === '12'
|
|
6834
|
+
? enableSeconds
|
|
6835
|
+
? 'hh:mm:ss A'
|
|
6836
|
+
: DEFAULT_TIME_FORMAT_12
|
|
6837
|
+
: enableSeconds
|
|
6838
|
+
? 'HH:mm:ss'
|
|
6839
|
+
: DEFAULT_TIME_FORMAT_24);
|
|
6840
|
+
const effectiveHourFormat = hourCycleFromFormat(defaultFormat) ?? hourFormat;
|
|
6872
6841
|
const [open, setOpenState] = useState(false);
|
|
6873
6842
|
const [text, setText] = useState(value ? formatTime(value, defaultFormat, locale) : '');
|
|
6874
6843
|
const inputRef = useRef(null);
|
|
@@ -6902,10 +6871,10 @@ const TimeInputBase = forwardRef((props, ref) => {
|
|
|
6902
6871
|
return prev;
|
|
6903
6872
|
if (next) {
|
|
6904
6873
|
valueAtOpenRef.current = value;
|
|
6905
|
-
onOpen
|
|
6874
|
+
onOpen?.();
|
|
6906
6875
|
}
|
|
6907
6876
|
else {
|
|
6908
|
-
onClose
|
|
6877
|
+
onClose?.();
|
|
6909
6878
|
}
|
|
6910
6879
|
return next;
|
|
6911
6880
|
});
|
|
@@ -6916,10 +6885,10 @@ const TimeInputBase = forwardRef((props, ref) => {
|
|
|
6916
6885
|
const commitValue = useCallback((next) => {
|
|
6917
6886
|
if (!isControlled)
|
|
6918
6887
|
setInternalValue(next);
|
|
6919
|
-
onChange
|
|
6888
|
+
onChange?.(next);
|
|
6920
6889
|
}, [isControlled, onChange]);
|
|
6921
6890
|
const handleSpinnerChange = useCallback((parts) => {
|
|
6922
|
-
const base = value
|
|
6891
|
+
const base = value ?? new Date();
|
|
6923
6892
|
const next = setTimeOfDay(base, parts);
|
|
6924
6893
|
if (!isWithin(next, min, max))
|
|
6925
6894
|
return;
|
|
@@ -6932,9 +6901,10 @@ const TimeInputBase = forwardRef((props, ref) => {
|
|
|
6932
6901
|
const fmt = typeof format === 'string' ? format : undefined;
|
|
6933
6902
|
return parse
|
|
6934
6903
|
? parse(trimmed)
|
|
6935
|
-
: parseTime(trimmed, fmt
|
|
6936
|
-
|
|
6937
|
-
|
|
6904
|
+
: parseTime(trimmed, fmt ??
|
|
6905
|
+
(typeof defaultFormat === 'string'
|
|
6906
|
+
? defaultFormat
|
|
6907
|
+
: DEFAULT_TIME_FORMAT_24));
|
|
6938
6908
|
}, [parse, format, defaultFormat]);
|
|
6939
6909
|
const makeBaseDate = useCallback(() => {
|
|
6940
6910
|
const d = new Date();
|
|
@@ -6990,9 +6960,9 @@ const TimeInputBase = forwardRef((props, ref) => {
|
|
|
6990
6960
|
}, min: min ? toIsoTime(min, enableSeconds) : undefined, max: max ? toIsoTime(max, enableSeconds) : undefined, disabled: disabled, readOnly: readOnly, placeholder: placeholder, name: name, form: form, required: required, id: id }));
|
|
6991
6961
|
}
|
|
6992
6962
|
const spinnerValue = {
|
|
6993
|
-
hours:
|
|
6994
|
-
minutes:
|
|
6995
|
-
seconds: enableSeconds ? (
|
|
6963
|
+
hours: value?.getHours() ?? 0,
|
|
6964
|
+
minutes: value?.getMinutes() ?? 0,
|
|
6965
|
+
seconds: enableSeconds ? (value?.getSeconds() ?? 0) : undefined,
|
|
6996
6966
|
};
|
|
6997
6967
|
const panel = (jsxs("div", { className: panelClass, children: [jsx(TimeWheels, { value: spinnerValue, onChange: handleSpinnerChange, hourFormat: effectiveHourFormat, enableSeconds: enableSeconds, incrementHours: incrementHours, incrementMinutes: incrementMinutes, incrementSeconds: incrementSeconds, unselectableTimes: unselectableTimes, color: color, size: size, disabled: disabled, id: popoverId, labels: labels, itemHeight: wheelItemHeight, audioTick: effectiveAudioTick, onCommit: () => setOpen(false) }), !inline && !isSmallViewport && (jsxs(Buttons, { className: footerClass, hasAddons: true, children: [jsx("button", { type: "button", className: footerOkClass, onClick: () => setOpen(false), children: t.ok }), jsx("button", { type: "button", className: footerButton, onClick: () => {
|
|
6998
6968
|
commitValue(snapTimeToIncrement(new Date(), {
|
|
@@ -7020,13 +6990,12 @@ const TimeInputBase = forwardRef((props, ref) => {
|
|
|
7020
6990
|
TimeInputBase.displayName = 'TimeInputBase';
|
|
7021
6991
|
|
|
7022
6992
|
const TimeInput = forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'clock', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
7023
|
-
var _a;
|
|
7024
6993
|
const insideField = useInsideField();
|
|
7025
6994
|
const insideControl = useInsideControl();
|
|
7026
6995
|
const helpClass = usePrefixedClassNames('help', {
|
|
7027
6996
|
[`is-${messageColor}`]: !!messageColor,
|
|
7028
6997
|
});
|
|
7029
|
-
let content = (jsx(TimeInputBase, { ref: ref, ...baseProps, triggerIcon:
|
|
6998
|
+
let content = (jsx(TimeInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
7030
6999
|
if (!insideControl && !baseProps.inline) {
|
|
7031
7000
|
content = (jsx(Control, { iconLeft: iconLeft, iconRight: iconRight, iconLeftName: iconLeftName, iconRightName: iconRightName, iconLeftSize: iconLeftSize, iconRightSize: iconRightSize, hasIconsLeft: hasIconsLeft || !!iconLeftName, hasIconsRight: hasIconsRight, isLoading: isLoading, isExpanded: isExpanded, size: controlSize, className: controlClassName, children: content }));
|
|
7032
7001
|
}
|
|
@@ -7056,27 +7025,27 @@ const fromIsoDateTime = (s) => {
|
|
|
7056
7025
|
return new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]), Number(m[4]), Number(m[5]), m[6] ? Number(m[6]) : 0, 0);
|
|
7057
7026
|
};
|
|
7058
7027
|
const DateTimeInputBase = forwardRef((props, ref) => {
|
|
7059
|
-
var _a, _b, _c, _d;
|
|
7060
7028
|
const { value: controlledValue, defaultValue, onChange, onOpen, onClose, min, max, disabled, readOnly, placeholder, format, parse, locale, inline = false, mobileNative = 'auto', editable = true, popover = true, openOnFocus = true, closeOnSelect = false, position = 'bottom-left', appendToBody = false, color, size, isRounded, shouldDisableDate, unselectableDates, firstDayOfWeek = 0, dayNames, monthNames, nearbyMonthDays = true, hourFormat = '24', enableSeconds = false, incrementHours = 1, incrementMinutes = 1, incrementSeconds = 1, unselectableTimes, className, name, form, required, id, onFocus, onClick, onKeyDown, onBlur, iconLeftName: _iconLeftName, triggerIcon = true, triggerIconName = 'chevron-down', audioTick = false, haptics = false, labels, ...rest } = props;
|
|
7061
7029
|
const t = mergeLabels(labels);
|
|
7062
7030
|
const hasVibrate = typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function';
|
|
7063
7031
|
const effectiveAudioTick = audioTick || (haptics && !hasVibrate);
|
|
7064
7032
|
const isControlled = controlledValue !== undefined;
|
|
7065
|
-
const [internalValue, setInternalValue] = useState(defaultValue
|
|
7066
|
-
const value = isControlled ? (controlledValue
|
|
7067
|
-
const initialFocused = useMemo(() => clampDate(value
|
|
7033
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? null);
|
|
7034
|
+
const value = isControlled ? (controlledValue ?? null) : internalValue;
|
|
7035
|
+
const initialFocused = useMemo(() => clampDate(value ?? new Date(), min, max), []);
|
|
7068
7036
|
const [focusedDate, setFocusedDate] = useState(initialFocused);
|
|
7069
7037
|
useEffect(() => {
|
|
7070
7038
|
setFocusedDate(prev => clampDate(prev, min, max));
|
|
7071
7039
|
}, [min, max]);
|
|
7072
|
-
const defaultFormat = format
|
|
7073
|
-
|
|
7074
|
-
?
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7040
|
+
const defaultFormat = format ??
|
|
7041
|
+
(hourFormat === '12'
|
|
7042
|
+
? enableSeconds
|
|
7043
|
+
? 'YYYY-MM-DD hh:mm:ss A'
|
|
7044
|
+
: 'YYYY-MM-DD hh:mm A'
|
|
7045
|
+
: enableSeconds
|
|
7046
|
+
? 'YYYY-MM-DD HH:mm:ss'
|
|
7047
|
+
: DEFAULT_DATETIME_FORMAT);
|
|
7048
|
+
const effectiveHourFormat = hourCycleFromFormat(defaultFormat) ?? hourFormat;
|
|
7080
7049
|
const [open, setOpenState] = useState(false);
|
|
7081
7050
|
const [timeOpen, setTimeOpen] = useState(false);
|
|
7082
7051
|
const [text, setText] = useState(value ? formatDateTime(value, defaultFormat, locale) : '');
|
|
@@ -7121,10 +7090,10 @@ const DateTimeInputBase = forwardRef((props, ref) => {
|
|
|
7121
7090
|
return prev;
|
|
7122
7091
|
if (next) {
|
|
7123
7092
|
valueAtOpenRef.current = value;
|
|
7124
|
-
onOpen
|
|
7093
|
+
onOpen?.();
|
|
7125
7094
|
}
|
|
7126
7095
|
else {
|
|
7127
|
-
onClose
|
|
7096
|
+
onClose?.();
|
|
7128
7097
|
}
|
|
7129
7098
|
return next;
|
|
7130
7099
|
});
|
|
@@ -7141,14 +7110,13 @@ const DateTimeInputBase = forwardRef((props, ref) => {
|
|
|
7141
7110
|
setInternalValue(next);
|
|
7142
7111
|
if (next)
|
|
7143
7112
|
setFocusedDate(next);
|
|
7144
|
-
onChange
|
|
7113
|
+
onChange?.(next);
|
|
7145
7114
|
}, [isControlled, onChange]);
|
|
7146
7115
|
const handleDateSelect = useCallback((d) => {
|
|
7147
|
-
var _a, _b, _c;
|
|
7148
7116
|
const merged = setTimeOfDay(d, {
|
|
7149
|
-
hours:
|
|
7150
|
-
minutes:
|
|
7151
|
-
seconds: enableSeconds ? (
|
|
7117
|
+
hours: value?.getHours() ?? 0,
|
|
7118
|
+
minutes: value?.getMinutes() ?? 0,
|
|
7119
|
+
seconds: enableSeconds ? (value?.getSeconds() ?? 0) : undefined,
|
|
7152
7120
|
});
|
|
7153
7121
|
if (!isWithin(merged, min, max))
|
|
7154
7122
|
return;
|
|
@@ -7156,7 +7124,7 @@ const DateTimeInputBase = forwardRef((props, ref) => {
|
|
|
7156
7124
|
setFocusedDate(d);
|
|
7157
7125
|
}, [value, enableSeconds, min, max, commitValue]);
|
|
7158
7126
|
const handleTimeChange = useCallback((parts) => {
|
|
7159
|
-
const base = value
|
|
7127
|
+
const base = value ?? focusedDate;
|
|
7160
7128
|
const next = setTimeOfDay(base, parts);
|
|
7161
7129
|
if (!isWithin(next, min, max))
|
|
7162
7130
|
return;
|
|
@@ -7169,17 +7137,17 @@ const DateTimeInputBase = forwardRef((props, ref) => {
|
|
|
7169
7137
|
if (parse)
|
|
7170
7138
|
return parse(trimmed);
|
|
7171
7139
|
const fmt = typeof defaultFormat === 'string' ? defaultFormat : undefined;
|
|
7172
|
-
return parseDate(trimmed, fmt
|
|
7140
|
+
return parseDate(trimmed, fmt ?? DEFAULT_DATETIME_FORMAT);
|
|
7173
7141
|
}, [parse, defaultFormat, locale]);
|
|
7174
7142
|
const makeBaseDate = useCallback(() => new Date(), []);
|
|
7175
7143
|
const inputReadOnlyAttr = !!readOnly || !editable;
|
|
7176
7144
|
const canOpen = !!popover && !disabled && !readOnly;
|
|
7177
7145
|
const isBlocked = useMemo(() => {
|
|
7178
|
-
if (!shouldDisableDate && !
|
|
7146
|
+
if (!shouldDisableDate && !unselectableDates?.length && !unselectableTimes)
|
|
7179
7147
|
return undefined;
|
|
7180
|
-
return (d) => !!
|
|
7181
|
-
!!
|
|
7182
|
-
!!
|
|
7148
|
+
return (d) => !!shouldDisableDate?.(d) ||
|
|
7149
|
+
!!unselectableDates?.some(u => isSameDay(u, d)) ||
|
|
7150
|
+
!!unselectableTimes?.(d);
|
|
7183
7151
|
}, [shouldDisableDate, unselectableDates, unselectableTimes]);
|
|
7184
7152
|
const { inputHandlers } = useSegmentedEntry({
|
|
7185
7153
|
format: defaultFormat,
|
|
@@ -7227,9 +7195,9 @@ const DateTimeInputBase = forwardRef((props, ref) => {
|
|
|
7227
7195
|
}, min: min ? toIsoDateTime(min, enableSeconds) : undefined, max: max ? toIsoDateTime(max, enableSeconds) : undefined, disabled: disabled, readOnly: readOnly, placeholder: placeholder, name: name, form: form, required: required, id: id }));
|
|
7228
7196
|
}
|
|
7229
7197
|
const spinnerValue = {
|
|
7230
|
-
hours:
|
|
7231
|
-
minutes:
|
|
7232
|
-
seconds: enableSeconds ? (
|
|
7198
|
+
hours: value?.getHours() ?? 0,
|
|
7199
|
+
minutes: value?.getMinutes() ?? 0,
|
|
7200
|
+
seconds: enableSeconds ? (value?.getSeconds() ?? 0) : undefined,
|
|
7233
7201
|
};
|
|
7234
7202
|
const panel = (jsxs("div", { className: panelClass, onKeyDown: e => {
|
|
7235
7203
|
if (timeOpen && e.key === 'Escape') {
|
|
@@ -7251,13 +7219,12 @@ const DateTimeInputBase = forwardRef((props, ref) => {
|
|
|
7251
7219
|
DateTimeInputBase.displayName = 'DateTimeInputBase';
|
|
7252
7220
|
|
|
7253
7221
|
const DateTimeInput = forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'calendar-alt', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
7254
|
-
var _a;
|
|
7255
7222
|
const insideField = useInsideField();
|
|
7256
7223
|
const insideControl = useInsideControl();
|
|
7257
7224
|
const helpClass = usePrefixedClassNames('help', {
|
|
7258
7225
|
[`is-${messageColor}`]: !!messageColor,
|
|
7259
7226
|
});
|
|
7260
|
-
let content = (jsx(DateTimeInputBase, { ref: ref, ...baseProps, triggerIcon:
|
|
7227
|
+
let content = (jsx(DateTimeInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
7261
7228
|
if (!insideControl && !baseProps.inline) {
|
|
7262
7229
|
content = (jsx(Control, { iconLeft: iconLeft, iconRight: iconRight, iconLeftName: iconLeftName, iconRightName: iconRightName, iconLeftSize: iconLeftSize, iconRightSize: iconRightSize, hasIconsLeft: hasIconsLeft || !!iconLeftName, hasIconsRight: hasIconsRight, isLoading: isLoading, isExpanded: isExpanded, size: controlSize, className: controlClassName, children: content }));
|
|
7263
7230
|
}
|
|
@@ -7940,7 +7907,7 @@ const Container = ({ className, textColor, bgColor, fluid, widescreen, fullhd, b
|
|
|
7940
7907
|
|
|
7941
7908
|
const Footer = ({ as = 'footer', className, children, color, bgColor, textColor, ...props }) => {
|
|
7942
7909
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
7943
|
-
color: textColor
|
|
7910
|
+
color: textColor ?? color,
|
|
7944
7911
|
backgroundColor: bgColor,
|
|
7945
7912
|
...props,
|
|
7946
7913
|
});
|
|
@@ -7965,7 +7932,7 @@ const Hero = ({ className, color, size, bgColor, fullheightWithNavbar, children,
|
|
|
7965
7932
|
};
|
|
7966
7933
|
const HeroHead = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
7967
7934
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
7968
|
-
color: textColor
|
|
7935
|
+
color: textColor ?? color,
|
|
7969
7936
|
backgroundColor: bgColor,
|
|
7970
7937
|
...props,
|
|
7971
7938
|
});
|
|
@@ -7975,7 +7942,7 @@ const HeroHead = ({ className, children, color, bgColor, textColor, ...props })
|
|
|
7975
7942
|
};
|
|
7976
7943
|
const HeroBody = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
7977
7944
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
7978
|
-
color: textColor
|
|
7945
|
+
color: textColor ?? color,
|
|
7979
7946
|
backgroundColor: bgColor,
|
|
7980
7947
|
...props,
|
|
7981
7948
|
});
|
|
@@ -7985,7 +7952,7 @@ const HeroBody = ({ className, children, color, bgColor, textColor, ...props })
|
|
|
7985
7952
|
};
|
|
7986
7953
|
const HeroFoot = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
7987
7954
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
7988
|
-
color: textColor
|
|
7955
|
+
color: textColor ?? color,
|
|
7989
7956
|
backgroundColor: bgColor,
|
|
7990
7957
|
...props,
|
|
7991
7958
|
});
|
|
@@ -7999,7 +7966,7 @@ Hero.Foot = HeroFoot;
|
|
|
7999
7966
|
|
|
8000
7967
|
const Level = ({ isMobile, className, children, color, bgColor, textColor, ...props }) => {
|
|
8001
7968
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8002
|
-
color: textColor
|
|
7969
|
+
color: textColor ?? color,
|
|
8003
7970
|
backgroundColor: bgColor,
|
|
8004
7971
|
...props,
|
|
8005
7972
|
});
|
|
@@ -8011,7 +7978,7 @@ const Level = ({ isMobile, className, children, color, bgColor, textColor, ...pr
|
|
|
8011
7978
|
};
|
|
8012
7979
|
const LevelLeft = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
8013
7980
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8014
|
-
color: textColor
|
|
7981
|
+
color: textColor ?? color,
|
|
8015
7982
|
backgroundColor: bgColor,
|
|
8016
7983
|
...props,
|
|
8017
7984
|
});
|
|
@@ -8021,7 +7988,7 @@ const LevelLeft = ({ className, children, color, bgColor, textColor, ...props })
|
|
|
8021
7988
|
};
|
|
8022
7989
|
const LevelRight = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
8023
7990
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8024
|
-
color: textColor
|
|
7991
|
+
color: textColor ?? color,
|
|
8025
7992
|
backgroundColor: bgColor,
|
|
8026
7993
|
...props,
|
|
8027
7994
|
});
|
|
@@ -8031,7 +7998,7 @@ const LevelRight = ({ className, children, color, bgColor, textColor, ...props }
|
|
|
8031
7998
|
};
|
|
8032
7999
|
const LevelItem = ({ as = 'div', hasTextCentered, className, children, href, target, rel, color, bgColor, textColor, ...props }) => {
|
|
8033
8000
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8034
|
-
color: textColor
|
|
8001
|
+
color: textColor ?? color,
|
|
8035
8002
|
backgroundColor: bgColor,
|
|
8036
8003
|
...props,
|
|
8037
8004
|
});
|
|
@@ -8051,7 +8018,7 @@ Level.Item = LevelItem;
|
|
|
8051
8018
|
|
|
8052
8019
|
const Media = ({ as = 'article', className, children, color, bgColor, textColor, ...props }) => {
|
|
8053
8020
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8054
|
-
color: textColor
|
|
8021
|
+
color: textColor ?? color,
|
|
8055
8022
|
backgroundColor: bgColor,
|
|
8056
8023
|
...props,
|
|
8057
8024
|
});
|
|
@@ -8062,7 +8029,7 @@ const Media = ({ as = 'article', className, children, color, bgColor, textColor,
|
|
|
8062
8029
|
};
|
|
8063
8030
|
const MediaLeft = ({ as = 'figure', className, children, color, bgColor, textColor, ...props }) => {
|
|
8064
8031
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8065
|
-
color: textColor
|
|
8032
|
+
color: textColor ?? color,
|
|
8066
8033
|
backgroundColor: bgColor,
|
|
8067
8034
|
...props,
|
|
8068
8035
|
});
|
|
@@ -8073,7 +8040,7 @@ const MediaLeft = ({ as = 'figure', className, children, color, bgColor, textCol
|
|
|
8073
8040
|
};
|
|
8074
8041
|
const MediaContent = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
8075
8042
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8076
|
-
color: textColor
|
|
8043
|
+
color: textColor ?? color,
|
|
8077
8044
|
backgroundColor: bgColor,
|
|
8078
8045
|
...props,
|
|
8079
8046
|
});
|
|
@@ -8083,7 +8050,7 @@ const MediaContent = ({ className, children, color, bgColor, textColor, ...props
|
|
|
8083
8050
|
};
|
|
8084
8051
|
const MediaRight = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
8085
8052
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8086
|
-
color: textColor
|
|
8053
|
+
color: textColor ?? color,
|
|
8087
8054
|
backgroundColor: bgColor,
|
|
8088
8055
|
...props,
|
|
8089
8056
|
});
|
|
@@ -8098,7 +8065,7 @@ MediaWithSubcomponents.Right = MediaRight;
|
|
|
8098
8065
|
|
|
8099
8066
|
const Section = ({ size, className, children, color, bgColor, textColor, ...props }) => {
|
|
8100
8067
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8101
|
-
color: textColor
|
|
8068
|
+
color: textColor ?? color,
|
|
8102
8069
|
backgroundColor: bgColor,
|
|
8103
8070
|
...props,
|
|
8104
8071
|
});
|