@blerp/design 1.4.3 → 1.4.5
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/Theme.js
CHANGED
|
@@ -99,19 +99,6 @@ const mainTheme = {
|
|
|
99
99
|
};
|
|
100
100
|
const fonts = "@font-face {\n font-family: \"Odudo\";\n font-weight: normal;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: lighter;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: 300;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: 400;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: bolder;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: 600;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: bold;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: 700;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.woff\")\n format(\"woff\");\n}"; // Try to load MUI dynamically, but don't fail if it's not installed
|
|
101
101
|
|
|
102
|
-
let createTheme = null;
|
|
103
|
-
let MuiThemeProvider = null;
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
const mui = require("@mui/material/styles");
|
|
107
|
-
|
|
108
|
-
createTheme = mui.createTheme;
|
|
109
|
-
MuiThemeProvider = mui.ThemeProvider;
|
|
110
|
-
} catch (e) {// MUI not installed, that's fine
|
|
111
|
-
// console.log("MUI not detected - using lightweight theme mode");
|
|
112
|
-
} // Try to load styled-components, but don't fail if it's not installed
|
|
113
|
-
|
|
114
|
-
|
|
115
102
|
let StyledThemeProvider = null;
|
|
116
103
|
|
|
117
104
|
try {
|
|
@@ -141,7 +128,7 @@ const darkThemeConfig = _objectSpread({
|
|
|
141
128
|
palette: colors.darkPalette
|
|
142
129
|
}, mainTheme); // MUI themes (only created if MUI is available)
|
|
143
130
|
|
|
144
|
-
|
|
131
|
+
({
|
|
145
132
|
typography: {
|
|
146
133
|
fontFamily: "Odudo, Arial"
|
|
147
134
|
},
|
|
@@ -244,84 +231,9 @@ const muiThemeConfig = {
|
|
|
244
231
|
styleOverrides: fonts
|
|
245
232
|
}
|
|
246
233
|
}
|
|
247
|
-
};
|
|
248
|
-
const theme =
|
|
249
|
-
|
|
250
|
-
colors: colors.lightColors,
|
|
251
|
-
icons: icons,
|
|
252
|
-
palette: colors.lightPalette
|
|
253
|
-
})) : lightThemeConfig;
|
|
254
|
-
const darkTheme = createTheme ? createTheme(_objectSpread(_objectSpread({}, muiThemeConfig), {}, {
|
|
255
|
-
components: _objectSpread(_objectSpread({}, muiThemeConfig.components), {}, {
|
|
256
|
-
MuiTypography: {
|
|
257
|
-
styleOverrides: {
|
|
258
|
-
root: {
|
|
259
|
-
color: colors["default"].white
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
MuiFilledInput: {
|
|
264
|
-
styleOverrides: {
|
|
265
|
-
root: {
|
|
266
|
-
color: colors["default"].white,
|
|
267
|
-
backgroundColor: colors["default"].grey7,
|
|
268
|
-
"& textarea": {
|
|
269
|
-
color: colors["default"].white
|
|
270
|
-
},
|
|
271
|
-
":hover": {
|
|
272
|
-
backgroundColor: colors["default"].grey7
|
|
273
|
-
},
|
|
274
|
-
":before": {
|
|
275
|
-
borderColor: colors["default"].waxwing
|
|
276
|
-
},
|
|
277
|
-
":hover:before": {
|
|
278
|
-
borderColor: "".concat(colors["default"].white, " !important")
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
MuiInput: {
|
|
284
|
-
styleOverrides: {
|
|
285
|
-
root: {
|
|
286
|
-
color: colors["default"].white,
|
|
287
|
-
borderColor: colors["default"].white,
|
|
288
|
-
":before": {
|
|
289
|
-
borderColor: colors["default"].waxwing
|
|
290
|
-
},
|
|
291
|
-
":hover:before": {
|
|
292
|
-
borderColor: "".concat(colors["default"].white, " !important")
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
MuiInputLabel: {
|
|
298
|
-
styleOverrides: {
|
|
299
|
-
root: {
|
|
300
|
-
color: colors["default"].white
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
MuiSvgIcon: {
|
|
305
|
-
styleOverrides: {
|
|
306
|
-
root: {
|
|
307
|
-
color: colors["default"].white
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
MuiBackdrop: {
|
|
312
|
-
styleOverrides: {
|
|
313
|
-
root: {
|
|
314
|
-
backgroundColor: "".concat(colors["default"].grey5, "70"),
|
|
315
|
-
backdropFilter: "blur(4px)"
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}),
|
|
320
|
-
mode: "dark",
|
|
321
|
-
colors: colors.darkColors,
|
|
322
|
-
icons: icons,
|
|
323
|
-
palette: colors.darkPalette
|
|
324
|
-
})) : darkThemeConfig; // Create a context for theme access (legacy - for styled-components)
|
|
234
|
+
});
|
|
235
|
+
const theme = lightThemeConfig;
|
|
236
|
+
const darkTheme = darkThemeConfig; // Create a context for theme access (legacy - for styled-components)
|
|
325
237
|
|
|
326
238
|
const BlerpThemeContext = /*#__PURE__*/React.createContext(null);
|
|
327
239
|
const useBlerpTheme = () => {
|
|
@@ -335,7 +247,7 @@ const useBlerpTheme = () => {
|
|
|
335
247
|
};
|
|
336
248
|
/**
|
|
337
249
|
* BlerpTheme - Main theme provider
|
|
338
|
-
*
|
|
250
|
+
*
|
|
339
251
|
* FIXED: Now accepts and passes through customColors to NewThemeProvider
|
|
340
252
|
* This allows ExtensionTheme and other consumers to override extension colors
|
|
341
253
|
*/
|
|
@@ -362,9 +274,7 @@ const BlerpTheme = _ref => {
|
|
|
362
274
|
theme: themeValue
|
|
363
275
|
}, innerContent) : innerContent; // Wrap with MUI ThemeProvider if available
|
|
364
276
|
|
|
365
|
-
const withMuiTheme =
|
|
366
|
-
theme: currentTheme
|
|
367
|
-
}, withStyledTheme) : withStyledTheme; // CRITICAL FIX: Pass customColors through to NewThemeProvider
|
|
277
|
+
const withMuiTheme = withStyledTheme; // CRITICAL FIX: Pass customColors through to NewThemeProvider
|
|
368
278
|
// This ensures neo-components get the extension color overrides
|
|
369
279
|
|
|
370
280
|
return /*#__PURE__*/React__default["default"].createElement(ThemeProvider.ThemeProvider, {
|
|
@@ -21,7 +21,7 @@ const _excluded = ["checked", "defaultChecked", "disabled", "onChange", "color",
|
|
|
21
21
|
_excluded2 = ["checked", "defaultChecked", "disabled", "onChange", "color", "size", "name", "value", "inputProps", "style"],
|
|
22
22
|
_excluded3 = ["checked", "defaultChecked", "disabled", "onChange", "color", "size", "name", "value", "inputProps", "style"],
|
|
23
23
|
_excluded4 = ["value", "defaultValue", "onChange", "children", "disabled", "multiple", "native", "variant", "label", "fullWidth", "size", "error", "displayEmpty", "renderValue", "MenuProps", "inputProps", "style", "IconComponent", "disableBorder", "color"],
|
|
24
|
-
_excluded5 = ["value", "defaultValue", "onChange", "onChangeCommitted", "min", "max", "step", "marks", "disabled", "orientation", "color", "size", "valueLabelDisplay", "valueLabelFormat", "getAriaValueText", "track", "style"],
|
|
24
|
+
_excluded5 = ["value", "defaultValue", "onChange", "onChangeCommitted", "min", "max", "step", "marks", "disabled", "orientation", "color", "size", "valueLabelDisplay", "valueLabelFormat", "getAriaValueText", "track", "disableSwap", "style"],
|
|
25
25
|
_excluded6 = ["value", "defaultValue", "onChange", "max", "precision", "disabled", "readOnly", "size", "emptyIcon", "icon", "name", "style"];
|
|
26
26
|
|
|
27
27
|
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; }
|
|
@@ -764,6 +764,7 @@ const BaseSlider = /*#__PURE__*/React__default["default"].forwardRef((_ref5, ref
|
|
|
764
764
|
valueLabelFormat,
|
|
765
765
|
getAriaValueText,
|
|
766
766
|
track = "normal",
|
|
767
|
+
disableSwap = false,
|
|
767
768
|
style
|
|
768
769
|
} = _ref5,
|
|
769
770
|
props = _objectWithoutProperties__default["default"](_ref5, _excluded5);
|
|
@@ -771,55 +772,103 @@ const BaseSlider = /*#__PURE__*/React__default["default"].forwardRef((_ref5, ref
|
|
|
771
772
|
const {
|
|
772
773
|
colors
|
|
773
774
|
} = ThemeProvider.useTheme();
|
|
775
|
+
const isRange = Array.isArray(value) || Array.isArray(defaultValue);
|
|
774
776
|
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
775
777
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
778
|
+
const [activeThumb, setActiveThumb] = React.useState(-1);
|
|
776
779
|
const sliderRef = React.useRef(null);
|
|
777
780
|
const currentValue = value !== undefined ? value : internalValue;
|
|
778
781
|
const colorValue = colors[color] || colors.primary;
|
|
779
782
|
const mainColor = typeof colorValue === "object" ? colorValue.main : colorValue;
|
|
780
783
|
const trackThickness = 4;
|
|
781
|
-
const thumbSize = 20;
|
|
782
|
-
const percentage = (currentValue - min) / (max - min) * 100;
|
|
784
|
+
const thumbSize = 20; // Calculate percentages for range or single
|
|
783
785
|
|
|
784
|
-
const
|
|
785
|
-
const clampedValue = Math.min(max, Math.max(min, newValue));
|
|
786
|
-
const steppedValue = Math.round(clampedValue / step) * step;
|
|
786
|
+
const getPercentage = val => (val - min) / (max - min) * 100;
|
|
787
787
|
|
|
788
|
-
|
|
789
|
-
setInternalValue(steppedValue);
|
|
790
|
-
}
|
|
788
|
+
const percentage = isRange ? [getPercentage(currentValue[0]), getPercentage(currentValue[1])] : getPercentage(currentValue);
|
|
791
789
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
790
|
+
const handleChange = (newValue, thumbIndex) => {
|
|
791
|
+
if (isRange) {
|
|
792
|
+
const clampedValue = Math.min(max, Math.max(min, newValue));
|
|
793
|
+
const steppedValue = Math.round(clampedValue / step) * step;
|
|
794
|
+
let newRange = [...currentValue];
|
|
795
|
+
newRange[thumbIndex] = steppedValue; // Handle swap prevention
|
|
796
|
+
|
|
797
|
+
if (disableSwap) {
|
|
798
|
+
if (thumbIndex === 0 && steppedValue > currentValue[1]) {
|
|
799
|
+
newRange[0] = currentValue[1];
|
|
800
|
+
} else if (thumbIndex === 1 && steppedValue < currentValue[0]) {
|
|
801
|
+
newRange[1] = currentValue[0];
|
|
802
|
+
}
|
|
803
|
+
} else {
|
|
804
|
+
// Auto-swap if needed
|
|
805
|
+
if (newRange[0] > newRange[1]) {
|
|
806
|
+
newRange = [newRange[1], newRange[0]];
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
if (value === undefined) {
|
|
811
|
+
setInternalValue(newRange);
|
|
795
812
|
}
|
|
796
|
-
|
|
813
|
+
|
|
814
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
815
|
+
target: {
|
|
816
|
+
value: newRange
|
|
817
|
+
}
|
|
818
|
+
}, newRange, thumbIndex);
|
|
819
|
+
} else {
|
|
820
|
+
const clampedValue = Math.min(max, Math.max(min, newValue));
|
|
821
|
+
const steppedValue = Math.round(clampedValue / step) * step;
|
|
822
|
+
|
|
823
|
+
if (value === undefined) {
|
|
824
|
+
setInternalValue(steppedValue);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
828
|
+
target: {
|
|
829
|
+
value: steppedValue
|
|
830
|
+
}
|
|
831
|
+
}, steppedValue);
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
const getClosestThumb = clientX => {
|
|
836
|
+
if (!sliderRef.current || !isRange) return 0;
|
|
837
|
+
const rect = sliderRef.current.getBoundingClientRect();
|
|
838
|
+
const percent = (clientX - rect.left) / rect.width;
|
|
839
|
+
const clickValue = min + percent * (max - min);
|
|
840
|
+
const dist0 = Math.abs(currentValue[0] - clickValue);
|
|
841
|
+
const dist1 = Math.abs(currentValue[1] - clickValue);
|
|
842
|
+
return dist0 <= dist1 ? 0 : 1;
|
|
797
843
|
};
|
|
798
844
|
|
|
799
|
-
const updateValue = e => {
|
|
845
|
+
const updateValue = (e, thumbIdx) => {
|
|
800
846
|
if (!sliderRef.current) return;
|
|
801
847
|
const rect = sliderRef.current.getBoundingClientRect();
|
|
802
848
|
const percent = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
803
849
|
const newValue = min + percent * (max - min);
|
|
804
|
-
handleChange(newValue);
|
|
850
|
+
handleChange(newValue, thumbIdx);
|
|
805
851
|
};
|
|
806
852
|
|
|
807
853
|
const handleMouseDown = e => {
|
|
808
854
|
if (disabled) return;
|
|
809
855
|
e.preventDefault();
|
|
856
|
+
const thumbIdx = isRange ? getClosestThumb(e.clientX) : 0;
|
|
857
|
+
setActiveThumb(thumbIdx);
|
|
810
858
|
setIsDragging(true);
|
|
811
|
-
updateValue(e);
|
|
859
|
+
updateValue(e, thumbIdx);
|
|
812
860
|
};
|
|
813
861
|
|
|
814
862
|
React.useEffect(() => {
|
|
815
863
|
if (!isDragging) return;
|
|
816
864
|
|
|
817
865
|
const handleMouseMove = e => {
|
|
818
|
-
updateValue(e);
|
|
866
|
+
updateValue(e, activeThumb);
|
|
819
867
|
};
|
|
820
868
|
|
|
821
869
|
const handleMouseUp = () => {
|
|
822
870
|
setIsDragging(false);
|
|
871
|
+
setActiveThumb(-1);
|
|
823
872
|
onChangeCommitted === null || onChangeCommitted === void 0 ? void 0 : onChangeCommitted({
|
|
824
873
|
target: {
|
|
825
874
|
value: currentValue
|
|
@@ -833,7 +882,7 @@ const BaseSlider = /*#__PURE__*/React__default["default"].forwardRef((_ref5, ref
|
|
|
833
882
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
834
883
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
835
884
|
};
|
|
836
|
-
}, [isDragging, currentValue, min, max, step]);
|
|
885
|
+
}, [isDragging, activeThumb, currentValue, min, max, step]);
|
|
837
886
|
|
|
838
887
|
const containerStyle = _objectSpread(_objectSpread({
|
|
839
888
|
position: "relative",
|
|
@@ -855,7 +904,17 @@ const BaseSlider = /*#__PURE__*/React__default["default"].forwardRef((_ref5, ref
|
|
|
855
904
|
borderRadius: "".concat(trackThickness / 2, "px"),
|
|
856
905
|
backgroundColor: "rgba(255, 255, 255, 0.3)"
|
|
857
906
|
};
|
|
858
|
-
const trackStyle = {
|
|
907
|
+
const trackStyle = isRange ? {
|
|
908
|
+
position: "absolute",
|
|
909
|
+
left: "".concat(percentage[0], "%"),
|
|
910
|
+
width: "".concat(percentage[1] - percentage[0], "%"),
|
|
911
|
+
height: "".concat(trackThickness, "px"),
|
|
912
|
+
top: "50%",
|
|
913
|
+
transform: "translateY(-50%)",
|
|
914
|
+
borderRadius: "".concat(trackThickness / 2, "px"),
|
|
915
|
+
backgroundColor: mainColor,
|
|
916
|
+
transition: isDragging ? "none" : "left 150ms, width 150ms"
|
|
917
|
+
} : {
|
|
859
918
|
position: "absolute",
|
|
860
919
|
width: "".concat(percentage, "%"),
|
|
861
920
|
height: "".concat(trackThickness, "px"),
|
|
@@ -866,22 +925,22 @@ const BaseSlider = /*#__PURE__*/React__default["default"].forwardRef((_ref5, ref
|
|
|
866
925
|
transition: isDragging ? "none" : "width 150ms"
|
|
867
926
|
};
|
|
868
927
|
|
|
869
|
-
const
|
|
928
|
+
const getThumbStyle = (pct, idx) => _objectSpread({
|
|
870
929
|
position: "absolute",
|
|
871
930
|
width: "".concat(thumbSize, "px"),
|
|
872
931
|
height: "".concat(thumbSize, "px"),
|
|
873
932
|
borderRadius: "50%",
|
|
874
933
|
backgroundColor: mainColor,
|
|
875
934
|
boxShadow: "0px 2px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 3px 0px rgba(0,0,0,0.12)",
|
|
876
|
-
left: "calc(".concat(
|
|
935
|
+
left: "calc(".concat(pct, "% - ").concat(thumbSize / 2, "px)"),
|
|
877
936
|
top: "50%",
|
|
878
937
|
transform: "translateY(-50%)",
|
|
879
|
-
transition: isDragging ? "none" : "left 150ms",
|
|
880
|
-
cursor: "grab"
|
|
881
|
-
|
|
938
|
+
transition: isDragging && activeThumb === idx ? "none" : "left 150ms",
|
|
939
|
+
cursor: "grab",
|
|
940
|
+
zIndex: activeThumb === idx ? 2 : 1
|
|
941
|
+
}, isDragging && activeThumb === idx && {
|
|
882
942
|
cursor: "grabbing"
|
|
883
|
-
});
|
|
884
|
-
|
|
943
|
+
});
|
|
885
944
|
|
|
886
945
|
const renderMarks = () => {
|
|
887
946
|
if (!marks) return null;
|
|
@@ -919,7 +978,12 @@ const BaseSlider = /*#__PURE__*/React__default["default"].forwardRef((_ref5, ref
|
|
|
919
978
|
});
|
|
920
979
|
};
|
|
921
980
|
|
|
922
|
-
const
|
|
981
|
+
const formatDisplayValue = val => {
|
|
982
|
+
if (valueLabelFormat) return valueLabelFormat(val);
|
|
983
|
+
if (getAriaValueText) return getAriaValueText(val);
|
|
984
|
+
return val;
|
|
985
|
+
};
|
|
986
|
+
|
|
923
987
|
return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({
|
|
924
988
|
ref: node => {
|
|
925
989
|
sliderRef.current = node;
|
|
@@ -935,15 +999,44 @@ const BaseSlider = /*#__PURE__*/React__default["default"].forwardRef((_ref5, ref
|
|
|
935
999
|
role: "slider",
|
|
936
1000
|
"aria-valuemin": min,
|
|
937
1001
|
"aria-valuemax": max,
|
|
938
|
-
"aria-valuenow": currentValue,
|
|
939
|
-
"aria-valuetext": getAriaValueText === null || getAriaValueText === void 0 ? void 0 : getAriaValueText(currentValue),
|
|
1002
|
+
"aria-valuenow": isRange ? currentValue[0] : currentValue,
|
|
940
1003
|
tabIndex: disabled ? -1 : 0
|
|
941
1004
|
}, props), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
942
1005
|
style: railStyle
|
|
943
1006
|
}), track !== false && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
944
1007
|
style: trackStyle
|
|
945
|
-
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
946
|
-
style:
|
|
1008
|
+
}), isRange ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1009
|
+
style: getThumbStyle(percentage[0], 0)
|
|
1010
|
+
}, valueLabelDisplay === "on" || valueLabelDisplay === "auto" && isDragging && activeThumb === 0 ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1011
|
+
style: {
|
|
1012
|
+
position: "absolute",
|
|
1013
|
+
bottom: "calc(100% + 8px)",
|
|
1014
|
+
left: "50%",
|
|
1015
|
+
transform: "translateX(-50%)",
|
|
1016
|
+
padding: "4px 8px",
|
|
1017
|
+
borderRadius: "4px",
|
|
1018
|
+
backgroundColor: "rgba(0, 0, 0, 0.87)",
|
|
1019
|
+
color: "#fff",
|
|
1020
|
+
fontSize: "12px",
|
|
1021
|
+
whiteSpace: "nowrap"
|
|
1022
|
+
}
|
|
1023
|
+
}, formatDisplayValue(currentValue[0])) : null), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1024
|
+
style: getThumbStyle(percentage[1], 1)
|
|
1025
|
+
}, valueLabelDisplay === "on" || valueLabelDisplay === "auto" && isDragging && activeThumb === 1 ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1026
|
+
style: {
|
|
1027
|
+
position: "absolute",
|
|
1028
|
+
bottom: "calc(100% + 8px)",
|
|
1029
|
+
left: "50%",
|
|
1030
|
+
transform: "translateX(-50%)",
|
|
1031
|
+
padding: "4px 8px",
|
|
1032
|
+
borderRadius: "4px",
|
|
1033
|
+
backgroundColor: "rgba(0, 0, 0, 0.87)",
|
|
1034
|
+
color: "#fff",
|
|
1035
|
+
fontSize: "12px",
|
|
1036
|
+
whiteSpace: "nowrap"
|
|
1037
|
+
}
|
|
1038
|
+
}, formatDisplayValue(currentValue[1])) : null)) : /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1039
|
+
style: getThumbStyle(percentage, 0)
|
|
947
1040
|
}, valueLabelDisplay === "on" && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
948
1041
|
style: {
|
|
949
1042
|
position: "absolute",
|
|
@@ -957,7 +1050,7 @@ const BaseSlider = /*#__PURE__*/React__default["default"].forwardRef((_ref5, ref
|
|
|
957
1050
|
fontSize: "12px",
|
|
958
1051
|
whiteSpace: "nowrap"
|
|
959
1052
|
}
|
|
960
|
-
},
|
|
1053
|
+
}, formatDisplayValue(currentValue))), renderMarks());
|
|
961
1054
|
});
|
|
962
1055
|
BaseSlider.displayName = "BaseSlider";
|
|
963
1056
|
const Slider = withSx.withSx(BaseSlider);
|
|
@@ -194,8 +194,8 @@ const BaseText = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
194
194
|
if ((colorValue === null || colorValue === void 0 ? void 0 : colorValue.toLowerCase()) === "notblack") return "#FFFFFF";
|
|
195
195
|
if ((colorValue === null || colorValue === void 0 ? void 0 : colorValue.toLowerCase()) === "notblack.main") return "#FFFFFF"; // Hardcode plain white / black detection
|
|
196
196
|
|
|
197
|
-
if (colorValue.toLowerCase() === "white") return "#FFFFFF";
|
|
198
|
-
if (colorValue.toLowerCase() === "black") return "#000000"; // Handle "white.override" or similar
|
|
197
|
+
if ((colorValue === null || colorValue === void 0 ? void 0 : colorValue.toLowerCase()) === "white") return "#FFFFFF";
|
|
198
|
+
if ((colorValue === null || colorValue === void 0 ? void 0 : colorValue.toLowerCase()) === "black") return "#000000"; // Handle "white.override" or similar
|
|
199
199
|
|
|
200
200
|
if (colorValue === "white.override" || colorValue === "whiteOverride") {
|
|
201
201
|
var _colors$whiteOverride;
|
package/dist/esm/Theme.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import React, { useContext, useMemo, createContext } from 'react';
|
|
3
3
|
import icons from './icons.js';
|
|
4
|
-
import colors, {
|
|
4
|
+
import colors, { lightColors, lightPalette, darkColors, darkPalette } from './colors.js';
|
|
5
5
|
import { SnackbarProvider } from './SnackbarContextProvider.js';
|
|
6
6
|
import { ThemeProvider } from './neo-components/ThemeProvider.js';
|
|
7
7
|
import '@babel/runtime/helpers/extends';
|
|
@@ -90,19 +90,6 @@ const mainTheme = {
|
|
|
90
90
|
};
|
|
91
91
|
const fonts = "@font-face {\n font-family: \"Odudo\";\n font-weight: normal;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: lighter;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: 300;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Light.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: 400;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Regular.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: bolder;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: 600;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/Odudo%20V1.3/WEB/odudo-semibold-webfont.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: bold;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.woff\")\n format(\"woff\");\n}\n\n@font-face {\n font-family: \"Odudo\";\n font-weight: 700;\n font-display: swap;\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.eot\");\n src: url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.woff2\")\n format(\"woff2\"),\n url(\"https://cdn.blerp.com/blerp-web-images/fonts/web/Odudo-Bold.woff\")\n format(\"woff\");\n}"; // Try to load MUI dynamically, but don't fail if it's not installed
|
|
92
92
|
|
|
93
|
-
let createTheme = null;
|
|
94
|
-
let MuiThemeProvider = null;
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
const mui = require("@mui/material/styles");
|
|
98
|
-
|
|
99
|
-
createTheme = mui.createTheme;
|
|
100
|
-
MuiThemeProvider = mui.ThemeProvider;
|
|
101
|
-
} catch (e) {// MUI not installed, that's fine
|
|
102
|
-
// console.log("MUI not detected - using lightweight theme mode");
|
|
103
|
-
} // Try to load styled-components, but don't fail if it's not installed
|
|
104
|
-
|
|
105
|
-
|
|
106
93
|
let StyledThemeProvider = null;
|
|
107
94
|
|
|
108
95
|
try {
|
|
@@ -132,7 +119,7 @@ const darkThemeConfig = _objectSpread({
|
|
|
132
119
|
palette: darkPalette
|
|
133
120
|
}, mainTheme); // MUI themes (only created if MUI is available)
|
|
134
121
|
|
|
135
|
-
|
|
122
|
+
({
|
|
136
123
|
typography: {
|
|
137
124
|
fontFamily: "Odudo, Arial"
|
|
138
125
|
},
|
|
@@ -235,84 +222,9 @@ const muiThemeConfig = {
|
|
|
235
222
|
styleOverrides: fonts
|
|
236
223
|
}
|
|
237
224
|
}
|
|
238
|
-
};
|
|
239
|
-
const theme =
|
|
240
|
-
|
|
241
|
-
colors: lightColors,
|
|
242
|
-
icons: icons,
|
|
243
|
-
palette: lightPalette
|
|
244
|
-
})) : lightThemeConfig;
|
|
245
|
-
const darkTheme = createTheme ? createTheme(_objectSpread(_objectSpread({}, muiThemeConfig), {}, {
|
|
246
|
-
components: _objectSpread(_objectSpread({}, muiThemeConfig.components), {}, {
|
|
247
|
-
MuiTypography: {
|
|
248
|
-
styleOverrides: {
|
|
249
|
-
root: {
|
|
250
|
-
color: colors.white
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
MuiFilledInput: {
|
|
255
|
-
styleOverrides: {
|
|
256
|
-
root: {
|
|
257
|
-
color: colors.white,
|
|
258
|
-
backgroundColor: colors.grey7,
|
|
259
|
-
"& textarea": {
|
|
260
|
-
color: colors.white
|
|
261
|
-
},
|
|
262
|
-
":hover": {
|
|
263
|
-
backgroundColor: colors.grey7
|
|
264
|
-
},
|
|
265
|
-
":before": {
|
|
266
|
-
borderColor: colors.waxwing
|
|
267
|
-
},
|
|
268
|
-
":hover:before": {
|
|
269
|
-
borderColor: "".concat(colors.white, " !important")
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
MuiInput: {
|
|
275
|
-
styleOverrides: {
|
|
276
|
-
root: {
|
|
277
|
-
color: colors.white,
|
|
278
|
-
borderColor: colors.white,
|
|
279
|
-
":before": {
|
|
280
|
-
borderColor: colors.waxwing
|
|
281
|
-
},
|
|
282
|
-
":hover:before": {
|
|
283
|
-
borderColor: "".concat(colors.white, " !important")
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
MuiInputLabel: {
|
|
289
|
-
styleOverrides: {
|
|
290
|
-
root: {
|
|
291
|
-
color: colors.white
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
MuiSvgIcon: {
|
|
296
|
-
styleOverrides: {
|
|
297
|
-
root: {
|
|
298
|
-
color: colors.white
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
MuiBackdrop: {
|
|
303
|
-
styleOverrides: {
|
|
304
|
-
root: {
|
|
305
|
-
backgroundColor: "".concat(colors.grey5, "70"),
|
|
306
|
-
backdropFilter: "blur(4px)"
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}),
|
|
311
|
-
mode: "dark",
|
|
312
|
-
colors: darkColors,
|
|
313
|
-
icons: icons,
|
|
314
|
-
palette: darkPalette
|
|
315
|
-
})) : darkThemeConfig; // Create a context for theme access (legacy - for styled-components)
|
|
225
|
+
});
|
|
226
|
+
const theme = lightThemeConfig;
|
|
227
|
+
const darkTheme = darkThemeConfig; // Create a context for theme access (legacy - for styled-components)
|
|
316
228
|
|
|
317
229
|
const BlerpThemeContext = /*#__PURE__*/createContext(null);
|
|
318
230
|
const useBlerpTheme = () => {
|
|
@@ -326,7 +238,7 @@ const useBlerpTheme = () => {
|
|
|
326
238
|
};
|
|
327
239
|
/**
|
|
328
240
|
* BlerpTheme - Main theme provider
|
|
329
|
-
*
|
|
241
|
+
*
|
|
330
242
|
* FIXED: Now accepts and passes through customColors to NewThemeProvider
|
|
331
243
|
* This allows ExtensionTheme and other consumers to override extension colors
|
|
332
244
|
*/
|
|
@@ -353,9 +265,7 @@ const BlerpTheme = _ref => {
|
|
|
353
265
|
theme: themeValue
|
|
354
266
|
}, innerContent) : innerContent; // Wrap with MUI ThemeProvider if available
|
|
355
267
|
|
|
356
|
-
const withMuiTheme =
|
|
357
|
-
theme: currentTheme
|
|
358
|
-
}, withStyledTheme) : withStyledTheme; // CRITICAL FIX: Pass customColors through to NewThemeProvider
|
|
268
|
+
const withMuiTheme = withStyledTheme; // CRITICAL FIX: Pass customColors through to NewThemeProvider
|
|
359
269
|
// This ensures neo-components get the extension color overrides
|
|
360
270
|
|
|
361
271
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
@@ -10,7 +10,7 @@ const _excluded = ["checked", "defaultChecked", "disabled", "onChange", "color",
|
|
|
10
10
|
_excluded2 = ["checked", "defaultChecked", "disabled", "onChange", "color", "size", "name", "value", "inputProps", "style"],
|
|
11
11
|
_excluded3 = ["checked", "defaultChecked", "disabled", "onChange", "color", "size", "name", "value", "inputProps", "style"],
|
|
12
12
|
_excluded4 = ["value", "defaultValue", "onChange", "children", "disabled", "multiple", "native", "variant", "label", "fullWidth", "size", "error", "displayEmpty", "renderValue", "MenuProps", "inputProps", "style", "IconComponent", "disableBorder", "color"],
|
|
13
|
-
_excluded5 = ["value", "defaultValue", "onChange", "onChangeCommitted", "min", "max", "step", "marks", "disabled", "orientation", "color", "size", "valueLabelDisplay", "valueLabelFormat", "getAriaValueText", "track", "style"],
|
|
13
|
+
_excluded5 = ["value", "defaultValue", "onChange", "onChangeCommitted", "min", "max", "step", "marks", "disabled", "orientation", "color", "size", "valueLabelDisplay", "valueLabelFormat", "getAriaValueText", "track", "disableSwap", "style"],
|
|
14
14
|
_excluded6 = ["value", "defaultValue", "onChange", "max", "precision", "disabled", "readOnly", "size", "emptyIcon", "icon", "name", "style"];
|
|
15
15
|
|
|
16
16
|
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; }
|
|
@@ -753,6 +753,7 @@ const BaseSlider = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
753
753
|
valueLabelFormat,
|
|
754
754
|
getAriaValueText,
|
|
755
755
|
track = "normal",
|
|
756
|
+
disableSwap = false,
|
|
756
757
|
style
|
|
757
758
|
} = _ref5,
|
|
758
759
|
props = _objectWithoutProperties(_ref5, _excluded5);
|
|
@@ -760,55 +761,103 @@ const BaseSlider = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
760
761
|
const {
|
|
761
762
|
colors
|
|
762
763
|
} = useTheme();
|
|
764
|
+
const isRange = Array.isArray(value) || Array.isArray(defaultValue);
|
|
763
765
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
764
766
|
const [isDragging, setIsDragging] = useState(false);
|
|
767
|
+
const [activeThumb, setActiveThumb] = useState(-1);
|
|
765
768
|
const sliderRef = useRef(null);
|
|
766
769
|
const currentValue = value !== undefined ? value : internalValue;
|
|
767
770
|
const colorValue = colors[color] || colors.primary;
|
|
768
771
|
const mainColor = typeof colorValue === "object" ? colorValue.main : colorValue;
|
|
769
772
|
const trackThickness = 4;
|
|
770
|
-
const thumbSize = 20;
|
|
771
|
-
const percentage = (currentValue - min) / (max - min) * 100;
|
|
773
|
+
const thumbSize = 20; // Calculate percentages for range or single
|
|
772
774
|
|
|
773
|
-
const
|
|
774
|
-
const clampedValue = Math.min(max, Math.max(min, newValue));
|
|
775
|
-
const steppedValue = Math.round(clampedValue / step) * step;
|
|
775
|
+
const getPercentage = val => (val - min) / (max - min) * 100;
|
|
776
776
|
|
|
777
|
-
|
|
778
|
-
setInternalValue(steppedValue);
|
|
779
|
-
}
|
|
777
|
+
const percentage = isRange ? [getPercentage(currentValue[0]), getPercentage(currentValue[1])] : getPercentage(currentValue);
|
|
780
778
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
779
|
+
const handleChange = (newValue, thumbIndex) => {
|
|
780
|
+
if (isRange) {
|
|
781
|
+
const clampedValue = Math.min(max, Math.max(min, newValue));
|
|
782
|
+
const steppedValue = Math.round(clampedValue / step) * step;
|
|
783
|
+
let newRange = [...currentValue];
|
|
784
|
+
newRange[thumbIndex] = steppedValue; // Handle swap prevention
|
|
785
|
+
|
|
786
|
+
if (disableSwap) {
|
|
787
|
+
if (thumbIndex === 0 && steppedValue > currentValue[1]) {
|
|
788
|
+
newRange[0] = currentValue[1];
|
|
789
|
+
} else if (thumbIndex === 1 && steppedValue < currentValue[0]) {
|
|
790
|
+
newRange[1] = currentValue[0];
|
|
791
|
+
}
|
|
792
|
+
} else {
|
|
793
|
+
// Auto-swap if needed
|
|
794
|
+
if (newRange[0] > newRange[1]) {
|
|
795
|
+
newRange = [newRange[1], newRange[0]];
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (value === undefined) {
|
|
800
|
+
setInternalValue(newRange);
|
|
784
801
|
}
|
|
785
|
-
|
|
802
|
+
|
|
803
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
804
|
+
target: {
|
|
805
|
+
value: newRange
|
|
806
|
+
}
|
|
807
|
+
}, newRange, thumbIndex);
|
|
808
|
+
} else {
|
|
809
|
+
const clampedValue = Math.min(max, Math.max(min, newValue));
|
|
810
|
+
const steppedValue = Math.round(clampedValue / step) * step;
|
|
811
|
+
|
|
812
|
+
if (value === undefined) {
|
|
813
|
+
setInternalValue(steppedValue);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
817
|
+
target: {
|
|
818
|
+
value: steppedValue
|
|
819
|
+
}
|
|
820
|
+
}, steppedValue);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
const getClosestThumb = clientX => {
|
|
825
|
+
if (!sliderRef.current || !isRange) return 0;
|
|
826
|
+
const rect = sliderRef.current.getBoundingClientRect();
|
|
827
|
+
const percent = (clientX - rect.left) / rect.width;
|
|
828
|
+
const clickValue = min + percent * (max - min);
|
|
829
|
+
const dist0 = Math.abs(currentValue[0] - clickValue);
|
|
830
|
+
const dist1 = Math.abs(currentValue[1] - clickValue);
|
|
831
|
+
return dist0 <= dist1 ? 0 : 1;
|
|
786
832
|
};
|
|
787
833
|
|
|
788
|
-
const updateValue = e => {
|
|
834
|
+
const updateValue = (e, thumbIdx) => {
|
|
789
835
|
if (!sliderRef.current) return;
|
|
790
836
|
const rect = sliderRef.current.getBoundingClientRect();
|
|
791
837
|
const percent = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
792
838
|
const newValue = min + percent * (max - min);
|
|
793
|
-
handleChange(newValue);
|
|
839
|
+
handleChange(newValue, thumbIdx);
|
|
794
840
|
};
|
|
795
841
|
|
|
796
842
|
const handleMouseDown = e => {
|
|
797
843
|
if (disabled) return;
|
|
798
844
|
e.preventDefault();
|
|
845
|
+
const thumbIdx = isRange ? getClosestThumb(e.clientX) : 0;
|
|
846
|
+
setActiveThumb(thumbIdx);
|
|
799
847
|
setIsDragging(true);
|
|
800
|
-
updateValue(e);
|
|
848
|
+
updateValue(e, thumbIdx);
|
|
801
849
|
};
|
|
802
850
|
|
|
803
851
|
useEffect(() => {
|
|
804
852
|
if (!isDragging) return;
|
|
805
853
|
|
|
806
854
|
const handleMouseMove = e => {
|
|
807
|
-
updateValue(e);
|
|
855
|
+
updateValue(e, activeThumb);
|
|
808
856
|
};
|
|
809
857
|
|
|
810
858
|
const handleMouseUp = () => {
|
|
811
859
|
setIsDragging(false);
|
|
860
|
+
setActiveThumb(-1);
|
|
812
861
|
onChangeCommitted === null || onChangeCommitted === void 0 ? void 0 : onChangeCommitted({
|
|
813
862
|
target: {
|
|
814
863
|
value: currentValue
|
|
@@ -822,7 +871,7 @@ const BaseSlider = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
822
871
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
823
872
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
824
873
|
};
|
|
825
|
-
}, [isDragging, currentValue, min, max, step]);
|
|
874
|
+
}, [isDragging, activeThumb, currentValue, min, max, step]);
|
|
826
875
|
|
|
827
876
|
const containerStyle = _objectSpread(_objectSpread({
|
|
828
877
|
position: "relative",
|
|
@@ -844,7 +893,17 @@ const BaseSlider = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
844
893
|
borderRadius: "".concat(trackThickness / 2, "px"),
|
|
845
894
|
backgroundColor: "rgba(255, 255, 255, 0.3)"
|
|
846
895
|
};
|
|
847
|
-
const trackStyle = {
|
|
896
|
+
const trackStyle = isRange ? {
|
|
897
|
+
position: "absolute",
|
|
898
|
+
left: "".concat(percentage[0], "%"),
|
|
899
|
+
width: "".concat(percentage[1] - percentage[0], "%"),
|
|
900
|
+
height: "".concat(trackThickness, "px"),
|
|
901
|
+
top: "50%",
|
|
902
|
+
transform: "translateY(-50%)",
|
|
903
|
+
borderRadius: "".concat(trackThickness / 2, "px"),
|
|
904
|
+
backgroundColor: mainColor,
|
|
905
|
+
transition: isDragging ? "none" : "left 150ms, width 150ms"
|
|
906
|
+
} : {
|
|
848
907
|
position: "absolute",
|
|
849
908
|
width: "".concat(percentage, "%"),
|
|
850
909
|
height: "".concat(trackThickness, "px"),
|
|
@@ -855,22 +914,22 @@ const BaseSlider = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
855
914
|
transition: isDragging ? "none" : "width 150ms"
|
|
856
915
|
};
|
|
857
916
|
|
|
858
|
-
const
|
|
917
|
+
const getThumbStyle = (pct, idx) => _objectSpread({
|
|
859
918
|
position: "absolute",
|
|
860
919
|
width: "".concat(thumbSize, "px"),
|
|
861
920
|
height: "".concat(thumbSize, "px"),
|
|
862
921
|
borderRadius: "50%",
|
|
863
922
|
backgroundColor: mainColor,
|
|
864
923
|
boxShadow: "0px 2px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 3px 0px rgba(0,0,0,0.12)",
|
|
865
|
-
left: "calc(".concat(
|
|
924
|
+
left: "calc(".concat(pct, "% - ").concat(thumbSize / 2, "px)"),
|
|
866
925
|
top: "50%",
|
|
867
926
|
transform: "translateY(-50%)",
|
|
868
|
-
transition: isDragging ? "none" : "left 150ms",
|
|
869
|
-
cursor: "grab"
|
|
870
|
-
|
|
927
|
+
transition: isDragging && activeThumb === idx ? "none" : "left 150ms",
|
|
928
|
+
cursor: "grab",
|
|
929
|
+
zIndex: activeThumb === idx ? 2 : 1
|
|
930
|
+
}, isDragging && activeThumb === idx && {
|
|
871
931
|
cursor: "grabbing"
|
|
872
|
-
});
|
|
873
|
-
|
|
932
|
+
});
|
|
874
933
|
|
|
875
934
|
const renderMarks = () => {
|
|
876
935
|
if (!marks) return null;
|
|
@@ -908,7 +967,12 @@ const BaseSlider = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
908
967
|
});
|
|
909
968
|
};
|
|
910
969
|
|
|
911
|
-
const
|
|
970
|
+
const formatDisplayValue = val => {
|
|
971
|
+
if (valueLabelFormat) return valueLabelFormat(val);
|
|
972
|
+
if (getAriaValueText) return getAriaValueText(val);
|
|
973
|
+
return val;
|
|
974
|
+
};
|
|
975
|
+
|
|
912
976
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
913
977
|
ref: node => {
|
|
914
978
|
sliderRef.current = node;
|
|
@@ -924,15 +988,44 @@ const BaseSlider = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
924
988
|
role: "slider",
|
|
925
989
|
"aria-valuemin": min,
|
|
926
990
|
"aria-valuemax": max,
|
|
927
|
-
"aria-valuenow": currentValue,
|
|
928
|
-
"aria-valuetext": getAriaValueText === null || getAriaValueText === void 0 ? void 0 : getAriaValueText(currentValue),
|
|
991
|
+
"aria-valuenow": isRange ? currentValue[0] : currentValue,
|
|
929
992
|
tabIndex: disabled ? -1 : 0
|
|
930
993
|
}, props), /*#__PURE__*/React.createElement("span", {
|
|
931
994
|
style: railStyle
|
|
932
995
|
}), track !== false && /*#__PURE__*/React.createElement("span", {
|
|
933
996
|
style: trackStyle
|
|
934
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
935
|
-
style:
|
|
997
|
+
}), isRange ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
998
|
+
style: getThumbStyle(percentage[0], 0)
|
|
999
|
+
}, valueLabelDisplay === "on" || valueLabelDisplay === "auto" && isDragging && activeThumb === 0 ? /*#__PURE__*/React.createElement("span", {
|
|
1000
|
+
style: {
|
|
1001
|
+
position: "absolute",
|
|
1002
|
+
bottom: "calc(100% + 8px)",
|
|
1003
|
+
left: "50%",
|
|
1004
|
+
transform: "translateX(-50%)",
|
|
1005
|
+
padding: "4px 8px",
|
|
1006
|
+
borderRadius: "4px",
|
|
1007
|
+
backgroundColor: "rgba(0, 0, 0, 0.87)",
|
|
1008
|
+
color: "#fff",
|
|
1009
|
+
fontSize: "12px",
|
|
1010
|
+
whiteSpace: "nowrap"
|
|
1011
|
+
}
|
|
1012
|
+
}, formatDisplayValue(currentValue[0])) : null), /*#__PURE__*/React.createElement("span", {
|
|
1013
|
+
style: getThumbStyle(percentage[1], 1)
|
|
1014
|
+
}, valueLabelDisplay === "on" || valueLabelDisplay === "auto" && isDragging && activeThumb === 1 ? /*#__PURE__*/React.createElement("span", {
|
|
1015
|
+
style: {
|
|
1016
|
+
position: "absolute",
|
|
1017
|
+
bottom: "calc(100% + 8px)",
|
|
1018
|
+
left: "50%",
|
|
1019
|
+
transform: "translateX(-50%)",
|
|
1020
|
+
padding: "4px 8px",
|
|
1021
|
+
borderRadius: "4px",
|
|
1022
|
+
backgroundColor: "rgba(0, 0, 0, 0.87)",
|
|
1023
|
+
color: "#fff",
|
|
1024
|
+
fontSize: "12px",
|
|
1025
|
+
whiteSpace: "nowrap"
|
|
1026
|
+
}
|
|
1027
|
+
}, formatDisplayValue(currentValue[1])) : null)) : /*#__PURE__*/React.createElement("span", {
|
|
1028
|
+
style: getThumbStyle(percentage, 0)
|
|
936
1029
|
}, valueLabelDisplay === "on" && /*#__PURE__*/React.createElement("span", {
|
|
937
1030
|
style: {
|
|
938
1031
|
position: "absolute",
|
|
@@ -946,7 +1039,7 @@ const BaseSlider = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
946
1039
|
fontSize: "12px",
|
|
947
1040
|
whiteSpace: "nowrap"
|
|
948
1041
|
}
|
|
949
|
-
},
|
|
1042
|
+
}, formatDisplayValue(currentValue))), renderMarks());
|
|
950
1043
|
});
|
|
951
1044
|
BaseSlider.displayName = "BaseSlider";
|
|
952
1045
|
const Slider = withSx(BaseSlider);
|
|
@@ -183,8 +183,8 @@ const BaseText = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
183
183
|
if ((colorValue === null || colorValue === void 0 ? void 0 : colorValue.toLowerCase()) === "notblack") return "#FFFFFF";
|
|
184
184
|
if ((colorValue === null || colorValue === void 0 ? void 0 : colorValue.toLowerCase()) === "notblack.main") return "#FFFFFF"; // Hardcode plain white / black detection
|
|
185
185
|
|
|
186
|
-
if (colorValue.toLowerCase() === "white") return "#FFFFFF";
|
|
187
|
-
if (colorValue.toLowerCase() === "black") return "#000000"; // Handle "white.override" or similar
|
|
186
|
+
if ((colorValue === null || colorValue === void 0 ? void 0 : colorValue.toLowerCase()) === "white") return "#FFFFFF";
|
|
187
|
+
if ((colorValue === null || colorValue === void 0 ? void 0 : colorValue.toLowerCase()) === "black") return "#000000"; // Handle "white.override" or similar
|
|
188
188
|
|
|
189
189
|
if (colorValue === "white.override" || colorValue === "whiteOverride") {
|
|
190
190
|
var _colors$whiteOverride;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blerp/design",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"description": "Blerp UI",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"watch": "rollup -c -w"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@mui/material": "5.10.16",
|
|
12
11
|
"react": "18.2.0",
|
|
13
12
|
"react-dom": "18.2.0",
|
|
14
13
|
"styled-components": "^5.0.0 || ^6.0.0"
|
|
@@ -38,8 +37,6 @@
|
|
|
38
37
|
"@babel/plugin-transform-runtime": "^7.23.9",
|
|
39
38
|
"@babel/preset-env": "^7.12.11",
|
|
40
39
|
"@babel/preset-react": "^7.12.10",
|
|
41
|
-
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest",
|
|
42
|
-
"@mui/styled-engine-sc": "5.10.16",
|
|
43
40
|
"@rollup/plugin-babel": "^5.2.2",
|
|
44
41
|
"@rollup/plugin-json": "^4.1.0",
|
|
45
42
|
"@rollup/plugin-node-resolve": "^16.0.3",
|