@box/metadata-filter 1.81.3 → 1.81.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 (54) hide show
  1. package/dist/chunks/advanced-filter-select.js +60 -0
  2. package/dist/chunks/metadata-date-field.module.js +10 -12
  3. package/dist/chunks/metadata-filter.js +47 -0
  4. package/dist/chunks/metadata-float-field-advanced.js +79 -97
  5. package/dist/chunks/metadata-taxonomy-field-advanced.js +92 -0
  6. package/dist/chunks/types.js +6 -9
  7. package/dist/chunks/types2.js +4 -6
  8. package/dist/chunks/use-float-validation.js +21 -28
  9. package/dist/esm/index.js +11 -23
  10. package/dist/esm/lib/components/metadata-filter-fields/components/constants.js +2 -6
  11. package/dist/esm/lib/components/metadata-filter-fields/components/index.js +6 -13
  12. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/constants.js +2 -4
  13. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/date-conversion-utils.js +48 -68
  14. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-advanced.js +166 -186
  15. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-relative.js +237 -257
  16. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field.js +88 -128
  17. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-internationalization.js +10 -12
  18. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-validation.js +24 -36
  19. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-integer-validation.js +14 -19
  20. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/utils.js +8 -11
  21. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-enum-field/metadata-enum-field.js +38 -57
  22. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/handlers.js +12 -15
  23. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field-advanced.js +2 -17
  24. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field.js +67 -100
  25. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/use-float-validation.js +2 -9
  26. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/utils.js +44 -57
  27. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field-advanced.js +71 -91
  28. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +35 -65
  29. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-multi-select-field/utils.js +12 -20
  30. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-string-field/metadata-string-field.js +63 -77
  31. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-string-field/utils.js +7 -15
  32. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-taxonomy-field/metadata-taxonomy-field-advanced.js +2 -113
  33. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.js +45 -68
  34. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-taxonomy-field/utils.js +8 -15
  35. package/dist/esm/lib/components/metadata-filter-fields/components/shared/advanced-filter-select.js +2 -11
  36. package/dist/esm/lib/components/metadata-filter-fields/components/shared/index.js +2 -4
  37. package/dist/esm/lib/components/metadata-filter-fields/field-processing-utils.js +26 -28
  38. package/dist/esm/lib/components/metadata-filter-fields/filter-field-types.js +26 -55
  39. package/dist/esm/lib/components/metadata-filter-fields/is-modified-utils.js +84 -94
  40. package/dist/esm/lib/components/metadata-filter-fields/metadata-filter-fields-accordion.js +60 -87
  41. package/dist/esm/lib/components/metadata-filter-fields/metadata-filter-fields.js +58 -84
  42. package/dist/esm/lib/components/metadata-template-selector/index.js +0 -1
  43. package/dist/esm/lib/components/metadata-template-selector/metadata-template-selector.js +32 -44
  44. package/dist/esm/lib/defaults.js +31 -40
  45. package/dist/esm/lib/mappers.js +17 -23
  46. package/dist/esm/lib/messages.js +218 -220
  47. package/dist/esm/lib/metadata-filter.js +3 -82
  48. package/dist/styles/advanced-filter-select.css +1 -0
  49. package/dist/styles/metadata-date-field.css +1 -1
  50. package/dist/styles/metadata-filter.css +1 -1
  51. package/dist/styles/metadata-float-field-advanced.css +1 -1
  52. package/package.json +7 -7
  53. package/dist/chunks/index.js +0 -82
  54. package/dist/styles/index.css +0 -1
@@ -1,100 +1,67 @@
1
- import { Text as D, TextInput as C } from "@box/blueprint-web";
2
- import { useFormikContext as S, getIn as y, Field as E } from "formik";
3
- import { useState as _, useRef as I } from "react";
4
- import { useIntl as k } from "react-intl";
5
- import V from "../../../../messages.js";
6
- import { R as t } from "../../../../../../chunks/types.js";
7
- import { fieldDefaultProps as $ } from "../constants.js";
8
- import { M as G, s as i } from "../../../../../../chunks/metadata-float-field-advanced.js";
9
- import { u as H, E as q } from "../../../../../../chunks/use-float-validation.js";
10
- import { jsx as r, jsxs as x } from "react/jsx-runtime";
11
- const w = ({
12
- label: o,
13
- fieldNamePrefix: a,
14
- disableForm: p,
15
- hasAccordion: L
16
- }) => {
17
- const f = k(), [h, c] = _(t.FROM), {
18
- values: F,
19
- setFieldValue: g,
20
- setFieldTouched: B
21
- } = S(), s = `${a}.value.range.gt`, d = `${a}.value.range.lt`, b = y(F, s), N = y(F, d), u = I(b), m = I(N), {
22
- validateFloats: T,
23
- fromErrorType: v,
24
- toErrorType: O
25
- } = H(), j = (e) => {
26
- u.current = e, g(s, e), c(t.FROM);
27
- }, A = (e) => {
28
- m.current = e, g(d, e), c(t.TO);
29
- }, M = (e, n) => {
30
- B(e, !0), c(n);
31
- }, R = (e, n, l) => !!(e === q.OVERLAPPING && l);
32
- return /* @__PURE__ */ x("div", {
33
- className: i.container,
34
- "data-testid": `${o}-field`,
35
- children: [!L && /* @__PURE__ */ r(D, {
36
- as: "span",
37
- color: "textOnLightSecondary",
38
- variant: "bodyDefaultBold",
39
- children: o
40
- }), /* @__PURE__ */ x("div", {
41
- className: i.rangeInputsContainer,
42
- children: [/* @__PURE__ */ r(E, {
43
- name: `${s}`,
44
- validate: () => T(u.current, m.current, t.FROM),
45
- children: ({
46
- field: e,
47
- meta: n
48
- }) => /* @__PURE__ */ r("div", {
49
- className: i.inputContainer,
50
- children: /* @__PURE__ */ r(C, {
51
- ...$,
52
- ...e,
53
- "data-target-id": `TextInput-${a}_from`,
54
- disabled: p,
55
- error: R(v, O, h !== t.FROM) ? void 0 : n.error,
56
- label: f.formatMessage(V.fieldFromLabel, {
57
- label: o
58
- }),
59
- onBlur: () => M(s, t.FROM),
60
- onChange: (l) => j(l.currentTarget.value),
61
- placeholder: "0"
62
- })
63
- })
64
- }), /* @__PURE__ */ r(E, {
65
- name: `${d}`,
66
- validate: () => T(u.current, m.current, t.TO),
67
- children: ({
68
- field: e,
69
- meta: n
70
- }) => /* @__PURE__ */ r("div", {
71
- className: i.inputContainer,
72
- children: /* @__PURE__ */ r(C, {
73
- ...$,
74
- ...e,
75
- "data-target-id": `TextInput-${a}_to`,
76
- disabled: p,
77
- error: R(O, v, h !== t.TO) ? void 0 : n.error,
78
- label: f.formatMessage(V.fieldToLabel, {
79
- label: o
80
- }),
81
- onBlur: () => M(d, t.TO),
82
- onChange: (l) => A(l.currentTarget.value),
83
- placeholder: "0"
84
- })
85
- })
86
- })]
87
- })]
88
- });
89
- }, ee = ({
90
- isAdvancedFilterEnabled: o,
91
- ...a
92
- }) => o ? /* @__PURE__ */ r(G, {
93
- ...a
94
- }) : /* @__PURE__ */ r(w, {
95
- ...a
96
- });
97
- export {
98
- ee as MetadataFloatField,
99
- ee as default
100
- };
1
+ import { n as e } from "../../../../../../chunks/types.js";
2
+ import t from "../../../../messages.js";
3
+ import { fieldDefaultProps as n } from "../constants.js";
4
+ import { n as r, t as i } from "../../../../../../chunks/metadata-float-field-advanced.js";
5
+ import { n as a, r as o } from "../../../../../../chunks/use-float-validation.js";
6
+ import { Text as s, TextInput as c } from "@box/blueprint-web";
7
+ import { Field as l, getIn as u, useFormikContext as d } from "formik";
8
+ import { useRef as f, useState as p } from "react";
9
+ import { useIntl as m } from "react-intl";
10
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
11
+ var _ = ({ label: i, fieldNamePrefix: _, disableForm: v, hasAccordion: y }) => {
12
+ let b = m(), [x, S] = p(e.FROM), { values: C, setFieldValue: w, setFieldTouched: T } = d(), E = `${_}.value.range.gt`, D = `${_}.value.range.lt`, O = u(C, E), k = u(C, D), A = f(O), j = f(k), { validateFloats: M, fromErrorType: N, toErrorType: P } = a(), F = (t) => {
13
+ A.current = t, w(E, t), S(e.FROM);
14
+ }, I = (t) => {
15
+ j.current = t, w(D, t), S(e.TO);
16
+ }, L = (e, t) => {
17
+ T(e, !0), S(t);
18
+ }, R = (e, t, n) => !!(e === o.OVERLAPPING && n);
19
+ return /* @__PURE__ */ g("div", {
20
+ className: r.container,
21
+ "data-testid": `${i}-field`,
22
+ children: [!y && /* @__PURE__ */ h(s, {
23
+ as: "span",
24
+ color: "textOnLightSecondary",
25
+ variant: "bodyDefaultBold",
26
+ children: i
27
+ }), /* @__PURE__ */ g("div", {
28
+ className: r.rangeInputsContainer,
29
+ children: [/* @__PURE__ */ h(l, {
30
+ name: `${E}`,
31
+ validate: () => M(A.current, j.current, e.FROM),
32
+ children: ({ field: a, meta: o }) => /* @__PURE__ */ h("div", {
33
+ className: r.inputContainer,
34
+ children: /* @__PURE__ */ h(c, {
35
+ ...n,
36
+ ...a,
37
+ "data-target-id": `TextInput-${_}_from`,
38
+ disabled: v,
39
+ error: R(N, P, x !== e.FROM) ? void 0 : o.error,
40
+ label: b.formatMessage(t.fieldFromLabel, { label: i }),
41
+ onBlur: () => L(E, e.FROM),
42
+ onChange: (e) => F(e.currentTarget.value),
43
+ placeholder: "0"
44
+ })
45
+ })
46
+ }), /* @__PURE__ */ h(l, {
47
+ name: `${D}`,
48
+ validate: () => M(A.current, j.current, e.TO),
49
+ children: ({ field: a, meta: o }) => /* @__PURE__ */ h("div", {
50
+ className: r.inputContainer,
51
+ children: /* @__PURE__ */ h(c, {
52
+ ...n,
53
+ ...a,
54
+ "data-target-id": `TextInput-${_}_to`,
55
+ disabled: v,
56
+ error: R(P, N, x !== e.TO) ? void 0 : o.error,
57
+ label: b.formatMessage(t.fieldToLabel, { label: i }),
58
+ onBlur: () => L(D, e.TO),
59
+ onChange: (e) => I(e.currentTarget.value),
60
+ placeholder: "0"
61
+ })
62
+ })
63
+ })]
64
+ })]
65
+ });
66
+ }, v = ({ isAdvancedFilterEnabled: e, ...t }) => h(e ? i : _, { ...t });
67
+ export { v as MetadataFloatField, v as default };
@@ -1,9 +1,2 @@
1
- import "react";
2
- import "react-intl";
3
- import "../../../../messages.js";
4
- import "../../../../../../chunks/types.js";
5
- import { i as p, u as l } from "../../../../../../chunks/use-float-validation.js";
6
- export {
7
- p as isFloatOrBlank,
8
- l as useFloatValidation
9
- };
1
+ import { n as e, t } from "../../../../../../chunks/use-float-validation.js";
2
+ export { t as isFloatOrBlank, e as useFloatValidation };
@@ -1,60 +1,47 @@
1
- let t = /* @__PURE__ */ (function(r) {
2
- return r.EQUALS = "equals", r.IS_NOT = "isNot", r.GREATER_THAN = "greaterThanOrEqual", r.LESS_THAN = "lessThanOrEqual", r.BETWEEN = "between", r.IS_BLANK = "isBlank", r.IS_NOT_BLANK = "isNotBlank", r;
3
- })({});
4
- const _ = (r, N) => r && N?.some(([e]) => e === r) ? r : t.EQUALS;
5
- let E = /* @__PURE__ */ (function(r) {
6
- return r.BOTH = "both", r.SINGLE = "single", r.NONE = "none", r;
7
- })({});
8
- const L = (r) => r === t.IS_BLANK || r === t.IS_NOT_BLANK ? E.NONE : r === t.BETWEEN ? E.BOTH : [t.EQUALS, t.IS_NOT, t.GREATER_THAN, t.LESS_THAN].includes(r) ? E.SINGLE : E.NONE, S = (r) => r.lt && !r.gt ? {
9
- from: r.lt,
10
- to: ""
1
+ var e = /* @__PURE__ */ function(e) {
2
+ return e.EQUALS = "equals", e.IS_NOT = "isNot", e.GREATER_THAN = "greaterThanOrEqual", e.LESS_THAN = "lessThanOrEqual", e.BETWEEN = "between", e.IS_BLANK = "isBlank", e.IS_NOT_BLANK = "isNotBlank", e;
3
+ }({}), t = (t, n) => t && n?.some(([e]) => e === t) ? t : e.EQUALS, n = /* @__PURE__ */ function(e) {
4
+ return e.BOTH = "both", e.SINGLE = "single", e.NONE = "none", e;
5
+ }({}), r = (t) => t === e.IS_BLANK || t === e.IS_NOT_BLANK ? n.NONE : t === e.BETWEEN ? n.BOTH : [
6
+ e.EQUALS,
7
+ e.IS_NOT,
8
+ e.GREATER_THAN,
9
+ e.LESS_THAN
10
+ ].includes(t) ? n.SINGLE : n.NONE, i = (e) => e.lt && !e.gt ? {
11
+ from: e.lt,
12
+ to: ""
11
13
  } : {
12
- from: r.gt || "",
13
- to: r.lt || ""
14
- }, T = (r) => r.advancedFilterOption === t.LESS_THAN ? {
15
- from: r.value?.range?.lt || "",
16
- to: ""
14
+ from: e.gt || "",
15
+ to: e.lt || ""
16
+ }, a = (t) => t.advancedFilterOption === e.LESS_THAN ? {
17
+ from: t.value?.range?.lt || "",
18
+ to: ""
17
19
  } : {
18
- from: r.value?.range?.gt || "",
19
- to: r.value?.range?.lt || ""
20
- }, g = (r) => typeof r == "object" && r !== null, f = (r) => g(r) && "advancedFilterOption" in r && "value" in r && typeof r.advancedFilterOption == "string", B = (r, N) => {
21
- if (!g(r))
22
- return {
23
- from: "",
24
- to: ""
25
- };
26
- const n = r;
27
- return n.range && !N ? S(n.range) : N && f(r) ? T(r) : n.range ? S(n.range) : {
28
- from: "",
29
- to: ""
30
- };
31
- }, I = (r, N, n, e) => {
32
- if (e) {
33
- if (n === t.IS_BLANK || n === t.IS_NOT_BLANK)
34
- return {
35
- value: {
36
- range: {}
37
- },
38
- advancedFilterOption: n
39
- };
40
- const s = {};
41
- return r && (n === t.LESS_THAN ? s.lt = r : s.gt = r), N && n === t.BETWEEN && (s.lt = N), {
42
- value: {
43
- range: s
44
- },
45
- advancedFilterOption: n
46
- };
47
- }
48
- const u = {};
49
- return r && (u.gt = r), N && (u.lt = N), {
50
- range: u
51
- };
52
- };
53
- export {
54
- t as FloatAdvancedFilterOption,
55
- E as FloatInputDisplayState,
56
- I as createFieldValue,
57
- _ as getInitialAdvancedFilterValue,
58
- L as getInputDisplayState,
59
- B as getInputValues
20
+ from: t.value?.range?.gt || "",
21
+ to: t.value?.range?.lt || ""
22
+ }, o = (e) => typeof e == "object" && !!e, s = (e) => o(e) && "advancedFilterOption" in e && "value" in e && typeof e.advancedFilterOption == "string", c = (e, t) => {
23
+ if (!o(e)) return {
24
+ from: "",
25
+ to: ""
26
+ };
27
+ let n = e;
28
+ return n.range && !t ? i(n.range) : t && s(e) ? a(e) : n.range ? i(n.range) : {
29
+ from: "",
30
+ to: ""
31
+ };
32
+ }, l = (t, n, r, i) => {
33
+ if (i) {
34
+ if (r === e.IS_BLANK || r === e.IS_NOT_BLANK) return {
35
+ value: { range: {} },
36
+ advancedFilterOption: r
37
+ };
38
+ let i = {};
39
+ return t && (r === e.LESS_THAN ? i.lt = t : i.gt = t), n && r === e.BETWEEN && (i.lt = n), {
40
+ value: { range: i },
41
+ advancedFilterOption: r
42
+ };
43
+ }
44
+ let a = {};
45
+ return t && (a.gt = t), n && (a.lt = n), { range: a };
60
46
  };
47
+ export { e as FloatAdvancedFilterOption, n as FloatInputDisplayState, l as createFieldValue, t as getInitialAdvancedFilterValue, r as getInputDisplayState, c as getInputValues };
@@ -1,92 +1,72 @@
1
- import { TooltipProvider as P, Combobox as U } from "@box/blueprint-web";
2
- import { useFormikContext as Y, getIn as q, Field as G } from "formik";
3
- import { useMemo as J, useState as m, useRef as A, useCallback as s } from "react";
4
- import { useIntl as Q } from "react-intl";
5
- import W from "../../../../messages.js";
6
- import { F as p } from "../../../../../../chunks/types.js";
7
- import { fieldDefaultProps as X } from "../constants.js";
8
- import { getInitialAdvancedFilterValue as Z, createFieldValue as x, getInputValue as E } from "./utils.js";
9
- import { jsx as l, jsxs as ee, Fragment as te } from "react/jsx-runtime";
10
- import { A as ne } from "../../../../../../chunks/index.js";
11
- const L = (n) => n === p.IS_BLANK || n === p.IS_NOT_BLANK, de = ({
12
- label: n,
13
- fieldNamePrefix: a,
14
- disableForm: d,
15
- onAdvancedFilterOptionChange: u,
16
- fieldAdvancedFilterOptions: f,
17
- filterOptionsMap: h,
18
- portalElement: g,
19
- hasAccordion: w,
20
- isModified: y,
21
- hasExperimentalVirtualization: T
22
- }) => {
23
- const {
24
- setFieldValue: C,
25
- values: V
26
- } = Y(), F = Q(), o = `${a}.value.enum`, k = J(() => q(V, `${a}.options`, []).map((e) => e?.key).filter((e) => typeof e == "string"), [V, a]), [c, M] = m(Z(f, h) || p.MATCH_ANY), [_, b] = m(!1), [B, O] = m(!1), K = (e, t) => typeof t != "string" ? !1 : t.toLowerCase().includes(e.toLowerCase()), S = A([]), i = A(null), v = s((e, t, r) => {
27
- const I = e;
28
- M(I), u?.(o, I);
29
- const D = L(e) ? [] : t, H = x(D, e, !0);
30
- r.setFieldValue(o, H);
31
- }, [o, u]), R = s((e) => {
32
- i.current && v(e, S.current, i.current);
33
- }, [v]), $ = s((e) => {
34
- const t = x(e, c, !0);
35
- C(o, t);
36
- }, [c, o, C]), j = s((e) => {
37
- b(e), e && O(!1);
38
- }, []), N = s((e) => {
39
- O(e), e && b(!1);
40
- }, []), z = s((e) => !e || e.length === 0 ? F.formatMessage(W.multiselectPlaceholder) : "", [F]);
41
- return /* @__PURE__ */ l("div", {
42
- "data-testid": `${n}-field`,
43
- children: /* @__PURE__ */ l(G, {
44
- name: o,
45
- children: ({
46
- field: e,
47
- form: t
48
- }) => {
49
- const r = E(e.value, !0);
50
- return S.current = r, i.current = t, /* @__PURE__ */ ee(te, {
51
- children: [/* @__PURE__ */ l(ne, {
52
- disableForm: d,
53
- fieldAdvancedFilterOptions: f,
54
- fieldNamePrefix: a,
55
- filterOptionsMap: h,
56
- isModified: y,
57
- label: n,
58
- onAdvancedFilterOptionChange: u,
59
- onOpenChange: N,
60
- onValueChange: R,
61
- open: B,
62
- portalElement: g,
63
- showLabel: !w,
64
- value: c
65
- }), !L(c) && /* @__PURE__ */ l(P, {
66
- children: /* @__PURE__ */ l(U, {
67
- ...X,
68
- as: "input",
69
- disabled: d,
70
- experimentalVirtualization: T,
71
- filterFn: K,
72
- hideLabel: !0,
73
- label: n,
74
- multiselect: !0,
75
- name: e.name,
76
- onOpenChange: j,
77
- onValueChange: $,
78
- open: _,
79
- options: k,
80
- placeholder: z(r),
81
- portalElement: g,
82
- value: r
83
- })
84
- })]
85
- });
86
- }
87
- })
88
- });
89
- };
90
- export {
91
- de as MetadataMultiSelectFieldAdvanced
1
+ import { t as e } from "../../../../../../chunks/types.js";
2
+ import t from "../../../../messages.js";
3
+ import { t as n } from "../../../../../../chunks/advanced-filter-select.js";
4
+ import { fieldDefaultProps as r } from "../constants.js";
5
+ import { createFieldValue as i, getInitialAdvancedFilterValue as a, getInputValue as o } from "./utils.js";
6
+ import { Combobox as s, TooltipProvider as c } from "@box/blueprint-web";
7
+ import { Field as l, getIn as u, useFormikContext as d } from "formik";
8
+ import { useCallback as f, useMemo as p, useRef as m, useState as h } from "react";
9
+ import { useIntl as g } from "react-intl";
10
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
11
+ var b = (t) => t === e.IS_BLANK || t === e.IS_NOT_BLANK, x = ({ label: x, fieldNamePrefix: S, disableForm: C, onAdvancedFilterOptionChange: w, fieldAdvancedFilterOptions: T, filterOptionsMap: E, portalElement: D, hasAccordion: O, isModified: k, hasExperimentalVirtualization: A }) => {
12
+ let { setFieldValue: j, values: M } = d(), N = g(), P = `${S}.value.enum`, F = p(() => u(M, `${S}.options`, []).map((e) => e?.key).filter((e) => typeof e == "string"), [M, S]), [I, L] = h(a(T, E) || e.MATCH_ANY), [R, z] = h(!1), [B, V] = h(!1), H = (e, t) => typeof t == "string" ? t.toLowerCase().includes(e.toLowerCase()) : !1, U = m([]), W = m(null), G = f((e, t, n) => {
13
+ let r = e;
14
+ L(r), w?.(P, r);
15
+ let a = i(b(e) ? [] : t, e, !0);
16
+ n.setFieldValue(P, a);
17
+ }, [P, w]), K = f((e) => {
18
+ W.current && G(e, U.current, W.current);
19
+ }, [G]), q = f((e) => {
20
+ j(P, i(e, I, !0));
21
+ }, [
22
+ I,
23
+ P,
24
+ j
25
+ ]), J = f((e) => {
26
+ z(e), e && V(!1);
27
+ }, []), Y = f((e) => {
28
+ V(e), e && z(!1);
29
+ }, []), X = f((e) => !e || e.length === 0 ? N.formatMessage(t.multiselectPlaceholder) : "", [N]);
30
+ return /* @__PURE__ */ v("div", {
31
+ "data-testid": `${x}-field`,
32
+ children: /* @__PURE__ */ v(l, {
33
+ name: P,
34
+ children: ({ field: e, form: t }) => {
35
+ let i = o(e.value, !0);
36
+ return U.current = i, W.current = t, /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v(n, {
37
+ disableForm: C,
38
+ fieldAdvancedFilterOptions: T,
39
+ fieldNamePrefix: S,
40
+ filterOptionsMap: E,
41
+ isModified: k,
42
+ label: x,
43
+ onAdvancedFilterOptionChange: w,
44
+ onOpenChange: Y,
45
+ onValueChange: K,
46
+ open: B,
47
+ portalElement: D,
48
+ showLabel: !O,
49
+ value: I
50
+ }), !b(I) && /* @__PURE__ */ v(c, { children: /* @__PURE__ */ v(s, {
51
+ ...r,
52
+ as: "input",
53
+ disabled: C,
54
+ experimentalVirtualization: A,
55
+ filterFn: H,
56
+ hideLabel: !0,
57
+ label: x,
58
+ multiselect: !0,
59
+ name: e.name,
60
+ onOpenChange: J,
61
+ onValueChange: q,
62
+ open: R,
63
+ options: F,
64
+ placeholder: X(i),
65
+ portalElement: D,
66
+ value: i
67
+ }) })] });
68
+ }
69
+ })
70
+ });
92
71
  };
72
+ export { x as MetadataMultiSelectFieldAdvanced };
@@ -1,65 +1,35 @@
1
- import { TooltipProvider as F, Combobox as M } from "@box/blueprint-web";
2
- import { useFormikContext as f, getIn as b, Field as V } from "formik";
3
- import { useMemo as $, useCallback as n } from "react";
4
- import { useIntl as x } from "react-intl";
5
- import L from "../../../../messages.js";
6
- import { fieldDefaultProps as S } from "../constants.js";
7
- import { MetadataMultiSelectFieldAdvanced as k } from "./metadata-multi-select-field-advanced.js";
8
- import { jsx as o } from "react/jsx-runtime";
9
- const w = ({
10
- disableForm: a,
11
- fieldNamePrefix: t,
12
- label: r,
13
- portalElement: d,
14
- hasAccordion: u,
15
- hasExperimentalVirtualization: c
16
- }) => {
17
- const {
18
- setFieldValue: i,
19
- values: s
20
- } = f(), m = x(), l = `${t}.value.enum`, p = $(() => b(s, `${t}.options`, []).map(({
21
- key: e
22
- }) => e), [s, t]), h = n((e, C) => C.toLowerCase().includes(e.toLowerCase()), []), g = n((e) => i(l, e), [i, l]), v = n((e) => (
23
- // Empty array must be substituted if there is no value found
24
- // Otherwise no placeholder appears despite no selection
25
- (e || [])?.length === 0 ? m.formatMessage(L.multiselectPlaceholder) : ""
26
- ), [m]);
27
- return /* @__PURE__ */ o("div", {
28
- "data-testid": `${r}-field`,
29
- children: /* @__PURE__ */ o(V, {
30
- name: l,
31
- children: ({
32
- field: e
33
- }) => /* @__PURE__ */ o(F, {
34
- children: /* @__PURE__ */ o(M, {
35
- ...S,
36
- as: "input",
37
- "data-target-id": `Combobox-${t}`,
38
- disabled: a,
39
- filterFn: h,
40
- hideLabel: u,
41
- label: r,
42
- multiselect: !0,
43
- experimentalVirtualization: c,
44
- name: e.name,
45
- onValueChange: g,
46
- options: p,
47
- placeholder: v(e.value),
48
- portalElement: d,
49
- value: e.value
50
- })
51
- })
52
- })
53
- });
54
- }, q = ({
55
- isAdvancedFilterEnabled: a,
56
- ...t
57
- }) => a ? /* @__PURE__ */ o(k, {
58
- ...t
59
- }) : /* @__PURE__ */ o(w, {
60
- ...t
61
- });
62
- export {
63
- q as MetadataMultiSelectField,
64
- q as default
65
- };
1
+ import e from "../../../../messages.js";
2
+ import { fieldDefaultProps as t } from "../constants.js";
3
+ import { MetadataMultiSelectFieldAdvanced as n } from "./metadata-multi-select-field-advanced.js";
4
+ import { Combobox as r, TooltipProvider as i } from "@box/blueprint-web";
5
+ import { Field as a, getIn as o, useFormikContext as s } from "formik";
6
+ import { useCallback as c, useMemo as l } from "react";
7
+ import { useIntl as u } from "react-intl";
8
+ import { jsx as d } from "react/jsx-runtime";
9
+ var f = ({ disableForm: n, fieldNamePrefix: f, label: p, portalElement: m, hasAccordion: h, hasExperimentalVirtualization: g }) => {
10
+ let { setFieldValue: _, values: v } = s(), y = u(), b = `${f}.value.enum`, x = l(() => o(v, `${f}.options`, []).map(({ key: e }) => e), [v, f]), S = c((e, t) => t.toLowerCase().includes(e.toLowerCase()), []), C = c((e) => _(b, e), [_, b]), w = c((t) => (t || [])?.length === 0 ? y.formatMessage(e.multiselectPlaceholder) : "", [y]);
11
+ return /* @__PURE__ */ d("div", {
12
+ "data-testid": `${p}-field`,
13
+ children: /* @__PURE__ */ d(a, {
14
+ name: b,
15
+ children: ({ field: e }) => /* @__PURE__ */ d(i, { children: /* @__PURE__ */ d(r, {
16
+ ...t,
17
+ as: "input",
18
+ "data-target-id": `Combobox-${f}`,
19
+ disabled: n,
20
+ filterFn: S,
21
+ hideLabel: h,
22
+ label: p,
23
+ multiselect: !0,
24
+ experimentalVirtualization: g,
25
+ name: e.name,
26
+ onValueChange: C,
27
+ options: x,
28
+ placeholder: w(e.value),
29
+ portalElement: m,
30
+ value: e.value
31
+ }) })
32
+ })
33
+ });
34
+ }, p = ({ isAdvancedFilterEnabled: e, ...t }) => d(e ? n : f, { ...t });
35
+ export { p as MetadataMultiSelectField, p as default };
@@ -1,20 +1,12 @@
1
- let A = /* @__PURE__ */ (function(r) {
2
- return r.MATCH_ANY = "matchAny", r.MATCH_ALL = "matchAll", r.IS_BLANK = "isBlank", r.IS_NOT_BLANK = "isNotBlank", r;
3
- })({});
4
- const _ = (r, t) => r && t?.some(([s]) => s === r) ? r : A.MATCH_ANY, o = (r, t) => {
5
- if (Array.isArray(r))
6
- return r.filter((s) => s !== "");
7
- if (t && typeof r == "object" && r !== null)
8
- return (r.value || []).filter((u) => u !== "");
9
- const n = r || [];
10
- return Array.isArray(n) ? n.filter((s) => s !== "") : [];
11
- }, I = (r, t, n) => n ? {
12
- value: N(t) ? [] : r,
13
- advancedFilterOption: t
14
- } : r, N = (r) => r === A.IS_BLANK || r === A.IS_NOT_BLANK;
15
- export {
16
- A as MultiSelectAdvancedFilterOption,
17
- I as createFieldValue,
18
- _ as getInitialAdvancedFilterValue,
19
- o as getInputValue
20
- };
1
+ var e = /* @__PURE__ */ function(e) {
2
+ return e.MATCH_ANY = "matchAny", e.MATCH_ALL = "matchAll", e.IS_BLANK = "isBlank", e.IS_NOT_BLANK = "isNotBlank", e;
3
+ }({}), t = (t, n) => t && n?.some(([e]) => e === t) ? t : e.MATCH_ANY, n = (e, t) => {
4
+ if (Array.isArray(e)) return e.filter((e) => e !== "");
5
+ if (t && typeof e == "object" && e) return (e.value || []).filter((e) => e !== "");
6
+ let n = e || [];
7
+ return Array.isArray(n) ? n.filter((e) => e !== "") : [];
8
+ }, r = (e, t, n) => n ? {
9
+ value: i(t) ? [] : e,
10
+ advancedFilterOption: t
11
+ } : e, i = (t) => t === e.IS_BLANK || t === e.IS_NOT_BLANK;
12
+ export { e as MultiSelectAdvancedFilterOption, r as createFieldValue, t as getInitialAdvancedFilterValue, n as getInputValue };