@trops/dash-core 0.1.570 → 0.1.572
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.esm.js +104 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +103 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36948,6 +36948,65 @@ var CustomHexColorPane = function CustomHexColorPane(_ref) {
|
|
|
36948
36948
|
});
|
|
36949
36949
|
};
|
|
36950
36950
|
|
|
36951
|
+
var CategorizedColorGrid = function CategorizedColorGrid(_ref) {
|
|
36952
|
+
var onSelect = _ref.onSelect,
|
|
36953
|
+
_ref$selectedHex = _ref.selectedHex,
|
|
36954
|
+
selectedHex = _ref$selectedHex === void 0 ? null : _ref$selectedHex,
|
|
36955
|
+
_ref$cols = _ref.cols,
|
|
36956
|
+
cols = _ref$cols === void 0 ? 6 : _ref$cols;
|
|
36957
|
+
var families = DashReact.getColorFamilies();
|
|
36958
|
+
var _useState = React.useState(families[0]),
|
|
36959
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36960
|
+
activeFamily = _useState2[0],
|
|
36961
|
+
setActiveFamily = _useState2[1];
|
|
36962
|
+
var colors = DashReact.getCuratedColorGrid(activeFamily);
|
|
36963
|
+
|
|
36964
|
+
// Map the `cols` prop to a Tailwind class. The pattern set is in
|
|
36965
|
+
// the dash-electron safelist already (grid-cols-1..12).
|
|
36966
|
+
var gridColsClass = {
|
|
36967
|
+
4: "grid-cols-4",
|
|
36968
|
+
6: "grid-cols-6",
|
|
36969
|
+
8: "grid-cols-8",
|
|
36970
|
+
9: "grid-cols-9",
|
|
36971
|
+
10: "grid-cols-10",
|
|
36972
|
+
12: "grid-cols-12"
|
|
36973
|
+
}[cols] || "grid-cols-6";
|
|
36974
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
36975
|
+
className: "flex flex-col gap-3 p-3",
|
|
36976
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
36977
|
+
className: "flex flex-row gap-2 flex-wrap",
|
|
36978
|
+
children: families.map(function (family) {
|
|
36979
|
+
var isActive = activeFamily === family;
|
|
36980
|
+
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
36981
|
+
type: "button",
|
|
36982
|
+
onClick: function onClick() {
|
|
36983
|
+
return setActiveFamily(family);
|
|
36984
|
+
},
|
|
36985
|
+
className: "px-3 py-1 rounded-full text-xs font-medium transition-colors ".concat(isActive ? "bg-blue-600 text-white" : "bg-gray-700 text-gray-300 hover:bg-gray-600"),
|
|
36986
|
+
children: family
|
|
36987
|
+
}, family);
|
|
36988
|
+
})
|
|
36989
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
36990
|
+
className: "grid ".concat(gridColsClass, " gap-1"),
|
|
36991
|
+
children: colors.map(function (hex) {
|
|
36992
|
+
var isSelected = selectedHex && hex.toLowerCase() === selectedHex.toLowerCase();
|
|
36993
|
+
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
36994
|
+
type: "button",
|
|
36995
|
+
onClick: function onClick() {
|
|
36996
|
+
return onSelect(hex);
|
|
36997
|
+
},
|
|
36998
|
+
title: hex,
|
|
36999
|
+
className: "aspect-square rounded transition-transform hover:scale-110 focus:scale-110 focus:outline-none ".concat(isSelected ? "ring-2 ring-white scale-110" : ""),
|
|
37000
|
+
style: {
|
|
37001
|
+
backgroundColor: hex
|
|
37002
|
+
},
|
|
37003
|
+
"aria-label": "Select color ".concat(hex)
|
|
37004
|
+
}, hex);
|
|
37005
|
+
})
|
|
37006
|
+
})]
|
|
37007
|
+
});
|
|
37008
|
+
};
|
|
37009
|
+
|
|
36951
37010
|
var AvailableColorsGridPane = function AvailableColorsGridPane(_ref) {
|
|
36952
37011
|
var _ref$currentColor = _ref.currentColor,
|
|
36953
37012
|
currentColor = _ref$currentColor === void 0 ? null : _ref$currentColor,
|
|
@@ -37008,36 +37067,56 @@ var AvailableColorsGridPane = function AvailableColorsGridPane(_ref) {
|
|
|
37008
37067
|
});
|
|
37009
37068
|
});
|
|
37010
37069
|
}
|
|
37011
|
-
|
|
37012
|
-
|
|
37013
|
-
|
|
37014
|
-
|
|
37015
|
-
|
|
37016
|
-
|
|
37017
|
-
|
|
37018
|
-
|
|
37019
|
-
|
|
37070
|
+
|
|
37071
|
+
// The picker renders inside a modal so it has room for the full
|
|
37072
|
+
// categorized grid without the user having to scroll within a
|
|
37073
|
+
// cramped left-column. Mount/unmount of this component is driven
|
|
37074
|
+
// by the parent (ThemeMenuPane) based on `selectedColor` state —
|
|
37075
|
+
// so `isOpen` is effectively always `true` while mounted, and
|
|
37076
|
+
// closing the modal triggers `onCancel` to unmount.
|
|
37077
|
+
var isMain = shade !== null;
|
|
37078
|
+
var title = isMain ? "Pick ".concat(DashReact.capitalizeFirstLetter(colorType || "color"), " color") : "Available Colors";
|
|
37079
|
+
return /*#__PURE__*/jsxRuntime.jsx(DashReact.Modal, {
|
|
37080
|
+
isOpen: true,
|
|
37081
|
+
setIsOpen: function setIsOpen() {
|
|
37082
|
+
return handleCancel();
|
|
37083
|
+
},
|
|
37084
|
+
width: "w-3/4",
|
|
37085
|
+
height: "h-3/4",
|
|
37086
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(DashReact.DashPanel, {
|
|
37020
37087
|
height: "h-full",
|
|
37021
37088
|
scrollable: true,
|
|
37022
37089
|
children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.DashPanel.Header, {
|
|
37023
|
-
title:
|
|
37024
|
-
}), /*#__PURE__*/jsxRuntime.
|
|
37090
|
+
title: title
|
|
37091
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DashReact.DashPanel.Body, {
|
|
37025
37092
|
scrollable: true,
|
|
37026
37093
|
space: true,
|
|
37027
|
-
children:
|
|
37094
|
+
children: isMain ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
37095
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(CategorizedColorGrid, {
|
|
37096
|
+
cols: 12,
|
|
37097
|
+
onSelect: function onSelect(hex) {
|
|
37098
|
+
return handleChooseColor({
|
|
37099
|
+
colorName: hex,
|
|
37100
|
+
colorType: colorType,
|
|
37101
|
+
shade: shade || 500,
|
|
37102
|
+
panelType: "main"
|
|
37103
|
+
});
|
|
37104
|
+
}
|
|
37105
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CustomHexColorPane, {
|
|
37106
|
+
onApply: function onApply(hex) {
|
|
37107
|
+
return handleChooseColor({
|
|
37108
|
+
colorName: hex,
|
|
37109
|
+
colorType: colorType,
|
|
37110
|
+
shade: shade || 500,
|
|
37111
|
+
panelType: "main"
|
|
37112
|
+
});
|
|
37113
|
+
},
|
|
37114
|
+
label: "Custom hex for ".concat(colorType || "channel")
|
|
37115
|
+
})]
|
|
37116
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
37028
37117
|
className: "flex flex-col space-y-1",
|
|
37029
37118
|
children: renderAvailableColors()
|
|
37030
|
-
})
|
|
37031
|
-
onApply: function onApply(hex) {
|
|
37032
|
-
return handleChooseColor({
|
|
37033
|
-
colorName: hex,
|
|
37034
|
-
colorType: colorType,
|
|
37035
|
-
shade: shade || 500,
|
|
37036
|
-
panelType: "main"
|
|
37037
|
-
});
|
|
37038
|
-
},
|
|
37039
|
-
label: "Custom hex for ".concat(colorType || "channel")
|
|
37040
|
-
})]
|
|
37119
|
+
})
|
|
37041
37120
|
}), onCancel && /*#__PURE__*/jsxRuntime.jsx(DashReact.DashPanel.Footer, {
|
|
37042
37121
|
children: /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
|
|
37043
37122
|
title: "Cancel",
|
|
@@ -37046,8 +37125,7 @@ var AvailableColorsGridPane = function AvailableColorsGridPane(_ref) {
|
|
|
37046
37125
|
})
|
|
37047
37126
|
})]
|
|
37048
37127
|
})
|
|
37049
|
-
|
|
37050
|
-
);
|
|
37128
|
+
});
|
|
37051
37129
|
};
|
|
37052
37130
|
|
|
37053
37131
|
var ThemeMenuPane = function ThemeMenuPane(_ref) {
|