@noirmd/previewer 2.1.2 → 2.1.4

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.cjs CHANGED
@@ -12008,6 +12008,22 @@ var hovergalleryDirective = ({ props, slots }) => {
12008
12008
  var hovergallery_default = hovergalleryDirective;
12009
12009
 
12010
12010
  // vanilla/directives/chat.ts
12011
+ var CHAT_THEME_TOKENS = /* @__PURE__ */ new Set([
12012
+ "primary",
12013
+ "secondary",
12014
+ "accent",
12015
+ "neutral",
12016
+ "info",
12017
+ "success",
12018
+ "warning",
12019
+ "error"
12020
+ ]);
12021
+ function isArbitraryColor(value) {
12022
+ if (CHAT_THEME_TOKENS.has(value)) return false;
12023
+ if (/^(#|rgb|hsl|oklch|oklab|lab|lch|color\()/i.test(value)) return true;
12024
+ if (/^[a-zA-Z]+$/.test(value)) return true;
12025
+ return false;
12026
+ }
12011
12027
  var chatItemDirective = ({ props, renderSlot }) => {
12012
12028
  const side = props.side === "end" ? "end" : "start";
12013
12029
  const wrap = document.createElement("div");
@@ -12038,8 +12054,14 @@ var chatItemDirective = ({ props, renderSlot }) => {
12038
12054
  avatar.appendChild(img);
12039
12055
  wrap.appendChild(avatar);
12040
12056
  }
12057
+ const isThemeToken = CHAT_THEME_TOKENS.has(props.color || "");
12058
+ const colorClass = isThemeToken ? ` nr-chat__bubble--${props.color}` : "";
12041
12059
  const bubble = document.createElement("div");
12042
- bubble.className = `nr-chat__bubble${props.color ? ` nr-chat__bubble--${props.color}` : ""}`;
12060
+ bubble.className = `nr-chat__bubble${colorClass}`;
12061
+ if (props.color && isArbitraryColor(props.color) && !isThemeToken) {
12062
+ bubble.style.background = props.color;
12063
+ bubble.style.color = "white";
12064
+ }
12043
12065
  bubble.appendChild(renderSlot("default"));
12044
12066
  wrap.appendChild(bubble);
12045
12067
  if (props.footer) {
@@ -12161,15 +12183,32 @@ var richlistDirective = ({ props, renderSlot }) => {
12161
12183
  var richlist_default = richlistDirective;
12162
12184
 
12163
12185
  // vanilla/directives/stat.ts
12186
+ var STAT_THEME_TOKENS = /* @__PURE__ */ new Set([
12187
+ "primary",
12188
+ "secondary",
12189
+ "info",
12190
+ "success",
12191
+ "warning",
12192
+ "error"
12193
+ ]);
12194
+ function isArbitraryColor2(value) {
12195
+ if (STAT_THEME_TOKENS.has(value)) return false;
12196
+ if (/^(#|rgb|hsl|oklch|oklab|lab|lch|color\()/i.test(value)) return true;
12197
+ if (/^[a-zA-Z]+$/.test(value)) return true;
12198
+ return false;
12199
+ }
12164
12200
  var statDirective = ({ props }) => {
12165
- const colorClass = props.color ? ` nr-stat--${props.color}` : "";
12201
+ const isThemeToken = STAT_THEME_TOKENS.has(props.color || "");
12202
+ const colorClass = isThemeToken ? ` nr-stat--${props.color}` : "";
12166
12203
  const stat = document.createElement("div");
12167
12204
  stat.className = `nr-stat${colorClass}`;
12168
12205
  if (props.class) stat.classList.add(...props.class.split(/\s+/).filter(Boolean));
12169
12206
  if (props.style) stat.setAttribute("style", props.style);
12207
+ const useInlineColor = props.color && isArbitraryColor2(props.color) && !isThemeToken;
12170
12208
  if (props.icon) {
12171
12209
  const figure = document.createElement("div");
12172
12210
  figure.className = "nr-stat__figure";
12211
+ if (useInlineColor) figure.style.color = props.color;
12173
12212
  figure.appendChild(createIcon(props.icon));
12174
12213
  stat.appendChild(figure);
12175
12214
  }
@@ -12182,6 +12221,7 @@ var statDirective = ({ props }) => {
12182
12221
  if (props.value) {
12183
12222
  const value = document.createElement("div");
12184
12223
  value.className = "nr-stat__value";
12224
+ if (useInlineColor) value.style.color = props.color;
12185
12225
  value.textContent = props.value;
12186
12226
  stat.appendChild(value);
12187
12227
  }
@@ -12308,7 +12348,9 @@ function processElements(elements, ctx, allElements) {
12308
12348
  }
12309
12349
  } else {
12310
12350
  const grid = document.createElement("div");
12311
- grid.className = BATCHED_DIRECTIVES[cards[0].directiveType];
12351
+ const gridClass = BATCHED_DIRECTIVES[cards[0].directiveType];
12352
+ const align = cards[0].props?.align;
12353
+ grid.className = align === "center" || align === "right" ? `${gridClass} ${gridClass}--${align}` : gridClass;
12312
12354
  for (const card of cards) {
12313
12355
  const rendered = renderElement(card, ctx, allElements);
12314
12356
  if (rendered) grid.appendChild(rendered);