@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,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var tslib_es6 = require('./tslib.es6-cjs.js');
|
|
3
4
|
var React = require('react');
|
|
4
5
|
var classnames = require('classnames');
|
|
5
6
|
var ActivityIndicator = require('./ActivityIndicator-cjs.js');
|
|
6
7
|
var Button = require('./Button-cjs.js');
|
|
7
8
|
var Icon = require('./Icon-cjs.js');
|
|
9
|
+
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
8
10
|
var clamp = require('./clamp-cjs.js');
|
|
9
11
|
var NumberFieldInput = require('./NumberFieldInput-cjs.js');
|
|
10
|
-
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
11
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
13
|
|
|
13
14
|
function _interopNamespaceDefault(e) {
|
|
@@ -466,6 +467,59 @@ const FieldRoot = /*#__PURE__*/React__namespace.forwardRef(function FieldRoot(co
|
|
|
466
467
|
});
|
|
467
468
|
if (process.env.NODE_ENV !== "production") FieldRoot.displayName = "FieldRoot";
|
|
468
469
|
|
|
470
|
+
/**
|
|
471
|
+
* An accessible label that is automatically associated with the field control.
|
|
472
|
+
* Renders a `<label>` element.
|
|
473
|
+
*
|
|
474
|
+
* Documentation: [Base UI Field](https://base-ui.com/react/components/field)
|
|
475
|
+
*/
|
|
476
|
+
const FieldLabel = /*#__PURE__*/React__namespace.forwardRef(function FieldLabel(componentProps, forwardedRef) {
|
|
477
|
+
const {
|
|
478
|
+
render,
|
|
479
|
+
className,
|
|
480
|
+
id: idProp,
|
|
481
|
+
nativeLabel = true,
|
|
482
|
+
...elementProps
|
|
483
|
+
} = componentProps;
|
|
484
|
+
const fieldRootContext = NumberFieldInput.useFieldRootContext(false);
|
|
485
|
+
const {
|
|
486
|
+
labelId
|
|
487
|
+
} = NumberFieldInput.useLabelableContext();
|
|
488
|
+
const labelRef = React__namespace.useRef(null);
|
|
489
|
+
const labelProps = NumberFieldInput.useLabel({
|
|
490
|
+
id: labelId ?? idProp,
|
|
491
|
+
native: nativeLabel
|
|
492
|
+
});
|
|
493
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
494
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
495
|
+
React__namespace.useEffect(() => {
|
|
496
|
+
if (!labelRef.current) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const isLabelTag = labelRef.current.tagName === 'LABEL';
|
|
500
|
+
if (nativeLabel) {
|
|
501
|
+
if (!isLabelTag) {
|
|
502
|
+
const ownerStackMessage = clamp.SafeReact.captureOwnerStack?.() || '';
|
|
503
|
+
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`.';
|
|
504
|
+
clamp.error(`${message}${ownerStackMessage}`);
|
|
505
|
+
}
|
|
506
|
+
} else if (isLabelTag) {
|
|
507
|
+
const ownerStackMessage = clamp.SafeReact.captureOwnerStack?.() || '';
|
|
508
|
+
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`.';
|
|
509
|
+
clamp.error(`${message}${ownerStackMessage}`);
|
|
510
|
+
}
|
|
511
|
+
}, [nativeLabel]);
|
|
512
|
+
}
|
|
513
|
+
const element = useRenderElement.useRenderElement('label', componentProps, {
|
|
514
|
+
ref: [forwardedRef, labelRef],
|
|
515
|
+
state: fieldRootContext.state,
|
|
516
|
+
props: [labelProps, elementProps],
|
|
517
|
+
stateAttributesMapping: NumberFieldInput.fieldValidityMapping
|
|
518
|
+
});
|
|
519
|
+
return element;
|
|
520
|
+
});
|
|
521
|
+
if (process.env.NODE_ENV !== "production") FieldLabel.displayName = "FieldLabel";
|
|
522
|
+
|
|
469
523
|
const stateAttributesMapping = {
|
|
470
524
|
...NumberFieldInput.fieldValidityMapping,
|
|
471
525
|
...clamp.transitionStatusMapping
|
|
@@ -624,13 +678,12 @@ const InputNumberExperimentalContext = React.createContext(null);
|
|
|
624
678
|
function useInputNumberExperimentalContext(consumer) {
|
|
625
679
|
const context = React.useContext(InputNumberExperimentalContext);
|
|
626
680
|
if (context === null) {
|
|
627
|
-
throw new Error(`<InputNumberExperimental.${consumer}> must be used inside <InputNumberExperimental>.`);
|
|
681
|
+
throw new Error(`<InputNumberExperimental.${consumer}> must be used inside <InputNumberExperimental.Wrapper>.`);
|
|
628
682
|
}
|
|
629
683
|
return context;
|
|
630
684
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
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;
|
|
685
|
+
function InputNumberExperimentalWrapperInternal(props, ref) {
|
|
686
|
+
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;
|
|
634
687
|
const generatedId = React.useId();
|
|
635
688
|
const id = idProp !== null && idProp !== void 0 ? idProp : generatedId;
|
|
636
689
|
const innerInputRef = React.useRef(null);
|
|
@@ -638,12 +691,8 @@ function InputNumberExperimentalInternal(props, ref) {
|
|
|
638
691
|
focus: () => { var _a; return (_a = innerInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
639
692
|
blur: () => { var _a; return (_a = innerInputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
|
|
640
693
|
}), []);
|
|
641
|
-
const handleValueCommitted = React.useCallback((newValue) =>
|
|
642
|
-
|
|
643
|
-
}, [onChange]);
|
|
644
|
-
const handleValueChange = React.useCallback((newValue) => {
|
|
645
|
-
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue !== null && newValue !== void 0 ? newValue : undefined);
|
|
646
|
-
}, [onValueChange]);
|
|
694
|
+
const handleValueCommitted = React.useCallback((newValue) => onValueCommitted === null || onValueCommitted === void 0 ? void 0 : onValueCommitted(newValue), [onValueCommitted]);
|
|
695
|
+
const handleValueChange = React.useCallback((newValue) => onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue), [onValueChange]);
|
|
647
696
|
const handleKeyDown = React.useCallback((event) => {
|
|
648
697
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
649
698
|
if (event.key === "Enter" &&
|
|
@@ -651,90 +700,131 @@ function InputNumberExperimentalInternal(props, ref) {
|
|
|
651
700
|
!event.ctrlKey &&
|
|
652
701
|
!event.metaKey) {
|
|
653
702
|
onEnter === null || onEnter === void 0 ? void 0 : onEnter(event);
|
|
654
|
-
//
|
|
655
|
-
//
|
|
656
|
-
// via Base UI's onBlur and restore focus immediately after.
|
|
703
|
+
// Commit on Enter. Base UI commits on blur, not Enter, so round-trip
|
|
704
|
+
// focus to fire onValueCommitted via blur and restore focus immediately.
|
|
657
705
|
const target = event.currentTarget;
|
|
658
706
|
target.blur();
|
|
659
707
|
target.focus();
|
|
660
708
|
}
|
|
661
709
|
}, [onKeyDown, onEnter]);
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
child.type === InputNumberExperimentalAffixCompound ||
|
|
665
|
-
child.type === InputNumberExperimentalStepperCompound)), [children]);
|
|
666
|
-
const showStepper = !disabled && !readonly;
|
|
667
|
-
// `handleKeyDown` is a `useCallback` whose own deps include `onKeyDown` and
|
|
668
|
-
// `onEnter`, so listing it here transitively tracks both. Don't add `onEnter`
|
|
669
|
-
// or `onKeyDown` separately — they'd be redundant and an exhaustive-deps lint
|
|
670
|
-
// would flag the duplication.
|
|
710
|
+
// `handleKeyDown` transitively tracks `onKeyDown`/`onEnter` via its own deps,
|
|
711
|
+
// so they are intentionally not listed separately here.
|
|
671
712
|
const contextValue = React.useMemo(() => ({
|
|
672
|
-
|
|
673
|
-
|
|
713
|
+
align,
|
|
714
|
+
autoComplete,
|
|
674
715
|
disabled,
|
|
716
|
+
format,
|
|
675
717
|
id,
|
|
676
718
|
innerInputRef,
|
|
677
|
-
|
|
719
|
+
inputMode,
|
|
678
720
|
loading,
|
|
721
|
+
max,
|
|
679
722
|
maxLength,
|
|
723
|
+
min,
|
|
680
724
|
onBlur,
|
|
681
725
|
onFocus,
|
|
682
726
|
onKeyDown: handleKeyDown,
|
|
683
727
|
onKeyUp,
|
|
684
|
-
|
|
685
|
-
|
|
728
|
+
onValueChange: handleValueChange,
|
|
729
|
+
onValueCommitted: handleValueCommitted,
|
|
730
|
+
readOnly,
|
|
686
731
|
showMiniLabel,
|
|
687
|
-
showStepper,
|
|
732
|
+
showStepper: !disabled && !readOnly,
|
|
688
733
|
size,
|
|
734
|
+
step,
|
|
735
|
+
value,
|
|
689
736
|
}), [
|
|
690
|
-
|
|
691
|
-
|
|
737
|
+
align,
|
|
738
|
+
autoComplete,
|
|
692
739
|
disabled,
|
|
740
|
+
format,
|
|
693
741
|
id,
|
|
694
|
-
|
|
742
|
+
inputMode,
|
|
695
743
|
loading,
|
|
744
|
+
max,
|
|
696
745
|
maxLength,
|
|
746
|
+
min,
|
|
697
747
|
onBlur,
|
|
698
748
|
onFocus,
|
|
699
749
|
handleKeyDown,
|
|
700
750
|
onKeyUp,
|
|
701
|
-
|
|
702
|
-
|
|
751
|
+
handleValueChange,
|
|
752
|
+
handleValueCommitted,
|
|
753
|
+
readOnly,
|
|
703
754
|
showMiniLabel,
|
|
704
|
-
showStepper,
|
|
705
755
|
size,
|
|
756
|
+
step,
|
|
757
|
+
value,
|
|
706
758
|
]);
|
|
707
|
-
const
|
|
708
|
-
return (React.createElement(FieldRoot, {
|
|
709
|
-
React.createElement(InputNumberExperimentalContext.Provider, { value: contextValue },
|
|
710
|
-
React.createElement(NumberFieldInput.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 },
|
|
711
|
-
React.createElement(NumberFieldInput.NumberFieldGroup, { className: classnames(styles.wrapper, align && styles[align], disabled && styles.disabled, size !== "default" && styles[size]) }, isUsingCompoundPattern
|
|
712
|
-
? children
|
|
713
|
-
: renderDefaultComposition({ prefix, suffix, size })))),
|
|
714
|
-
(description || error) && (React.createElement("div", { className: styles.belowField },
|
|
715
|
-
description && (React.createElement(FieldDescription, { className: styles.description }, description)),
|
|
716
|
-
error && (React.createElement(FieldError, { className: styles.fieldError, match: true, role: "alert" }, error))))));
|
|
759
|
+
const rootProps = useRenderElement.mergeProps({ className: classnames(styles.container, inline && styles.inline) }, { className, style });
|
|
760
|
+
return (React.createElement(FieldRoot, Object.assign({}, rootProps, { disabled: disabled, invalid: invalid || undefined, name: name }),
|
|
761
|
+
React.createElement(InputNumberExperimentalContext.Provider, { value: contextValue }, children)));
|
|
717
762
|
}
|
|
718
|
-
function
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
763
|
+
function InputNumberExperimentalGroup({ children, className, style, }) {
|
|
764
|
+
var _a, _b;
|
|
765
|
+
const ctx = useInputNumberExperimentalContext("Group");
|
|
766
|
+
const groupProps = useRenderElement.mergeProps({
|
|
767
|
+
className: classnames(styles.wrapper, ctx.align && styles[ctx.align], ctx.disabled && styles.disabled, ctx.size !== "default" && styles[ctx.size]),
|
|
768
|
+
}, { className, style });
|
|
769
|
+
return (React.createElement(NumberFieldInput.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 },
|
|
770
|
+
React.createElement(NumberFieldInput.NumberFieldGroup, Object.assign({}, groupProps), children)));
|
|
725
771
|
}
|
|
726
|
-
function
|
|
727
|
-
|
|
772
|
+
function InputNumberExperimentalFooter({ children, className, style, }) {
|
|
773
|
+
useInputNumberExperimentalContext("Footer");
|
|
774
|
+
const rootProps = useRenderElement.mergeProps({ className: styles.belowField }, { className, style });
|
|
775
|
+
return React.createElement("div", Object.assign({}, rootProps), children);
|
|
776
|
+
}
|
|
777
|
+
function InputNumberExperimentalInput({ children, className, style, }) {
|
|
728
778
|
const ctx = useInputNumberExperimentalContext("Input");
|
|
729
|
-
const labelText = (_a = props.placeholder) !== null && _a !== void 0 ? _a : ctx.placeholder;
|
|
730
779
|
const rootProps = useRenderElement.mergeProps({
|
|
731
780
|
className: classnames(styles.inputWrapper, !ctx.showMiniLabel && styles.hideLabel, ctx.size !== "default" && styles[ctx.size], ctx.disabled && styles.disabled),
|
|
732
|
-
}, { className
|
|
781
|
+
}, { className, style });
|
|
733
782
|
return (React.createElement("div", Object.assign({}, rootProps),
|
|
734
|
-
React.createElement(NumberFieldInput.NumberFieldInput, { "aria-busy": ctx.loading || undefined, autoComplete:
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
783
|
+
React.createElement(NumberFieldInput.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 }),
|
|
784
|
+
children));
|
|
785
|
+
}
|
|
786
|
+
function InputNumberExperimentalLabel({ children, className, style, }) {
|
|
787
|
+
const ctx = useInputNumberExperimentalContext("Label");
|
|
788
|
+
if (!children)
|
|
789
|
+
return null;
|
|
790
|
+
return (React.createElement(FieldLabel, { className: classnames(styles.label, className), htmlFor: ctx.id, style: style }, children));
|
|
791
|
+
}
|
|
792
|
+
function InputNumberExperimentalDescription({ children, className, style, }) {
|
|
793
|
+
useInputNumberExperimentalContext("Description");
|
|
794
|
+
if (!children)
|
|
795
|
+
return null;
|
|
796
|
+
return (React.createElement(FieldDescription, { className: classnames(styles.description, className), style: style }, children));
|
|
797
|
+
}
|
|
798
|
+
function InputNumberExperimentalError({ children, className, style, }) {
|
|
799
|
+
useInputNumberExperimentalContext("Error");
|
|
800
|
+
if (!children)
|
|
801
|
+
return null;
|
|
802
|
+
return (React.createElement(FieldError, { className: classnames(styles.fieldError, className), match: true, role: "alert", style: style }, children));
|
|
803
|
+
}
|
|
804
|
+
function InputNumberExperimentalLoading({ children, className, style, }) {
|
|
805
|
+
useInputNumberExperimentalContext("Loading");
|
|
806
|
+
const rootProps = useRenderElement.mergeProps({ className: styles.loadingIndicator }, { className, style });
|
|
807
|
+
return (React.createElement("div", Object.assign({}, rootProps), children !== null && children !== void 0 ? children : React.createElement(ActivityIndicator.ActivityIndicator, { size: "small" })));
|
|
808
|
+
}
|
|
809
|
+
function InputNumberExperimentalStepper({ children, incrementLabel, decrementLabel, className, style, }) {
|
|
810
|
+
const ctx = useInputNumberExperimentalContext("Stepper");
|
|
811
|
+
if (ctx.loading || !ctx.showStepper) {
|
|
812
|
+
return null;
|
|
813
|
+
}
|
|
814
|
+
const rootProps = useRenderElement.mergeProps({ className: styles.stepper }, { className, style });
|
|
815
|
+
return (React.createElement("div", Object.assign({}, rootProps), children !== null && children !== void 0 ? children : (React.createElement(React.Fragment, null,
|
|
816
|
+
React.createElement(InputNumberExperimentalIncrement, { ariaLabel: incrementLabel }),
|
|
817
|
+
React.createElement(InputNumberExperimentalDecrement, { ariaLabel: decrementLabel })))));
|
|
818
|
+
}
|
|
819
|
+
function InputNumberExperimentalIncrement({ children, ariaLabel, className, style, }) {
|
|
820
|
+
useInputNumberExperimentalContext("Increment");
|
|
821
|
+
const rootProps = useRenderElement.mergeProps({ className: styles.stepperButton }, { className, style });
|
|
822
|
+
return (React.createElement(NumberFieldInput.NumberFieldIncrement, Object.assign({ "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : "Increase value" }, rootProps), children !== null && children !== void 0 ? children : (React.createElement(Icon.Icon, { name: "arrowUp", size: "small", customColor: "currentColor" }))));
|
|
823
|
+
}
|
|
824
|
+
function InputNumberExperimentalDecrement({ children, ariaLabel, className, style, }) {
|
|
825
|
+
useInputNumberExperimentalContext("Decrement");
|
|
826
|
+
const rootProps = useRenderElement.mergeProps({ className: styles.stepperButton }, { className, style });
|
|
827
|
+
return (React.createElement(NumberFieldInput.NumberFieldDecrement, Object.assign({ "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : "Decrease value" }, rootProps), children !== null && children !== void 0 ? children : (React.createElement(Icon.Icon, { name: "arrowDown", size: "small", customColor: "currentColor" }))));
|
|
738
828
|
}
|
|
739
829
|
function InputNumberExperimentalAffixCompound({ variation, label, icon, onClick, ariaLabel, children, className, style, }) {
|
|
740
830
|
const ctx = useInputNumberExperimentalContext("Affix");
|
|
@@ -749,23 +839,20 @@ function InputNumberExperimentalAffixCompound({ variation, label, icon, onClick,
|
|
|
749
839
|
label && React.createElement("span", { className: styles.affixLabelText }, label),
|
|
750
840
|
children));
|
|
751
841
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
}
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
React.createElement(Icon.Icon, { name: "arrowUp", size: "small", customColor: "currentColor" })),
|
|
767
|
-
React.createElement(NumberFieldInput.NumberFieldDecrement, { "aria-label": resolvedDecrementLabel, className: styles.stepperButton },
|
|
768
|
-
React.createElement(Icon.Icon, { name: "arrowDown", size: "small", customColor: "currentColor" }))));
|
|
842
|
+
/**
|
|
843
|
+
* Renders the prop-driven `prefix`/`suffix` affixes for the sugar component.
|
|
844
|
+
* Icons sit outside the input area; labels render next to the typed value
|
|
845
|
+
* (suffix mirrors the order). The composable `.Affix` part is the alternative
|
|
846
|
+
* when composing the field directly.
|
|
847
|
+
*/
|
|
848
|
+
function renderDefaultAffix(variation, affix, size) {
|
|
849
|
+
const icon = affix.icon && (React.createElement(AffixIconSlot, { variation: variation, icon: affix.icon, size: size, ariaLabel: "ariaLabel" in affix ? affix.ariaLabel : undefined, onClick: "onClick" in affix ? affix.onClick : undefined }));
|
|
850
|
+
const affixLabel = affix.label && (React.createElement(AffixLabelSlot, { variation: variation, label: affix.label }));
|
|
851
|
+
return variation === "prefix" ? (React.createElement(React.Fragment, null,
|
|
852
|
+
icon,
|
|
853
|
+
affixLabel)) : (React.createElement(React.Fragment, null,
|
|
854
|
+
affixLabel,
|
|
855
|
+
icon));
|
|
769
856
|
}
|
|
770
857
|
function AffixIconSlot({ variation, icon, size, onClick, ariaLabel, }) {
|
|
771
858
|
return (React.createElement("div", { className: classnames(styles.affixIcon, variation === "suffix" && styles.suffix) },
|
|
@@ -781,25 +868,65 @@ function AffixIconContent({ icon, size, onClick, ariaLabel, }) {
|
|
|
781
868
|
function AffixLabelSlot({ variation, label }) {
|
|
782
869
|
return (React.createElement("div", { className: classnames(styles.affixLabel, variation === "prefix" && styles.prefix, variation === "suffix" && styles.suffix) }, label));
|
|
783
870
|
}
|
|
784
|
-
function
|
|
785
|
-
if (
|
|
871
|
+
function resolveAutoComplete(autoComplete) {
|
|
872
|
+
if (autoComplete === false)
|
|
786
873
|
return "off";
|
|
787
|
-
if (
|
|
874
|
+
if (autoComplete === true || autoComplete === undefined)
|
|
788
875
|
return undefined;
|
|
789
|
-
return
|
|
876
|
+
return autoComplete;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Sugar layer: composes the parts from props. This is the same composition a
|
|
880
|
+
* consumer would write by hand with `<InputNumberExperimental.Wrapper>` and the
|
|
881
|
+
* parts — to customize a single piece, copy this tree and swap that part.
|
|
882
|
+
*/
|
|
883
|
+
function InputNumberExperimentalInternal(props, ref) {
|
|
884
|
+
var _a;
|
|
885
|
+
const { label, description, error, prefix, suffix } = props, config = tslib_es6.__rest(props, ["label", "description", "error", "prefix", "suffix"]);
|
|
886
|
+
const size = (_a = config.size) !== null && _a !== void 0 ? _a : "default";
|
|
887
|
+
return (React.createElement(InputNumberExperimentalWrapper, Object.assign({}, config, { invalid: config.invalid || Boolean(error), ref: ref }),
|
|
888
|
+
React.createElement(InputNumberExperimentalGroup, null,
|
|
889
|
+
prefix && renderDefaultAffix("prefix", prefix, size),
|
|
890
|
+
React.createElement(InputNumberExperimentalInput, null,
|
|
891
|
+
React.createElement(InputNumberExperimentalLabel, null, label),
|
|
892
|
+
config.loading ? (React.createElement(InputNumberExperimentalLoading, null)) : (React.createElement(InputNumberExperimentalStepper, { incrementLabel: `Increase ${label !== null && label !== void 0 ? label : "value"}`, decrementLabel: `Decrease ${label !== null && label !== void 0 ? label : "value"}` }))),
|
|
893
|
+
suffix && renderDefaultAffix("suffix", suffix, size)),
|
|
894
|
+
(description || error) && (React.createElement(InputNumberExperimentalFooter, null,
|
|
895
|
+
React.createElement(InputNumberExperimentalDescription, null, description),
|
|
896
|
+
React.createElement(InputNumberExperimentalError, null, error)))));
|
|
790
897
|
}
|
|
898
|
+
const InputNumberExperimentalWrapper = React.forwardRef(InputNumberExperimentalWrapperInternal);
|
|
899
|
+
InputNumberExperimentalWrapper.displayName = "InputNumberExperimental.Wrapper";
|
|
791
900
|
const InputNumberExperimentalBase = React.forwardRef(InputNumberExperimentalInternal);
|
|
792
901
|
InputNumberExperimentalBase.displayName = "InputNumberExperimental";
|
|
793
|
-
|
|
794
|
-
|
|
902
|
+
InputNumberExperimentalGroup.displayName = "InputNumberExperimental.Group";
|
|
903
|
+
InputNumberExperimentalFooter.displayName = "InputNumberExperimental.Footer";
|
|
904
|
+
InputNumberExperimentalInput.displayName = "InputNumberExperimental.Input";
|
|
905
|
+
InputNumberExperimentalLabel.displayName = "InputNumberExperimental.Label";
|
|
906
|
+
InputNumberExperimentalDescription.displayName =
|
|
907
|
+
"InputNumberExperimental.Description";
|
|
908
|
+
InputNumberExperimentalError.displayName = "InputNumberExperimental.Error";
|
|
909
|
+
InputNumberExperimentalLoading.displayName = "InputNumberExperimental.Loading";
|
|
910
|
+
InputNumberExperimentalStepper.displayName = "InputNumberExperimental.Stepper";
|
|
911
|
+
InputNumberExperimentalIncrement.displayName =
|
|
912
|
+
"InputNumberExperimental.Increment";
|
|
913
|
+
InputNumberExperimentalDecrement.displayName =
|
|
914
|
+
"InputNumberExperimental.Decrement";
|
|
795
915
|
InputNumberExperimentalAffixCompound.displayName =
|
|
796
916
|
"InputNumberExperimental.Affix";
|
|
797
|
-
InputNumberExperimentalStepperCompound.displayName =
|
|
798
|
-
"InputNumberExperimental.Stepper";
|
|
799
917
|
const InputNumberExperimental = Object.assign(InputNumberExperimentalBase, {
|
|
800
|
-
|
|
918
|
+
Wrapper: InputNumberExperimentalWrapper,
|
|
919
|
+
Group: InputNumberExperimentalGroup,
|
|
920
|
+
Footer: InputNumberExperimentalFooter,
|
|
921
|
+
Input: InputNumberExperimentalInput,
|
|
922
|
+
Label: InputNumberExperimentalLabel,
|
|
923
|
+
Description: InputNumberExperimentalDescription,
|
|
924
|
+
Error: InputNumberExperimentalError,
|
|
925
|
+
Loading: InputNumberExperimentalLoading,
|
|
926
|
+
Stepper: InputNumberExperimentalStepper,
|
|
927
|
+
Increment: InputNumberExperimentalIncrement,
|
|
928
|
+
Decrement: InputNumberExperimentalDecrement,
|
|
801
929
|
Affix: InputNumberExperimentalAffixCompound,
|
|
802
|
-
Stepper: InputNumberExperimentalStepperCompound,
|
|
803
930
|
});
|
|
804
931
|
|
|
805
932
|
exports.InputNumberExperimental = InputNumberExperimental;
|