@eightshift/ui-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/Checkbox-BLcVbhiO.js +178 -0
- package/dist/ColorSwatch-Cmlex_kT.js +66 -0
- package/dist/FieldError-wtMA4667.js +42 -0
- package/dist/FocusScope-1u9yyfIN.js +725 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/GridList-BZPXp3_O.js +1256 -0
- package/dist/Group-DyqpTRPe.js +49 -0
- package/dist/Input-jsbb4ugq.js +130 -0
- package/dist/Label-BPzS-sR7.js +17 -0
- package/dist/ListBox-w9gDaJkV.js +4423 -0
- package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
- package/dist/NumberFormatter-LzoKy975.js +160 -0
- package/dist/RSPContexts-CrNYmadY.js +14 -0
- package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
- package/dist/SelectionManager-mefd0ThJ.js +2155 -0
- package/dist/Separator-DHn0CwdK.js +325 -0
- package/dist/Slider-Pyh2V4bY.js +885 -0
- package/dist/Text-BM136LvS.js +17 -0
- package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
- package/dist/assets/style.css +1 -0
- package/dist/button-BkkdyHfJ.js +307 -0
- package/dist/components/animated-visibility/animated-visibility.js +7165 -0
- package/dist/components/base-control/base-control.js +97 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
- package/dist/components/button/button.js +10 -0
- package/dist/components/checkbox/checkbox.js +119 -0
- package/dist/components/color-pickers/color-picker.js +242 -0
- package/dist/components/color-pickers/color-swatch.js +62 -0
- package/dist/components/color-pickers/gradient-editor.js +516 -0
- package/dist/components/color-pickers/solid-color-picker.js +1633 -0
- package/dist/components/component-toggle/component-toggle.js +71 -0
- package/dist/components/container-panel/container-panel.js +39 -0
- package/dist/components/expandable/expandable.js +144 -0
- package/dist/components/input-field/input-field.js +224 -0
- package/dist/components/link-input/link-input.js +937 -0
- package/dist/components/list-box/list-box.js +152 -0
- package/dist/components/matrix-align/matrix-align.js +185 -0
- package/dist/components/menu/menu.js +1608 -0
- package/dist/components/notice/notice.js +119 -0
- package/dist/components/number-picker/number-picker.js +277 -0
- package/dist/components/popover/popover.js +9 -0
- package/dist/components/radio/radio.js +552 -0
- package/dist/components/repeater/repeater-item.js +127 -0
- package/dist/components/repeater/repeater.js +248 -0
- package/dist/components/responsive/responsive-legacy.js +326 -0
- package/dist/components/responsive/responsive.js +499 -0
- package/dist/components/responsive-preview/responsive-preview.js +119 -0
- package/dist/components/rich-label/rich-label.js +56 -0
- package/dist/components/select/async-multi-select.js +144 -0
- package/dist/components/select/async-single-select.js +126 -0
- package/dist/components/select/custom-select-default-components.js +38 -0
- package/dist/components/select/multi-select-components.js +8 -0
- package/dist/components/select/multi-select.js +134 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +45 -0
- package/dist/components/select/single-select.js +116 -0
- package/dist/components/select/styles.js +55 -0
- package/dist/components/slider/column-config-slider.js +225 -0
- package/dist/components/slider/slider.js +362 -0
- package/dist/components/slider/utils.js +45 -0
- package/dist/components/spacer/spacer.js +93 -0
- package/dist/components/tabs/tabs.js +626 -0
- package/dist/components/toggle/switch.js +140 -0
- package/dist/components/toggle/toggle.js +58 -0
- package/dist/components/toggle-button/toggle-button.js +206 -0
- package/dist/components/tooltip/tooltip.js +10 -0
- package/dist/context-jMy6xdVq.js +98 -0
- package/dist/default-i18n-BhE-OUmt.js +873 -0
- package/dist/filterDOMProps-DG2RfOUr.js +30 -0
- package/dist/focusSafely-C3K8zAKj.js +743 -0
- package/dist/hooks/use-cell-edit-mode.js +35 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +21 -0
- package/dist/icons/icons.js +3636 -0
- package/dist/index-Bfb9bWcb.js +28844 -0
- package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
- package/dist/index.js +109 -0
- package/dist/intlStrings-CUhoK9EN.js +2484 -0
- package/dist/isScrollable-PcyglExV.js +10 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-CjVpCNko.js +3677 -0
- package/dist/number-rWqELA8W.js +39 -0
- package/dist/popover-Dx3vKXUX.js +1061 -0
- package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
- package/dist/react-select.esm-BjRWqf0E.js +15 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-BosCCRVE.js +89 -0
- package/dist/tooltip-CkCndvTI.js +1094 -0
- package/dist/useButton-CuG5UzUw.js +74 -0
- package/dist/useEvent-DHv-yhOH.js +24 -0
- package/dist/useFocusRing-Cc-4eouh.js +41 -0
- package/dist/useFocusable-5q1Gek1J.js +81 -0
- package/dist/useFormReset-Buc9YJcv.js +23 -0
- package/dist/useFormValidationState-BAPPNXic.js +238 -0
- package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
- package/dist/useLabel-CGlkoFG0.js +28 -0
- package/dist/useLabels-Dg62M_3P.js +25 -0
- package/dist/useListData-BelKu4kx.js +211 -0
- package/dist/useListState-Domq0blV.js +137 -0
- package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
- package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
- package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
- package/dist/usePress-BQgVor4T.js +698 -0
- package/dist/useToggle-C9ETOBaZ.js +58 -0
- package/dist/useToggleState-DJ_z5E2S.js +21 -0
- package/dist/utilities/classnames.js +16 -0
- package/dist/utilities/text-helpers.js +79 -0
- package/dist/utils-BsiH7-5Y.js +488 -0
- package/package.json +71 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
3
|
+
import { icons } from "../../icons/icons.js";
|
|
4
|
+
/**
|
|
5
|
+
* A simple notice component.
|
|
6
|
+
*
|
|
7
|
+
* @component
|
|
8
|
+
* @param {Object} props - Component props.
|
|
9
|
+
* @param {JSX.Element} [props.icon] - Icon to display within the notice.
|
|
10
|
+
* @param {string} [props.label] - The label of the notice.
|
|
11
|
+
* @param {string} [props.subtitle] - The subtitle of the notice.
|
|
12
|
+
* @param {string} [props.className] - Classes to pass to the notice.
|
|
13
|
+
* @param {NoticeType} [props.type='default'] - The type of the notice.
|
|
14
|
+
* @param {boolean} [props.alignIconToTitle=false] - If `true`, the icon will be aligned to the first row of title, instead of vertically centered.
|
|
15
|
+
*
|
|
16
|
+
* @returns {JSX.Element} The Notice component.
|
|
17
|
+
*
|
|
18
|
+
* @typedef {'info' | 'success' | 'warning' | 'error' | 'placeholder' | 'default'} NoticeType
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* <Notice label='This is a notice' />
|
|
22
|
+
*
|
|
23
|
+
* @preserve
|
|
24
|
+
*/
|
|
25
|
+
const Notice = (props) => {
|
|
26
|
+
const { icon, label, subtitle, className, type = "default", alignIconToTitle = false } = props;
|
|
27
|
+
const styles = {
|
|
28
|
+
info: {
|
|
29
|
+
icon: icons.infoCircle,
|
|
30
|
+
className: "es-uic-border-blue-400 es-uic-shadow-blue-500/15 es-uic-bg-blue-100/5",
|
|
31
|
+
iconColor: "es-uic-text-blue-400",
|
|
32
|
+
textColor: "es-uic-text-blue-900",
|
|
33
|
+
subtitleColor: "es-uic-text-blue-950/60"
|
|
34
|
+
},
|
|
35
|
+
success: {
|
|
36
|
+
icon: icons.checkSquare,
|
|
37
|
+
className: "es-uic-border-green-500 es-uic-shadow-green-500/15 es-uic-bg-green-100/5",
|
|
38
|
+
iconColor: "es-uic-text-green-500",
|
|
39
|
+
textColor: "es-uic-text-green-900",
|
|
40
|
+
subtitleColor: "es-uic-text-green-950/60"
|
|
41
|
+
},
|
|
42
|
+
warning: {
|
|
43
|
+
icon: icons.warning,
|
|
44
|
+
className: "es-uic-border-amber-500 es-uic-shadow-amber-500/15 es-uic-bg-amber-100/5",
|
|
45
|
+
iconColor: "es-uic-text-amber-500",
|
|
46
|
+
textColor: "es-uic-text-amber-900",
|
|
47
|
+
subtitleColor: "es-uic-text-amber-950/60"
|
|
48
|
+
},
|
|
49
|
+
error: {
|
|
50
|
+
icon: icons.errorCircle,
|
|
51
|
+
className: "es-uic-border-red-400 es-uic-shadow-red-500/15 es-uic-bg-red-100/5",
|
|
52
|
+
iconColor: "es-uic-text-red-400",
|
|
53
|
+
textColor: "es-uic-text-red-900",
|
|
54
|
+
subtitleColor: "es-uic-text-red-950/60"
|
|
55
|
+
},
|
|
56
|
+
placeholder: {
|
|
57
|
+
icon: icons.componentGeneric,
|
|
58
|
+
className: "es-uic-border-slate-300 es-uic-shadow-slate-300/25 es-uic-border-dashed es-uic-bg-slate-200/5",
|
|
59
|
+
iconColor: "es-uic-text-slate-400",
|
|
60
|
+
textColor: "es-uic-text-slate-900",
|
|
61
|
+
subtitleColor: "es-uic-text-slate-500"
|
|
62
|
+
},
|
|
63
|
+
default: {
|
|
64
|
+
className: "es-uic-border-gray-300 es-uic-shadow-gray-300/25 es-uic-bg-gray-200/5",
|
|
65
|
+
iconColor: "es-uic-text-gray-400",
|
|
66
|
+
textColor: "es-uic-text-gray-900",
|
|
67
|
+
subtitleColor: "es-uic-text-gray-500"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
className: classnames(
|
|
74
|
+
"es-uic-grid es-uic-grid-cols-[auto,_1fr] es-uic-grid-rows-[auto,_auto] es-uic-rounded-md es-uic-border es-uic-bg-gradient-to-tr es-uic-shadow-sm",
|
|
75
|
+
styles[type].className,
|
|
76
|
+
icon || styles[type].icon ? "es-uic-gap-x-1.5 es-uic-p-1.5" : "es-uic-py-1.5 es-uic-px-2",
|
|
77
|
+
className
|
|
78
|
+
),
|
|
79
|
+
children: [
|
|
80
|
+
(icon || styles[type].icon) && /* @__PURE__ */ jsx(
|
|
81
|
+
"span",
|
|
82
|
+
{
|
|
83
|
+
className: classnames(
|
|
84
|
+
"es-uic-col-span-1 es-uic-col-start-1 es-uic-row-span-2 es-uic-row-start-1 es-uic-shrink-0 es-uic-self-center [&>svg]:es-uic-size-7",
|
|
85
|
+
alignIconToTitle ? "es-uic-self-baseline" : "es-uic-self-center",
|
|
86
|
+
styles[type].iconColor
|
|
87
|
+
),
|
|
88
|
+
children: icon ?? styles[type].icon
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
label && /* @__PURE__ */ jsx(
|
|
92
|
+
"span",
|
|
93
|
+
{
|
|
94
|
+
className: classnames(
|
|
95
|
+
"es-uic-col-span-2 es-uic-col-start-2 es-uic-text-balance es-uic-text-sm es-uic-leading-tight",
|
|
96
|
+
subtitle ? "es-uic-self-end" : "es-uic-row-span-2 es-uic-self-center",
|
|
97
|
+
styles[type].textColor
|
|
98
|
+
),
|
|
99
|
+
children: label
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
subtitle && /* @__PURE__ */ jsx(
|
|
103
|
+
"span",
|
|
104
|
+
{
|
|
105
|
+
className: classnames(
|
|
106
|
+
"es-uic-col-span-2 es-uic-col-start-2 es-uic-text-balance es-uic-text-xs es-uic-leading-tight",
|
|
107
|
+
styles[type].subtitleColor,
|
|
108
|
+
label ? "es-uic-self-start" : "es-uic-row-span-2 es-uic-self-center"
|
|
109
|
+
),
|
|
110
|
+
children: subtitle
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
) });
|
|
116
|
+
};
|
|
117
|
+
export {
|
|
118
|
+
Notice
|
|
119
|
+
};
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React__default, { forwardRef, useRef, createContext, useState, cloneElement } from "react";
|
|
3
|
+
import { $ as $a049562f99e7db0e$export$f9c6924e160136d1, a as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4 } from "../../Group-DyqpTRPe.js";
|
|
4
|
+
import { $ as $3985021b0ad6602f$export$37fb8590cf2c088c, a as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-jsbb4ugq.js";
|
|
5
|
+
import { a as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-BPzS-sR7.js";
|
|
6
|
+
import { $ as $d2b4bc8c273e7be6$export$24d547caef80ccd1, B as Button } from "../../button-BkkdyHfJ.js";
|
|
7
|
+
import { a as $64fa3d84918910a7$export$29f1550f4b0d4415, $ as $64fa3d84918910a7$export$fabf2dc03a41866e, h as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, i as $64fa3d84918910a7$export$ef03459518577ad4, c as $64fa3d84918910a7$export$4d86445c2cf5e3, j as $64fa3d84918910a7$export$2881499e37b75b9a } from "../../utils-BsiH7-5Y.js";
|
|
8
|
+
import { $ as $ee014567cb39d3f0$export$ff05c3ac10437e03 } from "../../FieldError-wtMA4667.js";
|
|
9
|
+
import { $ as $d3e0e05bdfcf66bd$export$c24727297075ec6a } from "../../Form-Cq3fu75_.js";
|
|
10
|
+
import { a as $514c0188e459b4c0$export$9afb8bc826b033ea } from "../../Text-BM136LvS.js";
|
|
11
|
+
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-DG2RfOUr.js";
|
|
12
|
+
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "../../context-jMy6xdVq.js";
|
|
13
|
+
import { $ as $de67e98908f0c6ee$export$7f629e9dc1ecf37c, a as $81397a9303501bda$export$23f548e970bdf099 } from "../../useNumberFieldState-BLU3uhSR.js";
|
|
14
|
+
import { icons } from "../../icons/icons.js";
|
|
15
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
16
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
17
|
+
const $b91743d66a0ed188$export$b414a48cf5dcbc11 = /* @__PURE__ */ createContext(null);
|
|
18
|
+
const $b91743d66a0ed188$export$6cc906c6cff9bec5 = /* @__PURE__ */ createContext(null);
|
|
19
|
+
function $b91743d66a0ed188$var$NumberField(props, ref) {
|
|
20
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $b91743d66a0ed188$export$b414a48cf5dcbc11);
|
|
21
|
+
let { validationBehavior: formValidationBehavior } = $64fa3d84918910a7$export$fabf2dc03a41866e($d3e0e05bdfcf66bd$export$c24727297075ec6a) || {};
|
|
22
|
+
var _props_validationBehavior, _ref;
|
|
23
|
+
let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : "native";
|
|
24
|
+
let { locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
25
|
+
let state = $de67e98908f0c6ee$export$7f629e9dc1ecf37c({
|
|
26
|
+
...props,
|
|
27
|
+
locale,
|
|
28
|
+
validationBehavior
|
|
29
|
+
});
|
|
30
|
+
let inputRef = useRef(null);
|
|
31
|
+
let [labelRef, label] = $64fa3d84918910a7$export$9d4c57ee4c6ffdd8();
|
|
32
|
+
let { labelProps, groupProps, inputProps, incrementButtonProps, decrementButtonProps, descriptionProps, errorMessageProps, ...validation } = $81397a9303501bda$export$23f548e970bdf099({
|
|
33
|
+
...$64fa3d84918910a7$export$ef03459518577ad4(props),
|
|
34
|
+
label,
|
|
35
|
+
validationBehavior
|
|
36
|
+
}, state, inputRef);
|
|
37
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
38
|
+
...props,
|
|
39
|
+
values: {
|
|
40
|
+
state,
|
|
41
|
+
isDisabled: props.isDisabled || false,
|
|
42
|
+
isInvalid: validation.isInvalid || false
|
|
43
|
+
},
|
|
44
|
+
defaultClassName: "react-aria-NumberField"
|
|
45
|
+
});
|
|
46
|
+
let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
|
|
47
|
+
delete DOMProps.id;
|
|
48
|
+
return /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
|
|
49
|
+
values: [
|
|
50
|
+
[
|
|
51
|
+
$b91743d66a0ed188$export$6cc906c6cff9bec5,
|
|
52
|
+
state
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
$a049562f99e7db0e$export$f9c6924e160136d1,
|
|
56
|
+
groupProps
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
$3985021b0ad6602f$export$37fb8590cf2c088c,
|
|
60
|
+
{
|
|
61
|
+
...inputProps,
|
|
62
|
+
ref: inputRef
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
$01b77f81d0f07f68$export$75b6ee27786ba447,
|
|
67
|
+
{
|
|
68
|
+
...labelProps,
|
|
69
|
+
ref: labelRef
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
$d2b4bc8c273e7be6$export$24d547caef80ccd1,
|
|
74
|
+
{
|
|
75
|
+
slots: {
|
|
76
|
+
increment: incrementButtonProps,
|
|
77
|
+
decrement: decrementButtonProps
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
$514c0188e459b4c0$export$9afb8bc826b033ea,
|
|
83
|
+
{
|
|
84
|
+
slots: {
|
|
85
|
+
description: descriptionProps,
|
|
86
|
+
errorMessage: errorMessageProps
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
$ee014567cb39d3f0$export$ff05c3ac10437e03,
|
|
92
|
+
validation
|
|
93
|
+
]
|
|
94
|
+
]
|
|
95
|
+
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
96
|
+
...DOMProps,
|
|
97
|
+
...renderProps,
|
|
98
|
+
ref,
|
|
99
|
+
slot: props.slot || void 0,
|
|
100
|
+
"data-disabled": props.isDisabled || void 0,
|
|
101
|
+
"data-invalid": validation.isInvalid || void 0
|
|
102
|
+
}), props.name && /* @__PURE__ */ React__default.createElement("input", {
|
|
103
|
+
type: "hidden",
|
|
104
|
+
name: props.name,
|
|
105
|
+
value: isNaN(state.numberValue) ? "" : state.numberValue
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
const $b91743d66a0ed188$export$63c5fa0b2fdccd2e = /* @__PURE__ */ forwardRef($b91743d66a0ed188$var$NumberField);
|
|
109
|
+
/**
|
|
110
|
+
* A number picker component.
|
|
111
|
+
*
|
|
112
|
+
* @component
|
|
113
|
+
* @param {Object} props - Component props.
|
|
114
|
+
* @param {number} props.value - The current value of the number picker.
|
|
115
|
+
* @param {Function} props.onChange - Function to run when the value changes.
|
|
116
|
+
* @param {number} [props.min=0] - The minimum value of the number picker.
|
|
117
|
+
* @param {number} [props.max] - The maximum value of the number picker.
|
|
118
|
+
* @param {number} [props.step=1] - The step value of the number picker.
|
|
119
|
+
* @param {string} [props.label] - The label of the number picker.
|
|
120
|
+
* @param {JSX.Element} [props.icon] - Icon to display within the number picker.
|
|
121
|
+
* @param {string} [props.subtitle] - The subtitle of the number picker.
|
|
122
|
+
* @param {string} [props.help] - The help text shown below the number picker.
|
|
123
|
+
* @param {boolean} [props.readOnly] - If `true`, the number picker is read-only.
|
|
124
|
+
* @param {boolean} [props.disabled] - If `true`, the number picker is disabled.
|
|
125
|
+
* @param {string} [props.placeholder] - Placeholder text to display in the number picker.
|
|
126
|
+
* @param {JSX.Element} [props.prefix] - Element to display to the left of the number picker.
|
|
127
|
+
* @param {JSX.Element} [props.suffix] - Element to display to the right of the number picker.
|
|
128
|
+
* @param {number} [props.fixedWidth] - If passed, sets the width of the input field to the provided number of characters. Useful if you have e.g. value from 1 to 1000, but you don't want the input field to change size when on lower values.
|
|
129
|
+
* @param {boolean} [props.inline] - If `true`, the number picker is displayed inline.
|
|
130
|
+
* @param {boolean} [props.noScrollToChange=false] - If `true`, the number picker does not change value when scrolling.
|
|
131
|
+
* @param {NumberPickerSize} [props.size='default'] - Determines the input field size.
|
|
132
|
+
*
|
|
133
|
+
* @returns {JSX.Element} The NumberPicker component.
|
|
134
|
+
*
|
|
135
|
+
* @typedef {'compact' | 'small' | 'default'} NumberPickerSize
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* <NumberPicker
|
|
139
|
+
* value={value}
|
|
140
|
+
* onChange={setValue}
|
|
141
|
+
* />
|
|
142
|
+
*
|
|
143
|
+
* @preserve
|
|
144
|
+
*/
|
|
145
|
+
const NumberPicker = ({
|
|
146
|
+
value,
|
|
147
|
+
onChange,
|
|
148
|
+
min = 0,
|
|
149
|
+
max,
|
|
150
|
+
step = 1,
|
|
151
|
+
label,
|
|
152
|
+
icon,
|
|
153
|
+
subtitle,
|
|
154
|
+
help,
|
|
155
|
+
readOnly,
|
|
156
|
+
disabled,
|
|
157
|
+
placeholder,
|
|
158
|
+
prefix,
|
|
159
|
+
fixedWidth = null,
|
|
160
|
+
suffix,
|
|
161
|
+
children,
|
|
162
|
+
inline,
|
|
163
|
+
noScrollToChange = false,
|
|
164
|
+
size = "default",
|
|
165
|
+
...props
|
|
166
|
+
}) => {
|
|
167
|
+
var _a, _b, _c, _d;
|
|
168
|
+
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
169
|
+
const sizes = {
|
|
170
|
+
compact: {
|
|
171
|
+
field: "es-uic-min-h-5",
|
|
172
|
+
noPrefixPadding: "es-uic-pl-1.5"
|
|
173
|
+
},
|
|
174
|
+
small: {
|
|
175
|
+
field: "es-uic-min-h-9",
|
|
176
|
+
noPrefixPadding: "es-uic-pl-2"
|
|
177
|
+
},
|
|
178
|
+
default: {
|
|
179
|
+
field: "es-uic-min-h-10",
|
|
180
|
+
noPrefixPadding: "es-uic-pl-2"
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
return /* @__PURE__ */ jsx(
|
|
184
|
+
$b91743d66a0ed188$export$63c5fa0b2fdccd2e,
|
|
185
|
+
{
|
|
186
|
+
value,
|
|
187
|
+
onChange,
|
|
188
|
+
isDisabled: disabled,
|
|
189
|
+
isReadOnly: readOnly,
|
|
190
|
+
minValue: min,
|
|
191
|
+
maxValue: max,
|
|
192
|
+
step,
|
|
193
|
+
isWheelDisabled: noScrollToChange,
|
|
194
|
+
...props,
|
|
195
|
+
children: /* @__PURE__ */ jsx(
|
|
196
|
+
BaseControl,
|
|
197
|
+
{
|
|
198
|
+
labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
199
|
+
icon,
|
|
200
|
+
label,
|
|
201
|
+
subtitle,
|
|
202
|
+
help,
|
|
203
|
+
inline,
|
|
204
|
+
className: "text-sm",
|
|
205
|
+
children: /* @__PURE__ */ jsxs(
|
|
206
|
+
$a049562f99e7db0e$export$eb2fcfdbd7ba97d4,
|
|
207
|
+
{
|
|
208
|
+
className: classnames(
|
|
209
|
+
"es-uic-flex es-uic-w-fit es-uic-items-center es-uic-rounded-md es-uic-border es-uic-border-gray-300 es-uic-pl-1 es-uic-pr-0.5 es-uic-shadow-sm es-uic-transition",
|
|
210
|
+
isInputFocused && "es-uic-outline-none focus-visible:es-uic-ring focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50",
|
|
211
|
+
!prefix && (((_a = sizes == null ? void 0 : sizes[size]) == null ? void 0 : _a.noPrefixPadding) ?? sizes.default.noPrefixPadding),
|
|
212
|
+
((_b = sizes == null ? void 0 : sizes[size]) == null ? void 0 : _b.field) ?? sizes.default.field
|
|
213
|
+
),
|
|
214
|
+
children: [
|
|
215
|
+
prefix && /* @__PURE__ */ jsx(
|
|
216
|
+
"span",
|
|
217
|
+
{
|
|
218
|
+
slot: "prefix",
|
|
219
|
+
className: "es-uic-col-start-1 es-uic-row-span-2 es-uic-mr-0.5 es-uic-select-none es-uic-self-center es-uic-text-gray-500",
|
|
220
|
+
children: prefix
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
/* @__PURE__ */ jsx(
|
|
224
|
+
$3985021b0ad6602f$export$f5b8910cec6cf069,
|
|
225
|
+
{
|
|
226
|
+
onFocus: () => setIsInputFocused(true),
|
|
227
|
+
onBlur: () => setIsInputFocused(false),
|
|
228
|
+
className: "es-uic-col-start-2 es-uic-row-span-2 es-uic-bg-transparent es-uic-py-1 es-uic-tabular-nums focus:es-uic-outline-none es-uic-text-sm selection:es-uic-bg-teal-500/20 selection:es-uic-text-teal-950",
|
|
229
|
+
placeholder,
|
|
230
|
+
style: {
|
|
231
|
+
width: fixedWidth ? `${fixedWidth}ch` : `calc(${min < 0 ? "0.75ch + " : ""}${(_d = (_c = max ?? 1e3) == null ? void 0 : _c.toString()) == null ? void 0 : _d.length} * 1ch)`
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
),
|
|
235
|
+
suffix && /* @__PURE__ */ jsx(
|
|
236
|
+
"span",
|
|
237
|
+
{
|
|
238
|
+
slot: "suffix",
|
|
239
|
+
className: "es-uic-col-start-3 es-uic-row-span-2 es-uic-select-none es-uic-self-center es-uic-text-gray-500",
|
|
240
|
+
children: suffix
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
244
|
+
/* @__PURE__ */ jsx(
|
|
245
|
+
Button,
|
|
246
|
+
{
|
|
247
|
+
type: "ghost",
|
|
248
|
+
className: "es-uic-col-start-4 !es-uic-h-3 !es-uic-w-5 !es-uic-rounded !es-uic-text-gray-500 disabled:!es-uic-text-gray-300 [&>svg]:es-uic-size-[0.8rem]",
|
|
249
|
+
slot: "increment",
|
|
250
|
+
icon: icons.caretUpFill
|
|
251
|
+
}
|
|
252
|
+
),
|
|
253
|
+
/* @__PURE__ */ jsx(
|
|
254
|
+
Button,
|
|
255
|
+
{
|
|
256
|
+
type: "ghost",
|
|
257
|
+
className: "es-uic-col-start-4 !es-uic-h-3 !es-uic-w-5 !es-uic-rounded !es-uic-text-gray-500 disabled:!es-uic-text-gray-300 [&>svg]:es-uic-size-[0.8rem]",
|
|
258
|
+
slot: "decrement",
|
|
259
|
+
icon: icons.caretDownFill
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
] }),
|
|
263
|
+
children && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
264
|
+
/* @__PURE__ */ jsx("div", { className: "es-uic-h-[2.375rem] es-uic-w-px es-uic-bg-gray-300" }),
|
|
265
|
+
/* @__PURE__ */ jsx("div", { className: "es-uic-pl-1 es-uic-pr-0.5", children: Array.isArray(children) ? children.map((child) => cloneElement(child, { slot: null })) : cloneElement(children, { slot: null }) })
|
|
266
|
+
] })
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
export {
|
|
276
|
+
NumberPicker
|
|
277
|
+
};
|