@blerp/design 1.3.17 → 1.4.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/dist/cjs/Blerp/BlerpImageRow.js +176 -57
- package/dist/cjs/Blerp/BlerpSavePopup.js +44 -40
- package/dist/cjs/Blerp/BlerpTitleRow.js +36 -19
- package/dist/cjs/Blerp/BlerpTopRow.js +110 -44
- package/dist/cjs/Blerp.js +9 -16
- package/dist/cjs/BlerpAudioContextProvider.js +2 -2
- package/dist/cjs/BlerpListView.js +318 -168
- package/dist/cjs/BlerpListViewPremium.js +155 -130
- package/dist/cjs/BlerpListViewSkeleton.js +60 -13
- package/dist/cjs/BlerpSkeleton.js +32 -9
- package/dist/cjs/CollectionCard.js +139 -60
- package/dist/cjs/CollectionListViewPremium.js +368 -297
- package/dist/cjs/CollectionSkeleton.js +74 -13
- package/dist/cjs/Dropdown.js +272 -172
- package/dist/cjs/EllipsisLoader.js +66 -21
- package/dist/cjs/GroupCard.js +64 -57
- package/dist/cjs/Icons/Icons.js +288 -426
- package/dist/cjs/ImageEditor.js +247 -0
- package/dist/cjs/ImageUpload.js +226 -0
- package/dist/cjs/NewBlerp.js +354 -160
- package/dist/cjs/NewBlerpTest.js +10 -792
- package/dist/cjs/NewCollectionModal.js +294 -310
- package/dist/cjs/PremiumCollectionCard.js +191 -454
- package/dist/cjs/PurchaseModals/CheckoutModal.js +1 -1
- package/dist/cjs/PurchaseModals/PremiumBlerpCheckoutModal.js +1 -1
- package/dist/cjs/PurchaseModals/PremiumCollectionCheckoutModal.js +1 -1
- package/dist/cjs/PurchaseModals/PremiumSubscriptionCheckoutModal.js +1 -1
- package/dist/cjs/ReactionButtons.js +26 -13
- package/dist/cjs/SnackbarContextProvider.js +200 -116
- package/dist/cjs/Theme.js +217 -90
- package/dist/cjs/Toggle.js +86 -32
- package/dist/cjs/UserCard.js +13 -32
- package/dist/cjs/UserPage/LibraryControls.js +180 -93
- package/dist/cjs/UserPage/UserLibraryHeader.js +23 -14
- package/dist/cjs/UserPage/UserProfileHeader.js +120 -105
- package/dist/cjs/UsernameWithPopout.js +12 -8
- package/dist/cjs/colors.js +15 -8
- package/dist/cjs/helpers.js +131 -0
- package/dist/cjs/index.js +92 -58
- package/dist/cjs/neo-components/Autocomplete.js +280 -0
- package/dist/cjs/neo-components/BottomNavigation.js +120 -0
- package/dist/cjs/neo-components/Box.js +48 -0
- package/dist/cjs/neo-components/Button.js +206 -0
- package/dist/cjs/neo-components/CircularProgress.js +92 -0
- package/dist/cjs/neo-components/Container.js +75 -0
- package/dist/cjs/neo-components/Dialog.js +441 -0
- package/dist/cjs/neo-components/Fab.js +237 -0
- package/dist/cjs/neo-components/FormControls.js +1057 -0
- package/dist/cjs/neo-components/Grid.js +256 -0
- package/dist/cjs/neo-components/IconButton.js +111 -0
- package/dist/cjs/neo-components/Input.js +493 -0
- package/dist/cjs/neo-components/Layout.js +1213 -0
- package/dist/cjs/neo-components/Misc.js +858 -0
- package/dist/cjs/neo-components/Navigation.js +1578 -0
- package/dist/cjs/neo-components/Paper.js +256 -0
- package/dist/cjs/neo-components/Stack.js +194 -0
- package/dist/cjs/neo-components/Stepper.js +291 -0
- package/dist/cjs/neo-components/Text.js +290 -0
- package/dist/cjs/neo-components/ThemeProvider.js +731 -0
- package/dist/cjs/neo-components/ToggleButton.js +223 -0
- package/dist/cjs/neo-components/createTheme.js +306 -0
- package/dist/cjs/neo-components/withSx.js +164 -0
- package/dist/cjs/neo-utils/sxToStyle.js +508 -0
- package/dist/esm/Blerp/BlerpImageRow.js +166 -46
- package/dist/esm/Blerp/BlerpSavePopup.js +35 -27
- package/dist/esm/Blerp/BlerpTitleRow.js +32 -13
- package/dist/esm/Blerp/BlerpTopRow.js +85 -16
- package/dist/esm/Blerp.js +4 -12
- package/dist/esm/BlerpAudioContextProvider.js +1 -2
- package/dist/esm/BlerpListView.js +313 -160
- package/dist/esm/BlerpListViewPremium.js +135 -109
- package/dist/esm/BlerpListViewSkeleton.js +60 -11
- package/dist/esm/BlerpSkeleton.js +32 -7
- package/dist/esm/CollectionCard.js +118 -38
- package/dist/esm/CollectionListViewPremium.js +367 -294
- package/dist/esm/CollectionSkeleton.js +73 -11
- package/dist/esm/Dropdown.js +260 -161
- package/dist/esm/EllipsisLoader.js +63 -18
- package/dist/esm/GroupCard.js +54 -46
- package/dist/esm/Icons/Icons.js +226 -367
- package/dist/esm/ImageEditor.js +240 -0
- package/dist/esm/ImageUpload.js +217 -0
- package/dist/esm/NewBlerp.js +282 -79
- package/dist/esm/NewBlerpTest.js +11 -781
- package/dist/esm/NewCollectionModal.js +289 -304
- package/dist/esm/PremiumCollectionCard.js +192 -451
- package/dist/esm/PurchaseModals/CheckoutModal.js +1 -1
- package/dist/esm/PurchaseModals/PremiumBlerpCheckoutModal.js +1 -1
- package/dist/esm/PurchaseModals/PremiumCollectionCheckoutModal.js +1 -1
- package/dist/esm/PurchaseModals/PremiumSubscriptionCheckoutModal.js +1 -1
- package/dist/esm/ReactionButtons.js +23 -8
- package/dist/esm/SnackbarContextProvider.js +196 -110
- package/dist/esm/Theme.js +187 -66
- package/dist/esm/Toggle.js +84 -29
- package/dist/esm/UserCard.js +1 -20
- package/dist/esm/UserPage/LibraryControls.js +159 -65
- package/dist/esm/UserPage/UserLibraryHeader.js +18 -10
- package/dist/esm/UserPage/UserProfileHeader.js +100 -79
- package/dist/esm/UsernameWithPopout.js +7 -4
- package/dist/esm/colors.js +11 -9
- package/dist/esm/helpers.js +122 -0
- package/dist/esm/icons.js +1 -1
- package/dist/esm/index.js +32 -2
- package/dist/esm/neo-components/Autocomplete.js +269 -0
- package/dist/esm/neo-components/BottomNavigation.js +109 -0
- package/dist/esm/neo-components/Box.js +36 -0
- package/dist/esm/neo-components/Button.js +194 -0
- package/dist/esm/neo-components/CircularProgress.js +81 -0
- package/dist/esm/neo-components/Container.js +63 -0
- package/dist/esm/neo-components/Dialog.js +423 -0
- package/dist/esm/neo-components/Fab.js +225 -0
- package/dist/esm/neo-components/FormControls.js +1041 -0
- package/dist/esm/neo-components/Grid.js +244 -0
- package/dist/esm/neo-components/IconButton.js +99 -0
- package/dist/esm/neo-components/Input.js +478 -0
- package/dist/esm/neo-components/Layout.js +1179 -0
- package/dist/esm/neo-components/Misc.js +840 -0
- package/dist/esm/neo-components/Navigation.js +1556 -0
- package/dist/esm/neo-components/Paper.js +243 -0
- package/dist/esm/neo-components/Stack.js +182 -0
- package/dist/esm/neo-components/Stepper.js +278 -0
- package/dist/esm/neo-components/Text.js +277 -0
- package/dist/esm/neo-components/ThemeProvider.js +718 -0
- package/dist/esm/neo-components/ToggleButton.js +214 -0
- package/dist/esm/neo-components/createTheme.js +297 -0
- package/dist/esm/neo-components/withSx.js +153 -0
- package/dist/esm/neo-utils/sxToStyle.js +502 -0
- package/package.json +19 -15
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
+
import React, { useId, useState } from 'react';
|
|
5
|
+
import { withSx } from './withSx.js';
|
|
6
|
+
import { useTheme } from './ThemeProvider.js';
|
|
7
|
+
|
|
8
|
+
const _excluded = ["variant", "label", "placeholder", "helperText", "error", "disabled", "required", "fullWidth", "multiline", "rows", "maxRows", "minRows", "type", "value", "defaultValue", "onChange", "onFocus", "onBlur", "onClick", "onKeyDown", "InputProps", "inputProps", "InputLabelProps", "FormHelperTextProps", "size", "color", "darkMode", "autoFocus", "autoComplete", "name", "id", "inputRef", "startAdornment", "endAdornment", "style", "sx"],
|
|
9
|
+
_excluded2 = ["position", "children", "disablePointerEvents", "style"],
|
|
10
|
+
_excluded3 = ["children", "error", "disabled", "style"];
|
|
11
|
+
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
15
|
+
|
|
16
|
+
const resolveStyleValue = (value, colors) => {
|
|
17
|
+
if (typeof value === "string" && value.includes(".main")) {
|
|
18
|
+
const colorKey = value.replace(".main", "");
|
|
19
|
+
const color = colors === null || colors === void 0 ? void 0 : colors[colorKey];
|
|
20
|
+
if (color) return typeof color === "object" ? color.main : color;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const resolveStyles = (styleObj, colors) => {
|
|
27
|
+
if (!styleObj) return {};
|
|
28
|
+
const resolved = {};
|
|
29
|
+
|
|
30
|
+
for (const [key, value] of Object.entries(styleObj)) {
|
|
31
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
32
|
+
// Skip pseudo-selectors and nested objects for inline styles
|
|
33
|
+
if (key.startsWith("&") || key.startsWith(":")) continue;
|
|
34
|
+
resolved[key] = resolveStyles(value, colors);
|
|
35
|
+
} else {
|
|
36
|
+
resolved[key] = resolveStyleValue(value, colors);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return resolved;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Input/TextField - Form input component (replaces MUI TextField)
|
|
44
|
+
* Supports variants: outlined, filled, standard
|
|
45
|
+
*
|
|
46
|
+
* DEFAULTS TO DARK MODE (white text/borders) since most Blerp UI is on dark backgrounds.
|
|
47
|
+
* Pass darkMode={false} to use light mode styling.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const BaseInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
52
|
+
let {
|
|
53
|
+
variant = "outlined",
|
|
54
|
+
label,
|
|
55
|
+
placeholder,
|
|
56
|
+
helperText,
|
|
57
|
+
error = false,
|
|
58
|
+
disabled = false,
|
|
59
|
+
required = false,
|
|
60
|
+
fullWidth = false,
|
|
61
|
+
multiline = false,
|
|
62
|
+
rows,
|
|
63
|
+
maxRows,
|
|
64
|
+
minRows,
|
|
65
|
+
type = "text",
|
|
66
|
+
value,
|
|
67
|
+
defaultValue,
|
|
68
|
+
onChange,
|
|
69
|
+
onFocus,
|
|
70
|
+
onBlur,
|
|
71
|
+
onClick,
|
|
72
|
+
onKeyDown,
|
|
73
|
+
InputProps = {},
|
|
74
|
+
inputProps = {},
|
|
75
|
+
InputLabelProps = {},
|
|
76
|
+
FormHelperTextProps = {},
|
|
77
|
+
size = "medium",
|
|
78
|
+
color = "primary",
|
|
79
|
+
darkMode: forceDarkMode,
|
|
80
|
+
autoFocus,
|
|
81
|
+
autoComplete,
|
|
82
|
+
name,
|
|
83
|
+
id: providedId,
|
|
84
|
+
inputRef,
|
|
85
|
+
startAdornment,
|
|
86
|
+
endAdornment,
|
|
87
|
+
style,
|
|
88
|
+
sx
|
|
89
|
+
} = _ref,
|
|
90
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
91
|
+
|
|
92
|
+
const {
|
|
93
|
+
colors,
|
|
94
|
+
mode
|
|
95
|
+
} = useTheme();
|
|
96
|
+
const generatedId = useId();
|
|
97
|
+
const id = providedId || generatedId;
|
|
98
|
+
const [focused, setFocused] = useState(false);
|
|
99
|
+
const [internalValue, setInternalValue] = useState(defaultValue || ""); // Track actual value for label shrink detection
|
|
100
|
+
|
|
101
|
+
const currentValue = value !== undefined ? value : internalValue; // Helper to resolve theme colors
|
|
102
|
+
|
|
103
|
+
const getColor = (colorKey, fallback) => {
|
|
104
|
+
const c = colors === null || colors === void 0 ? void 0 : colors[colorKey];
|
|
105
|
+
if (!c) return fallback;
|
|
106
|
+
return typeof c === "object" ? c.main : c;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const colorValue = (colors === null || colors === void 0 ? void 0 : colors[color]) || (colors === null || colors === void 0 ? void 0 : colors.primary);
|
|
110
|
+
const mainColor = typeof colorValue === "object" ? colorValue.main : colorValue || "#21A5A2";
|
|
111
|
+
const errorColor = getColor("error", "#d32f2f"); // FORCE dark mode styling by default - most Blerp UI is on dark backgrounds
|
|
112
|
+
// Can be overridden with darkMode={false} prop if needed on light backgrounds
|
|
113
|
+
|
|
114
|
+
const isDark = forceDarkMode !== undefined ? forceDarkMode : true; // Colors - defaulting to white/light for dark backgrounds
|
|
115
|
+
|
|
116
|
+
const textColor = isDark ? "#FFFFFF" : "#21000C";
|
|
117
|
+
const labelColor = isDark ? "rgba(255, 255, 255, 0.7)" : "rgba(0, 0, 0, 0.6)";
|
|
118
|
+
const focusedLabelColor = isDark ? "#FFFFFF" : mainColor;
|
|
119
|
+
const borderColor = isDark ? "rgba(255, 255, 255, 0.5)" : "rgba(0, 0, 0, 0.23)";
|
|
120
|
+
const focusedBorderColor = isDark ? "#FFFFFF" : mainColor;
|
|
121
|
+
const bgColor = isDark ? "rgba(255, 255, 255, 0.08)" : "rgba(0, 0, 0, 0.04)";
|
|
122
|
+
const hoverBgColor = isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.06)";
|
|
123
|
+
const placeholderColor = isDark ? "rgba(255, 255, 255, 0.35)" : "rgba(0, 0, 0, 0.35)";
|
|
124
|
+
const labelBgColor = isDark ? "#212121" : "#FFFFFF";
|
|
125
|
+
const hasValue = currentValue !== undefined && currentValue !== null && currentValue !== "";
|
|
126
|
+
const hasPlaceholder = Boolean(placeholder); // Label should shrink if: focused, has value, OR has a placeholder (so they don't overlap)
|
|
127
|
+
|
|
128
|
+
const isLabelShrunk = focused || hasValue || hasPlaceholder; // Resolve InputProps.sx styles to actual style values
|
|
129
|
+
|
|
130
|
+
const inputPropsSx = resolveStyles(InputProps.sx || {}, colors); // Container styles
|
|
131
|
+
|
|
132
|
+
const containerStyle = _objectSpread(_objectSpread({
|
|
133
|
+
display: "inline-flex",
|
|
134
|
+
flexDirection: "column",
|
|
135
|
+
position: "relative",
|
|
136
|
+
minWidth: 0,
|
|
137
|
+
padding: 0,
|
|
138
|
+
margin: 0,
|
|
139
|
+
border: 0,
|
|
140
|
+
verticalAlign: "top"
|
|
141
|
+
}, fullWidth && {
|
|
142
|
+
width: "100%"
|
|
143
|
+
}), style); // Determine current border color based on state
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
const getCurrentBorderColor = () => {
|
|
147
|
+
if (error) return errorColor;
|
|
148
|
+
if (focused) return focusedBorderColor;
|
|
149
|
+
return borderColor;
|
|
150
|
+
}; // Input wrapper styles (the bordered box)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
const getWrapperStyles = () => {
|
|
154
|
+
const activeBorderColor = getCurrentBorderColor(); // Check if InputProps.sx overrides border-related styles
|
|
155
|
+
|
|
156
|
+
const hasBorderOverride = inputPropsSx.border !== undefined || inputPropsSx.borderColor !== undefined;
|
|
157
|
+
const hasRadiusOverride = inputPropsSx.borderRadius !== undefined;
|
|
158
|
+
const hasBgOverride = inputPropsSx.backgroundColor !== undefined || inputPropsSx.background !== undefined;
|
|
159
|
+
const hasHeightOverride = inputPropsSx.height !== undefined;
|
|
160
|
+
const hasPaddingOverride = inputPropsSx.padding !== undefined;
|
|
161
|
+
const base = {
|
|
162
|
+
display: "flex",
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
position: "relative",
|
|
165
|
+
borderRadius: hasRadiusOverride ? inputPropsSx.borderRadius : "6px",
|
|
166
|
+
transition: "border-color 200ms ease, background-color 200ms ease, box-shadow 200ms ease",
|
|
167
|
+
cursor: disabled ? "default" : "text",
|
|
168
|
+
backgroundColor: hasBgOverride ? inputPropsSx.backgroundColor || inputPropsSx.background : "transparent",
|
|
169
|
+
minHeight: hasHeightOverride ? undefined : size === "small" ? "32px" : "40px",
|
|
170
|
+
height: hasHeightOverride ? inputPropsSx.height : undefined,
|
|
171
|
+
boxSizing: inputPropsSx.boxSizing || "border-box"
|
|
172
|
+
}; // If there's a complete style override from InputProps.sx, use minimal base styling
|
|
173
|
+
|
|
174
|
+
if (hasBorderOverride || inputPropsSx.border === "none") {
|
|
175
|
+
return _objectSpread(_objectSpread({}, base), {}, {
|
|
176
|
+
border: inputPropsSx.border !== undefined ? inputPropsSx.border : "none",
|
|
177
|
+
borderColor: inputPropsSx.borderColor,
|
|
178
|
+
padding: hasPaddingOverride ? inputPropsSx.padding : undefined
|
|
179
|
+
}, inputPropsSx);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
switch (variant) {
|
|
183
|
+
case "filled":
|
|
184
|
+
return _objectSpread(_objectSpread({}, base), {}, {
|
|
185
|
+
backgroundColor: hasBgOverride ? inputPropsSx.backgroundColor || inputPropsSx.background : focused ? hoverBgColor : bgColor,
|
|
186
|
+
borderBottom: "2px solid ".concat(activeBorderColor),
|
|
187
|
+
borderRadius: hasRadiusOverride ? inputPropsSx.borderRadius : "8px 8px 0 0",
|
|
188
|
+
paddingTop: label ? "20px" : "0"
|
|
189
|
+
}, inputPropsSx);
|
|
190
|
+
|
|
191
|
+
case "standard":
|
|
192
|
+
return _objectSpread(_objectSpread({}, base), {}, {
|
|
193
|
+
borderBottom: "".concat(focused ? "2px" : "1px", " solid ").concat(activeBorderColor),
|
|
194
|
+
borderRadius: 0,
|
|
195
|
+
paddingTop: label ? "16px" : "0",
|
|
196
|
+
paddingBottom: focused ? "0px" : "1px"
|
|
197
|
+
}, inputPropsSx);
|
|
198
|
+
|
|
199
|
+
case "outlined":
|
|
200
|
+
default:
|
|
201
|
+
return _objectSpread(_objectSpread({}, base), {}, {
|
|
202
|
+
border: "".concat(focused ? "2px" : "1px", " solid ").concat(activeBorderColor),
|
|
203
|
+
padding: focused ? "0px" : "1px",
|
|
204
|
+
boxShadow: focused ? "0 0 0 3px ".concat(isDark ? "rgba(255,255,255,0.1)" : "".concat(mainColor, "20")) : "none"
|
|
205
|
+
}, inputPropsSx);
|
|
206
|
+
}
|
|
207
|
+
}; // Input element styles
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
const getInputStyles = () => {
|
|
211
|
+
// Check for font/text overrides
|
|
212
|
+
const fontSize = inputPropsSx.fontSize || (size === "small" ? "14px" : "16px");
|
|
213
|
+
const caretColor = inputPropsSx.caretColor;
|
|
214
|
+
return _objectSpread(_objectSpread({
|
|
215
|
+
fontFamily: "inherit",
|
|
216
|
+
fontSize: fontSize,
|
|
217
|
+
fontWeight: 400,
|
|
218
|
+
letterSpacing: "0.01em",
|
|
219
|
+
lineHeight: 1.5,
|
|
220
|
+
color: textColor,
|
|
221
|
+
// Always use theme text color (white for dark mode)
|
|
222
|
+
border: 0,
|
|
223
|
+
boxSizing: "border-box",
|
|
224
|
+
background: "none",
|
|
225
|
+
margin: 0,
|
|
226
|
+
display: "block",
|
|
227
|
+
minWidth: 0,
|
|
228
|
+
width: "100%",
|
|
229
|
+
outline: "none",
|
|
230
|
+
padding: "4px 8px",
|
|
231
|
+
resize: multiline ? "vertical" : "none",
|
|
232
|
+
WebkitTextFillColor: textColor
|
|
233
|
+
}, caretColor && {
|
|
234
|
+
caretColor
|
|
235
|
+
}), disabled && {
|
|
236
|
+
opacity: 0.5,
|
|
237
|
+
cursor: "not-allowed"
|
|
238
|
+
});
|
|
239
|
+
}; // Label styles
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
const getLabelStyles = () => {
|
|
243
|
+
const leftPos = variant === "outlined" ? "11px" : variant === "filled" ? "11px" : "0";
|
|
244
|
+
|
|
245
|
+
const getTransform = () => {
|
|
246
|
+
if (isLabelShrunk) {
|
|
247
|
+
switch (variant) {
|
|
248
|
+
case "outlined":
|
|
249
|
+
return "translate(0, -50%) scale(0.75)";
|
|
250
|
+
|
|
251
|
+
case "filled":
|
|
252
|
+
return "translate(0, -100%) scale(0.75)";
|
|
253
|
+
|
|
254
|
+
case "standard":
|
|
255
|
+
return "translate(0, -100%) scale(0.75)";
|
|
256
|
+
|
|
257
|
+
default:
|
|
258
|
+
return "translate(0, -50%) scale(0.75)";
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return "translate(0, -50%) scale(1)";
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const getTop = () => {
|
|
266
|
+
if (variant === "outlined") {
|
|
267
|
+
return isLabelShrunk ? "0" : "50%";
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (variant === "filled") {
|
|
271
|
+
return isLabelShrunk ? "8px" : "50%";
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return isLabelShrunk ? "0" : "50%";
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
return _objectSpread({
|
|
278
|
+
position: "absolute",
|
|
279
|
+
left: leftPos,
|
|
280
|
+
top: getTop(),
|
|
281
|
+
transform: getTransform(),
|
|
282
|
+
transformOrigin: "top left",
|
|
283
|
+
transition: "transform 200ms cubic-bezier(0.4, 0, 0.2, 1), color 200ms cubic-bezier(0.4, 0, 0.2, 1), top 200ms cubic-bezier(0.4, 0, 0.2, 1)",
|
|
284
|
+
color: error ? errorColor : focused ? focusedLabelColor : labelColor,
|
|
285
|
+
pointerEvents: "none",
|
|
286
|
+
backgroundColor: variant === "outlined" && isLabelShrunk ? labelBgColor : "transparent",
|
|
287
|
+
padding: variant === "outlined" && isLabelShrunk ? "0 6px" : "4px",
|
|
288
|
+
marginLeft: variant === "outlined" && isLabelShrunk ? "-4px" : 0,
|
|
289
|
+
fontSize: "11px",
|
|
290
|
+
fontWeight: 400,
|
|
291
|
+
lineHeight: 1.4,
|
|
292
|
+
whiteSpace: "nowrap",
|
|
293
|
+
overflow: "hidden",
|
|
294
|
+
textOverflow: "ellipsis",
|
|
295
|
+
maxWidth: isLabelShrunk ? "133%" : "calc(100% - 32px)",
|
|
296
|
+
zIndex: 1
|
|
297
|
+
}, InputLabelProps.style);
|
|
298
|
+
}; // Helper text styles
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
const helperTextStyle = _objectSpread({
|
|
302
|
+
fontSize: "12px",
|
|
303
|
+
fontWeight: 400,
|
|
304
|
+
lineHeight: 1.4,
|
|
305
|
+
marginTop: "6px",
|
|
306
|
+
marginLeft: variant === "standard" ? "0" : "14px",
|
|
307
|
+
marginRight: "14px",
|
|
308
|
+
color: error ? errorColor : labelColor
|
|
309
|
+
}, FormHelperTextProps.style);
|
|
310
|
+
|
|
311
|
+
const handleFocus = e => {
|
|
312
|
+
setFocused(true);
|
|
313
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const handleBlur = e => {
|
|
317
|
+
setFocused(false);
|
|
318
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const handleChange = e => {
|
|
322
|
+
if (value === undefined) {
|
|
323
|
+
setInternalValue(e.target.value);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const handleClick = e => {
|
|
330
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
331
|
+
|
|
332
|
+
if (!disabled) {
|
|
333
|
+
const input = document.getElementById(id);
|
|
334
|
+
input === null || input === void 0 ? void 0 : input.focus();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const InputComponent = multiline ? "textarea" : "input"; // Create a safe CSS ID for the style block
|
|
339
|
+
|
|
340
|
+
const safeId = id.replace(/:/g, "\\:"); // Text color is always based on dark/light mode, not InputProps.sx.color
|
|
341
|
+
// (InputProps.sx.color in MUI is typically for border/accent, not text)
|
|
342
|
+
|
|
343
|
+
const resolvedTextColor = textColor; // Combine refs
|
|
344
|
+
|
|
345
|
+
const setRefs = el => {
|
|
346
|
+
if (typeof ref === "function") ref(el);else if (ref) ref.current = el;
|
|
347
|
+
if (typeof inputRef === "function") inputRef(el);else if (inputRef) inputRef.current = el;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
351
|
+
style: containerStyle
|
|
352
|
+
}, props), /*#__PURE__*/React.createElement("style", null, "\n #".concat(safeId, "::placeholder {\n color: ").concat(placeholderColor, " !important;\n opacity: 1 !important;\n font-style: italic !important;\n font-weight: 300 !important;\n }\n #").concat(safeId, "::-webkit-input-placeholder {\n color: ").concat(placeholderColor, " !important;\n font-style: italic !important;\n font-weight: 300 !important;\n }\n #").concat(safeId, "::-moz-placeholder {\n color: ").concat(placeholderColor, " !important;\n font-style: italic !important;\n font-weight: 300 !important;\n }\n #").concat(safeId, " {\n color: ").concat(resolvedTextColor, " !important;\n -webkit-text-fill-color: ").concat(resolvedTextColor, " !important;\n }\n ")), /*#__PURE__*/React.createElement("div", {
|
|
353
|
+
style: getWrapperStyles(),
|
|
354
|
+
onClick: handleClick
|
|
355
|
+
}, label && /*#__PURE__*/React.createElement("label", _extends({
|
|
356
|
+
htmlFor: id,
|
|
357
|
+
style: getLabelStyles()
|
|
358
|
+
}, InputLabelProps), label, required && /*#__PURE__*/React.createElement("span", {
|
|
359
|
+
style: {
|
|
360
|
+
color: errorColor,
|
|
361
|
+
marginLeft: "2px"
|
|
362
|
+
}
|
|
363
|
+
}, "*")), (startAdornment || InputProps.startAdornment) && /*#__PURE__*/React.createElement("div", {
|
|
364
|
+
style: {
|
|
365
|
+
display: "flex",
|
|
366
|
+
alignItems: "center",
|
|
367
|
+
paddingLeft: "4px",
|
|
368
|
+
color: labelColor,
|
|
369
|
+
flexShrink: 0
|
|
370
|
+
}
|
|
371
|
+
}, startAdornment || InputProps.startAdornment), /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
372
|
+
ref: setRefs,
|
|
373
|
+
id: id,
|
|
374
|
+
type: type,
|
|
375
|
+
style: getInputStyles(),
|
|
376
|
+
placeholder: placeholder,
|
|
377
|
+
disabled: disabled,
|
|
378
|
+
required: required,
|
|
379
|
+
value: value,
|
|
380
|
+
defaultValue: defaultValue,
|
|
381
|
+
onChange: handleChange,
|
|
382
|
+
onFocus: handleFocus,
|
|
383
|
+
onBlur: handleBlur,
|
|
384
|
+
onKeyDown: onKeyDown,
|
|
385
|
+
autoFocus: autoFocus,
|
|
386
|
+
autoComplete: autoComplete,
|
|
387
|
+
name: name,
|
|
388
|
+
rows: multiline ? rows || minRows || 3 : undefined,
|
|
389
|
+
"aria-invalid": error,
|
|
390
|
+
"aria-describedby": helperText ? "".concat(id, "-helper-text") : undefined
|
|
391
|
+
}, inputProps, InputProps.inputProps)), (endAdornment || InputProps.endAdornment) && /*#__PURE__*/React.createElement("div", {
|
|
392
|
+
style: {
|
|
393
|
+
display: "flex",
|
|
394
|
+
alignItems: "center",
|
|
395
|
+
paddingRight: "4px",
|
|
396
|
+
color: labelColor,
|
|
397
|
+
flexShrink: 0
|
|
398
|
+
}
|
|
399
|
+
}, endAdornment || InputProps.endAdornment)), helperText && /*#__PURE__*/React.createElement("p", _extends({
|
|
400
|
+
id: "".concat(id, "-helper-text"),
|
|
401
|
+
style: helperTextStyle
|
|
402
|
+
}, FormHelperTextProps), helperText));
|
|
403
|
+
});
|
|
404
|
+
BaseInput.displayName = "BaseInput";
|
|
405
|
+
const Input = withSx(BaseInput);
|
|
406
|
+
const TextField = Input; // Alias for MUI compatibility
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* InputAdornment - For adding icons/text to inputs
|
|
410
|
+
*/
|
|
411
|
+
|
|
412
|
+
const InputAdornment = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
413
|
+
let {
|
|
414
|
+
position = "start",
|
|
415
|
+
children,
|
|
416
|
+
disablePointerEvents = false,
|
|
417
|
+
style
|
|
418
|
+
} = _ref2,
|
|
419
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
420
|
+
|
|
421
|
+
const adornmentStyle = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
422
|
+
display: "flex",
|
|
423
|
+
alignItems: "center",
|
|
424
|
+
justifyContent: "center",
|
|
425
|
+
height: "100%",
|
|
426
|
+
color: "rgba(255, 255, 255, 0.7)",
|
|
427
|
+
whiteSpace: "nowrap"
|
|
428
|
+
}, position === "start" && {
|
|
429
|
+
marginRight: "4px"
|
|
430
|
+
}), position === "end" && {
|
|
431
|
+
marginLeft: "4px"
|
|
432
|
+
}), disablePointerEvents && {
|
|
433
|
+
pointerEvents: "none"
|
|
434
|
+
}), style);
|
|
435
|
+
|
|
436
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
437
|
+
ref: ref,
|
|
438
|
+
style: adornmentStyle
|
|
439
|
+
}, props), children);
|
|
440
|
+
});
|
|
441
|
+
InputAdornment.displayName = "InputAdornment";
|
|
442
|
+
/**
|
|
443
|
+
* FormHelperText - Standalone helper text component
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
const FormHelperText = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
447
|
+
var _colors$error;
|
|
448
|
+
|
|
449
|
+
let {
|
|
450
|
+
children,
|
|
451
|
+
error = false,
|
|
452
|
+
disabled = false,
|
|
453
|
+
style
|
|
454
|
+
} = _ref3,
|
|
455
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
456
|
+
|
|
457
|
+
const {
|
|
458
|
+
colors
|
|
459
|
+
} = useTheme();
|
|
460
|
+
const errorColor = (colors === null || colors === void 0 ? void 0 : (_colors$error = colors.error) === null || _colors$error === void 0 ? void 0 : _colors$error.main) || "#d32f2f";
|
|
461
|
+
|
|
462
|
+
const helperStyle = _objectSpread({
|
|
463
|
+
fontSize: "12px",
|
|
464
|
+
fontWeight: 400,
|
|
465
|
+
lineHeight: 1.4,
|
|
466
|
+
margin: "6px 14px 0",
|
|
467
|
+
color: error ? errorColor : "rgba(255, 255, 255, 0.7)",
|
|
468
|
+
opacity: disabled ? 0.6 : 1
|
|
469
|
+
}, style);
|
|
470
|
+
|
|
471
|
+
return /*#__PURE__*/React.createElement("p", _extends({
|
|
472
|
+
ref: ref,
|
|
473
|
+
style: helperStyle
|
|
474
|
+
}, props), children);
|
|
475
|
+
});
|
|
476
|
+
FormHelperText.displayName = "FormHelperText";
|
|
477
|
+
|
|
478
|
+
export { FormHelperText, Input, InputAdornment, TextField, Input as default };
|