@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.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
2
2
|
import _typeof from '@babel/runtime/helpers/typeof';
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import * as DashReact from '@trops/dash-react';
|
|
5
|
-
import { isObject, ThemeContext, Modal, FontAwesomeIcon, deepCopy, MainSection, getUUID, getStylesForItem, themeObjects, Heading, SearchInput, ButtonIcon, SubHeading3, InputText, Button, Tag, Button3, Button2, Paragraph, Sidebar, Panel, Stepper, Tag3, Card2, Card3, Heading3, MenuItem3, FormLabel, SelectMenu, Switch, SelectInput, CodeEditorVS, SettingsModal, SubHeading2, tailwindHeightFractions, Menu3, Panel3, ButtonIcon2, DropdownPanel, MenuItem2, DragComponent, ConfirmationModal, DropComponent, getStyleName, capitalizeFirstLetter, colorTypes, isHexColor, deriveShades, TAILWIND_PALETTE, getCSSStyleForClassname, Panel2, Heading2, SubHeading, Paragraph2, Paragraph3, MenuItem, Tag2, ButtonIcon3, normalizeHex, contrastRatio, Caption2, Caption, DashPanel, colorNames, shades, themeVariants, Tabs3, DataList, Checkbox, StatCard, Card, Tabs, Accordion, Alert, Toast, ProgressBar, Toggle, Breadcrumbs, Tabs2, Accordion2, Alert2, Toast2, ProgressBar2, Toggle2, Breadcrumbs2, Accordion3, Alert3, Toast3, ProgressBar3, Toggle3, Breadcrumbs3, ThemeFromUrlPane, TextArea, CodeEditorInline, Icon2, AlgoliaSearchBox, CommandPalette, useSidebar, Divider, Caption3, EmptyState, Navbar, withRouter, Menu as Menu$1 } from '@trops/dash-react';
|
|
5
|
+
import { isObject, ThemeContext, Modal, FontAwesomeIcon, deepCopy, MainSection, getUUID, getStylesForItem, themeObjects, Heading, SearchInput, ButtonIcon, SubHeading3, InputText, Button, Tag, Button3, Button2, Paragraph, Sidebar, Panel, Stepper, Tag3, Card2, Card3, Heading3, MenuItem3, FormLabel, SelectMenu, Switch, SelectInput, CodeEditorVS, SettingsModal, SubHeading2, tailwindHeightFractions, Menu3, Panel3, ButtonIcon2, DropdownPanel, MenuItem2, DragComponent, ConfirmationModal, DropComponent, getStyleName, capitalizeFirstLetter, colorTypes, isHexColor, deriveShades, TAILWIND_PALETTE, getCSSStyleForClassname, Panel2, Heading2, SubHeading, Paragraph2, Paragraph3, MenuItem, Tag2, ButtonIcon3, normalizeHex, contrastRatio, Caption2, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, colorNames, shades, themeVariants, Tabs3, DataList, Checkbox, StatCard, Card, Tabs, Accordion, Alert, Toast, ProgressBar, Toggle, Breadcrumbs, Tabs2, Accordion2, Alert2, Toast2, ProgressBar2, Toggle2, Breadcrumbs2, Accordion3, Alert3, Toast3, ProgressBar3, Toggle3, Breadcrumbs3, ThemeFromUrlPane, TextArea, CodeEditorInline, Icon2, AlgoliaSearchBox, CommandPalette, useSidebar, Divider, Caption3, EmptyState, Navbar, withRouter, Menu as Menu$1 } from '@trops/dash-react';
|
|
6
6
|
export * from '@trops/dash-react';
|
|
7
7
|
export { ThemeContext } from '@trops/dash-react';
|
|
8
8
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
@@ -36930,6 +36930,65 @@ var CustomHexColorPane = function CustomHexColorPane(_ref) {
|
|
|
36930
36930
|
});
|
|
36931
36931
|
};
|
|
36932
36932
|
|
|
36933
|
+
var CategorizedColorGrid = function CategorizedColorGrid(_ref) {
|
|
36934
|
+
var onSelect = _ref.onSelect,
|
|
36935
|
+
_ref$selectedHex = _ref.selectedHex,
|
|
36936
|
+
selectedHex = _ref$selectedHex === void 0 ? null : _ref$selectedHex,
|
|
36937
|
+
_ref$cols = _ref.cols,
|
|
36938
|
+
cols = _ref$cols === void 0 ? 6 : _ref$cols;
|
|
36939
|
+
var families = getColorFamilies();
|
|
36940
|
+
var _useState = useState(families[0]),
|
|
36941
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36942
|
+
activeFamily = _useState2[0],
|
|
36943
|
+
setActiveFamily = _useState2[1];
|
|
36944
|
+
var colors = getCuratedColorGrid(activeFamily);
|
|
36945
|
+
|
|
36946
|
+
// Map the `cols` prop to a Tailwind class. The pattern set is in
|
|
36947
|
+
// the dash-electron safelist already (grid-cols-1..12).
|
|
36948
|
+
var gridColsClass = {
|
|
36949
|
+
4: "grid-cols-4",
|
|
36950
|
+
6: "grid-cols-6",
|
|
36951
|
+
8: "grid-cols-8",
|
|
36952
|
+
9: "grid-cols-9",
|
|
36953
|
+
10: "grid-cols-10",
|
|
36954
|
+
12: "grid-cols-12"
|
|
36955
|
+
}[cols] || "grid-cols-6";
|
|
36956
|
+
return /*#__PURE__*/jsxs("div", {
|
|
36957
|
+
className: "flex flex-col gap-3 p-3",
|
|
36958
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
36959
|
+
className: "flex flex-row gap-2 flex-wrap",
|
|
36960
|
+
children: families.map(function (family) {
|
|
36961
|
+
var isActive = activeFamily === family;
|
|
36962
|
+
return /*#__PURE__*/jsx("button", {
|
|
36963
|
+
type: "button",
|
|
36964
|
+
onClick: function onClick() {
|
|
36965
|
+
return setActiveFamily(family);
|
|
36966
|
+
},
|
|
36967
|
+
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"),
|
|
36968
|
+
children: family
|
|
36969
|
+
}, family);
|
|
36970
|
+
})
|
|
36971
|
+
}), /*#__PURE__*/jsx("div", {
|
|
36972
|
+
className: "grid ".concat(gridColsClass, " gap-1"),
|
|
36973
|
+
children: colors.map(function (hex) {
|
|
36974
|
+
var isSelected = selectedHex && hex.toLowerCase() === selectedHex.toLowerCase();
|
|
36975
|
+
return /*#__PURE__*/jsx("button", {
|
|
36976
|
+
type: "button",
|
|
36977
|
+
onClick: function onClick() {
|
|
36978
|
+
return onSelect(hex);
|
|
36979
|
+
},
|
|
36980
|
+
title: hex,
|
|
36981
|
+
className: "aspect-square rounded transition-transform hover:scale-110 focus:scale-110 focus:outline-none ".concat(isSelected ? "ring-2 ring-white scale-110" : ""),
|
|
36982
|
+
style: {
|
|
36983
|
+
backgroundColor: hex
|
|
36984
|
+
},
|
|
36985
|
+
"aria-label": "Select color ".concat(hex)
|
|
36986
|
+
}, hex);
|
|
36987
|
+
})
|
|
36988
|
+
})]
|
|
36989
|
+
});
|
|
36990
|
+
};
|
|
36991
|
+
|
|
36933
36992
|
var AvailableColorsGridPane = function AvailableColorsGridPane(_ref) {
|
|
36934
36993
|
var _ref$currentColor = _ref.currentColor,
|
|
36935
36994
|
currentColor = _ref$currentColor === void 0 ? null : _ref$currentColor,
|
|
@@ -36990,36 +37049,56 @@ var AvailableColorsGridPane = function AvailableColorsGridPane(_ref) {
|
|
|
36990
37049
|
});
|
|
36991
37050
|
});
|
|
36992
37051
|
}
|
|
36993
|
-
|
|
36994
|
-
|
|
36995
|
-
|
|
36996
|
-
|
|
36997
|
-
|
|
36998
|
-
|
|
36999
|
-
|
|
37000
|
-
|
|
37001
|
-
|
|
37052
|
+
|
|
37053
|
+
// The picker renders inside a modal so it has room for the full
|
|
37054
|
+
// categorized grid without the user having to scroll within a
|
|
37055
|
+
// cramped left-column. Mount/unmount of this component is driven
|
|
37056
|
+
// by the parent (ThemeMenuPane) based on `selectedColor` state —
|
|
37057
|
+
// so `isOpen` is effectively always `true` while mounted, and
|
|
37058
|
+
// closing the modal triggers `onCancel` to unmount.
|
|
37059
|
+
var isMain = shade !== null;
|
|
37060
|
+
var title = isMain ? "Pick ".concat(capitalizeFirstLetter(colorType || "color"), " color") : "Available Colors";
|
|
37061
|
+
return /*#__PURE__*/jsx(Modal, {
|
|
37062
|
+
isOpen: true,
|
|
37063
|
+
setIsOpen: function setIsOpen() {
|
|
37064
|
+
return handleCancel();
|
|
37065
|
+
},
|
|
37066
|
+
width: "w-3/4",
|
|
37067
|
+
height: "h-3/4",
|
|
37068
|
+
children: /*#__PURE__*/jsxs(DashPanel, {
|
|
37002
37069
|
height: "h-full",
|
|
37003
37070
|
scrollable: true,
|
|
37004
37071
|
children: [/*#__PURE__*/jsx(DashPanel.Header, {
|
|
37005
|
-
title:
|
|
37006
|
-
}), /*#__PURE__*/
|
|
37072
|
+
title: title
|
|
37073
|
+
}), /*#__PURE__*/jsx(DashPanel.Body, {
|
|
37007
37074
|
scrollable: true,
|
|
37008
37075
|
space: true,
|
|
37009
|
-
children:
|
|
37076
|
+
children: isMain ? /*#__PURE__*/jsxs(Fragment, {
|
|
37077
|
+
children: [/*#__PURE__*/jsx(CategorizedColorGrid, {
|
|
37078
|
+
cols: 12,
|
|
37079
|
+
onSelect: function onSelect(hex) {
|
|
37080
|
+
return handleChooseColor({
|
|
37081
|
+
colorName: hex,
|
|
37082
|
+
colorType: colorType,
|
|
37083
|
+
shade: shade || 500,
|
|
37084
|
+
panelType: "main"
|
|
37085
|
+
});
|
|
37086
|
+
}
|
|
37087
|
+
}), /*#__PURE__*/jsx(CustomHexColorPane, {
|
|
37088
|
+
onApply: function onApply(hex) {
|
|
37089
|
+
return handleChooseColor({
|
|
37090
|
+
colorName: hex,
|
|
37091
|
+
colorType: colorType,
|
|
37092
|
+
shade: shade || 500,
|
|
37093
|
+
panelType: "main"
|
|
37094
|
+
});
|
|
37095
|
+
},
|
|
37096
|
+
label: "Custom hex for ".concat(colorType || "channel")
|
|
37097
|
+
})]
|
|
37098
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
37010
37099
|
className: "flex flex-col space-y-1",
|
|
37011
37100
|
children: renderAvailableColors()
|
|
37012
|
-
})
|
|
37013
|
-
onApply: function onApply(hex) {
|
|
37014
|
-
return handleChooseColor({
|
|
37015
|
-
colorName: hex,
|
|
37016
|
-
colorType: colorType,
|
|
37017
|
-
shade: shade || 500,
|
|
37018
|
-
panelType: "main"
|
|
37019
|
-
});
|
|
37020
|
-
},
|
|
37021
|
-
label: "Custom hex for ".concat(colorType || "channel")
|
|
37022
|
-
})]
|
|
37101
|
+
})
|
|
37023
37102
|
}), onCancel && /*#__PURE__*/jsx(DashPanel.Footer, {
|
|
37024
37103
|
children: /*#__PURE__*/jsx(Button, {
|
|
37025
37104
|
title: "Cancel",
|
|
@@ -37028,8 +37107,7 @@ var AvailableColorsGridPane = function AvailableColorsGridPane(_ref) {
|
|
|
37028
37107
|
})
|
|
37029
37108
|
})]
|
|
37030
37109
|
})
|
|
37031
|
-
|
|
37032
|
-
);
|
|
37110
|
+
});
|
|
37033
37111
|
};
|
|
37034
37112
|
|
|
37035
37113
|
var ThemeMenuPane = function ThemeMenuPane(_ref) {
|