@noirmd/previewer 2.1.2 → 2.1.3

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/vanilla.js CHANGED
@@ -11979,6 +11979,22 @@ var hovergalleryDirective = ({ props, slots }) => {
11979
11979
  var hovergallery_default = hovergalleryDirective;
11980
11980
 
11981
11981
  // vanilla/directives/chat.ts
11982
+ var CHAT_THEME_TOKENS = /* @__PURE__ */ new Set([
11983
+ "primary",
11984
+ "secondary",
11985
+ "accent",
11986
+ "neutral",
11987
+ "info",
11988
+ "success",
11989
+ "warning",
11990
+ "error"
11991
+ ]);
11992
+ function isArbitraryColor(value) {
11993
+ if (CHAT_THEME_TOKENS.has(value)) return false;
11994
+ if (/^(#|rgb|hsl|oklch|oklab|lab|lch|color\()/i.test(value)) return true;
11995
+ if (/^[a-zA-Z]+$/.test(value)) return true;
11996
+ return false;
11997
+ }
11982
11998
  var chatItemDirective = ({ props, renderSlot }) => {
11983
11999
  const side = props.side === "end" ? "end" : "start";
11984
12000
  const wrap = document.createElement("div");
@@ -12009,8 +12025,14 @@ var chatItemDirective = ({ props, renderSlot }) => {
12009
12025
  avatar.appendChild(img);
12010
12026
  wrap.appendChild(avatar);
12011
12027
  }
12028
+ const isThemeToken = CHAT_THEME_TOKENS.has(props.color || "");
12029
+ const colorClass = isThemeToken ? ` nr-chat__bubble--${props.color}` : "";
12012
12030
  const bubble = document.createElement("div");
12013
- bubble.className = `nr-chat__bubble${props.color ? ` nr-chat__bubble--${props.color}` : ""}`;
12031
+ bubble.className = `nr-chat__bubble${colorClass}`;
12032
+ if (props.color && isArbitraryColor(props.color) && !isThemeToken) {
12033
+ bubble.style.background = props.color;
12034
+ bubble.style.color = "white";
12035
+ }
12014
12036
  bubble.appendChild(renderSlot("default"));
12015
12037
  wrap.appendChild(bubble);
12016
12038
  if (props.footer) {
@@ -12132,15 +12154,32 @@ var richlistDirective = ({ props, renderSlot }) => {
12132
12154
  var richlist_default = richlistDirective;
12133
12155
 
12134
12156
  // vanilla/directives/stat.ts
12157
+ var STAT_THEME_TOKENS = /* @__PURE__ */ new Set([
12158
+ "primary",
12159
+ "secondary",
12160
+ "info",
12161
+ "success",
12162
+ "warning",
12163
+ "error"
12164
+ ]);
12165
+ function isArbitraryColor2(value) {
12166
+ if (STAT_THEME_TOKENS.has(value)) return false;
12167
+ if (/^(#|rgb|hsl|oklch|oklab|lab|lch|color\()/i.test(value)) return true;
12168
+ if (/^[a-zA-Z]+$/.test(value)) return true;
12169
+ return false;
12170
+ }
12135
12171
  var statDirective = ({ props }) => {
12136
- const colorClass = props.color ? ` nr-stat--${props.color}` : "";
12172
+ const isThemeToken = STAT_THEME_TOKENS.has(props.color || "");
12173
+ const colorClass = isThemeToken ? ` nr-stat--${props.color}` : "";
12137
12174
  const stat = document.createElement("div");
12138
12175
  stat.className = `nr-stat${colorClass}`;
12139
12176
  if (props.class) stat.classList.add(...props.class.split(/\s+/).filter(Boolean));
12140
12177
  if (props.style) stat.setAttribute("style", props.style);
12178
+ const useInlineColor = props.color && isArbitraryColor2(props.color) && !isThemeToken;
12141
12179
  if (props.icon) {
12142
12180
  const figure = document.createElement("div");
12143
12181
  figure.className = "nr-stat__figure";
12182
+ if (useInlineColor) figure.style.color = props.color;
12144
12183
  figure.appendChild(createIcon(props.icon));
12145
12184
  stat.appendChild(figure);
12146
12185
  }
@@ -12153,6 +12192,7 @@ var statDirective = ({ props }) => {
12153
12192
  if (props.value) {
12154
12193
  const value = document.createElement("div");
12155
12194
  value.className = "nr-stat__value";
12195
+ if (useInlineColor) value.style.color = props.color;
12156
12196
  value.textContent = props.value;
12157
12197
  stat.appendChild(value);
12158
12198
  }
@@ -12279,7 +12319,9 @@ function processElements(elements, ctx, allElements) {
12279
12319
  }
12280
12320
  } else {
12281
12321
  const grid = document.createElement("div");
12282
- grid.className = BATCHED_DIRECTIVES[cards[0].directiveType];
12322
+ const gridClass = BATCHED_DIRECTIVES[cards[0].directiveType];
12323
+ const align = cards[0].props?.align;
12324
+ grid.className = align === "center" || align === "right" ? `${gridClass} ${gridClass}--${align}` : gridClass;
12283
12325
  for (const card of cards) {
12284
12326
  const rendered = renderElement(card, ctx, allElements);
12285
12327
  if (rendered) grid.appendChild(rendered);