@trops/dash-react 1.0.54 → 1.0.55

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.js CHANGED
@@ -1231,6 +1231,107 @@ function contrastRatio(hexA, hexB) {
1231
1231
  return (lighter + 0.05) / (darker + 0.05);
1232
1232
  }
1233
1233
 
1234
+ /**
1235
+ * Color harmony helpers — emit hex partners for a base hex using
1236
+ * classic hue-rotation rules. Saturation + lightness are preserved
1237
+ * from the base, so the generated palette has consistent intensity.
1238
+ * `null` is returned when the input hex is invalid.
1239
+ */
1240
+ function rotateHex(hex, deltaH) {
1241
+ var rgb = hexToRgb(hex);
1242
+ if (!rgb) return null;
1243
+ var _rgbToHsl2 = rgbToHsl(rgb),
1244
+ h = _rgbToHsl2.h,
1245
+ s = _rgbToHsl2.s,
1246
+ l = _rgbToHsl2.l;
1247
+ var newH = ((h + deltaH) % 360 + 360) % 360;
1248
+ return rgbToHex(hslToRgb({
1249
+ h: newH,
1250
+ s: s,
1251
+ l: l
1252
+ }));
1253
+ }
1254
+ function complementHex(hex) {
1255
+ return rotateHex(hex, 180);
1256
+ }
1257
+ function analogousHexes(hex) {
1258
+ var a = rotateHex(hex, -30);
1259
+ var b = rotateHex(hex, 30);
1260
+ if (!a || !b) return null;
1261
+ return [a, b];
1262
+ }
1263
+ function triadicHexes(hex) {
1264
+ var a = rotateHex(hex, 120);
1265
+ var b = rotateHex(hex, 240);
1266
+ if (!a || !b) return null;
1267
+ return [a, b];
1268
+ }
1269
+ function splitComplementaryHexes(hex) {
1270
+ var a = rotateHex(hex, 150);
1271
+ var b = rotateHex(hex, 210);
1272
+ if (!a || !b) return null;
1273
+ return [a, b];
1274
+ }
1275
+ function tetradicHexes(hex) {
1276
+ var a = rotateHex(hex, 90);
1277
+ var b = rotateHex(hex, 180);
1278
+ var c = rotateHex(hex, 270);
1279
+ if (!a || !b || !c) return null;
1280
+ return [a, b, c];
1281
+ }
1282
+
1283
+ /**
1284
+ * Monochromatic palette: same hue as the base, varied saturation +
1285
+ * lightness. Returns `count` hexes evenly distributed across the
1286
+ * lightness band (0.15..0.85) with mild saturation variation.
1287
+ * Useful for single-hue brand palettes.
1288
+ */
1289
+ function monochromaticHexes(hex) {
1290
+ var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
1291
+ var rgb = hexToRgb(hex);
1292
+ if (!rgb) return null;
1293
+ var _rgbToHsl3 = rgbToHsl(rgb),
1294
+ h = _rgbToHsl3.h,
1295
+ s = _rgbToHsl3.s;
1296
+ var out = [];
1297
+ for (var i = 0; i < count; i++) {
1298
+ var t = count === 1 ? 0.5 : i / (count - 1);
1299
+ var l = 0.15 + t * 0.7;
1300
+ // Slightly dampen saturation at the extremes so the lightest
1301
+ // and darkest mono shades don't feel oversaturated.
1302
+ var sAdj = s * (1 - 0.3 * Math.abs(t - 0.5) * 2);
1303
+ out.push(rgbToHex(hslToRgb({
1304
+ h: h,
1305
+ s: sAdj,
1306
+ l: l
1307
+ })));
1308
+ }
1309
+ return out;
1310
+ }
1311
+
1312
+ /**
1313
+ * Apply an HSL nudge to a hex color. Accepts deltas in:
1314
+ * - dH: degrees [-360..360], wraps through 0/360
1315
+ * - dS: fraction [-1..1], clamped to [0..1] after add
1316
+ * - dL: fraction [-1..1], clamped to [0..1] after add
1317
+ */
1318
+ function adjustHsl(hex) {
1319
+ var dH = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1320
+ var dS = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1321
+ var dL = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1322
+ var rgb = hexToRgb(hex);
1323
+ if (!rgb) return null;
1324
+ var hsl = rgbToHsl(rgb);
1325
+ var h = ((hsl.h + dH) % 360 + 360) % 360;
1326
+ var s = Math.max(0, Math.min(1, hsl.s + dS));
1327
+ var l = Math.max(0, Math.min(1, hsl.l + dL));
1328
+ return rgbToHex(hslToRgb({
1329
+ h: h,
1330
+ s: s,
1331
+ l: l
1332
+ }));
1333
+ }
1334
+
1234
1335
  /**
1235
1336
  * Color families for the categorized picker grid. Each chromatic
1236
1337
  * family declares a hue range (inclusive, may wrap through 0/360);
@@ -5857,25 +5958,20 @@ function _toPropertyKey$j(t) { var i = _toPrimitive$j(t, "string"); return "symb
5857
5958
  function _toPrimitive$j(t, r) { if ("object" != _typeof$j(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$j(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5858
5959
  function _objectWithoutProperties$d(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$d(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
5859
5960
  function _objectWithoutPropertiesLoose$d(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
5860
- var OriginalResizeObserver = window.ResizeObserver;
5861
-
5862
- // Create a new ResizeObserver constructor
5863
- window.ResizeObserver = function (callback) {
5864
- var wrappedCallback = function wrappedCallback(entries, observer) {
5865
- window.requestAnimationFrame(function () {
5866
- callback(entries, observer);
5867
- });
5961
+ if (typeof window !== "undefined" && window.ResizeObserver) {
5962
+ var OriginalResizeObserver = window.ResizeObserver;
5963
+ window.ResizeObserver = function (callback) {
5964
+ var wrappedCallback = function wrappedCallback(entries, observer) {
5965
+ window.requestAnimationFrame(function () {
5966
+ callback(entries, observer);
5967
+ });
5968
+ };
5969
+ return new OriginalResizeObserver(wrappedCallback);
5868
5970
  };
5869
-
5870
- // Create an instance of the original ResizeObserver
5871
- // with the wrapped callback
5872
- return new OriginalResizeObserver(wrappedCallback);
5873
- };
5874
-
5875
- // Copy over static methods, if any
5876
- for (var staticMethod in OriginalResizeObserver) {
5877
- if (OriginalResizeObserver.hasOwnProperty(staticMethod)) {
5878
- window.ResizeObserver[staticMethod] = OriginalResizeObserver[staticMethod];
5971
+ for (var staticMethod in OriginalResizeObserver) {
5972
+ if (OriginalResizeObserver.hasOwnProperty(staticMethod)) {
5973
+ window.ResizeObserver[staticMethod] = OriginalResizeObserver[staticMethod];
5974
+ }
5879
5975
  }
5880
5976
  }
5881
5977
  function CodeEditorVS(_ref) {
@@ -6288,7 +6384,7 @@ function _setPrototypeOf$2(t, e) { return _setPrototypeOf$2 = Object.setPrototyp
6288
6384
  function _defineProperty$c(e, r, t) { return (r = _toPropertyKey$e(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6289
6385
  function _toPropertyKey$e(t) { var i = _toPrimitive$e(t, "string"); return "symbol" == _typeof$e(i) ? i : i + ""; }
6290
6386
  function _toPrimitive$e(t, r) { if ("object" != _typeof$e(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$e(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6291
- var mainApi = window.mainApi;
6387
+ var mainApi = typeof window !== "undefined" ? window.mainApi : undefined;
6292
6388
  /*#__PURE__*/(function (_React$Component) {
6293
6389
  function Header() {
6294
6390
  var _this;
@@ -9826,7 +9922,7 @@ var ColorSwatch = function ColorSwatch(_ref) {
9826
9922
  var hex = (color === null || color === void 0 ? void 0 : color.hex) || (color === null || color === void 0 ? void 0 : color.value) || "#888";
9827
9923
  var label = (color === null || color === void 0 ? void 0 : color.family) || (color === null || color === void 0 ? void 0 : color.name) || hex;
9828
9924
  return /*#__PURE__*/jsxs("div", {
9829
- className: "flex flex-col items-center gap-1.5 flex-1 cursor-pointer group transition-all ".concat(isDragOver ? "scale-110 ring-2 ring-blue-400 rounded-lg" : "", " ").concat(isDragging ? "opacity-40 scale-95" : "", " ").concat(focused ? "ring-2 ring-white/50 rounded-lg" : "", " ").concat(className),
9925
+ className: "flex flex-col items-center gap-1.5 flex-1 min-h-0 min-w-0 cursor-pointer group transition-all ".concat(isDragOver ? "scale-110 ring-2 ring-blue-400 rounded-lg" : "", " ").concat(isDragging ? "opacity-40 scale-95" : "", " ").concat(focused ? "ring-2 ring-white/50 rounded-lg" : "", " ").concat(className),
9830
9926
  onClick: onClick,
9831
9927
  title: "".concat(ROLE_LABELS[role] || role, " \u2014 drag to reorder or click to cycle"),
9832
9928
  draggable: true,
@@ -9841,7 +9937,7 @@ var ColorSwatch = function ColorSwatch(_ref) {
9841
9937
  "aria-label": "".concat(ROLE_LABELS[role], " color: ").concat(label, ". Drag to reorder or use arrow keys."),
9842
9938
  "aria-grabbed": isDragging,
9843
9939
  children: [/*#__PURE__*/jsx("div", {
9844
- className: "h-12 w-full rounded-lg transition-all group-hover:scale-105 group-hover:shadow-lg ring-1 ring-white/10 ".concat(isDragOver ? "shadow-lg shadow-blue-400/30" : ""),
9940
+ className: "flex-1 min-h-0 w-full rounded-lg transition-all group-hover:scale-105 group-hover:shadow-lg ring-1 ring-white/10 ".concat(isDragOver ? "shadow-lg shadow-blue-400/30" : ""),
9845
9941
  style: {
9846
9942
  backgroundColor: hex
9847
9943
  }
@@ -10005,14 +10101,11 @@ var PalettePreviewPane = function PalettePreviewPane(_ref2) {
10005
10101
  var hasReorder = onReorderRoles != null;
10006
10102
  var helpText = hasReorder ? "Drag colors to swap roles, or use arrow keys + Enter" : "Click a color to cycle its role assignment";
10007
10103
  return /*#__PURE__*/jsxs("div", {
10008
- className: "flex flex-col gap-3 ".concat(styles.string || "", " ").concat(className),
10104
+ className: "flex flex-col gap-3 flex-1 min-h-0 ".concat(styles.string || "", " ").concat(className),
10009
10105
  role: "group",
10010
10106
  "aria-label": "Color role assignments",
10011
- children: [/*#__PURE__*/jsx("span", {
10012
- className: "text-sm font-semibold opacity-50",
10013
- children: "Color Roles"
10014
- }), /*#__PURE__*/jsx("div", {
10015
- className: "flex flex-row gap-3",
10107
+ children: [/*#__PURE__*/jsx("div", {
10108
+ className: "flex flex-row gap-3 flex-1 min-h-0",
10016
10109
  role: "listbox",
10017
10110
  children: activeRoles.map(function (role, index) {
10018
10111
  var colorIndex = roleAssignments[role];
@@ -10152,7 +10245,6 @@ var ThemeFromUrlPane = function ThemeFromUrlPane(_ref) {
10152
10245
  var timeoutRef = useRef(null);
10153
10246
  var isValidUrl = URL_REGEX.test(url.trim());
10154
10247
  var canExtract = isValidUrl && !loading;
10155
- var canGenerate = palette && roleAssignments && !loading;
10156
10248
  var inputId = getUUID$1("", "theme-url-input");
10157
10249
  var handleExtract = useCallback(/*#__PURE__*/function () {
10158
10250
  var _handleExtract = _asyncToGenerator$2(/*#__PURE__*/_regenerator$2().m(function _callee() {
@@ -10265,13 +10357,19 @@ var ThemeFromUrlPane = function ThemeFromUrlPane(_ref) {
10265
10357
  })["catch"](function () {});
10266
10358
  }
10267
10359
  }
10268
- function handleGenerate() {
10360
+
10361
+ // Auto-commit: whenever the derived theme changes (after extract
10362
+ // or a role swap), push it up to the parent wizard. Drops the
10363
+ // explicit "Generate Theme" button — the parent's Create Theme
10364
+ // is the single commit action.
10365
+ useEffect(function () {
10269
10366
  if (!onGenerate || !generatedTheme) return;
10270
10367
  var theme = _objectSpread$2(_objectSpread$2({}, generatedTheme), {}, {
10271
10368
  name: suggestedName || deriveNameFromUrl(url)
10272
10369
  });
10273
10370
  onGenerate(theme);
10274
- }
10371
+ // eslint-disable-next-line react-hooks/exhaustive-deps
10372
+ }, [generatedTheme, suggestedName]);
10275
10373
  function handleKeyDown(e) {
10276
10374
  if (e.key === "Enter" && canExtract) {
10277
10375
  handleExtract();
@@ -10286,12 +10384,9 @@ var ThemeFromUrlPane = function ThemeFromUrlPane(_ref) {
10286
10384
  grow: false
10287
10385
  });
10288
10386
  return /*#__PURE__*/jsxs("div", {
10289
- className: inline ? "flex flex-col gap-4 ".concat(styles.string || "", " ").concat(className) : "flex flex-col gap-4 p-6 overflow-y-auto flex-1 min-h-0 ".concat(styles.string || "", " ").concat(className),
10290
- children: [/*#__PURE__*/jsx("span", {
10291
- className: "text-sm font-semibold opacity-50",
10292
- children: "Generate from Website"
10293
- }), /*#__PURE__*/jsxs("div", {
10294
- className: "flex flex-col gap-2",
10387
+ className: inline ? "flex flex-col gap-4 flex-1 min-h-0 ".concat(styles.string || "", " ").concat(className) : "flex flex-col gap-4 p-6 flex-1 min-h-0 ".concat(styles.string || "", " ").concat(className),
10388
+ children: [/*#__PURE__*/jsxs("div", {
10389
+ className: "flex flex-col gap-2 shrink-0",
10295
10390
  children: [/*#__PURE__*/jsxs("div", {
10296
10391
  className: "flex flex-row gap-2",
10297
10392
  children: [/*#__PURE__*/jsx("input", {
@@ -10358,22 +10453,14 @@ var ThemeFromUrlPane = function ThemeFromUrlPane(_ref) {
10358
10453
  children: "Try Again"
10359
10454
  })]
10360
10455
  })]
10361
- }), palette && roleAssignments && /*#__PURE__*/jsx(PalettePreviewPane, {
10362
- palette: palette,
10363
- roleAssignments: roleAssignments,
10364
- onSwapRole: handleSwapRole,
10365
- onReorderRoles: handleReorderRoles
10366
- }), canGenerate && generatedTheme && /*#__PURE__*/jsxs("button", {
10367
- type: "button",
10368
- onClick: handleGenerate,
10369
- className: "flex flex-row items-center justify-center gap-2 h-10 w-full ".concat(buttonStyles.string, " focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 ").concat(buttonStyles.focusRingColor || ""),
10370
- children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
10371
- icon: "wand-magic-sparkles",
10372
- className: "h-3.5 w-3.5"
10373
- }), /*#__PURE__*/jsx("span", {
10374
- className: "text-sm",
10375
- children: "Generate Theme"
10376
- })]
10456
+ }), palette && roleAssignments && /*#__PURE__*/jsx("div", {
10457
+ className: "flex-1 min-h-0 flex flex-col",
10458
+ children: /*#__PURE__*/jsx(PalettePreviewPane, {
10459
+ palette: palette,
10460
+ roleAssignments: roleAssignments,
10461
+ onSwapRole: handleSwapRole,
10462
+ onReorderRoles: handleReorderRoles
10463
+ })
10377
10464
  })]
10378
10465
  });
10379
10466
  };
@@ -11158,5 +11245,5 @@ if (process.env.NODE_ENV !== "development") {
11158
11245
  console.log = function () {};
11159
11246
  }
11160
11247
 
11161
- export { Accordion, Accordion2, Accordion3, Alert, Alert2, Alert3, AlertBanner, AlgoliaRefinementList, AlgoliaSearchBox, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Button, Button2, Button3, ButtonIcon, ButtonIcon2, ButtonIcon3, Caption, Caption2, Caption3, Card, Card2, Card3, Checkbox, Code, Code2, Code3, CodeEditorInline, CodeEditorVS, CodeRenderer, CommandPalette, ConfirmationModal, Container, DashPanel, DashPanel2, DashPanel3, DataList, Divider, Divider2, Divider3, DragComponent, Drawer, DropComponent, DropdownPanel, DropdownPanel2, DropdownPanel3, EmptyState, ErrorMessage, FormField, FormLabel, Heading, Heading2, Heading3, Icon, Icon2, Icon3, InputText, LayoutContainer, MainSection, Menu, Menu2, Menu3, MenuItem, MenuItem2, MenuItem3, MockAlgolia, MockLayout, MockWrapper, Modal, Navbar, PalettePreviewPane, Panel, Panel2, Panel3, Paragraph, Paragraph2, Paragraph3, ProgressBar, ProgressBar2, ProgressBar3, RadioGroup, RichText, SLACK_QUICK_REACTION_SHORTCODES, SearchInput, SelectInput, SelectMenu, SelectableCard, SettingsModal, Sidebar, Skeleton, Slider, StatCard, StatusBadge, Stepper, SubHeading, SubHeading2, SubHeading3, Switch, TAILWIND_PALETTE, TabbedNavbar, Table, Table2, Table3, Tabs, Tabs2, Tabs3, Tag, Tag2, Tag3, TextArea, ThemeContext, ThemeFromUrlPane, ThemePreviewBanner, ThemePreviewContext, ThemePreviewProvider, Toast, Toast2, Toast3, Toggle, Toggle2, Toggle3, Tooltip, WS_STATES, WebSocketStatus, WidgetChrome, WidgetContext, capitalizeFirstLetter, colorNames, colorTypes, contrastRatio, deepCopy, deriveShades, getCSSStyleForClassname, getClassForObjectType, getColorFamilies, getCuratedColorGrid, getDefaultStylesForItem, getRandomInt, getStyleName, getStylesForItem, getUUID$1 as getUUID, hexForTailwindClass, hexToRgb, hslToRgb, isHexColor, isObject, mock, mockText, normalizeHex, objectTypes, rgbToHex, rgbToHsl, shades, slackEmojiForName, styleClassNames, tailwindHeightFractions, themeObjects, themeVariants, useLazyEnrichment, useSidebar, useThemePreview, withRouter };
11248
+ export { Accordion, Accordion2, Accordion3, Alert, Alert2, Alert3, AlertBanner, AlgoliaRefinementList, AlgoliaSearchBox, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Button, Button2, Button3, ButtonIcon, ButtonIcon2, ButtonIcon3, Caption, Caption2, Caption3, Card, Card2, Card3, Checkbox, Code, Code2, Code3, CodeEditorInline, CodeEditorVS, CodeRenderer, CommandPalette, ConfirmationModal, Container, DashPanel, DashPanel2, DashPanel3, DataList, Divider, Divider2, Divider3, DragComponent, Drawer, DropComponent, DropdownPanel, DropdownPanel2, DropdownPanel3, EmptyState, ErrorMessage, FormField, FormLabel, Heading, Heading2, Heading3, Icon, Icon2, Icon3, InputText, LayoutContainer, MainSection, Menu, Menu2, Menu3, MenuItem, MenuItem2, MenuItem3, MockAlgolia, MockLayout, MockWrapper, Modal, Navbar, PalettePreviewPane, Panel, Panel2, Panel3, Paragraph, Paragraph2, Paragraph3, ProgressBar, ProgressBar2, ProgressBar3, RadioGroup, RichText, SLACK_QUICK_REACTION_SHORTCODES, SearchInput, SelectInput, SelectMenu, SelectableCard, SettingsModal, Sidebar, Skeleton, Slider, StatCard, StatusBadge, Stepper, SubHeading, SubHeading2, SubHeading3, Switch, TAILWIND_PALETTE, TabbedNavbar, Table, Table2, Table3, Tabs, Tabs2, Tabs3, Tag, Tag2, Tag3, TextArea, ThemeContext, ThemeFromUrlPane, ThemePreviewBanner, ThemePreviewContext, ThemePreviewProvider, Toast, Toast2, Toast3, Toggle, Toggle2, Toggle3, Tooltip, WS_STATES, WebSocketStatus, WidgetChrome, WidgetContext, adjustHsl, analogousHexes, capitalizeFirstLetter, colorNames, colorTypes, complementHex, contrastRatio, deepCopy, deriveShades, getCSSStyleForClassname, getClassForObjectType, getColorFamilies, getCuratedColorGrid, getDefaultStylesForItem, getRandomInt, getStyleName, getStylesForItem, getUUID$1 as getUUID, hexForTailwindClass, hexToRgb, hslToRgb, isHexColor, isObject, mock, mockText, monochromaticHexes, normalizeHex, objectTypes, rgbToHex, rgbToHsl, shades, slackEmojiForName, splitComplementaryHexes, styleClassNames, tailwindHeightFractions, tetradicHexes, themeObjects, themeVariants, triadicHexes, useLazyEnrichment, useSidebar, useThemePreview, withRouter };
11162
11249
  //# sourceMappingURL=index.js.map