@m4l/components 9.1.78 → 9.1.80

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.
Files changed (48) hide show
  1. package/components/Label/Label.styles.js +32 -18
  2. package/components/NumberInput/NumberInput.js +124 -0
  3. package/components/NumberInput/NumberInput.styles.js +199 -0
  4. package/components/NumberInput/constants.js +4 -0
  5. package/components/NumberInput/hooks/useNumberInput/NumberInputActions.js +12 -0
  6. package/components/NumberInput/hooks/useNumberInput/NumberInputReducer.js +106 -0
  7. package/components/NumberInput/hooks/useNumberInput/useNumberInput.js +364 -0
  8. package/components/NumberInput/slots/NumberInputEnum.js +13 -0
  9. package/components/NumberInput/slots/NumberInputSlots.js +43 -0
  10. package/components/NumberInput/utils.js +23 -0
  11. package/components/PropertyValue/PropertyValue.d.ts +1 -1
  12. package/components/PropertyValue/PropertyValue.js +5 -17
  13. package/components/PropertyValue/PropertyValue.styles.js +6 -6
  14. package/components/extended/React-Splitter/SplitLayout/SplitLayout.d.ts +14 -0
  15. package/components/extended/React-Splitter/SplitLayout/SplitLayout.js +53 -0
  16. package/components/extended/React-Splitter/SplitLayout/SplitLayout.styles.d.ts +2 -0
  17. package/components/extended/React-Splitter/SplitLayout/SplitLayout.styles.js +157 -0
  18. package/components/extended/React-Splitter/SplitLayout/constants.d.ts +9 -0
  19. package/components/extended/React-Splitter/SplitLayout/constants.js +6 -0
  20. package/components/extended/React-Splitter/SplitLayout/slots/SplitLayoutEnum.d.ts +5 -0
  21. package/components/extended/React-Splitter/SplitLayout/slots/SplitLayoutEnum.js +9 -0
  22. package/components/extended/React-Splitter/SplitLayout/slots/SplitLayoutSlots.d.ts +3 -0
  23. package/components/extended/React-Splitter/SplitLayout/slots/SplitLayoutSlots.js +21 -0
  24. package/components/extended/React-Splitter/SplitLayout/tests/SplitLayout.test.d.ts +1 -0
  25. package/components/{SplitLayout → extended/React-Splitter/SplitLayout}/types.d.ts +11 -5
  26. package/components/hook-form/RHFNumberInput/RHFNumberInput.js +89 -0
  27. package/components/hook-form/RHFNumberInput/RHFNumberInput.styles.js +16 -0
  28. package/components/hook-form/RHFNumberInput/constants.js +4 -0
  29. package/components/hook-form/RHFNumberInput/slots/RHFNumberInputEnum.js +7 -0
  30. package/components/hook-form/RHFNumberInput/slots/RHFNumberInputSlots.js +11 -0
  31. package/components/hook-form/index.d.ts +1 -0
  32. package/components/index.d.ts +2 -2
  33. package/index.js +23 -21
  34. package/package.json +1 -1
  35. package/components/SplitLayout/SplitLayout.d.ts +0 -16
  36. package/components/SplitLayout/SplitLayout.js +0 -57
  37. package/components/SplitLayout/classes/constants.d.ts +0 -1
  38. package/components/SplitLayout/classes/constants.js +0 -4
  39. package/components/SplitLayout/classes/index.d.ts +0 -17
  40. package/components/SplitLayout/classes/index.js +0 -33
  41. package/components/SplitLayout/classes/types.d.ts +0 -10
  42. package/components/SplitLayout/index.d.ts +0 -2
  43. package/components/SplitLayout/styles.d.ts +0 -3
  44. package/components/SplitLayout/styles.js +0 -29
  45. package/components/SplitLayout/tests/constants.d.ts +0 -1
  46. package/components/SplitLayout/tests/constants.js +0 -4
  47. package/components/SplitLayout/tests/utils.d.ts +0 -2
  48. package/components/SplitLayout/tests/utils.js +0 -7
@@ -8,8 +8,8 @@ const labelStyles = {
8
8
  * @returns {object} - Los estilos aplicados al root del Label.
9
9
  * @author Bruce Escobar - automatic
10
10
  * @createdAt 2024-10-22 09:34:39 - automatic
11
- * @updatedAt 2025-01-08 10:36:40 - automatic
12
- * @updatedUser Andrés Quintero - automatic
11
+ * @updatedAt 2025-01-20 18:52:54 - automatic
12
+ * @updatedUser cesar - automatic
13
13
  */
14
14
  root: ({ theme, ownerState }) => ({
15
15
  display: "flex",
@@ -17,6 +17,16 @@ const labelStyles = {
17
17
  alignItems: "center",
18
18
  flexWrap: "wrap",
19
19
  width: "fit-content",
20
+ ...getHeightSizeStyles(
21
+ theme.generalSettings.isMobile,
22
+ ownerState.size || "small",
23
+ "base",
24
+ (height) => ({
25
+ minHeight: height,
26
+ height: "auto",
27
+ maxHeight: "none"
28
+ })
29
+ ),
20
30
  gap: theme.size.baseSpacings.sp1,
21
31
  /** Estilos para el estado disabled del Label 😶‍🌫️ */
22
32
  ...ownerState.disabled && {
@@ -24,10 +34,11 @@ const labelStyles = {
24
34
  }
25
35
  }),
26
36
  /**
27
- * Estilos para el slot Typography del Label 📝
28
- * @param {object} theme - El tema de MUI.
29
- * @param {object} ownerState - El estado del componente.
30
- * @returns {object} - Los estilos aplicados al Typography del Label.
37
+ * Estilos para el slot Typography del Label.
38
+ * @author cesar - automatic
39
+ * @createdAt 2025-01-20 18:52:54 - automatic
40
+ * @updatedAt 2025-01-20 18:52:54 - automatic
41
+ * @updatedUser cesar - automatic
31
42
  */
32
43
  typographyStyled: ({ theme, ownerState }) => ({
33
44
  "&.MuiTypography-root": {
@@ -50,10 +61,11 @@ const labelStyles = {
50
61
  }
51
62
  }),
52
63
  /**
53
- * Estilos para el slot Typography del mensaje obligatorio del Label
54
- * @param {object} theme - El tema de MUI.
55
- * @param {object} ownerState - El estado del componente.
56
- * @returns {object} - Los estilos aplicados al Typography del mensaje obligatorio del Label.
64
+ * Estilos para el slot Typography del mensaje obligatorio del Label.
65
+ * @author cesar - automatic
66
+ * @createdAt 2025-01-20 18:52:54 - automatic
67
+ * @updatedAt 2025-01-20 18:52:54 - automatic
68
+ * @updatedUser cesar - automatic
57
69
  */
58
70
  typographyMandatoryMessageStyled: ({ theme, ownerState }) => ({
59
71
  "&.MuiTypography-root": {
@@ -76,10 +88,11 @@ const labelStyles = {
76
88
  }
77
89
  }),
78
90
  /**
79
- * Estilos para el slot Icon del Label 🛠️
80
- * @param {object} theme - El tema de MUI.
81
- * @param {object} ownerState - El estado del componente.
82
- * @returns {object} - Los estilos aplicados al Icon del Label.
91
+ * Estilos para el slot Icon del Label.
92
+ * @author cesar - automatic
93
+ * @createdAt 2025-01-20 18:52:54 - automatic
94
+ * @updatedAt 2025-01-20 18:52:54 - automatic
95
+ * @updatedUser cesar - automatic
83
96
  */
84
97
  iconHelperMessageStyled: ({ theme, ownerState }) => ({
85
98
  borderRadius: theme.vars.size.borderRadius.r1,
@@ -101,10 +114,11 @@ const labelStyles = {
101
114
  )
102
115
  }),
103
116
  /**
104
- * Estilos para el slot Skeleton del Label 💀
105
- * @param {object} theme - El tema de MUI.
106
- * @param {object} ownerState - El estado del componente.
107
- * @returns {object} - Los estilos aplicados al Skeleton del Label.
117
+ * Estilos para el slot Skeleton del Label.
118
+ * @author cesar - automatic
119
+ * @createdAt 2025-01-20 18:52:54 - automatic
120
+ * @updatedAt 2025-01-20 18:52:54 - automatic
121
+ * @updatedUser cesar - automatic
108
122
  */
109
123
  skeletonStyled: ({ ownerState, theme }) => ({
110
124
  width: "100%",
@@ -0,0 +1,124 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import { forwardRef } from "react";
4
+ import { useEnvironment, useModuleSkeleton } from "@m4l/core";
5
+ import { g as getComponentClasses } from "../../utils/getComponentSlotRoot.js";
6
+ import { g as getPropDataTestId } from "../../test/getNameDataTestId.js";
7
+ import { u as useNumberInput } from "./hooks/useNumberInput/useNumberInput.js";
8
+ import { S as SkeletonStyled, R as RootStyled, I as InputStyled, C as ContainButtonsAdornmentStyled, a as ContainerButtonsStyled, b as IncrementButtonStyled, D as DecrementButtonStyled } from "./slots/NumberInputSlots.js";
9
+ import { N as NUMBER_INPUT_KEY_COMPONENT } from "./constants.js";
10
+ import { N as NumberInputSlots } from "./slots/NumberInputEnum.js";
11
+ const NumberInput = forwardRef(function NumberInput2(props, forwardedRef) {
12
+ const {
13
+ className,
14
+ defaultValue,
15
+ value,
16
+ disabled = false,
17
+ endAdornment,
18
+ error,
19
+ id,
20
+ max,
21
+ min,
22
+ onBlur,
23
+ onInputChange,
24
+ onFocus,
25
+ onChange,
26
+ required,
27
+ readOnly = false,
28
+ shiftMultiplier,
29
+ startAdornment,
30
+ step,
31
+ size = "medium",
32
+ variant = "outlined",
33
+ withDecimal = false,
34
+ dataTestId
35
+ } = props;
36
+ const {
37
+ getRootProps,
38
+ getInputProps,
39
+ getIncrementButtonProps,
40
+ getDecrementButtonProps,
41
+ focusError
42
+ } = useNumberInput({
43
+ min,
44
+ max,
45
+ step,
46
+ withDecimal,
47
+ shiftMultiplier,
48
+ defaultValue,
49
+ disabled,
50
+ error,
51
+ onFocus,
52
+ onInputChange,
53
+ onBlur,
54
+ onChange,
55
+ required,
56
+ readOnly,
57
+ value,
58
+ inputId: id,
59
+ componentName: NUMBER_INPUT_KEY_COMPONENT
60
+ });
61
+ const { host_static_assets, environment_assets } = useEnvironment();
62
+ const ownerState = {
63
+ disabled,
64
+ error,
65
+ size,
66
+ variant,
67
+ focusError,
68
+ noButtons: withDecimal
69
+ };
70
+ const isSkeleton = useModuleSkeleton();
71
+ const classes = getComponentClasses(NUMBER_INPUT_KEY_COMPONENT, NumberInputSlots);
72
+ if (isSkeleton) {
73
+ return /* @__PURE__ */ jsx(
74
+ SkeletonStyled,
75
+ {
76
+ ownerState,
77
+ className: clsx(classes.skeleton, className),
78
+ ...getPropDataTestId(NUMBER_INPUT_KEY_COMPONENT, NumberInputSlots.skeleton, dataTestId)
79
+ }
80
+ );
81
+ }
82
+ const ICON_INCREMENT = `${host_static_assets}/${environment_assets}/frontend/components/ControlIncrement/assets/icons/chevron_up_sm.svg`;
83
+ const ICON_DECREMENT = `${host_static_assets}/${environment_assets}/frontend/components/ControlIncrement/assets/icons/chevron_down_sm.svg`;
84
+ return /* @__PURE__ */ jsxs(
85
+ RootStyled,
86
+ {
87
+ ...getPropDataTestId(NUMBER_INPUT_KEY_COMPONENT, NumberInputSlots.root, dataTestId),
88
+ className: clsx(classes.root, className),
89
+ ref: forwardedRef,
90
+ ownerState,
91
+ ...getRootProps(),
92
+ children: [
93
+ startAdornment,
94
+ /* @__PURE__ */ jsx(InputStyled, { className: clsx(classes.input, className), ownerState, ...getInputProps() }),
95
+ /* @__PURE__ */ jsxs(ContainButtonsAdornmentStyled, { ownerState, children: [
96
+ endAdornment,
97
+ !withDecimal && /* @__PURE__ */ jsxs(ContainerButtonsStyled, { className: clsx(classes.containerButtons, className), ownerState, children: [
98
+ /* @__PURE__ */ jsx(
99
+ IncrementButtonStyled,
100
+ {
101
+ icon: ICON_INCREMENT,
102
+ className: clsx(classes.increment, className),
103
+ ownerState,
104
+ ...getIncrementButtonProps()
105
+ }
106
+ ),
107
+ /* @__PURE__ */ jsx(
108
+ DecrementButtonStyled,
109
+ {
110
+ icon: ICON_DECREMENT,
111
+ className: clsx(classes.decrement, className),
112
+ ownerState,
113
+ ...getDecrementButtonProps()
114
+ }
115
+ )
116
+ ] })
117
+ ] })
118
+ ]
119
+ }
120
+ );
121
+ });
122
+ export {
123
+ NumberInput as N
124
+ };
@@ -0,0 +1,199 @@
1
+ import { g as getHeightSizeStyles } from "../../utils/getHeightSizeStyles.js";
2
+ const numberInputStyles = {
3
+ /**
4
+ * Estilos aplicados al contenedor principal (root).
5
+ */
6
+ root: ({ theme, ownerState }) => ({
7
+ //Estilos generales
8
+ display: "flex",
9
+ alignItems: "center",
10
+ position: "relative",
11
+ height: "auto",
12
+ width: "100%",
13
+ gap: theme.vars.size.baseSpacings.sp1,
14
+ paddingLeft: theme.vars.size.baseSpacings.sp1,
15
+ paddingRight: ownerState.noButtons && theme.vars.size.baseSpacings.sp1,
16
+ boxSizing: "border-box",
17
+ //Variantes (Outlined y Text)
18
+ ...ownerState.variant === "outlined" && {
19
+ border: theme.vars.size.borderStroke.container,
20
+ borderColor: ownerState.error ? theme.vars.palette.error.main : theme.vars.palette.border.default,
21
+ borderRadius: theme.vars.size.borderRadius.r1
22
+ },
23
+ ...ownerState.variant === "text" && {
24
+ borderBottom: theme.vars.size.borderStroke.container,
25
+ borderColor: ownerState.error ? theme.vars.palette.error.main : theme.vars.palette.border.default,
26
+ borderRadius: theme.vars.size.borderRadius.r1
27
+ },
28
+ // Estados (Pseudo-classes)
29
+ ...ownerState.disabled === false && {
30
+ "&:hover": {
31
+ background: ownerState.error ? theme.vars.palette.error.hoverOpacity : theme.vars.palette.primary.hoverOpacity,
32
+ borderColor: ownerState.error ? theme.vars.palette.error.hover : theme.vars.palette.primary.hover,
33
+ "& button": {
34
+ background: ownerState.error ? theme.vars.palette.error.hoverOpacity : theme.vars.palette.primary.hoverOpacity,
35
+ "&:hover": {
36
+ // background: theme.vars.palette?.default.hover,
37
+ }
38
+ }
39
+ },
40
+ "&:focus-within": {
41
+ borderColor: ownerState.error ? theme.vars.palette.error.main : theme.vars.palette.primary.main
42
+ },
43
+ "&:active": {
44
+ background: "transparent",
45
+ borderColor: ownerState.error ? theme.vars.palette.error.active : theme.vars.palette.primary.active
46
+ }
47
+ },
48
+ ...getHeightSizeStyles(
49
+ theme.generalSettings.isMobile,
50
+ ownerState.size || "medium",
51
+ "action"
52
+ )
53
+ }),
54
+ /**
55
+ * Estilos aplicados al campo de entrada (input).
56
+ */
57
+ input: ({ theme, ownerState }) => ({
58
+ //Estilos generales
59
+ background: "transparent",
60
+ border: 0,
61
+ outline: 0,
62
+ color: ownerState.disabled ? theme.vars.palette.text.disabled : theme.vars.palette.text.primary,
63
+ height: "max-content ",
64
+ width: "100%",
65
+ ...ownerState.focusError && {
66
+ color: theme.vars.palette.error.main
67
+ }
68
+ }),
69
+ /**
70
+ * Estilos para envoltorio de boton y endAdornment
71
+ */
72
+ ContainButtonsAdornment: ({ theme }) => ({
73
+ display: "flex",
74
+ flexDirection: "row",
75
+ justifyContent: "center",
76
+ alignContent: "center",
77
+ height: "100%",
78
+ gap: theme.vars.size.baseSpacings.sp2,
79
+ "span": {
80
+ alignSelf: "center"
81
+ }
82
+ }),
83
+ /**
84
+ * Estilos aplicados al div que contiene los botones de incremento/decremento.
85
+ */
86
+ containerButtons: () => ({
87
+ display: "flex",
88
+ flexDirection: "column",
89
+ height: "100%"
90
+ }),
91
+ /**
92
+ * Estilos de increment
93
+ */
94
+ increment: ({ theme, ownerState }) => ({
95
+ //Estilos generales
96
+ height: "50%",
97
+ background: theme.vars.palette.default.main,
98
+ borderBottomLeftRadius: 0,
99
+ borderBottomRightRadius: 0,
100
+ borderTopLeftRadius: 0,
101
+ borderTopRightRadius: `calc(${theme.vars.size.borderRadius.r1} - 1px)`,
102
+ outlineOffset: 0,
103
+ //Sizes
104
+ ...ownerState.sizes === "medium" && {
105
+ ...theme.generalSettings.isMobile ? {
106
+ width: theme.vars.size.mobile.medium.action
107
+ } : {
108
+ width: theme.vars.size.desktop.medium.action
109
+ }
110
+ },
111
+ ...ownerState.sizes === "small" && {
112
+ ...theme.generalSettings.isMobile ? {
113
+ width: theme.vars.size.mobile.small.action
114
+ } : {
115
+ width: theme.vars.size.desktop.small.action
116
+ }
117
+ },
118
+ //Estados (Pseudo-classes)
119
+ "&:focus-visible": {
120
+ zIndex: 1,
121
+ outline: `1px solid ${theme.vars.palette?.primary.main}`
122
+ },
123
+ "&:active": {
124
+ background: `${theme.vars.palette?.default.active} !important`
125
+ },
126
+ "& div": {
127
+ height: "100%",
128
+ width: "100%",
129
+ "& div": {
130
+ height: "100%",
131
+ width: "50%",
132
+ minHeight: "min-content",
133
+ maskPosition: "center center"
134
+ }
135
+ }
136
+ }),
137
+ /**
138
+ * Estilos Decrement
139
+ */
140
+ decrement: ({ theme, ownerState }) => ({
141
+ //Estilos generales
142
+ height: "50%",
143
+ background: theme.vars.palette.default.main,
144
+ borderTopLeftRadius: 0,
145
+ borderTopRightRadius: 0,
146
+ borderBottomLeftRadius: 0,
147
+ borderBottomRightRadius: `calc(${theme.vars.size.borderRadius.r1} - 1px)`,
148
+ outlineOffset: 0,
149
+ //Sizes
150
+ ...ownerState.sizes === "medium" && {
151
+ ...theme.generalSettings.isMobile ? {
152
+ width: theme.vars.size.mobile.medium.action
153
+ } : {
154
+ width: theme.vars.size.desktop.medium.action
155
+ }
156
+ },
157
+ ...ownerState.sizes === "small" && {
158
+ ...theme.generalSettings.isMobile ? {
159
+ width: theme.vars.size.mobile.small.action
160
+ } : {
161
+ width: theme.vars.size.desktop.small.action
162
+ }
163
+ },
164
+ // Estados (Pseudo-classes)
165
+ "&:focus-visible": {
166
+ zIndex: 1,
167
+ outline: `1px solid ${theme.vars.palette?.primary.main}`
168
+ },
169
+ "&:active": {
170
+ background: `${theme.vars.palette?.default.active} !important`
171
+ },
172
+ "& div": {
173
+ height: "100%",
174
+ width: "100%",
175
+ "& div": {
176
+ height: "100%",
177
+ width: "50%",
178
+ minHeight: "min-content",
179
+ maskPosition: "center center"
180
+ }
181
+ }
182
+ }),
183
+ /**
184
+ * Estilos aplicados al skeleton.
185
+ */
186
+ skeleton: ({ theme, ownerState }) => ({
187
+ "&.M4lclassCssSpecificity": {
188
+ width: "100%",
189
+ ...getHeightSizeStyles(
190
+ theme.generalSettings.isMobile,
191
+ ownerState.size || "medium",
192
+ "action"
193
+ )
194
+ }
195
+ })
196
+ };
197
+ export {
198
+ numberInputStyles as n
199
+ };
@@ -0,0 +1,4 @@
1
+ const NUMBER_INPUT_KEY_COMPONENT = "M4LNumberInput";
2
+ export {
3
+ NUMBER_INPUT_KEY_COMPONENT as N
4
+ };
@@ -0,0 +1,12 @@
1
+ const NumberInputActionTypes = {
2
+ clamp: "numberInput:clamp",
3
+ inputChange: "numberInput:inputChange",
4
+ increment: "numberInput:increment",
5
+ decrement: "numberInput:decrement",
6
+ decrementToMin: "numberInput:decrementToMin",
7
+ incrementToMax: "numberInput:incrementToMax",
8
+ resetInputValue: "numberInput:resetInputValue"
9
+ };
10
+ export {
11
+ NumberInputActionTypes as N
12
+ };
@@ -0,0 +1,106 @@
1
+ import { c as clampStepwise, i as isNumber } from "../../utils.js";
2
+ import { N as NumberInputActionTypes } from "./NumberInputActions.js";
3
+ function getClampedValues(rawValue, context) {
4
+ const { min, max, step, withDecimal } = context;
5
+ const clampedValue = rawValue === null ? null : clampStepwise(rawValue, min, max, step, withDecimal);
6
+ const newInputValue = clampedValue === null ? "" : String(clampedValue);
7
+ return {
8
+ value: clampedValue,
9
+ inputValue: newInputValue
10
+ };
11
+ }
12
+ function roundToDecimals(value, decimals = 6) {
13
+ const factor = Math.pow(10, decimals);
14
+ return Math.round(value * factor) / factor;
15
+ }
16
+ function stepValue(state, context, direction, multiplier) {
17
+ const { value } = state;
18
+ const { step = 1, min, max } = context;
19
+ if (isNumber(value)) {
20
+ return {
21
+ up: roundToDecimals(value + (step ?? 1) * multiplier),
22
+ down: roundToDecimals(value - (step ?? 1) * multiplier)
23
+ }[direction];
24
+ }
25
+ return {
26
+ up: min ?? 1,
27
+ down: max ?? -1
28
+ }[direction];
29
+ }
30
+ function handleClamp(state, context, inputValue) {
31
+ const { getInputValueAsString } = context;
32
+ const numberValueAsString = getInputValueAsString(inputValue);
33
+ const intermediateValue = numberValueAsString === "" || numberValueAsString === "-" ? null : Number(numberValueAsString);
34
+ const clampedValues = getClampedValues(intermediateValue, context);
35
+ return {
36
+ ...state,
37
+ ...clampedValues,
38
+ noControlledValue: clampedValues.value
39
+ };
40
+ }
41
+ function handleInputChange(state, context, inputValue) {
42
+ const { getInputValueAsString, min, max, step, withDecimal } = context;
43
+ const numberValueAsString = getInputValueAsString(inputValue);
44
+ if (numberValueAsString.match(withDecimal ? /^-?(?:\d+(\.\d*)?|\.\d+)$/ : /^-?\d+?$/) || numberValueAsString === "" || numberValueAsString === "." || numberValueAsString === "-") {
45
+ const intermediateValue = numberValueAsString === "" || numberValueAsString === "-" || numberValueAsString === "." ? null : Number(numberValueAsString);
46
+ const clampedValue = intermediateValue === null ? null : clampStepwise(intermediateValue, min, max, step, withDecimal);
47
+ const value = intermediateValue !== null && clampedValue === Number(numberValueAsString) ? clampedValue : state.value;
48
+ const ret = {
49
+ ...state,
50
+ value,
51
+ inputValue: numberValueAsString,
52
+ noControlledValue: value
53
+ };
54
+ return ret;
55
+ }
56
+ return state;
57
+ }
58
+ function handleStep(state, context, applyMultiplier, direction) {
59
+ const multiplier = applyMultiplier ? context.shiftMultiplier : 1;
60
+ const newValue = stepValue(state, context, direction, multiplier);
61
+ const clampedValues = getClampedValues(newValue, context);
62
+ return {
63
+ ...state,
64
+ ...clampedValues,
65
+ noControlledValue: clampedValues.value
66
+ };
67
+ }
68
+ function handleToMinOrMax(state, context, to) {
69
+ const newValue = context[to];
70
+ if (!isNumber(newValue)) {
71
+ return state;
72
+ }
73
+ return {
74
+ ...state,
75
+ value: newValue,
76
+ inputValue: String(newValue),
77
+ noControlledValue: newValue
78
+ };
79
+ }
80
+ function numberInputReducer(state, action) {
81
+ const { type, context } = action;
82
+ switch (type) {
83
+ case NumberInputActionTypes.clamp:
84
+ return handleClamp(state, context, action.inputValue);
85
+ case NumberInputActionTypes.inputChange:
86
+ return handleInputChange(state, context, action.inputValue);
87
+ case NumberInputActionTypes.increment:
88
+ return handleStep(state, context, action.applyMultiplier, "up");
89
+ case NumberInputActionTypes.decrement:
90
+ return handleStep(state, context, action.applyMultiplier, "down");
91
+ case NumberInputActionTypes.incrementToMax:
92
+ return handleToMinOrMax(state, context, "max");
93
+ case NumberInputActionTypes.decrementToMin:
94
+ return handleToMinOrMax(state, context, "min");
95
+ case NumberInputActionTypes.resetInputValue:
96
+ return {
97
+ ...state,
98
+ inputValue: String(state.value)
99
+ };
100
+ default:
101
+ return state;
102
+ }
103
+ }
104
+ export {
105
+ numberInputReducer as n
106
+ };