@wistia/ui 0.13.4-beta.0a5560fe.25f646e → 0.13.4-beta.15e04cfa.4eadefb
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/index.cjs +162 -264
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -10
- package/dist/index.d.ts +1 -10
- package/dist/index.mjs +198 -308
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.13.4-beta.
|
|
3
|
+
* @license @wistia/ui v0.13.4-beta.15e04cfa.4eadefb
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -9649,30 +9649,39 @@ var CollapsibleContent = ({ clamp, children }) => {
|
|
|
9649
9649
|
|
|
9650
9650
|
// src/components/ColorPicker/color-conversion-utils.ts
|
|
9651
9651
|
var import_fn = require("culori/fn");
|
|
9652
|
-
(0, import_fn.useMode)(import_fn.modeRgb);
|
|
9653
|
-
(0, import_fn.useMode)(import_fn.modeHsv);
|
|
9652
|
+
var convertToRgbRaw = (0, import_fn.useMode)(import_fn.modeRgb);
|
|
9653
|
+
var convertToHsvRaw = (0, import_fn.useMode)(import_fn.modeHsv);
|
|
9654
|
+
(0, import_fn.useMode)(import_fn.modeLrgb);
|
|
9654
9655
|
var convertToHsv = (color) => {
|
|
9655
|
-
|
|
9656
|
-
if (
|
|
9657
|
-
|
|
9656
|
+
let result;
|
|
9657
|
+
if (typeof color === "string") {
|
|
9658
|
+
const rgb = (0, import_fn.parseHex)(color);
|
|
9659
|
+
if (rgb == null) {
|
|
9660
|
+
throw new Error(`Invalid hex color value: ${color}`);
|
|
9661
|
+
}
|
|
9662
|
+
result = convertToHsvRaw(rgb);
|
|
9663
|
+
}
|
|
9664
|
+
result = convertToHsvRaw(color);
|
|
9665
|
+
if (result == null) {
|
|
9666
|
+
throw new Error(`Invalid color value: ${JSON.stringify(color)}`);
|
|
9658
9667
|
}
|
|
9659
|
-
return
|
|
9668
|
+
return result;
|
|
9660
9669
|
};
|
|
9661
|
-
var
|
|
9670
|
+
var convertToRgb = (color) => {
|
|
9662
9671
|
let result;
|
|
9663
9672
|
if (typeof color === "string") {
|
|
9664
9673
|
const rgb = (0, import_fn.parseHex)(color);
|
|
9665
9674
|
if (rgb == null) {
|
|
9666
9675
|
throw new Error(`Invalid hex color value: ${color}`);
|
|
9667
9676
|
}
|
|
9668
|
-
result = (
|
|
9669
|
-
}
|
|
9670
|
-
|
|
9671
|
-
|
|
9677
|
+
result = convertToRgbRaw(color);
|
|
9678
|
+
}
|
|
9679
|
+
result = convertToRgbRaw(color);
|
|
9680
|
+
if (result == null) {
|
|
9681
|
+
throw new Error(`Invalid color value: ${JSON.stringify(color)}`);
|
|
9672
9682
|
}
|
|
9673
9683
|
return result;
|
|
9674
9684
|
};
|
|
9675
|
-
var convertToRgb = (hsv) => (0, import_fn.convertHsvToRgb)(hsv);
|
|
9676
9685
|
|
|
9677
9686
|
// src/components/ColorPicker/ColorGrid.tsx
|
|
9678
9687
|
var import_react42 = require("react");
|
|
@@ -9763,7 +9772,7 @@ var updateSearchBounds = (searchingBrighter, contrast, minContrast, midValue, se
|
|
|
9763
9772
|
};
|
|
9764
9773
|
var getAccessibleColorByValueChannelChange = ({
|
|
9765
9774
|
originalHsv,
|
|
9766
|
-
|
|
9775
|
+
colorForComparison,
|
|
9767
9776
|
minContrast,
|
|
9768
9777
|
maxIterations = 50,
|
|
9769
9778
|
direction
|
|
@@ -9778,8 +9787,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9778
9787
|
v: extremeValue,
|
|
9779
9788
|
mode: "hsv"
|
|
9780
9789
|
};
|
|
9781
|
-
const
|
|
9782
|
-
const extremeContrast = (0, import_fn3.wcagContrast)(extremeVariantAsLrgb, colorForComparisonAsLrgb);
|
|
9790
|
+
const extremeContrast = (0, import_fn3.wcagContrast)(extremeVariant, colorForComparison);
|
|
9783
9791
|
if (extremeContrast < minContrast) {
|
|
9784
9792
|
return null;
|
|
9785
9793
|
}
|
|
@@ -9795,7 +9803,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9795
9803
|
v: midValue,
|
|
9796
9804
|
mode: "hsv"
|
|
9797
9805
|
};
|
|
9798
|
-
const contrast = (0, import_fn3.wcagContrast)(
|
|
9806
|
+
const contrast = (0, import_fn3.wcagContrast)(candidateHsv, colorForComparison);
|
|
9799
9807
|
if (contrast >= minContrast) {
|
|
9800
9808
|
bestSoFar = candidateHsv;
|
|
9801
9809
|
}
|
|
@@ -9838,7 +9846,7 @@ var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalH
|
|
|
9838
9846
|
};
|
|
9839
9847
|
var getAccessibleColorBySaturationAndValueChange = ({
|
|
9840
9848
|
originalHsv,
|
|
9841
|
-
|
|
9849
|
+
colorForComparison,
|
|
9842
9850
|
minContrast,
|
|
9843
9851
|
direction
|
|
9844
9852
|
}) => {
|
|
@@ -9867,7 +9875,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9867
9875
|
};
|
|
9868
9876
|
};
|
|
9869
9877
|
const checkContrast = (hsv) => {
|
|
9870
|
-
return (0, import_fn3.wcagContrast)(
|
|
9878
|
+
return (0, import_fn3.wcagContrast)(hsv, colorForComparison);
|
|
9871
9879
|
};
|
|
9872
9880
|
const extremeHsv = getHsvForStep(highStep);
|
|
9873
9881
|
if (checkContrast(extremeHsv) < minContrast) {
|
|
@@ -9897,14 +9905,14 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9897
9905
|
};
|
|
9898
9906
|
var getAccessibleColorInDirection = ({
|
|
9899
9907
|
originalHsv,
|
|
9900
|
-
|
|
9908
|
+
colorForComparison,
|
|
9901
9909
|
minContrast,
|
|
9902
9910
|
maxIterations = 50,
|
|
9903
9911
|
direction
|
|
9904
9912
|
}) => {
|
|
9905
9913
|
const valueResult = getAccessibleColorByValueChannelChange({
|
|
9906
9914
|
originalHsv,
|
|
9907
|
-
|
|
9915
|
+
colorForComparison,
|
|
9908
9916
|
minContrast,
|
|
9909
9917
|
maxIterations,
|
|
9910
9918
|
direction
|
|
@@ -9914,31 +9922,31 @@ var getAccessibleColorInDirection = ({
|
|
|
9914
9922
|
}
|
|
9915
9923
|
return getAccessibleColorBySaturationAndValueChange({
|
|
9916
9924
|
originalHsv,
|
|
9917
|
-
|
|
9925
|
+
colorForComparison,
|
|
9918
9926
|
minContrast,
|
|
9919
9927
|
direction
|
|
9920
9928
|
});
|
|
9921
9929
|
};
|
|
9922
9930
|
var getAccessibleColor = ({
|
|
9923
9931
|
originalHsv,
|
|
9924
|
-
|
|
9932
|
+
colorForComparison,
|
|
9925
9933
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9926
9934
|
maxIterations = 50
|
|
9927
9935
|
}) => {
|
|
9928
|
-
const originalContrast = (0, import_fn3.wcagContrast)(
|
|
9936
|
+
const originalContrast = (0, import_fn3.wcagContrast)(originalHsv, colorForComparison);
|
|
9929
9937
|
if (originalContrast >= minContrast) {
|
|
9930
9938
|
return originalHsv;
|
|
9931
9939
|
}
|
|
9932
9940
|
const brighterOption = getAccessibleColorInDirection({
|
|
9933
9941
|
originalHsv,
|
|
9934
|
-
|
|
9942
|
+
colorForComparison,
|
|
9935
9943
|
minContrast,
|
|
9936
9944
|
maxIterations,
|
|
9937
9945
|
direction: "brighter"
|
|
9938
9946
|
});
|
|
9939
9947
|
const darkerOption = getAccessibleColorInDirection({
|
|
9940
9948
|
originalHsv,
|
|
9941
|
-
|
|
9949
|
+
colorForComparison,
|
|
9942
9950
|
minContrast,
|
|
9943
9951
|
maxIterations,
|
|
9944
9952
|
direction: "darker"
|
|
@@ -9953,22 +9961,22 @@ var getAccessibleColor = ({
|
|
|
9953
9961
|
};
|
|
9954
9962
|
var hasAccessibleDerivatives = ({
|
|
9955
9963
|
originalHsv,
|
|
9956
|
-
|
|
9964
|
+
colorForComparison,
|
|
9957
9965
|
minContrast = DEFAULT_MIN_CONTRAST
|
|
9958
9966
|
}) => {
|
|
9959
|
-
const originalContrast = (0, import_fn3.wcagContrast)(
|
|
9967
|
+
const originalContrast = (0, import_fn3.wcagContrast)(originalHsv, colorForComparison);
|
|
9960
9968
|
if (originalContrast >= minContrast) {
|
|
9961
9969
|
return true;
|
|
9962
9970
|
}
|
|
9963
9971
|
const brighterOption = getAccessibleColorInDirection({
|
|
9964
9972
|
originalHsv,
|
|
9965
|
-
|
|
9973
|
+
colorForComparison,
|
|
9966
9974
|
minContrast,
|
|
9967
9975
|
direction: "brighter"
|
|
9968
9976
|
});
|
|
9969
9977
|
const darkerOption = getAccessibleColorInDirection({
|
|
9970
9978
|
originalHsv,
|
|
9971
|
-
|
|
9979
|
+
colorForComparison,
|
|
9972
9980
|
minContrast,
|
|
9973
9981
|
direction: "darker"
|
|
9974
9982
|
});
|
|
@@ -9977,190 +9985,100 @@ var hasAccessibleDerivatives = ({
|
|
|
9977
9985
|
|
|
9978
9986
|
// src/components/ColorPicker/ColorPickerContext.tsx
|
|
9979
9987
|
var import_jsx_runtime225 = require("react/jsx-runtime");
|
|
9980
|
-
var createInitialState = ({
|
|
9981
|
-
valueAsHex,
|
|
9982
|
-
shouldEnforceMinContrast,
|
|
9983
|
-
colorForComparisonAsHex,
|
|
9984
|
-
minimumContrastRatio
|
|
9985
|
-
}) => {
|
|
9986
|
-
const valueAsHsv = convertToHsv(valueAsHex);
|
|
9987
|
-
const colorForComparisonAsLrgb = convertToLrgb(colorForComparisonAsHex);
|
|
9988
|
-
return {
|
|
9989
|
-
nonDerivedValueAsHsv: valueAsHsv,
|
|
9990
|
-
nonDerivedValueAsHex: valueAsHex,
|
|
9991
|
-
valueAsHsv,
|
|
9992
|
-
shouldEnforceMinContrast,
|
|
9993
|
-
colorForComparisonAsLrgb,
|
|
9994
|
-
minimumContrastRatio,
|
|
9995
|
-
isTransitioning: false
|
|
9996
|
-
};
|
|
9997
|
-
};
|
|
9998
|
-
var colorPickerReducer = (state, action) => {
|
|
9999
|
-
switch (action.type) {
|
|
10000
|
-
case "SET_VALUE_AS_HSV":
|
|
10001
|
-
const result = {
|
|
10002
|
-
...state,
|
|
10003
|
-
...action.payload
|
|
10004
|
-
};
|
|
10005
|
-
if (action.payload.nonDerivedValueAsHsv != null) {
|
|
10006
|
-
result.nonDerivedValueAsHex = (0, import_fn4.formatHex)(action.payload.nonDerivedValueAsHsv);
|
|
10007
|
-
}
|
|
10008
|
-
return result;
|
|
10009
|
-
case "SET_SHOULD_ENFORCE_MIN_CONTRAST":
|
|
10010
|
-
return {
|
|
10011
|
-
...state,
|
|
10012
|
-
shouldEnforceMinContrast: action.payload
|
|
10013
|
-
};
|
|
10014
|
-
case "SET_MINIMUM_CONTRAST_RATIO":
|
|
10015
|
-
return {
|
|
10016
|
-
...state,
|
|
10017
|
-
minimumContrastRatio: action.payload,
|
|
10018
|
-
valueAsHsv: state.shouldEnforceMinContrast ? getAccessibleColor({
|
|
10019
|
-
originalHsv: state.valueAsHsv,
|
|
10020
|
-
colorForComparisonAsLrgb: state.colorForComparisonAsLrgb,
|
|
10021
|
-
minContrast: action.payload
|
|
10022
|
-
}) : state.valueAsHsv
|
|
10023
|
-
};
|
|
10024
|
-
case "SET_COLOR_FOR_COMPARISON":
|
|
10025
|
-
return {
|
|
10026
|
-
...state,
|
|
10027
|
-
colorForComparisonAsLrgb: action.payload,
|
|
10028
|
-
valueAsHsv: state.shouldEnforceMinContrast ? getAccessibleColor({
|
|
10029
|
-
originalHsv: state.valueAsHsv,
|
|
10030
|
-
colorForComparisonAsLrgb: action.payload,
|
|
10031
|
-
minContrast: state.minimumContrastRatio
|
|
10032
|
-
}) : state.valueAsHsv
|
|
10033
|
-
};
|
|
10034
|
-
case "SET_IS_TRANSITIONING":
|
|
10035
|
-
return {
|
|
10036
|
-
...state,
|
|
10037
|
-
isTransitioning: action.payload
|
|
10038
|
-
};
|
|
10039
|
-
default:
|
|
10040
|
-
return state;
|
|
10041
|
-
}
|
|
10042
|
-
};
|
|
10043
9988
|
var ColorPickerContext = (0, import_react41.createContext)(null);
|
|
10044
9989
|
var ColorPickerProvider = ({
|
|
10045
9990
|
children,
|
|
10046
9991
|
value: valueAsHex,
|
|
10047
9992
|
onValueChange,
|
|
10048
|
-
shouldEnforceMinContrast = false,
|
|
10049
9993
|
minimumContrastRatio = DEFAULT_MIN_CONTRAST,
|
|
10050
|
-
colorForComparison
|
|
9994
|
+
colorForComparison = DEFAULT_COLOR_FOR_COMPARISON
|
|
10051
9995
|
}) => {
|
|
10052
|
-
const [
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
valueAsHex,
|
|
10056
|
-
shouldEnforceMinContrast,
|
|
10057
|
-
colorForComparisonAsHex,
|
|
10058
|
-
minimumContrastRatio
|
|
10059
|
-
})
|
|
10060
|
-
);
|
|
10061
|
-
const valueAsLrgb = (0, import_react41.useMemo)(() => convertToLrgb(state.valueAsHsv), [state.valueAsHsv]);
|
|
10062
|
-
const colorForComparisonAsLrgb = (0, import_react41.useMemo)(
|
|
10063
|
-
() => convertToLrgb(colorForComparisonAsHex),
|
|
10064
|
-
[colorForComparisonAsHex]
|
|
10065
|
-
);
|
|
10066
|
-
const currentContrastRatio = (0, import_react41.useMemo)(() => {
|
|
10067
|
-
return (0, import_fn4.wcagContrast)(valueAsLrgb, colorForComparisonAsLrgb);
|
|
10068
|
-
}, [valueAsLrgb, colorForComparisonAsLrgb]);
|
|
10069
|
-
const hasAccessibleDerivativesValue = (0, import_react41.useMemo)(() => {
|
|
10070
|
-
return hasAccessibleDerivatives({
|
|
10071
|
-
originalHsv: state.valueAsHsv,
|
|
10072
|
-
colorForComparisonAsLrgb,
|
|
10073
|
-
minContrast: minimumContrastRatio
|
|
10074
|
-
});
|
|
10075
|
-
}, [state.valueAsHsv, colorForComparisonAsLrgb, minimumContrastRatio]);
|
|
9996
|
+
const [isTransitioning, setIsTransitioning] = (0, import_react41.useState)(false);
|
|
9997
|
+
const [nonDerivedValueAsHsv, setNonDerivedValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
|
|
9998
|
+
const [shouldEnforceMinContrast, setShouldEnforceMinContrast] = (0, import_react41.useState)(false);
|
|
10076
9999
|
const getAccessibleDerivativeColor = (0, import_react41.useCallback)(
|
|
10077
10000
|
(originalHsv) => getAccessibleColor({
|
|
10078
10001
|
originalHsv,
|
|
10079
|
-
|
|
10002
|
+
colorForComparison,
|
|
10080
10003
|
minContrast: minimumContrastRatio
|
|
10081
10004
|
}),
|
|
10082
|
-
[minimumContrastRatio,
|
|
10083
|
-
);
|
|
10084
|
-
const onValueAsHsvChange = (0, import_react41.useCallback)(
|
|
10085
|
-
(rawNewValueAsHsv) => {
|
|
10086
|
-
const hsvToSet = state.shouldEnforceMinContrast ? getAccessibleDerivativeColor(rawNewValueAsHsv) : rawNewValueAsHsv;
|
|
10087
|
-
const hexToSet = (0, import_fn4.formatHex)(hsvToSet);
|
|
10088
|
-
onValueChange(hexToSet);
|
|
10089
|
-
dispatch({
|
|
10090
|
-
type: "SET_VALUE_AS_HSV",
|
|
10091
|
-
payload: { valueAsHsv: hsvToSet, nonDerivedValueAsHsv: rawNewValueAsHsv }
|
|
10092
|
-
});
|
|
10093
|
-
},
|
|
10094
|
-
[getAccessibleDerivativeColor, state.shouldEnforceMinContrast, onValueChange]
|
|
10005
|
+
[minimumContrastRatio, colorForComparison]
|
|
10095
10006
|
);
|
|
10007
|
+
const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValueAsHsv) : nonDerivedValueAsHsv;
|
|
10008
|
+
const currentContrastRatio = (0, import_fn4.wcagContrast)(valueAsHsv, colorForComparison);
|
|
10009
|
+
const hasAccessibleDerivativesValue = (0, import_react41.useMemo)(() => {
|
|
10010
|
+
return hasAccessibleDerivatives({
|
|
10011
|
+
originalHsv: valueAsHsv,
|
|
10012
|
+
colorForComparison,
|
|
10013
|
+
minContrast: minimumContrastRatio
|
|
10014
|
+
});
|
|
10015
|
+
}, [valueAsHsv, colorForComparison, minimumContrastRatio]);
|
|
10016
|
+
const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)((nonDerivedValue) => {
|
|
10017
|
+
setNonDerivedValueAsHsv(nonDerivedValue);
|
|
10018
|
+
}, []);
|
|
10096
10019
|
const changeValueSmoothly = (0, import_react41.useCallback)(
|
|
10097
10020
|
(toHsv) => {
|
|
10098
|
-
|
|
10021
|
+
setIsTransitioning(true);
|
|
10099
10022
|
transitionBetweenColors(
|
|
10100
|
-
|
|
10023
|
+
valueAsHsv,
|
|
10101
10024
|
toHsv,
|
|
10102
10025
|
(colorForStepAsHsv) => {
|
|
10103
10026
|
const hexValue = (0, import_fn4.formatHex)(colorForStepAsHsv);
|
|
10104
10027
|
onValueChange(hexValue);
|
|
10105
|
-
dispatch({ type: "SET_VALUE_AS_HSV", payload: { valueAsHsv: colorForStepAsHsv } });
|
|
10106
10028
|
},
|
|
10107
10029
|
() => {
|
|
10108
|
-
|
|
10030
|
+
setIsTransitioning(false);
|
|
10109
10031
|
}
|
|
10110
10032
|
);
|
|
10111
10033
|
},
|
|
10112
|
-
[
|
|
10034
|
+
[valueAsHsv, onValueChange]
|
|
10113
10035
|
);
|
|
10114
|
-
const
|
|
10036
|
+
const setShouldEnforceMinContrastWrapped = (0, import_react41.useCallback)(
|
|
10115
10037
|
(newShouldEnforceMinContrast) => {
|
|
10116
|
-
|
|
10117
|
-
const newColorAsHsv = newShouldEnforceMinContrast ? getAccessibleDerivativeColor(
|
|
10118
|
-
const currentHsv =
|
|
10038
|
+
setShouldEnforceMinContrast(newShouldEnforceMinContrast);
|
|
10039
|
+
const newColorAsHsv = newShouldEnforceMinContrast ? getAccessibleDerivativeColor(valueAsHsv) : nonDerivedValueAsHsv;
|
|
10040
|
+
const currentHsv = valueAsHsv;
|
|
10119
10041
|
if (currentHsv.h !== newColorAsHsv.h || currentHsv.s !== newColorAsHsv.s || currentHsv.v !== newColorAsHsv.v) {
|
|
10120
10042
|
changeValueSmoothly(newColorAsHsv);
|
|
10121
10043
|
}
|
|
10122
10044
|
},
|
|
10123
|
-
[
|
|
10124
|
-
changeValueSmoothly,
|
|
10125
|
-
getAccessibleDerivativeColor,
|
|
10126
|
-
state.nonDerivedValueAsHsv,
|
|
10127
|
-
state.valueAsHsv
|
|
10128
|
-
]
|
|
10045
|
+
[changeValueSmoothly, getAccessibleDerivativeColor, nonDerivedValueAsHsv, valueAsHsv]
|
|
10129
10046
|
);
|
|
10047
|
+
const whatValuePropShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(getAccessibleDerivativeColor(nonDerivedValueAsHsv)) : (0, import_fn4.formatHex)(nonDerivedValueAsHsv);
|
|
10130
10048
|
(0, import_react41.useEffect)(() => {
|
|
10131
|
-
if (valueAsHex
|
|
10132
|
-
|
|
10049
|
+
if (valueAsHex !== whatValuePropShouldBe && !isTransitioning) {
|
|
10050
|
+
onValueChange(whatValuePropShouldBe);
|
|
10133
10051
|
}
|
|
10134
|
-
|
|
10135
|
-
dispatch({
|
|
10136
|
-
type: "SET_VALUE_AS_HSV",
|
|
10137
|
-
payload: { valueAsHsv: newValueAsHsv }
|
|
10138
|
-
});
|
|
10139
|
-
}, [getAccessibleDerivativeColor, state.valueAsHsv, valueAsHex]);
|
|
10052
|
+
}, [valueAsHex, whatValuePropShouldBe, isTransitioning, onValueChange]);
|
|
10140
10053
|
const contextValue = (0, import_react41.useMemo)(
|
|
10141
10054
|
() => ({
|
|
10142
|
-
|
|
10143
|
-
valueAsLrgb,
|
|
10055
|
+
colorForComparison,
|
|
10144
10056
|
currentContrastRatio,
|
|
10057
|
+
getAccessibleDerivativeColor,
|
|
10145
10058
|
hasAccessibleDerivatives: hasAccessibleDerivativesValue,
|
|
10146
|
-
|
|
10147
|
-
colorForComparisonAsHex,
|
|
10059
|
+
isTransitioning,
|
|
10148
10060
|
minimumContrastRatio,
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10061
|
+
nonDerivedValueAsHex: (0, import_fn4.formatHex)(nonDerivedValueAsHsv),
|
|
10062
|
+
nonDerivedValueAsHsv,
|
|
10063
|
+
onChangeNonDerivedValueAsHsv,
|
|
10064
|
+
setShouldEnforceMinContrast: setShouldEnforceMinContrastWrapped,
|
|
10065
|
+
shouldEnforceMinContrast,
|
|
10066
|
+
valueAsHex,
|
|
10067
|
+
valueAsHsv
|
|
10152
10068
|
}),
|
|
10153
10069
|
[
|
|
10154
|
-
|
|
10155
|
-
valueAsLrgb,
|
|
10070
|
+
colorForComparison,
|
|
10156
10071
|
currentContrastRatio,
|
|
10072
|
+
getAccessibleDerivativeColor,
|
|
10157
10073
|
hasAccessibleDerivativesValue,
|
|
10158
|
-
|
|
10159
|
-
colorForComparisonAsHex,
|
|
10074
|
+
isTransitioning,
|
|
10160
10075
|
minimumContrastRatio,
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
|
|
10076
|
+
nonDerivedValueAsHsv,
|
|
10077
|
+
onChangeNonDerivedValueAsHsv,
|
|
10078
|
+
setShouldEnforceMinContrastWrapped,
|
|
10079
|
+
shouldEnforceMinContrast,
|
|
10080
|
+
valueAsHex,
|
|
10081
|
+
valueAsHsv
|
|
10164
10082
|
]
|
|
10165
10083
|
);
|
|
10166
10084
|
return /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(ColorPickerContext.Provider, { value: contextValue, children });
|
|
@@ -10184,13 +10102,13 @@ var Container = (0, import_styled_components47.default)(import_react_radio_group
|
|
|
10184
10102
|
gap: var(--wui-space-02);
|
|
10185
10103
|
`;
|
|
10186
10104
|
var ColorGrid = ({ children }) => {
|
|
10187
|
-
const { valueAsHex,
|
|
10105
|
+
const { valueAsHex, onChangeNonDerivedValueAsHsv } = useColorPickerState();
|
|
10188
10106
|
const onValueChange = (0, import_react42.useCallback)(
|
|
10189
10107
|
(value) => {
|
|
10190
10108
|
const hsv = convertToHsv(value);
|
|
10191
|
-
|
|
10109
|
+
onChangeNonDerivedValueAsHsv(hsv);
|
|
10192
10110
|
},
|
|
10193
|
-
[
|
|
10111
|
+
[onChangeNonDerivedValueAsHsv]
|
|
10194
10112
|
);
|
|
10195
10113
|
return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
|
|
10196
10114
|
Container,
|
|
@@ -10467,16 +10385,16 @@ var Container3 = (0, import_styled_components51.default)(import_react_toggle_gro
|
|
|
10467
10385
|
padding: var(--wui-space-02);
|
|
10468
10386
|
`;
|
|
10469
10387
|
var ColorList = ({ children }) => {
|
|
10470
|
-
const { valueAsHex,
|
|
10388
|
+
const { valueAsHex, onChangeNonDerivedValueAsHsv } = useColorPickerState();
|
|
10471
10389
|
const onValueChange = (0, import_react43.useCallback)(
|
|
10472
10390
|
(value) => {
|
|
10473
10391
|
if (value === "") {
|
|
10474
10392
|
return;
|
|
10475
10393
|
}
|
|
10476
10394
|
const hsv = convertToHsv(value);
|
|
10477
|
-
|
|
10395
|
+
onChangeNonDerivedValueAsHsv(hsv);
|
|
10478
10396
|
},
|
|
10479
|
-
[
|
|
10397
|
+
[onChangeNonDerivedValueAsHsv]
|
|
10480
10398
|
);
|
|
10481
10399
|
return /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(
|
|
10482
10400
|
Container3,
|
|
@@ -10619,12 +10537,11 @@ ColorListOption.displayName = "ColorListOption_UI";
|
|
|
10619
10537
|
var import_react_popover = require("@radix-ui/react-popover");
|
|
10620
10538
|
var import_jsx_runtime234 = require("react/jsx-runtime");
|
|
10621
10539
|
var ColorPicker = ({
|
|
10622
|
-
value,
|
|
10623
|
-
onValueChange,
|
|
10624
10540
|
children,
|
|
10625
|
-
|
|
10541
|
+
colorForComparison = DEFAULT_COLOR_FOR_COMPARISON,
|
|
10626
10542
|
minimumContrastRatio = DEFAULT_MIN_CONTRAST,
|
|
10627
|
-
|
|
10543
|
+
onValueChange,
|
|
10544
|
+
value
|
|
10628
10545
|
}) => {
|
|
10629
10546
|
return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(import_react_popover.Root, { modal: false, children: /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
|
|
10630
10547
|
ColorPickerProvider,
|
|
@@ -10632,7 +10549,6 @@ var ColorPicker = ({
|
|
|
10632
10549
|
colorForComparison,
|
|
10633
10550
|
minimumContrastRatio,
|
|
10634
10551
|
onValueChange,
|
|
10635
|
-
shouldEnforceMinContrast,
|
|
10636
10552
|
value,
|
|
10637
10553
|
children
|
|
10638
10554
|
}
|
|
@@ -10993,13 +10909,13 @@ var ContrastEnforcerSwitch = () => {
|
|
|
10993
10909
|
// src/components/ColorPicker/ContrastPreview.tsx
|
|
10994
10910
|
var import_jsx_runtime243 = require("react/jsx-runtime");
|
|
10995
10911
|
var ContrastPreview = () => {
|
|
10996
|
-
const { valueAsHex,
|
|
10912
|
+
const { valueAsHex, colorForComparison } = useColorPickerState();
|
|
10997
10913
|
return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(
|
|
10998
10914
|
ColorSwatch,
|
|
10999
10915
|
{
|
|
11000
10916
|
diameterPx: 36,
|
|
11001
10917
|
value: valueAsHex,
|
|
11002
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(Text, { style: { color:
|
|
10918
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(Text, { style: { color: colorForComparison }, children: "Aa" })
|
|
11003
10919
|
}
|
|
11004
10920
|
);
|
|
11005
10921
|
};
|
|
@@ -11250,7 +11166,7 @@ var normalizeHexInput = (input) => {
|
|
|
11250
11166
|
return cleaned.slice(0, SIX_DIGIT_HEX_CODE_LENGTH).toLocaleLowerCase();
|
|
11251
11167
|
};
|
|
11252
11168
|
var HexColorInput = ({ autoFocus = true }) => {
|
|
11253
|
-
const { valueAsHex, nonDerivedValueAsHsv,
|
|
11169
|
+
const { valueAsHex, nonDerivedValueAsHsv, onChangeNonDerivedValueAsHsv } = useColorPickerState();
|
|
11254
11170
|
const inputRef = (0, import_react48.useRef)(null);
|
|
11255
11171
|
const [textInputValue, setTextInputValue] = (0, import_react48.useState)(valueAsHex);
|
|
11256
11172
|
const onChangeInputValue = (0, import_react48.useCallback)(
|
|
@@ -11265,9 +11181,9 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11265
11181
|
return;
|
|
11266
11182
|
}
|
|
11267
11183
|
const newValueAsHsv = convertToHsv(newValue);
|
|
11268
|
-
|
|
11184
|
+
onChangeNonDerivedValueAsHsv(newValueAsHsv);
|
|
11269
11185
|
},
|
|
11270
|
-
[
|
|
11186
|
+
[onChangeNonDerivedValueAsHsv]
|
|
11271
11187
|
);
|
|
11272
11188
|
const onCopy = (0, import_react48.useCallback)((event) => {
|
|
11273
11189
|
const inputElem = inputRef.current;
|
|
@@ -11318,7 +11234,7 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11318
11234
|
...nonDerivedValueAsHsv,
|
|
11319
11235
|
s: newSaturation
|
|
11320
11236
|
};
|
|
11321
|
-
|
|
11237
|
+
onChangeNonDerivedValueAsHsv(newHsv);
|
|
11322
11238
|
return;
|
|
11323
11239
|
}
|
|
11324
11240
|
if (key.length > 1) {
|
|
@@ -11332,7 +11248,7 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11332
11248
|
event.preventDefault();
|
|
11333
11249
|
}
|
|
11334
11250
|
},
|
|
11335
|
-
[valueAsHex,
|
|
11251
|
+
[valueAsHex, onChangeNonDerivedValueAsHsv, nonDerivedValueAsHsv]
|
|
11336
11252
|
);
|
|
11337
11253
|
const onPaste = (0, import_react48.useCallback)(
|
|
11338
11254
|
(event) => {
|
|
@@ -11345,9 +11261,9 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11345
11261
|
return;
|
|
11346
11262
|
}
|
|
11347
11263
|
const newValueAsHsv = convertToHsv(normalizedValue);
|
|
11348
|
-
|
|
11264
|
+
onChangeNonDerivedValueAsHsv(newValueAsHsv);
|
|
11349
11265
|
},
|
|
11350
|
-
[
|
|
11266
|
+
[onChangeNonDerivedValueAsHsv]
|
|
11351
11267
|
);
|
|
11352
11268
|
const selectAllButTheHash = (0, import_react48.useCallback)(() => {
|
|
11353
11269
|
const inputElem = inputRef.current;
|
|
@@ -11489,7 +11405,7 @@ var ThumbInner = import_styled_components62.default.div`
|
|
|
11489
11405
|
}
|
|
11490
11406
|
`;
|
|
11491
11407
|
var HueSlider = () => {
|
|
11492
|
-
const { nonDerivedValueAsHsv,
|
|
11408
|
+
const { nonDerivedValueAsHsv, onChangeNonDerivedValueAsHsv, valueAsHsv } = useColorPickerState();
|
|
11493
11409
|
const containerStyle = (0, import_react50.useMemo)(() => {
|
|
11494
11410
|
return {
|
|
11495
11411
|
backgroundColor: (0, import_fn7.formatHex)({
|
|
@@ -11507,12 +11423,12 @@ var HueSlider = () => {
|
|
|
11507
11423
|
const onHueChange = (0, import_react50.useCallback)(
|
|
11508
11424
|
(values) => {
|
|
11509
11425
|
const newHue = values[0] ?? 0;
|
|
11510
|
-
|
|
11426
|
+
onChangeNonDerivedValueAsHsv({
|
|
11511
11427
|
...nonDerivedValueAsHsv,
|
|
11512
11428
|
h: newHue
|
|
11513
11429
|
});
|
|
11514
11430
|
},
|
|
11515
|
-
[nonDerivedValueAsHsv,
|
|
11431
|
+
[nonDerivedValueAsHsv, onChangeNonDerivedValueAsHsv]
|
|
11516
11432
|
);
|
|
11517
11433
|
return /* @__PURE__ */ (0, import_jsx_runtime248.jsxs)(Container7, { style: containerStyle, children: [
|
|
11518
11434
|
/* @__PURE__ */ (0, import_jsx_runtime248.jsxs)(
|
|
@@ -11575,14 +11491,14 @@ var Canvas2 = import_styled_components63.default.canvas`
|
|
|
11575
11491
|
display: block;
|
|
11576
11492
|
width: 100%;
|
|
11577
11493
|
`;
|
|
11578
|
-
var calculateContrastCurve = (width, height, hue, minimumContrastRatio,
|
|
11494
|
+
var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorForComparison, limit) => {
|
|
11579
11495
|
const contrastPoints = [];
|
|
11580
11496
|
for (let x = 0; x < width; x += 1) {
|
|
11581
11497
|
const saturationChanel = x / (width - 1);
|
|
11582
11498
|
const initialValueChannelForSearch = limit === "upper" ? 0 : 1;
|
|
11583
11499
|
const colorForXAsHsv = getAccessibleColorByValueChannelChange({
|
|
11584
11500
|
originalHsv: { h: hue, s: saturationChanel, v: initialValueChannelForSearch, mode: "hsv" },
|
|
11585
|
-
|
|
11501
|
+
colorForComparison,
|
|
11586
11502
|
minContrast: minimumContrastRatio,
|
|
11587
11503
|
direction: limit === "upper" ? "brighter" : "darker"
|
|
11588
11504
|
});
|
|
@@ -11624,7 +11540,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11624
11540
|
hue,
|
|
11625
11541
|
shouldShowContrastCurve = false,
|
|
11626
11542
|
minimumContrastRatio = DEFAULT_MIN_CONTRAST,
|
|
11627
|
-
|
|
11543
|
+
colorForComparison
|
|
11628
11544
|
}) => {
|
|
11629
11545
|
const canvasRef = (0, import_react51.useRef)(null);
|
|
11630
11546
|
(0, import_react51.useEffect)(() => {
|
|
@@ -11639,7 +11555,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11639
11555
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
11640
11556
|
const { width, height } = canvas;
|
|
11641
11557
|
drawGradientBackground(ctx, width, height, hue);
|
|
11642
|
-
if (shouldShowContrastCurve &&
|
|
11558
|
+
if (shouldShowContrastCurve && colorForComparison) {
|
|
11643
11559
|
ctx.lineWidth = 1.5;
|
|
11644
11560
|
ctx.strokeStyle = "white";
|
|
11645
11561
|
const maxHsvValueChannelCurve = calculateContrastCurve(
|
|
@@ -11647,7 +11563,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11647
11563
|
height,
|
|
11648
11564
|
hue,
|
|
11649
11565
|
minimumContrastRatio,
|
|
11650
|
-
|
|
11566
|
+
colorForComparison,
|
|
11651
11567
|
"upper"
|
|
11652
11568
|
);
|
|
11653
11569
|
const minHsvValueChannelCurve = calculateContrastCurve(
|
|
@@ -11655,7 +11571,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11655
11571
|
height,
|
|
11656
11572
|
hue,
|
|
11657
11573
|
minimumContrastRatio,
|
|
11658
|
-
|
|
11574
|
+
colorForComparison,
|
|
11659
11575
|
"lower"
|
|
11660
11576
|
);
|
|
11661
11577
|
if (minHsvValueChannelCurve.length > 0) {
|
|
@@ -11665,7 +11581,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11665
11581
|
drawSmoothCurve(ctx, maxHsvValueChannelCurve);
|
|
11666
11582
|
}
|
|
11667
11583
|
}
|
|
11668
|
-
}, [hue, shouldShowContrastCurve, minimumContrastRatio,
|
|
11584
|
+
}, [hue, shouldShowContrastCurve, minimumContrastRatio, colorForComparison]);
|
|
11669
11585
|
return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
|
|
11670
11586
|
Canvas2,
|
|
11671
11587
|
{
|
|
@@ -11711,39 +11627,25 @@ var SaturationAndValuePicker = ({
|
|
|
11711
11627
|
}) => {
|
|
11712
11628
|
const {
|
|
11713
11629
|
valueAsHex,
|
|
11714
|
-
|
|
11630
|
+
onChangeNonDerivedValueAsHsv,
|
|
11715
11631
|
valueAsHsv,
|
|
11716
11632
|
isTransitioning,
|
|
11717
11633
|
minimumContrastRatio,
|
|
11718
|
-
|
|
11634
|
+
colorForComparison,
|
|
11719
11635
|
shouldEnforceMinContrast,
|
|
11720
|
-
nonDerivedValueAsHsv
|
|
11721
|
-
getAccessibleDerivativeColor
|
|
11636
|
+
nonDerivedValueAsHsv
|
|
11722
11637
|
} = useColorPickerState();
|
|
11723
11638
|
const containerRef = (0, import_react52.useRef)(null);
|
|
11724
11639
|
const thumbRef = (0, import_react52.useRef)(null);
|
|
11725
11640
|
const uuid = (0, import_react52.useMemo)(() => crypto.randomUUID(), []);
|
|
11726
11641
|
const instructionsId = `sv-instructions-${uuid}`;
|
|
11642
|
+
const valueAsHexConvertedToHsv = convertToHsv(valueAsHex);
|
|
11727
11643
|
const thumbPositionHsv = (0, import_react52.useMemo)(() => {
|
|
11728
|
-
if (isTransitioning) {
|
|
11644
|
+
if (!isTransitioning) {
|
|
11729
11645
|
return valueAsHsv;
|
|
11730
11646
|
}
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
}
|
|
11734
|
-
const accessibleHsv = getAccessibleDerivativeColor(nonDerivedValueAsHsv);
|
|
11735
|
-
return {
|
|
11736
|
-
...nonDerivedValueAsHsv,
|
|
11737
|
-
s: accessibleHsv.s,
|
|
11738
|
-
v: accessibleHsv.v
|
|
11739
|
-
};
|
|
11740
|
-
}, [
|
|
11741
|
-
isTransitioning,
|
|
11742
|
-
shouldEnforceMinContrast,
|
|
11743
|
-
nonDerivedValueAsHsv,
|
|
11744
|
-
valueAsHsv,
|
|
11745
|
-
getAccessibleDerivativeColor
|
|
11746
|
-
]);
|
|
11647
|
+
return valueAsHexConvertedToHsv;
|
|
11648
|
+
}, [isTransitioning, valueAsHexConvertedToHsv, valueAsHsv]);
|
|
11747
11649
|
const [thumbStyle, setThumbStyle] = (0, import_react52.useState)({
|
|
11748
11650
|
backgroundColor: valueAsHex
|
|
11749
11651
|
});
|
|
@@ -11764,19 +11666,19 @@ var SaturationAndValuePicker = ({
|
|
|
11764
11666
|
(channel, delta) => {
|
|
11765
11667
|
if (channel === "s") {
|
|
11766
11668
|
const newSaturation = Math.max(0, Math.min(1, nonDerivedValueAsHsv.s + delta));
|
|
11767
|
-
|
|
11669
|
+
onChangeNonDerivedValueAsHsv({
|
|
11768
11670
|
...nonDerivedValueAsHsv,
|
|
11769
11671
|
s: newSaturation
|
|
11770
11672
|
});
|
|
11771
11673
|
return;
|
|
11772
11674
|
}
|
|
11773
11675
|
const newValue = Math.max(0, Math.min(1, nonDerivedValueAsHsv.v + delta));
|
|
11774
|
-
|
|
11676
|
+
onChangeNonDerivedValueAsHsv({
|
|
11775
11677
|
...nonDerivedValueAsHsv,
|
|
11776
11678
|
v: newValue
|
|
11777
11679
|
});
|
|
11778
11680
|
},
|
|
11779
|
-
[nonDerivedValueAsHsv,
|
|
11681
|
+
[nonDerivedValueAsHsv, onChangeNonDerivedValueAsHsv]
|
|
11780
11682
|
);
|
|
11781
11683
|
const [isDragging, setIsDragging] = (0, import_react52.useState)(false);
|
|
11782
11684
|
const updateSaturationAndValueFromCoordinates = (0, import_react52.useCallback)(
|
|
@@ -11790,13 +11692,13 @@ var SaturationAndValuePicker = ({
|
|
|
11790
11692
|
const y = Math.max(0, Math.min(1, (clientY - rect.top) / rect.height));
|
|
11791
11693
|
const saturation = x;
|
|
11792
11694
|
const value = 1 - y;
|
|
11793
|
-
|
|
11695
|
+
onChangeNonDerivedValueAsHsv({
|
|
11794
11696
|
...nonDerivedValueAsHsv,
|
|
11795
11697
|
s: saturation,
|
|
11796
11698
|
v: value
|
|
11797
11699
|
});
|
|
11798
11700
|
},
|
|
11799
|
-
[
|
|
11701
|
+
[onChangeNonDerivedValueAsHsv, nonDerivedValueAsHsv]
|
|
11800
11702
|
);
|
|
11801
11703
|
const onContainerMouseDown = (0, import_react52.useCallback)(
|
|
11802
11704
|
(event) => {
|
|
@@ -11881,7 +11783,7 @@ var SaturationAndValuePicker = ({
|
|
|
11881
11783
|
/* @__PURE__ */ (0, import_jsx_runtime250.jsx)(
|
|
11882
11784
|
HSVSaturationValueCanvas,
|
|
11883
11785
|
{
|
|
11884
|
-
|
|
11786
|
+
colorForComparison,
|
|
11885
11787
|
hue: nonDerivedValueAsHsv.h ?? 0,
|
|
11886
11788
|
minimumContrastRatio,
|
|
11887
11789
|
shouldShowContrastCurve: shouldEnforceMinContrast
|
|
@@ -13065,52 +12967,49 @@ var import_styled_components74 = __toESM(require("styled-components"));
|
|
|
13065
12967
|
var import_type_guards40 = require("@wistia/type-guards");
|
|
13066
12968
|
var import_jsx_runtime262 = require("react/jsx-runtime");
|
|
13067
12969
|
var DEFAULT_ELEMENT5 = "div";
|
|
13068
|
-
var getGridTemplateColumns = (maxColumns, minChildWidth, expandItems) => {
|
|
13069
|
-
if (minChildWidth === "auto" && maxColumns === "auto") {
|
|
13070
|
-
return import_styled_components74.css`
|
|
13071
|
-
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
|
|
13072
|
-
`;
|
|
13073
|
-
}
|
|
13074
|
-
const gridMode = expandItems ? "auto-fit" : "auto-fill";
|
|
13075
|
-
const minChildWidthValue = minChildWidth === "auto" ? 0 : minChildWidth;
|
|
13076
|
-
if (maxColumns === "auto") {
|
|
13077
|
-
return import_styled_components74.css`
|
|
13078
|
-
grid-template-columns: repeat(${gridMode}, minmax(${minChildWidthValue}px, 1fr));
|
|
13079
|
-
`;
|
|
13080
|
-
}
|
|
13081
|
-
return import_styled_components74.css`
|
|
13082
|
-
/* Adapted from https://9elements.com/blog/building-a-rock-solid-auto-grid/ */
|
|
13083
|
-
--wui-grid-total-column-gap-width: calc(${maxColumns - 1} * var(--wui-grid-column-gap));
|
|
13084
|
-
--wui-grid-max-column-width: calc(
|
|
13085
|
-
(100% - var(--wui-grid-total-column-gap-width)) / ${maxColumns}
|
|
13086
|
-
);
|
|
13087
|
-
|
|
13088
|
-
grid-template-columns: repeat(
|
|
13089
|
-
${gridMode},
|
|
13090
|
-
minmax(max(${minChildWidthValue}px, var(--wui-grid-max-column-width)), 1fr)
|
|
13091
|
-
);
|
|
13092
|
-
`;
|
|
13093
|
-
};
|
|
13094
12970
|
var StyledGrid = import_styled_components74.default.div`
|
|
13095
12971
|
--wui-grid-column-gap: ${({ $columnGap }) => `var(--wui-${$columnGap})`};
|
|
13096
12972
|
--wui-grid-row-gap: ${({ $rowGap }) => `var(--wui-${$rowGap})`};
|
|
12973
|
+
--wui-grid-min-column-size: ${({ $minChildWidth }) => $minChildWidth === "auto" ? "0" : `${$minChildWidth}px`};
|
|
12974
|
+
--wui-grid-max-columns: ${({ $maxColumns }) => $maxColumns === "auto" ? "infinity" : $maxColumns};
|
|
12975
|
+
--wui-grid-column-gap-count: calc(var(--wui-grid-max-columns) - 1);
|
|
12976
|
+
--wui-grid-total-column-gap-width: calc(
|
|
12977
|
+
var(--wui-grid-column-gap-count) * var(--wui-grid-column-gap)
|
|
12978
|
+
);
|
|
12979
|
+
--wui-grid-max-column-width: calc(
|
|
12980
|
+
(100% - var(--wui-grid-total-column-gap-width)) / var(--wui-grid-max-columns)
|
|
12981
|
+
);
|
|
13097
12982
|
|
|
13098
12983
|
display: grid;
|
|
13099
12984
|
gap: var(--wui-grid-column-gap) var(--wui-grid-row-gap);
|
|
13100
12985
|
width: 100%;
|
|
13101
12986
|
|
|
13102
|
-
${({ $maxColumns, $minChildWidth
|
|
12987
|
+
${({ $maxColumns, $minChildWidth }) => {
|
|
12988
|
+
if ($maxColumns === "auto" && $minChildWidth === "auto") {
|
|
12989
|
+
return import_styled_components74.css`
|
|
12990
|
+
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
|
|
12991
|
+
`;
|
|
12992
|
+
}
|
|
12993
|
+
if ($maxColumns !== "auto" && $minChildWidth === "auto") {
|
|
12994
|
+
return import_styled_components74.css`
|
|
12995
|
+
grid-template-columns: repeat(${$maxColumns}, minmax(0, 1fr));
|
|
12996
|
+
`;
|
|
12997
|
+
}
|
|
12998
|
+
if ($maxColumns === "auto" && $minChildWidth !== "auto") {
|
|
12999
|
+
return import_styled_components74.css`
|
|
13000
|
+
grid-template-columns: repeat(auto-fit, minmax(${$minChildWidth}px, 1fr));
|
|
13001
|
+
`;
|
|
13002
|
+
}
|
|
13003
|
+
return import_styled_components74.css`
|
|
13004
|
+
grid-template-columns: repeat(
|
|
13005
|
+
auto-fit,
|
|
13006
|
+
minmax(max(var(--wui-grid-min-column-size), var(--wui-grid-max-column-width)), 1fr)
|
|
13007
|
+
);
|
|
13008
|
+
`;
|
|
13009
|
+
}}
|
|
13103
13010
|
`;
|
|
13104
13011
|
var GridComponent = (0, import_react61.forwardRef)(
|
|
13105
|
-
({
|
|
13106
|
-
children,
|
|
13107
|
-
columns = "auto",
|
|
13108
|
-
minChildWidth = "auto",
|
|
13109
|
-
gap = "space-02",
|
|
13110
|
-
expandItems = false,
|
|
13111
|
-
renderAs,
|
|
13112
|
-
...props
|
|
13113
|
-
}, ref) => {
|
|
13012
|
+
({ children, columns = "auto", minChildWidth = "auto", gap = "space-02", renderAs, ...props }, ref) => {
|
|
13114
13013
|
const responsiveGap = useResponsiveProp(gap);
|
|
13115
13014
|
const { column, row } = (0, import_type_guards40.isRecord)(responsiveGap) ? responsiveGap : { column: responsiveGap, row: responsiveGap };
|
|
13116
13015
|
const responsiveColumns = useResponsiveProp(columns);
|
|
@@ -13120,7 +13019,6 @@ var GridComponent = (0, import_react61.forwardRef)(
|
|
|
13120
13019
|
{
|
|
13121
13020
|
ref,
|
|
13122
13021
|
$columnGap: column,
|
|
13123
|
-
$expandItems: expandItems,
|
|
13124
13022
|
$maxColumns: responsiveColumns,
|
|
13125
13023
|
$minChildWidth: responsiveMinChildWidth,
|
|
13126
13024
|
$rowGap: row,
|