@bynder/compact-view 5.2.3 → 5.2.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.
Files changed (253) hide show
  1. package/AccessToken2.js +1 -1
  2. package/ActiveFilters.js +49 -50
  3. package/AddMedia.js +19 -18
  4. package/Advanced.js +13 -13
  5. package/App.js +60 -59
  6. package/Arrow.js +1 -1
  7. package/AssetFilter.js +38 -38
  8. package/AssetItem.js +10 -17
  9. package/AssetList.js +5 -5
  10. package/AssetTypeItem.js +21 -21
  11. package/AssetsView.js +13 -13
  12. package/Axios2.js +82 -76
  13. package/AxiosError.js +36 -35
  14. package/ButtonAction.js +1 -1
  15. package/CanceledError.js +15 -8
  16. package/Card.js +1 -1
  17. package/Chip.js +1 -1
  18. package/CollectionCard.js +22 -22
  19. package/CollectionItem.js +9 -9
  20. package/CollectionList.js +5 -5
  21. package/CollectionView.js +11 -11
  22. package/ColorPicker.js +1 -1
  23. package/ColorPickerSolid.js +3 -3
  24. package/ColorPickerWithOpacity.js +3 -3
  25. package/Component.js +158 -0
  26. package/Component2.js +4 -0
  27. package/ConfigContext.js +7 -8
  28. package/Container.js +1 -1
  29. package/ContextAction.js +1 -1
  30. package/ControlGroup.js +6 -6
  31. package/Dat.js +33 -32
  32. package/DatDropdownItem.js +1 -1
  33. package/DesignSystemProvider.js +7 -7
  34. package/DirectionSelect.js +11 -10
  35. package/DomainInput.js +19 -11
  36. package/Draggable.js +337 -0
  37. package/Draggable2.js +4 -0
  38. package/DraggableCore.js +312 -0
  39. package/DraggableCore2.js +4 -0
  40. package/Dropdown.js +37 -37
  41. package/Dropdown2.js +1 -1
  42. package/DropdownListItem.js +1 -1
  43. package/FieldSelect.js +19 -17
  44. package/FileSelector.js +38 -37
  45. package/FontPicker.js +1 -1
  46. package/Form.js +1 -1
  47. package/Header.js +5 -4
  48. package/HttpStatusCode.js +7 -1
  49. package/InfiniteScroll.js +1 -1
  50. package/InlineBanner.js +1 -1
  51. package/Input.js +1 -1
  52. package/InterceptorManager.js +2 -1
  53. package/Item.js +8 -8
  54. package/Item4.js +2 -2
  55. package/LeftArrow.js +1 -1
  56. package/ListItem2.js +1 -1
  57. package/ModalBase.js +15 -15
  58. package/NoResults.js +1 -1
  59. package/Option_new.js +36 -29
  60. package/ReactPropTypesSecret.js +10 -0
  61. package/RightArrow.js +1 -1
  62. package/SearchInput.js +1 -1
  63. package/SearchInput2.js +1 -1
  64. package/SelectionFooter.js +41 -31
  65. package/Shield.js +2 -2
  66. package/Smartfilters_new.js +107 -98
  67. package/StatefulAssetList.js +50 -50
  68. package/StoreInitializer.js +32 -16
  69. package/SwitchNLS.js +1 -1
  70. package/TagItem.js +15 -15
  71. package/Tags.js +1 -1
  72. package/Toolbar.js +23 -20
  73. package/Tooltip2.js +1 -1
  74. package/ViewSwitch.js +17 -15
  75. package/_commonjsHelpers.js +28 -3
  76. package/adapters.js +54 -42
  77. package/api/filterAssets.d.ts +1 -1
  78. package/api/getAssets.d.ts +1 -1
  79. package/api/getFilters.d.ts +1 -1
  80. package/api/rest/index.d.ts +1 -1
  81. package/api/rest/types.d.ts +1 -1
  82. package/api2.js +1 -1
  83. package/asset.type.js +1 -1
  84. package/autocomplete.js +1 -1
  85. package/axios.js +1 -1
  86. package/bodyScrollLock.esm.js +68 -0
  87. package/buildURL.js +13 -15
  88. package/checkGlobals.js +1 -1
  89. package/cjs.js +7 -0
  90. package/cjs2.js +15 -0
  91. package/cjs3.js +4 -0
  92. package/clsx.m.js +6 -0
  93. package/clsx.m2.js +15 -0
  94. package/combineMetaproperties.js +3 -1
  95. package/composeSignals.js +1 -1
  96. package/cookieStore.js +1 -1
  97. package/cookies.js +13 -11
  98. package/currentScopes.js +1 -1
  99. package/data.js +1 -1
  100. package/devUtils.js +1 -1
  101. package/dispatchRequest.js +5 -5
  102. package/domFns.js +151 -0
  103. package/domFns2.js +4 -0
  104. package/factoryWithThrowingShims.js +52 -0
  105. package/fetch2.js +156 -128
  106. package/filter/AssetFilterContext.d.ts +3 -3
  107. package/filterAssets.js +1 -1
  108. package/getAsset.js +1 -1
  109. package/getAssetCounts.js +1 -1
  110. package/getAssets.js +1 -1
  111. package/getCollections.js +1 -1
  112. package/getFilterOptions.js +1 -1
  113. package/getFilters.js +1 -1
  114. package/getFilters_new.js +1 -1
  115. package/getPrefix.js +35 -0
  116. package/getPrefix2.js +4 -0
  117. package/getSimilarityAssets.js +1 -1
  118. package/goober.modern.js +75 -0
  119. package/handlers.js +1 -1
  120. package/iconBase.js +56 -0
  121. package/iconContext.js +12 -0
  122. package/iconsManifest.js +222 -0
  123. package/index-esm.js +1 -4
  124. package/index.browser.js +1 -1
  125. package/index.m.js +9 -0
  126. package/index.m2.js +17 -0
  127. package/index10.js +18 -2
  128. package/index11.js +181 -15
  129. package/index112.js +1 -1
  130. package/index12.js +313 -36
  131. package/index13.js +5 -2430
  132. package/index14.js +3 -557
  133. package/index15.js +15 -55
  134. package/index16.js +3 -2
  135. package/index17.js +3 -87
  136. package/index18.js +36 -60
  137. package/index19.js +3 -7
  138. package/index20.js +2429 -12
  139. package/index21.js +557 -10
  140. package/index22.js +1 -1
  141. package/index23.js +119 -6
  142. package/index24.js +39 -7
  143. package/index25.js +2 -5
  144. package/index26.js +86 -9
  145. package/index27.js +55 -8
  146. package/index28.js +6 -636
  147. package/index29.js +8692 -74
  148. package/index3.js +1684 -5
  149. package/index30.js +2 -5
  150. package/index31.js +4 -20
  151. package/index310.js +2 -0
  152. package/index32.js +11 -2
  153. package/index33.js +5083 -4
  154. package/index34.js +2 -18
  155. package/index35.js +59 -5
  156. package/index36.js +2 -2
  157. package/index37.js +13 -11
  158. package/index38.js +46 -10
  159. package/index39.js +6 -12
  160. package/index4.js +5 -1684
  161. package/index40.js +8 -11
  162. package/index41.js +26 -18
  163. package/index42.js +2 -64
  164. package/index43.js +63 -5
  165. package/index44.js +9 -55
  166. package/index45.js +7 -67
  167. package/index46.js +8 -31
  168. package/index47.js +5 -11
  169. package/index48.js +10 -121
  170. package/index49.js +9 -86
  171. package/index5.js +215 -23
  172. package/index50.js +636 -7
  173. package/index51.js +74 -11
  174. package/index52.js +4 -13
  175. package/index53.js +19 -13
  176. package/index54.js +4 -6
  177. package/index55.js +18 -7
  178. package/index56.js +5 -14
  179. package/index57.js +10 -28
  180. package/index58.js +10 -15
  181. package/index59.js +15 -0
  182. package/index6.js +250 -299
  183. package/index60.js +13 -0
  184. package/index61.js +21 -0
  185. package/index62.js +8 -0
  186. package/index63.js +57 -0
  187. package/index64.js +4 -0
  188. package/index65.js +69 -0
  189. package/index66.js +33 -0
  190. package/index67.js +13 -0
  191. package/index68.js +123 -0
  192. package/index69.js +88 -0
  193. package/index7.js +22 -5047
  194. package/index70.js +10 -0
  195. package/index71.js +13 -0
  196. package/index72.js +13 -225
  197. package/index73.js +16 -0
  198. package/index74.js +9 -0
  199. package/index75.js +228 -0
  200. package/index76.js +9 -0
  201. package/index77.js +17 -0
  202. package/index78.js +31 -0
  203. package/index79.js +18 -0
  204. package/index8.js +5044 -47
  205. package/index9.js +50 -15
  206. package/isAbsoluteURL.js +1 -1
  207. package/isURLSameOrigin.js +1 -1
  208. package/localization.js +15 -15
  209. package/log.js +14 -0
  210. package/log2.js +4 -0
  211. package/matchRequestUrl.js +1 -1
  212. package/mergeConfig.js +37 -32
  213. package/notify.js +2 -2
  214. package/package.json +1 -1
  215. package/positionFns.js +101 -0
  216. package/positionFns2.js +4 -0
  217. package/react-laag.esm.js +957 -0
  218. package/react.js +8 -8
  219. package/react2.js +9 -9
  220. package/resolveConfig.js +23 -23
  221. package/select/add-media/AddMedia.d.ts +3 -1
  222. package/select/current-selection/SelectedItems.d.ts +1 -1
  223. package/shims.js +29 -0
  224. package/shims2.js +4 -0
  225. package/store/StoreInitializer.d.ts +5 -1
  226. package/store/useAssetFilterStore.d.ts +55 -0
  227. package/store/useSelectionStore.d.ts +47 -0
  228. package/styled-components.browser.esm.js +2 -2
  229. package/throttle.js +1 -1
  230. package/toURLEncodedForm.js +11 -10
  231. package/tokenExpirationHelper.js +1 -1
  232. package/transformData.js +1 -1
  233. package/transitional.js +4 -3
  234. package/useAssetFilterStore.js +152 -0
  235. package/useDatStore.js +1 -1
  236. package/useEffectEvent.js +7 -7
  237. package/useFonts.js +2 -2
  238. package/useOrderingStore.js +1 -1
  239. package/useRouterStore.js +1 -1
  240. package/useSearchStore.js +1 -1
  241. package/useSelectionStore.js +131 -0
  242. package/useSimilaritySearchStore.js +1 -1
  243. package/useTranslate.js +1 -1
  244. package/utils/combineMetaproperties.d.ts +2 -0
  245. package/utils6.js +160 -118
  246. package/utils7.js +7 -68
  247. package/utils8.js +68 -7
  248. package/xhr.js +47 -46
  249. package/AssetFilterContext.js +0 -161
  250. package/SelectionContext.js +0 -143
  251. package/select/SelectionContext.d.ts +0 -30
  252. /package/{Middleware.js → Middleware2.js} +0 -0
  253. /package/{middleware2.js → middleware.js} +0 -0
package/utils8.js CHANGED
@@ -1,9 +1,70 @@
1
- const e = typeof window < "u" && typeof document < "u", o = typeof navigator == "object" && navigator || void 0, n = e && (!o || ["ReactNative", "NativeScript", "NS"].indexOf(o.product) < 0), t = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
2
- self instanceof WorkerGlobalScope && typeof self.importScripts == "function", r = e && window.location.href || "http://localhost";
1
+ import { produce as e } from "./immer.js";
2
+ import { API as a } from "./api2.js";
3
+ function F(i, t) {
4
+ return e(i, (n) => {
5
+ const o = n.findIndex((f) => f.id === t?.id);
6
+ o !== -1 && n.splice(o, 1), n.unshift(t);
7
+ });
8
+ }
9
+ function c(i, t = !1) {
10
+ return t ? i.map((n) => ({
11
+ ...n,
12
+ subfamilies: n.subfamilies.filter((o) => !o.is_italic)
13
+ })) : i;
14
+ }
15
+ function r(i, t) {
16
+ return i.subfamilies.find(
17
+ (o) => o.weight === t
18
+ ) || i.subfamilies[0];
19
+ }
20
+ async function u(i, t = "400") {
21
+ const n = await s(), o = i || n.family.id;
22
+ if (!o)
23
+ throw new Error(`Fonts: Family not found for (default) id: ${o}`);
24
+ const f = await a.getFontFamilyById(o);
25
+ if (!f)
26
+ throw new Error(`Fonts: Family not found for id: ${o}`);
27
+ const l = r(f, t);
28
+ if (!l)
29
+ throw new Error(`Fonts: Subfamily not found for weight: ${t}`);
30
+ return {
31
+ family: f,
32
+ subfamily: l
33
+ };
34
+ }
35
+ async function m(i) {
36
+ const t = await a.getSubfamilyById(i);
37
+ if (!t)
38
+ throw new Error(`Fonts: Subfamily not found for id: ${i}`);
39
+ const n = await a.getFontFamilyById(t.font_id);
40
+ if (!n)
41
+ throw new Error(`Fonts: Family not found for id: ${t.font_id}`);
42
+ return {
43
+ family: n,
44
+ subfamily: t
45
+ };
46
+ }
47
+ async function s() {
48
+ const i = await a.getDefaultGlobalFont();
49
+ if (!i)
50
+ throw new Error("FontManager v2: (Default) Global Font Family not found");
51
+ const t = i.family.subfamilies.find(
52
+ (n) => n.id === i.default_subfamily_id
53
+ );
54
+ if (!t)
55
+ throw new Error("FontManager v2: (Default) Global Font Subfamily not found");
56
+ return {
57
+ family: i.family,
58
+ subfamily: t
59
+ };
60
+ }
61
+ async function w(i, t) {
62
+ let n;
63
+ return t ? n = await m(t) : n = await u(i), n;
64
+ }
3
65
  export {
4
- e as hasBrowserEnv,
5
- n as hasStandardBrowserEnv,
6
- t as hasStandardBrowserWebWorkerEnv,
7
- o as navigator,
8
- r as origin
66
+ c as filterFamilies,
67
+ s as getDefaultFont,
68
+ w as getFamilyAndSubfamily,
69
+ F as moveSelectedFamilyToTop
9
70
  };
package/xhr.js CHANGED
@@ -1,69 +1,70 @@
1
- import b from "./utils6.js";
1
+ import H from "./utils6.js";
2
2
  import D from "./settle.js";
3
3
  import L from "./transitional.js";
4
- import r from "./AxiosError.js";
5
- import v from "./CanceledError.js";
6
- import y from "./parseProtocol.js";
7
- import O from "./index19.js";
8
- import H from "./AxiosHeaders.js";
9
- import { progressEventReducer as q } from "./progressEventReducer.js";
10
- import U from "./resolveConfig.js";
11
- const N = typeof XMLHttpRequest < "u", Q = N && function(n) {
12
- return new Promise(function(A, s) {
13
- const t = U(n);
14
- let c = t.data;
15
- const E = H.from(t.headers).normalize();
16
- let { responseType: i, onUploadProgress: T, onDownloadProgress: R } = t, a, h, w, u, p;
17
- function g() {
18
- u && u(), p && p(), t.cancelToken && t.cancelToken.unsubscribe(a), t.signal && t.signal.removeEventListener("abort", a);
4
+ import n from "./AxiosError.js";
5
+ import y from "./CanceledError.js";
6
+ import O from "./parseProtocol.js";
7
+ import U from "./index28.js";
8
+ import q from "./AxiosHeaders.js";
9
+ import { progressEventReducer as A } from "./progressEventReducer.js";
10
+ import v from "./resolveConfig.js";
11
+ const N = typeof XMLHttpRequest < "u", Q = N && function(s) {
12
+ return new Promise(function(C, i) {
13
+ const t = v(s);
14
+ let E = t.data;
15
+ const T = q.from(t.headers).normalize();
16
+ let { responseType: d, onUploadProgress: R, onDownloadProgress: h } = t, l, g, w, u, f;
17
+ function x() {
18
+ u && u(), f && f(), t.cancelToken && t.cancelToken.unsubscribe(l), t.signal && t.signal.removeEventListener("abort", l);
19
19
  }
20
20
  let e = new XMLHttpRequest();
21
21
  e.open(t.method.toUpperCase(), t.url, !0), e.timeout = t.timeout;
22
- function x() {
22
+ function b() {
23
23
  if (!e)
24
24
  return;
25
- const o = H.from(
25
+ const o = q.from(
26
26
  "getAllResponseHeaders" in e && e.getAllResponseHeaders()
27
- ), d = {
28
- data: !i || i === "text" || i === "json" ? e.responseText : e.response,
27
+ ), a = {
28
+ data: !d || d === "text" || d === "json" ? e.responseText : e.response,
29
29
  status: e.status,
30
30
  statusText: e.statusText,
31
31
  headers: o,
32
- config: n,
32
+ config: s,
33
33
  request: e
34
34
  };
35
- D(function(m) {
36
- A(m), g();
37
- }, function(m) {
38
- s(m), g();
39
- }, d), e = null;
35
+ D(function(c) {
36
+ C(c), x();
37
+ }, function(c) {
38
+ i(c), x();
39
+ }, a), e = null;
40
40
  }
41
- "onloadend" in e ? e.onloadend = x : e.onreadystatechange = function() {
42
- !e || e.readyState !== 4 || e.status === 0 && !(e.responseURL && e.responseURL.indexOf("file:") === 0) || setTimeout(x);
41
+ "onloadend" in e ? e.onloadend = b : e.onreadystatechange = function() {
42
+ !e || e.readyState !== 4 || e.status === 0 && !(e.responseURL && e.responseURL.indexOf("file:") === 0) || setTimeout(b);
43
43
  }, e.onabort = function() {
44
- e && (s(new r("Request aborted", r.ECONNABORTED, n, e)), e = null);
45
- }, e.onerror = function() {
46
- s(new r("Network Error", r.ERR_NETWORK, n, e)), e = null;
44
+ e && (i(new n("Request aborted", n.ECONNABORTED, s, e)), e = null);
45
+ }, e.onerror = function(r) {
46
+ const a = r && r.message ? r.message : "Network Error", p = new n(a, n.ERR_NETWORK, s, e);
47
+ p.event = r || null, i(p), e = null;
47
48
  }, e.ontimeout = function() {
48
- let l = t.timeout ? "timeout of " + t.timeout + "ms exceeded" : "timeout exceeded";
49
- const d = t.transitional || L;
50
- t.timeoutErrorMessage && (l = t.timeoutErrorMessage), s(new r(
51
- l,
52
- d.clarifyTimeoutError ? r.ETIMEDOUT : r.ECONNABORTED,
53
- n,
49
+ let r = t.timeout ? "timeout of " + t.timeout + "ms exceeded" : "timeout exceeded";
50
+ const a = t.transitional || L;
51
+ t.timeoutErrorMessage && (r = t.timeoutErrorMessage), i(new n(
52
+ r,
53
+ a.clarifyTimeoutError ? n.ETIMEDOUT : n.ECONNABORTED,
54
+ s,
54
55
  e
55
56
  )), e = null;
56
- }, c === void 0 && E.setContentType(null), "setRequestHeader" in e && b.forEach(E.toJSON(), function(l, d) {
57
- e.setRequestHeader(d, l);
58
- }), b.isUndefined(t.withCredentials) || (e.withCredentials = !!t.withCredentials), i && i !== "json" && (e.responseType = t.responseType), R && ([w, p] = q(R, !0), e.addEventListener("progress", w)), T && e.upload && ([h, u] = q(T), e.upload.addEventListener("progress", h), e.upload.addEventListener("loadend", u)), (t.cancelToken || t.signal) && (a = (o) => {
59
- e && (s(!o || o.type ? new v(null, n, e) : o), e.abort(), e = null);
60
- }, t.cancelToken && t.cancelToken.subscribe(a), t.signal && (t.signal.aborted ? a() : t.signal.addEventListener("abort", a)));
61
- const f = y(t.url);
62
- if (f && O.protocols.indexOf(f) === -1) {
63
- s(new r("Unsupported protocol " + f + ":", r.ERR_BAD_REQUEST, n));
57
+ }, E === void 0 && T.setContentType(null), "setRequestHeader" in e && H.forEach(T.toJSON(), function(r, a) {
58
+ e.setRequestHeader(a, r);
59
+ }), H.isUndefined(t.withCredentials) || (e.withCredentials = !!t.withCredentials), d && d !== "json" && (e.responseType = t.responseType), h && ([w, f] = A(h, !0), e.addEventListener("progress", w)), R && e.upload && ([g, u] = A(R), e.upload.addEventListener("progress", g), e.upload.addEventListener("loadend", u)), (t.cancelToken || t.signal) && (l = (o) => {
60
+ e && (i(!o || o.type ? new y(null, s, e) : o), e.abort(), e = null);
61
+ }, t.cancelToken && t.cancelToken.subscribe(l), t.signal && (t.signal.aborted ? l() : t.signal.addEventListener("abort", l)));
62
+ const m = O(t.url);
63
+ if (m && U.protocols.indexOf(m) === -1) {
64
+ i(new n("Unsupported protocol " + m + ":", n.ERR_BAD_REQUEST, s));
64
65
  return;
65
66
  }
66
- e.send(c || null);
67
+ e.send(E || null);
67
68
  });
68
69
  };
69
70
  export {
@@ -1,161 +0,0 @@
1
- import { jsx as R } from "react/jsx-runtime";
2
- import { createContext as V, useState as c, useEffect as x, useMemo as X, useContext as Y } from "react";
3
- const j = V(null);
4
- function U({
5
- children: o,
6
- hideLimitedUse: u = !1,
7
- predefinedFilter: s
8
- }) {
9
- const [b, l] = c(
10
- s?.predefinedAssetType ? [...s?.predefinedAssetType] : []
11
- ), [p, g] = c([]), [E, C] = c(!1), [M, m] = c(
12
- s?.predefinedTagNames ? [...s.predefinedTagNames] : []
13
- ), [O, I] = c(), [P, S] = c({}), [v, d] = c({}), [D, y] = c(null);
14
- x(() => {
15
- I(u ? !1 : void 0);
16
- }, [u]), x(() => {
17
- w();
18
- }, [s?.predefinedMetapropertiesOptions]);
19
- function L(e) {
20
- l((t) => T(t, e));
21
- }
22
- function N(e) {
23
- s?.showToolbar && s.predefinedAssetType?.includes(e) || l((t) => A(t, e));
24
- }
25
- function W(e) {
26
- g((t) => T(t, e.id)), S((t) => ({
27
- ...t,
28
- [e.id]: e
29
- }));
30
- }
31
- function _(e) {
32
- g(
33
- (t) => A(t, e.id)
34
- ), S((t) => {
35
- const { [e.id]: i, ...r } = t;
36
- return r;
37
- });
38
- }
39
- function w() {
40
- s?.predefinedMetapropertiesOptions && d(() => Object.entries(
41
- s.predefinedMetapropertiesOptions || {}
42
- ).reduce((e, [t, i]) => (e[t] = {}, Object.entries(i).forEach(([r, n]) => {
43
- e[t][n] = {
44
- id: n,
45
- label: r,
46
- metapropertyName: t
47
- };
48
- }), e), {}));
49
- }
50
- function k(e) {
51
- m((t) => T(t, e));
52
- }
53
- function q(e) {
54
- s?.showToolbar && s.predefinedTagNames?.includes(e) || m((t) => A(t, e));
55
- }
56
- function z(e, t, i) {
57
- const r = {
58
- id: t.id,
59
- label: t.label,
60
- metapropertyName: e
61
- };
62
- d((n) => {
63
- const a = n[e] || {}, f = !!a[t.id];
64
- return i ? {
65
- ...n,
66
- [e]: f ? (
67
- // Remove if already selected
68
- Object.fromEntries(
69
- Object.entries(a).filter(
70
- ([Q]) => Q !== t.id
71
- )
72
- )
73
- ) : (
74
- // Add if not selected already
75
- {
76
- ...a,
77
- [t.id]: r
78
- }
79
- )
80
- } : f ? {
81
- ...n,
82
- [e]: {}
83
- } : {
84
- ...n,
85
- [e]: {
86
- [t.id]: r
87
- }
88
- };
89
- });
90
- }
91
- function B(e, t) {
92
- d((i) => {
93
- const { [e]: r, ...n } = i, { [t]: a, ...f } = r || {};
94
- return f && Object.keys(f).length > 0 ? {
95
- ...i,
96
- [e]: f
97
- } : n;
98
- });
99
- }
100
- function G(e) {
101
- const t = e.count, i = Object.entries(t || {}).filter(
102
- ([r, n]) => r.startsWith("property") && n && Object.keys(n).length > 0
103
- ).reduce((r, [n, a]) => (r[n.replace("property_", "")] = a, r), {});
104
- y(i);
105
- }
106
- function H() {
107
- l(
108
- s?.showToolbar && s?.predefinedAssetType ? [...s.predefinedAssetType] : []
109
- ), m(
110
- s?.showToolbar && s?.predefinedTagNames ? [...s.predefinedTagNames] : []
111
- ), d({}), y(null);
112
- }
113
- const h = p.map((e) => P[e]);
114
- function J(e) {
115
- C(e);
116
- }
117
- const K = X(
118
- () => ({
119
- assetTypes: b,
120
- metaproperties: h,
121
- metapropertyIds: p,
122
- tags: M,
123
- isLimited: O,
124
- addAssetType: L,
125
- removeAssetType: N,
126
- addMetaproperty: W,
127
- removeMetaproperty: _,
128
- setPredefinedMetaproperties: w,
129
- addTag: k,
130
- removeTag: q,
131
- clear: H,
132
- setDropdownState: J,
133
- isDropdownActive: E,
134
- selectSmartfilterOption: z,
135
- removeSmartfilterOption: B,
136
- selectedSmartfilterOptions: v,
137
- setActiveFiltersState: G,
138
- existingFilters: D
139
- }),
140
- // eslint-disable-next-line react-hooks/exhaustive-deps
141
- [b, h, M, O, p, v]
142
- );
143
- return /* @__PURE__ */ R(j.Provider, { value: K, children: o });
144
- }
145
- function T(o, u) {
146
- return o.includes(u) ? o : [...o, u];
147
- }
148
- function A(o, u) {
149
- return o.filter((s) => s !== u);
150
- }
151
- function F() {
152
- const o = Y(j);
153
- if (o === null)
154
- throw new Error("useAssetFilter must be used with a AssetFilterProvider");
155
- return o;
156
- }
157
- export {
158
- j as AssetFilterContext,
159
- U as AssetFilterProvider,
160
- F as useAssetFilter
161
- };
@@ -1,143 +0,0 @@
1
- import { jsx as O } from "react/jsx-runtime";
2
- import { createContext as j, useState as v, useEffect as p, useMemo as k, useContext as q } from "react";
3
- import { getAssetsByMediaId as B } from "./filterAssets.js";
4
- import { isErr as I } from "./result.type.js";
5
- import { useSelectionMode as L, useConfig as T } from "./ConfigContext.js";
6
- import { useAuth as V } from "./LoginContext.js";
7
- import { useDat as _ } from "./useDatStore.js";
8
- const C = j(null);
9
- function W(t) {
10
- const [s, i] = v([]), [f, g] = v([]), [a, S] = v(), u = z(a), h = L(), { transformation: o } = _();
11
- p(() => {
12
- S(
13
- (t.preselectedAssetIds ?? []).filter((e) => !!e).map((e) => window.btoa("(Asset_id " + e + ")"))
14
- );
15
- }, [t.preselectedAssetIds]), p(() => {
16
- u.length && x(u);
17
- }, [u]), p(() => {
18
- o && Object.keys(o).length && (m(), x([o?.asset]));
19
- }, [o]);
20
- function d(e) {
21
- e.tag === "Loaded" && e.value && g(e.value);
22
- }
23
- function y() {
24
- i((e) => {
25
- const n = f.filter(
26
- (l) => !e.some((c) => c.value.id === l.id)
27
- );
28
- return [
29
- ...e,
30
- ...n.map((l) => ({
31
- type: "asset",
32
- value: l
33
- }))
34
- ];
35
- });
36
- }
37
- function m() {
38
- i([]);
39
- }
40
- function x(e) {
41
- i((n) => {
42
- const l = e.filter((c) => !A(n, c));
43
- return [
44
- ...n,
45
- ...l.map((c) => ({
46
- type: "asset",
47
- value: c
48
- }))
49
- ];
50
- });
51
- }
52
- function M(e) {
53
- s.some((n) => n.value.id === e.id) ? i([]) : i([{ type: "asset", value: e }]);
54
- }
55
- function P(e) {
56
- h !== "MultiSelect" ? M(e[0]) : i((n) => {
57
- const l = e.filter(
58
- (r) => !A(n, r)
59
- ), c = e.filter(
60
- (r) => A(n, r)
61
- );
62
- return [
63
- ...n.filter(
64
- (r) => !c.some(
65
- (b) => b.id === r.value.id
66
- )
67
- ),
68
- ...l.map((r) => ({
69
- type: "asset",
70
- value: r
71
- }))
72
- ];
73
- });
74
- }
75
- function E(e) {
76
- i((n) => A(n, e) ? n.filter(
77
- (l) => l.value.id !== e.id
78
- ) : [
79
- ...n,
80
- {
81
- type: "collection",
82
- value: e
83
- }
84
- ]);
85
- }
86
- const R = k(
87
- () => ({
88
- selection: s,
89
- preselectedAssetIds: a,
90
- clear: m,
91
- selectAssets: x,
92
- toggleAssets: P,
93
- toggleCollection: E,
94
- selectAll: y,
95
- setAllAssets: d
96
- }),
97
- // eslint-disable-next-line react-hooks/exhaustive-deps
98
- [s, f]
99
- );
100
- return /* @__PURE__ */ O(C.Provider, { value: R, children: t.children });
101
- }
102
- function A(t, s) {
103
- return t.some((i) => i.value.id === s.id);
104
- }
105
- function w() {
106
- const t = q(C);
107
- if (t === null)
108
- throw new Error("useSelection must be used with a SelectionProvider");
109
- return t;
110
- }
111
- function X() {
112
- const { selection: t } = w();
113
- return t.filter((s) => s.type === "asset").map((s) => s.value.id);
114
- }
115
- function Y() {
116
- const { selection: t } = w();
117
- return t.filter((s) => s.type === "collection").map((s) => s.value.id);
118
- }
119
- function z(t) {
120
- const [s, i] = v([]), { selectionMode: f, language: g, noCache: a } = T(), S = V();
121
- let u = !1;
122
- const h = async (o) => {
123
- if (o.length) {
124
- const d = await B({ ids: o, auth: S, language: g, noCache: a });
125
- u || I(d) || (d.value?.sort((y, m) => o.indexOf(y.id) - o.indexOf(m.id)), i(d.value ?? []));
126
- }
127
- };
128
- return p(() => {
129
- if (t) {
130
- let o = t ?? [];
131
- f !== "MultiSelect" && (o = o[0] ? [o[0]] : []), h(o);
132
- }
133
- return () => {
134
- u = !0;
135
- };
136
- }, [t]), s;
137
- }
138
- export {
139
- W as SelectionProvider,
140
- X as useSelectedAssetIds,
141
- Y as useSelectedCollectionIds,
142
- w as useSelection
143
- };
@@ -1,30 +0,0 @@
1
- import { default as React } from 'react';
2
- import { Asset, AssetData } from '../views/asset/asset.type';
3
- import { Collection } from '../views/collection/collection.types';
4
- export type SelectedAsset = {
5
- type: 'asset';
6
- value: Asset;
7
- };
8
- export type SelectedCollection = {
9
- type: 'collection';
10
- value: Collection;
11
- };
12
- export type SelectedItem = SelectedAsset | SelectedCollection;
13
- interface Context {
14
- selection: SelectedItem[];
15
- preselectedAssetIds?: string[];
16
- clear: () => void;
17
- selectAll: () => void;
18
- selectAssets: (assets: Asset[]) => void;
19
- toggleAssets: (assets: Asset[]) => void;
20
- toggleCollection: (collection: Collection) => void;
21
- setAllAssets: (assetData: AssetData) => void;
22
- }
23
- export declare function SelectionProvider(props: {
24
- preselectedAssetIds: string[];
25
- children: React.ReactNode;
26
- }): React.JSX.Element;
27
- export declare function useSelection(): Context;
28
- export declare function useSelectedAssetIds(): string[];
29
- export declare function useSelectedCollectionIds(): string[];
30
- export {};
File without changes
File without changes