@nmorph/nmorph-ui-kit 3.0.6 → 3.0.7

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.
@@ -1,18 +1,18 @@
1
1
  import './NmorphImagePreview.css';
2
- import { defineComponent as $, ref as g, watch as h, computed as t, onBeforeUnmount as Z } from "vue";
3
- import { useModifiers as j } from "../../../utils/create-modifiers.js";
4
- import { createCssSizeVariables as U } from "../../../utils/common.js";
5
- import W from "../nmorph-preview-portal/NmorphPreviewPortal.vue.js";
6
- import J from "../../../assets/icons/shrink.svg.js";
7
- import Q from "../../../assets/icons/rotate-right.svg.js";
8
- import X from "../../../assets/icons/rotate-left.svg.js";
9
- import Y from "../../../assets/icons/zoom-in.svg.js";
10
- import ee from "../../../assets/icons/zoom-out.svg.js";
11
- import re from "../../../assets/icons/enlarge.svg.js";
12
- import te from "../../basic/nmorph-icon/NmorphIcon.vue.js";
13
- import ae from "../../basic/nmorph-button/NmorphButton.vue.js";
14
- import ie from "../nmorph-image/NmorphImage.vue.js";
15
- const Ne = /* @__PURE__ */ $({
2
+ import { defineComponent as ee, ref as w, watch as I, computed as a, onBeforeUnmount as te } from "vue";
3
+ import { useModifiers as re } from "../../../utils/create-modifiers.js";
4
+ import { createCssSizeVariables as ae } from "../../../utils/common.js";
5
+ import oe from "../nmorph-preview-portal/NmorphPreviewPortal.vue.js";
6
+ import le from "../../../assets/icons/shrink.svg.js";
7
+ import ne from "../../../assets/icons/rotate-right.svg.js";
8
+ import ie from "../../../assets/icons/rotate-left.svg.js";
9
+ import ue from "../../../assets/icons/zoom-in.svg.js";
10
+ import se from "../../../assets/icons/zoom-out.svg.js";
11
+ import me from "../../../assets/icons/enlarge.svg.js";
12
+ import de from "../../basic/nmorph-icon/NmorphIcon.vue.js";
13
+ import ce from "../../basic/nmorph-button/NmorphButton.vue.js";
14
+ import ge from "../nmorph-image/NmorphImage.vue.js";
15
+ const _e = /* @__PURE__ */ ee({
16
16
  __name: "NmorphImagePreview",
17
17
  props: {
18
18
  modelValue: { type: Boolean, required: !1, default: !1 },
@@ -38,117 +38,141 @@ const Ne = /* @__PURE__ */ $({
38
38
  triggerGap: { type: [Number, String], required: !1, default: 8 }
39
39
  },
40
40
  emits: ["update:model-value"],
41
- setup(V, { expose: C, emit: H }) {
42
- C();
43
- const r = V, l = g(r.modelValue);
44
- h(
45
- () => r.modelValue,
41
+ setup(O, { expose: D, emit: E }) {
42
+ D();
43
+ const t = O, l = w(t.modelValue);
44
+ I(
45
+ () => t.modelValue,
46
46
  (e) => l.value = e
47
47
  );
48
- const a = t(() => Array.isArray(r.src) ? r.src : [r.src]), s = (e) => {
49
- const o = a.value.length - 1;
50
- return o < 0 || e < 0 ? 0 : e > o ? o : e;
51
- }, u = g(s(r.initialIndex)), d = t(() => s(u.value)), K = t(() => a.value[d.value] || ""), v = t(() => r.triggerView === "gallery" && a.value.length > 1), y = t(() => !r.triggerLimit || r.triggerLimit < 1 ? a.value.length : Math.min(Math.floor(r.triggerLimit), a.value.length)), m = t(
52
- () => a.value.slice(0, y.value).map((e, o) => ({
53
- index: o,
48
+ const o = a(() => Array.isArray(t.src) ? t.src : [t.src]), s = (e) => {
49
+ const r = o.value.length - 1;
50
+ return r < 0 || e < 0 ? 0 : e > r ? r : e;
51
+ }, i = w(s(t.initialIndex)), u = a(() => s(i.value)), b = a(() => o.value[u.value] || ""), p = a(() => t.triggerView === "gallery" && o.value.length > 1), q = a(() => !t.triggerLimit || t.triggerLimit < 1 ? o.value.length : Math.min(Math.floor(t.triggerLimit), o.value.length)), d = a(
52
+ () => o.value.slice(0, q.value).map((e, r) => ({
53
+ index: r,
54
54
  src: e
55
55
  }))
56
- ), M = t(() => a.value.length - m.value.length), P = t(() => m.value[m.value.length - 1]?.index ?? -1), R = t(
57
- () => j({
58
- "nmorph-image-preview": [l.value && "opened", v.value && "gallery-trigger"]
56
+ ), G = a(() => o.value.length - d.value.length), j = a(() => d.value[d.value.length - 1]?.index ?? -1), F = a(
57
+ () => re({
58
+ "nmorph-image-preview": [l.value && "opened", p.value && "gallery-trigger"]
59
59
  })
60
- ), i = g(1);
61
- h(
62
- () => [r.initialIndex, a.value.length],
60
+ ), c = w(/* @__PURE__ */ new Map()), x = (e, r) => e || `__empty-image-${r}`, f = a(() => x(b.value, u.value)), g = a(
61
+ () => c.value.get(f.value) || {
62
+ rotateLevel: 0,
63
+ scaleLevel: 1
64
+ }
65
+ ), v = a(() => g.value.rotateLevel), m = a(() => g.value.scaleLevel), Z = a(() => `rotate(${v.value}deg) scale(${m.value})`), T = (e) => {
66
+ const r = new Map(c.value);
67
+ r.set(f.value, e), c.value = r;
68
+ }, n = (e) => {
69
+ T({
70
+ ...g.value,
71
+ ...e
72
+ });
73
+ }, h = (e) => {
74
+ const r = e % 360;
75
+ return Object.is(r, -0) ? 0 : r;
76
+ }, y = (e) => parseFloat(Math.min(Math.max(e, t.minScaleLevel), t.maxScaleLevel).toFixed(3));
77
+ I(
78
+ () => [t.initialIndex, o.value.length],
63
79
  () => {
64
- u.value = s(r.initialIndex);
80
+ i.value = s(t.initialIndex);
65
81
  }
66
82
  );
67
- const N = (e) => {
68
- u.value = s(e), l.value = !0, f("update:model-value", l.value);
83
+ const _ = (e) => {
84
+ i.value = s(e), l.value = !0, S("update:model-value", l.value);
85
+ }, U = () => {
86
+ p.value || _(u.value);
87
+ }, W = () => {
88
+ l.value = !1, S("update:model-value", l.value);
89
+ }, B = () => {
90
+ n({
91
+ rotateLevel: h(v.value + 90)
92
+ });
93
+ }, k = () => {
94
+ n({
95
+ rotateLevel: h(v.value - 90)
96
+ });
97
+ }, M = () => {
98
+ n({
99
+ scaleLevel: y(m.value + t.scaleStep)
100
+ });
101
+ }, A = () => {
102
+ n({
103
+ scaleLevel: y(m.value - t.scaleStep)
104
+ });
105
+ }, C = a(() => m.value < 1), K = () => {
106
+ n({ scaleLevel: 1 });
107
+ }, V = () => {
108
+ n({ scaleLevel: 1 });
69
109
  }, z = () => {
70
- v.value || N(d.value);
71
- }, F = () => {
72
- l.value = !1, f("update:model-value", l.value);
73
- }, S = () => {
74
- n.value = n.value + 90, n.value >= 360 && (n.value = 0);
75
- }, w = () => {
76
- n.value = n.value - 90, n.value <= -360 && (n.value = 0);
77
- }, I = () => {
78
- i.value < r.maxScaleLevel && (i.value += r.scaleStep), i.value = parseFloat(i.value.toFixed(3));
79
- }, b = () => {
80
- i.value > r.minScaleLevel && (i.value -= r.scaleStep), i.value = parseFloat(i.value.toFixed(3));
81
- }, L = t(() => i.value < 1), q = () => {
82
- i.value = 1;
83
- }, x = () => {
84
- i.value = 1;
85
- }, n = g(0), B = () => {
86
- const e = a.value.length;
110
+ const e = o.value.length;
87
111
  if (!e) return;
88
- const o = d.value - 1;
89
- u.value = o < 0 ? e - 1 : o;
90
- }, _ = () => {
91
- const e = a.value.length;
112
+ const r = u.value - 1;
113
+ i.value = r < 0 ? e - 1 : r;
114
+ }, H = () => {
115
+ const e = o.value.length;
92
116
  if (!e) return;
93
- const o = d.value + 1;
94
- u.value = o > e - 1 ? 0 : o;
95
- }, p = (e) => {
96
- !l.value || a.value.length < 2 || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || (e.key === "ArrowLeft" && (e.preventDefault(), B()), e.key === "ArrowRight" && (e.preventDefault(), _()));
97
- }, k = () => {
98
- typeof document > "u" || document.addEventListener("keydown", p);
99
- }, c = () => {
100
- typeof document > "u" || document.removeEventListener("keydown", p);
117
+ const r = u.value + 1;
118
+ i.value = r > e - 1 ? 0 : r;
119
+ }, N = (e) => {
120
+ !l.value || o.value.length < 2 || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || (e.key === "ArrowLeft" && (e.preventDefault(), z()), e.key === "ArrowRight" && (e.preventDefault(), H()));
121
+ }, R = () => {
122
+ typeof document > "u" || document.addEventListener("keydown", N);
123
+ }, L = () => {
124
+ typeof document > "u" || document.removeEventListener("keydown", N);
101
125
  };
102
- h(
126
+ I(
103
127
  l,
104
128
  (e) => {
105
- e ? k() : c();
129
+ e ? R() : L();
106
130
  },
107
131
  { immediate: !0 }
108
- ), Z(c);
109
- const D = t(() => {
132
+ ), te(L);
133
+ const J = a(() => {
110
134
  let e = {
111
- icon: J,
112
- handler: x
135
+ icon: le,
136
+ handler: V
113
137
  };
114
- return L.value && (e = {
115
- icon: re,
116
- handler: q
138
+ return C.value && (e = {
139
+ icon: me,
140
+ handler: K
117
141
  }), e;
118
- }), E = [
142
+ }), Q = [
119
143
  {
120
- icon: Q,
121
- handler: S
144
+ icon: ne,
145
+ handler: B
122
146
  },
123
147
  {
124
- icon: X,
125
- handler: w
148
+ icon: ie,
149
+ handler: k
126
150
  },
127
151
  {
128
- icon: Y,
129
- handler: I
152
+ icon: ue,
153
+ handler: M
130
154
  },
131
155
  {
132
- icon: ee,
133
- handler: b
156
+ icon: se,
157
+ handler: A
134
158
  }
135
- ], f = H, T = t(() => a.value.length > 1), G = t(() => r.showNavigationButtons && T.value), O = t(
136
- () => U({
137
- "--nmorph-private-image-preview-trigger-width": r.width,
138
- "--nmorph-private-image-preview-trigger-height": r.height,
139
- "--nmorph-private-image-preview-radius": r.radius,
140
- "--nmorph-private-image-preview-trigger-gap": r.triggerGap
159
+ ], S = E, $ = a(() => o.value.length > 1), X = a(() => t.showNavigationButtons && $.value), Y = a(
160
+ () => ae({
161
+ "--nmorph-private-image-preview-trigger-width": t.width,
162
+ "--nmorph-private-image-preview-trigger-height": t.height,
163
+ "--nmorph-private-image-preview-radius": t.radius,
164
+ "--nmorph-private-image-preview-trigger-gap": t.triggerGap
141
165
  })
142
- ), A = { props: r, open: l, sourceList: a, getClampedIndex: s, currentIndex: u, resolvedCurrentIndex: d, triggerSource: K, showGalleryTrigger: v, triggerSourceLimit: y, triggerSources: m, hiddenTriggerCount: M, lastVisibleTriggerIndex: P, modifiers: R, scaleLevel: i, openPreviewAt: N, clickHandler: z, closeHandler: F, rotateRight: S, rotateLeft: w, zoomIn: I, zoomOut: b, isLevelChangedToMin: L, enlargeToNormal: q, shrinkToNormal: x, rotateLevel: n, previousHandler: B, nextHandler: _, keyboardNavigationHandler: p, addKeyboardNavigationListener: k, removeKeyboardNavigationListener: c, enlargeShrinkActionData: D, actions: E, emit: f, multipleSources: T, showNavigation: G, triggerStyle: O, getTriggerLabel: (e) => r.alt ? `${r.alt} ${e + 1}` : `Image ${e + 1}`, get NmorphImage() {
143
- return ie;
166
+ ), P = { props: t, open: l, sourceList: o, getClampedIndex: s, currentIndex: i, resolvedCurrentIndex: u, triggerSource: b, showGalleryTrigger: p, triggerSourceLimit: q, triggerSources: d, hiddenTriggerCount: G, lastVisibleTriggerIndex: j, modifiers: F, imageTransformStates: c, getImageTransformKey: x, currentTransformKey: f, currentTransformState: g, rotateLevel: v, scaleLevel: m, imageTransform: Z, setCurrentTransformState: T, updateCurrentTransformState: n, normalizeRotateLevel: h, clampScaleLevel: y, openPreviewAt: _, clickHandler: U, closeHandler: W, rotateRight: B, rotateLeft: k, zoomIn: M, zoomOut: A, isLevelChangedToMin: C, enlargeToNormal: K, shrinkToNormal: V, previousHandler: z, nextHandler: H, keyboardNavigationHandler: N, addKeyboardNavigationListener: R, removeKeyboardNavigationListener: L, enlargeShrinkActionData: J, actions: Q, emit: S, multipleSources: $, showNavigation: X, triggerStyle: Y, getTriggerLabel: (e) => t.alt ? `${t.alt} ${e + 1}` : `Image ${e + 1}`, get NmorphImage() {
167
+ return ge;
144
168
  }, get NmorphButton() {
145
- return ae;
169
+ return ce;
146
170
  }, get NmorphIcon() {
147
- return te;
148
- }, NmorphPreviewPortal: W };
149
- return Object.defineProperty(A, "__isScriptSetup", { enumerable: !1, value: !0 }), A;
171
+ return de;
172
+ }, NmorphPreviewPortal: oe };
173
+ return Object.defineProperty(P, "__isScriptSetup", { enumerable: !1, value: !0 }), P;
150
174
  }
151
175
  });
152
176
  export {
153
- Ne as default
177
+ _e as default
154
178
  };
@@ -1,14 +1,14 @@
1
1
  import './NmorphMediaTile.css';
2
- import { defineComponent as E, ref as p, computed as t, watch as q } from "vue";
3
- import { useModifiers as L } from "../../../utils/create-modifiers.js";
4
- import M from "../../../assets/icons/video-camera-off.svg.js";
2
+ import { defineComponent as _, ref as m, computed as t, watch as I } from "vue";
3
+ import { useModifiers as E } from "../../../utils/create-modifiers.js";
4
+ import L from "../../../assets/icons/video-camera-off.svg.js";
5
5
  import A from "../../../assets/icons/share.svg.js";
6
6
  import C from "../../../assets/icons/mute.svg.js";
7
7
  import x from "../../basic/nmorph-icon/NmorphIcon.vue.js";
8
8
  import w from "../../basic/nmorph-button/NmorphButton.vue.js";
9
- import D from "../nmorph-avatar/NmorphAvatar.vue.js";
10
- import R from "../../../assets/icons/loader.svg.js";
11
- const W = /* @__PURE__ */ E({
9
+ import R from "../nmorph-avatar/NmorphAvatar.vue.js";
10
+ import D from "../../../assets/icons/loader.svg.js";
11
+ const W = /* @__PURE__ */ _({
12
12
  __name: "NmorphMediaTile",
13
13
  props: {
14
14
  src: { type: String, required: !1, default: "" },
@@ -32,23 +32,21 @@ const W = /* @__PURE__ */ E({
32
32
  error: { type: Boolean, required: !1, default: !1 },
33
33
  errorText: { type: String, required: !1, default: "" }
34
34
  },
35
- setup(B, { expose: I }) {
36
- const e = B, o = p(null), a = p(null), u = p({
35
+ setup(j, { expose: N }) {
36
+ const e = j, o = m(null), n = m(null), u = m({
37
37
  audio: 0,
38
38
  video: 0
39
- }), v = t(() => !!(e.src || e.srcObject)), m = (r) => !r || typeof r.getAudioTracks != "function" ? [] : r.getAudioTracks(), y = (r) => !r || typeof r.getVideoTracks != "function" ? [] : r.getVideoTracks(), d = (r) => {
39
+ }), y = t(() => !!(e.src || e.srcObject)), h = (r) => !r || typeof r.getAudioTracks != "function" ? [] : r.getAudioTracks(), g = (r) => !r || typeof r.getVideoTracks != "function" ? [] : r.getVideoTracks(), d = (r) => {
40
40
  u.value = {
41
- audio: m(r).length,
42
- video: y(r).length
41
+ audio: h(r).length,
42
+ video: g(r).length
43
43
  };
44
- }, h = t(() => typeof e.srcObject?.getVideoTracks == "function"), g = t(() => u.value.audio > 0), k = t(() => u.value.video > 0), S = t(
45
- () => !!(e.src || e.srcObject && (!h.value || k.value))
46
- ), n = t(() => v.value && S.value && !e.videoOff && !e.error), i = t(
47
- () => !!(e.srcObject && !e.muted && !e.error && g.value)
48
- ), j = t(() => e.muted || i.value), N = t(() => n.value && e.src ? e.src : void 0), O = t(
44
+ }, k = t(() => typeof e.srcObject?.getVideoTracks == "function"), O = t(() => u.value.video > 0), S = t(
45
+ () => !!(e.src || e.srcObject && (!k.value || O.value))
46
+ ), c = t(() => y.value && S.value && !e.videoOff && !e.error), i = t(() => !!(e.srcObject && !e.muted && !e.error)), b = t(() => e.muted || i.value), T = t(() => c.value && e.src ? e.src : void 0), q = t(
49
47
  () => e.name.split(/\s+/).filter(Boolean).slice(0, 2).map((r) => r[0]?.toUpperCase()).join("")
50
- ), T = t(() => O.value || e.name || "?"), V = t(
51
- () => L({
48
+ ), M = t(() => q.value || e.name || "?"), V = t(
49
+ () => E({
52
50
  "nmorph-media-tile": [
53
51
  e.fit,
54
52
  e.mirrored && "mirrored",
@@ -62,62 +60,74 @@ const W = /* @__PURE__ */ E({
62
60
  })
63
61
  ), s = (r) => {
64
62
  if (!r || e.sinkId === void 0) return;
65
- const f = r;
66
- typeof f.setSinkId == "function" && f.setSinkId(e.sinkId).catch(() => {
67
- });
68
- }, c = (r) => {
69
- !r || !e.autoplay || r.play().catch(() => {
63
+ const a = r;
64
+ typeof a.setSinkId == "function" && a.setSinkId(e.sinkId).catch(() => {
70
65
  });
66
+ }, f = (r) => {
67
+ console.warn("[NmorphMediaTile] media autoplay failed", r);
68
+ }, p = (r) => {
69
+ if (!r || !e.autoplay) return;
70
+ let a;
71
+ try {
72
+ a = r.play();
73
+ } catch (v) {
74
+ f(v);
75
+ return;
76
+ }
77
+ a && typeof a.catch == "function" && a.catch(f);
71
78
  };
72
- q(
79
+ I(
73
80
  () => e.srcObject,
74
- (r, f, _) => {
81
+ (r, a, v) => {
75
82
  if (d(r), !r || typeof r.addEventListener != "function" || typeof r.removeEventListener != "function")
76
83
  return;
77
84
  const l = () => d(r);
78
- r.addEventListener("addtrack", l), r.addEventListener("removetrack", l), _(() => {
85
+ r.addEventListener("addtrack", l), r.addEventListener("removetrack", l), v(() => {
79
86
  r.removeEventListener("addtrack", l), r.removeEventListener("removetrack", l);
80
87
  });
81
88
  },
82
89
  { immediate: !0 }
83
- ), q(
90
+ ), I(
84
91
  () => [
85
92
  e.srcObject,
86
93
  e.sinkId,
87
94
  e.autoplay,
88
- n.value,
95
+ e.videoOff,
96
+ e.error,
97
+ c.value,
89
98
  i.value,
99
+ b.value,
90
100
  o.value,
91
- a.value
101
+ n.value
92
102
  ],
93
103
  () => {
94
104
  if (o.value) {
95
- const r = n.value ? e.srcObject : null;
96
- o.value.srcObject !== r && (o.value.srcObject = r), s(o.value), e.autoplay && n.value && r && c(o.value);
105
+ const r = e.srcObject;
106
+ o.value.srcObject !== r && (o.value.srcObject = r), s(o.value), e.autoplay && r && !e.videoOff && !e.error && p(o.value);
97
107
  }
98
- if (a.value) {
108
+ if (n.value) {
99
109
  const r = i.value ? e.srcObject : null;
100
- a.value.srcObject !== r && (a.value.srcObject = r), s(a.value), e.autoplay && i.value && c(a.value);
110
+ n.value.srcObject !== r && (n.value.srcObject = r), s(n.value), e.autoplay && i.value && p(n.value);
101
111
  }
102
112
  },
103
113
  { immediate: !0, flush: "post" }
104
- ), I({ videoRef: o });
105
- const b = { props: e, videoRef: o, audioRef: a, srcObjectTrackCount: u, hasMediaSource: v, getAudioTracks: m, getVideoTracks: y, updateSrcObjectTrackCount: d, canInspectVideoTracks: h, hasAudioTracks: g, hasVideoTracks: k, hasVideoSource: S, videoVisible: n, needsSeparateAudioOutput: i, videoMuted: j, videoSrc: N, initials: O, fallbackLabel: T, modifiers: V, setMediaElementSinkId: s, playMediaElement: c, get NmorphAvatar() {
106
- return D;
114
+ ), N({ videoRef: o });
115
+ const B = { props: e, videoRef: o, audioRef: n, srcObjectTrackCount: u, hasMediaSource: y, getAudioTracks: h, getVideoTracks: g, updateSrcObjectTrackCount: d, canInspectVideoTracks: k, hasVideoTracks: O, hasVideoSource: S, videoVisible: c, needsSeparateAudioOutput: i, videoMuted: b, videoSrc: T, initials: q, fallbackLabel: M, modifiers: V, setMediaElementSinkId: s, logMediaPlaybackError: f, playMediaElement: p, get NmorphAvatar() {
116
+ return R;
107
117
  }, get NmorphButton() {
108
118
  return w;
109
119
  }, get NmorphIcon() {
110
120
  return x;
111
121
  }, get NmorphIconLoaderDots() {
112
- return R;
122
+ return D;
113
123
  }, get NmorphIconMute() {
114
124
  return C;
115
125
  }, get NmorphIconShare() {
116
126
  return A;
117
127
  }, get NmorphIconVideoCameraOff() {
118
- return M;
128
+ return L;
119
129
  } };
120
- return Object.defineProperty(b, "__isScriptSetup", { enumerable: !1, value: !0 }), b;
130
+ return Object.defineProperty(B, "__isScriptSetup", { enumerable: !1, value: !0 }), B;
121
131
  }
122
132
  });
123
133
  export {
@@ -1 +1 @@
1
- .nmorph-pagination{display:flex;justify-content:center;margin-top:var(--indentation-04)}.nmorph-pagination .nmorph-radio-group__content{display:flex;gap:8px;justify-content:center}.nmorph-pagination .nmorph-radio-group{display:inline-flex;align-items:center}.nmorph-pagination .nmorph-radio-group .nmorph-radio:not(:last-child){margin-right:0;margin-bottom:0}.nmorph-pagination .nmorph-pagination__page-group{margin:0 var(--indentation-01)}.nmorph-pagination .nmorph-pagination__prev-icon{rotate:90deg}.nmorph-pagination .nmorph-pagination__next-icon{rotate:-90deg}.nmorph-pagination .nmorph-pagination__prev-btn{margin-right:8px}.nmorph-pagination .nmorph-pagination__next-btn{margin-left:8px}.nmorph-pagination .nmorph-pagination__page-btn{--nmorph-private-control-height: var(--nmorph-private-pagination-height);--nmorph-private-selection-control-size: var(--nmorph-private-pagination-height);width:40px;min-width:40px;height:var(--nmorph-private-pagination-height);min-height:var(--nmorph-private-pagination-height)}.nmorph-pagination .nmorph-pagination__page-btn.nmorph-radio .nmorph-radio__content,.nmorph-pagination .nmorph-pagination__page-btn.nmorph-radio .nmorph-radio__fake{width:100%;height:100%}.nmorph-pagination .nmorph-pagination__page-btn.nmorph-radio.nmorph-radio--nmorph .nmorph-radio__fake{padding:0}.nmorph-pagination .nmorph-pagination__page-btn-wrapper{display:flex}.nmorph-pagination .nmorph-pagination__prev-secondary-btn{margin-right:8px}.nmorph-pagination .nmorph-pagination__next-secondary-btn{margin-left:8px}
1
+ .nmorph-pagination{display:flex;justify-content:center;box-sizing:border-box;width:var(--nmorph-private-pagination-width, 100%);min-width:min(100%,var(--nmorph-private-pagination-min-width, 0px));max-width:100%;margin-top:var(--indentation-04);margin-right:auto;margin-left:auto}.nmorph-pagination.nmorph-pagination--fixed-container{width:var(--nmorph-private-pagination-width, var(--nmorph-private-pagination-fixed-width))}.nmorph-pagination .nmorph-radio-group__content{display:flex;gap:8px;justify-content:center}.nmorph-pagination .nmorph-radio-group{display:inline-flex;align-items:center}.nmorph-pagination .nmorph-radio-group .nmorph-radio:not(:last-child){margin-right:0;margin-bottom:0}.nmorph-pagination .nmorph-pagination__page-group{margin:0 var(--indentation-01)}.nmorph-pagination .nmorph-pagination__prev-icon{rotate:90deg}.nmorph-pagination .nmorph-pagination__next-icon{rotate:-90deg}.nmorph-pagination .nmorph-pagination__prev-btn{margin-right:8px}.nmorph-pagination .nmorph-pagination__next-btn{margin-left:8px}.nmorph-pagination .nmorph-pagination__page-btn{--nmorph-private-control-height: var(--nmorph-private-pagination-height);--nmorph-private-selection-control-size: var(--nmorph-private-pagination-height);width:40px;min-width:40px;height:var(--nmorph-private-pagination-height);min-height:var(--nmorph-private-pagination-height)}.nmorph-pagination .nmorph-pagination__page-btn.nmorph-radio .nmorph-radio__content,.nmorph-pagination .nmorph-pagination__page-btn.nmorph-radio .nmorph-radio__fake{width:100%;height:100%}.nmorph-pagination .nmorph-pagination__page-btn.nmorph-radio.nmorph-radio--nmorph .nmorph-radio__fake{padding:0}.nmorph-pagination .nmorph-pagination__page-btn-wrapper{display:flex}.nmorph-pagination .nmorph-pagination__prev-secondary-btn{margin-right:8px}.nmorph-pagination .nmorph-pagination__next-secondary-btn{margin-left:8px}
@@ -17,7 +17,7 @@ function k(v, r, g, n, f, N) {
17
17
  disabled: n.blockPrevButton || n.interactionDisabled,
18
18
  onClick: n.prevClick
19
19
  }, {
20
- default: e(() => [
20
+ "icon-only": e(() => [
21
21
  i(n.NmorphIcon, { class: "nmorph-pagination__prev-icon" }, {
22
22
  default: e(() => [
23
23
  i(n.NmorphIconChevronDown)
@@ -50,7 +50,7 @@ function k(v, r, g, n, f, N) {
50
50
  text: o.label,
51
51
  thickness: n.props.thickness,
52
52
  disabled: n.interactionDisabled,
53
- onClick: (x) => n.bigStepUpdate(o.value)
53
+ onClick: (y) => n.bigStepUpdate(o.value)
54
54
  }, null, 8, ["class", "text", "thickness", "disabled", "onClick"])) : (a(), s(n.NmorphRadio, {
55
55
  key: 1,
56
56
  value: o.value,
@@ -73,7 +73,7 @@ function k(v, r, g, n, f, N) {
73
73
  disabled: n.blockNextButton || n.interactionDisabled,
74
74
  onClick: n.nextClick
75
75
  }, {
76
- default: e(() => [
76
+ "icon-only": e(() => [
77
77
  i(n.NmorphIcon, { class: "nmorph-pagination__next-icon" }, {
78
78
  default: e(() => [
79
79
  i(n.NmorphIconChevronDown)
@@ -87,7 +87,7 @@ function k(v, r, g, n, f, N) {
87
87
  }, 8, ["thickness", "disabled"])
88
88
  ], 14, b)) : p("v-if", !0);
89
89
  }
90
- const u = /* @__PURE__ */ _(c, [["render", k], ["__file", "/builds/ketjo/nmorph/library/src/components/data/nmorph-pagination/NmorphPagination.vue"]]);
90
+ const P = /* @__PURE__ */ _(c, [["render", k], ["__file", "/builds/ketjo/nmorph/library/src/components/data/nmorph-pagination/NmorphPagination.vue"]]);
91
91
  export {
92
- u as default
92
+ P as default
93
93
  };
@@ -1,12 +1,13 @@
1
1
  import './NmorphPagination.css';
2
- import { defineComponent as O, computed as n, ref as g, watch as c } from "vue";
3
- import { useModifiers as Q } from "../../../utils/create-modifiers.js";
4
- import V from "../../form/nmorph-radio/NmorphRadio.vue.js";
2
+ import { defineComponent as V, computed as i, ref as b, watch as d } from "vue";
3
+ import { useModifiers as O } from "../../../utils/create-modifiers.js";
4
+ import { createCssSizeVariables as Q } from "../../../utils/common.js";
5
+ import W from "../../form/nmorph-radio/NmorphRadio.vue.js";
5
6
  import F from "../../basic/nmorph-icon/NmorphIcon.vue.js";
6
- import M from "../../basic/nmorph-button/NmorphButton.vue.js";
7
- import I from "../../form/nmorph-radio-group/NmorphRadioGroup.vue.js";
8
- import R from "../../../assets/icons/chevron-down.svg.js";
9
- const z = /* @__PURE__ */ O({
7
+ import I from "../../basic/nmorph-button/NmorphButton.vue.js";
8
+ import R from "../../form/nmorph-radio-group/NmorphRadioGroup.vue.js";
9
+ import D from "../../../assets/icons/chevron-down.svg.js";
10
+ const K = /* @__PURE__ */ V({
10
11
  __name: "NmorphPagination",
11
12
  props: {
12
13
  totalElementsQuantity: { type: Number, required: !0 },
@@ -17,88 +18,111 @@ const z = /* @__PURE__ */ O({
17
18
  hideOnSinglePage: { type: Boolean, required: !1, default: !0 },
18
19
  maxVisiblePages: { type: Number, required: !1, default: 9 },
19
20
  fastForwardStep: { type: Number, required: !1, default: 5 },
20
- thickness: { type: null, required: !1, default: "basic" }
21
+ thickness: { type: null, required: !1, default: "basic" },
22
+ fixedContainer: { type: Boolean, required: !1, default: !1 },
23
+ width: { type: [Number, String], required: !1, default: void 0 },
24
+ minWidth: { type: [Number, String], required: !1, default: void 0 }
21
25
  },
22
26
  emits: ["update:model-value"],
23
- setup(b, { expose: h, emit: N }) {
24
- h();
25
- const t = b, p = N, S = n(
26
- () => Q({
27
- "nmorph-pagination": [t.disabled && "disabled", t.loading && "loading"]
27
+ setup(N, { expose: S, emit: x }) {
28
+ S();
29
+ const t = N, c = x, y = i(
30
+ () => O({
31
+ "nmorph-pagination": [
32
+ t.disabled && "disabled",
33
+ t.loading && "loading",
34
+ t.fixedContainer && "fixed-container"
35
+ ]
28
36
  })
29
- ), d = {
37
+ ), g = {
30
38
  thick: "var(--thick-component)",
31
39
  basic: "var(--basic-component)",
32
40
  thin: "var(--thin-component)"
33
- }, y = n(() => ({
34
- "--nmorph-private-pagination-height": d[t.thickness]
35
- })), P = n(() => t.disabled || t.loading), k = () => {
36
- r.value = String(Number(r.value) - 1);
37
- }, _ = () => {
38
- r.value = String(Number(r.value) + 1);
39
- }, r = g(String(t.modelValue)), u = n(() => {
41
+ }, o = i(() => Math.max(1, Math.floor(t.maxVisiblePages))), v = i(() => {
42
+ const e = o.value * 40, a = Math.max(0, o.value - 1) * 8;
43
+ return [
44
+ "calc(",
45
+ "var(--nmorph-private-pagination-height) + ",
46
+ "var(--nmorph-private-pagination-height) + ",
47
+ "16px + var(--indentation-01) + var(--indentation-01) + ",
48
+ `${e + a}px`,
49
+ ")"
50
+ ].join("");
51
+ }), P = i(() => ({
52
+ "--nmorph-private-pagination-height": g[t.thickness],
53
+ "--nmorph-private-pagination-fixed-pages": o.value,
54
+ "--nmorph-private-pagination-fixed-width": v.value,
55
+ ...Q({
56
+ "--nmorph-private-pagination-width": t.width,
57
+ "--nmorph-private-pagination-min-width": t.minWidth
58
+ })
59
+ })), q = i(() => t.disabled || t.loading), k = () => {
60
+ n.value = String(Number(n.value) - 1);
61
+ }, w = () => {
62
+ n.value = String(Number(n.value) + 1);
63
+ }, n = b(String(t.modelValue)), u = i(() => {
40
64
  const e = Number(t.totalElementsQuantity), a = Number(t.elementsQuantityOnPage);
41
65
  return !Number.isFinite(e) || !Number.isFinite(a) || e <= 0 || a <= 0 ? 0 : Math.ceil(e / a);
42
- }), i = n(
66
+ }), s = i(
43
67
  () => Array.from({ length: u.value }, (e, a) => ({ value: String(a + 1), label: String(a + 1) }))
44
- ), s = g([]), v = n(() => {
45
- const e = String(Math.max(1, Number(r.value) || 1));
68
+ ), p = b([]), f = i(() => {
69
+ const e = String(Math.max(1, Number(n.value) || 1));
46
70
  return [{ value: e, label: e }];
47
- }), l = n(() => t.loading && s.value.length ? s.value : i.value.length ? i.value : v.value), q = n(() => t.loading || !t.hideOnSinglePage || u.value > 1);
48
- c(r, (e) => {
49
- p("update:model-value", Number(e));
50
- }), c(
51
- [i, () => t.loading],
71
+ }), r = i(() => t.loading && p.value.length ? p.value : s.value.length ? s.value : f.value), _ = i(() => t.loading || !t.hideOnSinglePage || u.value > 1);
72
+ d(n, (e) => {
73
+ c("update:model-value", Number(e));
74
+ }), d(
75
+ [s, () => t.loading],
52
76
  ([e, a]) => {
53
- (e.length || !a) && (s.value = e);
77
+ (e.length || !a) && (p.value = e);
54
78
  },
55
79
  { immediate: !0 }
56
- ), c(
80
+ ), d(
57
81
  () => t.modelValue,
58
82
  (e) => {
59
- r.value = String(e);
83
+ n.value = String(e);
60
84
  }
61
- ), c([u, () => t.loading], ([e, a]) => {
62
- a || e <= 0 || Number(r.value) > e && (r.value = String(e));
85
+ ), d([u, () => t.loading], ([e, a]) => {
86
+ a || e <= 0 || Number(n.value) > e && (n.value = String(e));
63
87
  });
64
- const x = n(() => Number(r.value) === 1), B = n(() => Number(r.value) >= l.value.length), w = n(() => {
65
- const e = l.value.length, a = Number(r.value), o = t.maxVisiblePages;
66
- if (e <= o)
67
- return l.value;
68
- const m = Math.floor(o / 2);
88
+ const B = i(() => Number(n.value) === 1), C = i(() => Number(n.value) >= r.value.length), M = i(() => {
89
+ const e = r.value.length, a = Number(n.value), l = t.maxVisiblePages;
90
+ if (e <= l)
91
+ return r.value;
92
+ const m = Math.floor(l / 2);
69
93
  return a <= m ? [
70
- ...l.value.slice(0, o - 2),
94
+ ...r.value.slice(0, l - 2),
71
95
  { value: "next", label: "..." },
72
- l.value[e - 1]
96
+ r.value[e - 1]
73
97
  ] : a >= e - m ? [
74
- l.value[0],
98
+ r.value[0],
75
99
  { value: "prev", label: "..." },
76
- ...l.value.slice(e - (o - 2))
100
+ ...r.value.slice(e - (l - 2))
77
101
  ] : [
78
- l.value[0],
102
+ r.value[0],
79
103
  { value: "prev", label: "..." },
80
- ...l.value.slice(a - m, a + m - 1),
104
+ ...r.value.slice(a - m, a + m - 1),
81
105
  { value: "next", label: "..." },
82
- l.value[e - 1]
106
+ r.value[e - 1]
83
107
  ];
84
- }), f = { props: t, emit: p, modifiers: S, thicknessHeightMap: d, paginationStyle: y, interactionDisabled: P, prevClick: k, nextClick: _, selectedPage: r, totalPages: u, pages: i, retainedPages: s, fallbackPages: v, effectivePages: l, show: q, blockPrevButton: x, blockNextButton: B, visiblePages: w, bigStepUpdate: (e) => {
85
- const a = Number(r.value);
86
- let o = e === "prev" ? a - t.fastForwardStep : a + t.fastForwardStep;
87
- o <= 0 && (o = 1), o >= l.value.length && (o = l.value.length), r.value = String(o);
108
+ }), h = { props: t, emit: c, modifiers: y, thicknessHeightMap: g, fixedPagesCount: o, fixedContainerWidth: v, paginationStyle: P, interactionDisabled: q, prevClick: k, nextClick: w, selectedPage: n, totalPages: u, pages: s, retainedPages: p, fallbackPages: f, effectivePages: r, show: _, blockPrevButton: B, blockNextButton: C, visiblePages: M, bigStepUpdate: (e) => {
109
+ const a = Number(n.value);
110
+ let l = e === "prev" ? a - t.fastForwardStep : a + t.fastForwardStep;
111
+ l <= 0 && (l = 1), l >= r.value.length && (l = r.value.length), n.value = String(l);
88
112
  }, get NmorphRadioGroup() {
89
- return I;
113
+ return R;
90
114
  }, get NmorphButton() {
91
- return M;
115
+ return I;
92
116
  }, get NmorphIcon() {
93
117
  return F;
94
118
  }, get NmorphRadio() {
95
- return V;
119
+ return W;
96
120
  }, get NmorphIconChevronDown() {
97
- return R;
121
+ return D;
98
122
  } };
99
- return Object.defineProperty(f, "__isScriptSetup", { enumerable: !1, value: !0 }), f;
123
+ return Object.defineProperty(h, "__isScriptSetup", { enumerable: !1, value: !0 }), h;
100
124
  }
101
125
  });
102
126
  export {
103
- z as default
127
+ K as default
104
128
  };