@loafacto/ui 0.19.0 → 0.20.0

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
@@ -1,8 +1,8 @@
1
1
  import { readonly, ref, openBlock, createElementBlock, createStaticVNode, createElementVNode, defineComponent, computed, watch, onBeforeUnmount, normalizeClass, normalizeStyle, createCommentVNode, Fragment, toDisplayString, createVNode, Transition, withCtx, renderList, renderSlot, unref, nextTick, onUnmounted, createBlock, Teleport, TransitionGroup, withModifiers, useTemplateRef, onMounted, createTextVNode, withDirectives, withKeys, vModelText, resolveDynamicComponent, useModel, useId, mergeProps, isRef, vModelDynamic, mergeModels, vModelCheckbox, vModelRadio, useSlots, vShow } from "vue";
2
2
  import { a as applyTheme, D as DARK_THEME, L as LIGHT_THEME } from "./applyTheme-8AxcQbPB.js";
3
3
  import { b, c, d, e, f, h, i, l } from "./applyTheme-8AxcQbPB.js";
4
- import { _ as _export_sfc, L as LfSpinner, a as LfIcon, u as useSplitAttrs, b as LfField, c as LfIconButton, d as LF_ICONS } from "./LfSegmented-Dvpie4c_.js";
5
- import { e as e2, f as f2 } from "./LfSegmented-Dvpie4c_.js";
4
+ import { _ as _export_sfc, L as LfSpinner, a as LfIcon, u as useSplitAttrs, b as LfField, c as LfIconButton, d as LF_ICONS } from "./LfSegmented-BjlkJm2I.js";
5
+ import { e as e2, f as f2 } from "./LfSegmented-BjlkJm2I.js";
6
6
  import { defineStore } from "pinia";
7
7
  const LOAFACTO_SERVICES = [
8
8
  {
@@ -636,7 +636,7 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
636
636
  };
637
637
  }
638
638
  });
639
- const AppShell = /* @__PURE__ */ _export_sfc(_sfc_main$N, [["__scopeId", "data-v-b8a57f75"]]);
639
+ const AppShell = /* @__PURE__ */ _export_sfc(_sfc_main$N, [["__scopeId", "data-v-fd060854"]]);
640
640
  function generateId() {
641
641
  return `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
642
642
  }
@@ -1005,7 +1005,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
1005
1005
  };
1006
1006
  }
1007
1007
  });
1008
- const LfButton = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["__scopeId", "data-v-0d2e2b97"]]);
1008
+ const LfButton = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["__scopeId", "data-v-fbe98cd7"]]);
1009
1009
  const _hoisted_1$G = { class: "lf-control-wrap" };
1010
1010
  const _hoisted_2$E = {
1011
1011
  key: 0,
@@ -1639,7 +1639,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
1639
1639
  };
1640
1640
  }
1641
1641
  });
1642
- const LfCard = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-3ffcb11e"]]);
1642
+ const LfCard = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-61964a83"]]);
1643
1643
  const _hoisted_1$z = { class: "lf-page-header" };
1644
1644
  const _hoisted_2$x = { class: "lf-page-header__title-box" };
1645
1645
  const _hoisted_3$r = { class: "lf-page-header__title" };
@@ -1669,8 +1669,6 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
1669
1669
  count: {}
1670
1670
  },
1671
1671
  setup(__props) {
1672
- const slots = useSlots();
1673
- const hasTools = computed(() => !!slots.filters || !!slots.actions);
1674
1672
  return (_ctx, _cache) => {
1675
1673
  return openBlock(), createElementBlock("div", _hoisted_1$z, [
1676
1674
  createElementVNode("div", _hoisted_2$x, [
@@ -1690,7 +1688,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
1690
1688
  ]),
1691
1689
  __props.count !== void 0 ? (openBlock(), createElementBlock("span", _hoisted_5$k, toDisplayString(__props.count), 1)) : createCommentVNode("", true)
1692
1690
  ]),
1693
- hasTools.value ? (openBlock(), createElementBlock("div", _hoisted_6$e, [
1691
+ _ctx.$slots.filters || _ctx.$slots.actions ? (openBlock(), createElementBlock("div", _hoisted_6$e, [
1694
1692
  renderSlot(_ctx.$slots, "filters", {}, void 0, true),
1695
1693
  _cache[0] || (_cache[0] = createElementVNode("span", { class: "lf-page-header__spacer" }, null, -1)),
1696
1694
  renderSlot(_ctx.$slots, "actions", {}, void 0, true)
@@ -1704,7 +1702,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
1704
1702
  };
1705
1703
  }
1706
1704
  });
1707
- const LfPageHeader = /* @__PURE__ */ _export_sfc(_sfc_main$B, [["__scopeId", "data-v-a7ef2659"]]);
1705
+ const LfPageHeader = /* @__PURE__ */ _export_sfc(_sfc_main$B, [["__scopeId", "data-v-503c1630"]]);
1708
1706
  const _hoisted_1$y = {
1709
1707
  key: 0,
1710
1708
  class: "lf-badge__dot",
@@ -2071,7 +2069,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
2071
2069
  };
2072
2070
  }
2073
2071
  });
2074
- const LfTable = /* @__PURE__ */ _export_sfc(_sfc_main$x, [["__scopeId", "data-v-2eb52796"]]);
2072
+ const LfTable = /* @__PURE__ */ _export_sfc(_sfc_main$x, [["__scopeId", "data-v-240462cb"]]);
2075
2073
  const _hoisted_1$u = ["aria-label"];
2076
2074
  const _hoisted_2$s = {
2077
2075
  key: 0,
@@ -2356,7 +2354,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
2356
2354
  };
2357
2355
  }
2358
2356
  });
2359
- const LfStatCard = /* @__PURE__ */ _export_sfc(_sfc_main$t, [["__scopeId", "data-v-ddc6565d"]]);
2357
+ const LfStatCard = /* @__PURE__ */ _export_sfc(_sfc_main$t, [["__scopeId", "data-v-c84e9955"]]);
2360
2358
  const _hoisted_1$q = ["aria-describedby"];
2361
2359
  const _hoisted_2$p = ["id"];
2362
2360
  const _sfc_main$s = /* @__PURE__ */ defineComponent({
@@ -2529,7 +2527,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
2529
2527
  const props = __props;
2530
2528
  const emit = __emit;
2531
2529
  function linkAttrs(item) {
2532
- return props.link === "a" ? { href: item.to } : { to: item.to };
2530
+ if (props.link === "a") return { href: item.to };
2531
+ return props.current === void 0 ? { to: item.to } : { to: item.to, activeClass: "", exactActiveClass: "" };
2533
2532
  }
2534
2533
  const list = useTemplateRef("list");
2535
2534
  const thumb = ref(null);
@@ -2622,7 +2621,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
2622
2621
  };
2623
2622
  }
2624
2623
  });
2625
- const LfNavRail = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-a29be44a"]]);
2624
+ const LfNavRail = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-dfb20796"]]);
2626
2625
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
2627
2626
  __name: "LfTransitionList",
2628
2627
  props: {
@@ -3140,7 +3139,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
3140
3139
  };
3141
3140
  }
3142
3141
  });
3143
- const LfListItem = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-e05ac56f"]]);
3142
+ const LfListItem = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-57a82ab1"]]);
3144
3143
  const _hoisted_1$l = {
3145
3144
  key: 0,
3146
3145
  class: "lf-divider lf-divider--labeled",
@@ -3307,7 +3306,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
3307
3306
  };
3308
3307
  }
3309
3308
  });
3310
- const LfTabs = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-ad8ded73"]]);
3309
+ const LfTabs = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-4439195d"]]);
3311
3310
  const _hoisted_1$j = ["aria-modal", "aria-labelledby", "aria-label"];
3312
3311
  const _hoisted_2$i = {
3313
3312
  key: 0,
@@ -5095,7 +5094,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5095
5094
  };
5096
5095
  }
5097
5096
  });
5098
- const LfCodeBlock = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-c26782cf"]]);
5097
+ const LfCodeBlock = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-edbc475d"]]);
5099
5098
  const _hoisted_1 = { class: "lf-gridedit__table" };
5100
5099
  const _hoisted_2 = {
5101
5100
  class: "lf-gridedit__corner",
@@ -5434,6 +5433,201 @@ function createApiClient(options) {
5434
5433
  }
5435
5434
  return { api, request, install };
5436
5435
  }
5436
+ let lastBtn = null;
5437
+ let lastAt = 0;
5438
+ let installed = false;
5439
+ function markDone(el) {
5440
+ if (!el || !el.isConnected) return;
5441
+ el.classList.remove("lf-done");
5442
+ void el.offsetWidth;
5443
+ el.classList.add("lf-done");
5444
+ window.setTimeout(() => el.classList.remove("lf-done"), 1200);
5445
+ }
5446
+ function installDoneFeedback(store) {
5447
+ if (installed || typeof document === "undefined") return;
5448
+ installed = true;
5449
+ document.addEventListener("click", (e3) => {
5450
+ var _a, _b;
5451
+ const b2 = (_b = (_a = e3.target) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(_a, "button");
5452
+ if (b2) {
5453
+ lastBtn = b2;
5454
+ lastAt = Date.now();
5455
+ }
5456
+ }, true);
5457
+ store.$onAction(({ name }) => {
5458
+ if (name !== "success") return;
5459
+ if (lastBtn && Date.now() - lastAt < 3e3) markDone(lastBtn);
5460
+ lastBtn = null;
5461
+ });
5462
+ }
5463
+ function useThumb(el, sel, src) {
5464
+ const style = ref({ opacity: "0" });
5465
+ const ready = ref(false);
5466
+ function measure() {
5467
+ const box = el.value;
5468
+ const on = box == null ? void 0 : box.querySelector(sel);
5469
+ if (!box || !on) {
5470
+ style.value = { opacity: "0" };
5471
+ return;
5472
+ }
5473
+ style.value = {
5474
+ transform: `translate(${on.offsetLeft}px, ${on.offsetTop}px)`,
5475
+ width: `${on.offsetWidth}px`,
5476
+ height: `${on.offsetHeight}px`,
5477
+ opacity: "1"
5478
+ };
5479
+ }
5480
+ let ro = null;
5481
+ watch(src, () => {
5482
+ void nextTick(measure);
5483
+ });
5484
+ watch(el, (box) => {
5485
+ ro == null ? void 0 : ro.disconnect();
5486
+ ready.value = false;
5487
+ if (!box) return;
5488
+ ro = new ResizeObserver(() => measure());
5489
+ ro.observe(box);
5490
+ void nextTick(() => {
5491
+ measure();
5492
+ window.setTimeout(() => {
5493
+ ready.value = true;
5494
+ }, 60);
5495
+ });
5496
+ }, { immediate: true });
5497
+ onUnmounted(() => ro == null ? void 0 : ro.disconnect());
5498
+ return { style, ready };
5499
+ }
5500
+ const thumbs = /* @__PURE__ */ new WeakMap();
5501
+ function placeThumb(el, st) {
5502
+ const on = el.querySelector(st.opt.on);
5503
+ const s = st.thumb.style;
5504
+ if (!on || on.offsetWidth === 0) {
5505
+ s.opacity = "0";
5506
+ return;
5507
+ }
5508
+ const bar = st.opt.kind === "bar";
5509
+ const y = bar ? on.offsetTop + on.offsetHeight - 2 : on.offsetTop;
5510
+ s.transform = `translate(${on.offsetLeft}px, ${y}px)`;
5511
+ s.width = `${on.offsetWidth}px`;
5512
+ s.height = bar ? "2px" : `${on.offsetHeight}px`;
5513
+ s.opacity = "1";
5514
+ }
5515
+ const vThumb = {
5516
+ mounted(el, b2) {
5517
+ if (getComputedStyle(el).position === "static") el.style.position = "relative";
5518
+ const thumb = document.createElement("span");
5519
+ thumb.className = `lf-thumb lf-thumb--${b2.value.kind ?? "fill"}`;
5520
+ thumb.setAttribute("aria-hidden", "true");
5521
+ el.prepend(thumb);
5522
+ const watchKids = () => {
5523
+ for (const c2 of Array.from(el.children)) if (c2 !== thumb) st.ro.observe(c2);
5524
+ };
5525
+ const st = { thumb, opt: b2.value, mo: new MutationObserver(() => {
5526
+ watchKids();
5527
+ placeThumb(el, st);
5528
+ }), ro: new ResizeObserver(() => placeThumb(el, st)), t: 0 };
5529
+ st.mo.observe(el, { subtree: true, attributes: true, attributeFilter: ["class"], childList: true, characterData: true });
5530
+ st.ro.observe(el);
5531
+ watchKids();
5532
+ placeThumb(el, st);
5533
+ st.t = window.setTimeout(() => thumb.classList.add("lf-thumb--ready"), 60);
5534
+ thumbs.set(el, st);
5535
+ },
5536
+ updated(el, b2) {
5537
+ const st = thumbs.get(el);
5538
+ if (!st) return;
5539
+ st.opt = b2.value;
5540
+ placeThumb(el, st);
5541
+ },
5542
+ unmounted(el) {
5543
+ const st = thumbs.get(el);
5544
+ if (!st) return;
5545
+ st.mo.disconnect();
5546
+ st.ro.disconnect();
5547
+ window.clearTimeout(st.t);
5548
+ thumbs.delete(el);
5549
+ }
5550
+ };
5551
+ const SHOW_MS = 350;
5552
+ function installTooltips() {
5553
+ if (typeof document === "undefined" || window.__lfTip) return;
5554
+ window.__lfTip = true;
5555
+ const tip = document.createElement("div");
5556
+ tip.className = "lf-tip";
5557
+ tip.setAttribute("role", "tooltip");
5558
+ document.body.appendChild(tip);
5559
+ let cur = null;
5560
+ let timer = 0;
5561
+ const obs = new MutationObserver(() => {
5562
+ if (!cur) return;
5563
+ const t = cur.getAttribute("title");
5564
+ if (t == null) return;
5565
+ cur.setAttribute("data-lf-title", t);
5566
+ cur.removeAttribute("title");
5567
+ if (t) {
5568
+ tip.textContent = t;
5569
+ if (tip.classList.contains("lf-tip--on")) place();
5570
+ } else hide();
5571
+ });
5572
+ function place() {
5573
+ if (!cur) return;
5574
+ const r = cur.getBoundingClientRect();
5575
+ const b2 = tip.getBoundingClientRect();
5576
+ const gap = 6;
5577
+ let top = r.top - b2.height - gap;
5578
+ if (top < 4) top = r.bottom + gap;
5579
+ let left = r.left + r.width / 2 - b2.width / 2;
5580
+ left = Math.max(4, Math.min(window.innerWidth - b2.width - 4, left));
5581
+ tip.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
5582
+ }
5583
+ function hide() {
5584
+ clearTimeout(timer);
5585
+ tip.classList.remove("lf-tip--on");
5586
+ }
5587
+ function release() {
5588
+ hide();
5589
+ obs.disconnect();
5590
+ if (cur && cur.hasAttribute("data-lf-title")) {
5591
+ if (!cur.hasAttribute("title")) cur.setAttribute("title", cur.getAttribute("data-lf-title") || "");
5592
+ cur.removeAttribute("data-lf-title");
5593
+ }
5594
+ cur = null;
5595
+ }
5596
+ document.addEventListener("pointerover", (e3) => {
5597
+ var _a, _b;
5598
+ if (e3.pointerType === "touch") return;
5599
+ const el = (_b = (_a = e3.target) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(_a, "[title]");
5600
+ if (!el || el === cur) return;
5601
+ const text = el.getAttribute("title") || "";
5602
+ release();
5603
+ if (!text.trim()) return;
5604
+ if (el.tagName === "IFRAME") return;
5605
+ cur = el;
5606
+ el.setAttribute("data-lf-title", text);
5607
+ el.removeAttribute("title");
5608
+ obs.observe(el, { attributes: true, attributeFilter: ["title"] });
5609
+ tip.textContent = text;
5610
+ timer = window.setTimeout(() => {
5611
+ if (cur !== el) return;
5612
+ tip.classList.add("lf-tip--on");
5613
+ place();
5614
+ }, SHOW_MS);
5615
+ }, true);
5616
+ document.addEventListener("pointerout", (e3) => {
5617
+ if (!cur) return;
5618
+ const to = e3.relatedTarget;
5619
+ if (to && cur.contains(to)) return;
5620
+ release();
5621
+ }, true);
5622
+ for (const ev of ["pointerdown", "wheel", "keydown"]) document.addEventListener(ev, () => hide(), true);
5623
+ window.addEventListener("blur", () => release());
5624
+ }
5625
+ function installConventions(app, opts = {}) {
5626
+ app.directive("thumb", vThumb);
5627
+ if (typeof document === "undefined") return;
5628
+ if (opts.tooltips !== false) installTooltips();
5629
+ if (opts.doneFeedback !== false) installDoneFeedback(useToastStore());
5630
+ }
5437
5631
  function useToast() {
5438
5632
  const store = useToastStore();
5439
5633
  return {
@@ -5519,15 +5713,21 @@ export {
5519
5713
  f as deriveSemanticPalette,
5520
5714
  h as hexToRgb,
5521
5715
  initTheme,
5716
+ installConventions,
5717
+ installDoneFeedback,
5718
+ installTooltips,
5522
5719
  i as isLightBackground,
5523
5720
  isServicePath,
5524
5721
  l as luminance,
5722
+ markDone,
5525
5723
  serviceIdForPath,
5526
5724
  useConfirm,
5527
5725
  useConfirmStore,
5528
5726
  useLoadingStore,
5529
5727
  useTheme,
5728
+ useThumb,
5530
5729
  useToast,
5531
- useToastStore
5730
+ useToastStore,
5731
+ vThumb
5532
5732
  };
5533
5733
  //# sourceMappingURL=index.js.map