@trops/dash-react 1.0.51 → 1.0.52

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
@@ -3,7 +3,7 @@ import * as SolidIcons from '@fortawesome/free-solid-svg-icons';
3
3
  import { faCheck } from '@fortawesome/free-solid-svg-icons';
4
4
  export * from '@fortawesome/free-solid-svg-icons';
5
5
  import * as BrandIcons from '@fortawesome/free-brands-svg-icons';
6
- import React, { createContext, useContext, useState, useCallback, useMemo, createElement, useEffect, useRef, Fragment, Children } from 'react';
6
+ import React, { createContext, useContext, useState, useCallback, useMemo, useRef, useEffect, createElement, Fragment, Children } from 'react';
7
7
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
8
8
  import { Dialog, Transition } from '@headlessui/react';
9
9
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@@ -30,27 +30,28 @@ var ThemeContext = /*#__PURE__*/createContext({
30
30
  rawThemes: null
31
31
  });
32
32
 
33
+ function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$j(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
33
34
  function _typeof$K(o) { "@babel/helpers - typeof"; return _typeof$K = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$K(o); }
34
35
  function ownKeys$E(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
35
36
  function _objectSpread$E(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$E(Object(t), !0).forEach(function (r) { _defineProperty$F(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$E(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
36
37
  function _defineProperty$F(e, r, t) { return (r = _toPropertyKey$J(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
37
38
  function _toPropertyKey$J(t) { var i = _toPrimitive$J(t, "string"); return "symbol" == _typeof$K(i) ? i : i + ""; }
38
39
  function _toPrimitive$J(t, r) { if ("object" != _typeof$K(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$K(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
39
- function _slicedToArray$e(r, e) { return _arrayWithHoles$e(r) || _iterableToArrayLimit$e(r, e) || _unsupportedIterableToArray$i(r, e) || _nonIterableRest$e(); }
40
- function _nonIterableRest$e() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
41
- function _unsupportedIterableToArray$i(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$i(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$i(r, a) : void 0; } }
42
- function _arrayLikeToArray$i(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
43
- function _iterableToArrayLimit$e(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
44
- function _arrayWithHoles$e(r) { if (Array.isArray(r)) return r; }
40
+ function _slicedToArray$f(r, e) { return _arrayWithHoles$f(r) || _iterableToArrayLimit$f(r, e) || _unsupportedIterableToArray$j(r, e) || _nonIterableRest$f(); }
41
+ function _nonIterableRest$f() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
42
+ function _unsupportedIterableToArray$j(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$j(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$j(r, a) : void 0; } }
43
+ function _arrayLikeToArray$j(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
44
+ function _iterableToArrayLimit$f(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
45
+ function _arrayWithHoles$f(r) { if (Array.isArray(r)) return r; }
45
46
  var ThemePreviewProvider = function ThemePreviewProvider(_ref) {
46
47
  var children = _ref.children;
47
48
  var parentCtx = useContext(ThemeContext);
48
49
  var _useState = useState(null),
49
- _useState2 = _slicedToArray$e(_useState, 2),
50
+ _useState2 = _slicedToArray$f(_useState, 2),
50
51
  previewTheme = _useState2[0],
51
52
  setPreviewThemeState = _useState2[1];
52
53
  var _useState3 = useState(true),
53
- _useState4 = _slicedToArray$e(_useState3, 2),
54
+ _useState4 = _slicedToArray$f(_useState3, 2),
54
55
  showPreview = _useState4[0],
55
56
  setShowPreview = _useState4[1];
56
57
  var isPreview = previewTheme !== null && showPreview;
@@ -76,6 +77,70 @@ var ThemePreviewProvider = function ThemePreviewProvider(_ref) {
76
77
  });
77
78
  }, [parentCtx, isPreview, previewTheme]);
78
79
 
80
+ // Inject CSS custom properties when the active theme has a
81
+ // `cssVars` map. ThemeModel emits this for themes with
82
+ // arbitrary-color (hex) channels — see PRD
83
+ // `arbitrary-color-themes.md`, FR-003. Tracks which variables we
84
+ // wrote so a transition theme-with-cssVars → theme-without
85
+ // cleanly removes them (no flash: we set the new set before
86
+ // removing the stale ones).
87
+ var writtenVarsRef = useRef(new Set());
88
+ useEffect(function () {
89
+ var _ctxValue$currentThem;
90
+ var cssVars = ctxValue === null || ctxValue === void 0 || (_ctxValue$currentThem = ctxValue.currentTheme) === null || _ctxValue$currentThem === void 0 ? void 0 : _ctxValue$currentThem.cssVars;
91
+ var root = typeof document !== "undefined" ? document.documentElement : null;
92
+ if (!root) return undefined;
93
+ var newSet = new Set();
94
+ if (cssVars && _typeof$K(cssVars) === "object") {
95
+ for (var _i = 0, _Object$entries = Object.entries(cssVars); _i < _Object$entries.length; _i++) {
96
+ var _Object$entries$_i = _slicedToArray$f(_Object$entries[_i], 2),
97
+ varName = _Object$entries$_i[0],
98
+ value = _Object$entries$_i[1];
99
+ root.style.setProperty(varName, value);
100
+ newSet.add(varName);
101
+ }
102
+ }
103
+ // Remove any vars from a prior theme that aren't in the new set.
104
+ var _iterator = _createForOfIteratorHelper$2(writtenVarsRef.current),
105
+ _step;
106
+ try {
107
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
108
+ var _varName = _step.value;
109
+ if (!newSet.has(_varName)) {
110
+ root.style.removeProperty(_varName);
111
+ }
112
+ }
113
+ } catch (err) {
114
+ _iterator.e(err);
115
+ } finally {
116
+ _iterator.f();
117
+ }
118
+ writtenVarsRef.current = newSet;
119
+ return undefined;
120
+ }, [ctxValue]);
121
+
122
+ // Final cleanup on unmount — remove any vars still attached to
123
+ // :root so the theme system leaves no stylesheet residue.
124
+ useEffect(function () {
125
+ return function () {
126
+ var root = typeof document !== "undefined" ? document.documentElement : null;
127
+ if (!root) return;
128
+ var _iterator2 = _createForOfIteratorHelper$2(writtenVarsRef.current),
129
+ _step2;
130
+ try {
131
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
132
+ var varName = _step2.value;
133
+ root.style.removeProperty(varName);
134
+ }
135
+ } catch (err) {
136
+ _iterator2.e(err);
137
+ } finally {
138
+ _iterator2.f();
139
+ }
140
+ writtenVarsRef.current = new Set();
141
+ };
142
+ }, []);
143
+
79
144
  // Preview control bag — passed to render-prop children and available via useThemePreview
80
145
  var previewControls = useMemo(function () {
81
146
  return {
@@ -508,12 +573,12 @@ var styleClassNames = {
508
573
 
509
574
  var _themeObjects$BUTTON, _themeObjects$BUTTON_, _themeObjects$BUTTON_2, _themeObjects$BUTTON_3, _themeObjects$BUTTON_4, _themeObjects$BUTTON_5, _themeObjects$MENU_IT, _themeObjects$TABS_TR, _colorMap;
510
575
  function _typeof$J(o) { "@babel/helpers - typeof"; return _typeof$J = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$J(o); }
511
- function _toConsumableArray$5(r) { return _arrayWithoutHoles$5(r) || _iterableToArray$5(r) || _unsupportedIterableToArray$h(r) || _nonIterableSpread$5(); }
576
+ function _toConsumableArray$5(r) { return _arrayWithoutHoles$5(r) || _iterableToArray$5(r) || _unsupportedIterableToArray$i(r) || _nonIterableSpread$5(); }
512
577
  function _nonIterableSpread$5() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
513
- function _unsupportedIterableToArray$h(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$h(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$h(r, a) : void 0; } }
578
+ function _unsupportedIterableToArray$i(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$i(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$i(r, a) : void 0; } }
514
579
  function _iterableToArray$5(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
515
- function _arrayWithoutHoles$5(r) { if (Array.isArray(r)) return _arrayLikeToArray$h(r); }
516
- function _arrayLikeToArray$h(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
580
+ function _arrayWithoutHoles$5(r) { if (Array.isArray(r)) return _arrayLikeToArray$i(r); }
581
+ function _arrayLikeToArray$i(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
517
582
  function ownKeys$D(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
518
583
  function _objectSpread$D(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$D(Object(t), !0).forEach(function (r) { _defineProperty$E(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$D(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
519
584
  function _defineProperty$E(e, r, t) { return (r = _toPropertyKey$I(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -919,6 +984,252 @@ var getDefaultStylesForItem = function getDefaultStylesForItem(itemName) {
919
984
  return itemName in colorMap ? _objectSpread$D({}, colorMap[itemName]) : {};
920
985
  };
921
986
 
987
+ function _slicedToArray$e(r, e) { return _arrayWithHoles$e(r) || _iterableToArrayLimit$e(r, e) || _unsupportedIterableToArray$h(r, e) || _nonIterableRest$e(); }
988
+ function _nonIterableRest$e() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
989
+ function _unsupportedIterableToArray$h(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$h(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$h(r, a) : void 0; } }
990
+ function _arrayLikeToArray$h(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
991
+ function _iterableToArrayLimit$e(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
992
+ function _arrayWithHoles$e(r) { if (Array.isArray(r)) return r; }
993
+ /**
994
+ * colorMath — pure-function helpers for working with hex colors.
995
+ *
996
+ * Used by the theme system to support arbitrary-color themes (PRD:
997
+ * `dash-electron/docs/requirements/prd/arbitrary-color-themes.md`).
998
+ * Standalone — no React, no dependencies beyond JavaScript primitives.
999
+ *
1000
+ * Exports:
1001
+ * - isHexColor(value) → boolean
1002
+ * - normalizeHex(input) → "#rrggbb" or null
1003
+ * - hexToRgb(hex) → { r, g, b } or null
1004
+ * - rgbToHex({r,g,b}) → "#rrggbb"
1005
+ * - rgbToHsl({r,g,b}) → { h, s, l } (h 0..360, s/l 0..1)
1006
+ * - hslToRgb({h,s,l}) → { r, g, b } (0..255)
1007
+ * - deriveShades(hex) → { 50, 100, 200, ..., 950 } hex map
1008
+ * - contrastRatio(hexA, hexB) → 1..21
1009
+ */
1010
+
1011
+ var HEX_REGEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
1012
+ function isHexColor(value) {
1013
+ return typeof value === "string" && HEX_REGEX.test(value.trim());
1014
+ }
1015
+
1016
+ /**
1017
+ * Normalize a user-supplied hex string. Accepts `4A154B`, `#4A154B`,
1018
+ * `#abc`, `#abcd`, `#aabbccdd`. Returns lowercase `#rrggbb` (alpha
1019
+ * dropped) or null if invalid.
1020
+ */
1021
+ function normalizeHex(input) {
1022
+ if (typeof input !== "string") return null;
1023
+ var s = input.trim().toLowerCase();
1024
+ if (!s.startsWith("#")) s = "#".concat(s);
1025
+ if (!HEX_REGEX.test(s)) return null;
1026
+ if (s.length === 4) {
1027
+ // #rgb → #rrggbb
1028
+ s = "#".concat(s[1]).concat(s[1]).concat(s[2]).concat(s[2]).concat(s[3]).concat(s[3]);
1029
+ } else if (s.length === 5) {
1030
+ // #rgba → #rrggbb (drop alpha)
1031
+ s = "#".concat(s[1]).concat(s[1]).concat(s[2]).concat(s[2]).concat(s[3]).concat(s[3]);
1032
+ } else if (s.length === 9) {
1033
+ // #rrggbbaa → #rrggbb
1034
+ s = s.slice(0, 7);
1035
+ }
1036
+ return s;
1037
+ }
1038
+ function hexToRgb(hex) {
1039
+ var normalized = normalizeHex(hex);
1040
+ if (!normalized) return null;
1041
+ var n = parseInt(normalized.slice(1), 16);
1042
+ return {
1043
+ r: n >> 16 & 0xff,
1044
+ g: n >> 8 & 0xff,
1045
+ b: n & 0xff
1046
+ };
1047
+ }
1048
+ function rgbToHex(_ref) {
1049
+ var r = _ref.r,
1050
+ g = _ref.g,
1051
+ b = _ref.b;
1052
+ var clamp = function clamp(v) {
1053
+ return Math.max(0, Math.min(255, Math.round(v)));
1054
+ };
1055
+ var toHex = function toHex(v) {
1056
+ return clamp(v).toString(16).padStart(2, "0");
1057
+ };
1058
+ return "#".concat(toHex(r)).concat(toHex(g)).concat(toHex(b));
1059
+ }
1060
+ function rgbToHsl(_ref2) {
1061
+ var r = _ref2.r,
1062
+ g = _ref2.g,
1063
+ b = _ref2.b;
1064
+ var R = r / 255;
1065
+ var G = g / 255;
1066
+ var B = b / 255;
1067
+ var max = Math.max(R, G, B);
1068
+ var min = Math.min(R, G, B);
1069
+ var l = (max + min) / 2;
1070
+ var h = 0;
1071
+ var s = 0;
1072
+ if (max !== min) {
1073
+ var d = max - min;
1074
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
1075
+ switch (max) {
1076
+ case R:
1077
+ h = (G - B) / d + (G < B ? 6 : 0);
1078
+ break;
1079
+ case G:
1080
+ h = (B - R) / d + 2;
1081
+ break;
1082
+ default:
1083
+ h = (R - G) / d + 4;
1084
+ break;
1085
+ }
1086
+ h *= 60;
1087
+ }
1088
+ return {
1089
+ h: h,
1090
+ s: s,
1091
+ l: l
1092
+ };
1093
+ }
1094
+ function hslToRgb(_ref3) {
1095
+ var h = _ref3.h,
1096
+ s = _ref3.s,
1097
+ l = _ref3.l;
1098
+ if (s === 0) {
1099
+ var v = l * 255;
1100
+ return {
1101
+ r: v,
1102
+ g: v,
1103
+ b: v
1104
+ };
1105
+ }
1106
+ var c = (1 - Math.abs(2 * l - 1)) * s;
1107
+ var x = c * (1 - Math.abs(h / 60 % 2 - 1));
1108
+ var m = l - c / 2;
1109
+ var rp;
1110
+ var gp;
1111
+ var bp;
1112
+ if (h < 60) {
1113
+ rp = c;
1114
+ gp = x;
1115
+ bp = 0;
1116
+ } else if (h < 120) {
1117
+ rp = x;
1118
+ gp = c;
1119
+ bp = 0;
1120
+ } else if (h < 180) {
1121
+ rp = 0;
1122
+ gp = c;
1123
+ bp = x;
1124
+ } else if (h < 240) {
1125
+ rp = 0;
1126
+ gp = x;
1127
+ bp = c;
1128
+ } else if (h < 300) {
1129
+ rp = x;
1130
+ gp = 0;
1131
+ bp = c;
1132
+ } else {
1133
+ rp = c;
1134
+ gp = 0;
1135
+ bp = x;
1136
+ }
1137
+ return {
1138
+ r: (rp + m) * 255,
1139
+ g: (gp + m) * 255,
1140
+ b: (bp + m) * 255
1141
+ };
1142
+ }
1143
+
1144
+ /**
1145
+ * Derive an 11-shade Tailwind-like palette from a base hex.
1146
+ *
1147
+ * Returns `{ "50": "#…", "100": "#…", …, "900": "#…", "950": "#…" }`.
1148
+ *
1149
+ * Strategy: keep the input's hue + saturation; vary lightness across
1150
+ * fixed targets that approximate Tailwind's stock palette structure.
1151
+ * Shade `500` preserves the user's lightness (so picking a known
1152
+ * Tailwind hex like `#3b82f6` produces a `500` close to Tailwind
1153
+ * `blue-500`). Lighter shades approach white; darker approach black.
1154
+ *
1155
+ * For very dark (`l < 0.20`) or very light (`l > 0.80`) inputs we
1156
+ * snap shade `500` to `0.50` so the ramp stays balanced — otherwise
1157
+ * the input might land at e.g. shade `900` and produce no visible
1158
+ * darker steps.
1159
+ */
1160
+ function deriveShades(hex) {
1161
+ var rgb = hexToRgb(hex);
1162
+ if (!rgb) return null;
1163
+ var _rgbToHsl = rgbToHsl(rgb),
1164
+ h = _rgbToHsl.h,
1165
+ s = _rgbToHsl.s,
1166
+ l = _rgbToHsl.l;
1167
+ var baseL = l < 0.2 || l > 0.8 ? 0.5 : l;
1168
+ var targets = {
1169
+ 50: 0.96,
1170
+ 100: 0.9,
1171
+ 200: 0.8,
1172
+ 300: 0.68,
1173
+ 400: 0.55,
1174
+ 500: baseL,
1175
+ 600: 0.42,
1176
+ 700: 0.32,
1177
+ 800: 0.22,
1178
+ 900: 0.13,
1179
+ 950: 0.08
1180
+ };
1181
+ // Slight saturation curve: lighter shades fade saturation toward
1182
+ // white-ish; darker shades fade toward black-ish. Mirrors how
1183
+ // Tailwind's stock palette feels.
1184
+ var satFor = function satFor(targetL) {
1185
+ if (targetL > 0.85) return s * 0.4;
1186
+ if (targetL < 0.15) return s * 0.7;
1187
+ return s;
1188
+ };
1189
+ var out = {};
1190
+ for (var _i = 0, _Object$entries = Object.entries(targets); _i < _Object$entries.length; _i++) {
1191
+ var _Object$entries$_i = _slicedToArray$e(_Object$entries[_i], 2),
1192
+ shade = _Object$entries$_i[0],
1193
+ targetL = _Object$entries$_i[1];
1194
+ var rgbOut = hslToRgb({
1195
+ h: h,
1196
+ s: satFor(targetL),
1197
+ l: targetL
1198
+ });
1199
+ out[shade] = rgbToHex(rgbOut);
1200
+ }
1201
+ return out;
1202
+ }
1203
+
1204
+ /**
1205
+ * WCAG-relative luminance (0..1). Used by `contrastRatio`.
1206
+ */
1207
+ function relativeLuminance(_ref4) {
1208
+ var r = _ref4.r,
1209
+ g = _ref4.g,
1210
+ b = _ref4.b;
1211
+ var channel = function channel(v) {
1212
+ var sRGB = v / 255;
1213
+ return sRGB <= 0.03928 ? sRGB / 12.92 : Math.pow((sRGB + 0.055) / 1.055, 2.4);
1214
+ };
1215
+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
1216
+ }
1217
+
1218
+ /**
1219
+ * WCAG contrast ratio between two hex colors. Returns a value in
1220
+ * [1, 21]. WCAG AA target is 4.5 for normal text; AAA is 7.
1221
+ */
1222
+ function contrastRatio(hexA, hexB) {
1223
+ var rgbA = hexToRgb(hexA);
1224
+ var rgbB = hexToRgb(hexB);
1225
+ if (!rgbA || !rgbB) return null;
1226
+ var lA = relativeLuminance(rgbA);
1227
+ var lB = relativeLuminance(rgbB);
1228
+ var lighter = Math.max(lA, lB);
1229
+ var darker = Math.min(lA, lB);
1230
+ return (lighter + 0.05) / (darker + 0.05);
1231
+ }
1232
+
922
1233
  function _typeof$I(o) { "@babel/helpers - typeof"; return _typeof$I = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$I(o); }
923
1234
  /**
924
1235
  * deepCopy
@@ -10380,5 +10691,5 @@ if (process.env.NODE_ENV !== "development") {
10380
10691
  console.log = function () {};
10381
10692
  }
10382
10693
 
10383
- 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, 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, deepCopy, getCSSStyleForClassname, getClassForObjectType, getDefaultStylesForItem, getRandomInt, getStyleName, getStylesForItem, getUUID$1 as getUUID, isObject, mock, mockText, objectTypes, shades, slackEmojiForName, styleClassNames, tailwindHeightFractions, themeObjects, themeVariants, useLazyEnrichment, useSidebar, useThemePreview, withRouter };
10694
+ 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, 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, getDefaultStylesForItem, getRandomInt, getStyleName, getStylesForItem, getUUID$1 as getUUID, hexToRgb, hslToRgb, isHexColor, isObject, mock, mockText, normalizeHex, objectTypes, rgbToHex, rgbToHsl, shades, slackEmojiForName, styleClassNames, tailwindHeightFractions, themeObjects, themeVariants, useLazyEnrichment, useSidebar, useThemePreview, withRouter };
10384
10695
  //# sourceMappingURL=index.js.map