@cocoar/vue-ui 1.7.0 → 1.8.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
@@ -2538,8 +2538,17 @@ var tt = { class: "coar-code-header" }, nt = { class: "coar-code-header-left" },
2538
2538
  //#region src/components/select/useSelectBase.ts
2539
2539
  function fn(e) {
2540
2540
  let t = E(!1), n = E(!1), i = E(""), a = E(-1), o = E("bottom"), s = `coar-select-${crypto.randomUUID?.() ?? Date.now().toString(16)}`, c = r(() => e.id.value || s), l = r(() => `${c.value}-message`), u = r(() => `${c.value}-listbox`), d = r(() => {
2541
- let t = i.value.toLowerCase().trim(), n = t ? e.options.value.filter((e) => e.label.toLowerCase().includes(t)) : e.options.value;
2542
- return n.some((e) => e.group) ? [...n].sort((e, t) => !e.group && !t.group ? 0 : e.group ? t.group ? e.group.localeCompare(t.group) : 1 : -1) : n;
2541
+ let t = i.value.toLowerCase().trim(), n = t ? e.options.value.filter((e) => e.label.toLowerCase().includes(t)) : e.options.value, r = e.sortOptions.value, a = e.sortGroups.value, o = n.some((e) => e.group), s = typeof r == "function" ? r : r === "asc" ? (e, t) => e.label.localeCompare(t.label) : r === "desc" ? (e, t) => t.label.localeCompare(e.label) : null;
2542
+ if (!o) return s ? [...n].sort(s) : n;
2543
+ let c = typeof a == "function" ? a : a === "asc" ? (e, t) => e.localeCompare(t) : a === "desc" ? (e, t) => t.localeCompare(e) : null, l = [], u = /* @__PURE__ */ new Map(), d = [];
2544
+ for (let e of n) e.group ? (u.has(e.group) || (l.push(e.group), u.set(e.group, [])), u.get(e.group).push(e)) : d.push(e);
2545
+ if (c && l.sort(c), s) {
2546
+ d.sort(s);
2547
+ for (let e of u.values()) e.sort(s);
2548
+ }
2549
+ let f = [...d];
2550
+ for (let e of l) f.push(...u.get(e));
2551
+ return f;
2543
2552
  });
2544
2553
  B(d, () => {
2545
2554
  a.value = -1;
@@ -4420,7 +4429,15 @@ var Uo = { class: "coar-select-wrapper" }, Wo = [
4420
4429
  type: Function,
4421
4430
  default: void 0
4422
4431
  },
4423
- dropdownPosition: { default: "auto" }
4432
+ dropdownPosition: { default: "auto" },
4433
+ sortGroups: {
4434
+ type: [String, Function],
4435
+ default: "asc"
4436
+ },
4437
+ sortOptions: {
4438
+ type: [String, Function],
4439
+ default: "none"
4440
+ }
4424
4441
  }, {
4425
4442
  modelValue: { default: null },
4426
4443
  modelModifiers: {}
@@ -4433,7 +4450,9 @@ var Uo = { class: "coar-select-wrapper" }, Wo = [
4433
4450
  disabled: N(u, "disabled"),
4434
4451
  readonly: N(u, "readonly"),
4435
4452
  id: N(u, "id"),
4436
- dropdownPositionPreference: N(u, "dropdownPosition")
4453
+ dropdownPositionPreference: N(u, "dropdownPosition"),
4454
+ sortGroups: N(u, "sortGroups"),
4455
+ sortOptions: N(u, "sortOptions")
4437
4456
  }), te = r(() => u.id || m?.inputId.value || j.value), ne = r(() => m?.messageId.value || void 0), { left: re, top: ie, minWidth: ae } = En({
4438
4457
  isOpen: E,
4439
4458
  triggerEl: v,
@@ -4595,7 +4614,7 @@ var Uo = { class: "coar-select-wrapper" }, Wo = [
4595
4614
  defer: !1
4596
4615
  }]])], 14, Jo)) : a("", !0)]))])], 2));
4597
4616
  }
4598
- }), [["__scopeId", "data-v-9d5cd526"]]), ts = null, ns = 0;
4617
+ }), [["__scopeId", "data-v-c097763c"]]), ts = null, ns = 0;
4599
4618
  function rs(e) {
4600
4619
  let t = e.value;
4601
4620
  return typeof t == "string" ? { content: t } : t;
@@ -4838,7 +4857,15 @@ var ms = /* @__PURE__ */ new WeakMap(), hs = {
4838
4857
  type: Function,
4839
4858
  default: void 0
4840
4859
  },
4841
- dropdownPosition: { default: "auto" }
4860
+ dropdownPosition: { default: "auto" },
4861
+ sortGroups: {
4862
+ type: [String, Function],
4863
+ default: "asc"
4864
+ },
4865
+ sortOptions: {
4866
+ type: [String, Function],
4867
+ default: "none"
4868
+ }
4842
4869
  }, {
4843
4870
  modelValue: { default: () => [] },
4844
4871
  modelModifiers: {}
@@ -4851,7 +4878,9 @@ var ms = /* @__PURE__ */ new WeakMap(), hs = {
4851
4878
  disabled: N(c, "disabled"),
4852
4879
  readonly: N(c, "readonly"),
4853
4880
  id: N(c, "id"),
4854
- dropdownPositionPreference: N(c, "dropdownPosition")
4881
+ dropdownPositionPreference: N(c, "dropdownPosition"),
4882
+ sortGroups: N(c, "sortGroups"),
4883
+ sortOptions: N(c, "sortOptions")
4855
4884
  }), q = r(() => c.id || p?.inputId.value || A.value), te = r(() => p?.messageId.value || void 0), { left: ne, top: re, minWidth: ie } = En({
4856
4885
  isOpen: T,
4857
4886
  triggerEl: h,
@@ -5051,7 +5080,7 @@ var ms = /* @__PURE__ */ new WeakMap(), hs = {
5051
5080
  defer: !1
5052
5081
  }]])], 14, Ss)) : a("", !0)]))])], 2));
5053
5082
  }
5054
- }), [["__scopeId", "data-v-29389b8d"]]), Ps = { class: "coar-select-wrapper" }, Fs = { class: "coar-tag-select-tags" }, Is = { class: "coar-tag-select-tag-label" }, Ls = ["aria-label", "onClick"], Rs = [
5083
+ }), [["__scopeId", "data-v-f8a0a781"]]), Ps = { class: "coar-select-wrapper" }, Fs = { class: "coar-tag-select-tags" }, Is = { class: "coar-tag-select-tag-label" }, Ls = ["aria-label", "onClick"], Rs = [
5055
5084
  "id",
5056
5085
  "placeholder",
5057
5086
  "disabled",
@@ -5101,7 +5130,15 @@ var ms = /* @__PURE__ */ new WeakMap(), hs = {
5101
5130
  type: Function,
5102
5131
  default: void 0
5103
5132
  },
5104
- dropdownPosition: { default: "auto" }
5133
+ dropdownPosition: { default: "auto" },
5134
+ sortGroups: {
5135
+ type: [String, Function],
5136
+ default: "asc"
5137
+ },
5138
+ sortOptions: {
5139
+ type: [String, Function],
5140
+ default: "none"
5141
+ }
5105
5142
  }, {
5106
5143
  modelValue: { default: () => [] },
5107
5144
  modelModifiers: {}
@@ -5114,7 +5151,9 @@ var ms = /* @__PURE__ */ new WeakMap(), hs = {
5114
5151
  disabled: N(c, "disabled"),
5115
5152
  readonly: N(c, "readonly"),
5116
5153
  id: N(c, "id"),
5117
- dropdownPositionPreference: N(c, "dropdownPosition")
5154
+ dropdownPositionPreference: N(c, "dropdownPosition"),
5155
+ sortGroups: N(c, "sortGroups"),
5156
+ sortOptions: N(c, "sortOptions")
5118
5157
  }), q = r(() => c.id || p?.inputId.value || z.value), te = r(() => p?.messageId.value || void 0), { left: ne, top: re, minWidth: ie } = En({
5119
5158
  isOpen: A,
5120
5159
  triggerEl: h,
@@ -5264,7 +5303,7 @@ var ms = /* @__PURE__ */ new WeakMap(), hs = {
5264
5303
  defer: !1
5265
5304
  }]])], 14, zs)) : a("", !0)]))])], 2));
5266
5305
  }
5267
- }), [["__scopeId", "data-v-8b78bca7"]]), Gs = {
5306
+ }), [["__scopeId", "data-v-259216f6"]]), Gs = {
5268
5307
  anchor: {
5269
5308
  kind: "virtual",
5270
5309
  placement: "center"
@@ -7022,21 +7061,23 @@ var Ml = /* @__PURE__ */ Y(kl, [["render", jl], ["__scopeId", "data-v-a0d5d1e3"]
7022
7061
  }
7023
7062
  });
7024
7063
  let C = r(() => n.disabled ? -1 : p ? p.items.value.findIndex((e) => e.el === v.value) === p.activeIndex.value ? 0 : -1 : 0), w = null;
7025
- d.onChildPanelEnter = () => L(), yl(() => {
7026
- D();
7064
+ d.onChildPanelEnter = () => R();
7065
+ let T = bl();
7066
+ yl(() => {
7067
+ k(), T?.();
7027
7068
  });
7028
- function T(e) {
7069
+ function D(e) {
7029
7070
  m.value || (d.closeSiblings(), m.value = !0, g(() => {
7030
- k(e), d.overlayRef = {
7071
+ A(e), d.overlayRef = {
7031
7072
  panelEl: h.value,
7032
- close: () => D()
7073
+ close: () => k()
7033
7074
  }, u?.notifyChildOpened();
7034
7075
  }));
7035
7076
  }
7036
- function D() {
7077
+ function k() {
7037
7078
  m.value && (m.value = !1, d.overlayRef &&= null, u?.notifyChildClosed(d));
7038
7079
  }
7039
- function k(e) {
7080
+ function A(e) {
7040
7081
  let t = h.value;
7041
7082
  if (!t) return;
7042
7083
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = bn({
@@ -7060,79 +7101,79 @@ var Ml = /* @__PURE__ */ Y(kl, [["render", jl], ["__scopeId", "data-v-a0d5d1e3"]
7060
7101
  });
7061
7102
  t.style.left = `${i.left}px`, t.style.top = `${i.top}px`;
7062
7103
  }
7063
- function A(e) {
7104
+ function j(e) {
7064
7105
  if (n.disabled) return;
7065
- L();
7106
+ R();
7066
7107
  let t = e.currentTarget;
7067
- u ? u.requestOpenFromChild(d, () => T(t), {
7108
+ u ? u.requestOpenFromChild(d, () => D(t), {
7068
7109
  x: e.clientX,
7069
7110
  y: e.clientY
7070
- }) : T(t);
7071
- }
7072
- function j() {
7073
- n.disabled || I();
7111
+ }) : D(t);
7074
7112
  }
7075
7113
  function N() {
7076
- L(), u?.cancelAncestorCloseTimers();
7114
+ n.disabled || L();
7077
7115
  }
7078
7116
  function P() {
7079
- I();
7117
+ R(), u?.cancelAncestorCloseTimers();
7080
7118
  }
7081
7119
  function I() {
7082
- L(), w = setTimeout(() => {
7083
- D();
7084
- }, 80);
7120
+ L();
7085
7121
  }
7086
7122
  function L() {
7123
+ R(), w = setTimeout(() => {
7124
+ k();
7125
+ }, 80);
7126
+ }
7127
+ function R() {
7087
7128
  w &&= (clearTimeout(w), null);
7088
7129
  }
7089
- function R(e) {
7130
+ function z(e) {
7090
7131
  if (n.disabled) {
7091
7132
  e.preventDefault(), e.stopPropagation();
7092
7133
  return;
7093
7134
  }
7094
- e.stopPropagation(), m.value ? D() : T(e.currentTarget);
7135
+ e.stopPropagation(), m.value ? k() : D(e.currentTarget);
7095
7136
  }
7096
- function z(e) {
7137
+ function V(e) {
7097
7138
  if (!n.disabled) {
7098
7139
  if (e.key === "Enter" || e.key === " ") {
7099
- e.preventDefault(), m.value ? D() : T(v.value);
7140
+ e.preventDefault(), m.value ? k() : D(v.value);
7100
7141
  return;
7101
7142
  }
7102
7143
  if (e.key === "ArrowRight") {
7103
- e.preventDefault(), e.stopPropagation(), m.value || T(v.value), g(() => {
7144
+ e.preventDefault(), e.stopPropagation(), m.value || D(v.value), g(() => {
7104
7145
  (h.value?.querySelector("[role=\"menuitem\"]:not([aria-disabled=\"true\"])"))?.focus();
7105
7146
  });
7106
7147
  return;
7107
7148
  }
7108
7149
  if (e.key === "ArrowLeft") {
7109
- m.value && (e.preventDefault(), e.stopPropagation(), D(), v.value?.focus());
7150
+ m.value && (e.preventDefault(), e.stopPropagation(), k(), v.value?.focus());
7110
7151
  return;
7111
7152
  }
7112
7153
  }
7113
7154
  }
7114
- let V = null;
7115
- function H(e) {
7155
+ let H = null;
7156
+ function U(e) {
7116
7157
  if (!m.value) return;
7117
- if (e === V) {
7118
- V = null;
7158
+ if (e === H) {
7159
+ H = null;
7119
7160
  return;
7120
7161
  }
7121
- V = null;
7162
+ H = null;
7122
7163
  let t = e.target;
7123
- v.value?.contains(t) || h.value?.contains(t) || D();
7124
- }
7125
- let U = !1;
7126
- function W() {
7127
- U ||= (document.addEventListener("click", H), !0);
7164
+ v.value?.contains(t) || h.value?.contains(t) || k();
7128
7165
  }
7166
+ let W = !1;
7129
7167
  function G() {
7130
- document.removeEventListener("click", H), U = !1;
7168
+ W ||= (document.addEventListener("click", U), !0);
7169
+ }
7170
+ function K() {
7171
+ document.removeEventListener("click", U), W = !1;
7131
7172
  }
7132
7173
  return B(m, (e) => {
7133
- e ? requestAnimationFrame(() => W()) : G();
7174
+ e ? requestAnimationFrame(() => G()) : K();
7134
7175
  }), b(() => {
7135
- y?.(), L(), G(), d.destroy();
7176
+ y?.(), R(), K(), d.destroy();
7136
7177
  }), (e, r) => (S(), o("div", Vl, [s("div", {
7137
7178
  ref_key: "itemRef",
7138
7179
  ref: v,
@@ -7146,10 +7187,10 @@ var Ml = /* @__PURE__ */ Y(kl, [["render", jl], ["__scopeId", "data-v-a0d5d1e3"]
7146
7187
  "aria-controls": c,
7147
7188
  "aria-disabled": n.disabled || void 0,
7148
7189
  tabindex: C.value,
7149
- onMouseenter: A,
7150
- onMouseleave: j,
7151
- onClick: R,
7152
- onKeydown: z
7190
+ onMouseenter: j,
7191
+ onMouseleave: N,
7192
+ onClick: z,
7193
+ onKeydown: V
7153
7194
  }, [
7154
7195
  s("span", Ul, [l(X, {
7155
7196
  name: n.icon || "square-dashed",
@@ -7168,11 +7209,11 @@ var Ml = /* @__PURE__ */ Y(kl, [["render", jl], ["__scopeId", "data-v-a0d5d1e3"]
7168
7209
  ref_key: "panelRef",
7169
7210
  ref: h,
7170
7211
  class: "coar-submenu-panel",
7171
- onMouseenter: N,
7172
- onMouseleave: P
7212
+ onMouseenter: P,
7213
+ onMouseleave: I
7173
7214
  }, [O(e.$slots, "default", {}, void 0, !0)], 544)) : a("", !0)]))]));
7174
7215
  }
7175
- }), [["__scopeId", "data-v-da19ff9a"]]), Kl = /* @__PURE__ */ u({
7216
+ }), [["__scopeId", "data-v-4f413627"]]), Kl = /* @__PURE__ */ u({
7176
7217
  __name: "CoarContextMenu",
7177
7218
  props: { menu: {} },
7178
7219
  setup(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocoar/vue-ui",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Cocoar Design System — a touch-first Vue 3 component library with 30+ accessible, themeable components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -48,7 +48,7 @@
48
48
  "lint": "eslint src/"
49
49
  },
50
50
  "dependencies": {
51
- "@cocoar/vue-localization": "1.7.0",
51
+ "@cocoar/vue-localization": "1.8.0",
52
52
  "@fontsource/inter": "^5.2.8",
53
53
  "@fontsource/poppins": "^5.2.7",
54
54
  "@js-temporal/polyfill": "^0.5.1",