wave-ui 3.17.2 → 3.17.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.
@@ -3,7 +3,7 @@ var de = (e) => {
3
3
  throw TypeError(e);
4
4
  };
5
5
  var Ie = (e, t, i) => t in e ? $e(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
6
- var H = (e, t, i) => Ie(e, typeof t != "symbol" ? t + "" : t, i), ue = (e, t, i) => t.has(e) || de("Cannot " + i);
6
+ var F = (e, t, i) => Ie(e, typeof t != "symbol" ? t + "" : t, i), ue = (e, t, i) => t.has(e) || de("Cannot " + i);
7
7
  var Y = (e, t, i) => (ue(e, t, "read from private field"), i ? i.call(e) : t.get(e)), te = (e, t, i) => t.has(e) ? de("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, i), ie = (e, t, i, s) => (ue(e, t, "write to private field"), s ? s.call(e, i) : t.set(e, i), i);
8
8
  import { reactive as Z, resolveComponent as $, openBlock as o, createBlock as b, Teleport as Ve, createVNode as T, TransitionGroup as ae, normalizeClass as m, withCtx as f, createElementBlock as u, Fragment as v, renderList as x, mergeProps as _, createElementVNode as w, createCommentVNode as p, createApp as Te, defineComponent as Le, inject as Re, withKeys as A, withModifiers as M, renderSlot as c, createTextVNode as B, toDisplayString as S, normalizeStyle as R, toHandlers as ne, Transition as O, resolveDynamicComponent as L, normalizeProps as le, resolveDirective as ke, withDirectives as W, createSlots as ee, vShow as re, vModelText as ve, vModelDynamic as xe, KeepAlive as Oe } from "vue";
9
9
  const Pe = Z({
@@ -74,7 +74,7 @@ const Pe = Z({
74
74
  typeof s == "object" && typeof t[i] == "object" ? Ce(e[i], t[i]) : t[i] = s;
75
75
  }
76
76
  return t;
77
- }, j = (e) => console.warn(`Wave UI: ${e}`), F = (e) => console.error(`Wave UI: ${e}`), ze = (e) => {
77
+ }, j = (e) => console.warn(`Wave UI: ${e}`), D = (e) => console.error(`Wave UI: ${e}`), ze = (e) => {
78
78
  ["light", "dark"].forEach((t) => {
79
79
  var s, a, l;
80
80
  const i = e.colors[t];
@@ -106,7 +106,7 @@ function G(e, t, i) {
106
106
  }
107
107
  function J(e) {
108
108
  const t = e.toString(16);
109
- return t.length === 1 && `0${t}` || t.length === 2 && t || F(`expected value from 0~255, got: ${e}`) || "";
109
+ return t.length === 1 && `0${t}` || t.length === 2 && t || D(`expected value from 0~255, got: ${e}`) || "";
110
110
  }
111
111
  function Me(e) {
112
112
  return /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e);
@@ -118,7 +118,7 @@ function Ae(e) {
118
118
  return `#${e.substring(1).split("").map((t) => `${t}${t}`).join("")}`;
119
119
  }
120
120
  function We(e) {
121
- return Me(e) && e || Ee(e) && Ae(e) || F(`expected color hex string, got '${e}'`) || "";
121
+ return Me(e) && e || Ee(e) && Ae(e) || D(`expected color hex string, got '${e}'`) || "";
122
122
  }
123
123
  function ce(e) {
124
124
  const t = We(e), i = parseInt(t.substring(1, 3), 16), s = parseInt(t.substring(3, 5), 16), a = parseInt(t.substring(5, 7), 16), l = t.length === 9 ? parseInt(t.substring(7, 9), 16) / 255 : 1;
@@ -672,22 +672,22 @@ const C = (e, t) => {
672
672
  }
673
673
  }
674
674
  }, Je = /* @__PURE__ */ C(Ge, [["render", Ye]]);
675
- var D;
675
+ var H;
676
676
  const N = class N {
677
677
  constructor() {
678
- H(this, "notifications");
678
+ F(this, "notifications");
679
679
  // Private fields.
680
- H(this, "_uid");
680
+ F(this, "_uid");
681
681
  // A unique ID for each notification.
682
- H(this, "_notificationDefaults");
683
- if (Y(N, D)) return Y(N, D);
682
+ F(this, "_notificationDefaults");
683
+ if (Y(N, H)) return Y(N, H);
684
684
  this.notifications = [], this._uid = 0, this._notificationDefaults = {
685
685
  _uid: 0,
686
686
  _value: !0,
687
687
  message: "",
688
688
  timeout: 4e3,
689
689
  dismiss: !0
690
- }, ie(N, D, this);
690
+ }, ie(N, H, this);
691
691
  }
692
692
  notify(...t) {
693
693
  let i = {
@@ -710,7 +710,7 @@ const N = class N {
710
710
  this.notifications = this.notifications.filter((i) => i._uid !== t);
711
711
  }
712
712
  };
713
- D = new WeakMap(), te(N, D);
713
+ H = new WeakMap(), te(N, H);
714
714
  let oe = N;
715
715
  const Qe = (e, t, i) => {
716
716
  const s = document.createElement("div");
@@ -754,7 +754,7 @@ const K = class K {
754
754
  constructor(t, i = {}) {
755
755
  // Exposed as a global object and also `app.provide`d.
756
756
  // Accessible from this.$waveui, or inject('$waveui').
757
- H(this, "$waveui", {
757
+ F(this, "$waveui", {
758
758
  breakpoint: {
759
759
  name: "",
760
760
  xs: !1,
@@ -853,7 +853,7 @@ function ot(e, t, i, s, a, l) {
853
853
  onClick: t[1] || (t[1] = M((d) => !l.accordionItem._disabled && l.toggleItem(l.accordionItem, d), ["stop"]))
854
854
  }, null, 8, ["icon", "icon-props", "disabled", "class"])) : p("", !0),
855
855
  c(e.$slots, "title", {
856
- item: l.accordionItem,
856
+ item: l.getOriginalItem(l.accordionItem),
857
857
  expanded: l.accordionItem._expanded,
858
858
  index: l.accordionItem._index + 1
859
859
  }, () => [
@@ -883,7 +883,7 @@ function ot(e, t, i, s, a, l) {
883
883
  class: m(["w-accordion__item-content", l.contentClasses])
884
884
  }, [
885
885
  c(e.$slots, "content", {
886
- item: l.accordionItem,
886
+ item: l.getOriginalItem(l.accordionItem),
887
887
  expanded: l.accordionItem._expanded,
888
888
  index: l.accordionItem._index + 1
889
889
  }, () => [
@@ -900,40 +900,36 @@ function ot(e, t, i, s, a, l) {
900
900
  const at = {
901
901
  name: "w-accordion-item",
902
902
  props: {
903
- item: { type: Object }
903
+ title: { type: String },
904
+ content: { type: String },
905
+ expanded: { type: Boolean },
906
+ disabled: { type: Boolean }
904
907
  },
905
908
  inject: [
906
909
  "options",
907
- "itemClasses",
908
910
  "titleClasses",
909
911
  "contentClasses",
910
912
  "onItemToggle",
911
913
  "onEndOfCollapse",
912
914
  "getOriginalItem",
915
+ "getAccordionItem",
913
916
  "registerItem",
914
- "state"
917
+ "unregisterItem"
915
918
  ],
916
919
  emits: ["focus"],
917
- data() {
918
- var e;
919
- return {
920
- accordionItemIndex: (e = this.item) == null ? void 0 : e._index
921
- };
922
- },
923
920
  computed: {
924
921
  accordionItem: {
925
922
  get() {
926
- return this.state.accordionItems[this.accordionItemIndex] || {};
923
+ return this.getAccordionItem(this._.uid);
927
924
  },
928
925
  set() {
929
926
  }
930
927
  },
931
- itemClass() {
928
+ itemClasses() {
932
929
  return {
933
930
  "w-accordion__item--expanded": this.accordionItem._expanded,
934
931
  "w-accordion__item--disabled": this.accordionItem._disabled,
935
- [this.accordionItem[this.options.itemColorKey]]: this.accordionItem[this.options.itemColorKey],
936
- ...this.accordionItemClasses
932
+ [this.accordionItem[this.options.itemColorKey]]: this.accordionItem[this.options.itemColorKey]
937
933
  };
938
934
  }
939
935
  },
@@ -943,12 +939,17 @@ const at = {
943
939
  }
944
940
  },
945
941
  created() {
946
- this.accordionItemIndex = this.registerItem({
942
+ this.registerItem({
943
+ _cuid: this._.uid,
947
944
  _index: 0,
948
- _expanded: !1,
949
- _disabled: !1,
950
- ...this.item || {}
945
+ _expanded: this.expanded,
946
+ _disabled: this.disabled,
947
+ title: this.title,
948
+ content: this.content
951
949
  });
950
+ },
951
+ beforeUnmount() {
952
+ this.unregisterItem(this._.uid);
952
953
  }
953
954
  }, Be = /* @__PURE__ */ C(at, [["render", ot]]);
954
955
  function nt(e, t, i, s, a, l) {
@@ -956,14 +957,17 @@ function nt(e, t, i, s, a, l) {
956
957
  return o(), u("div", {
957
958
  class: m(["w-accordion", l.accordionClasses])
958
959
  }, [
959
- l.accordionItemsProvided ? c(e.$slots, "default", { key: 0 }) : !isNaN(i.items) || (i.items || []).length ? (o(!0), u(v, { key: 1 }, x(e.state.accordionItems, (r, d) => (o(), b(n, {
960
+ l.accordionItemsProvided ? c(e.$slots, "default", { key: 0 }) : (i.items || []).length ? (o(!0), u(v, { key: 1 }, x(i.items.length ? i.items : e.accordionItems, (r, d) => (o(), b(n, {
960
961
  key: d,
961
- class: m(i.itemClass),
962
- item: r,
962
+ class: m(l.itemClasses),
963
+ title: r.title,
964
+ content: r.content,
965
+ expanded: r.expanded || r._expanded,
966
+ disabled: r.disabled || r._disabled,
963
967
  onFocus: t[0] || (t[0] = (h) => e.$emit("focus", h))
964
968
  }, {
965
969
  title: f(({ item: h, expanded: y, index: k }) => [
966
- e.$slots[`item-title.${r.id || r._index + 1}`] ? c(e.$slots, `item-title.${r.id || r._index + 1}`, {
970
+ e.$slots[`item-title.${h.id || k}`] ? c(e.$slots, `item-title.${h.id || k}`, {
967
971
  key: 0,
968
972
  item: h,
969
973
  expanded: y,
@@ -976,7 +980,7 @@ function nt(e, t, i, s, a, l) {
976
980
  })
977
981
  ]),
978
982
  content: f(({ item: h, expanded: y, index: k }) => [
979
- e.$slots[`item-content.${r.id || r._index + 1}`] ? c(e.$slots, `item-content.${r.id || r._index + 1}`, {
983
+ e.$slots[`item-content.${h.id || k}`] ? c(e.$slots, `item-content.${h.id || k}`, {
980
984
  key: 0,
981
985
  item: h,
982
986
  expanded: y,
@@ -989,7 +993,7 @@ function nt(e, t, i, s, a, l) {
989
993
  })
990
994
  ]),
991
995
  _: 2
992
- }, 1032, ["class", "item"]))), 128)) : p("", !0)
996
+ }, 1032, ["class", "title", "content", "expanded", "disabled"]))), 128)) : p("", !0)
993
997
  ], 2);
994
998
  }
995
999
  const rt = {
@@ -998,8 +1002,9 @@ const rt = {
998
1002
  modelValue: { type: Array },
999
1003
  color: { type: String },
1000
1004
  bgColor: { type: String },
1001
- items: { type: [Array, Number] },
1002
1005
  // Required unless externally using WAccordionItem.
1006
+ // Number deprecated: use WAccordionItem.
1007
+ items: { type: [Array, Number] },
1003
1008
  itemColorKey: { type: String, default: "color" },
1004
1009
  // Support a different color per item.
1005
1010
  itemTitleKey: { type: String, default: "title" },
@@ -1023,7 +1028,6 @@ const rt = {
1023
1028
  // All provided to the WAccordionItem, not passed as prop since it could be used externally.
1024
1029
  provide() {
1025
1030
  return {
1026
- itemClasses: P(this.itemClasses),
1027
1031
  titleClasses: this.titleClasses,
1028
1032
  contentClasses: this.contentClasses,
1029
1033
  onItemToggle: this.onItemToggle,
@@ -1031,15 +1035,17 @@ const rt = {
1031
1035
  getOriginalItem: this.getOriginalItem,
1032
1036
  options: this.$props,
1033
1037
  registerItem: this.registerItem,
1034
- state: this.state
1038
+ unregisterItem: this.unregisterItem,
1039
+ getAccordionItem: this.getAccordionItem
1035
1040
  };
1036
1041
  },
1037
1042
  data: () => ({
1038
- state: {
1039
- accordionItems: []
1040
- }
1043
+ accordionItems: []
1041
1044
  }),
1042
1045
  computed: {
1046
+ accordionItemsById() {
1047
+ return this.accordionItems.reduce((e, t) => (e[t._cuid] = t, e), {});
1048
+ },
1043
1049
  // Detect if the accordion items are directly provided through slot using WAccordionItem.
1044
1050
  accordionItemsProvided() {
1045
1051
  var e, t, i;
@@ -1071,9 +1077,12 @@ const rt = {
1071
1077
  }
1072
1078
  },
1073
1079
  methods: {
1080
+ getAccordionItem(e) {
1081
+ return this.accordionItemsById[e];
1082
+ },
1074
1083
  onItemToggle(e) {
1075
- this.expandSingle && this.state.accordionItems.forEach((i) => i._index !== e._index && (i._expanded = !1));
1076
- const t = this.state.accordionItems.map((i) => i._expanded || !1);
1084
+ this.expandSingle && this.accordionItems.forEach((i) => i._index !== e._index && (i._expanded = !1));
1085
+ const t = this.accordionItems.map((i) => i._expanded || !1);
1077
1086
  this.$emit("update:modelValue", t), this.$emit("input", t), this.$emit("item-expand", { item: e, expanded: e._expanded });
1078
1087
  },
1079
1088
  onEndOfCollapse(e) {
@@ -1081,35 +1090,37 @@ const rt = {
1081
1090
  },
1082
1091
  // Return the original accordion item (so there is no `_index`, etc.).
1083
1092
  getOriginalItem(e) {
1084
- return this.items[e._index];
1085
- },
1086
- updateItems() {
1087
- let e = this.state.accordionItems;
1088
- !this.accordionItemsProvided && this.items && (e = (typeof this.items == "number" ? Array(this.items).fill({}) : this.items) || []), this.state.accordionItems = e.map((t, i) => {
1089
- var s;
1090
- return {
1091
- ...t,
1092
- _index: i,
1093
- _expanded: ((s = this.modelValue) == null ? void 0 : s[i]) ?? !1,
1094
- _disabled: !!t.disabled
1095
- };
1096
- });
1093
+ var t;
1094
+ return ((t = this.items) == null ? void 0 : t[e._index]) || e;
1097
1095
  },
1098
- // Provide-injected in and used from w-accordion-item.
1096
+ // Provide-injected and used from w-accordion-item.
1099
1097
  // Only when w-accordion-item is directly used outside of Wave UI.
1100
1098
  registerItem(e) {
1101
- var t;
1102
- return this.accordionItemsProvided && (e._index = this.state.accordionItems.length, e._expanded = ((t = this.modelValue) == null ? void 0 : t[e._index]) ?? !1, e._disabled = !!e.disabled, this.state.accordionItems.push(e)), e._index;
1099
+ var t, i;
1100
+ e._index = this.accordionItems.length, e = Object.assign(e, (t = this.items) == null ? void 0 : t[e._index]), e._expanded = ((i = this.modelValue) == null ? void 0 : i[e._index]) ?? !1, e._disabled = !!e._disabled, this.accordionItems.push(e);
1101
+ },
1102
+ // Provide-injected and used from w-accordion-item.
1103
+ unregisterItem(e) {
1104
+ var i;
1105
+ const t = (i = this.getAccordionItem(e)) == null ? void 0 : i._index;
1106
+ t !== void 0 && this.accordionItems.splice(t, 1);
1103
1107
  }
1104
1108
  },
1105
1109
  created() {
1106
- !this.accordionItemsProvided && this.items && this.updateItems();
1110
+ isNaN(this.items) || D(
1111
+ "Since version 3.17.3, the w-accordion `items` prop can no longer be a Number.\n Please use the w-accordion-item component instead for advanced custom rendering.\n https://antoniandre.github.io/wave-ui/w-accordion#w-accordion-item"
1112
+ );
1113
+ },
1114
+ unmounted() {
1115
+ this.accordionItems = [];
1107
1116
  },
1108
1117
  watch: {
1109
- modelValue() {
1110
- this.updateItems();
1111
- },
1112
- items() {
1118
+ modelValue(e) {
1119
+ if (this.expandSingle) {
1120
+ const t = e.findIndex((i) => !!i);
1121
+ t > -1 && (e = e.fill(!1, t + 1));
1122
+ }
1123
+ e.forEach((t, i) => (this.accordionItems[i] || {})._expanded = t);
1113
1124
  }
1114
1125
  }
1115
1126
  }, dt = /* @__PURE__ */ C(rt, [["render", nt]]), ut = { class: "w-alert__content" };
@@ -1791,7 +1802,7 @@ const At = {
1791
1802
  };
1792
1803
  return {
1793
1804
  ...this.$attrs,
1794
- onClick: !this.disabled && (e ? t : this.$attrs.onClick)
1805
+ onClick: !this.disabled && !this.loading && (e ? t : this.$attrs.onClick)
1795
1806
  };
1796
1807
  },
1797
1808
  size() {
@@ -6908,14 +6919,14 @@ const we = 15, bo = {
6908
6919
  filter: { type: Function },
6909
6920
  fetch: { type: Function },
6910
6921
  expandableRows: {
6911
- validator: (e) => ([void 0, !0, !1, 1, "1", ""].includes(e) || F(
6922
+ validator: (e) => ([void 0, !0, !1, 1, "1", ""].includes(e) || D(
6912
6923
  `Wrong value for the w-table's \`expandableRows\` prop. Given: "${e}", expected one of: [undefined, true, false, 1, '1', ''].`
6913
6924
  ), !0)
6914
6925
  },
6915
6926
  // Allow providing the expanded rows and keeping it in sync via .sync in Vue 2 or v-model:expandedRows in Vue 3.
6916
6927
  expandedRows: { type: Array },
6917
6928
  selectableRows: {
6918
- validator: (e) => ([void 0, !0, !1, 1, "1", ""].includes(e) || F(
6929
+ validator: (e) => ([void 0, !0, !1, 1, "1", ""].includes(e) || D(
6919
6930
  `Wrong value for the w-table's \`selectableRows\` prop. Given: "${e}", expected one of: [undefined, true, false, 1, '1', ''].`
6920
6931
  ), !0)
6921
6932
  },
@@ -6938,7 +6949,7 @@ const we = 15, bo = {
6938
6949
  validator: (e) => {
6939
6950
  if (e) {
6940
6951
  if (typeof e == "object" && (!e.itemsPerPage || e.page && isNaN(e.page)))
6941
- return F(
6952
+ return D(
6942
6953
  "Wrong pagination config received in the w-table's `pagination` prop (received: `" + JSON.stringify(e) + "`). \nExpected object: { itemsPerPage: Integer, page: Integer } or { itemsPerPage: Integer, start: Integer }."
6943
6954
  ), !1;
6944
6955
  } else return !0;