@jobber/components 8.18.1 → 8.20.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/InputNumberExperimental-cjs.js +214 -87
- package/dist/InputNumberExperimental-es.js +215 -88
- package/dist/MenuSubmenuTrigger-cjs.js +41 -41
- package/dist/MenuSubmenuTrigger-es.js +2 -2
- package/dist/NumberFieldInput-cjs.js +81 -2
- package/dist/NumberFieldInput-es.js +81 -3
- package/dist/ScrollAreaViewport-cjs.js +50 -175
- package/dist/ScrollAreaViewport-es.js +3 -115
- package/dist/clamp-cjs.js +131 -2
- package/dist/clamp-es.js +114 -2
- package/dist/primitives/BottomSheet/index.cjs +1 -1
- package/dist/primitives/BottomSheet/index.mjs +1 -1
- package/dist/primitives/InputNumberExperimental/InputNumberExperimental.d.ts +51 -10
- package/dist/primitives/InputNumberExperimental/index.cjs +3 -3
- package/dist/primitives/InputNumberExperimental/index.d.ts +1 -1
- package/dist/primitives/InputNumberExperimental/index.mjs +3 -3
- package/dist/primitives/InputNumberExperimental/types.d.ts +83 -83
- package/dist/primitives/index.cjs +1 -1
- package/dist/primitives/index.mjs +1 -1
- package/dist/styles.css +2 -2
- package/dist/unstyledPrimitives/index.cjs +17 -95
- package/dist/unstyledPrimitives/index.mjs +3 -81
- package/package.json +2 -2
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { _ as __rest } from './tslib.es6-es.js';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import React__default, { createContext, forwardRef, useId, useRef, useImperativeHandle, useCallback, useMemo, useContext } from 'react';
|
|
3
4
|
import classnames from 'classnames';
|
|
4
5
|
import { A as ActivityIndicator } from './ActivityIndicator-es.js';
|
|
5
6
|
import { B as Button } from './Button-es.js';
|
|
6
7
|
import { I as Icon } from './Icon-es.js';
|
|
7
|
-
import { u as useBaseUiId, a as useStableCallback, b as useTimeout, t as transitionStatusMapping, c as useTransitionStatus, d as useIsoLayoutEffect, e as useOpenChangeComplete } from './clamp-es.js';
|
|
8
|
-
import { u as useLabelableContext, L as LabelableContext, a as useFormContext, D as DEFAULT_VALIDITY_STATE, g as getCombinedFieldValidityData, f as fieldValidityMapping, F as FieldRootContext, b as useFieldRootContext, N as NumberFieldRoot, c as NumberFieldGroup, d as NumberFieldInput, e as NumberFieldIncrement, h as NumberFieldDecrement } from './NumberFieldInput-es.js';
|
|
9
8
|
import { f as formatErrorMessage, a as useRefWithInit, m as mergeProps, E as EMPTY_OBJECT, u as useRenderElement } from './useRenderElement-es.js';
|
|
9
|
+
import { u as useBaseUiId, a as useStableCallback, b as useTimeout, S as SafeReact, e as error, t as transitionStatusMapping, c as useTransitionStatus, d as useIsoLayoutEffect, f as useOpenChangeComplete } from './clamp-es.js';
|
|
10
|
+
import { u as useLabelableContext, L as LabelableContext, a as useFormContext, D as DEFAULT_VALIDITY_STATE, g as getCombinedFieldValidityData, f as fieldValidityMapping, F as FieldRootContext, b as useFieldRootContext, c as useLabel, N as NumberFieldRoot, d as NumberFieldGroup, e as NumberFieldInput, h as NumberFieldIncrement, i as NumberFieldDecrement } from './NumberFieldInput-es.js';
|
|
10
11
|
import { jsx } from 'react/jsx-runtime';
|
|
11
12
|
|
|
12
13
|
const FieldsetRootContext = /*#__PURE__*/React.createContext({
|
|
@@ -446,6 +447,59 @@ const FieldRoot = /*#__PURE__*/React.forwardRef(function FieldRoot(componentProp
|
|
|
446
447
|
});
|
|
447
448
|
if (process.env.NODE_ENV !== "production") FieldRoot.displayName = "FieldRoot";
|
|
448
449
|
|
|
450
|
+
/**
|
|
451
|
+
* An accessible label that is automatically associated with the field control.
|
|
452
|
+
* Renders a `<label>` element.
|
|
453
|
+
*
|
|
454
|
+
* Documentation: [Base UI Field](https://base-ui.com/react/components/field)
|
|
455
|
+
*/
|
|
456
|
+
const FieldLabel = /*#__PURE__*/React.forwardRef(function FieldLabel(componentProps, forwardedRef) {
|
|
457
|
+
const {
|
|
458
|
+
render,
|
|
459
|
+
className,
|
|
460
|
+
id: idProp,
|
|
461
|
+
nativeLabel = true,
|
|
462
|
+
...elementProps
|
|
463
|
+
} = componentProps;
|
|
464
|
+
const fieldRootContext = useFieldRootContext(false);
|
|
465
|
+
const {
|
|
466
|
+
labelId
|
|
467
|
+
} = useLabelableContext();
|
|
468
|
+
const labelRef = React.useRef(null);
|
|
469
|
+
const labelProps = useLabel({
|
|
470
|
+
id: labelId ?? idProp,
|
|
471
|
+
native: nativeLabel
|
|
472
|
+
});
|
|
473
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
474
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
475
|
+
React.useEffect(() => {
|
|
476
|
+
if (!labelRef.current) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
const isLabelTag = labelRef.current.tagName === 'LABEL';
|
|
480
|
+
if (nativeLabel) {
|
|
481
|
+
if (!isLabelTag) {
|
|
482
|
+
const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';
|
|
483
|
+
const message = '<Field.Label> expected a <label> element because the `nativeLabel` prop is true. ' + 'Rendering a non-<label> disables native label association, so `htmlFor` will not ' + 'work. Use a real <label> in the `render` prop, or set `nativeLabel` to `false`.';
|
|
484
|
+
error(`${message}${ownerStackMessage}`);
|
|
485
|
+
}
|
|
486
|
+
} else if (isLabelTag) {
|
|
487
|
+
const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';
|
|
488
|
+
const message = '<Field.Label> expected a non-<label> element because the `nativeLabel` prop is false. ' + 'Rendering a <label> assumes native label behavior while Base UI treats it as ' + 'non-native, which can cause unexpected pointer behavior. Use a non-<label> in the ' + '`render` prop, or set `nativeLabel` to `true`.';
|
|
489
|
+
error(`${message}${ownerStackMessage}`);
|
|
490
|
+
}
|
|
491
|
+
}, [nativeLabel]);
|
|
492
|
+
}
|
|
493
|
+
const element = useRenderElement('label', componentProps, {
|
|
494
|
+
ref: [forwardedRef, labelRef],
|
|
495
|
+
state: fieldRootContext.state,
|
|
496
|
+
props: [labelProps, elementProps],
|
|
497
|
+
stateAttributesMapping: fieldValidityMapping
|
|
498
|
+
});
|
|
499
|
+
return element;
|
|
500
|
+
});
|
|
501
|
+
if (process.env.NODE_ENV !== "production") FieldLabel.displayName = "FieldLabel";
|
|
502
|
+
|
|
449
503
|
const stateAttributesMapping = {
|
|
450
504
|
...fieldValidityMapping,
|
|
451
505
|
...transitionStatusMapping
|
|
@@ -604,13 +658,12 @@ const InputNumberExperimentalContext = createContext(null);
|
|
|
604
658
|
function useInputNumberExperimentalContext(consumer) {
|
|
605
659
|
const context = useContext(InputNumberExperimentalContext);
|
|
606
660
|
if (context === null) {
|
|
607
|
-
throw new Error(`<InputNumberExperimental.${consumer}> must be used inside <InputNumberExperimental>.`);
|
|
661
|
+
throw new Error(`<InputNumberExperimental.${consumer}> must be used inside <InputNumberExperimental.Wrapper>.`);
|
|
608
662
|
}
|
|
609
663
|
return context;
|
|
610
664
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
const { align, autocomplete, children, description, disabled, error, format, id: idProp, inline, invalid, keyboard, loading, max, maxLength, min, name, onBlur, onChange, onEnter, onFocus, onKeyDown, onKeyUp, onValueChange, placeholder, prefix, readonly, showMiniLabel = true, size = "default", step = 1, suffix, value, } = props;
|
|
665
|
+
function InputNumberExperimentalWrapperInternal(props, ref) {
|
|
666
|
+
const { align, autoComplete, children, className, disabled, format, id: idProp, inline, inputMode, invalid, loading, max, maxLength, min, name, onBlur, onEnter, onFocus, onKeyDown, onKeyUp, onValueChange, onValueCommitted, readOnly, showMiniLabel = true, size = "default", step = 1, style, value, } = props;
|
|
614
667
|
const generatedId = useId();
|
|
615
668
|
const id = idProp !== null && idProp !== void 0 ? idProp : generatedId;
|
|
616
669
|
const innerInputRef = useRef(null);
|
|
@@ -618,12 +671,8 @@ function InputNumberExperimentalInternal(props, ref) {
|
|
|
618
671
|
focus: () => { var _a; return (_a = innerInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
619
672
|
blur: () => { var _a; return (_a = innerInputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
|
|
620
673
|
}), []);
|
|
621
|
-
const handleValueCommitted = useCallback((newValue) =>
|
|
622
|
-
|
|
623
|
-
}, [onChange]);
|
|
624
|
-
const handleValueChange = useCallback((newValue) => {
|
|
625
|
-
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue !== null && newValue !== void 0 ? newValue : undefined);
|
|
626
|
-
}, [onValueChange]);
|
|
674
|
+
const handleValueCommitted = useCallback((newValue) => onValueCommitted === null || onValueCommitted === void 0 ? void 0 : onValueCommitted(newValue), [onValueCommitted]);
|
|
675
|
+
const handleValueChange = useCallback((newValue) => onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue), [onValueChange]);
|
|
627
676
|
const handleKeyDown = useCallback((event) => {
|
|
628
677
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
629
678
|
if (event.key === "Enter" &&
|
|
@@ -631,90 +680,131 @@ function InputNumberExperimentalInternal(props, ref) {
|
|
|
631
680
|
!event.ctrlKey &&
|
|
632
681
|
!event.metaKey) {
|
|
633
682
|
onEnter === null || onEnter === void 0 ? void 0 : onEnter(event);
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
// via Base UI's onBlur and restore focus immediately after.
|
|
683
|
+
// Commit on Enter. Base UI commits on blur, not Enter, so round-trip
|
|
684
|
+
// focus to fire onValueCommitted via blur and restore focus immediately.
|
|
637
685
|
const target = event.currentTarget;
|
|
638
686
|
target.blur();
|
|
639
687
|
target.focus();
|
|
640
688
|
}
|
|
641
689
|
}, [onKeyDown, onEnter]);
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
child.type === InputNumberExperimentalAffixCompound ||
|
|
645
|
-
child.type === InputNumberExperimentalStepperCompound)), [children]);
|
|
646
|
-
const showStepper = !disabled && !readonly;
|
|
647
|
-
// `handleKeyDown` is a `useCallback` whose own deps include `onKeyDown` and
|
|
648
|
-
// `onEnter`, so listing it here transitively tracks both. Don't add `onEnter`
|
|
649
|
-
// or `onKeyDown` separately — they'd be redundant and an exhaustive-deps lint
|
|
650
|
-
// would flag the duplication.
|
|
690
|
+
// `handleKeyDown` transitively tracks `onKeyDown`/`onEnter` via its own deps,
|
|
691
|
+
// so they are intentionally not listed separately here.
|
|
651
692
|
const contextValue = useMemo(() => ({
|
|
652
|
-
|
|
653
|
-
|
|
693
|
+
align,
|
|
694
|
+
autoComplete,
|
|
654
695
|
disabled,
|
|
696
|
+
format,
|
|
655
697
|
id,
|
|
656
698
|
innerInputRef,
|
|
657
|
-
|
|
699
|
+
inputMode,
|
|
658
700
|
loading,
|
|
701
|
+
max,
|
|
659
702
|
maxLength,
|
|
703
|
+
min,
|
|
660
704
|
onBlur,
|
|
661
705
|
onFocus,
|
|
662
706
|
onKeyDown: handleKeyDown,
|
|
663
707
|
onKeyUp,
|
|
664
|
-
|
|
665
|
-
|
|
708
|
+
onValueChange: handleValueChange,
|
|
709
|
+
onValueCommitted: handleValueCommitted,
|
|
710
|
+
readOnly,
|
|
666
711
|
showMiniLabel,
|
|
667
|
-
showStepper,
|
|
712
|
+
showStepper: !disabled && !readOnly,
|
|
668
713
|
size,
|
|
714
|
+
step,
|
|
715
|
+
value,
|
|
669
716
|
}), [
|
|
670
|
-
|
|
671
|
-
|
|
717
|
+
align,
|
|
718
|
+
autoComplete,
|
|
672
719
|
disabled,
|
|
720
|
+
format,
|
|
673
721
|
id,
|
|
674
|
-
|
|
722
|
+
inputMode,
|
|
675
723
|
loading,
|
|
724
|
+
max,
|
|
676
725
|
maxLength,
|
|
726
|
+
min,
|
|
677
727
|
onBlur,
|
|
678
728
|
onFocus,
|
|
679
729
|
handleKeyDown,
|
|
680
730
|
onKeyUp,
|
|
681
|
-
|
|
682
|
-
|
|
731
|
+
handleValueChange,
|
|
732
|
+
handleValueCommitted,
|
|
733
|
+
readOnly,
|
|
683
734
|
showMiniLabel,
|
|
684
|
-
showStepper,
|
|
685
735
|
size,
|
|
736
|
+
step,
|
|
737
|
+
value,
|
|
686
738
|
]);
|
|
687
|
-
const
|
|
688
|
-
return (React__default.createElement(FieldRoot, {
|
|
689
|
-
React__default.createElement(InputNumberExperimentalContext.Provider, { value: contextValue },
|
|
690
|
-
React__default.createElement(NumberFieldRoot, { allowOutOfRange: true, format: format !== null && format !== void 0 ? format : DEFAULT_FORMAT, id: id, max: max, min: min, onValueChange: handleValueChange, onValueCommitted: handleValueCommitted, readOnly: readonly, step: step, value: value !== null && value !== void 0 ? value : null },
|
|
691
|
-
React__default.createElement(NumberFieldGroup, { className: classnames(styles.wrapper, align && styles[align], disabled && styles.disabled, size !== "default" && styles[size]) }, isUsingCompoundPattern
|
|
692
|
-
? children
|
|
693
|
-
: renderDefaultComposition({ prefix, suffix, size })))),
|
|
694
|
-
(description || error) && (React__default.createElement("div", { className: styles.belowField },
|
|
695
|
-
description && (React__default.createElement(FieldDescription, { className: styles.description }, description)),
|
|
696
|
-
error && (React__default.createElement(FieldError, { className: styles.fieldError, match: true, role: "alert" }, error))))));
|
|
739
|
+
const rootProps = mergeProps({ className: classnames(styles.container, inline && styles.inline) }, { className, style });
|
|
740
|
+
return (React__default.createElement(FieldRoot, Object.assign({}, rootProps, { disabled: disabled, invalid: invalid || undefined, name: name }),
|
|
741
|
+
React__default.createElement(InputNumberExperimentalContext.Provider, { value: contextValue }, children)));
|
|
697
742
|
}
|
|
698
|
-
function
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
743
|
+
function InputNumberExperimentalGroup({ children, className, style, }) {
|
|
744
|
+
var _a, _b;
|
|
745
|
+
const ctx = useInputNumberExperimentalContext("Group");
|
|
746
|
+
const groupProps = mergeProps({
|
|
747
|
+
className: classnames(styles.wrapper, ctx.align && styles[ctx.align], ctx.disabled && styles.disabled, ctx.size !== "default" && styles[ctx.size]),
|
|
748
|
+
}, { className, style });
|
|
749
|
+
return (React__default.createElement(NumberFieldRoot, { allowOutOfRange: true, format: (_a = ctx.format) !== null && _a !== void 0 ? _a : DEFAULT_FORMAT, id: ctx.id, max: ctx.max, min: ctx.min, onValueChange: ctx.onValueChange, onValueCommitted: ctx.onValueCommitted, readOnly: ctx.readOnly, step: ctx.step, value: (_b = ctx.value) !== null && _b !== void 0 ? _b : null },
|
|
750
|
+
React__default.createElement(NumberFieldGroup, Object.assign({}, groupProps), children)));
|
|
705
751
|
}
|
|
706
|
-
function
|
|
707
|
-
|
|
752
|
+
function InputNumberExperimentalFooter({ children, className, style, }) {
|
|
753
|
+
useInputNumberExperimentalContext("Footer");
|
|
754
|
+
const rootProps = mergeProps({ className: styles.belowField }, { className, style });
|
|
755
|
+
return React__default.createElement("div", Object.assign({}, rootProps), children);
|
|
756
|
+
}
|
|
757
|
+
function InputNumberExperimentalInput({ children, className, style, }) {
|
|
708
758
|
const ctx = useInputNumberExperimentalContext("Input");
|
|
709
|
-
const labelText = (_a = props.placeholder) !== null && _a !== void 0 ? _a : ctx.placeholder;
|
|
710
759
|
const rootProps = mergeProps({
|
|
711
760
|
className: classnames(styles.inputWrapper, !ctx.showMiniLabel && styles.hideLabel, ctx.size !== "default" && styles[ctx.size], ctx.disabled && styles.disabled),
|
|
712
|
-
}, { className
|
|
761
|
+
}, { className, style });
|
|
713
762
|
return (React__default.createElement("div", Object.assign({}, rootProps),
|
|
714
|
-
React__default.createElement(NumberFieldInput, { "aria-busy": ctx.loading || undefined, autoComplete:
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
763
|
+
React__default.createElement(NumberFieldInput, { "aria-busy": ctx.loading || undefined, autoComplete: resolveAutoComplete(ctx.autoComplete), className: styles.input, inputMode: ctx.inputMode, maxLength: ctx.maxLength, onBlur: ctx.onBlur, onFocus: ctx.onFocus, onKeyDown: ctx.onKeyDown, onKeyUp: ctx.onKeyUp, placeholder: " ", ref: ctx.innerInputRef }),
|
|
764
|
+
children));
|
|
765
|
+
}
|
|
766
|
+
function InputNumberExperimentalLabel({ children, className, style, }) {
|
|
767
|
+
const ctx = useInputNumberExperimentalContext("Label");
|
|
768
|
+
if (!children)
|
|
769
|
+
return null;
|
|
770
|
+
return (React__default.createElement(FieldLabel, { className: classnames(styles.label, className), htmlFor: ctx.id, style: style }, children));
|
|
771
|
+
}
|
|
772
|
+
function InputNumberExperimentalDescription({ children, className, style, }) {
|
|
773
|
+
useInputNumberExperimentalContext("Description");
|
|
774
|
+
if (!children)
|
|
775
|
+
return null;
|
|
776
|
+
return (React__default.createElement(FieldDescription, { className: classnames(styles.description, className), style: style }, children));
|
|
777
|
+
}
|
|
778
|
+
function InputNumberExperimentalError({ children, className, style, }) {
|
|
779
|
+
useInputNumberExperimentalContext("Error");
|
|
780
|
+
if (!children)
|
|
781
|
+
return null;
|
|
782
|
+
return (React__default.createElement(FieldError, { className: classnames(styles.fieldError, className), match: true, role: "alert", style: style }, children));
|
|
783
|
+
}
|
|
784
|
+
function InputNumberExperimentalLoading({ children, className, style, }) {
|
|
785
|
+
useInputNumberExperimentalContext("Loading");
|
|
786
|
+
const rootProps = mergeProps({ className: styles.loadingIndicator }, { className, style });
|
|
787
|
+
return (React__default.createElement("div", Object.assign({}, rootProps), children !== null && children !== void 0 ? children : React__default.createElement(ActivityIndicator, { size: "small" })));
|
|
788
|
+
}
|
|
789
|
+
function InputNumberExperimentalStepper({ children, incrementLabel, decrementLabel, className, style, }) {
|
|
790
|
+
const ctx = useInputNumberExperimentalContext("Stepper");
|
|
791
|
+
if (ctx.loading || !ctx.showStepper) {
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
const rootProps = mergeProps({ className: styles.stepper }, { className, style });
|
|
795
|
+
return (React__default.createElement("div", Object.assign({}, rootProps), children !== null && children !== void 0 ? children : (React__default.createElement(React__default.Fragment, null,
|
|
796
|
+
React__default.createElement(InputNumberExperimentalIncrement, { ariaLabel: incrementLabel }),
|
|
797
|
+
React__default.createElement(InputNumberExperimentalDecrement, { ariaLabel: decrementLabel })))));
|
|
798
|
+
}
|
|
799
|
+
function InputNumberExperimentalIncrement({ children, ariaLabel, className, style, }) {
|
|
800
|
+
useInputNumberExperimentalContext("Increment");
|
|
801
|
+
const rootProps = mergeProps({ className: styles.stepperButton }, { className, style });
|
|
802
|
+
return (React__default.createElement(NumberFieldIncrement, Object.assign({ "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : "Increase value" }, rootProps), children !== null && children !== void 0 ? children : (React__default.createElement(Icon, { name: "arrowUp", size: "small", customColor: "currentColor" }))));
|
|
803
|
+
}
|
|
804
|
+
function InputNumberExperimentalDecrement({ children, ariaLabel, className, style, }) {
|
|
805
|
+
useInputNumberExperimentalContext("Decrement");
|
|
806
|
+
const rootProps = mergeProps({ className: styles.stepperButton }, { className, style });
|
|
807
|
+
return (React__default.createElement(NumberFieldDecrement, Object.assign({ "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : "Decrease value" }, rootProps), children !== null && children !== void 0 ? children : (React__default.createElement(Icon, { name: "arrowDown", size: "small", customColor: "currentColor" }))));
|
|
718
808
|
}
|
|
719
809
|
function InputNumberExperimentalAffixCompound({ variation, label, icon, onClick, ariaLabel, children, className, style, }) {
|
|
720
810
|
const ctx = useInputNumberExperimentalContext("Affix");
|
|
@@ -729,23 +819,20 @@ function InputNumberExperimentalAffixCompound({ variation, label, icon, onClick,
|
|
|
729
819
|
label && React__default.createElement("span", { className: styles.affixLabelText }, label),
|
|
730
820
|
children));
|
|
731
821
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
React__default.createElement(Icon, { name: "arrowUp", size: "small", customColor: "currentColor" })),
|
|
747
|
-
React__default.createElement(NumberFieldDecrement, { "aria-label": resolvedDecrementLabel, className: styles.stepperButton },
|
|
748
|
-
React__default.createElement(Icon, { name: "arrowDown", size: "small", customColor: "currentColor" }))));
|
|
822
|
+
/**
|
|
823
|
+
* Renders the prop-driven `prefix`/`suffix` affixes for the sugar component.
|
|
824
|
+
* Icons sit outside the input area; labels render next to the typed value
|
|
825
|
+
* (suffix mirrors the order). The composable `.Affix` part is the alternative
|
|
826
|
+
* when composing the field directly.
|
|
827
|
+
*/
|
|
828
|
+
function renderDefaultAffix(variation, affix, size) {
|
|
829
|
+
const icon = affix.icon && (React__default.createElement(AffixIconSlot, { variation: variation, icon: affix.icon, size: size, ariaLabel: "ariaLabel" in affix ? affix.ariaLabel : undefined, onClick: "onClick" in affix ? affix.onClick : undefined }));
|
|
830
|
+
const affixLabel = affix.label && (React__default.createElement(AffixLabelSlot, { variation: variation, label: affix.label }));
|
|
831
|
+
return variation === "prefix" ? (React__default.createElement(React__default.Fragment, null,
|
|
832
|
+
icon,
|
|
833
|
+
affixLabel)) : (React__default.createElement(React__default.Fragment, null,
|
|
834
|
+
affixLabel,
|
|
835
|
+
icon));
|
|
749
836
|
}
|
|
750
837
|
function AffixIconSlot({ variation, icon, size, onClick, ariaLabel, }) {
|
|
751
838
|
return (React__default.createElement("div", { className: classnames(styles.affixIcon, variation === "suffix" && styles.suffix) },
|
|
@@ -761,25 +848,65 @@ function AffixIconContent({ icon, size, onClick, ariaLabel, }) {
|
|
|
761
848
|
function AffixLabelSlot({ variation, label }) {
|
|
762
849
|
return (React__default.createElement("div", { className: classnames(styles.affixLabel, variation === "prefix" && styles.prefix, variation === "suffix" && styles.suffix) }, label));
|
|
763
850
|
}
|
|
764
|
-
function
|
|
765
|
-
if (
|
|
851
|
+
function resolveAutoComplete(autoComplete) {
|
|
852
|
+
if (autoComplete === false)
|
|
766
853
|
return "off";
|
|
767
|
-
if (
|
|
854
|
+
if (autoComplete === true || autoComplete === undefined)
|
|
768
855
|
return undefined;
|
|
769
|
-
return
|
|
856
|
+
return autoComplete;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Sugar layer: composes the parts from props. This is the same composition a
|
|
860
|
+
* consumer would write by hand with `<InputNumberExperimental.Wrapper>` and the
|
|
861
|
+
* parts — to customize a single piece, copy this tree and swap that part.
|
|
862
|
+
*/
|
|
863
|
+
function InputNumberExperimentalInternal(props, ref) {
|
|
864
|
+
var _a;
|
|
865
|
+
const { label, description, error, prefix, suffix } = props, config = __rest(props, ["label", "description", "error", "prefix", "suffix"]);
|
|
866
|
+
const size = (_a = config.size) !== null && _a !== void 0 ? _a : "default";
|
|
867
|
+
return (React__default.createElement(InputNumberExperimentalWrapper, Object.assign({}, config, { invalid: config.invalid || Boolean(error), ref: ref }),
|
|
868
|
+
React__default.createElement(InputNumberExperimentalGroup, null,
|
|
869
|
+
prefix && renderDefaultAffix("prefix", prefix, size),
|
|
870
|
+
React__default.createElement(InputNumberExperimentalInput, null,
|
|
871
|
+
React__default.createElement(InputNumberExperimentalLabel, null, label),
|
|
872
|
+
config.loading ? (React__default.createElement(InputNumberExperimentalLoading, null)) : (React__default.createElement(InputNumberExperimentalStepper, { incrementLabel: `Increase ${label !== null && label !== void 0 ? label : "value"}`, decrementLabel: `Decrease ${label !== null && label !== void 0 ? label : "value"}` }))),
|
|
873
|
+
suffix && renderDefaultAffix("suffix", suffix, size)),
|
|
874
|
+
(description || error) && (React__default.createElement(InputNumberExperimentalFooter, null,
|
|
875
|
+
React__default.createElement(InputNumberExperimentalDescription, null, description),
|
|
876
|
+
React__default.createElement(InputNumberExperimentalError, null, error)))));
|
|
770
877
|
}
|
|
878
|
+
const InputNumberExperimentalWrapper = forwardRef(InputNumberExperimentalWrapperInternal);
|
|
879
|
+
InputNumberExperimentalWrapper.displayName = "InputNumberExperimental.Wrapper";
|
|
771
880
|
const InputNumberExperimentalBase = forwardRef(InputNumberExperimentalInternal);
|
|
772
881
|
InputNumberExperimentalBase.displayName = "InputNumberExperimental";
|
|
773
|
-
|
|
774
|
-
|
|
882
|
+
InputNumberExperimentalGroup.displayName = "InputNumberExperimental.Group";
|
|
883
|
+
InputNumberExperimentalFooter.displayName = "InputNumberExperimental.Footer";
|
|
884
|
+
InputNumberExperimentalInput.displayName = "InputNumberExperimental.Input";
|
|
885
|
+
InputNumberExperimentalLabel.displayName = "InputNumberExperimental.Label";
|
|
886
|
+
InputNumberExperimentalDescription.displayName =
|
|
887
|
+
"InputNumberExperimental.Description";
|
|
888
|
+
InputNumberExperimentalError.displayName = "InputNumberExperimental.Error";
|
|
889
|
+
InputNumberExperimentalLoading.displayName = "InputNumberExperimental.Loading";
|
|
890
|
+
InputNumberExperimentalStepper.displayName = "InputNumberExperimental.Stepper";
|
|
891
|
+
InputNumberExperimentalIncrement.displayName =
|
|
892
|
+
"InputNumberExperimental.Increment";
|
|
893
|
+
InputNumberExperimentalDecrement.displayName =
|
|
894
|
+
"InputNumberExperimental.Decrement";
|
|
775
895
|
InputNumberExperimentalAffixCompound.displayName =
|
|
776
896
|
"InputNumberExperimental.Affix";
|
|
777
|
-
InputNumberExperimentalStepperCompound.displayName =
|
|
778
|
-
"InputNumberExperimental.Stepper";
|
|
779
897
|
const InputNumberExperimental = Object.assign(InputNumberExperimentalBase, {
|
|
780
|
-
|
|
898
|
+
Wrapper: InputNumberExperimentalWrapper,
|
|
899
|
+
Group: InputNumberExperimentalGroup,
|
|
900
|
+
Footer: InputNumberExperimentalFooter,
|
|
901
|
+
Input: InputNumberExperimentalInput,
|
|
902
|
+
Label: InputNumberExperimentalLabel,
|
|
903
|
+
Description: InputNumberExperimentalDescription,
|
|
904
|
+
Error: InputNumberExperimentalError,
|
|
905
|
+
Loading: InputNumberExperimentalLoading,
|
|
906
|
+
Stepper: InputNumberExperimentalStepper,
|
|
907
|
+
Increment: InputNumberExperimentalIncrement,
|
|
908
|
+
Decrement: InputNumberExperimentalDecrement,
|
|
781
909
|
Affix: InputNumberExperimentalAffixCompound,
|
|
782
|
-
Stepper: InputNumberExperimentalStepperCompound,
|
|
783
910
|
});
|
|
784
911
|
|
|
785
912
|
export { InputNumberExperimental as I };
|