@orangelogic/design-system 4.57.0 → 4.59.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.
@@ -32,7 +32,7 @@ import { a as D, c as O, l as k, n as ve, o as A, r as j, s as M, t as N } from
32
32
  import { t as ye } from "./menu-label.B-FOyfAX.js";
33
33
  import { t as be } from "./switch.BM9msK5T.js";
34
34
  import { t as xe } from "./v4.JyXW8GUB.js";
35
- import "./cropper.BRsN8h2t.js";
35
+ import "./cropper.CNmQt-sa.js";
36
36
  import { t as Se } from "./_baseUniq.h_pGICPH.js";
37
37
  import { d as Ce, i as we, n as Te, o as Ee, p as P, r as De, s as Oe, t as ke } from "./string-array.Dstcqyjm.js";
38
38
  import { t as Ae } from "./position-picker.X2hhfGx7.js";
@@ -778,7 +778,7 @@ var Tt = class {
778
778
  }
779
779
  this.invalidWidth = !1, this.unit === k.Pixel && (t = Math.max(Math.min(t, this.maxWidth), 1));
780
780
  let n = this.unit === k.Pixel ? this.height : this.ratioHeight, r = !1;
781
- this.keepAspectRatio && (n = Math.max(Math.round(t / this.aspectRatio), 1)), this.unit === k.Pixel && this.maxHeight >= 1 && n > this.maxHeight && (n = this.maxHeight, r = this.keepAspectRatio), e.target.value = t.toString(), this.invalidHeight = !1, this.emit("cx-asset-link-format-crop-change", { detail: {
781
+ this.keepAspectRatio ? n = Math.max(Math.round(t / this.aspectRatio), 1) : this.unit === k.AspectRatio && ([t, n] = this.fitRatioSides(t, n, this.maxWidth, this.maxHeight)), this.unit === k.Pixel && this.maxHeight >= 1 && n > this.maxHeight && (n = this.maxHeight, r = this.keepAspectRatio), e.target.value = t.toString(), this.invalidHeight = !1, this.emit("cx-asset-link-format-crop-change", { detail: {
782
782
  breakAspectRatio: r,
783
783
  height: n,
784
784
  keepAspectRatio: this.keepAspectRatio,
@@ -794,7 +794,7 @@ var Tt = class {
794
794
  }
795
795
  this.invalidHeight = !1, this.unit === k.Pixel && (t = Math.max(Math.min(t, this.maxHeight), 1));
796
796
  let n = this.unit === k.Pixel ? this.width : this.ratioWidth, r = !1;
797
- this.keepAspectRatio && (n = Math.max(Math.round(t * this.aspectRatio), 1)), this.unit === k.Pixel && this.maxWidth >= 1 && n > this.maxWidth && (n = this.maxWidth, r = this.keepAspectRatio), e.target.value = t.toString(), this.invalidWidth = !1, this.emit("cx-asset-link-format-crop-change", { detail: {
797
+ this.keepAspectRatio ? n = Math.max(Math.round(t * this.aspectRatio), 1) : this.unit === k.AspectRatio && ([t, n] = this.fitRatioSides(t, n, this.maxHeight, this.maxWidth)), this.unit === k.Pixel && this.maxWidth >= 1 && n > this.maxWidth && (n = this.maxWidth, r = this.keepAspectRatio), e.target.value = t.toString(), this.invalidWidth = !1, this.emit("cx-asset-link-format-crop-change", { detail: {
798
798
  breakAspectRatio: r,
799
799
  height: t,
800
800
  keepAspectRatio: this.keepAspectRatio,
@@ -920,6 +920,11 @@ var Tt = class {
920
920
  scale: 0
921
921
  } };
922
922
  }
923
+ fitRatioSides(e, t, n, r) {
924
+ if (!this.hasMaxSize || n < 1 || r < 1) return [e, t];
925
+ let i = Math.min(e, n * t);
926
+ return [i, Math.min(t, r * i)];
927
+ }
923
928
  render() {
924
929
  let t = this.cropModes.filter((e) => !e.auto), n = this.cropModes.filter((e) => e.auto);
925
930
  return e`<cx-details class="details ${this.inline ? "details--inline" : ""}" ?open=${this.inline || this.open} @cx-show=${this.onShowDetails} @cx-hide=${this.onHideDetails}><cx-space slot="summary" align-items="center"><div part="icon"><cx-icon name="crop"></cx-icon></div><cx-typography variant="body2">${this.localize.term("crop")}</cx-typography></cx-space><cx-space direction="vertical" spacing="small">${m(!this.noRatioModes, () => e`<cx-select data-testid="cx-asset-link-format-crop-mode" value=${this.cropMode} hoist style=${g({ width: "100%" })} @cx-change=${this.onCropModeChange} ?disabled=${this.loading}>${S(t, (e) => e.value, ({ label: t, value: n }) => e`<cx-option value=${n}>${t}</cx-option>`)}
@@ -1477,9 +1482,9 @@ var Rt = q, zt = t`cx-details::part(base){border-bottom-width:0}cx-space{width:1
1477
1482
  this.invalidWidth = !0;
1478
1483
  return;
1479
1484
  }
1480
- this.invalidWidth = !1, this.unit === k.Pixel && (t = Math.max(Math.min(t, this.maxWidth), 1)), e.target.value = t.toString();
1485
+ this.invalidWidth = !1, this.unit === k.Pixel && (t = Math.max(Math.min(t, this.maxWidth), 1));
1481
1486
  let n = this.unit === k.Pixel ? this.height : this.ratioHeight;
1482
- this.keepAspectRatio && (n = Math.max(Math.min(Math.round(t / this.aspectRatio), this.maxHeight), 1), this.invalidHeight = !1), this.emit("cx-asset-link-format-resize-change", { detail: {
1487
+ !this.keepAspectRatio && this.unit === k.AspectRatio && ([t, n] = this.fitRatioSides(t, n, this.maxWidth, this.maxHeight)), e.target.value = t.toString(), this.keepAspectRatio && (n = Math.max(Math.min(Math.round(t / this.aspectRatio), this.maxHeight), 1), this.invalidHeight = !1), this.emit("cx-asset-link-format-resize-change", { detail: {
1483
1488
  height: n,
1484
1489
  keepAspectRatio: this.keepAspectRatio,
1485
1490
  unit: this.unit,
@@ -1492,9 +1497,9 @@ var Rt = q, zt = t`cx-details::part(base){border-bottom-width:0}cx-space{width:1
1492
1497
  this.invalidHeight = !0;
1493
1498
  return;
1494
1499
  }
1495
- this.invalidHeight = !1, this.unit === k.Pixel && (t = Math.max(Math.min(t, this.maxHeight), 1)), e.target.value = t.toString();
1500
+ this.invalidHeight = !1, this.unit === k.Pixel && (t = Math.max(Math.min(t, this.maxHeight), 1));
1496
1501
  let n = this.unit === k.Pixel ? this.width : this.ratioWidth;
1497
- this.keepAspectRatio && (n = Math.max(Math.min(Math.round(t * this.aspectRatio), this.maxWidth), 1), this.invalidWidth = !1), this.emit("cx-asset-link-format-resize-change", { detail: {
1502
+ !this.keepAspectRatio && this.unit === k.AspectRatio && ([t, n] = this.fitRatioSides(t, n, this.maxHeight, this.maxWidth)), e.target.value = t.toString(), this.keepAspectRatio && (n = Math.max(Math.min(Math.round(t * this.aspectRatio), this.maxWidth), 1), this.invalidWidth = !1), this.emit("cx-asset-link-format-resize-change", { detail: {
1498
1503
  height: t,
1499
1504
  keepAspectRatio: this.keepAspectRatio,
1500
1505
  unit: this.unit,
@@ -1535,6 +1540,11 @@ var Rt = q, zt = t`cx-details::part(base){border-bottom-width:0}cx-space{width:1
1535
1540
  width: this.unit === k.Pixel ? this.width : this.ratioWidth
1536
1541
  } });
1537
1542
  }
1543
+ fitRatioSides(e, t, n, r) {
1544
+ if (!Number.isFinite(n) || !Number.isFinite(r) || n < 1 || r < 1) return [e, t];
1545
+ let i = Math.min(e, n * t);
1546
+ return [i, Math.min(t, r * i)];
1547
+ }
1538
1548
  render() {
1539
1549
  return e`<cx-details class="details" ?open=${this.open} @cx-show=${this.onShowDetails} @cx-hide=${this.onHideDetails}><cx-space slot="summary" align-items="center"><div part="icon"><cx-icon name="aspect_ratio"></cx-icon></div><cx-typography variant="body2">${this.localize.term("resize")}</cx-typography></cx-space><cx-space direction="vertical" spacing="small"><cx-space spacing="small"><div class="resize__input-group"><cx-input data-testid="cx-asset-link-format-resize-width" placeholder=${this.localize.term("width")} mask="num" .maskBlocks=${{ num: {
1540
1550
  mask: Number,
@@ -1772,6 +1782,13 @@ var Wt = X, Z, Gt = {
1772
1782
  static getTransformExtension(e) {
1773
1783
  return !e || St(e) ? e : "jpg";
1774
1784
  }
1785
+ static fitRatioResizeSize(e, t, n, r) {
1786
+ let { height: i, width: a } = ie(n, r, e, t);
1787
+ return {
1788
+ height: Math.max(i, 1),
1789
+ width: Math.max(a, 1)
1790
+ };
1791
+ }
1775
1792
  static uniqueTransformations(e) {
1776
1793
  return [...new Map(e.map((e) => [e.key, e])).values()];
1777
1794
  }
@@ -2736,7 +2753,7 @@ var Wt = X, Z, Gt = {
2736
2753
  async onCropChange(e) {
2737
2754
  let t = this.cropSize.unit;
2738
2755
  if (e.detail.unit === k.AspectRatio) {
2739
- let t = e.detail.width / e.detail.height, n = this.asset ? Math.min(Math.max(Math.round(this.cropSize.height * t), 0), this.resizeSize.width) : 0, r = this.asset ? Math.min(Math.max(Math.round(n / t), 0), this.resizeSize.height) : 0, i = this.asset ? r * 100 / this.selectedFormat.height : 100, a = this.asset ? n * 100 / this.selectedFormat.width : 100, o = this.cropSize.x, s = this.cropSize.y;
2756
+ let t = e.detail.width / e.detail.height, n = this.asset ? Math.min(Math.max(Math.round(this.cropSize.height * t), 1), this.resizeSize.width) : 0, r = this.asset ? Math.min(Math.max(Math.round(n / t), 1), this.resizeSize.height) : 0, i = this.asset ? r * 100 / this.selectedFormat.height : 100, a = this.asset ? n * 100 / this.selectedFormat.width : 100, o = this.cropSize.x, s = this.cropSize.y;
2740
2757
  o + a > 100 && (o = 100 - a), s + i > 100 && (s = 100 - i);
2741
2758
  let c = this.cropSize.cropMode, l = this.cropModes.find((e) => e.value === c)?.auto, u = /^(\d+):(\d+)$/.exec(c), d = u !== null && !e.detail.keepAspectRatio && Number(u[1]) * e.detail.height !== Number(u[2]) * e.detail.width;
2742
2759
  (l || d) && (c = "free"), e.detail.silent ? (this.cropSize.height = r, this.cropSize.keepAspectRatio = e.detail.keepAspectRatio, this.cropSize.percentageHeight = i, this.cropSize.percentageWidth = a, this.cropSize.ratioHeight = e.detail.height, this.cropSize.ratioWidth = e.detail.width, this.cropSize.unit = k.AspectRatio, this.cropSize.width = n) : this.cropSize = {
@@ -2860,12 +2877,21 @@ var Wt = X, Z, Gt = {
2860
2877
  }
2861
2878
  }]);
2862
2879
  }
2880
+ getRatioResizePreviewSize(e, t) {
2881
+ let { height: n, width: r } = this.imageSize;
2882
+ if (this.asset && r && n) return Z.fitRatioResizeSize(e, t, r, n);
2883
+ let i = e / t, a = Math.max(Math.round(this.lastResizeSize[k.Pixel].height * i), 0);
2884
+ return {
2885
+ height: Math.max(Math.round(a / i), 0),
2886
+ width: a
2887
+ };
2888
+ }
2863
2889
  onResizeChange(e) {
2864
2890
  if (e.detail.unit === k.AspectRatio) {
2865
- let t = e.detail.width / e.detail.height, n = Math.max(Math.round(this.lastResizeSize[k.Pixel].height * t), 0), r = Math.max(Math.round(n / t), 0);
2891
+ let { height: t, width: n } = this.getRatioResizePreviewSize(e.detail.width, e.detail.height);
2866
2892
  this.resizeSize = {
2867
2893
  ...this.resizeSize,
2868
- height: r,
2894
+ height: t,
2869
2895
  keepAspectRatio: e.detail.keepAspectRatio,
2870
2896
  ratioHeight: e.detail.height,
2871
2897
  ratioWidth: e.detail.width,
@@ -2908,7 +2934,7 @@ var Wt = X, Z, Gt = {
2908
2934
  }
2909
2935
  if (!this.selectedFormat) return;
2910
2936
  let i = this.selectedFormat.width || this.defaultSize.width, a = this.selectedFormat.height || this.defaultSize.height, o = r, s = t;
2911
- this.resizeSize.unit === n ? n === k.AspectRatio && (o = Math.round(r / t * a), s = a) : (o = i, s = a), this.transformations = [...this.transformations, {
2937
+ this.resizeSize.unit === n ? n === k.AspectRatio && ({height: s, width: o} = Z.fitRatioResizeSize(r, t, i, a)) : (o = i, s = a), this.transformations = [...this.transformations, {
2912
2938
  key: O.Resize,
2913
2939
  value: {
2914
2940
  height: s,
@@ -69,7 +69,7 @@ import { t as bt } from "./bicolor-picker.DZY5PP24.js";
69
69
  import { t as xt } from "./border-input-group.BymzNWba.js";
70
70
  import { n as St, t as Ct } from "./confirm-popover.DUrgLQjC.js";
71
71
  import { t as wt } from "./corner-position-input-group.mrOiz-0k.js";
72
- import { t as Tt } from "./cropper.BRsN8h2t.js";
72
+ import { t as Tt } from "./cropper.CNmQt-sa.js";
73
73
  import { t as Et } from "./dynamic-select.Dwcz7UjN.js";
74
74
  import { t as Dt } from "./string-array.Dstcqyjm.js";
75
75
  import { n as M, r as Ot, t as N } from "./folder-select.Buoz3ioX.js";
@@ -79,7 +79,7 @@ import { t as jt } from "./padding-input-group.B-hbA7P2.js";
79
79
  import { t as Mt } from "./position-picker.X2hhfGx7.js";
80
80
  import { t as Nt } from "./shadow-input-group.B_W5gJ4u.js";
81
81
  import { t as Pt } from "./size-input-group.DUyTc5na.js";
82
- import { C as Ft, S as It, T as Lt, _ as Rt, b as zt, c as Bt, f as Vt, g as Ht, h as Ut, i as Wt, l as Gt, n as Kt, o as qt, p as Jt, r as Yt, s as P, t as Xt, u as Zt, v as Qt, w as $t, x as en, y as tn } from "./asset-link-format.DFFHzlDh.js";
82
+ import { C as Ft, S as It, T as Lt, _ as Rt, b as zt, c as Bt, f as Vt, g as Ht, h as Ut, i as Wt, l as Gt, n as Kt, o as qt, p as Jt, r as Yt, s as P, t as Xt, u as Zt, v as Qt, w as $t, x as en, y as tn } from "./asset-link-format.zO0t0oA3.js";
83
83
  import { c as nn, d as rn, f as an, n as on, u as sn } from "./color-swatch-group.Bcw5aIqG.js";
84
84
  import { $ as cn, B as F, G as ln, O as un, P as dn, Q as fn, T as pn, X as mn, Y as hn, Z as gn, _ as _n, at as vn, ct as I, et as yn, lt as bn, ot as L, st as xn, v as Sn, w as Cn, x as wn } from "./configs-controller.uTcM4iX4.js";
85
85
  import { a as Tn } from "./cloneDeep.C6x5LNv3.js";
@@ -14,7 +14,7 @@ import { t as b } from "./style-map.DPGQIxip.js";
14
14
  import { t as x } from "./button.BjijpxeK.js";
15
15
  import { t as ee } from "./tooltip.Cc02vm6M.js";
16
16
  import { t as te } from "./line-clamp.SD3U021K.js";
17
- import { S as ne, _ as re, a as ie, b as ae, c as oe, d as se, f as ce, g as le, h as ue, i as de, l as fe, m as pe, n as me, o as he, p as ge, s as S, t as C, u as w, v as T, x as E, y as D } from "./block-width.BPsewZ8l.js";
17
+ import { S as ne, _ as re, a as ie, b as ae, c as oe, d as se, f as ce, g as le, h as ue, i as de, l as fe, m as pe, n as me, o as he, p as ge, s as S, t as C, u as w, v as T, x as E, y as D } from "./block-width.Dbc3rT3Y.js";
18
18
  import { t as O } from "./typography.B0mkhqTB.js";
19
19
  import { t as k } from "./button-group.CPfXrqyq.js";
20
20
  import { t as A } from "./card.3c-X4hqR.js";
@@ -59,7 +59,7 @@ import { t as Je } from "./padding-input-group.B-hbA7P2.js";
59
59
  import { t as Ye } from "./position-picker.X2hhfGx7.js";
60
60
  import { t as Xe } from "./shadow-input-group.B_W5gJ4u.js";
61
61
  import { t as Ze } from "./size-input-group.DUyTc5na.js";
62
- import { T as K } from "./asset-link-format.DFFHzlDh.js";
62
+ import { T as K } from "./asset-link-format.zO0t0oA3.js";
63
63
  import { n as Qe } from "./_baseXor.Ca5K0ORC.js";
64
64
  import { n as $e, s as et, t as q } from "./isArrayLikeObject.Da3IzQeH.js";
65
65
  import { i as tt } from "./_baseClone.CnI5Vpqn.js";
@@ -166,10 +166,10 @@ var F = b(), I = {
166
166
  if (a || o || !i) return;
167
167
  if (t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight") t.stopPropagation(), t.preventDefault();
168
168
  else return;
169
- let m = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? e.nudgeStepLarge : t.shiftKey ? e.nudgeStepMedium : e.nudgeStep, h = N(P(M(i, p.width, p.height), t.key, m, n), r, n, p.width, p.height, u, l, c, s);
170
- if (!O(i, h)) {
171
- let e = j(h, p.width, p.height);
172
- d(h, e), f && f(h, e);
169
+ let m = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? e.nudgeStepLarge : t.shiftKey ? e.nudgeStepMedium : e.nudgeStep, h = P(M(i, p.width, p.height), t.key, m, n), [g, _] = this.resolveMinDimensions(p, r, u, l), v = N(h, r, n, p.width, p.height, g, _, c, s);
170
+ if (!O(i, v)) {
171
+ let e = j(v, p.width, p.height);
172
+ d(v, e), f && f(v, e);
173
173
  }
174
174
  }, this.onDocPointerDone = (e) => {
175
175
  let { crop: t, disabled: n, loading: r, onComplete: i, onDragEnd: a } = this.props, o = this.getBox();
@@ -251,20 +251,16 @@ var F = b(), I = {
251
251
  let { evData: e } = this, t = this.getBox(), n = this.makePixelCrop(t), r = e.clientX - e.startClientX, i = e.clientY - e.startClientY;
252
252
  return n.x = E(e.startCropX + r, 0, t.width - n.width), n.y = E(e.startCropY + i, 0, t.height - n.height), n;
253
253
  }
254
- getPointRegion(e, t, n, r) {
255
- let { evData: i } = this, a = i.clientX - e.x, o = i.clientY - e.y, s;
256
- s = r && t ? t === "nw" || t === "n" || t === "ne" : o < i.startCropY;
257
- let c;
258
- return c = n && t ? t === "nw" || t === "w" || t === "sw" : a < i.startCropX, c ? s ? "nw" : "sw" : s ? "ne" : "se";
254
+ getPointRegion(e) {
255
+ let { evData: t } = this, n = t.clientX - e.x, r = t.clientY - e.y < t.startCropY;
256
+ return n < t.startCropX ? r ? "nw" : "sw" : r ? "ne" : "se";
259
257
  }
260
258
  resolveMinDimensions(e, t, n = 0, r = 0) {
261
259
  let i = Math.min(n, e.width), a = Math.min(r, e.height);
262
260
  return !t || !i && !a ? [i, a] : t > 1 ? i ? [i, i / t] : [a * t, a] : a ? [a * t, a] : [i, i / t];
263
261
  }
264
262
  resizeCrop() {
265
- let { evData: t } = this, { aspect: n = 0, centerCrop: r, maxHeight: i, maxWidth: a } = this.props, o = this.getBox(), [s, c] = this.resolveMinDimensions(o, n, this.props.minWidth, this.props.minHeight), l = this.makePixelCrop(o), u = this.getPointRegion(o, t.ord, s, c), d = t.ord || u, f = t.clientX - t.startClientX, p = t.clientY - t.startClientY;
266
- (s && d === "nw" || d === "w" || d === "sw") && (f = Math.min(f, -s)), (c && d === "nw" || d === "n" || d === "ne") && (p = Math.min(p, -c));
267
- let m = {
263
+ let { evData: t } = this, { aspect: n = 0, centerCrop: r, maxHeight: i, maxWidth: a } = this.props, o = this.getBox(), [s, c] = this.resolveMinDimensions(o, n, this.props.minWidth, this.props.minHeight), l = this.makePixelCrop(o), u = this.getPointRegion(o), d = t.ord || u, f = t.clientX - t.startClientX, p = t.clientY - t.startClientY, m = {
268
264
  height: 0,
269
265
  unit: "px",
270
266
  width: 0,
@@ -673,6 +669,8 @@ var B = (0, S.forwardRef)(({ cropper: e, disabled: t, fillImage: n, image: r, lo
673
669
  disabled: v,
674
670
  loading: a || l && d,
675
671
  keepSelection: !0,
672
+ minHeight: 1,
673
+ minWidth: 1,
676
674
  ruleOfThirds: !0,
677
675
  onChange: K,
678
676
  onComplete: Y,
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/asset-link-format.DFFHzlDh.js";
1
+ import { t as e } from "../chunks/asset-link-format.zO0t0oA3.js";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../chunks/cropper.BRsN8h2t.js";
1
+ import { t as e } from "../chunks/cropper.CNmQt-sa.js";
2
2
  export { e as default };
@@ -3,7 +3,7 @@ import { t } from "../chunks/border-input-group.BymzNWba.js";
3
3
  import { t as n } from "../chunks/color-swatch.DZG975M_.js";
4
4
  import { t as r } from "../chunks/confirm-popover.DUrgLQjC.js";
5
5
  import { t as i } from "../chunks/corner-position-input-group.mrOiz-0k.js";
6
- import { t as a } from "../chunks/cropper.BRsN8h2t.js";
6
+ import { t as a } from "../chunks/cropper.CNmQt-sa.js";
7
7
  import { t as o } from "../chunks/dynamic-select.Dwcz7UjN.js";
8
8
  import { t as s } from "../chunks/folder-select.Buoz3ioX.js";
9
9
  import { t as c } from "../chunks/masonry.BxNeClR6.js";
@@ -1,4 +1,4 @@
1
- import { t as e } from "../chunks/asset-link-format.DFFHzlDh.js";
1
+ import { t as e } from "../chunks/asset-link-format.zO0t0oA3.js";
2
2
  import { t } from "../chunks/color-swatch-group.Bcw5aIqG.js";
3
3
  import { t as n } from "../chunks/file-on-demand.BmRBmyyq.js";
4
4
  export { e as CxAssetLinkFormat, t as CxColorSwatchGroup, n as CxFileOnDemand };