@box/metadata-filter 1.34.0 → 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,25 @@
1
1
  import { Select as l, SELECT_EMPTY_VALUE as n } from "@box/blueprint-web";
2
- import { useFormikContext as g, getIn as x, Field as E } from "formik";
3
- import { useIntl as F, FormattedMessage as M } from "react-intl";
2
+ import { useFormikContext as x, getIn as E, Field as F } from "formik";
3
+ import { useIntl as M, FormattedMessage as V } from "react-intl";
4
4
  import m from "../../../../messages.js";
5
- import { jsx as t, jsxs as V } from "react/jsx-runtime";
6
- const O = ({
5
+ import { jsx as t, jsxs as C } from "react/jsx-runtime";
6
+ const P = ({
7
7
  disableForm: u,
8
8
  fieldNamePrefix: o,
9
9
  label: d,
10
10
  portalElement: h,
11
- hasAccordion: p
11
+ hasAccordion: p,
12
+ defaultValue: v
12
13
  }) => {
13
14
  const {
14
15
  setFieldValue: c,
15
- values: v
16
- } = g(), f = F(), s = `${o}.value.enum[0]`, r = x(v, `${o}.options`, []).map(({
16
+ values: f
17
+ } = x(), g = M(), s = `${o}.value.enum[0]`, r = E(f, `${o}.options`, []).map(({
17
18
  key: a
18
- }) => a), i = f.formatMessage(m.selectValuePlaceholder);
19
+ }) => a), i = v || g.formatMessage(m.selectValuePlaceholder);
19
20
  return /* @__PURE__ */ t("div", {
20
21
  "data-testid": `${d}-field`,
21
- children: /* @__PURE__ */ t(E, {
22
+ children: /* @__PURE__ */ t(F, {
22
23
  name: s,
23
24
  children: ({
24
25
  field: a
@@ -32,12 +33,12 @@ const O = ({
32
33
  placeholder: i,
33
34
  ...a,
34
35
  value: a.value === n ? "" : a.value,
35
- children: /* @__PURE__ */ V(l.Content, {
36
+ children: /* @__PURE__ */ C(l.Content, {
36
37
  container: h,
37
38
  children: [/* @__PURE__ */ t(l.Option, {
38
39
  text: i,
39
40
  value: n,
40
- children: /* @__PURE__ */ t(M, {
41
+ children: /* @__PURE__ */ t(V, {
41
42
  ...m.selectValuePlaceholder
42
43
  })
43
44
  }), r == null ? void 0 : r.map((e) => /* @__PURE__ */ t(l.Option, {
@@ -51,6 +52,6 @@ const O = ({
51
52
  });
52
53
  };
53
54
  export {
54
- O as MetadataEnumField,
55
- O as default
55
+ P as MetadataEnumField,
56
+ P as default
56
57
  };
@@ -1,13 +1,13 @@
1
- import { TextInput as j } from "@box/blueprint-web";
2
- import { Field as $ } from "formik";
3
- import { useState as k, useCallback as n } from "react";
4
- import { useIntl as y } from "react-intl";
1
+ import { TextInput as $ } from "@box/blueprint-web";
2
+ import { Field as k } from "formik";
3
+ import { useState as y, useCallback as n } from "react";
4
+ import { useIntl as D } from "react-intl";
5
5
  import x from "../../../../messages.js";
6
- import { fieldDefaultProps as D } from "../constants.js";
7
- import { getInitialAdvancedFilterValue as H, createFieldValue as w, getInputValue as N, shouldHideTextInput as P } from "./utils.js";
8
- import { jsx as p, jsxs as q, Fragment as z } from "react/jsx-runtime";
9
- import { A as B } from "../../../../../../chunks/index.js";
10
- const G = ({
6
+ import { fieldDefaultProps as H } from "../constants.js";
7
+ import { getInitialAdvancedFilterValue as N, createFieldValue as w, getInputValue as P, shouldHideTextInput as q } from "./utils.js";
8
+ import { jsx as p, jsxs as z, Fragment as B } from "react/jsx-runtime";
9
+ import { A as G } from "../../../../../../chunks/index.js";
10
+ const J = ({
11
11
  label: s,
12
12
  fieldNamePrefix: f,
13
13
  disableForm: g,
@@ -16,28 +16,29 @@ const G = ({
16
16
  fieldAdvancedFilterOptions: h,
17
17
  filterOptionsMap: I,
18
18
  hasAccordion: c,
19
- isModified: S
19
+ isModified: S,
20
+ placeholder: L
20
21
  }) => {
21
- const i = y(), r = `${f}.value.enum[0]`, [l, L] = k(H(h, I)), M = n((e, m, u) => {
22
- L(e), o == null || o(r, e);
22
+ const i = D(), r = `${f}.value.enum[0]`, [l, M] = y(N(h, I)), T = n((e, m, u) => {
23
+ M(e), o == null || o(r, e);
23
24
  const a = w(m, e, t);
24
25
  u.setFieldValue(r, a);
25
- }, [r, t, o]), T = n((e, m) => {
26
+ }, [r, t, o]), j = n((e, m) => {
26
27
  const u = e.target.value, a = w(u, l, t);
27
28
  m.setFieldValue(r, a);
28
29
  }, [l, t, r]);
29
30
  return /* @__PURE__ */ p("div", {
30
31
  "data-testid": `${s}-field`,
31
- children: /* @__PURE__ */ p($, {
32
+ children: /* @__PURE__ */ p(k, {
32
33
  name: r,
33
34
  children: ({
34
35
  field: e,
35
36
  meta: m,
36
37
  form: u
37
38
  }) => {
38
- const a = N(e.value, t);
39
- return /* @__PURE__ */ q(z, {
40
- children: [t && /* @__PURE__ */ p(B, {
39
+ const a = P(e.value, t);
40
+ return /* @__PURE__ */ z(B, {
41
+ children: [t && /* @__PURE__ */ p(G, {
41
42
  disableForm: g,
42
43
  fieldAdvancedFilterOptions: h,
43
44
  fieldNamePrefix: f,
@@ -45,11 +46,11 @@ const G = ({
45
46
  isModified: S,
46
47
  label: s,
47
48
  onAdvancedFilterOptionChange: o,
48
- onValueChange: (V) => M(V, a, u),
49
+ onValueChange: (V) => T(V, a, u),
49
50
  showLabel: t && !c,
50
51
  value: l
51
- }), !P(t, l) && /* @__PURE__ */ p(j, {
52
- ...D,
52
+ }), !q(t, l) && /* @__PURE__ */ p($, {
53
+ ...H,
53
54
  ...e,
54
55
  "aria-label": i.formatMessage(x.enterValueAriaLabel, {
55
56
  label: s
@@ -58,8 +59,8 @@ const G = ({
58
59
  error: m.error,
59
60
  hideLabel: t || c,
60
61
  label: s,
61
- onChange: (V) => T(V, u),
62
- placeholder: i.formatMessage(x.setValuePlaceholder),
62
+ onChange: (V) => j(V, u),
63
+ placeholder: L || i.formatMessage(x.setValuePlaceholder),
63
64
  value: a
64
65
  })]
65
66
  });
@@ -67,8 +68,8 @@ const G = ({
67
68
  })
68
69
  });
69
70
  };
70
- G.displayName = "MetadataStringField";
71
+ J.displayName = "MetadataStringField";
71
72
  export {
72
- G as MetadataStringField,
73
- G as default
73
+ J as MetadataStringField,
74
+ J as default
74
75
  };
@@ -1,3 +1,3 @@
1
1
  import { MetadataFieldProps } from '../../types';
2
- export declare const MetadataEnumField: ({ disableForm, fieldNamePrefix, label, portalElement, hasAccordion, }: MetadataFieldProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MetadataEnumField: ({ disableForm, fieldNamePrefix, label, portalElement, hasAccordion, defaultValue, }: MetadataFieldProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default MetadataEnumField;
@@ -1,6 +1,6 @@
1
1
  import { MetadataFieldProps } from '../../types';
2
2
  export declare const MetadataStringField: {
3
- ({ label, fieldNamePrefix, disableForm, isAdvancedFilterEnabled, onAdvancedFilterOptionChange, fieldAdvancedFilterOptions, filterOptionsMap, hasAccordion, isModified, }: Omit<MetadataFieldProps, "locale" | "taxonomyOptionsFetcher">): import("react/jsx-runtime").JSX.Element;
3
+ ({ label, fieldNamePrefix, disableForm, isAdvancedFilterEnabled, onAdvancedFilterOptionChange, fieldAdvancedFilterOptions, filterOptionsMap, hasAccordion, isModified, placeholder, }: Omit<MetadataFieldProps, "locale" | "taxonomyOptionsFetcher">): import("react/jsx-runtime").JSX.Element;
4
4
  displayName: string;
5
5
  };
6
6
  export default MetadataStringField;
@@ -50,6 +50,8 @@ export type MetadataFieldProps = {
50
50
  customDateFilterOptions?: Array<CustomDateFilterOptionsProps>;
51
51
  hasAccordion?: boolean;
52
52
  isModified?: boolean;
53
+ placeholder?: string;
54
+ defaultValue?: string;
53
55
  };
54
56
  export type FieldType = Extract<MetadataTemplateFieldType, 'string' | 'float' | 'enum' | 'multiSelect' | 'date'>;
55
57
  export type PartialRangeValue = Partial<RangeValue>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-filter",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.16.0",
@@ -11,7 +11,7 @@
11
11
  "react-intl": "6.4.2"
12
12
  },
13
13
  "devDependencies": {
14
- "@box/blueprint-web": "^12.78.6",
14
+ "@box/blueprint-web": "^12.79.0",
15
15
  "@box/blueprint-web-assets": "^4.71.0",
16
16
  "@box/storybook-utils": "^0.14.7",
17
17
  "react": "^18.3.0",