@noirmd/previewer 2.1.5 → 2.1.6

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
@@ -11077,6 +11077,7 @@ function createModal(title) {
11077
11077
  header.appendChild(titleEl);
11078
11078
  const closeBtn = document.createElement("button");
11079
11079
  closeBtn.className = "nr-modal__close";
11080
+ closeBtn.setAttribute("aria-label", "Close");
11080
11081
  closeBtn.appendChild(createIcon("close"));
11081
11082
  closeBtn.addEventListener("click", () => dialog.close());
11082
11083
  header.appendChild(closeBtn);
@@ -11358,6 +11359,18 @@ function openModal(dialog) {
11358
11359
  }
11359
11360
  }
11360
11361
  var IMG_RE = /!\[([^\]]*)\]\(([^)]+)\)/g;
11362
+ function applyAlignClass(el, baseClass, align) {
11363
+ if (align === "center") {
11364
+ el.classList.add(`${baseClass}--center`);
11365
+ } else if (align === "right") {
11366
+ el.classList.add(`${baseClass}--right`);
11367
+ }
11368
+ }
11369
+ function resolveIcon(value, fallback) {
11370
+ if (!value) return fallback;
11371
+ if (value === "none" || value === "off") return null;
11372
+ return value;
11373
+ }
11361
11374
  function parseIntProp(value, defaultValue) {
11362
11375
  if (!value) return defaultValue;
11363
11376
  const n = parseInt(value, 10);
@@ -11397,13 +11410,16 @@ var modalDirective = ({ props, renderSlot }) => {
11397
11410
  const label = props.label || props.title || "Open";
11398
11411
  const modalTitle = props.title || "Modal";
11399
11412
  const align = props.align || "left";
11413
+ const iconName = resolveIcon(props.icon, "open_in_full");
11400
11414
  const wrapper = document.createElement("div");
11401
- wrapper.className = `nr-modal-trigger${align === "center" ? " nr-modal-trigger--center" : align === "right" ? " nr-modal-trigger--right" : ""}`;
11415
+ wrapper.className = "nr-modal-trigger";
11416
+ applyAlignClass(wrapper, "nr-modal-trigger", align);
11402
11417
  const btn = document.createElement("button");
11403
- btn.className = `nr-button nr-button--default`;
11418
+ btn.className = "nr-button nr-button--default";
11419
+ btn.setAttribute("aria-haspopup", "dialog");
11420
+ applyColor(btn, props.color, "nr-button");
11404
11421
  applyBaseProps(btn, props);
11405
- const icon = props.icon || "open_in_new";
11406
- if (icon) btn.appendChild(createIcon(icon));
11422
+ if (iconName) btn.appendChild(createIcon(iconName));
11407
11423
  btn.appendChild(document.createTextNode(label));
11408
11424
  const dialog = createModal(modalTitle);
11409
11425
  const body = dialog.querySelector(".nr-modal__body");
@@ -11424,20 +11440,21 @@ var modal_default = modalDirective;
11424
11440
  var buttonDirective = ({ props, renderSlot }) => {
11425
11441
  const url = props.url || props.href || "#";
11426
11442
  const label = props.label || props.title;
11427
- const icon = props.icon || "near_me";
11443
+ const iconName = resolveIcon(props.icon, "touch_app");
11428
11444
  const target = props.target || "_blank";
11429
- const customClass = props.class || "";
11430
11445
  const align = props.align || "left";
11431
11446
  const wrapper = document.createElement("div");
11432
- wrapper.className = `nr-button-wrap${align === "center" ? " nr-button-wrap--center" : align === "right" ? " nr-button-wrap--right" : ""}`;
11447
+ wrapper.className = "nr-button-wrap";
11448
+ applyAlignClass(wrapper, "nr-button-wrap", align);
11433
11449
  if (label) {
11434
11450
  const a = document.createElement("a");
11435
11451
  a.href = url;
11436
11452
  a.target = target;
11437
- a.rel = "noopener noreferrer";
11453
+ if (target === "_blank") a.rel = "noopener noreferrer";
11438
11454
  a.className = "nr-button nr-button--default";
11455
+ applyColor(a, props.color, "nr-button");
11439
11456
  applyBaseProps(a, props);
11440
- a.appendChild(createIcon(icon));
11457
+ if (iconName) a.appendChild(createIcon(iconName));
11441
11458
  a.appendChild(document.createTextNode(label));
11442
11459
  wrapper.appendChild(a);
11443
11460
  return wrapper;
@@ -11447,6 +11464,8 @@ var buttonDirective = ({ props, renderSlot }) => {
11447
11464
  if (links.length > 0) {
11448
11465
  links.forEach((link) => {
11449
11466
  link.classList.add("nr-button", "nr-button--default");
11467
+ applyColor(link, props.color, "nr-button");
11468
+ if (iconName) link.prepend(createIcon(iconName));
11450
11469
  applyBaseProps(link, props);
11451
11470
  });
11452
11471
  wrapper.appendChild(slotContent);
@@ -11454,10 +11473,11 @@ var buttonDirective = ({ props, renderSlot }) => {
11454
11473
  const a = document.createElement("a");
11455
11474
  a.href = url;
11456
11475
  a.target = target;
11457
- a.rel = "noopener noreferrer";
11476
+ if (target === "_blank") a.rel = "noopener noreferrer";
11458
11477
  a.className = "nr-button nr-button--default";
11478
+ applyColor(a, props.color, "nr-button");
11459
11479
  applyBaseProps(a, props);
11460
- a.appendChild(createIcon(icon));
11480
+ if (iconName) a.appendChild(createIcon(iconName));
11461
11481
  a.appendChild(slotContent);
11462
11482
  wrapper.appendChild(a);
11463
11483
  }