1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.hasValue = hasValue;
|
7 | exports.isAdornedStart = isAdornedStart;
|
8 | exports.isFilled = isFilled;
|
9 | // Supports determination of isControlled().
|
10 | // Controlled input accepts its current value as a prop.
|
11 | //
|
12 | // @see https://facebook.github.io/react/docs/forms.html#controlled-components
|
13 | // @param value
|
14 | // @returns {boolean} true if string (including '') or number (including zero)
|
15 | function hasValue(value) {
|
16 | return value != null && !(Array.isArray(value) && value.length === 0);
|
17 | }
|
18 |
|
19 | // Determine if field is empty or filled.
|
20 | // Response determines if label is presented above field or as placeholder.
|
21 | //
|
22 | // @param obj
|
23 | // @param SSR
|
24 | // @returns {boolean} False when not present or empty string.
|
25 | // True when any number or string with length.
|
26 | function isFilled(obj, SSR = false) {
|
27 | return obj && (hasValue(obj.value) && obj.value !== '' || SSR && hasValue(obj.defaultValue) && obj.defaultValue !== '');
|
28 | }
|
29 |
|
30 | // Determine if an Input is adorned on start.
|
31 | // It's corresponding to the left with LTR.
|
32 | //
|
33 | // @param obj
|
34 | // @returns {boolean} False when no adornments.
|
35 | // True when adorned at the start.
|
36 | function isAdornedStart(obj) {
|
37 | return obj.startAdornment;
|
38 | } |
\ | No newline at end of file |