@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.
- package/components/Label/Label.styles.js +32 -18
- package/components/NumberInput/NumberInput.js +124 -0
- package/components/NumberInput/NumberInput.styles.js +199 -0
- package/components/NumberInput/constants.js +4 -0
- package/components/NumberInput/hooks/useNumberInput/NumberInputActions.js +12 -0
- package/components/NumberInput/hooks/useNumberInput/NumberInputReducer.js +106 -0
- package/components/NumberInput/hooks/useNumberInput/useNumberInput.js +364 -0
- package/components/NumberInput/slots/NumberInputEnum.js +13 -0
- package/components/NumberInput/slots/NumberInputSlots.js +43 -0
- package/components/NumberInput/utils.js +23 -0
- package/components/PropertyValue/PropertyValue.d.ts +1 -1
- package/components/PropertyValue/PropertyValue.js +5 -17
- package/components/PropertyValue/PropertyValue.styles.js +6 -6
- package/components/extended/React-Splitter/SplitLayout/SplitLayout.d.ts +14 -0
- package/components/extended/React-Splitter/SplitLayout/SplitLayout.js +53 -0
- package/components/extended/React-Splitter/SplitLayout/SplitLayout.styles.d.ts +2 -0
- package/components/extended/React-Splitter/SplitLayout/SplitLayout.styles.js +157 -0
- package/components/extended/React-Splitter/SplitLayout/constants.d.ts +9 -0
- package/components/extended/React-Splitter/SplitLayout/constants.js +6 -0
- package/components/extended/React-Splitter/SplitLayout/slots/SplitLayoutEnum.d.ts +5 -0
- package/components/extended/React-Splitter/SplitLayout/slots/SplitLayoutEnum.js +9 -0
- package/components/extended/React-Splitter/SplitLayout/slots/SplitLayoutSlots.d.ts +3 -0
- package/components/extended/React-Splitter/SplitLayout/slots/SplitLayoutSlots.js +21 -0
- package/components/extended/React-Splitter/SplitLayout/tests/SplitLayout.test.d.ts +1 -0
- package/components/{SplitLayout → extended/React-Splitter/SplitLayout}/types.d.ts +11 -5
- package/components/hook-form/RHFNumberInput/RHFNumberInput.js +89 -0
- package/components/hook-form/RHFNumberInput/RHFNumberInput.styles.js +16 -0
- package/components/hook-form/RHFNumberInput/constants.js +4 -0
- package/components/hook-form/RHFNumberInput/slots/RHFNumberInputEnum.js +7 -0
- package/components/hook-form/RHFNumberInput/slots/RHFNumberInputSlots.js +11 -0
- package/components/hook-form/index.d.ts +1 -0
- package/components/index.d.ts +2 -2
- package/index.js +23 -21
- package/package.json +1 -1
- package/components/SplitLayout/SplitLayout.d.ts +0 -16
- package/components/SplitLayout/SplitLayout.js +0 -57
- package/components/SplitLayout/classes/constants.d.ts +0 -1
- package/components/SplitLayout/classes/constants.js +0 -4
- package/components/SplitLayout/classes/index.d.ts +0 -17
- package/components/SplitLayout/classes/index.js +0 -33
- package/components/SplitLayout/classes/types.d.ts +0 -10
- package/components/SplitLayout/index.d.ts +0 -2
- package/components/SplitLayout/styles.d.ts +0 -3
- package/components/SplitLayout/styles.js +0 -29
- package/components/SplitLayout/tests/constants.d.ts +0 -1
- package/components/SplitLayout/tests/constants.js +0 -4
- package/components/SplitLayout/tests/utils.d.ts +0 -2
- package/components/SplitLayout/tests/utils.js +0 -7
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { useRef, useCallback, useState, useMemo, useEffect } from "react";
|
|
2
|
+
import { useFormControlContext, extractEventHandlers } from "@mui/base";
|
|
3
|
+
import { useForkRef } from "@mui/material";
|
|
4
|
+
import useId from "@mui/material/utils/useId";
|
|
5
|
+
import { useControllableReducer } from "@mui/base/utils/useControllableReducer";
|
|
6
|
+
import { i as isNumber } from "../../utils.js";
|
|
7
|
+
import { N as NUMBER_INPUT_KEY_COMPONENT } from "../../constants.js";
|
|
8
|
+
import { N as NumberInputActionTypes } from "./NumberInputActions.js";
|
|
9
|
+
import { n as numberInputReducer } from "./NumberInputReducer.js";
|
|
10
|
+
const STEP_KEYS = ["ArrowUp", "ArrowDown", "PageUp", "PageDown", "Enter"];
|
|
11
|
+
const SUPPORTED_KEYS = [...STEP_KEYS, "Home", "End"];
|
|
12
|
+
function getInputValueAsString(v) {
|
|
13
|
+
return v ? String(v.trim()) : String(v);
|
|
14
|
+
}
|
|
15
|
+
const useNumberInput = (parameters) => {
|
|
16
|
+
const {
|
|
17
|
+
min,
|
|
18
|
+
max,
|
|
19
|
+
step,
|
|
20
|
+
withDecimal,
|
|
21
|
+
shiftMultiplier = 10,
|
|
22
|
+
value: valueProp,
|
|
23
|
+
inputRef: inputRefProp,
|
|
24
|
+
inputId: inputIdProp,
|
|
25
|
+
onChange,
|
|
26
|
+
disabled: disabledProp = false,
|
|
27
|
+
onBlur,
|
|
28
|
+
onFocus,
|
|
29
|
+
onInputChange,
|
|
30
|
+
defaultValue: defaultValueProp,
|
|
31
|
+
componentName = NUMBER_INPUT_KEY_COMPONENT,
|
|
32
|
+
error: errorProp = false,
|
|
33
|
+
required: requiredProp = false,
|
|
34
|
+
readOnly: readOnlyProp = false
|
|
35
|
+
} = parameters;
|
|
36
|
+
const formControlContext = useFormControlContext();
|
|
37
|
+
const { current: isControlled } = useRef(valueProp !== null);
|
|
38
|
+
const handleInputRefWarning = useCallback((instance) => {
|
|
39
|
+
if (process.env.NODE_ENV !== "production") {
|
|
40
|
+
if (instance && instance.nodeName !== "INPUT" && !instance.focus) {
|
|
41
|
+
console.error(
|
|
42
|
+
[
|
|
43
|
+
"MUI: You have provided a `slots.input` to the input component",
|
|
44
|
+
"that does not correctly handle the `ref` prop.",
|
|
45
|
+
"Make sure the `ref` prop is called with a HTMLInputElement."
|
|
46
|
+
].join("\n")
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, []);
|
|
51
|
+
const inputRef = useRef(null);
|
|
52
|
+
const handleInputRef = useForkRef(inputRef, inputRefProp, handleInputRefWarning);
|
|
53
|
+
const inputId = useId(inputIdProp);
|
|
54
|
+
const [focused, setFocused] = useState(false);
|
|
55
|
+
const handleStateChange = useCallback(
|
|
56
|
+
(event, field, fieldValue, reason) => {
|
|
57
|
+
if (field === "value" && typeof fieldValue !== "string") {
|
|
58
|
+
switch (reason) {
|
|
59
|
+
case "numberInput:inputChange":
|
|
60
|
+
onChange?.(event, fieldValue);
|
|
61
|
+
break;
|
|
62
|
+
case "numberInput:clamp":
|
|
63
|
+
onChange?.(event, fieldValue);
|
|
64
|
+
break;
|
|
65
|
+
case "numberInput:increment":
|
|
66
|
+
case "numberInput:decrement":
|
|
67
|
+
case "numberInput:incrementToMax":
|
|
68
|
+
case "numberInput:decrementToMin":
|
|
69
|
+
onChange?.(event, fieldValue);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[onChange]
|
|
75
|
+
);
|
|
76
|
+
const numberInputActionContext = useMemo(() => {
|
|
77
|
+
return {
|
|
78
|
+
min,
|
|
79
|
+
max,
|
|
80
|
+
step,
|
|
81
|
+
withDecimal,
|
|
82
|
+
shiftMultiplier,
|
|
83
|
+
getInputValueAsString
|
|
84
|
+
};
|
|
85
|
+
}, [min, max, step, withDecimal, shiftMultiplier]);
|
|
86
|
+
const initialValue = valueProp ?? defaultValueProp ?? null;
|
|
87
|
+
const initialState = {
|
|
88
|
+
value: initialValue,
|
|
89
|
+
inputValue: initialValue ? String(initialValue) : "",
|
|
90
|
+
noControlledValue: initialValue
|
|
91
|
+
};
|
|
92
|
+
const controlledState = useMemo(
|
|
93
|
+
() => ({
|
|
94
|
+
value: valueProp
|
|
95
|
+
}),
|
|
96
|
+
[valueProp]
|
|
97
|
+
);
|
|
98
|
+
const [state, dispatch] = useControllableReducer({
|
|
99
|
+
reducer: numberInputReducer,
|
|
100
|
+
controlledProps: controlledState,
|
|
101
|
+
initialState,
|
|
102
|
+
onStateChange: handleStateChange,
|
|
103
|
+
actionContext: useMemo(() => numberInputActionContext, [numberInputActionContext]),
|
|
104
|
+
componentName
|
|
105
|
+
});
|
|
106
|
+
const { value, inputValue, noControlledValue } = state;
|
|
107
|
+
const focusError = focused && inputValue !== "" ? noControlledValue !== Number(inputValue) : false;
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (!formControlContext && disabledProp && focused) {
|
|
110
|
+
setFocused(false);
|
|
111
|
+
onBlur?.();
|
|
112
|
+
}
|
|
113
|
+
}, [formControlContext, disabledProp, focused, onBlur]);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (isControlled && isNumber(value)) {
|
|
116
|
+
dispatch({
|
|
117
|
+
type: NumberInputActionTypes.resetInputValue
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, [value, dispatch, isControlled]);
|
|
121
|
+
const createHandleFocus = (otherHandlers) => (event) => {
|
|
122
|
+
otherHandlers.onFocus?.(event);
|
|
123
|
+
if (event.defaultMuiPrevented || event.defaultPrevented) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (formControlContext && formControlContext.onFocus) {
|
|
127
|
+
formControlContext?.onFocus?.();
|
|
128
|
+
}
|
|
129
|
+
setFocused(true);
|
|
130
|
+
};
|
|
131
|
+
const createHandleInputChange = (otherHandlers) => (event) => {
|
|
132
|
+
if (!isControlled && event.target === null) {
|
|
133
|
+
throw (
|
|
134
|
+
/* minify-error */
|
|
135
|
+
new Error(
|
|
136
|
+
"MUI: Expected valid input target. Did you use a custom `slots.input` and forget to forward refs? See https://mui.com/r/input-component-ref-interface for more info."
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
formControlContext?.onChange?.(event);
|
|
141
|
+
otherHandlers.onInputChange?.(event);
|
|
142
|
+
if (event.defaultMuiPrevented || event.defaultPrevented) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
dispatch({
|
|
146
|
+
type: NumberInputActionTypes.inputChange,
|
|
147
|
+
event,
|
|
148
|
+
inputValue: event.currentTarget.value
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
const createHandleBlur = (otherHandlers) => (event) => {
|
|
152
|
+
formControlContext?.onBlur();
|
|
153
|
+
otherHandlers.onBlur?.(event);
|
|
154
|
+
if (event.defaultMuiPrevented || event.defaultPrevented) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
dispatch({
|
|
158
|
+
type: NumberInputActionTypes.clamp,
|
|
159
|
+
event,
|
|
160
|
+
inputValue: event.currentTarget.value
|
|
161
|
+
});
|
|
162
|
+
setFocused(false);
|
|
163
|
+
};
|
|
164
|
+
const createHandleClick = (otherHandlers) => (event) => {
|
|
165
|
+
otherHandlers.onClick?.(event);
|
|
166
|
+
if (event.defaultMuiPrevented || event.defaultPrevented) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (inputRef.current && event.currentTarget === event.target) {
|
|
170
|
+
inputRef.current.focus();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const handleStep = (direction) => (event) => {
|
|
174
|
+
const applyMultiplier = Boolean(event.shiftKey);
|
|
175
|
+
const actionType = {
|
|
176
|
+
up: NumberInputActionTypes.increment,
|
|
177
|
+
down: NumberInputActionTypes.decrement
|
|
178
|
+
}[direction];
|
|
179
|
+
dispatch({
|
|
180
|
+
type: actionType,
|
|
181
|
+
event,
|
|
182
|
+
applyMultiplier
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
const createHandleKeyDown = (otherHandlers) => (event) => {
|
|
186
|
+
otherHandlers.onKeyDown?.(event);
|
|
187
|
+
if (event.defaultMuiPrevented || event.defaultPrevented) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (SUPPORTED_KEYS.includes(event.key)) {
|
|
191
|
+
event.preventDefault();
|
|
192
|
+
}
|
|
193
|
+
switch (event.key) {
|
|
194
|
+
case "ArrowUp":
|
|
195
|
+
dispatch({
|
|
196
|
+
type: NumberInputActionTypes.increment,
|
|
197
|
+
event,
|
|
198
|
+
applyMultiplier: !!event.shiftKey
|
|
199
|
+
});
|
|
200
|
+
break;
|
|
201
|
+
case "ArrowDown":
|
|
202
|
+
dispatch({
|
|
203
|
+
type: NumberInputActionTypes.decrement,
|
|
204
|
+
event,
|
|
205
|
+
applyMultiplier: !!event.shiftKey
|
|
206
|
+
});
|
|
207
|
+
break;
|
|
208
|
+
case "PageUp":
|
|
209
|
+
dispatch({
|
|
210
|
+
type: NumberInputActionTypes.increment,
|
|
211
|
+
event,
|
|
212
|
+
applyMultiplier: true
|
|
213
|
+
});
|
|
214
|
+
break;
|
|
215
|
+
case "PageDown":
|
|
216
|
+
dispatch({
|
|
217
|
+
type: NumberInputActionTypes.decrement,
|
|
218
|
+
event,
|
|
219
|
+
applyMultiplier: true
|
|
220
|
+
});
|
|
221
|
+
break;
|
|
222
|
+
case "Home":
|
|
223
|
+
dispatch({
|
|
224
|
+
type: NumberInputActionTypes.decrementToMin,
|
|
225
|
+
event
|
|
226
|
+
});
|
|
227
|
+
break;
|
|
228
|
+
case "Enter":
|
|
229
|
+
dispatch({
|
|
230
|
+
type: NumberInputActionTypes.clamp,
|
|
231
|
+
event,
|
|
232
|
+
inputValue: event.currentTarget.value
|
|
233
|
+
});
|
|
234
|
+
break;
|
|
235
|
+
case "End":
|
|
236
|
+
dispatch({
|
|
237
|
+
type: NumberInputActionTypes.incrementToMax,
|
|
238
|
+
event
|
|
239
|
+
});
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const getRootProps = (externalProps = {}) => {
|
|
244
|
+
const propsEventHandlers = extractEventHandlers(parameters, [
|
|
245
|
+
// these are handled by the input slot
|
|
246
|
+
"onBlur",
|
|
247
|
+
"onInputChange",
|
|
248
|
+
"onFocus",
|
|
249
|
+
"onChange"
|
|
250
|
+
]);
|
|
251
|
+
const externalEventHandlers = {
|
|
252
|
+
...propsEventHandlers,
|
|
253
|
+
...extractEventHandlers(externalProps)
|
|
254
|
+
};
|
|
255
|
+
return {
|
|
256
|
+
...externalProps,
|
|
257
|
+
...externalEventHandlers,
|
|
258
|
+
onClick: createHandleClick(externalEventHandlers)
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
const getInputProps = (externalProps = {}) => {
|
|
262
|
+
const propsEventHandlers = {
|
|
263
|
+
onBlur,
|
|
264
|
+
onFocus,
|
|
265
|
+
// onChange from normal props is the custom onChange so we ignore it here
|
|
266
|
+
onChange: onInputChange
|
|
267
|
+
};
|
|
268
|
+
const externalEventHandlers = {
|
|
269
|
+
...propsEventHandlers,
|
|
270
|
+
...extractEventHandlers(externalProps, [
|
|
271
|
+
// onClick is handled by the root slot
|
|
272
|
+
"onClick"
|
|
273
|
+
// do not ignore 'onInputChange', we want slotProps.input.onInputChange to enter the DOM and throw
|
|
274
|
+
])
|
|
275
|
+
};
|
|
276
|
+
const mergedEventHandlers = {
|
|
277
|
+
...externalEventHandlers,
|
|
278
|
+
onFocus: createHandleFocus(externalEventHandlers),
|
|
279
|
+
// slotProps.onChange is renamed to onInputChange and passed to createHandleInputChange
|
|
280
|
+
onChange: createHandleInputChange({
|
|
281
|
+
...externalEventHandlers,
|
|
282
|
+
onInputChange: externalEventHandlers.onChange
|
|
283
|
+
}),
|
|
284
|
+
onBlur: createHandleBlur(externalEventHandlers),
|
|
285
|
+
onKeyDown: createHandleKeyDown(externalEventHandlers)
|
|
286
|
+
};
|
|
287
|
+
const displayValue = (focused ? inputValue : value) ?? "";
|
|
288
|
+
delete externalProps.onInputChange;
|
|
289
|
+
return {
|
|
290
|
+
type: "text",
|
|
291
|
+
id: inputId,
|
|
292
|
+
"aria-invalid": errorProp || void 0,
|
|
293
|
+
defaultValue: void 0,
|
|
294
|
+
value: displayValue,
|
|
295
|
+
"aria-valuenow": displayValue,
|
|
296
|
+
"aria-valuetext": String(displayValue),
|
|
297
|
+
"aria-valuemin": min,
|
|
298
|
+
"aria-valuemax": max,
|
|
299
|
+
autoComplete: "off",
|
|
300
|
+
autoCorrect: "off",
|
|
301
|
+
spellCheck: "false",
|
|
302
|
+
required: !!requiredProp,
|
|
303
|
+
readOnly: readOnlyProp,
|
|
304
|
+
"aria-disabled": disabledProp,
|
|
305
|
+
disabled: disabledProp,
|
|
306
|
+
...externalProps,
|
|
307
|
+
ref: handleInputRef,
|
|
308
|
+
...mergedEventHandlers
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
const handleStepperButtonMouseDown = (event) => {
|
|
312
|
+
event.preventDefault();
|
|
313
|
+
if (inputRef.current) {
|
|
314
|
+
inputRef.current.focus();
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const stepperButtonCommonProps = {
|
|
318
|
+
"aria-controls": inputId,
|
|
319
|
+
tabIndex: -1
|
|
320
|
+
};
|
|
321
|
+
const isIncrementDisabled = disabledProp || (isNumber(value) ? value >= (max ?? Number.MAX_SAFE_INTEGER) : false);
|
|
322
|
+
const getIncrementButtonProps = (externalProps = {}) => {
|
|
323
|
+
return {
|
|
324
|
+
...externalProps,
|
|
325
|
+
...stepperButtonCommonProps,
|
|
326
|
+
disabled: isIncrementDisabled,
|
|
327
|
+
tabIndex: 0,
|
|
328
|
+
"aria-disabled": isIncrementDisabled,
|
|
329
|
+
onMouseDown: handleStepperButtonMouseDown,
|
|
330
|
+
onClick: handleStep("up")
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
const isDecrementDisabled = disabledProp || (isNumber(value) ? value <= (min ?? Number.MIN_SAFE_INTEGER) : false);
|
|
334
|
+
const getDecrementButtonProps = (externalProps = {}) => {
|
|
335
|
+
return {
|
|
336
|
+
...externalProps,
|
|
337
|
+
...stepperButtonCommonProps,
|
|
338
|
+
disabled: isDecrementDisabled,
|
|
339
|
+
tabIndex: 0,
|
|
340
|
+
"aria-disabled": isDecrementDisabled,
|
|
341
|
+
onMouseDown: handleStepperButtonMouseDown,
|
|
342
|
+
onClick: handleStep("down")
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
return {
|
|
346
|
+
disabled: disabledProp,
|
|
347
|
+
error: errorProp,
|
|
348
|
+
focused,
|
|
349
|
+
formControlContext,
|
|
350
|
+
getInputProps,
|
|
351
|
+
getIncrementButtonProps,
|
|
352
|
+
getDecrementButtonProps,
|
|
353
|
+
getRootProps,
|
|
354
|
+
required: requiredProp,
|
|
355
|
+
value,
|
|
356
|
+
inputValue,
|
|
357
|
+
isIncrementDisabled,
|
|
358
|
+
isDecrementDisabled,
|
|
359
|
+
focusError
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
export {
|
|
363
|
+
useNumberInput as u
|
|
364
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var NumberInputSlots = /* @__PURE__ */ ((NumberInputSlots2) => {
|
|
2
|
+
NumberInputSlots2["root"] = "root";
|
|
3
|
+
NumberInputSlots2["input"] = "input";
|
|
4
|
+
NumberInputSlots2["containButtonsAdornment"] = "ContainButtonsAdornment";
|
|
5
|
+
NumberInputSlots2["containerButtons"] = "containerButtons";
|
|
6
|
+
NumberInputSlots2["increment"] = "increment";
|
|
7
|
+
NumberInputSlots2["decrement"] = "decrement";
|
|
8
|
+
NumberInputSlots2["skeleton"] = "skeleton";
|
|
9
|
+
return NumberInputSlots2;
|
|
10
|
+
})(NumberInputSlots || {});
|
|
11
|
+
export {
|
|
12
|
+
NumberInputSlots as N
|
|
13
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { styled } from "@mui/material/styles";
|
|
2
|
+
import { S as Skeleton } from "../../mui_extended/Skeleton/Skeleton.js";
|
|
3
|
+
import { n as numberInputStyles } from "../NumberInput.styles.js";
|
|
4
|
+
import { N as NUMBER_INPUT_KEY_COMPONENT } from "../constants.js";
|
|
5
|
+
import { N as NumberInputSlots } from "./NumberInputEnum.js";
|
|
6
|
+
import { I as IconButton } from "../../mui_extended/IconButton/IconButton.js";
|
|
7
|
+
const RootStyled = styled("div", {
|
|
8
|
+
name: NUMBER_INPUT_KEY_COMPONENT,
|
|
9
|
+
slot: NumberInputSlots.root
|
|
10
|
+
})(numberInputStyles?.root);
|
|
11
|
+
const InputStyled = styled("input", {
|
|
12
|
+
name: NUMBER_INPUT_KEY_COMPONENT,
|
|
13
|
+
slot: NumberInputSlots.input
|
|
14
|
+
})(numberInputStyles?.input);
|
|
15
|
+
const ContainerButtonsStyled = styled("div", {
|
|
16
|
+
name: NUMBER_INPUT_KEY_COMPONENT,
|
|
17
|
+
slot: NumberInputSlots.containerButtons
|
|
18
|
+
})(numberInputStyles?.containerButtons);
|
|
19
|
+
const ContainButtonsAdornmentStyled = styled("div", {
|
|
20
|
+
name: NUMBER_INPUT_KEY_COMPONENT,
|
|
21
|
+
slot: NumberInputSlots.containButtonsAdornment
|
|
22
|
+
})(numberInputStyles?.ContainButtonsAdornment);
|
|
23
|
+
const IncrementButtonStyled = styled(IconButton, {
|
|
24
|
+
name: NUMBER_INPUT_KEY_COMPONENT,
|
|
25
|
+
slot: NumberInputSlots.increment
|
|
26
|
+
})(numberInputStyles?.increment);
|
|
27
|
+
const DecrementButtonStyled = styled(IconButton, {
|
|
28
|
+
name: NUMBER_INPUT_KEY_COMPONENT,
|
|
29
|
+
slot: NumberInputSlots.decrement
|
|
30
|
+
})(numberInputStyles?.decrement);
|
|
31
|
+
const SkeletonStyled = styled(Skeleton, {
|
|
32
|
+
name: NUMBER_INPUT_KEY_COMPONENT,
|
|
33
|
+
slot: NumberInputSlots.skeleton
|
|
34
|
+
})(numberInputStyles?.skeleton);
|
|
35
|
+
export {
|
|
36
|
+
ContainButtonsAdornmentStyled as C,
|
|
37
|
+
DecrementButtonStyled as D,
|
|
38
|
+
InputStyled as I,
|
|
39
|
+
RootStyled as R,
|
|
40
|
+
SkeletonStyled as S,
|
|
41
|
+
ContainerButtonsStyled as a,
|
|
42
|
+
IncrementButtonStyled as b
|
|
43
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { clamp } from "@mui/utils";
|
|
2
|
+
function clampStepwise(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER, stepProp = NaN, withDecimal = false) {
|
|
3
|
+
if (Number.isNaN(stepProp)) {
|
|
4
|
+
return clamp(val, min, max);
|
|
5
|
+
}
|
|
6
|
+
if (withDecimal) {
|
|
7
|
+
return clamp(val, min, max);
|
|
8
|
+
}
|
|
9
|
+
const step = stepProp || 1;
|
|
10
|
+
const remainder = val % step;
|
|
11
|
+
const positivity = Math.sign(remainder);
|
|
12
|
+
if (Math.abs(remainder) > step / 2) {
|
|
13
|
+
return clamp(val + positivity * (step - Math.abs(remainder)), min, max);
|
|
14
|
+
}
|
|
15
|
+
return clamp(val - positivity * Math.abs(remainder), min, max);
|
|
16
|
+
}
|
|
17
|
+
function isNumber(val) {
|
|
18
|
+
return typeof val === "number" && !Number.isNaN(val) && Number.isFinite(val);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
clampStepwise as c,
|
|
22
|
+
isNumber as i
|
|
23
|
+
};
|
|
@@ -3,7 +3,7 @@ import { PropertyValueProps } from './types';
|
|
|
3
3
|
* PropertyValue component is used to display a property and its value in a form or not.
|
|
4
4
|
* @author cesar - automatic
|
|
5
5
|
* @createdAt 2024-12-19 14:44:17 - automatic
|
|
6
|
-
* @updatedAt 2025-01-
|
|
6
|
+
* @updatedAt 2025-01-21 09:09:02 - automatic
|
|
7
7
|
* @updatedUser cesar - automatic
|
|
8
8
|
*/
|
|
9
9
|
export declare function PropertyValue(props: PropertyValueProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,8 +6,8 @@ import { g as getPropDataTestId, a as getNameDataTestId } from "../../test/getNa
|
|
|
6
6
|
import { P as PropertyValueRootStyled, a as PropertyStyled, V as ValueStyled } from "./slots/PropertyValueSlots.js";
|
|
7
7
|
import { a as getComponentSlotRoot } from "../../utils/getComponentSlotRoot.js";
|
|
8
8
|
import { u as useComponentSize } from "../../hooks/useComponentSize/useComponentSize.js";
|
|
9
|
+
import React from "react";
|
|
9
10
|
import { L as Label } from "../Label/Label.js";
|
|
10
|
-
import { T as TextField } from "../mui_extended/TextField/TextField.js";
|
|
11
11
|
import { T as Typography } from "../mui_extended/Typography/Typography.js";
|
|
12
12
|
import { I as Icon } from "../Icon/Icon.js";
|
|
13
13
|
function PropertyValue(props) {
|
|
@@ -47,23 +47,11 @@ function PropertyValue(props) {
|
|
|
47
47
|
return startAdornment;
|
|
48
48
|
};
|
|
49
49
|
const renderValue = () => {
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
return /* @__PURE__ */ jsx(
|
|
53
|
-
TextField,
|
|
54
|
-
{
|
|
55
|
-
size: normalizedSize,
|
|
56
|
-
defaultValue: value,
|
|
57
|
-
disabled,
|
|
58
|
-
helperText: helperMessage,
|
|
59
|
-
fullWidth: true
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
return value;
|
|
50
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
51
|
+
return /* @__PURE__ */ jsx(Typography, { size: normalizedSize, variant: "body", children: value });
|
|
64
52
|
}
|
|
65
|
-
if (
|
|
66
|
-
return
|
|
53
|
+
if (React.isValidElement(value)) {
|
|
54
|
+
return React.cloneElement(value, { size: normalizedSize });
|
|
67
55
|
}
|
|
68
56
|
return value;
|
|
69
57
|
};
|
|
@@ -4,8 +4,8 @@ const propertyValueStyles = {
|
|
|
4
4
|
* Property Value Root Styles
|
|
5
5
|
* @author cesar - automatic
|
|
6
6
|
* @createdAt 2024-12-19 14:44:17 - automatic
|
|
7
|
-
* @updatedAt 2025-01-
|
|
8
|
-
* @updatedUser
|
|
7
|
+
* @updatedAt 2025-01-20 18:52:54 - automatic
|
|
8
|
+
* @updatedUser cesar - automatic
|
|
9
9
|
*/
|
|
10
10
|
Root: ({ theme, ownerState }) => {
|
|
11
11
|
const createSemanticStyle = (minWidth, maxWidth) => ({
|
|
@@ -67,8 +67,8 @@ const propertyValueStyles = {
|
|
|
67
67
|
* Property Styles
|
|
68
68
|
* @author cesar - automatic
|
|
69
69
|
* @createdAt 2024-12-26 11:44:46 - automatic
|
|
70
|
-
* @updatedAt 2025-01-
|
|
71
|
-
* @updatedUser
|
|
70
|
+
* @updatedAt 2025-01-20 18:52:54 - automatic
|
|
71
|
+
* @updatedUser cesar - automatic
|
|
72
72
|
*/
|
|
73
73
|
property: ({ theme, ownerState }) => ({
|
|
74
74
|
display: "flex",
|
|
@@ -82,8 +82,8 @@ const propertyValueStyles = {
|
|
|
82
82
|
* Value Styles (Form and No Form Combined)
|
|
83
83
|
* @author cesar - automatic
|
|
84
84
|
* @createdAt 2024-12-26 11:44:46 - automatic
|
|
85
|
-
* @updatedAt 2025-01-
|
|
86
|
-
* @updatedUser
|
|
85
|
+
* @updatedAt 2025-01-20 18:52:54 - automatic
|
|
86
|
+
* @updatedUser cesar - automatic
|
|
87
87
|
*/
|
|
88
88
|
value: ({ theme, ownerState }) => ({
|
|
89
89
|
width: "100%",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SplitLayoutProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Componente SplitLayout refactorizado de la libreria `react-splitter-layout` que usa `SplitterLayout`.
|
|
4
|
+
* @param {SplitLayoutProps} props
|
|
5
|
+
* @example
|
|
6
|
+
* ```
|
|
7
|
+
* <SplitLayout
|
|
8
|
+
* splitPosition={isDesktop ? splitPosition : 'none'}
|
|
9
|
+
* firstPart={masterComponent}
|
|
10
|
+
* secondPart={detailComponent}
|
|
11
|
+
* />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const SplitLayout: (props: SplitLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { S as SplitterLayout } from "../../../../internal_libs/react-splitter-layout.js";
|
|
4
|
+
import { g as getPropDataTestId } from "../../../../test/getNameDataTestId.js";
|
|
5
|
+
import { a as getComponentSlotRoot } from "../../../../utils/getComponentSlotRoot.js";
|
|
6
|
+
import { S as SplitLayoutRootStyled, a as SplitMasterStyled, b as SplitDetailStyled } from "./slots/SplitLayoutSlots.js";
|
|
7
|
+
import { S as SplitLayoutSlots } from "./slots/SplitLayoutEnum.js";
|
|
8
|
+
import { S as SPLIT_LAYOUT_PREFIX, a as SPLIT_LAYOUT_KEY_COMPONENT } from "./constants.js";
|
|
9
|
+
const SplitLayout = (props) => {
|
|
10
|
+
const {
|
|
11
|
+
splitPosition,
|
|
12
|
+
firstPart,
|
|
13
|
+
secondPart,
|
|
14
|
+
secondParrtInitialSize = 50,
|
|
15
|
+
percentage = true,
|
|
16
|
+
dataTestId,
|
|
17
|
+
className
|
|
18
|
+
} = props;
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
SplitLayoutRootStyled,
|
|
21
|
+
{
|
|
22
|
+
...getPropDataTestId(SPLIT_LAYOUT_PREFIX, SplitLayoutSlots.root, dataTestId),
|
|
23
|
+
className: clsx(getComponentSlotRoot(SPLIT_LAYOUT_KEY_COMPONENT), className),
|
|
24
|
+
children: /* @__PURE__ */ jsxs(
|
|
25
|
+
SplitterLayout,
|
|
26
|
+
{
|
|
27
|
+
vertical: splitPosition === "vertical",
|
|
28
|
+
percentage,
|
|
29
|
+
secondaryInitialSize: secondParrtInitialSize,
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
SplitMasterStyled,
|
|
33
|
+
{
|
|
34
|
+
...getPropDataTestId(SPLIT_LAYOUT_PREFIX, SplitLayoutSlots.splitMaster, dataTestId),
|
|
35
|
+
children: typeof firstPart === "function" ? firstPart() : firstPart
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
splitPosition !== "none" && /* @__PURE__ */ jsx(
|
|
39
|
+
SplitDetailStyled,
|
|
40
|
+
{
|
|
41
|
+
...getPropDataTestId(SPLIT_LAYOUT_PREFIX, SplitLayoutSlots.splitDetail, dataTestId),
|
|
42
|
+
children: typeof secondPart === "function" ? secondPart() : secondPart
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
SplitLayout as S
|
|
53
|
+
};
|