@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.cjs.js
CHANGED
|
@@ -762,7 +762,7 @@ const CardComponent = ({ className, children, textColor, bgColor, hasShadow = tr
|
|
|
762
762
|
'is-centered': headerCentered,
|
|
763
763
|
}), children: header })), headerIcon] }));
|
|
764
764
|
};
|
|
765
|
-
return (jsxRuntime.jsxs("div", { className: cardClasses, ...rest, children: [renderHeader(header, headerIcon, headerCentered, classPrefix), image && (jsxRuntime.jsx("div", { className: prefixedClassNames(classPrefix, 'card-image'), children: typeof image === 'string' ? (jsxRuntime.jsx("figure", { className: prefixedClassNames(classPrefix, 'image'), children: jsxRuntime.jsx("img", { src: image, alt: imageAlt
|
|
765
|
+
return (jsxRuntime.jsxs("div", { className: cardClasses, ...rest, children: [renderHeader(header, headerIcon, headerCentered, classPrefix), image && (jsxRuntime.jsx("div", { className: prefixedClassNames(classPrefix, 'card-image'), children: typeof image === 'string' ? (jsxRuntime.jsx("figure", { className: prefixedClassNames(classPrefix, 'image'), children: jsxRuntime.jsx("img", { src: image, alt: imageAlt ?? 'Card image' }) })) : (image) })), typeof children !== 'undefined' &&
|
|
766
766
|
children !== null &&
|
|
767
767
|
children !== '' &&
|
|
768
768
|
!hasCompoundComponents(children) && (jsxRuntime.jsx("div", { className: prefixedClassNames(classPrefix, 'card-content'), children: children })), typeof children !== 'undefined' &&
|
|
@@ -825,10 +825,9 @@ const DropdownComponent = ({ label, children, className, menuClassName, active:
|
|
|
825
825
|
if (!isBrowser$1(window, document))
|
|
826
826
|
return;
|
|
827
827
|
const handleClick = (e) => {
|
|
828
|
-
|
|
829
|
-
if (!((_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
828
|
+
if (!dropdownRef.current?.contains(e.target)) {
|
|
830
829
|
setActive(false);
|
|
831
|
-
onActiveChange
|
|
830
|
+
onActiveChange?.(false);
|
|
832
831
|
}
|
|
833
832
|
};
|
|
834
833
|
document.addEventListener('mousedown', handleClick);
|
|
@@ -839,12 +838,12 @@ const DropdownComponent = ({ label, children, className, menuClassName, active:
|
|
|
839
838
|
return;
|
|
840
839
|
const newActive = !active;
|
|
841
840
|
setActive(newActive);
|
|
842
|
-
onActiveChange
|
|
841
|
+
onActiveChange?.(newActive);
|
|
843
842
|
};
|
|
844
843
|
const handleMenuClick = () => {
|
|
845
844
|
if (closeOnClick) {
|
|
846
845
|
setActive(false);
|
|
847
|
-
onActiveChange
|
|
846
|
+
onActiveChange?.(false);
|
|
848
847
|
}
|
|
849
848
|
};
|
|
850
849
|
const dropdownClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
|
|
@@ -965,14 +964,13 @@ const ModalClose = ({ className, size = 'large', variant = 'delete', ...props })
|
|
|
965
964
|
return (jsxRuntime.jsx("button", { className: classes, "aria-label": "close", type: "button", ...props }));
|
|
966
965
|
};
|
|
967
966
|
const ModalRoot = ({ active, isActive, onClose, className, textColor, bgColor, modalCardTitle, modalCardFoot, type, children, ...props }) => {
|
|
968
|
-
var _a;
|
|
969
967
|
const { classPrefix } = useConfig();
|
|
970
968
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
971
969
|
color: textColor,
|
|
972
970
|
backgroundColor: bgColor,
|
|
973
971
|
...props,
|
|
974
972
|
});
|
|
975
|
-
const isModalActive =
|
|
973
|
+
const isModalActive = active ?? isActive ?? false;
|
|
976
974
|
const hasCompoundComponents = React.Children.toArray(children).some(child => React.isValidElement(child) &&
|
|
977
975
|
(child.type === ModalBackground ||
|
|
978
976
|
child.type === ModalContent ||
|
|
@@ -1033,13 +1031,12 @@ const NavbarItem = ({ className, as: Component = 'a', active, textColor, bgColor
|
|
|
1033
1031
|
}), bulmaHelperClasses, className), ...rest, children: children }));
|
|
1034
1032
|
};
|
|
1035
1033
|
const NavbarBurger = ({ className, active, children, ...props }) => {
|
|
1036
|
-
var _a;
|
|
1037
1034
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
1038
1035
|
...props,
|
|
1039
1036
|
});
|
|
1040
1037
|
return (jsxRuntime.jsxs("button", { type: "button", className: classNames(usePrefixedClassNames('navbar-burger', {
|
|
1041
1038
|
'is-active': active,
|
|
1042
|
-
}), bulmaHelperClasses, className), "aria-label": props['aria-label'] || 'menu', "aria-expanded":
|
|
1039
|
+
}), bulmaHelperClasses, className), "aria-label": props['aria-label'] || 'menu', "aria-expanded": props['aria-expanded'] ?? !!active, ...rest, children: [jsxRuntime.jsx("span", { "aria-hidden": "true" }), jsxRuntime.jsx("span", { "aria-hidden": "true" }), jsxRuntime.jsx("span", { "aria-hidden": "true" }), children] }));
|
|
1043
1040
|
};
|
|
1044
1041
|
const NavbarMenu = ({ className, active, children, ...props }) => {
|
|
1045
1042
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
@@ -1161,9 +1158,9 @@ Pagination.Previous = PaginationPrevious;
|
|
|
1161
1158
|
Pagination.Next = PaginationNext;
|
|
1162
1159
|
|
|
1163
1160
|
function getIconClasses(library, name, variant, features) {
|
|
1164
|
-
let baseClass
|
|
1165
|
-
let iconClass
|
|
1166
|
-
|
|
1161
|
+
let baseClass;
|
|
1162
|
+
let iconClass;
|
|
1163
|
+
const featureList = Array.isArray(features)
|
|
1167
1164
|
? features
|
|
1168
1165
|
: features
|
|
1169
1166
|
? [features]
|
|
@@ -1353,7 +1350,7 @@ const Tabs = ({ align, size, fullwidth, boxed, toggle, rounded, color, value, on
|
|
|
1353
1350
|
if (!isControlled) {
|
|
1354
1351
|
setInternalTab(index);
|
|
1355
1352
|
}
|
|
1356
|
-
onChange
|
|
1353
|
+
onChange?.(index);
|
|
1357
1354
|
}, [isControlled, onChange]);
|
|
1358
1355
|
const contextValue = { activeTab, setActiveTab };
|
|
1359
1356
|
const tabsClasses = usePrefixedClassNames('tabs', {
|
|
@@ -1488,7 +1485,8 @@ const Collapse = ({ open: controlledOpen, defaultOpen = false, onOpen, onClose,
|
|
|
1488
1485
|
const isControlled = controlledOpen !== undefined;
|
|
1489
1486
|
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
1490
1487
|
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
1491
|
-
const
|
|
1488
|
+
const generatedId = React.useId();
|
|
1489
|
+
const uniqueId = ariaId || generatedId;
|
|
1492
1490
|
React.useEffect(() => {
|
|
1493
1491
|
if (!contentRef.current)
|
|
1494
1492
|
return undefined;
|
|
@@ -1522,10 +1520,10 @@ const Collapse = ({ open: controlledOpen, defaultOpen = false, onOpen, onClose,
|
|
|
1522
1520
|
const newOpen = !internalOpen;
|
|
1523
1521
|
setInternalOpen(newOpen);
|
|
1524
1522
|
if (newOpen) {
|
|
1525
|
-
onOpen
|
|
1523
|
+
onOpen?.();
|
|
1526
1524
|
}
|
|
1527
1525
|
else {
|
|
1528
|
-
onClose
|
|
1526
|
+
onClose?.();
|
|
1529
1527
|
}
|
|
1530
1528
|
}
|
|
1531
1529
|
}, [isControlled, internalOpen, onOpen, onClose]);
|
|
@@ -1565,8 +1563,8 @@ const Collapse = ({ open: controlledOpen, defaultOpen = false, onOpen, onClose,
|
|
|
1565
1563
|
display: isOpen ? 'block' : 'none',
|
|
1566
1564
|
};
|
|
1567
1565
|
}
|
|
1568
|
-
const triggerElement = (jsxRuntime.jsx("div", { className: combinedTriggerClasses, onClick: handleToggle, onKeyDown: handleKeyDown, role: "button", tabIndex: 0, "aria-expanded": isOpen, "aria-controls": uniqueId
|
|
1569
|
-
const contentElement = (jsxRuntime.jsx("div", { style: contentWrapperStyle, children: jsxRuntime.jsx("div", { ref: contentRef, id: uniqueId
|
|
1566
|
+
const triggerElement = (jsxRuntime.jsx("div", { className: combinedTriggerClasses, onClick: handleToggle, onKeyDown: handleKeyDown, role: "button", tabIndex: 0, "aria-expanded": isOpen, "aria-controls": uniqueId, children: trigger }));
|
|
1567
|
+
const contentElement = (jsxRuntime.jsx("div", { style: contentWrapperStyle, children: jsxRuntime.jsx("div", { ref: contentRef, id: uniqueId, className: combinedContentClasses, "aria-hidden": !isOpen, children: children }) }));
|
|
1570
1568
|
return (jsxRuntime.jsx("div", { className: combinedClasses, ...rest, children: position === 'bottom' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [contentElement, triggerElement] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [triggerElement, contentElement] })) }));
|
|
1571
1569
|
};
|
|
1572
1570
|
|
|
@@ -1744,7 +1742,7 @@ const Step = ({ isActive = false, isCompleted = false, label, icon, clickable =
|
|
|
1744
1742
|
const markerContent = icon ||
|
|
1745
1743
|
(isCompleted && resolvedCompletedIcon
|
|
1746
1744
|
? resolvedCompletedIcon
|
|
1747
|
-
: (stepNumber
|
|
1745
|
+
: (stepNumber ?? null));
|
|
1748
1746
|
return (jsxRuntime.jsx("li", { className: stepClasses, onClick: handleClick, onKeyDown: handleKeyDown, tabIndex: clickable ? 0 : undefined, role: clickable ? 'button' : undefined, "aria-current": isActive ? 'step' : undefined, ...rest, children: jsxRuntime.jsxs("div", { className: "steps-link", children: [jsxRuntime.jsx("span", { className: "steps-marker", children: markerContent }), (label || children) && (jsxRuntime.jsx("div", { className: "steps-content", children: jsxRuntime.jsx("p", { className: "steps-title", children: label || children }) }))] }) }));
|
|
1749
1747
|
};
|
|
1750
1748
|
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 }) => {
|
|
@@ -1785,7 +1783,7 @@ const Steps = ({ value = 0, items, size, color, hasMarker = true, animated = tru
|
|
|
1785
1783
|
}
|
|
1786
1784
|
return null;
|
|
1787
1785
|
};
|
|
1788
|
-
return (jsxRuntime.jsxs("div", { className: combinedClasses, ...rest, children: [jsxRuntime.jsx("ul", { className: listClasses, children: renderSteps() }), hasNavigation && (jsxRuntime.jsxs("div", { className: "steps-navigation", children: [jsxRuntime.jsx("button", { className: "button", disabled: value === 0, onClick: onPrev
|
|
1786
|
+
return (jsxRuntime.jsxs("div", { className: combinedClasses, ...rest, children: [jsxRuntime.jsx("ul", { className: listClasses, children: renderSteps() }), hasNavigation && (jsxRuntime.jsxs("div", { className: "steps-navigation", children: [jsxRuntime.jsx("button", { className: "button", disabled: value === 0, onClick: onPrev ?? (() => onStepClick?.(value - 1)), children: prevLabel ?? 'Previous' }), jsxRuntime.jsx("button", { className: "button is-primary", disabled: value === totalSteps - 1, onClick: onNext ?? (() => onStepClick?.(value + 1)), children: nextLabel ?? 'Next' })] }))] }));
|
|
1789
1787
|
};
|
|
1790
1788
|
Steps.Step = Step;
|
|
1791
1789
|
|
|
@@ -1906,10 +1904,10 @@ const Toast = React.forwardRef(({ message, type = 'default', actionType, positio
|
|
|
1906
1904
|
const toastRef = React.useRef(null);
|
|
1907
1905
|
const handleClose = React.useCallback(() => {
|
|
1908
1906
|
setIsVisible(false);
|
|
1909
|
-
onClose
|
|
1907
|
+
onClose?.();
|
|
1910
1908
|
}, [onClose]);
|
|
1911
1909
|
const handleAction = React.useCallback(() => {
|
|
1912
|
-
onAction
|
|
1910
|
+
onAction?.();
|
|
1913
1911
|
handleClose();
|
|
1914
1912
|
}, [onAction, handleClose]);
|
|
1915
1913
|
React.useEffect(() => {
|
|
@@ -2096,11 +2094,11 @@ const Dialog = React.forwardRef(({ isOpen, title, message, type = 'default', con
|
|
|
2096
2094
|
const cancelRef = React.useRef(null);
|
|
2097
2095
|
const handleCancel = React.useCallback(() => {
|
|
2098
2096
|
if (canCancel) {
|
|
2099
|
-
onCancel
|
|
2097
|
+
onCancel?.();
|
|
2100
2098
|
}
|
|
2101
2099
|
}, [canCancel, onCancel]);
|
|
2102
2100
|
const handleConfirm = React.useCallback(() => {
|
|
2103
|
-
onConfirm
|
|
2101
|
+
onConfirm?.();
|
|
2104
2102
|
}, [onConfirm]);
|
|
2105
2103
|
const handleBackgroundClick = React.useCallback(() => {
|
|
2106
2104
|
if (canCancel) {
|
|
@@ -2121,7 +2119,7 @@ const Dialog = React.forwardRef(({ isOpen, title, message, type = 'default', con
|
|
|
2121
2119
|
React.useEffect(() => {
|
|
2122
2120
|
if (isOpen) {
|
|
2123
2121
|
const buttonToFocus = focusCancel && showCancel ? cancelRef.current : confirmRef.current;
|
|
2124
|
-
buttonToFocus
|
|
2122
|
+
buttonToFocus?.focus();
|
|
2125
2123
|
}
|
|
2126
2124
|
}, [isOpen, focusCancel, showCancel]);
|
|
2127
2125
|
React.useEffect(() => {
|
|
@@ -2321,7 +2319,7 @@ const Carousel = React.forwardRef(({ value: controlledValue, autoplay = false, i
|
|
|
2321
2319
|
if (syncDisplay) {
|
|
2322
2320
|
setDisplayIndex(newIndex);
|
|
2323
2321
|
}
|
|
2324
|
-
onChange
|
|
2322
|
+
onChange?.(newIndex);
|
|
2325
2323
|
}, [controlledValue, itemCount, repeat, onChange]);
|
|
2326
2324
|
const goToPrev = React.useCallback(() => {
|
|
2327
2325
|
if (activeIndex === 0 && repeat && itemCount > 1) {
|
|
@@ -2409,8 +2407,7 @@ const Carousel = React.forwardRef(({ value: controlledValue, autoplay = false, i
|
|
|
2409
2407
|
}, [handleDragEnd]);
|
|
2410
2408
|
React.useEffect(() => {
|
|
2411
2409
|
const handleKeyDown = (e) => {
|
|
2412
|
-
|
|
2413
|
-
if (!((_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)))
|
|
2410
|
+
if (!carouselRef.current?.contains(document.activeElement))
|
|
2414
2411
|
return;
|
|
2415
2412
|
switch (e.key) {
|
|
2416
2413
|
case 'ArrowLeft':
|
|
@@ -3116,17 +3113,16 @@ const Checkbox = React.forwardRef(({ color, size, className, children, textColor
|
|
|
3116
3113
|
...props,
|
|
3117
3114
|
});
|
|
3118
3115
|
const group = useCheckboxesGroup();
|
|
3119
|
-
const effectiveName = name
|
|
3120
|
-
const groupManaged =
|
|
3116
|
+
const effectiveName = name ?? group?.name;
|
|
3117
|
+
const groupManaged = group?.value !== undefined && value !== undefined;
|
|
3121
3118
|
const groupHas = groupManaged && group.value.includes(String(value));
|
|
3122
3119
|
const effectiveChecked = checked !== undefined ? checked : groupManaged ? groupHas : undefined;
|
|
3123
3120
|
const effectiveDefaultChecked = groupManaged ? undefined : defaultChecked;
|
|
3124
3121
|
const handleChange = React.useCallback((e) => {
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
if ((group === null || group === void 0 ? void 0 : group.onChange) && value !== undefined) {
|
|
3122
|
+
onChange?.(e);
|
|
3123
|
+
if (group?.onChange && value !== undefined) {
|
|
3128
3124
|
const valStr = String(value);
|
|
3129
|
-
const currentArr =
|
|
3125
|
+
const currentArr = group.value ?? [];
|
|
3130
3126
|
const next = e.target.checked
|
|
3131
3127
|
? currentArr.includes(valStr)
|
|
3132
3128
|
? currentArr
|
|
@@ -3187,29 +3183,23 @@ const Field = ({ horizontal, grouped, hasAddons, narrow, label, labelSize, label
|
|
|
3187
3183
|
'is-grouped-multiline': grouped === 'multiline',
|
|
3188
3184
|
});
|
|
3189
3185
|
const fieldClass = classNames(mainClass, bulmaHelperClasses, className);
|
|
3190
|
-
const effectiveLabelSize = labelSize
|
|
3186
|
+
const effectiveLabelSize = labelSize ?? (horizontal ? 'normal' : undefined);
|
|
3191
3187
|
const labelClass = usePrefixedClassNames('label');
|
|
3192
3188
|
let renderedLabel = null;
|
|
3193
3189
|
if (label) {
|
|
3194
3190
|
if (horizontal) {
|
|
3195
|
-
renderedLabel = (jsxRuntime.jsx(FieldLabel, { size: effectiveLabelSize, children: jsxRuntime.jsx("label", { ...labelProps, className: classNames(labelClass, labelProps
|
|
3191
|
+
renderedLabel = (jsxRuntime.jsx(FieldLabel, { size: effectiveLabelSize, children: jsxRuntime.jsx("label", { ...labelProps, className: classNames(labelClass, labelProps?.className), style: labelProps?.style, children: label }) }));
|
|
3196
3192
|
}
|
|
3197
3193
|
else {
|
|
3198
|
-
renderedLabel = (jsxRuntime.jsx("label", { ...labelProps, className: classNames(labelClass, labelProps
|
|
3194
|
+
renderedLabel = (jsxRuntime.jsx("label", { ...labelProps, className: classNames(labelClass, labelProps?.className), style: { display: 'block', ...(labelProps?.style || {}) }, children: label }));
|
|
3199
3195
|
}
|
|
3200
3196
|
}
|
|
3201
3197
|
let content = children;
|
|
3202
3198
|
if (horizontal) {
|
|
3203
|
-
const isFieldBody = (c) =>
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
};
|
|
3208
|
-
const isFieldLabel = (c) => {
|
|
3209
|
-
var _a;
|
|
3210
|
-
return React.isValidElement(c) &&
|
|
3211
|
-
(c.type === FieldLabel || ((_a = c.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'FieldLabel');
|
|
3212
|
-
};
|
|
3199
|
+
const isFieldBody = (c) => React.isValidElement(c) &&
|
|
3200
|
+
(c.type === FieldBody || c.type?.displayName === 'FieldBody');
|
|
3201
|
+
const isFieldLabel = (c) => React.isValidElement(c) &&
|
|
3202
|
+
(c.type === FieldLabel || c.type?.displayName === 'FieldLabel');
|
|
3213
3203
|
const childArray = React.Children.toArray(children);
|
|
3214
3204
|
const userProvidedStructure = childArray.some(c => isFieldBody(c) || isFieldLabel(c));
|
|
3215
3205
|
if (userProvidedStructure) {
|
|
@@ -3287,7 +3277,7 @@ const Checkboxes = ({ label, labelSize, labelProps, horizontal, message, message
|
|
|
3287
3277
|
const handleChange = React.useCallback((newValues) => {
|
|
3288
3278
|
if (!isControlled)
|
|
3289
3279
|
setInternalValue(newValues);
|
|
3290
|
-
onChange
|
|
3280
|
+
onChange?.(newValues);
|
|
3291
3281
|
}, [isControlled, onChange]);
|
|
3292
3282
|
const ctx = React.useMemo(() => ({
|
|
3293
3283
|
name,
|
|
@@ -3356,8 +3346,8 @@ const Radio = React.forwardRef(({ color, size, className, children, textColor, d
|
|
|
3356
3346
|
...props,
|
|
3357
3347
|
});
|
|
3358
3348
|
const group = useRadiosGroup();
|
|
3359
|
-
const effectiveName = name
|
|
3360
|
-
const groupManaged =
|
|
3349
|
+
const effectiveName = name ?? group?.name;
|
|
3350
|
+
const groupManaged = group?.value !== undefined && value !== undefined;
|
|
3361
3351
|
const effectiveChecked = checked !== undefined
|
|
3362
3352
|
? checked
|
|
3363
3353
|
: groupManaged
|
|
@@ -3365,8 +3355,8 @@ const Radio = React.forwardRef(({ color, size, className, children, textColor, d
|
|
|
3365
3355
|
: undefined;
|
|
3366
3356
|
const effectiveDefaultChecked = groupManaged ? undefined : defaultChecked;
|
|
3367
3357
|
const handleChange = React.useCallback((e) => {
|
|
3368
|
-
onChange
|
|
3369
|
-
if (
|
|
3358
|
+
onChange?.(e);
|
|
3359
|
+
if (group?.onChange && value !== undefined) {
|
|
3370
3360
|
group.onChange(String(value));
|
|
3371
3361
|
}
|
|
3372
3362
|
}, [onChange, group, value]);
|
|
@@ -3398,7 +3388,7 @@ const Radios = ({ label, labelSize, labelProps, horizontal, message, messageColo
|
|
|
3398
3388
|
const handleChange = React.useCallback((newValue) => {
|
|
3399
3389
|
if (!isControlled)
|
|
3400
3390
|
setInternalValue(newValue);
|
|
3401
|
-
onChange
|
|
3391
|
+
onChange?.(newValue);
|
|
3402
3392
|
}, [isControlled, onChange]);
|
|
3403
3393
|
const ctx = React.useMemo(() => ({
|
|
3404
3394
|
name,
|
|
@@ -3464,7 +3454,6 @@ function getTickPositions(min, max, step, ticks, marks) {
|
|
|
3464
3454
|
return positions;
|
|
3465
3455
|
}
|
|
3466
3456
|
const Slider = React.forwardRef((props, ref) => {
|
|
3467
|
-
var _a, _b, _c;
|
|
3468
3457
|
let range;
|
|
3469
3458
|
let controlledValue;
|
|
3470
3459
|
let defaultValue;
|
|
@@ -3479,7 +3468,7 @@ const Slider = React.forwardRef((props, ref) => {
|
|
|
3479
3468
|
defaultValue = props.defaultValue;
|
|
3480
3469
|
onChange = props.onChange;
|
|
3481
3470
|
ariaLabel = props.ariaLabel;
|
|
3482
|
-
minDistance =
|
|
3471
|
+
minDistance = props.minDistance ?? 0;
|
|
3483
3472
|
nameLow = props.nameLow;
|
|
3484
3473
|
nameHigh = props.nameHigh;
|
|
3485
3474
|
}
|
|
@@ -3494,9 +3483,9 @@ const Slider = React.forwardRef((props, ref) => {
|
|
|
3494
3483
|
const insideField = useInsideField();
|
|
3495
3484
|
const insideControl = useInsideControl();
|
|
3496
3485
|
const { bulmaHelperClasses, rest } = useBulmaClasses(restProps);
|
|
3497
|
-
const tooltipMode = tooltip
|
|
3498
|
-
const [internalRange, setInternalRange] = React.useState(() =>
|
|
3499
|
-
const [internalSingle, setInternalSingle] = React.useState(() =>
|
|
3486
|
+
const tooltipMode = tooltip ?? (showOutput ? 'auto' : 'hidden');
|
|
3487
|
+
const [internalRange, setInternalRange] = React.useState(() => range ? (defaultValue ?? [min, max]) : [min, min]);
|
|
3488
|
+
const [internalSingle, setInternalSingle] = React.useState(() => !range ? (defaultValue ?? 0) : 0);
|
|
3500
3489
|
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
3501
3490
|
const [showTooltipHigh, setShowTooltipHigh] = React.useState(false);
|
|
3502
3491
|
const inputRef = React.useRef(null);
|
|
@@ -3538,7 +3527,7 @@ const Slider = React.forwardRef((props, ref) => {
|
|
|
3538
3527
|
const newValue = parseFloat(e.target.value);
|
|
3539
3528
|
if (!isControlled)
|
|
3540
3529
|
setInternalSingle(newValue);
|
|
3541
|
-
onChange
|
|
3530
|
+
onChange?.(newValue);
|
|
3542
3531
|
}, [isControlled, onChange]);
|
|
3543
3532
|
const handleRangeLowChange = React.useCallback((e) => {
|
|
3544
3533
|
const raw = parseFloat(e.target.value);
|
|
@@ -3546,7 +3535,7 @@ const Slider = React.forwardRef((props, ref) => {
|
|
|
3546
3535
|
const newRange = [clamped, currentRange[1]];
|
|
3547
3536
|
if (!isControlled)
|
|
3548
3537
|
setInternalRange(newRange);
|
|
3549
|
-
onChange
|
|
3538
|
+
onChange?.(newRange);
|
|
3550
3539
|
}, [isControlled, onChange, currentRange, minDistance]);
|
|
3551
3540
|
const handleRangeHighChange = React.useCallback((e) => {
|
|
3552
3541
|
const raw = parseFloat(e.target.value);
|
|
@@ -3554,7 +3543,7 @@ const Slider = React.forwardRef((props, ref) => {
|
|
|
3554
3543
|
const newRange = [currentRange[0], clamped];
|
|
3555
3544
|
if (!isControlled)
|
|
3556
3545
|
setInternalRange(newRange);
|
|
3557
|
-
onChange
|
|
3546
|
+
onChange?.(newRange);
|
|
3558
3547
|
}, [isControlled, onChange, currentRange, minDistance]);
|
|
3559
3548
|
const handleKeyDown = React.useCallback((e) => {
|
|
3560
3549
|
if (e.key === 'Home') {
|
|
@@ -3562,7 +3551,7 @@ const Slider = React.forwardRef((props, ref) => {
|
|
|
3562
3551
|
if (!range) {
|
|
3563
3552
|
if (!isControlled)
|
|
3564
3553
|
setInternalSingle(min);
|
|
3565
|
-
onChange
|
|
3554
|
+
onChange?.(min);
|
|
3566
3555
|
}
|
|
3567
3556
|
}
|
|
3568
3557
|
else if (e.key === 'End') {
|
|
@@ -3570,7 +3559,7 @@ const Slider = React.forwardRef((props, ref) => {
|
|
|
3570
3559
|
if (!range) {
|
|
3571
3560
|
if (!isControlled)
|
|
3572
3561
|
setInternalSingle(max);
|
|
3573
|
-
onChange
|
|
3562
|
+
onChange?.(max);
|
|
3574
3563
|
}
|
|
3575
3564
|
}
|
|
3576
3565
|
}, [range, isControlled, onChange, min, max]);
|
|
@@ -3757,7 +3746,7 @@ const Slider = React.forwardRef((props, ref) => {
|
|
|
3757
3746
|
: {
|
|
3758
3747
|
'--slider-progress-low': `${progressLow}%`,
|
|
3759
3748
|
'--slider-progress-high': `${progressHigh}%`,
|
|
3760
|
-
} }), jsxRuntime.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":
|
|
3749
|
+
} }), jsxRuntime.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 } : {}) }), jsxRuntime.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' && (jsxRuntime.jsx("output", { ref: outputRef, className: classNames('slider-output slider-output-low', {
|
|
3761
3750
|
'is-visible': showTipLow,
|
|
3762
3751
|
'is-flipped': flipped,
|
|
3763
3752
|
'is-flipped-left': isVertical && verticalFlippedLeft,
|
|
@@ -3813,7 +3802,7 @@ const ArrowDropUp = () => (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "
|
|
|
3813
3802
|
const ArrowDropDown = () => (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M7 9.5l5 5 5-5" }) }));
|
|
3814
3803
|
const Numberinput = React.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) => {
|
|
3815
3804
|
const insideField = useInsideField();
|
|
3816
|
-
const effectiveBare = bare
|
|
3805
|
+
const effectiveBare = bare ?? insideField;
|
|
3817
3806
|
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
3818
3807
|
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
3819
3808
|
const inputRef = React.useRef(null);
|
|
@@ -3835,18 +3824,18 @@ const Numberinput = React.forwardRef(({ label, labelSize, labelProps, horizontal
|
|
|
3835
3824
|
if (!isControlled) {
|
|
3836
3825
|
setInternalValue(clampedValue);
|
|
3837
3826
|
}
|
|
3838
|
-
onChange
|
|
3827
|
+
onChange?.(clampedValue);
|
|
3839
3828
|
}, [isControlled, clampValue, onChange]);
|
|
3840
3829
|
const getEffectiveStep = React.useCallback(() => {
|
|
3841
3830
|
if (!exponential)
|
|
3842
3831
|
return step;
|
|
3843
|
-
return step * Math.max(1, Math.floor(Math.abs(currentValue
|
|
3832
|
+
return step * Math.max(1, Math.floor(Math.abs(currentValue ?? 0)));
|
|
3844
3833
|
}, [exponential, step, currentValue]);
|
|
3845
3834
|
const handleIncrement = React.useCallback(() => {
|
|
3846
|
-
updateValue((currentValue
|
|
3835
|
+
updateValue((currentValue ?? 0) + getEffectiveStep());
|
|
3847
3836
|
}, [currentValue, getEffectiveStep, updateValue]);
|
|
3848
3837
|
const handleDecrement = React.useCallback(() => {
|
|
3849
|
-
updateValue((currentValue
|
|
3838
|
+
updateValue((currentValue ?? 0) - getEffectiveStep());
|
|
3850
3839
|
}, [currentValue, getEffectiveStep, updateValue]);
|
|
3851
3840
|
const handleInputChange = React.useCallback((e) => {
|
|
3852
3841
|
const newValue = parseFloat(e.target.value);
|
|
@@ -3909,7 +3898,7 @@ const Numberinput = React.forwardRef(({ label, labelSize, labelProps, horizontal
|
|
|
3909
3898
|
ref.current = node;
|
|
3910
3899
|
}
|
|
3911
3900
|
};
|
|
3912
|
-
const inputControl = (jsxRuntime.jsx("div", { className: expandedControlClasses, children: jsxRuntime.jsx("input", { ref: combinedRef, type: "number", className: inputClasses, value: currentValue
|
|
3901
|
+
const inputControl = (jsxRuntime.jsx("div", { className: expandedControlClasses, children: jsxRuntime.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 }) }));
|
|
3913
3902
|
if (isStepper) {
|
|
3914
3903
|
const stepperElement = (jsxRuntime.jsxs("div", { className: combinedClasses, children: [inputControl, jsxRuntime.jsx("div", { className: controlClasses, children: jsxRuntime.jsxs("div", { className: stepperClasses, children: [jsxRuntime.jsx("button", { type: "button", className: stepperButtonClasses, onClick: handleIncrement, disabled: disabled || isAtMax, tabIndex: -1, "aria-label": "Increase value", children: jsxRuntime.jsx(ArrowDropUp, {}) }), jsxRuntime.jsx("button", { type: "button", className: stepperButtonClasses, onClick: handleDecrement, disabled: disabled || isAtMin, tabIndex: -1, "aria-label": "Decrease value", children: jsxRuntime.jsx(ArrowDropDown, {}) })] }) })] }));
|
|
3915
3904
|
if (!insideField) {
|
|
@@ -3977,7 +3966,7 @@ const Rate = React.forwardRef(({ label, labelSize, labelProps, horizontal, messa
|
|
|
3977
3966
|
if (!isControlled) {
|
|
3978
3967
|
setInternalValue(finalValue);
|
|
3979
3968
|
}
|
|
3980
|
-
onChange
|
|
3969
|
+
onChange?.(finalValue);
|
|
3981
3970
|
}, [isControlled, currentValue, disabled, onChange]);
|
|
3982
3971
|
const handleClick = React.useCallback((iconIndex, e) => {
|
|
3983
3972
|
if (disabled)
|
|
@@ -4042,7 +4031,7 @@ const Rate = React.forwardRef(({ label, labelSize, labelProps, horizontal, messa
|
|
|
4042
4031
|
if (!isControlled) {
|
|
4043
4032
|
setInternalValue(newValue);
|
|
4044
4033
|
}
|
|
4045
|
-
onChange
|
|
4034
|
+
onChange?.(newValue);
|
|
4046
4035
|
}
|
|
4047
4036
|
}, [currentValue, max, precision, disabled, isControlled, onChange]);
|
|
4048
4037
|
const getText = () => {
|
|
@@ -4092,7 +4081,7 @@ const Rate = React.forwardRef(({ label, labelSize, labelProps, horizontal, messa
|
|
|
4092
4081
|
const iconProps = {
|
|
4093
4082
|
index: iconIndex,
|
|
4094
4083
|
isActive: fillPercent > 0,
|
|
4095
|
-
isHovered: hoverValue !== null && iconIndex < (hoverValue
|
|
4084
|
+
isHovered: hoverValue !== null && iconIndex < (hoverValue ?? 0),
|
|
4096
4085
|
value: displayValue,
|
|
4097
4086
|
fillPercent,
|
|
4098
4087
|
};
|
|
@@ -4175,7 +4164,7 @@ const Autocomplete = React.forwardRef(({ data = [], value: controlledValue, plac
|
|
|
4175
4164
|
if (controlledValue === undefined) {
|
|
4176
4165
|
setInternalValue(newValue);
|
|
4177
4166
|
}
|
|
4178
|
-
onInput
|
|
4167
|
+
onInput?.(newValue);
|
|
4179
4168
|
if (!isActive && newValue) {
|
|
4180
4169
|
setIsActive(true);
|
|
4181
4170
|
}
|
|
@@ -4187,21 +4176,20 @@ const Autocomplete = React.forwardRef(({ data = [], value: controlledValue, plac
|
|
|
4187
4176
|
if (controlledValue === undefined) {
|
|
4188
4177
|
setInternalValue(displayValue);
|
|
4189
4178
|
}
|
|
4190
|
-
onInput
|
|
4191
|
-
onSelect
|
|
4179
|
+
onInput?.(displayValue);
|
|
4180
|
+
onSelect?.(item);
|
|
4192
4181
|
if (!keepOpen) {
|
|
4193
4182
|
setIsActive(false);
|
|
4194
4183
|
}
|
|
4195
4184
|
setHighlightedIndex(-1);
|
|
4196
4185
|
}, [controlledValue, field, keepOpen, onInput, onSelect]);
|
|
4197
4186
|
const handleClear = React.useCallback(() => {
|
|
4198
|
-
var _a;
|
|
4199
4187
|
if (controlledValue === undefined) {
|
|
4200
4188
|
setInternalValue('');
|
|
4201
4189
|
}
|
|
4202
|
-
onInput
|
|
4203
|
-
onSelect
|
|
4204
|
-
|
|
4190
|
+
onInput?.('');
|
|
4191
|
+
onSelect?.(null);
|
|
4192
|
+
inputRef.current?.focus();
|
|
4205
4193
|
}, [controlledValue, onInput, onSelect]);
|
|
4206
4194
|
const handleFocus = React.useCallback(() => {
|
|
4207
4195
|
if (openOnFocus && !disabled) {
|
|
@@ -4233,7 +4221,7 @@ const Autocomplete = React.forwardRef(({ data = [], value: controlledValue, plac
|
|
|
4233
4221
|
handleSelect,
|
|
4234
4222
|
]);
|
|
4235
4223
|
React.useEffect(() => {
|
|
4236
|
-
onActiveChange
|
|
4224
|
+
onActiveChange?.(isActive);
|
|
4237
4225
|
}, [isActive, onActiveChange]);
|
|
4238
4226
|
React.useEffect(() => {
|
|
4239
4227
|
if (keepFirst && isActive && filteredData.length > 0) {
|
|
@@ -4281,7 +4269,7 @@ const Autocomplete = React.forwardRef(({ data = [], value: controlledValue, plac
|
|
|
4281
4269
|
return;
|
|
4282
4270
|
const { scrollTop, scrollHeight, clientHeight } = dropdownRef.current;
|
|
4283
4271
|
if (scrollHeight - scrollTop - clientHeight <= infiniteScrollDistance) {
|
|
4284
|
-
onInfiniteScroll
|
|
4272
|
+
onInfiniteScroll?.();
|
|
4285
4273
|
}
|
|
4286
4274
|
}, [checkInfiniteScroll, infiniteScrollDistance, onInfiniteScroll]);
|
|
4287
4275
|
React.useEffect(() => {
|
|
@@ -4387,7 +4375,7 @@ const Taginput = React.forwardRef(({ label, labelSize, labelProps, horizontal, m
|
|
|
4387
4375
|
if (controlledValue === undefined) {
|
|
4388
4376
|
setInternalTags(newTags);
|
|
4389
4377
|
}
|
|
4390
|
-
onChange
|
|
4378
|
+
onChange?.(newTags);
|
|
4391
4379
|
}, [controlledValue, onChange]);
|
|
4392
4380
|
const addTag = React.useCallback((value) => {
|
|
4393
4381
|
if (disabled || readonly)
|
|
@@ -4411,7 +4399,7 @@ const Taginput = React.forwardRef(({ label, labelSize, labelProps, horizontal, m
|
|
|
4411
4399
|
const finalTag = createTag ? createTag(displayValue) : tagValue;
|
|
4412
4400
|
const newTags = [...tags, finalTag];
|
|
4413
4401
|
updateTags(newTags);
|
|
4414
|
-
onAdd
|
|
4402
|
+
onAdd?.(finalTag);
|
|
4415
4403
|
setInputValue('');
|
|
4416
4404
|
if (!keepOpen) {
|
|
4417
4405
|
setIsActive(false);
|
|
@@ -4438,7 +4426,7 @@ const Taginput = React.forwardRef(({ label, labelSize, labelProps, horizontal, m
|
|
|
4438
4426
|
const removedTag = tags[index];
|
|
4439
4427
|
const newTags = tags.filter((_, i) => i !== index);
|
|
4440
4428
|
updateTags(newTags);
|
|
4441
|
-
onRemove
|
|
4429
|
+
onRemove?.(removedTag, index);
|
|
4442
4430
|
}, [disabled, readonly, tags, updateTags, onRemove]);
|
|
4443
4431
|
const handleInputChange = React.useCallback((e) => {
|
|
4444
4432
|
const newValue = e.target.value;
|
|
@@ -4451,7 +4439,7 @@ const Taginput = React.forwardRef(({ label, labelSize, labelProps, horizontal, m
|
|
|
4451
4439
|
return;
|
|
4452
4440
|
}
|
|
4453
4441
|
setInputValue(newValue);
|
|
4454
|
-
onTyping
|
|
4442
|
+
onTyping?.(newValue);
|
|
4455
4443
|
if (newValue && data.length > 0) {
|
|
4456
4444
|
setIsActive(true);
|
|
4457
4445
|
}
|
|
@@ -4556,8 +4544,7 @@ const Taginput = React.forwardRef(({ label, labelSize, labelProps, horizontal, m
|
|
|
4556
4544
|
}
|
|
4557
4545
|
}, [ref]);
|
|
4558
4546
|
const handleContainerClick = React.useCallback(() => {
|
|
4559
|
-
|
|
4560
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
4547
|
+
inputRef.current?.focus();
|
|
4561
4548
|
}, []);
|
|
4562
4549
|
const taginputClasses = pcn('taginput', {
|
|
4563
4550
|
'is-active': isActive,
|
|
@@ -4765,7 +4752,7 @@ const DEFAULT_PICKER_LABELS = {
|
|
|
4765
4752
|
};
|
|
4766
4753
|
const mergeLabels = (overrides) => ({
|
|
4767
4754
|
...DEFAULT_PICKER_LABELS,
|
|
4768
|
-
...(overrides
|
|
4755
|
+
...(overrides ?? {}),
|
|
4769
4756
|
});
|
|
4770
4757
|
|
|
4771
4758
|
const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
|
|
@@ -4823,19 +4810,19 @@ function formatWithIntl(d, options, locale) {
|
|
|
4823
4810
|
return new Intl.DateTimeFormat(locale, options).format(d);
|
|
4824
4811
|
}
|
|
4825
4812
|
function formatDate(d, fmt, locale) {
|
|
4826
|
-
const f = fmt
|
|
4813
|
+
const f = fmt ?? DEFAULT_DATE_FORMAT;
|
|
4827
4814
|
if (typeof f === 'string')
|
|
4828
4815
|
return formatTokenString(d, f);
|
|
4829
4816
|
return formatWithIntl(d, f, locale);
|
|
4830
4817
|
}
|
|
4831
4818
|
function formatTime(d, fmt, locale) {
|
|
4832
|
-
const f = fmt
|
|
4819
|
+
const f = fmt ?? DEFAULT_TIME_FORMAT_24;
|
|
4833
4820
|
if (typeof f === 'string')
|
|
4834
4821
|
return formatTokenString(d, f);
|
|
4835
4822
|
return formatWithIntl(d, f, locale);
|
|
4836
4823
|
}
|
|
4837
4824
|
function formatDateTime(d, fmt, locale) {
|
|
4838
|
-
const f = fmt
|
|
4825
|
+
const f = fmt ?? DEFAULT_DATETIME_FORMAT;
|
|
4839
4826
|
if (typeof f === 'string')
|
|
4840
4827
|
return formatTokenString(d, f);
|
|
4841
4828
|
return formatWithIntl(d, f, locale);
|
|
@@ -4852,19 +4839,18 @@ function hourCycleFromFormat(fmt) {
|
|
|
4852
4839
|
return null;
|
|
4853
4840
|
}
|
|
4854
4841
|
function parseDate(s, fmt, _locale) {
|
|
4855
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4856
4842
|
if (!s)
|
|
4857
4843
|
return null;
|
|
4858
|
-
const format = fmt
|
|
4844
|
+
const format = fmt ?? DEFAULT_DATE_FORMAT;
|
|
4859
4845
|
const parts = parseTokens(s, format);
|
|
4860
4846
|
if (!parts)
|
|
4861
4847
|
return null;
|
|
4862
|
-
const year =
|
|
4863
|
-
const month = (
|
|
4864
|
-
const day =
|
|
4865
|
-
const hours =
|
|
4866
|
-
const minutes =
|
|
4867
|
-
const seconds =
|
|
4848
|
+
const year = parts.year ?? new Date().getFullYear();
|
|
4849
|
+
const month = (parts.month ?? 1) - 1;
|
|
4850
|
+
const day = parts.day ?? 1;
|
|
4851
|
+
const hours = parts.hours ?? 0;
|
|
4852
|
+
const minutes = parts.minutes ?? 0;
|
|
4853
|
+
const seconds = parts.seconds ?? 0;
|
|
4868
4854
|
const d = new Date(year, month, day, hours, minutes, seconds, 0);
|
|
4869
4855
|
if (d.getFullYear() !== year ||
|
|
4870
4856
|
d.getMonth() !== month ||
|
|
@@ -4874,15 +4860,14 @@ function parseDate(s, fmt, _locale) {
|
|
|
4874
4860
|
return d;
|
|
4875
4861
|
}
|
|
4876
4862
|
function parseTime(s, fmt) {
|
|
4877
|
-
var _a, _b, _c;
|
|
4878
4863
|
if (!s)
|
|
4879
4864
|
return null;
|
|
4880
|
-
const format = fmt
|
|
4865
|
+
const format = fmt ?? DEFAULT_TIME_FORMAT_24;
|
|
4881
4866
|
const parts = parseTokens(s, format);
|
|
4882
4867
|
if (!parts)
|
|
4883
4868
|
return null;
|
|
4884
4869
|
const today = new Date();
|
|
4885
|
-
return new Date(today.getFullYear(), today.getMonth(), today.getDate(),
|
|
4870
|
+
return new Date(today.getFullYear(), today.getMonth(), today.getDate(), parts.hours ?? 0, parts.minutes ?? 0, parts.seconds ?? 0, 0);
|
|
4886
4871
|
}
|
|
4887
4872
|
function escapeRegExp(s) {
|
|
4888
4873
|
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
@@ -5156,9 +5141,9 @@ const Calendar = ({ value, focusedDate, onSelect, onFocusedDateChange, min, max,
|
|
|
5156
5141
|
const isDateUnselectable = React.useCallback((d) => {
|
|
5157
5142
|
if (!isWithin(d, min, max))
|
|
5158
5143
|
return true;
|
|
5159
|
-
if (shouldDisableDate
|
|
5144
|
+
if (shouldDisableDate?.(d))
|
|
5160
5145
|
return true;
|
|
5161
|
-
if (unselectableDates
|
|
5146
|
+
if (unselectableDates?.some(u => isSameDay(u, d)))
|
|
5162
5147
|
return true;
|
|
5163
5148
|
return false;
|
|
5164
5149
|
}, [min, max, shouldDisableDate, unselectableDates]);
|
|
@@ -5255,7 +5240,7 @@ const Calendar = ({ value, focusedDate, onSelect, onFocusedDateChange, min, max,
|
|
|
5255
5240
|
const focusedYear = focusedDate.getFullYear();
|
|
5256
5241
|
const minYear = min ? min.getFullYear() : focusedYear - 100;
|
|
5257
5242
|
const maxYear = max ? max.getFullYear() : focusedYear + 100;
|
|
5258
|
-
const [lo, hi] = yearsRange
|
|
5243
|
+
const [lo, hi] = yearsRange ?? [minYear, maxYear];
|
|
5259
5244
|
const start = Math.max(lo, minYear);
|
|
5260
5245
|
const end = Math.min(hi, maxYear);
|
|
5261
5246
|
const out = [];
|
|
@@ -5275,14 +5260,14 @@ const Calendar = ({ value, focusedDate, onSelect, onFocusedDateChange, min, max,
|
|
|
5275
5260
|
if (!autoFocusCell || !gridRef.current)
|
|
5276
5261
|
return;
|
|
5277
5262
|
const target = gridRef.current.querySelector('[data-focused="true"]');
|
|
5278
|
-
target
|
|
5263
|
+
target?.focus();
|
|
5279
5264
|
}, [autoFocusCell, focusedDate, view]);
|
|
5280
5265
|
React.useEffect(() => {
|
|
5281
5266
|
if (view !== 'years' || !yearGridRef.current)
|
|
5282
5267
|
return;
|
|
5283
5268
|
const sel = yearGridRef.current.querySelector('[data-focused-year="true"]');
|
|
5284
|
-
sel
|
|
5285
|
-
sel
|
|
5269
|
+
sel?.scrollIntoView({ block: 'center' });
|
|
5270
|
+
sel?.focus();
|
|
5286
5271
|
}, [view]);
|
|
5287
5272
|
const focusedYear = focusedDate.getFullYear();
|
|
5288
5273
|
const todayYear = new Date().getFullYear();
|
|
@@ -5341,13 +5326,12 @@ function useFocusTrap(containerRef, active, options = {}) {
|
|
|
5341
5326
|
? document.activeElement
|
|
5342
5327
|
: null;
|
|
5343
5328
|
const focusInitial = () => {
|
|
5344
|
-
|
|
5345
|
-
if (initialFocusRef === null || initialFocusRef === void 0 ? void 0 : initialFocusRef.current) {
|
|
5329
|
+
if (initialFocusRef?.current) {
|
|
5346
5330
|
initialFocusRef.current.focus();
|
|
5347
5331
|
return;
|
|
5348
5332
|
}
|
|
5349
5333
|
const focusables = Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter(el => !el.hasAttribute('disabled'));
|
|
5350
|
-
const target =
|
|
5334
|
+
const target = focusables[0] ?? container;
|
|
5351
5335
|
target.focus();
|
|
5352
5336
|
};
|
|
5353
5337
|
focusInitial();
|
|
@@ -5374,7 +5358,7 @@ function useFocusTrap(containerRef, active, options = {}) {
|
|
|
5374
5358
|
container.addEventListener('keydown', handleKeyDown);
|
|
5375
5359
|
return () => {
|
|
5376
5360
|
container.removeEventListener('keydown', handleKeyDown);
|
|
5377
|
-
if (restoreFocus &&
|
|
5361
|
+
if (restoreFocus && previouslyFocused?.focus) {
|
|
5378
5362
|
previouslyFocused.focus();
|
|
5379
5363
|
}
|
|
5380
5364
|
};
|
|
@@ -5748,13 +5732,12 @@ function setAmPm(currentDate, isPm) {
|
|
|
5748
5732
|
return next;
|
|
5749
5733
|
}
|
|
5750
5734
|
function segmentIndexAtCaret(map, caret) {
|
|
5751
|
-
var _a;
|
|
5752
5735
|
for (const idx of map.editable) {
|
|
5753
5736
|
const s = map.segments[idx];
|
|
5754
5737
|
if (caret >= s.start && caret <= s.end)
|
|
5755
5738
|
return idx;
|
|
5756
5739
|
}
|
|
5757
|
-
let bestIdx =
|
|
5740
|
+
let bestIdx = map.editable[0] ?? null;
|
|
5758
5741
|
let bestDist = Infinity;
|
|
5759
5742
|
for (const idx of map.editable) {
|
|
5760
5743
|
const s = map.segments[idx];
|
|
@@ -5774,8 +5757,8 @@ function useSegmentedEntry(params) {
|
|
|
5774
5757
|
const [activeSegmentIdx, setActiveSegmentIdx] = React.useState(null);
|
|
5775
5758
|
const typedDigitsRef = React.useRef('');
|
|
5776
5759
|
const segmentEditable = !!segmentMap && !!editable && !disabled && !readOnly;
|
|
5777
|
-
const segmentBaseDate = React.useCallback(() => value
|
|
5778
|
-
const isAllowed = React.useCallback((d) => isWithin(d, min, max) && !
|
|
5760
|
+
const segmentBaseDate = React.useCallback(() => value ?? makeBaseDate(), [value, makeBaseDate]);
|
|
5761
|
+
const isAllowed = React.useCallback((d) => isWithin(d, min, max) && !isBlocked?.(d), [min, max, isBlocked]);
|
|
5779
5762
|
const applyDateFromSegment = React.useCallback((next) => {
|
|
5780
5763
|
if (!isAllowed(next))
|
|
5781
5764
|
return;
|
|
@@ -5818,7 +5801,7 @@ function useSegmentedEntry(params) {
|
|
|
5818
5801
|
containerRef.current !== null &&
|
|
5819
5802
|
containerRef.current.contains(nextFocus);
|
|
5820
5803
|
if (stayingInPicker) {
|
|
5821
|
-
onBlur
|
|
5804
|
+
onBlur?.(e);
|
|
5822
5805
|
return;
|
|
5823
5806
|
}
|
|
5824
5807
|
setActiveSegmentIdx(null);
|
|
@@ -5830,7 +5813,7 @@ function useSegmentedEntry(params) {
|
|
|
5830
5813
|
else {
|
|
5831
5814
|
setText(value ? formatFn(value, format, locale) : '');
|
|
5832
5815
|
}
|
|
5833
|
-
onBlur
|
|
5816
|
+
onBlur?.(e);
|
|
5834
5817
|
}, [
|
|
5835
5818
|
containerRef,
|
|
5836
5819
|
tryParse,
|
|
@@ -5854,7 +5837,7 @@ function useSegmentedEntry(params) {
|
|
|
5854
5837
|
typedDigitsRef.current = '';
|
|
5855
5838
|
setActiveSegmentIdx(segmentMap.editable[0]);
|
|
5856
5839
|
}
|
|
5857
|
-
onFocus
|
|
5840
|
+
onFocus?.(e);
|
|
5858
5841
|
}, [
|
|
5859
5842
|
openOnFocus,
|
|
5860
5843
|
popover,
|
|
@@ -5872,18 +5855,17 @@ function useSegmentedEntry(params) {
|
|
|
5872
5855
|
onFocus,
|
|
5873
5856
|
]);
|
|
5874
5857
|
const handleClick = React.useCallback((e) => {
|
|
5875
|
-
var _a;
|
|
5876
5858
|
if (openOnFocus && popover && !disabled && !readOnly)
|
|
5877
5859
|
setOpen(true);
|
|
5878
5860
|
if (segmentEditable && segmentMap && inputRef.current) {
|
|
5879
|
-
const caret =
|
|
5861
|
+
const caret = inputRef.current.selectionStart ?? 0;
|
|
5880
5862
|
const idx = segmentIndexAtCaret(segmentMap, caret);
|
|
5881
5863
|
if (idx !== null && idx !== activeSegmentIdx) {
|
|
5882
5864
|
typedDigitsRef.current = '';
|
|
5883
5865
|
setActiveSegmentIdx(idx);
|
|
5884
5866
|
}
|
|
5885
5867
|
}
|
|
5886
|
-
onClick
|
|
5868
|
+
onClick?.(e);
|
|
5887
5869
|
}, [
|
|
5888
5870
|
openOnFocus,
|
|
5889
5871
|
popover,
|
|
@@ -6001,7 +5983,7 @@ function useSegmentedEntry(params) {
|
|
|
6001
5983
|
setOpen(false);
|
|
6002
5984
|
}
|
|
6003
5985
|
}
|
|
6004
|
-
onKeyDown
|
|
5986
|
+
onKeyDown?.(e);
|
|
6005
5987
|
}, [
|
|
6006
5988
|
inSegmentMode,
|
|
6007
5989
|
segmentMap,
|
|
@@ -6045,9 +6027,9 @@ const DateInputBase = React.forwardRef((props, ref) => {
|
|
|
6045
6027
|
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;
|
|
6046
6028
|
const t = mergeLabels(labels);
|
|
6047
6029
|
const isControlled = controlledValue !== undefined;
|
|
6048
|
-
const [internalValue, setInternalValue] = React.useState(defaultValue
|
|
6049
|
-
const value = isControlled ? (controlledValue
|
|
6050
|
-
const initialFocused = React.useMemo(() => clampDate(value
|
|
6030
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue ?? null);
|
|
6031
|
+
const value = isControlled ? (controlledValue ?? null) : internalValue;
|
|
6032
|
+
const initialFocused = React.useMemo(() => clampDate(value ?? new Date(), min, max), []);
|
|
6051
6033
|
const [focusedDate, setFocusedDate] = React.useState(initialFocused);
|
|
6052
6034
|
React.useEffect(() => {
|
|
6053
6035
|
setFocusedDate(prev => clampDate(prev, min, max));
|
|
@@ -6075,9 +6057,9 @@ const DateInputBase = React.forwardRef((props, ref) => {
|
|
|
6075
6057
|
if (prev === next)
|
|
6076
6058
|
return prev;
|
|
6077
6059
|
if (next)
|
|
6078
|
-
onOpen
|
|
6060
|
+
onOpen?.();
|
|
6079
6061
|
else
|
|
6080
|
-
onClose
|
|
6062
|
+
onClose?.();
|
|
6081
6063
|
return next;
|
|
6082
6064
|
});
|
|
6083
6065
|
}, [onOpen, onClose]);
|
|
@@ -6089,7 +6071,7 @@ const DateInputBase = React.forwardRef((props, ref) => {
|
|
|
6089
6071
|
setInternalValue(next);
|
|
6090
6072
|
if (next)
|
|
6091
6073
|
setFocusedDate(next);
|
|
6092
|
-
onChange
|
|
6074
|
+
onChange?.(next);
|
|
6093
6075
|
}, [isControlled, onChange]);
|
|
6094
6076
|
const handleSelect = React.useCallback((d) => {
|
|
6095
6077
|
if (!isWithin(d, min, max))
|
|
@@ -6106,7 +6088,7 @@ const DateInputBase = React.forwardRef((props, ref) => {
|
|
|
6106
6088
|
const fmt = typeof format === 'string' ? format : undefined;
|
|
6107
6089
|
return parse
|
|
6108
6090
|
? parse(trimmed)
|
|
6109
|
-
: parseDate(trimmed, fmt
|
|
6091
|
+
: parseDate(trimmed, fmt ?? DEFAULT_DATE_FORMAT);
|
|
6110
6092
|
}, [parse, format, locale]);
|
|
6111
6093
|
const makeBaseDate = React.useCallback(() => {
|
|
6112
6094
|
const d = new Date();
|
|
@@ -6116,13 +6098,13 @@ const DateInputBase = React.forwardRef((props, ref) => {
|
|
|
6116
6098
|
const inputReadOnlyAttr = !!readOnly || !editable;
|
|
6117
6099
|
const canOpen = !!popover && !disabled && !readOnly;
|
|
6118
6100
|
const isBlocked = React.useMemo(() => {
|
|
6119
|
-
if (!shouldDisableDate && !
|
|
6101
|
+
if (!shouldDisableDate && !unselectableDates?.length)
|
|
6120
6102
|
return undefined;
|
|
6121
|
-
return (d) => !!
|
|
6122
|
-
!!
|
|
6103
|
+
return (d) => !!shouldDisableDate?.(d) ||
|
|
6104
|
+
!!unselectableDates?.some(u => isSameDay(u, d));
|
|
6123
6105
|
}, [shouldDisableDate, unselectableDates]);
|
|
6124
6106
|
const { inputHandlers } = useSegmentedEntry({
|
|
6125
|
-
format: format
|
|
6107
|
+
format: format ?? DEFAULT_DATE_FORMAT,
|
|
6126
6108
|
value,
|
|
6127
6109
|
commitValue,
|
|
6128
6110
|
formatFn: formatDate,
|
|
@@ -6177,13 +6159,12 @@ const DateInputBase = React.forwardRef((props, ref) => {
|
|
|
6177
6159
|
DateInputBase.displayName = 'DateInputBase';
|
|
6178
6160
|
|
|
6179
6161
|
const DateInput = React.forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'calendar', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
6180
|
-
var _a;
|
|
6181
6162
|
const insideField = useInsideField();
|
|
6182
6163
|
const insideControl = useInsideControl();
|
|
6183
6164
|
const helpClass = usePrefixedClassNames('help', {
|
|
6184
6165
|
[`is-${messageColor}`]: !!messageColor,
|
|
6185
6166
|
});
|
|
6186
|
-
let content = (jsxRuntime.jsx(DateInputBase, { ref: ref, ...baseProps, triggerIcon:
|
|
6167
|
+
let content = (jsxRuntime.jsx(DateInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
6187
6168
|
if (!insideControl && !baseProps.inline) {
|
|
6188
6169
|
content = (jsxRuntime.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 }));
|
|
6189
6170
|
}
|
|
@@ -6208,11 +6189,10 @@ const tickHaptic = () => {
|
|
|
6208
6189
|
|
|
6209
6190
|
let audioCtx = null;
|
|
6210
6191
|
const getAudioContextCtor = () => {
|
|
6211
|
-
var _a, _b;
|
|
6212
6192
|
if (typeof window === 'undefined')
|
|
6213
6193
|
return null;
|
|
6214
6194
|
const w = window;
|
|
6215
|
-
return
|
|
6195
|
+
return w.AudioContext ?? w.webkitAudioContext ?? null;
|
|
6216
6196
|
};
|
|
6217
6197
|
const ensureAudioCtx = () => {
|
|
6218
6198
|
if (audioCtx)
|
|
@@ -6292,11 +6272,10 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6292
6272
|
const audioTickEnabledRef = React.useRef(audioTick);
|
|
6293
6273
|
audioTickEnabledRef.current = audioTick;
|
|
6294
6274
|
const playBandPulse = React.useCallback(() => {
|
|
6295
|
-
var _a;
|
|
6296
6275
|
const el = bandRef.current;
|
|
6297
6276
|
if (!el || typeof el.animate !== 'function')
|
|
6298
6277
|
return;
|
|
6299
|
-
if (
|
|
6278
|
+
if (reducedMotionMqlRef.current?.matches)
|
|
6300
6279
|
return;
|
|
6301
6280
|
pulseAnimRef.current = el.animate([
|
|
6302
6281
|
{ transform: 'scale(1)', filter: 'brightness(1)' },
|
|
@@ -6332,15 +6311,13 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6332
6311
|
}
|
|
6333
6312
|
}, []);
|
|
6334
6313
|
React.useEffect(() => () => {
|
|
6335
|
-
var _a;
|
|
6336
6314
|
cancelRaf();
|
|
6337
|
-
|
|
6315
|
+
pulseAnimRef.current?.cancel();
|
|
6338
6316
|
pulseAnimRef.current = null;
|
|
6339
6317
|
}, [cancelRaf]);
|
|
6340
6318
|
React.useImperativeHandle(ref, () => ({
|
|
6341
|
-
focus: () =>
|
|
6319
|
+
focus: () => rootRef.current?.focus(),
|
|
6342
6320
|
startDrag: (pointerId, clientY) => {
|
|
6343
|
-
var _a;
|
|
6344
6321
|
if (disabled)
|
|
6345
6322
|
return;
|
|
6346
6323
|
cancelRaf();
|
|
@@ -6355,7 +6332,7 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6355
6332
|
samples: [{ t: now, y: clientY }],
|
|
6356
6333
|
};
|
|
6357
6334
|
try {
|
|
6358
|
-
|
|
6335
|
+
rootRef.current?.setPointerCapture(pointerId);
|
|
6359
6336
|
}
|
|
6360
6337
|
catch {
|
|
6361
6338
|
}
|
|
@@ -6445,15 +6422,15 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6445
6422
|
break;
|
|
6446
6423
|
case 'ArrowLeft':
|
|
6447
6424
|
e.preventDefault();
|
|
6448
|
-
onFocusPrev
|
|
6425
|
+
onFocusPrev?.();
|
|
6449
6426
|
break;
|
|
6450
6427
|
case 'ArrowRight':
|
|
6451
6428
|
e.preventDefault();
|
|
6452
|
-
onFocusNext
|
|
6429
|
+
onFocusNext?.();
|
|
6453
6430
|
break;
|
|
6454
6431
|
case 'Enter':
|
|
6455
6432
|
e.preventDefault();
|
|
6456
|
-
onCommit
|
|
6433
|
+
onCommit?.();
|
|
6457
6434
|
break;
|
|
6458
6435
|
}
|
|
6459
6436
|
}, [
|
|
@@ -6579,7 +6556,6 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6579
6556
|
};
|
|
6580
6557
|
};
|
|
6581
6558
|
const onPointerMove = (e) => {
|
|
6582
|
-
var _a;
|
|
6583
6559
|
const s = dragStateRef.current;
|
|
6584
6560
|
if (s.pointerId !== e.pointerId)
|
|
6585
6561
|
return;
|
|
@@ -6587,7 +6563,7 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6587
6563
|
if (!s.captured) {
|
|
6588
6564
|
if (Math.abs(dy) < DRAG_THRESHOLD_PX)
|
|
6589
6565
|
return;
|
|
6590
|
-
|
|
6566
|
+
rootRef.current?.setPointerCapture(e.pointerId);
|
|
6591
6567
|
s.captured = true;
|
|
6592
6568
|
setIsDragging(true);
|
|
6593
6569
|
}
|
|
@@ -6600,13 +6576,12 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6600
6576
|
commitPosition(s.startPosition - dy / itemHeight);
|
|
6601
6577
|
};
|
|
6602
6578
|
const onPointerUp = (e) => {
|
|
6603
|
-
var _a, _b;
|
|
6604
6579
|
const s = dragStateRef.current;
|
|
6605
6580
|
if (s.pointerId !== e.pointerId)
|
|
6606
6581
|
return;
|
|
6607
6582
|
if (s.captured) {
|
|
6608
|
-
|
|
6609
|
-
|
|
6583
|
+
rootRef.current?.releasePointerCapture(e.pointerId);
|
|
6584
|
+
rootRef.current?.focus();
|
|
6610
6585
|
const samples = s.samples;
|
|
6611
6586
|
let pxPerMs = 0;
|
|
6612
6587
|
if (samples.length >= 2) {
|
|
@@ -6673,15 +6648,13 @@ const WheelInner = ({ values, index, onChange, formatLabel, formatAriaText, aria
|
|
|
6673
6648
|
height: itemHeight,
|
|
6674
6649
|
top: `${top}px`,
|
|
6675
6650
|
}, disabled: itemDisabled, onClick: () => {
|
|
6676
|
-
var _a;
|
|
6677
6651
|
moveBy(vIdx - virtualIdx);
|
|
6678
|
-
|
|
6652
|
+
rootRef.current?.focus();
|
|
6679
6653
|
}, children: formatLabel(values[aIdx]) }, vIdx));
|
|
6680
6654
|
})] }));
|
|
6681
6655
|
};
|
|
6682
6656
|
const Wheel = React.forwardRef(WheelInner);
|
|
6683
6657
|
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, }) => {
|
|
6684
|
-
var _a;
|
|
6685
6658
|
const t = mergeLabels(labels);
|
|
6686
6659
|
const rootClass = usePrefixedClassNames('timeinput', {
|
|
6687
6660
|
[`is-${color}`]: !!color,
|
|
@@ -6704,29 +6677,27 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6704
6677
|
return !unselectableTimes(probe);
|
|
6705
6678
|
}, [unselectableTimes]);
|
|
6706
6679
|
const isHourDisabled = React.useCallback((display) => {
|
|
6707
|
-
var _a;
|
|
6708
6680
|
let h24 = display;
|
|
6709
6681
|
if (hourFormat === '12') {
|
|
6710
6682
|
const base = display % 12;
|
|
6711
6683
|
h24 = isPm ? base + 12 : base;
|
|
6712
6684
|
}
|
|
6713
|
-
return !isTimeAllowed(h24, value.minutes,
|
|
6685
|
+
return !isTimeAllowed(h24, value.minutes, value.seconds ?? 0);
|
|
6714
6686
|
}, [hourFormat, isPm, isTimeAllowed, value.minutes, value.seconds]);
|
|
6715
|
-
const isMinuteDisabled = React.useCallback((m) =>
|
|
6687
|
+
const isMinuteDisabled = React.useCallback((m) => !isTimeAllowed(value.hours, m, value.seconds ?? 0), [isTimeAllowed, value.hours, value.seconds]);
|
|
6716
6688
|
const isSecondDisabled = React.useCallback((s) => !isTimeAllowed(value.hours, value.minutes, s), [isTimeAllowed, value.hours, value.minutes]);
|
|
6717
6689
|
const hourDisabledFor = unselectableTimes ? isHourDisabled : undefined;
|
|
6718
6690
|
const minuteDisabledFor = unselectableTimes ? isMinuteDisabled : undefined;
|
|
6719
6691
|
const secondDisabledFor = unselectableTimes ? isSecondDisabled : undefined;
|
|
6720
6692
|
const commit = React.useCallback((next) => {
|
|
6721
|
-
var _a, _b, _c, _d, _e;
|
|
6722
6693
|
const merged = {
|
|
6723
|
-
hours:
|
|
6724
|
-
minutes:
|
|
6694
|
+
hours: next.hours ?? value.hours,
|
|
6695
|
+
minutes: next.minutes ?? value.minutes,
|
|
6725
6696
|
seconds: enableSeconds
|
|
6726
|
-
? (
|
|
6697
|
+
? (next.seconds ?? value.seconds ?? 0)
|
|
6727
6698
|
: undefined,
|
|
6728
6699
|
};
|
|
6729
|
-
if (!isTimeAllowed(merged.hours, merged.minutes,
|
|
6700
|
+
if (!isTimeAllowed(merged.hours, merged.minutes, merged.seconds ?? 0)) {
|
|
6730
6701
|
return;
|
|
6731
6702
|
}
|
|
6732
6703
|
onChange(merged);
|
|
@@ -6765,7 +6736,7 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6765
6736
|
: value.hours;
|
|
6766
6737
|
const hourIndex = Math.max(0, hourValues.indexOf(displayedHours));
|
|
6767
6738
|
const minuteIndex = Math.max(0, minuteValues.indexOf(value.minutes));
|
|
6768
|
-
const secondIndex = Math.max(0, secondValues.indexOf(
|
|
6739
|
+
const secondIndex = Math.max(0, secondValues.indexOf(value.seconds ?? 0));
|
|
6769
6740
|
const ampmIndex = isPm ? 1 : 0;
|
|
6770
6741
|
const hoursRef = React.useRef(null);
|
|
6771
6742
|
const minutesRef = React.useRef(null);
|
|
@@ -6778,7 +6749,7 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6778
6749
|
columnOrder.push(secondsRef);
|
|
6779
6750
|
if (hourFormat === '12')
|
|
6780
6751
|
columnOrder.push(ampmRef);
|
|
6781
|
-
const focusAt = (i) =>
|
|
6752
|
+
const focusAt = (i) => columnOrder[i]?.current?.focus();
|
|
6782
6753
|
const indexOf = (r) => columnOrder.indexOf(r);
|
|
6783
6754
|
const focusPrevOf = (r) => () => focusAt(indexOf(r) - 1);
|
|
6784
6755
|
const focusNextOf = (r) => () => focusAt(indexOf(r) + 1);
|
|
@@ -6789,18 +6760,17 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6789
6760
|
const baseHour = display % 12;
|
|
6790
6761
|
next24 = isPm ? baseHour + 12 : baseHour;
|
|
6791
6762
|
}
|
|
6792
|
-
const allowed = nextValid(next24, next24 >= value.hours ? 1 : -1, 24, h =>
|
|
6763
|
+
const allowed = nextValid(next24, next24 >= value.hours ? 1 : -1, 24, h => isTimeAllowed(h, value.minutes, value.seconds ?? 0));
|
|
6793
6764
|
commit({ hours: allowed });
|
|
6794
6765
|
};
|
|
6795
6766
|
const onMinuteIndex = (next) => {
|
|
6796
6767
|
const m = minuteValues[Math.max(0, Math.min(minuteValues.length - 1, next))];
|
|
6797
|
-
const allowed = nextValid(m, m >= value.minutes ? 1 : -1, 60, mm =>
|
|
6768
|
+
const allowed = nextValid(m, m >= value.minutes ? 1 : -1, 60, mm => isTimeAllowed(value.hours, mm, value.seconds ?? 0));
|
|
6798
6769
|
commit({ minutes: allowed });
|
|
6799
6770
|
};
|
|
6800
6771
|
const onSecondIndex = (next) => {
|
|
6801
|
-
var _a;
|
|
6802
6772
|
const s = secondValues[Math.max(0, Math.min(secondValues.length - 1, next))];
|
|
6803
|
-
const allowed = nextValid(s, s >= (
|
|
6773
|
+
const allowed = nextValid(s, s >= (value.seconds ?? 0) ? 1 : -1, 60, ss => isTimeAllowed(value.hours, value.minutes, ss));
|
|
6804
6774
|
commit({ seconds: allowed });
|
|
6805
6775
|
};
|
|
6806
6776
|
const onAmpmIndex = (next) => {
|
|
@@ -6809,7 +6779,6 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6809
6779
|
commit({ hours: (value.hours + 12) % 24 });
|
|
6810
6780
|
};
|
|
6811
6781
|
const onWheelsContainerPointerDown = (e) => {
|
|
6812
|
-
var _a, _b;
|
|
6813
6782
|
if (disabled)
|
|
6814
6783
|
return;
|
|
6815
6784
|
if (e.target.closest(`.${wheelSingleClass}`))
|
|
@@ -6832,7 +6801,7 @@ const TimeWheels = ({ value, onChange, hourFormat = '24', enableSeconds = false,
|
|
|
6832
6801
|
nearestIdx = i;
|
|
6833
6802
|
}
|
|
6834
6803
|
});
|
|
6835
|
-
|
|
6804
|
+
columnOrder[nearestIdx]?.current?.startDrag(e.pointerId, e.clientY);
|
|
6836
6805
|
};
|
|
6837
6806
|
return (jsxRuntime.jsx("div", { id: id, className: classNames(rootClass, className), "aria-disabled": disabled, children: jsxRuntime.jsxs("div", { className: wheelsClass, ref: wheelsContainerRef, onPointerDown: onWheelsContainerPointerDown, children: [jsxRuntime.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 }), jsxRuntime.jsx("div", { className: sepClass, "aria-hidden": "true", children: ":" }), jsxRuntime.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 && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: sepClass, "aria-hidden": "true", children: ":" }), jsxRuntime.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' && (jsxRuntime.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 }))] }) }));
|
|
6838
6807
|
};
|
|
@@ -6854,23 +6823,23 @@ const fromIsoTime = (s) => {
|
|
|
6854
6823
|
return new Date(today.getFullYear(), today.getMonth(), today.getDate(), Number(m[1]), Number(m[2]), m[3] ? Number(m[3]) : 0, 0);
|
|
6855
6824
|
};
|
|
6856
6825
|
const TimeInputBase = React.forwardRef((props, ref) => {
|
|
6857
|
-
var _a, _b, _c, _d;
|
|
6858
6826
|
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;
|
|
6859
6827
|
const hasVibrate = typeof navigator !== 'undefined' &&
|
|
6860
6828
|
typeof navigator.vibrate === 'function';
|
|
6861
6829
|
const effectiveAudioTick = audioTick || (haptics && !hasVibrate);
|
|
6862
6830
|
const t = mergeLabels(labels);
|
|
6863
6831
|
const isControlled = controlledValue !== undefined;
|
|
6864
|
-
const [internalValue, setInternalValue] = React.useState(defaultValue
|
|
6865
|
-
const value = isControlled ? (controlledValue
|
|
6866
|
-
const defaultFormat = format
|
|
6867
|
-
|
|
6868
|
-
?
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6832
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue ?? null);
|
|
6833
|
+
const value = isControlled ? (controlledValue ?? null) : internalValue;
|
|
6834
|
+
const defaultFormat = format ??
|
|
6835
|
+
(hourFormat === '12'
|
|
6836
|
+
? enableSeconds
|
|
6837
|
+
? 'hh:mm:ss A'
|
|
6838
|
+
: DEFAULT_TIME_FORMAT_12
|
|
6839
|
+
: enableSeconds
|
|
6840
|
+
? 'HH:mm:ss'
|
|
6841
|
+
: DEFAULT_TIME_FORMAT_24);
|
|
6842
|
+
const effectiveHourFormat = hourCycleFromFormat(defaultFormat) ?? hourFormat;
|
|
6874
6843
|
const [open, setOpenState] = React.useState(false);
|
|
6875
6844
|
const [text, setText] = React.useState(value ? formatTime(value, defaultFormat, locale) : '');
|
|
6876
6845
|
const inputRef = React.useRef(null);
|
|
@@ -6904,10 +6873,10 @@ const TimeInputBase = React.forwardRef((props, ref) => {
|
|
|
6904
6873
|
return prev;
|
|
6905
6874
|
if (next) {
|
|
6906
6875
|
valueAtOpenRef.current = value;
|
|
6907
|
-
onOpen
|
|
6876
|
+
onOpen?.();
|
|
6908
6877
|
}
|
|
6909
6878
|
else {
|
|
6910
|
-
onClose
|
|
6879
|
+
onClose?.();
|
|
6911
6880
|
}
|
|
6912
6881
|
return next;
|
|
6913
6882
|
});
|
|
@@ -6918,10 +6887,10 @@ const TimeInputBase = React.forwardRef((props, ref) => {
|
|
|
6918
6887
|
const commitValue = React.useCallback((next) => {
|
|
6919
6888
|
if (!isControlled)
|
|
6920
6889
|
setInternalValue(next);
|
|
6921
|
-
onChange
|
|
6890
|
+
onChange?.(next);
|
|
6922
6891
|
}, [isControlled, onChange]);
|
|
6923
6892
|
const handleSpinnerChange = React.useCallback((parts) => {
|
|
6924
|
-
const base = value
|
|
6893
|
+
const base = value ?? new Date();
|
|
6925
6894
|
const next = setTimeOfDay(base, parts);
|
|
6926
6895
|
if (!isWithin(next, min, max))
|
|
6927
6896
|
return;
|
|
@@ -6934,9 +6903,10 @@ const TimeInputBase = React.forwardRef((props, ref) => {
|
|
|
6934
6903
|
const fmt = typeof format === 'string' ? format : undefined;
|
|
6935
6904
|
return parse
|
|
6936
6905
|
? parse(trimmed)
|
|
6937
|
-
: parseTime(trimmed, fmt
|
|
6938
|
-
|
|
6939
|
-
|
|
6906
|
+
: parseTime(trimmed, fmt ??
|
|
6907
|
+
(typeof defaultFormat === 'string'
|
|
6908
|
+
? defaultFormat
|
|
6909
|
+
: DEFAULT_TIME_FORMAT_24));
|
|
6940
6910
|
}, [parse, format, defaultFormat]);
|
|
6941
6911
|
const makeBaseDate = React.useCallback(() => {
|
|
6942
6912
|
const d = new Date();
|
|
@@ -6992,9 +6962,9 @@ const TimeInputBase = React.forwardRef((props, ref) => {
|
|
|
6992
6962
|
}, 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 }));
|
|
6993
6963
|
}
|
|
6994
6964
|
const spinnerValue = {
|
|
6995
|
-
hours:
|
|
6996
|
-
minutes:
|
|
6997
|
-
seconds: enableSeconds ? (
|
|
6965
|
+
hours: value?.getHours() ?? 0,
|
|
6966
|
+
minutes: value?.getMinutes() ?? 0,
|
|
6967
|
+
seconds: enableSeconds ? (value?.getSeconds() ?? 0) : undefined,
|
|
6998
6968
|
};
|
|
6999
6969
|
const panel = (jsxRuntime.jsxs("div", { className: panelClass, children: [jsxRuntime.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 && (jsxRuntime.jsxs(Buttons, { className: footerClass, hasAddons: true, children: [jsxRuntime.jsx("button", { type: "button", className: footerOkClass, onClick: () => setOpen(false), children: t.ok }), jsxRuntime.jsx("button", { type: "button", className: footerButton, onClick: () => {
|
|
7000
6970
|
commitValue(snapTimeToIncrement(new Date(), {
|
|
@@ -7022,13 +6992,12 @@ const TimeInputBase = React.forwardRef((props, ref) => {
|
|
|
7022
6992
|
TimeInputBase.displayName = 'TimeInputBase';
|
|
7023
6993
|
|
|
7024
6994
|
const TimeInput = React.forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'clock', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
7025
|
-
var _a;
|
|
7026
6995
|
const insideField = useInsideField();
|
|
7027
6996
|
const insideControl = useInsideControl();
|
|
7028
6997
|
const helpClass = usePrefixedClassNames('help', {
|
|
7029
6998
|
[`is-${messageColor}`]: !!messageColor,
|
|
7030
6999
|
});
|
|
7031
|
-
let content = (jsxRuntime.jsx(TimeInputBase, { ref: ref, ...baseProps, triggerIcon:
|
|
7000
|
+
let content = (jsxRuntime.jsx(TimeInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
7032
7001
|
if (!insideControl && !baseProps.inline) {
|
|
7033
7002
|
content = (jsxRuntime.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 }));
|
|
7034
7003
|
}
|
|
@@ -7058,27 +7027,27 @@ const fromIsoDateTime = (s) => {
|
|
|
7058
7027
|
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);
|
|
7059
7028
|
};
|
|
7060
7029
|
const DateTimeInputBase = React.forwardRef((props, ref) => {
|
|
7061
|
-
var _a, _b, _c, _d;
|
|
7062
7030
|
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;
|
|
7063
7031
|
const t = mergeLabels(labels);
|
|
7064
7032
|
const hasVibrate = typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function';
|
|
7065
7033
|
const effectiveAudioTick = audioTick || (haptics && !hasVibrate);
|
|
7066
7034
|
const isControlled = controlledValue !== undefined;
|
|
7067
|
-
const [internalValue, setInternalValue] = React.useState(defaultValue
|
|
7068
|
-
const value = isControlled ? (controlledValue
|
|
7069
|
-
const initialFocused = React.useMemo(() => clampDate(value
|
|
7035
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue ?? null);
|
|
7036
|
+
const value = isControlled ? (controlledValue ?? null) : internalValue;
|
|
7037
|
+
const initialFocused = React.useMemo(() => clampDate(value ?? new Date(), min, max), []);
|
|
7070
7038
|
const [focusedDate, setFocusedDate] = React.useState(initialFocused);
|
|
7071
7039
|
React.useEffect(() => {
|
|
7072
7040
|
setFocusedDate(prev => clampDate(prev, min, max));
|
|
7073
7041
|
}, [min, max]);
|
|
7074
|
-
const defaultFormat = format
|
|
7075
|
-
|
|
7076
|
-
?
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7042
|
+
const defaultFormat = format ??
|
|
7043
|
+
(hourFormat === '12'
|
|
7044
|
+
? enableSeconds
|
|
7045
|
+
? 'YYYY-MM-DD hh:mm:ss A'
|
|
7046
|
+
: 'YYYY-MM-DD hh:mm A'
|
|
7047
|
+
: enableSeconds
|
|
7048
|
+
? 'YYYY-MM-DD HH:mm:ss'
|
|
7049
|
+
: DEFAULT_DATETIME_FORMAT);
|
|
7050
|
+
const effectiveHourFormat = hourCycleFromFormat(defaultFormat) ?? hourFormat;
|
|
7082
7051
|
const [open, setOpenState] = React.useState(false);
|
|
7083
7052
|
const [timeOpen, setTimeOpen] = React.useState(false);
|
|
7084
7053
|
const [text, setText] = React.useState(value ? formatDateTime(value, defaultFormat, locale) : '');
|
|
@@ -7123,10 +7092,10 @@ const DateTimeInputBase = React.forwardRef((props, ref) => {
|
|
|
7123
7092
|
return prev;
|
|
7124
7093
|
if (next) {
|
|
7125
7094
|
valueAtOpenRef.current = value;
|
|
7126
|
-
onOpen
|
|
7095
|
+
onOpen?.();
|
|
7127
7096
|
}
|
|
7128
7097
|
else {
|
|
7129
|
-
onClose
|
|
7098
|
+
onClose?.();
|
|
7130
7099
|
}
|
|
7131
7100
|
return next;
|
|
7132
7101
|
});
|
|
@@ -7143,14 +7112,13 @@ const DateTimeInputBase = React.forwardRef((props, ref) => {
|
|
|
7143
7112
|
setInternalValue(next);
|
|
7144
7113
|
if (next)
|
|
7145
7114
|
setFocusedDate(next);
|
|
7146
|
-
onChange
|
|
7115
|
+
onChange?.(next);
|
|
7147
7116
|
}, [isControlled, onChange]);
|
|
7148
7117
|
const handleDateSelect = React.useCallback((d) => {
|
|
7149
|
-
var _a, _b, _c;
|
|
7150
7118
|
const merged = setTimeOfDay(d, {
|
|
7151
|
-
hours:
|
|
7152
|
-
minutes:
|
|
7153
|
-
seconds: enableSeconds ? (
|
|
7119
|
+
hours: value?.getHours() ?? 0,
|
|
7120
|
+
minutes: value?.getMinutes() ?? 0,
|
|
7121
|
+
seconds: enableSeconds ? (value?.getSeconds() ?? 0) : undefined,
|
|
7154
7122
|
});
|
|
7155
7123
|
if (!isWithin(merged, min, max))
|
|
7156
7124
|
return;
|
|
@@ -7158,7 +7126,7 @@ const DateTimeInputBase = React.forwardRef((props, ref) => {
|
|
|
7158
7126
|
setFocusedDate(d);
|
|
7159
7127
|
}, [value, enableSeconds, min, max, commitValue]);
|
|
7160
7128
|
const handleTimeChange = React.useCallback((parts) => {
|
|
7161
|
-
const base = value
|
|
7129
|
+
const base = value ?? focusedDate;
|
|
7162
7130
|
const next = setTimeOfDay(base, parts);
|
|
7163
7131
|
if (!isWithin(next, min, max))
|
|
7164
7132
|
return;
|
|
@@ -7171,17 +7139,17 @@ const DateTimeInputBase = React.forwardRef((props, ref) => {
|
|
|
7171
7139
|
if (parse)
|
|
7172
7140
|
return parse(trimmed);
|
|
7173
7141
|
const fmt = typeof defaultFormat === 'string' ? defaultFormat : undefined;
|
|
7174
|
-
return parseDate(trimmed, fmt
|
|
7142
|
+
return parseDate(trimmed, fmt ?? DEFAULT_DATETIME_FORMAT);
|
|
7175
7143
|
}, [parse, defaultFormat, locale]);
|
|
7176
7144
|
const makeBaseDate = React.useCallback(() => new Date(), []);
|
|
7177
7145
|
const inputReadOnlyAttr = !!readOnly || !editable;
|
|
7178
7146
|
const canOpen = !!popover && !disabled && !readOnly;
|
|
7179
7147
|
const isBlocked = React.useMemo(() => {
|
|
7180
|
-
if (!shouldDisableDate && !
|
|
7148
|
+
if (!shouldDisableDate && !unselectableDates?.length && !unselectableTimes)
|
|
7181
7149
|
return undefined;
|
|
7182
|
-
return (d) => !!
|
|
7183
|
-
!!
|
|
7184
|
-
!!
|
|
7150
|
+
return (d) => !!shouldDisableDate?.(d) ||
|
|
7151
|
+
!!unselectableDates?.some(u => isSameDay(u, d)) ||
|
|
7152
|
+
!!unselectableTimes?.(d);
|
|
7185
7153
|
}, [shouldDisableDate, unselectableDates, unselectableTimes]);
|
|
7186
7154
|
const { inputHandlers } = useSegmentedEntry({
|
|
7187
7155
|
format: defaultFormat,
|
|
@@ -7229,9 +7197,9 @@ const DateTimeInputBase = React.forwardRef((props, ref) => {
|
|
|
7229
7197
|
}, 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 }));
|
|
7230
7198
|
}
|
|
7231
7199
|
const spinnerValue = {
|
|
7232
|
-
hours:
|
|
7233
|
-
minutes:
|
|
7234
|
-
seconds: enableSeconds ? (
|
|
7200
|
+
hours: value?.getHours() ?? 0,
|
|
7201
|
+
minutes: value?.getMinutes() ?? 0,
|
|
7202
|
+
seconds: enableSeconds ? (value?.getSeconds() ?? 0) : undefined,
|
|
7235
7203
|
};
|
|
7236
7204
|
const panel = (jsxRuntime.jsxs("div", { className: panelClass, onKeyDown: e => {
|
|
7237
7205
|
if (timeOpen && e.key === 'Escape') {
|
|
@@ -7253,13 +7221,12 @@ const DateTimeInputBase = React.forwardRef((props, ref) => {
|
|
|
7253
7221
|
DateTimeInputBase.displayName = 'DateTimeInputBase';
|
|
7254
7222
|
|
|
7255
7223
|
const DateTimeInput = React.forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'calendar-alt', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
7256
|
-
var _a;
|
|
7257
7224
|
const insideField = useInsideField();
|
|
7258
7225
|
const insideControl = useInsideControl();
|
|
7259
7226
|
const helpClass = usePrefixedClassNames('help', {
|
|
7260
7227
|
[`is-${messageColor}`]: !!messageColor,
|
|
7261
7228
|
});
|
|
7262
|
-
let content = (jsxRuntime.jsx(DateTimeInputBase, { ref: ref, ...baseProps, triggerIcon:
|
|
7229
|
+
let content = (jsxRuntime.jsx(DateTimeInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
7263
7230
|
if (!insideControl && !baseProps.inline) {
|
|
7264
7231
|
content = (jsxRuntime.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 }));
|
|
7265
7232
|
}
|
|
@@ -7942,7 +7909,7 @@ const Container = ({ className, textColor, bgColor, fluid, widescreen, fullhd, b
|
|
|
7942
7909
|
|
|
7943
7910
|
const Footer = ({ as = 'footer', className, children, color, bgColor, textColor, ...props }) => {
|
|
7944
7911
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
7945
|
-
color: textColor
|
|
7912
|
+
color: textColor ?? color,
|
|
7946
7913
|
backgroundColor: bgColor,
|
|
7947
7914
|
...props,
|
|
7948
7915
|
});
|
|
@@ -7967,7 +7934,7 @@ const Hero = ({ className, color, size, bgColor, fullheightWithNavbar, children,
|
|
|
7967
7934
|
};
|
|
7968
7935
|
const HeroHead = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
7969
7936
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
7970
|
-
color: textColor
|
|
7937
|
+
color: textColor ?? color,
|
|
7971
7938
|
backgroundColor: bgColor,
|
|
7972
7939
|
...props,
|
|
7973
7940
|
});
|
|
@@ -7977,7 +7944,7 @@ const HeroHead = ({ className, children, color, bgColor, textColor, ...props })
|
|
|
7977
7944
|
};
|
|
7978
7945
|
const HeroBody = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
7979
7946
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
7980
|
-
color: textColor
|
|
7947
|
+
color: textColor ?? color,
|
|
7981
7948
|
backgroundColor: bgColor,
|
|
7982
7949
|
...props,
|
|
7983
7950
|
});
|
|
@@ -7987,7 +7954,7 @@ const HeroBody = ({ className, children, color, bgColor, textColor, ...props })
|
|
|
7987
7954
|
};
|
|
7988
7955
|
const HeroFoot = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
7989
7956
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
7990
|
-
color: textColor
|
|
7957
|
+
color: textColor ?? color,
|
|
7991
7958
|
backgroundColor: bgColor,
|
|
7992
7959
|
...props,
|
|
7993
7960
|
});
|
|
@@ -8001,7 +7968,7 @@ Hero.Foot = HeroFoot;
|
|
|
8001
7968
|
|
|
8002
7969
|
const Level = ({ isMobile, className, children, color, bgColor, textColor, ...props }) => {
|
|
8003
7970
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8004
|
-
color: textColor
|
|
7971
|
+
color: textColor ?? color,
|
|
8005
7972
|
backgroundColor: bgColor,
|
|
8006
7973
|
...props,
|
|
8007
7974
|
});
|
|
@@ -8013,7 +7980,7 @@ const Level = ({ isMobile, className, children, color, bgColor, textColor, ...pr
|
|
|
8013
7980
|
};
|
|
8014
7981
|
const LevelLeft = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
8015
7982
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8016
|
-
color: textColor
|
|
7983
|
+
color: textColor ?? color,
|
|
8017
7984
|
backgroundColor: bgColor,
|
|
8018
7985
|
...props,
|
|
8019
7986
|
});
|
|
@@ -8023,7 +7990,7 @@ const LevelLeft = ({ className, children, color, bgColor, textColor, ...props })
|
|
|
8023
7990
|
};
|
|
8024
7991
|
const LevelRight = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
8025
7992
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8026
|
-
color: textColor
|
|
7993
|
+
color: textColor ?? color,
|
|
8027
7994
|
backgroundColor: bgColor,
|
|
8028
7995
|
...props,
|
|
8029
7996
|
});
|
|
@@ -8033,7 +8000,7 @@ const LevelRight = ({ className, children, color, bgColor, textColor, ...props }
|
|
|
8033
8000
|
};
|
|
8034
8001
|
const LevelItem = ({ as = 'div', hasTextCentered, className, children, href, target, rel, color, bgColor, textColor, ...props }) => {
|
|
8035
8002
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8036
|
-
color: textColor
|
|
8003
|
+
color: textColor ?? color,
|
|
8037
8004
|
backgroundColor: bgColor,
|
|
8038
8005
|
...props,
|
|
8039
8006
|
});
|
|
@@ -8053,7 +8020,7 @@ Level.Item = LevelItem;
|
|
|
8053
8020
|
|
|
8054
8021
|
const Media = ({ as = 'article', className, children, color, bgColor, textColor, ...props }) => {
|
|
8055
8022
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8056
|
-
color: textColor
|
|
8023
|
+
color: textColor ?? color,
|
|
8057
8024
|
backgroundColor: bgColor,
|
|
8058
8025
|
...props,
|
|
8059
8026
|
});
|
|
@@ -8064,7 +8031,7 @@ const Media = ({ as = 'article', className, children, color, bgColor, textColor,
|
|
|
8064
8031
|
};
|
|
8065
8032
|
const MediaLeft = ({ as = 'figure', className, children, color, bgColor, textColor, ...props }) => {
|
|
8066
8033
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8067
|
-
color: textColor
|
|
8034
|
+
color: textColor ?? color,
|
|
8068
8035
|
backgroundColor: bgColor,
|
|
8069
8036
|
...props,
|
|
8070
8037
|
});
|
|
@@ -8075,7 +8042,7 @@ const MediaLeft = ({ as = 'figure', className, children, color, bgColor, textCol
|
|
|
8075
8042
|
};
|
|
8076
8043
|
const MediaContent = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
8077
8044
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8078
|
-
color: textColor
|
|
8045
|
+
color: textColor ?? color,
|
|
8079
8046
|
backgroundColor: bgColor,
|
|
8080
8047
|
...props,
|
|
8081
8048
|
});
|
|
@@ -8085,7 +8052,7 @@ const MediaContent = ({ className, children, color, bgColor, textColor, ...props
|
|
|
8085
8052
|
};
|
|
8086
8053
|
const MediaRight = ({ className, children, color, bgColor, textColor, ...props }) => {
|
|
8087
8054
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8088
|
-
color: textColor
|
|
8055
|
+
color: textColor ?? color,
|
|
8089
8056
|
backgroundColor: bgColor,
|
|
8090
8057
|
...props,
|
|
8091
8058
|
});
|
|
@@ -8100,7 +8067,7 @@ MediaWithSubcomponents.Right = MediaRight;
|
|
|
8100
8067
|
|
|
8101
8068
|
const Section = ({ size, className, children, color, bgColor, textColor, ...props }) => {
|
|
8102
8069
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
8103
|
-
color: textColor
|
|
8070
|
+
color: textColor ?? color,
|
|
8104
8071
|
backgroundColor: bgColor,
|
|
8105
8072
|
...props,
|
|
8106
8073
|
});
|