@trops/dash-core 0.1.575 → 0.1.576

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 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, isHexColor, deriveShades, colorTypes, TAILWIND_PALETTE, Toggle, normalizeHex, contrastRatio, Caption2, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, themeVariants, SubHeading, Heading2, Paragraph2, Paragraph3, ButtonIcon3, Tag2, Alert, Alert2, Alert3, Toast, Toast2, Toast3, ProgressBar, ProgressBar2, ProgressBar3, MenuItem, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Caption3, Code, Code2, Code3, Divider, Divider2, Divider3, DashPanel2, DashPanel3, Tabs, Tabs2, Tabs3, Accordion, Accordion2, Accordion3, Toggle2, Toggle3, TextArea, Checkbox, Slider, RadioGroup, AlertBanner, StatusBadge, Skeleton, StatCard, DataList, EmptyState, Card, Panel2, hexToRgb, rgbToHsl, rgbToHex, hslToRgb, ThemeFromUrlPane, CodeEditorInline, Icon2, AlgoliaSearchBox, CommandPalette, useSidebar, 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, isHexColor as isHexColor$1, deriveShades, colorTypes, TAILWIND_PALETTE, Toggle, normalizeHex as normalizeHex$1, contrastRatio, Caption2, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, themeVariants, SubHeading, Heading2, Paragraph2, Paragraph3, ButtonIcon3, Tag2, Alert, Alert2, Alert3, Toast, Toast2, Toast3, ProgressBar, ProgressBar2, ProgressBar3, MenuItem, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Caption3, Code, Code2, Code3, Divider, Divider2, Divider3, DashPanel2, DashPanel3, Tabs, Tabs2, Tabs3, Accordion, Accordion2, Accordion3, Toggle2, Toggle3, TextArea, Checkbox, Slider, RadioGroup, AlertBanner, StatusBadge, Skeleton, StatCard, DataList, EmptyState, Card, Panel2, ThemeFromUrlPane, CodeEditorInline, Icon2, AlgoliaSearchBox, CommandPalette, useSidebar, Navbar, withRouter, Menu as Menu$1 } from '@trops/dash-react';
6
6
  export * from '@trops/dash-react';
7
7
  export { FontAwesomeIcon, ThemeContext } from '@trops/dash-react';
8
8
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
@@ -28902,7 +28902,7 @@ function invert(shade) {
28902
28902
  function classFor(prefix, type, shade, channelValue) {
28903
28903
  var hover = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
28904
28904
  var h = hover ? "hover:" : "";
28905
- if (isHexColor(channelValue)) {
28905
+ if (isHexColor$1(channelValue)) {
28906
28906
  return "".concat(h).concat(prefix, "-[var(--").concat(type, "-").concat(shade, ")]");
28907
28907
  }
28908
28908
  return "".concat(h).concat(prefix, "-").concat(channelValue, "-").concat(shade);
@@ -28922,7 +28922,7 @@ function classFor(prefix, type, shade, channelValue) {
28922
28922
  * falls back to className-only reactivity for that token.
28923
28923
  */
28924
28924
  function cssValueFor(type, shade, channelValue) {
28925
- if (isHexColor(channelValue)) {
28925
+ if (isHexColor$1(channelValue)) {
28926
28926
  // Resolve to a real hex so non-active themes (e.g. tiles in the
28927
28927
  // theme picker) can render inline without depending on :root
28928
28928
  // cssVars, which are only written for the currently-active
@@ -28940,7 +28940,7 @@ function cssValueFor(type, shade, channelValue) {
28940
28940
  return hex || null;
28941
28941
  }
28942
28942
  function gradientFor(direction, type, fromShade, viaShade, toShade, channelValue) {
28943
- if (isHexColor(channelValue)) {
28943
+ if (isHexColor$1(channelValue)) {
28944
28944
  return "bg-gradient-to-".concat(direction, " from-[var(--").concat(type, "-").concat(fromShade, ")] via-[var(--").concat(type, "-").concat(viaShade, ")] to-[var(--").concat(type, "-").concat(toShade, ")]");
28945
28945
  }
28946
28946
  return "bg-gradient-to-".concat(direction, " from-").concat(channelValue, "-").concat(fromShade, " via-").concat(channelValue, "-").concat(viaShade, " to-").concat(channelValue, "-").concat(toShade);
@@ -28950,7 +28950,7 @@ var ThemeModel = function ThemeModel() {
28950
28950
  try {
28951
28951
  var applyOverride = function applyOverride(variantKey, key, value) {
28952
28952
  var m = key.match(OVR_TOKEN_RE);
28953
- if (m && typeof value === "string" && isHexColor(value)) {
28953
+ if (m && typeof value === "string" && isHexColor$1(value)) {
28954
28954
  var prefix = m[1];
28955
28955
  var overrideChannel = m[2];
28956
28956
  var level = m[3];
@@ -29087,7 +29087,7 @@ var ThemeModel = function ThemeModel() {
29087
29087
  // PRD: arbitrary-color-themes.md.
29088
29088
  var hexChannels = new Set();
29089
29089
  colorTypes.forEach(function (type) {
29090
- if (isHexColor(theme[type])) hexChannels.add(type);
29090
+ if (isHexColor$1(theme[type])) hexChannels.add(type);
29091
29091
  });
29092
29092
  var overrideTargetsHexChannel = function overrideTargetsHexChannel(key) {
29093
29093
  var m = key.match(/^(?:hover-)?(?:bg|text|border|from|via|to)-([a-z]+)-/);
@@ -29149,7 +29149,7 @@ var ThemeModel = function ThemeModel() {
29149
29149
  var cssVarsAll = {};
29150
29150
  colorTypes.forEach(function (type) {
29151
29151
  var channelValue = theme[type];
29152
- if (isHexColor(channelValue)) {
29152
+ if (isHexColor$1(channelValue)) {
29153
29153
  var shades = deriveShades(channelValue);
29154
29154
  if (shades) {
29155
29155
  for (var _i = 0, _Object$entries = Object.entries(shades); _i < _Object$entries.length; _i++) {
@@ -34780,7 +34780,7 @@ var CHANNELS$1 = [{
34780
34780
  label: "Neutral"
34781
34781
  }];
34782
34782
  function swatchDisplay(channelValue) {
34783
- if (isHexColor(channelValue)) {
34783
+ if (isHexColor$1(channelValue)) {
34784
34784
  return {
34785
34785
  style: {
34786
34786
  backgroundColor: channelValue
@@ -34850,7 +34850,7 @@ var CustomHexColorPane = function CustomHexColorPane(_ref) {
34850
34850
  error = _useState4[0],
34851
34851
  setError = _useState4[1];
34852
34852
  var normalized = useMemo(function () {
34853
- return normalizeHex(input);
34853
+ return normalizeHex$1(input);
34854
34854
  }, [input]);
34855
34855
  var isValid = !!normalized;
34856
34856
 
@@ -34949,7 +34949,7 @@ var SHADE_LEVELS = [{
34949
34949
  function channelSwatchProps(theme, themeVariant, channelKey) {
34950
34950
  var _theme$themeVariant;
34951
34951
  var baseValue = theme === null || theme === void 0 || (_theme$themeVariant = theme[themeVariant]) === null || _theme$themeVariant === void 0 ? void 0 : _theme$themeVariant[channelKey];
34952
- if (isHexColor(baseValue)) {
34952
+ if (isHexColor$1(baseValue)) {
34953
34953
  return {
34954
34954
  style: {
34955
34955
  backgroundColor: baseValue
@@ -34997,7 +34997,7 @@ var ChannelEditorModal = function ChannelEditorModal(_ref) {
34997
34997
  setActiveSlot = _useState6[1];
34998
34998
  var themeData = theme === null || theme === void 0 ? void 0 : theme[themeVariant];
34999
34999
  var baseValue = themeData === null || themeData === void 0 ? void 0 : themeData[activeChannel];
35000
- var baseHex = isHexColor(baseValue) ? baseValue : null;
35000
+ var baseHex = isHexColor$1(baseValue) ? baseValue : null;
35001
35001
  function expandChannel(channelKey) {
35002
35002
  setActiveChannel(channelKey);
35003
35003
  setActiveSlot("base");
@@ -36903,11 +36903,137 @@ var PanelThemeStudio = function PanelThemeStudio(_ref) {
36903
36903
  });
36904
36904
  };
36905
36905
 
36906
- // Color harmony helpers — inlined so dash-core can ship the new
36907
- // "From Colors" generator without first publishing matching
36908
- // exports from @trops/dash-react. Same math as the planned dash-react
36909
- // counterparts; can be replaced with a re-export once both ship in
36910
- // the same cycle.
36906
+ /**
36907
+ * themeGenerator.js
36908
+ *
36909
+ * Utility for generating themes via presets, random generation,
36910
+ * and color-harmony-based generation from a user-selected base color.
36911
+ */
36912
+ // All color math is inlined here (no @trops/dash-react import). This
36913
+ // file is reachable from Electron's main process via
36914
+ // `electron/controller/paletteToThemeMapper.js`. Importing dash-react
36915
+ // from a main-process reachable file pulls dash-react's renderer
36916
+ // bundle into the main bundle — that bundle has top-level browser
36917
+ // API access (`window.ResizeObserver` in CodeEditorVS) which throws
36918
+ // when required under Node. Keeping this module pure-JS / no-deps
36919
+ // breaks the chain.
36920
+
36921
+ var HEX_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
36922
+ function isHexColor(value) {
36923
+ return typeof value === "string" && HEX_RE.test(value.trim());
36924
+ }
36925
+ function normalizeHex(input) {
36926
+ if (typeof input !== "string") return null;
36927
+ var s = input.trim().toLowerCase();
36928
+ if (!s.startsWith("#")) s = "#".concat(s);
36929
+ if (!HEX_RE.test(s)) return null;
36930
+ if (s.length === 4) s = "#".concat(s[1]).concat(s[1]).concat(s[2]).concat(s[2]).concat(s[3]).concat(s[3]);else if (s.length === 5) s = "#".concat(s[1]).concat(s[1]).concat(s[2]).concat(s[2]).concat(s[3]).concat(s[3]);else if (s.length === 9) s = s.slice(0, 7);
36931
+ return s;
36932
+ }
36933
+ function hexToRgb(hex) {
36934
+ var n = normalizeHex(hex);
36935
+ if (!n) return null;
36936
+ var v = parseInt(n.slice(1), 16);
36937
+ return {
36938
+ r: v >> 16 & 0xff,
36939
+ g: v >> 8 & 0xff,
36940
+ b: v & 0xff
36941
+ };
36942
+ }
36943
+ function rgbToHex(_ref) {
36944
+ var r = _ref.r,
36945
+ g = _ref.g,
36946
+ b = _ref.b;
36947
+ var c = function c(x) {
36948
+ return Math.max(0, Math.min(255, Math.round(x)));
36949
+ };
36950
+ var h = function h(x) {
36951
+ return c(x).toString(16).padStart(2, "0");
36952
+ };
36953
+ return "#".concat(h(r)).concat(h(g)).concat(h(b));
36954
+ }
36955
+ function rgbToHsl(_ref2) {
36956
+ var r = _ref2.r,
36957
+ g = _ref2.g,
36958
+ b = _ref2.b;
36959
+ var R = r / 255,
36960
+ G = g / 255,
36961
+ B = b / 255;
36962
+ var max = Math.max(R, G, B),
36963
+ min = Math.min(R, G, B);
36964
+ var l = (max + min) / 2;
36965
+ var h = 0,
36966
+ s = 0;
36967
+ if (max !== min) {
36968
+ var d = max - min;
36969
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
36970
+ switch (max) {
36971
+ case R:
36972
+ h = (G - B) / d + (G < B ? 6 : 0);
36973
+ break;
36974
+ case G:
36975
+ h = (B - R) / d + 2;
36976
+ break;
36977
+ default:
36978
+ h = (R - G) / d + 4;
36979
+ }
36980
+ h *= 60;
36981
+ }
36982
+ return {
36983
+ h: h,
36984
+ s: s,
36985
+ l: l
36986
+ };
36987
+ }
36988
+ function hslToRgb(_ref3) {
36989
+ var h = _ref3.h,
36990
+ s = _ref3.s,
36991
+ l = _ref3.l;
36992
+ if (s === 0) {
36993
+ var v = l * 255;
36994
+ return {
36995
+ r: v,
36996
+ g: v,
36997
+ b: v
36998
+ };
36999
+ }
37000
+ var c = (1 - Math.abs(2 * l - 1)) * s;
37001
+ var x = c * (1 - Math.abs(h / 60 % 2 - 1));
37002
+ var m = l - c / 2;
37003
+ var rp, gp, bp;
37004
+ if (h < 60) {
37005
+ rp = c;
37006
+ gp = x;
37007
+ bp = 0;
37008
+ } else if (h < 120) {
37009
+ rp = x;
37010
+ gp = c;
37011
+ bp = 0;
37012
+ } else if (h < 180) {
37013
+ rp = 0;
37014
+ gp = c;
37015
+ bp = x;
37016
+ } else if (h < 240) {
37017
+ rp = 0;
37018
+ gp = x;
37019
+ bp = c;
37020
+ } else if (h < 300) {
37021
+ rp = x;
37022
+ gp = 0;
37023
+ bp = c;
37024
+ } else {
37025
+ rp = c;
37026
+ gp = 0;
37027
+ bp = x;
37028
+ }
37029
+ return {
37030
+ r: (rp + m) * 255,
37031
+ g: (gp + m) * 255,
37032
+ b: (bp + m) * 255
37033
+ };
37034
+ }
37035
+
37036
+ // Color harmony helpers — pure JS, no DOM/window access.
36911
37037
  function rotateHex(hex, deltaH) {
36912
37038
  var rgb = hexToRgb(hex);
36913
37039
  if (!rgb) return null;
@@ -37356,11 +37482,11 @@ var GENERATE_MODES = {
37356
37482
  // carry hex palettes.
37357
37483
  var PresetSwatch = function PresetSwatch(_ref) {
37358
37484
  var color = _ref.color;
37359
- if (isHexColor(color)) {
37485
+ if (isHexColor$1(color)) {
37360
37486
  return /*#__PURE__*/jsx("div", {
37361
37487
  className: "h-6 flex-1 rounded",
37362
37488
  style: {
37363
- backgroundColor: normalizeHex(color) || color
37489
+ backgroundColor: normalizeHex$1(color) || color
37364
37490
  }
37365
37491
  });
37366
37492
  }
@@ -37440,7 +37566,7 @@ var PresetGallery = function PresetGallery(_ref3) {
37440
37566
  var PaletteSwatch = function PaletteSwatch(_ref4) {
37441
37567
  var value = _ref4.value,
37442
37568
  label = _ref4.label;
37443
- var isHex = isHexColor(value);
37569
+ var isHex = isHexColor$1(value);
37444
37570
  return /*#__PURE__*/jsxs("div", {
37445
37571
  className: "flex flex-col items-center gap-1 flex-1",
37446
37572
  children: [/*#__PURE__*/jsx("div", {
@@ -37622,7 +37748,7 @@ var ColorHarmonyPicker = function ColorHarmonyPicker(_ref7) {
37622
37748
  className: "text-xs opacity-50",
37623
37749
  children: "Base Color"
37624
37750
  }), /*#__PURE__*/jsx(InlineHexPicker, {
37625
- selectedHex: isHexColor(selectedColor) ? selectedColor : null,
37751
+ selectedHex: isHexColor$1(selectedColor) ? selectedColor : null,
37626
37752
  onPick: function onPick(hex) {
37627
37753
  return setSelectedColor(hex);
37628
37754
  }