@snmt-react-ui/user-select 1.1.0 → 1.1.1

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.
Files changed (2) hide show
  1. package/dist/user-select.js +78 -67
  2. package/package.json +4 -4
@@ -3,7 +3,7 @@ var Xs = (e, t, r) => t in e ? Js(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var On = (e, t, r) => Xs(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import "./index.css";
5
5
  import { jsx as h, jsxs as C, Fragment as Ue } from "react/jsx-runtime";
6
- import { createContext as lt, forwardRef as ct, useState as G, useRef as Kt, useEffect as ce, useCallback as Le, useContext as ht } from "react";
6
+ import { createContext as lt, forwardRef as ct, useState as G, useRef as Kt, useEffect as ce, useCallback as ve, useContext as ht } from "react";
7
7
  import { Select as Qs, Flex as e1, Avatar as t1, Checkbox as r1, Typography as qo, Tag as zo, Popover as n1 } from "antd";
8
8
  import { SNMTUiContext as o1 } from "@snmt-react-ui/core";
9
9
  const Lt = ({
@@ -1443,7 +1443,7 @@ function _a(e, t, r) {
1443
1443
  const Dr = {
1444
1444
  assertOptions: _a,
1445
1445
  validators: fn
1446
- }, we = Dr.validators;
1446
+ }, ke = Dr.validators;
1447
1447
  let Ae = class {
1448
1448
  constructor(e) {
1449
1449
  this.defaults = e, this.interceptors = {
@@ -1480,14 +1480,14 @@ let Ae = class {
1480
1480
  typeof e == "string" ? (t = t || {}, t.url = e) : t = e || {}, t = Be(this.defaults, t);
1481
1481
  const { transitional: r, paramsSerializer: n, headers: o } = t;
1482
1482
  r !== void 0 && Dr.assertOptions(r, {
1483
- silentJSONParsing: we.transitional(we.boolean),
1484
- forcedJSONParsing: we.transitional(we.boolean),
1485
- clarifyTimeoutError: we.transitional(we.boolean)
1483
+ silentJSONParsing: ke.transitional(ke.boolean),
1484
+ forcedJSONParsing: ke.transitional(ke.boolean),
1485
+ clarifyTimeoutError: ke.transitional(ke.boolean)
1486
1486
  }, !1), n != null && (w.isFunction(n) ? t.paramsSerializer = {
1487
1487
  serialize: n
1488
1488
  } : Dr.assertOptions(n, {
1489
- encode: we.function,
1490
- serialize: we.function
1489
+ encode: ke.function,
1490
+ serialize: ke.function
1491
1491
  }, !0)), t.method = (t.method || this.defaults.method || "get").toLowerCase();
1492
1492
  let i = o && w.merge(
1493
1493
  o.common,
@@ -3175,7 +3175,7 @@ function cc(e, t, r) {
3175
3175
  const Kr = {
3176
3176
  assertOptions: cc,
3177
3177
  validators: Cn
3178
- }, ke = Kr.validators;
3178
+ }, ye = Kr.validators;
3179
3179
  let Te = class {
3180
3180
  constructor(e) {
3181
3181
  this.defaults = e, this.interceptors = {
@@ -3212,14 +3212,14 @@ let Te = class {
3212
3212
  typeof e == "string" ? (t = t || {}, t.url = e) : t = e || {}, t = Pe(this.defaults, t);
3213
3213
  const { transitional: r, paramsSerializer: n, headers: o } = t;
3214
3214
  r !== void 0 && Kr.assertOptions(r, {
3215
- silentJSONParsing: ke.transitional(ke.boolean),
3216
- forcedJSONParsing: ke.transitional(ke.boolean),
3217
- clarifyTimeoutError: ke.transitional(ke.boolean)
3215
+ silentJSONParsing: ye.transitional(ye.boolean),
3216
+ forcedJSONParsing: ye.transitional(ye.boolean),
3217
+ clarifyTimeoutError: ye.transitional(ye.boolean)
3218
3218
  }, !1), n != null && (k.isFunction(n) ? t.paramsSerializer = {
3219
3219
  serialize: n
3220
3220
  } : Kr.assertOptions(n, {
3221
- encode: ke.function,
3222
- serialize: ke.function
3221
+ encode: ye.function,
3222
+ serialize: ye.function
3223
3223
  }, !0)), t.method = (t.method || this.defaults.method || "get").toLowerCase();
3224
3224
  let i = o && k.merge(
3225
3225
  o.common,
@@ -8166,7 +8166,7 @@ function w5(e, t, r) {
8166
8166
  const Jr = {
8167
8167
  assertOptions: w5,
8168
8168
  validators: bn
8169
- }, ye = Jr.validators;
8169
+ }, be = Jr.validators;
8170
8170
  let _e = class {
8171
8171
  constructor(e) {
8172
8172
  this.defaults = e, this.interceptors = {
@@ -8203,14 +8203,14 @@ let _e = class {
8203
8203
  typeof e == "string" ? (t = t || {}, t.url = e) : t = e || {}, t = De(this.defaults, t);
8204
8204
  const { transitional: r, paramsSerializer: n, headers: o } = t;
8205
8205
  r !== void 0 && Jr.assertOptions(r, {
8206
- silentJSONParsing: ye.transitional(ye.boolean),
8207
- forcedJSONParsing: ye.transitional(ye.boolean),
8208
- clarifyTimeoutError: ye.transitional(ye.boolean)
8206
+ silentJSONParsing: be.transitional(be.boolean),
8207
+ forcedJSONParsing: be.transitional(be.boolean),
8208
+ clarifyTimeoutError: be.transitional(be.boolean)
8209
8209
  }, !1), n != null && (y.isFunction(n) ? t.paramsSerializer = {
8210
8210
  serialize: n
8211
8211
  } : Jr.assertOptions(n, {
8212
- encode: ye.function,
8213
- serialize: ye.function
8212
+ encode: be.function,
8213
+ serialize: be.function
8214
8214
  }, !0)), t.method = (t.method || this.defaults.method || "get").toLowerCase();
8215
8215
  let i = o && y.merge(
8216
8216
  o.common,
@@ -13119,7 +13119,7 @@ function v6(e, t, r) {
13119
13119
  const on = {
13120
13120
  assertOptions: v6,
13121
13121
  validators: En
13122
- }, be = on.validators;
13122
+ }, Le = on.validators;
13123
13123
  class Me {
13124
13124
  constructor(t) {
13125
13125
  this.defaults = t, this.interceptors = {
@@ -13156,14 +13156,14 @@ class Me {
13156
13156
  typeof t == "string" ? (r = r || {}, r.url = t) : r = t || {}, r = He(this.defaults, r);
13157
13157
  const { transitional: n, paramsSerializer: o, headers: i } = r;
13158
13158
  n !== void 0 && on.assertOptions(n, {
13159
- silentJSONParsing: be.transitional(be.boolean),
13160
- forcedJSONParsing: be.transitional(be.boolean),
13161
- clarifyTimeoutError: be.transitional(be.boolean)
13159
+ silentJSONParsing: Le.transitional(Le.boolean),
13160
+ forcedJSONParsing: Le.transitional(Le.boolean),
13161
+ clarifyTimeoutError: Le.transitional(Le.boolean)
13162
13162
  }, !1), o != null && (b.isFunction(o) ? r.paramsSerializer = {
13163
13163
  serialize: o
13164
13164
  } : on.assertOptions(o, {
13165
- encode: be.function,
13166
- serialize: be.function
13165
+ encode: Le.function,
13166
+ serialize: Le.function
13167
13167
  }, !0)), r.method = (r.method || this.defaults.method || "get").toLowerCase();
13168
13168
  let s = i && b.merge(
13169
13169
  i.common,
@@ -13510,39 +13510,47 @@ const Ks = ({ children: e, width: t, size: r = "small", onClose: n, closable: o
13510
13510
  values: e,
13511
13511
  onTagClose: t,
13512
13512
  maxWidth: r,
13513
- disabled: n
13513
+ disabled: n,
13514
+ options: o,
13515
+ extraOptions: i
13514
13516
  }) => {
13515
- const [o, i] = G(!1);
13517
+ const [s, a] = G(!1);
13516
13518
  ce(() => {
13517
- e.length || i(!1);
13519
+ e.length || a(!1);
13518
13520
  }, [e]);
13519
- const s = (a) => {
13520
- a.preventDefault(), a.stopPropagation();
13521
+ const d = (l) => {
13522
+ l.preventDefault(), l.stopPropagation();
13523
+ };
13524
+ if (!e.length)
13525
+ return null;
13526
+ const c = (l) => {
13527
+ var u, g;
13528
+ return ((u = o == null ? void 0 : o.find((f) => f.value === l)) == null ? void 0 : u.label) || ((g = i == null ? void 0 : i.find((f) => f.value === l)) == null ? void 0 : g.label) || l;
13521
13529
  };
13522
- return e.length ? /* @__PURE__ */ h("div", { onMouseDown: s, className: "wrapper", children: /* @__PURE__ */ h(
13530
+ return /* @__PURE__ */ h("div", { onMouseDown: d, className: "wrapper", children: /* @__PURE__ */ h(
13523
13531
  A6,
13524
13532
  {
13525
13533
  content: (
13526
13534
  // 90: paddings + margins + gaps and so on
13527
- /* @__PURE__ */ h("div", { style: { maxWidth: r - 90 }, children: /* @__PURE__ */ h(Lt, { gap: 6, flexWrap: "wrap", children: e.map(({ value: a, label: d }) => /* @__PURE__ */ h(
13535
+ /* @__PURE__ */ h("div", { style: { maxWidth: r - 90 }, children: /* @__PURE__ */ h(Lt, { gap: 6, flexWrap: "wrap", children: e.map(({ value: l }) => /* @__PURE__ */ h(
13528
13536
  Ks,
13529
13537
  {
13530
- onClose: () => t(a),
13538
+ onClose: () => t(l),
13531
13539
  closable: !n,
13532
- children: d
13540
+ children: c(l)
13533
13541
  },
13534
- a
13542
+ l
13535
13543
  )) }) })
13536
13544
  ),
13537
13545
  placement: "bottomRight",
13538
- isOpen: o,
13539
- setIsOpen: i,
13540
- children: /* @__PURE__ */ h(zo, { className: `overflow-button ${o ? "open" : ""}`, bordered: !1, children: /* @__PURE__ */ C(Gs, { variant: "body4", color: o ? Ve.BLUE_PRIMARY : void 0, children: [
13546
+ isOpen: s,
13547
+ setIsOpen: a,
13548
+ children: /* @__PURE__ */ h(zo, { className: `overflow-button ${s ? "open" : ""}`, bordered: !1, children: /* @__PURE__ */ C(Gs, { variant: "body4", color: s ? Ve.BLUE_PRIMARY : void 0, children: [
13541
13549
  e.length,
13542
13550
  " more"
13543
13551
  ] }) })
13544
13552
  }
13545
- ) }) : null;
13553
+ ) });
13546
13554
  }, _o = ct(
13547
13555
  ({
13548
13556
  value: e,
@@ -13583,13 +13591,13 @@ const Ks = ({ children: e, width: t, size: r = "small", onClose: n, closable: o
13583
13591
  }
13584
13592
  const K = A;
13585
13593
  t == null || t(K);
13586
- }, ve = () => {
13594
+ }, Re = () => {
13587
13595
  if (n) {
13588
13596
  Z([]);
13589
13597
  return;
13590
13598
  }
13591
13599
  Z("");
13592
- }, Re = (A) => {
13600
+ }, Ne = (A) => {
13593
13601
  const K = O.filter((me) => me !== A);
13594
13602
  Z(K), D(K);
13595
13603
  }, kt = (A) => (O == null ? void 0 : O.indexOf(A)) === 0 ? (
@@ -13600,7 +13608,7 @@ const Ks = ({ children: e, width: t, size: r = "small", onClose: n, closable: o
13600
13608
  }, ge = async (A) => {
13601
13609
  const { target: K } = A;
13602
13610
  K.scrollTop + K.offsetHeight >= K.scrollHeight - c && (g == null || g(!0)), f && await f(A);
13603
- }, Ne = (A) => {
13611
+ }, we = (A) => {
13604
13612
  var K, me;
13605
13613
  return ((K = i.find((dr) => dr.value === A)) == null ? void 0 : K.label) || ((me = p == null ? void 0 : p.find((dr) => dr.value === A)) == null ? void 0 : me.label) || A;
13606
13614
  };
@@ -13623,6 +13631,7 @@ const Ks = ({ children: e, width: t, size: r = "small", onClose: n, closable: o
13623
13631
  placeholder: r ? d ? `${r}*` : r : void 0,
13624
13632
  disabled: a,
13625
13633
  value: O || void 0,
13634
+ labelRender: (A) => we(A.value),
13626
13635
  mode: n === "filter" ? "multiple" : n,
13627
13636
  onChange: Z,
13628
13637
  onFocus: Ce,
@@ -13640,9 +13649,9 @@ const Ks = ({ children: e, width: t, size: r = "small", onClose: n, closable: o
13640
13649
  return /* @__PURE__ */ h("div", { onMouseDown: q, className: "tag-wrapper", children: /* @__PURE__ */ h(
13641
13650
  Ks,
13642
13651
  {
13643
- onClose: () => Re(A.value),
13652
+ onClose: () => Ne(A.value),
13644
13653
  closable: !a,
13645
- children: /* @__PURE__ */ h(Gs, { variant: "body4", children: K ? A.label : Ne(A.value) })
13654
+ children: /* @__PURE__ */ h(Gs, { variant: "body4", children: K ? A.label : we(A.value) })
13646
13655
  }
13647
13656
  ) });
13648
13657
  },
@@ -13653,15 +13662,17 @@ const Ks = ({ children: e, width: t, size: r = "small", onClose: n, closable: o
13653
13662
  T6,
13654
13663
  {
13655
13664
  values: A,
13656
- onTagClose: Re,
13665
+ onTagClose: Ne,
13657
13666
  maxWidth: ((K = H.current) == null ? void 0 : K.clientWidth) || 0,
13658
- disabled: a
13667
+ disabled: a,
13668
+ options: i,
13669
+ extraOptions: p
13659
13670
  }
13660
13671
  );
13661
13672
  },
13662
13673
  onPopupScroll: ge,
13663
13674
  suffixIcon: /* @__PURE__ */ h("div", { className: "wrapper-suffix-icon", children: n !== "filter" && /* @__PURE__ */ C(Ue, { children: [
13664
- n && O && !!O.length && /* @__PURE__ */ h("div", { onClick: ve, children: /* @__PURE__ */ h(yt, { name: "cancel" }) }),
13675
+ n && O && !!O.length && /* @__PURE__ */ h("div", { onClick: Re, children: /* @__PURE__ */ h(yt, { name: "cancel" }) }),
13665
13676
  /* @__PURE__ */ h(
13666
13677
  yt,
13667
13678
  {
@@ -13739,7 +13750,7 @@ const Sr = {
13739
13750
  loadOnClosedState: c,
13740
13751
  extraOptions: l
13741
13752
  }, u) => {
13742
- const [g, f] = G([]), [m, p] = G(Sr), [R, v] = G(!1), [L, S] = G(null), N = Le(
13753
+ const [g, f] = G([]), [m, p] = G(Sr), [R, v] = G(!1), [L, S] = G(null), N = ve(
13743
13754
  async (I = !1, ae) => {
13744
13755
  if (!R) {
13745
13756
  v(!0);
@@ -13757,14 +13768,14 @@ const Sr = {
13757
13768
  }
13758
13769
  },
13759
13770
  [m, e, R]
13760
- ), E = _6(N), x = Le(
13771
+ ), E = _6(N), x = ve(
13761
13772
  (I) => {
13762
13773
  (I === "" || I === void 0 || I === null) && p(Sr), E(!0, I);
13763
13774
  },
13764
13775
  [E]
13765
13776
  ), O = async (I) => {
13766
13777
  I && L !== null && L > g.length && await N(!1);
13767
- }, D = Le(
13778
+ }, D = ve(
13768
13779
  (I) => {
13769
13780
  I && !c && N(!1);
13770
13781
  },
@@ -13914,7 +13925,7 @@ const z6 = (e, t) => {
13914
13925
  return ce(() => {
13915
13926
  r.current = e;
13916
13927
  }, [e, t]), r.current;
13917
- }, qs = (e, t, r, n) => e.getFixedT(t, r, n), Y6 = (e, t, r, n) => Le(qs(e, t, r, n), [e, t, r, n]), J6 = function(e) {
13928
+ }, qs = (e, t, r, n) => e.getFixedT(t, r, n), Y6 = (e, t, r, n) => ve(qs(e, t, r, n), [e, t, r, n]), J6 = function(e) {
13918
13929
  let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
13919
13930
  const {
13920
13931
  i18n: r
@@ -14364,22 +14375,22 @@ class Wt extends ur {
14364
14375
  });
14365
14376
  q && q.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
14366
14377
  }
14367
- let ve = [];
14368
- const Re = this.languageUtils.getFallbackCodes(this.options.fallbackLng, r.lng || this.language);
14369
- if (this.options.saveMissingTo === "fallback" && Re && Re[0])
14370
- for (let q = 0; q < Re.length; q++)
14371
- ve.push(Re[q]);
14372
- else this.options.saveMissingTo === "all" ? ve = this.languageUtils.toResolveHierarchy(r.lng || this.language) : ve.push(r.lng || this.language);
14373
- const kt = (q, ge, Ne) => {
14374
- const A = O && Ne !== g ? Ne : le;
14378
+ let Re = [];
14379
+ const Ne = this.languageUtils.getFallbackCodes(this.options.fallbackLng, r.lng || this.language);
14380
+ if (this.options.saveMissingTo === "fallback" && Ne && Ne[0])
14381
+ for (let q = 0; q < Ne.length; q++)
14382
+ Re.push(Ne[q]);
14383
+ else this.options.saveMissingTo === "all" ? Re = this.languageUtils.toResolveHierarchy(r.lng || this.language) : Re.push(r.lng || this.language);
14384
+ const kt = (q, ge, we) => {
14385
+ const A = O && we !== g ? we : le;
14375
14386
  this.options.missingKeyHandler ? this.options.missingKeyHandler(q, d, ge, A, Z, r) : this.backendConnector && this.backendConnector.saveMissing && this.backendConnector.saveMissing(q, d, ge, A, Z, r), this.emit("missingKey", q, d, ge, g);
14376
14387
  };
14377
- this.options.saveMissing && (this.options.saveMissingPlurals && x ? ve.forEach((q) => {
14388
+ this.options.saveMissing && (this.options.saveMissingPlurals && x ? Re.forEach((q) => {
14378
14389
  const ge = this.pluralResolver.getSuffixes(q, r);
14379
- I && r[`defaultValue${this.options.pluralSeparator}zero`] && ge.indexOf(`${this.options.pluralSeparator}zero`) < 0 && ge.push(`${this.options.pluralSeparator}zero`), ge.forEach((Ne) => {
14380
- kt([q], s + Ne, r[`defaultValue${Ne}`] || ae);
14390
+ I && r[`defaultValue${this.options.pluralSeparator}zero`] && ge.indexOf(`${this.options.pluralSeparator}zero`) < 0 && ge.push(`${this.options.pluralSeparator}zero`), ge.forEach((we) => {
14391
+ kt([q], s + we, r[`defaultValue${we}`] || ae);
14381
14392
  });
14382
- }) : kt(ve, s, ae));
14393
+ }) : kt(Re, s, ae));
14383
14394
  }
14384
14395
  g = this.extendTranslation(g, t, r, u, n), E && g === s && this.options.appendNamespaceToMissingKey && (g = `${d}:${s}`), (E || N) && this.options.parseMissingKeyHandler && (this.options.compatibilityAPI !== "v1" ? g = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${d}:${s}` : s, N ? g : void 0) : g = this.options.parseMissingKeyHandler(g));
14385
14396
  }
@@ -15468,13 +15479,13 @@ $.use(Z6).init({
15468
15479
  });
15469
15480
  const M7 = ct(
15470
15481
  ({ fetchParams: e, mode: t = void 0, placeholder: r, disabled: n, value: o, onChange: i, onError: s }, a) => {
15471
- const { axios: d, locale: c } = ht(o1), { t: l } = J6("common", { lng: c }), [u, g] = G([]), [f, m] = G(!0), p = Le(
15482
+ const { axios: d, locale: c } = ht(o1), { t: l } = J6("common", { lng: c }), [u, g] = G([]), [f, m] = G(!0), p = ve(
15472
15483
  (N) => {
15473
15484
  let E = "";
15474
15485
  return N.deletedAt && (E += `[${l("deleted")}] `), N.status === Tt.ARCHIVED && (E += `[${l("archived")}] `), `${E}${N.firstName} ${N.lastName}`;
15475
15486
  },
15476
15487
  [l]
15477
- ), R = Le(
15488
+ ), R = ve(
15478
15489
  async ({
15479
15490
  offset: N,
15480
15491
  limit: E,
@@ -15507,7 +15518,7 @@ const M7 = ct(
15507
15518
  }
15508
15519
  },
15509
15520
  [d, e, s, p]
15510
- ), v = Le(
15521
+ ), v = ve(
15511
15522
  async (N) => {
15512
15523
  var E, x, O;
15513
15524
  try {
@@ -15549,7 +15560,7 @@ const M7 = ct(
15549
15560
  g(x), m(!1);
15550
15561
  })();
15551
15562
  }, [v, o]);
15552
- const L = Le(
15563
+ const L = ve(
15553
15564
  async ({
15554
15565
  limit: N,
15555
15566
  offset: E,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snmt-react-ui/user-select",
3
3
  "private": false,
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "type": "module",
6
6
  "main": "dist/user-select.js",
7
7
  "types": "dist/index.d.ts",
@@ -18,15 +18,15 @@
18
18
  "build": "tsc && vite build"
19
19
  },
20
20
  "dependencies": {
21
- "@snmt-react-ui/async-select": "^1.2.2",
21
+ "@snmt-react-ui/async-select": "^1.2.3",
22
22
  "@snmt-react-ui/core": "^1.6.0",
23
23
  "@snmt-react-ui/loader": "^1.2.0",
24
- "@snmt-react-ui/select": "^1.8.2"
24
+ "@snmt-react-ui/select": "^1.8.3"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "antd": "^5.22.3",
28
28
  "i18next": "^23.11.1",
29
29
  "react-i18next": "^14.1.0"
30
30
  },
31
- "gitHead": "7f9b1f1c9ede6d9bb0e8d1c0404e6fad6f135ab0"
31
+ "gitHead": "3d8e739899178b34e6cf0575f7f79127f95aeba6"
32
32
  }