@box/metadata-filter 1.14.3

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 (142) hide show
  1. package/LICENSE +379 -0
  2. package/README.md +48 -0
  3. package/dist/chunks/index.js +73 -0
  4. package/dist/chunks/metadata-date-field.module.js +13 -0
  5. package/dist/chunks/metadata-float-field.module.js +11 -0
  6. package/dist/chunks/types.js +6 -0
  7. package/dist/chunks/use-date-validation.js +40 -0
  8. package/dist/chunks/use-float-validation.js +26 -0
  9. package/dist/esm/index.js +23 -0
  10. package/dist/esm/lib/components/metadata-filter-fields/components/constants.js +6 -0
  11. package/dist/esm/lib/components/metadata-filter-fields/components/index.js +13 -0
  12. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/constants.js +5 -0
  13. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/date-conversion-utils.js +62 -0
  14. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-advanced.js +173 -0
  15. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-relative.js +189 -0
  16. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field.js +123 -0
  17. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-internationalization.js +14 -0
  18. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-validation.js +12 -0
  19. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/utils.js +5 -0
  20. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-enum-field/metadata-enum-field.js +54 -0
  21. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/handlers.js +15 -0
  22. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field-advanced.js +93 -0
  23. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field.js +90 -0
  24. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/use-float-validation.js +9 -0
  25. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/utils.js +63 -0
  26. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field-advanced.js +75 -0
  27. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +50 -0
  28. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-multi-select-field/utils.js +20 -0
  29. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-string-field/metadata-string-field.js +71 -0
  30. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-string-field/utils.js +15 -0
  31. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.js +67 -0
  32. package/dist/esm/lib/components/metadata-filter-fields/components/shared/advanced-filter-select.js +11 -0
  33. package/dist/esm/lib/components/metadata-filter-fields/components/shared/index.js +4 -0
  34. package/dist/esm/lib/components/metadata-filter-fields/filter-field-types.js +53 -0
  35. package/dist/esm/lib/components/metadata-filter-fields/metadata-filter-fields.js +62 -0
  36. package/dist/esm/lib/components/metadata-template-selector/index.js +1 -0
  37. package/dist/esm/lib/components/metadata-template-selector/metadata-template-selector.js +45 -0
  38. package/dist/esm/lib/defaults.js +39 -0
  39. package/dist/esm/lib/mappers.js +24 -0
  40. package/dist/esm/lib/messages.js +194 -0
  41. package/dist/esm/lib/metadata-filter.js +71 -0
  42. package/dist/i18n/bn-IN.js +49 -0
  43. package/dist/i18n/bn-IN.properties +94 -0
  44. package/dist/i18n/da-DK.js +49 -0
  45. package/dist/i18n/da-DK.properties +94 -0
  46. package/dist/i18n/de-DE.js +49 -0
  47. package/dist/i18n/de-DE.properties +94 -0
  48. package/dist/i18n/en-AU.js +49 -0
  49. package/dist/i18n/en-AU.properties +94 -0
  50. package/dist/i18n/en-CA.js +49 -0
  51. package/dist/i18n/en-CA.properties +94 -0
  52. package/dist/i18n/en-GB.js +49 -0
  53. package/dist/i18n/en-GB.properties +94 -0
  54. package/dist/i18n/en-US.js +49 -0
  55. package/dist/i18n/en-US.properties +94 -0
  56. package/dist/i18n/en-x-pseudo.js +49 -0
  57. package/dist/i18n/en-x-pseudo.properties +94 -0
  58. package/dist/i18n/es-419.js +49 -0
  59. package/dist/i18n/es-419.properties +94 -0
  60. package/dist/i18n/es-ES.js +49 -0
  61. package/dist/i18n/es-ES.properties +94 -0
  62. package/dist/i18n/fi-FI.js +49 -0
  63. package/dist/i18n/fi-FI.properties +94 -0
  64. package/dist/i18n/fr-CA.js +49 -0
  65. package/dist/i18n/fr-CA.properties +94 -0
  66. package/dist/i18n/fr-FR.js +49 -0
  67. package/dist/i18n/fr-FR.properties +94 -0
  68. package/dist/i18n/hi-IN.js +49 -0
  69. package/dist/i18n/hi-IN.properties +94 -0
  70. package/dist/i18n/it-IT.js +49 -0
  71. package/dist/i18n/it-IT.properties +94 -0
  72. package/dist/i18n/ja-JP.js +49 -0
  73. package/dist/i18n/ja-JP.properties +94 -0
  74. package/dist/i18n/json/src/lib/messages.json +1 -0
  75. package/dist/i18n/ko-KR.js +49 -0
  76. package/dist/i18n/ko-KR.properties +94 -0
  77. package/dist/i18n/nb-NO.js +49 -0
  78. package/dist/i18n/nb-NO.properties +94 -0
  79. package/dist/i18n/nl-NL.js +49 -0
  80. package/dist/i18n/nl-NL.properties +94 -0
  81. package/dist/i18n/pl-PL.js +49 -0
  82. package/dist/i18n/pl-PL.properties +94 -0
  83. package/dist/i18n/pt-BR.js +49 -0
  84. package/dist/i18n/pt-BR.properties +94 -0
  85. package/dist/i18n/ru-RU.js +49 -0
  86. package/dist/i18n/ru-RU.properties +94 -0
  87. package/dist/i18n/sv-SE.js +49 -0
  88. package/dist/i18n/sv-SE.properties +94 -0
  89. package/dist/i18n/tr-TR.js +49 -0
  90. package/dist/i18n/tr-TR.properties +94 -0
  91. package/dist/i18n/zh-CN.js +49 -0
  92. package/dist/i18n/zh-CN.properties +94 -0
  93. package/dist/i18n/zh-TW.js +49 -0
  94. package/dist/i18n/zh-TW.properties +94 -0
  95. package/dist/styles/index.css +1 -0
  96. package/dist/styles/metadata-date-field.css +1 -0
  97. package/dist/styles/metadata-filter.css +1 -0
  98. package/dist/styles/metadata-float-field.css +1 -0
  99. package/dist/types/index.d.ts +6 -0
  100. package/dist/types/lib/components/metadata-filter-fields/components/constants.d.ts +3 -0
  101. package/dist/types/lib/components/metadata-filter-fields/components/index.d.ts +5 -0
  102. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/constants.d.ts +1 -0
  103. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/date-conversion-utils.d.ts +13 -0
  104. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-advanced.d.ts +3 -0
  105. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-relative.d.ts +3 -0
  106. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field.d.ts +4 -0
  107. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/types.d.ts +9 -0
  108. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-internationalization.d.ts +6 -0
  109. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-validation.d.ts +9 -0
  110. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/utils.d.ts +2 -0
  111. package/dist/types/lib/components/metadata-filter-fields/components/metadata-enum-field/metadata-enum-field.d.ts +3 -0
  112. package/dist/types/lib/components/metadata-filter-fields/components/metadata-float-field/handlers.d.ts +4 -0
  113. package/dist/types/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field-advanced.d.ts +3 -0
  114. package/dist/types/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field.d.ts +3 -0
  115. package/dist/types/lib/components/metadata-filter-fields/components/metadata-float-field/types.d.ts +4 -0
  116. package/dist/types/lib/components/metadata-filter-fields/components/metadata-float-field/use-float-validation.d.ts +8 -0
  117. package/dist/types/lib/components/metadata-filter-fields/components/metadata-float-field/utils.d.ts +35 -0
  118. package/dist/types/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field-advanced.d.ts +2 -0
  119. package/dist/types/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field.d.ts +3 -0
  120. package/dist/types/lib/components/metadata-filter-fields/components/metadata-multi-select-field/utils.d.ts +13 -0
  121. package/dist/types/lib/components/metadata-filter-fields/components/metadata-string-field/metadata-string-field.d.ts +6 -0
  122. package/dist/types/lib/components/metadata-filter-fields/components/metadata-string-field/utils.d.ts +17 -0
  123. package/dist/types/lib/components/metadata-filter-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.d.ts +3 -0
  124. package/dist/types/lib/components/metadata-filter-fields/components/metadata-taxonomy-field/types.d.ts +6 -0
  125. package/dist/types/lib/components/metadata-filter-fields/components/shared/advanced-filter-select.d.ts +18 -0
  126. package/dist/types/lib/components/metadata-filter-fields/components/shared/index.d.ts +1 -0
  127. package/dist/types/lib/components/metadata-filter-fields/filter-field-types.d.ts +17 -0
  128. package/dist/types/lib/components/metadata-filter-fields/metadata-filter-fields.d.ts +3 -0
  129. package/dist/types/lib/components/metadata-filter-fields/types.d.ts +33 -0
  130. package/dist/types/lib/components/metadata-template-selector/index.d.ts +1 -0
  131. package/dist/types/lib/components/metadata-template-selector/metadata-template-selector.d.ts +3 -0
  132. package/dist/types/lib/components/metadata-template-selector/types.d.ts +6 -0
  133. package/dist/types/lib/defaults.d.ts +13 -0
  134. package/dist/types/lib/mappers.d.ts +16 -0
  135. package/dist/types/lib/messages.d.ts +238 -0
  136. package/dist/types/lib/metadata-filter.d.ts +2 -0
  137. package/dist/types/lib/test-utils/formik-wrapper.d.ts +9 -0
  138. package/dist/types/lib/test-utils/index.d.ts +3 -0
  139. package/dist/types/lib/test-utils/sample-data.d.ts +15 -0
  140. package/dist/types/lib/test-utils/test-utils.d.ts +3 -0
  141. package/dist/types/lib/types.d.ts +86 -0
  142. package/package.json +50 -0
@@ -0,0 +1,93 @@
1
+ import { TextInput as T } from "@box/blueprint-web";
2
+ import { useFormikContext as j, Field as k, getIn as B } from "formik";
3
+ import { useState as N, useCallback as F } from "react";
4
+ import { useIntl as $ } from "react-intl";
5
+ import d from "../../../../messages.js";
6
+ import { R as u } from "../../../../../../chunks/types.js";
7
+ import { fieldDefaultProps as S } from "../constants.js";
8
+ import { createAdvancedFilterOptionHandler as G, createInputChangeHandler as b } from "./handlers.js";
9
+ import { s as m } from "../../../../../../chunks/metadata-float-field.module.js";
10
+ import { u as Q } from "../../../../../../chunks/use-float-validation.js";
11
+ import { FloatAdvancedFilterOption as U, getInputValues as V, getInputDisplayState as q, FloatInputDisplayState as I } from "./utils.js";
12
+ import { jsx as o, jsxs as x, Fragment as z } from "react/jsx-runtime";
13
+ import { A as J } from "../../../../../../chunks/index.js";
14
+ const se = ({
15
+ label: c,
16
+ fieldNamePrefix: C,
17
+ disableForm: p,
18
+ onAdvancedFilterOptionChange: h,
19
+ fieldAdvancedFilterOptions: O,
20
+ filterOptionsMap: y
21
+ }) => {
22
+ const s = $(), a = `${C}.value.enum[0]`, {
23
+ values: A
24
+ } = j(), [f, L] = N(u.FROM), [l, M] = N(O || U.EQUALS), {
25
+ validateFloats: R
26
+ } = Q(), w = F((e, r, t, n) => G(a, h, M)(e, r, t, n), [a, h, M]), D = F((e, r, t) => b(a, l, L, u.FROM)(e, r, t), [a, l]), E = F((e, r, t) => b(a, l, L, u.TO)(e, r, t), [a, l]);
27
+ return /* @__PURE__ */ o("div", {
28
+ className: m.advancedFilterContainer,
29
+ "data-testid": `${c}-field`,
30
+ children: /* @__PURE__ */ o(k, {
31
+ name: a,
32
+ validate: () => {
33
+ const e = V(B(A, a), !0);
34
+ return R(e.from, e.to, f, !0);
35
+ },
36
+ children: ({
37
+ field: e,
38
+ meta: r,
39
+ form: t
40
+ }) => {
41
+ const n = V(e.value, !0), g = q(l), H = g !== I.NONE, P = g === I.SINGLE, v = g === I.BOTH;
42
+ return /* @__PURE__ */ x(z, {
43
+ children: [/* @__PURE__ */ o(J, {
44
+ disableForm: p,
45
+ fieldAdvancedFilterOptions: O,
46
+ fieldNamePrefix: C,
47
+ filterOptionsMap: y,
48
+ label: c,
49
+ onAdvancedFilterOptionChange: h,
50
+ onValueChange: (i) => w(i, n.from, n.to, t),
51
+ showLabel: !0,
52
+ value: l
53
+ }), H && /* @__PURE__ */ x("div", {
54
+ className: m.rangeInputsContainer,
55
+ children: [(P || v) && /* @__PURE__ */ o("div", {
56
+ className: m.inputContainer,
57
+ children: /* @__PURE__ */ o(T, {
58
+ ...S,
59
+ disabled: p,
60
+ error: f === u.FROM ? r.error : void 0,
61
+ hideLabel: !0,
62
+ label: s.formatMessage(d.fieldFromLabel, {
63
+ label: c
64
+ }),
65
+ onChange: (i) => D(i.currentTarget.value, n.to, t),
66
+ placeholder: v ? s.formatMessage(d.minValuePlaceholder) : s.formatMessage(d.enterNumberPlaceholder),
67
+ value: n.from
68
+ })
69
+ }), v && /* @__PURE__ */ o("div", {
70
+ className: m.inputContainer,
71
+ children: /* @__PURE__ */ o(T, {
72
+ ...S,
73
+ disabled: p,
74
+ error: f === u.TO ? r.error : void 0,
75
+ hideLabel: !0,
76
+ label: s.formatMessage(d.fieldToLabel, {
77
+ label: c
78
+ }),
79
+ onChange: (i) => E(i.currentTarget.value, n.from, t),
80
+ placeholder: s.formatMessage(d.maxValuePlaceholder),
81
+ value: n.to
82
+ })
83
+ })]
84
+ })]
85
+ });
86
+ }
87
+ })
88
+ });
89
+ };
90
+ export {
91
+ se as MetadataFloatFieldAdvanced,
92
+ se as default
93
+ };
@@ -0,0 +1,90 @@
1
+ import { Text as D, TextInput as y } from "@box/blueprint-web";
2
+ import { useFormikContext as P, getIn as M, Field as E } from "formik";
3
+ import { useState as S, useRef as V } from "react";
4
+ import { useIntl as k } from "react-intl";
5
+ import x from "../../../../messages.js";
6
+ import { R as r } from "../../../../../../chunks/types.js";
7
+ import { fieldDefaultProps as L } from "../constants.js";
8
+ import { s as i } from "../../../../../../chunks/metadata-float-field.module.js";
9
+ import { u as A, E as G } from "../../../../../../chunks/use-float-validation.js";
10
+ import { jsxs as N, jsx as t } from "react/jsx-runtime";
11
+ const Y = ({
12
+ label: n,
13
+ fieldNamePrefix: m,
14
+ disableForm: f
15
+ }) => {
16
+ const p = k(), [h, d] = S(r.FROM), {
17
+ values: g,
18
+ setFieldValue: F,
19
+ setFieldTouched: I
20
+ } = P(), l = `${m}.value.range.gt`, s = `${m}.value.range.lt`, $ = M(g, l), b = M(g, s), c = V($), u = V(b), {
21
+ validateFloats: T,
22
+ fromErrorType: O,
23
+ toErrorType: v
24
+ } = A(), B = (e) => {
25
+ c.current = e, F(l, e), d(r.FROM);
26
+ }, j = (e) => {
27
+ u.current = e, F(s, e), d(r.TO);
28
+ }, R = (e, o) => {
29
+ I(e, !0), d(o);
30
+ }, C = (e, o, a) => !!(e === G.OVERLAPPING && a);
31
+ return /* @__PURE__ */ N("div", {
32
+ className: i.container,
33
+ "data-testid": `${n}-field`,
34
+ children: [/* @__PURE__ */ t(D, {
35
+ as: "span",
36
+ color: "textOnLightSecondary",
37
+ variant: "bodyDefaultBold",
38
+ children: n
39
+ }), /* @__PURE__ */ N("div", {
40
+ className: i.rangeInputsContainer,
41
+ children: [/* @__PURE__ */ t(E, {
42
+ name: `${l}`,
43
+ validate: () => T(c.current, u.current, r.FROM),
44
+ children: ({
45
+ field: e,
46
+ meta: o
47
+ }) => /* @__PURE__ */ t("div", {
48
+ className: i.inputContainer,
49
+ children: /* @__PURE__ */ t(y, {
50
+ ...L,
51
+ ...e,
52
+ disabled: f,
53
+ error: C(O, v, h !== r.FROM) ? void 0 : o.error,
54
+ label: p.formatMessage(x.fieldFromLabel, {
55
+ label: n
56
+ }),
57
+ onBlur: () => R(l, r.FROM),
58
+ onChange: (a) => B(a.currentTarget.value),
59
+ placeholder: "0"
60
+ })
61
+ })
62
+ }), /* @__PURE__ */ t(E, {
63
+ name: `${s}`,
64
+ validate: () => T(c.current, u.current, r.TO),
65
+ children: ({
66
+ field: e,
67
+ meta: o
68
+ }) => /* @__PURE__ */ t("div", {
69
+ className: i.inputContainer,
70
+ children: /* @__PURE__ */ t(y, {
71
+ ...L,
72
+ ...e,
73
+ disabled: f,
74
+ error: C(v, O, h !== r.TO) ? void 0 : o.error,
75
+ label: p.formatMessage(x.fieldToLabel, {
76
+ label: n
77
+ }),
78
+ onBlur: () => R(s, r.TO),
79
+ onChange: (a) => j(a.currentTarget.value),
80
+ placeholder: "0"
81
+ })
82
+ })
83
+ })]
84
+ })]
85
+ });
86
+ };
87
+ export {
88
+ Y as MetadataFloatField,
89
+ Y as default
90
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,63 @@
1
+ let E = /* @__PURE__ */ function(r) {
2
+ return r.EQUALS = "equals", r.GREATER_THAN = "greaterThanOrEqual", r.LESS_THAN = "lessThanOrEqual", r.BETWEEN = "between", r.IS_BLANK = "isBlank", r.IS_NOT_BLANK = "isNotBlank", r;
3
+ }({});
4
+ const f = (r, t) => r && (t == null ? void 0 : t.some(([u]) => u === r)) ? r : E.EQUALS;
5
+ let s = /* @__PURE__ */ function(r) {
6
+ return r.BOTH = "both", r.SINGLE = "single", r.NONE = "none", r;
7
+ }({});
8
+ const A = (r) => r === E.IS_BLANK || r === E.IS_NOT_BLANK ? s.NONE : r === E.BETWEEN ? s.BOTH : [E.EQUALS, E.GREATER_THAN, E.LESS_THAN].includes(r) ? s.SINGLE : s.NONE, S = (r) => r.lt && !r.gt ? {
9
+ from: r.lt,
10
+ to: ""
11
+ } : {
12
+ from: r.gt || "",
13
+ to: r.lt || ""
14
+ }, L = (r) => {
15
+ var t, n, u, e, N, g;
16
+ return r.advancedFilterOption === E.LESS_THAN ? {
17
+ from: ((n = (t = r.value) == null ? void 0 : t.range) == null ? void 0 : n.lt) || "",
18
+ to: ""
19
+ } : {
20
+ from: ((e = (u = r.value) == null ? void 0 : u.range) == null ? void 0 : e.gt) || "",
21
+ to: ((g = (N = r.value) == null ? void 0 : N.range) == null ? void 0 : g.lt) || ""
22
+ };
23
+ }, T = (r) => typeof r == "object" && r !== null, _ = (r) => T(r) && "advancedFilterOption" in r && "value" in r && typeof r.advancedFilterOption == "string", B = (r, t) => {
24
+ if (!T(r))
25
+ return {
26
+ from: "",
27
+ to: ""
28
+ };
29
+ const n = r;
30
+ return n.range && !t ? S(n.range) : t && _(r) ? L(r) : n.range ? S(n.range) : {
31
+ from: "",
32
+ to: ""
33
+ };
34
+ }, I = (r, t, n, u) => {
35
+ if (u) {
36
+ if (n === E.IS_BLANK || n === E.IS_NOT_BLANK)
37
+ return {
38
+ value: {
39
+ range: {}
40
+ },
41
+ advancedFilterOption: n
42
+ };
43
+ const N = {};
44
+ return r && (n === E.LESS_THAN ? N.lt = r : N.gt = r), t && n === E.BETWEEN && (N.lt = t), {
45
+ value: {
46
+ range: N
47
+ },
48
+ advancedFilterOption: n
49
+ };
50
+ }
51
+ const e = {};
52
+ return r && (e.gt = r), t && (e.lt = t), {
53
+ range: e
54
+ };
55
+ };
56
+ export {
57
+ E as FloatAdvancedFilterOption,
58
+ s as FloatInputDisplayState,
59
+ I as createFieldValue,
60
+ f as getInitialAdvancedFilterValue,
61
+ A as getInputDisplayState,
62
+ B as getInputValues
63
+ };
@@ -0,0 +1,75 @@
1
+ import { TooltipProvider as S, Combobox as $ } from "@box/blueprint-web";
2
+ import { useFormikContext as j, getIn as C, Field as F } from "formik";
3
+ import { useState as M, useCallback as T } from "react";
4
+ import { useIntl as D } from "react-intl";
5
+ import P from "../../../../messages.js";
6
+ import { fieldDefaultProps as U } from "../constants.js";
7
+ import { getInitialAdvancedFilterValue as b, createFieldValue as h, getInputValue as q } from "./utils.js";
8
+ import { jsx as a, jsxs as v, Fragment as z } from "react/jsx-runtime";
9
+ import { A as G } from "../../../../../../chunks/index.js";
10
+ const d = (t) => t === "isBlank" || t === "isNotBlank", Z = ({
11
+ label: t,
12
+ fieldNamePrefix: n,
13
+ disableForm: f,
14
+ isAdvancedFilterEnabled: m,
15
+ onAdvancedFilterOptionChange: o,
16
+ fieldAdvancedFilterOptions: p,
17
+ filterOptionsMap: V,
18
+ portalElement: g
19
+ }) => {
20
+ const {
21
+ setFieldValue: k,
22
+ values: w
23
+ } = j(), I = D(), l = `${n}.value.enum`, L = C(w, `${n}.options`, []).map((e) => e == null ? void 0 : e.key).filter((e) => typeof e == "string"), [c, x] = M(b(p, V)), y = (e, s) => typeof s != "string" ? !1 : s.toLowerCase().includes(e.toLowerCase()), B = T((e, s, r) => {
24
+ x(e), o == null || o(l, e);
25
+ const u = d(e) ? [] : s, i = h(u, e, m);
26
+ r.setFieldValue(l, i);
27
+ }, [l, m, o]);
28
+ return /* @__PURE__ */ a("div", {
29
+ "data-testid": `${t}-field`,
30
+ children: /* @__PURE__ */ a(F, {
31
+ name: l,
32
+ children: ({
33
+ field: e,
34
+ form: s
35
+ }) => {
36
+ const r = q(e.value, m);
37
+ return /* @__PURE__ */ v(z, {
38
+ children: [/* @__PURE__ */ a(G, {
39
+ disableForm: f,
40
+ fieldAdvancedFilterOptions: p,
41
+ fieldNamePrefix: n,
42
+ filterOptionsMap: V,
43
+ label: t,
44
+ onAdvancedFilterOptionChange: o,
45
+ onValueChange: (u) => B(u, r, s),
46
+ showLabel: !0,
47
+ value: c
48
+ }), !d(c) && /* @__PURE__ */ a(S, {
49
+ children: /* @__PURE__ */ a($, {
50
+ ...U,
51
+ as: "input",
52
+ disabled: f,
53
+ filterFn: y,
54
+ hideLabel: !0,
55
+ label: t,
56
+ multiselect: !0,
57
+ name: e.name,
58
+ onValueChange: (u) => {
59
+ const i = h(u, c, m);
60
+ k(l, i);
61
+ },
62
+ options: L,
63
+ placeholder: !r || r.length === 0 ? I.formatMessage(P.multiselectPlaceholder) : "",
64
+ portalElement: g,
65
+ value: r
66
+ })
67
+ })]
68
+ });
69
+ }
70
+ })
71
+ });
72
+ };
73
+ export {
74
+ Z as MetadataMultiSelectFieldAdvanced
75
+ };
@@ -0,0 +1,50 @@
1
+ import { TooltipProvider as f, Combobox as h } from "@box/blueprint-web";
2
+ import { useFormikContext as v, getIn as F, Field as g } from "formik";
3
+ import { useIntl as C } from "react-intl";
4
+ import x from "../../../../messages.js";
5
+ import { fieldDefaultProps as M } from "../constants.js";
6
+ import { jsx as o } from "react/jsx-runtime";
7
+ const V = ({
8
+ disableForm: n,
9
+ fieldNamePrefix: l,
10
+ label: r,
11
+ portalElement: s
12
+ }) => {
13
+ const {
14
+ setFieldValue: i,
15
+ values: m
16
+ } = v(), u = C(), a = `${l}.value.enum`, d = F(m, `${l}.options`, []).map(({
17
+ key: e
18
+ }) => e), c = (e, t) => t.toLowerCase().includes(e.toLowerCase());
19
+ return /* @__PURE__ */ o("div", {
20
+ "data-testid": `${r}-field`,
21
+ children: /* @__PURE__ */ o(g, {
22
+ name: a,
23
+ children: ({
24
+ field: e
25
+ }) => {
26
+ var t;
27
+ return /* @__PURE__ */ o(f, {
28
+ children: /* @__PURE__ */ o(h, {
29
+ ...M,
30
+ as: "input",
31
+ disabled: n,
32
+ filterFn: c,
33
+ label: r,
34
+ multiselect: !0,
35
+ name: e.name,
36
+ onValueChange: (p) => i(a, p),
37
+ options: d,
38
+ placeholder: ((t = e.value) == null ? void 0 : t.length) === 0 ? u.formatMessage(x.multiselectPlaceholder) : "",
39
+ portalElement: s,
40
+ value: e.value
41
+ })
42
+ });
43
+ }
44
+ })
45
+ });
46
+ };
47
+ export {
48
+ V as MetadataMultiSelectField,
49
+ V as default
50
+ };
@@ -0,0 +1,20 @@
1
+ let t = /* @__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, A) => r && (A == null ? void 0 : A.some(([s]) => s === r)) ? r : t.MATCH_ANY, I = (r, A) => {
5
+ if (Array.isArray(r))
6
+ return r.filter((s) => s !== "");
7
+ if (A && 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
+ }, B = (r, A, n) => n ? {
12
+ value: N(A) ? [] : r,
13
+ advancedFilterOption: A
14
+ } : r, N = (r) => r === t.IS_BLANK || r === t.IS_NOT_BLANK;
15
+ export {
16
+ t as MultiSelectAdvancedFilterOption,
17
+ B as createFieldValue,
18
+ _ as getInitialAdvancedFilterValue,
19
+ I as getInputValue
20
+ };
@@ -0,0 +1,71 @@
1
+ import { TextInput as M } from "@box/blueprint-web";
2
+ import { Field as T } from "formik";
3
+ import { useState as j, useCallback as i } from "react";
4
+ import { useIntl as $ } from "react-intl";
5
+ import n from "../../../../messages.js";
6
+ import { fieldDefaultProps as k } from "../constants.js";
7
+ import { getInitialAdvancedFilterValue as y, createFieldValue as x, getInputValue as D, shouldHideTextInput as H } from "./utils.js";
8
+ import { jsx as p, jsxs as N, Fragment as P } from "react/jsx-runtime";
9
+ import { A as q } from "../../../../../../chunks/index.js";
10
+ const z = ({
11
+ label: m,
12
+ fieldNamePrefix: f,
13
+ disableForm: c,
14
+ isAdvancedFilterEnabled: t,
15
+ onAdvancedFilterOptionChange: o,
16
+ fieldAdvancedFilterOptions: h,
17
+ filterOptionsMap: g
18
+ }) => {
19
+ const I = $(), r = `${f}.value.enum[0]`, [l, w] = j(y(h, g)), S = i((e, s, a) => {
20
+ w(e), o == null || o(r, e);
21
+ const u = x(s, e, t);
22
+ a.setFieldValue(r, u);
23
+ }, [r, t, o]), L = i((e, s) => {
24
+ const a = e.target.value, u = x(a, l, t);
25
+ s.setFieldValue(r, u);
26
+ }, [l, t, r]);
27
+ return /* @__PURE__ */ p("div", {
28
+ "data-testid": `${m}-field`,
29
+ children: /* @__PURE__ */ p(T, {
30
+ name: r,
31
+ children: ({
32
+ field: e,
33
+ meta: s,
34
+ form: a
35
+ }) => {
36
+ const u = D(e.value, t);
37
+ return /* @__PURE__ */ N(P, {
38
+ children: [t && /* @__PURE__ */ p(q, {
39
+ disableForm: c,
40
+ fieldAdvancedFilterOptions: h,
41
+ fieldNamePrefix: f,
42
+ filterOptionsMap: g,
43
+ label: m,
44
+ onAdvancedFilterOptionChange: o,
45
+ onValueChange: (V) => S(V, u, a),
46
+ showLabel: t,
47
+ value: l
48
+ }), !H(t, l) && /* @__PURE__ */ p(M, {
49
+ ...k,
50
+ ...e,
51
+ "aria-label": I.formatMessage(n.enterValueAriaLabel, {
52
+ label: m
53
+ }),
54
+ disabled: c,
55
+ error: s.error,
56
+ hideLabel: t,
57
+ label: m,
58
+ onChange: (V) => L(V, a),
59
+ placeholder: I.formatMessage(n.setValuePlaceholder),
60
+ value: u
61
+ })]
62
+ });
63
+ }
64
+ })
65
+ });
66
+ };
67
+ z.displayName = "MetadataStringField";
68
+ export {
69
+ z as MetadataStringField,
70
+ z as default
71
+ };
@@ -0,0 +1,15 @@
1
+ let s = /* @__PURE__ */ function(t) {
2
+ return t.MATCH_EXACTLY = "matchExactly", t.STARTS_WITH = "startsWith", t.CONTAINS = "contains", t.IS_NOT = "isNot", t.IS_BLANK = "isBlank", t.IS_NOT_BLANK = "isNotBlank", t;
3
+ }({});
4
+ const _ = (t, u) => t && (u == null ? void 0 : u.some(([N]) => N === t)) ? t : s.MATCH_EXACTLY, I = (t) => t === s.IS_BLANK || t === s.IS_NOT_BLANK, r = (t, u) => u && typeof t == "object" && t !== null ? t.value || "" : t || "", n = (t, u, T) => T ? {
5
+ value: I(u) ? "" : t,
6
+ advancedFilterOption: u
7
+ } : t, c = (t, u) => t && I(u);
8
+ export {
9
+ s as AdvancedFilterOption,
10
+ n as createFieldValue,
11
+ _ as getInitialAdvancedFilterValue,
12
+ r as getInputValue,
13
+ I as isBlankOption,
14
+ c as shouldHideTextInput
15
+ };
@@ -0,0 +1,67 @@
1
+ import { ComboboxWithApiTreeView as T, ComboboxWithApiPagination as A } from "@box/combobox-with-api";
2
+ import { useFormikContext as I, getIn as P, Field as W } from "formik";
3
+ import { useCallback as $ } from "react";
4
+ import { useIntl as b } from "react-intl";
5
+ import j from "../../../../messages.js";
6
+ import { jsx as e } from "react/jsx-runtime";
7
+ const B = ({
8
+ className: m,
9
+ disableForm: u,
10
+ fieldNamePrefix: l,
11
+ label: n,
12
+ portalElement: d,
13
+ taxonomyOptionsFetcher: s,
14
+ isMultilevelTaxonomyFieldEnabled: C
15
+ }) => {
16
+ const {
17
+ setFieldValue: c,
18
+ values: p
19
+ } = I(), {
20
+ metadata: {
21
+ templateKey: h,
22
+ scope: v
23
+ }
24
+ } = p, k = b(), a = `${l}.value`, y = P(p, l), {
25
+ key: g,
26
+ optionsRules: {
27
+ multiSelect: i,
28
+ selectableLevels: t
29
+ },
30
+ levels: F
31
+ } = y, M = C && (t == null ? void 0 : t.some((o) => o > 1)), f = $((o) => s(v, h, g, t == null ? void 0 : t[0], o), [g, v, t, s, h]), x = (o) => i || !(o != null && o.length) ? k.formatMessage(j.taxonomyPlaceholder) : void 0;
32
+ return /* @__PURE__ */ e("div", {
33
+ "data-testid": `${n}-field`,
34
+ children: /* @__PURE__ */ e(W, {
35
+ name: a,
36
+ children: ({
37
+ field: o
38
+ }) => M ? /* @__PURE__ */ e(T, {
39
+ className: m,
40
+ defaultFetcher: f,
41
+ disabled: u,
42
+ label: n,
43
+ levels: F,
44
+ multiselect: i,
45
+ onValueChange: (r) => c(a, r),
46
+ placeholder: x(o.value),
47
+ portalElement: d,
48
+ selectableLevels: t,
49
+ value: o.value
50
+ }) : /* @__PURE__ */ e(A, {
51
+ className: m,
52
+ defaultFetcher: f,
53
+ disabled: u,
54
+ label: n,
55
+ multiselect: i,
56
+ onValueChange: (r) => c(a, r),
57
+ placeholder: x(o.value),
58
+ portalElement: d,
59
+ value: o.value
60
+ })
61
+ })
62
+ });
63
+ };
64
+ export {
65
+ B as MetadataTaxonomyField,
66
+ B as default
67
+ };
@@ -0,0 +1,11 @@
1
+ import "@box/blueprint-web";
2
+ import "formik";
3
+ import "react";
4
+ import "react-intl";
5
+ import "../../../../messages.js";
6
+ import { A as d, A as l } from "../../../../../../chunks/index.js";
7
+ import "react/jsx-runtime";
8
+ export {
9
+ d as AdvancedFilterSelect,
10
+ l as default
11
+ };
@@ -0,0 +1,4 @@
1
+ import { A as t } from "../../../../../../chunks/index.js";
2
+ export {
3
+ t as AdvancedFilterSelect
4
+ };
@@ -0,0 +1,53 @@
1
+ import { MetadataDateField as i } from "./components/metadata-date-field/metadata-date-field.js";
2
+ import { MetadataDateFieldAdvanced as m } from "./components/metadata-date-field/metadata-date-field-advanced.js";
3
+ import { MetadataEnumField as r } from "./components/metadata-enum-field/metadata-enum-field.js";
4
+ import { MetadataFloatField as l } from "./components/metadata-float-field/metadata-float-field.js";
5
+ import { MetadataFloatFieldAdvanced as n } from "./components/metadata-float-field/metadata-float-field-advanced.js";
6
+ import { MetadataMultiSelectField as F } from "./components/metadata-multi-select-field/metadata-multi-select-field.js";
7
+ import { MetadataMultiSelectFieldAdvanced as e } from "./components/metadata-multi-select-field/metadata-multi-select-field-advanced.js";
8
+ import { MetadataStringField as o } from "./components/metadata-string-field/metadata-string-field.js";
9
+ import { MetadataTaxonomyField as d } from "./components/metadata-taxonomy-field/metadata-taxonomy-field.js";
10
+ import { jsx as a } from "react/jsx-runtime";
11
+ const g = {
12
+ date: (t) => /* @__PURE__ */ a(i, {
13
+ ...t
14
+ }),
15
+ enum: (t) => /* @__PURE__ */ a(r, {
16
+ ...t
17
+ }),
18
+ float: (t) => /* @__PURE__ */ a(l, {
19
+ ...t
20
+ }),
21
+ multiSelect: (t) => /* @__PURE__ */ a(F, {
22
+ ...t
23
+ }),
24
+ string: (t) => /* @__PURE__ */ a(o, {
25
+ ...t
26
+ }),
27
+ taxonomy: (t) => /* @__PURE__ */ a(d, {
28
+ ...t
29
+ })
30
+ }, A = {
31
+ date: (t) => /* @__PURE__ */ a(m, {
32
+ ...t
33
+ }),
34
+ enum: (t) => /* @__PURE__ */ a(e, {
35
+ ...t
36
+ }),
37
+ float: (t) => /* @__PURE__ */ a(n, {
38
+ ...t
39
+ }),
40
+ multiSelect: (t) => /* @__PURE__ */ a(e, {
41
+ ...t
42
+ }),
43
+ string: (t) => /* @__PURE__ */ a(o, {
44
+ ...t
45
+ }),
46
+ taxonomy: (t) => /* @__PURE__ */ a(d, {
47
+ ...t
48
+ })
49
+ };
50
+ export {
51
+ A as advancedFilterFieldTypes,
52
+ g as filterFieldTypes
53
+ };