@box/metadata-template-editor 2.2.20 → 2.2.21

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,131 +1,137 @@
1
1
  import { t as e } from "./field-selector.js";
2
2
  import { t } from "./field-type-dropdown.js";
3
- import { FieldTypeTiles as ee } from "../esm/lib/components/field-type-tiles/field-type-tiles.js";
4
- import { createDefaultFieldValues as n } from "../esm/lib/components/metadata-field-configurator/utils.js";
5
- import { FieldExtensionsContext as r } from "../esm/lib/components/metadata-field-configurator/context/field-extensions-context.js";
6
- import { t as i } from "./metadata-field-list.js";
7
- import a from "../esm/lib/messages.js";
8
- import { Button as o, EmptyState as s, Link as c, Text as l, TextInput as u } from "@box/blueprint-web";
9
- import { FormattedMessage as d, useIntl as f } from "react-intl";
10
- import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
11
- import { useEffect as g, useMemo as _, useRef as v } from "react";
12
- import te from "clsx";
13
- import { Form as y, useFormikContext as b } from "formik";
14
- import { NoTemplates as x } from "@box/blueprint-web-assets/illustrations/Medium";
15
- import '../styles/metadata-template-editor-form.css';var S = {
3
+ import { FieldTypeTiles as n } from "../esm/lib/components/field-type-tiles/field-type-tiles.js";
4
+ import { createDefaultFieldValues as r } from "../esm/lib/components/metadata-field-configurator/utils.js";
5
+ import { FieldExtensionsContext as i } from "../esm/lib/components/metadata-field-configurator/context/field-extensions-context.js";
6
+ import { t as a } from "./metadata-field-list.js";
7
+ import o from "../esm/lib/messages.js";
8
+ import { Button as s, EmptyState as c, Link as l, Text as u, TextInput as d } from "@box/blueprint-web";
9
+ import { FormattedMessage as f, useIntl as p } from "react-intl";
10
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
11
+ import { useEffect as _, useMemo as v, useRef as y } from "react";
12
+ import b from "clsx";
13
+ import { Form as x, useFormikContext as ee } from "formik";
14
+ import { NoTemplates as S } from "@box/blueprint-web-assets/illustrations/Medium";
15
+ import '../styles/metadata-template-editor-form.css';var C = {
16
16
  form: "_form_1f0e7_1",
17
17
  loading: "_loading_1f0e7_10",
18
18
  fields: "_fields_1f0e7_17",
19
19
  emptyFields: "_emptyFields_1f0e7_23",
20
20
  actions: "_actions_1f0e7_28",
21
21
  fieldsHeader: "_fieldsHeader_1f0e7_35"
22
- }, C = "bodyDefaultBold", w = "h2", T = "https://developer.box.com/guides/metadata/fields/", E = ({ formId: E, onCancel: D, taxonomyOptions: O, fetchTaxonomies: k, hideActions: A, isEditMode: j, readOnly: M = !1, onDirtyStateChange: N, onValidationChange: P, fieldExtensions: F }) => {
23
- let I = f(), { errors: L, values: R, setFieldValue: z, isSubmitting: B, isValid: V, touched: H, handleChange: U, handleBlur: W, submitCount: G, dirty: K } = b(), q = v(null), J = _(() => {
24
- if (!Array.isArray(L.fields)) return null;
25
- let e = L.fields.findIndex(Boolean);
22
+ }, w = "bodyDefaultBold", T = "h2", E = "https://developer.box.com/guides/metadata/fields/", D = ({ formId: D, onCancel: O, taxonomyOptions: k, fetchTaxonomies: A, hideActions: te, isEditMode: ne, readOnly: j = !1, onDirtyStateChange: M, onValidationChange: N, fieldExtensions: P }) => {
23
+ let F = p(), { errors: I, values: L, setFieldValue: R, setFieldTouched: z, isSubmitting: B, isValid: V, handleChange: H, submitCount: U, dirty: W, touched: G } = ee(), K = y(null), q = y(!1), J = () => {
24
+ q.current = !0;
25
+ }, Y = () => {
26
+ q.current && z("displayName", !0);
27
+ }, X = v(() => {
28
+ if (!Array.isArray(I.fields)) return null;
29
+ let e = I.fields.findIndex(Boolean);
26
30
  return e >= 0 ? e : null;
27
- }, [L.fields]), Y = (e) => {
28
- let t = n(e.type);
29
- z("fields", [...R.fields, t]);
30
- }, X = (e) => {
31
- z("fields", e);
31
+ }, [I.fields]), Z = (e) => {
32
+ let t = r(e.type);
33
+ R("fields", [...L.fields, t]);
34
+ }, re = (e) => {
35
+ R("fields", e);
32
36
  };
33
- g(() => {
34
- N?.(K);
35
- }, [K, N]), g(() => {
36
- P?.(V);
37
- }, [V, P]);
38
- let Z = B || j && !K, Q;
39
- Q = M && R.fields.length === 0 ? /* @__PURE__ */ m(s, {
37
+ _(() => {
38
+ M?.(W);
39
+ }, [W, M]), _(() => {
40
+ N?.(V);
41
+ }, [V, N]);
42
+ let ie = B || ne && !W, Q;
43
+ Q = j && L.fields.length === 0 ? /* @__PURE__ */ h(c, {
40
44
  size: "large",
41
- illustration: x,
42
- body: /* @__PURE__ */ m(l, {
45
+ illustration: S,
46
+ body: /* @__PURE__ */ h(u, {
43
47
  as: "p",
44
- children: I.formatMessage(a.noFields)
48
+ children: F.formatMessage(o.noFields)
45
49
  })
46
- }) : M ? /* @__PURE__ */ m(i, {
47
- ref: q,
48
- fields: R.fields,
49
- taxonomyOptions: O,
50
- fetchTaxonomies: k,
50
+ }) : j ? /* @__PURE__ */ h(a, {
51
+ ref: K,
52
+ fields: L.fields,
53
+ taxonomyOptions: k,
54
+ fetchTaxonomies: A,
51
55
  readOnly: !0
52
- }) : R.fields.length === 0 ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(ee, { onFieldAdd: Y }), /* @__PURE__ */ m(c, {
56
+ }) : L.fields.length === 0 ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(n, { onFieldAdd: Z }), /* @__PURE__ */ h(l, {
53
57
  isExternal: !0,
54
- className: S.fieldsLearnMoreLink,
55
- href: T,
58
+ className: C.fieldsLearnMoreLink,
59
+ href: E,
56
60
  target: "_blank",
57
- children: /* @__PURE__ */ m(d, { ...a.fieldsLearnMore })
58
- })] }) : /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(i, {
59
- ref: q,
60
- fields: R.fields,
61
- taxonomyOptions: O,
62
- fetchTaxonomies: k,
63
- onChangeFields: X,
64
- firstInvalidFieldIndex: J,
65
- submitAttemptCount: G
66
- }), /* @__PURE__ */ m(t, { onFieldAdd: Y })] });
67
- let $ = /* @__PURE__ */ h(y, {
61
+ children: /* @__PURE__ */ h(f, { ...o.fieldsLearnMore })
62
+ })] }) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(a, {
63
+ ref: K,
64
+ fields: L.fields,
65
+ taxonomyOptions: k,
66
+ fetchTaxonomies: A,
67
+ onChangeFields: re,
68
+ firstInvalidFieldIndex: X,
69
+ submitAttemptCount: U
70
+ }), /* @__PURE__ */ h(t, { onFieldAdd: Z })] });
71
+ let $ = /* @__PURE__ */ g(x, {
68
72
  noValidate: !0,
69
- id: E,
70
- className: S.form,
73
+ id: D,
74
+ className: C.form,
71
75
  children: [
72
- /* @__PURE__ */ m("div", {
73
- className: S.templateInfo,
74
- children: /* @__PURE__ */ m(u, {
76
+ /* @__PURE__ */ h("div", {
77
+ className: C.templateInfo,
78
+ children: /* @__PURE__ */ h(d, {
75
79
  name: "displayName",
76
- label: I.formatMessage(a.templateName),
77
- placeholder: I.formatMessage(a.templateNameDescription),
78
- value: R.displayName,
79
- error: !M && H.displayName && L.displayName ? L.displayName : void 0,
80
+ label: F.formatMessage(o.templateName),
81
+ placeholder: F.formatMessage(o.templateNameDescription),
82
+ value: L.displayName,
83
+ error: !j && G.displayName && I.displayName ? I.displayName : void 0,
80
84
  onChange: (e) => {
81
- U(e);
85
+ H(e);
82
86
  },
83
- onBlur: W,
84
- readOnly: M
87
+ onPointerDown: J,
88
+ onKeyDown: J,
89
+ onBlur: Y,
90
+ readOnly: j
85
91
  })
86
92
  }),
87
- /* @__PURE__ */ h("div", {
88
- className: S.fieldsHeader,
89
- children: [/* @__PURE__ */ m(l, {
90
- as: w,
91
- variant: C,
92
- children: /* @__PURE__ */ m(d, { ...!M && R.fields.length === 0 ? a.fieldsAddFirst : a.fields })
93
- }), R.fields.length > 0 && /* @__PURE__ */ m(e, {
94
- fields: R.fields,
95
- onSelect: (e) => q.current?.scrollToAndExpand(e)
93
+ /* @__PURE__ */ g("div", {
94
+ className: C.fieldsHeader,
95
+ children: [/* @__PURE__ */ h(u, {
96
+ as: T,
97
+ variant: w,
98
+ children: /* @__PURE__ */ h(f, { ...!j && L.fields.length === 0 ? o.fieldsAddFirst : o.fields })
99
+ }), L.fields.length > 0 && /* @__PURE__ */ h(e, {
100
+ fields: L.fields,
101
+ onSelect: (e) => K.current?.scrollToAndExpand(e)
96
102
  })]
97
103
  }),
98
- /* @__PURE__ */ m("div", {
99
- className: te(S.fields, { [S.emptyFields]: R.fields.length === 0 && M }),
104
+ /* @__PURE__ */ h("div", {
105
+ className: b(C.fields, { [C.emptyFields]: L.fields.length === 0 && j }),
100
106
  children: Q
101
107
  }),
102
- !A && /* @__PURE__ */ m("div", {
103
- className: S.actions,
104
- children: M ? D && /* @__PURE__ */ m(o, {
108
+ !te && /* @__PURE__ */ h("div", {
109
+ className: C.actions,
110
+ children: j ? O && /* @__PURE__ */ h(s, {
105
111
  variant: "primary",
106
112
  type: "button",
107
- onClick: D,
108
- children: I.formatMessage(a.close)
109
- }) : /* @__PURE__ */ h(p, { children: [D && /* @__PURE__ */ m(o, {
113
+ onClick: O,
114
+ children: F.formatMessage(o.close)
115
+ }) : /* @__PURE__ */ g(m, { children: [O && /* @__PURE__ */ h(s, {
110
116
  variant: "secondary",
111
117
  type: "button",
112
- onClick: D,
118
+ onClick: O,
113
119
  loading: B,
114
120
  disabled: B,
115
- loadingAriaLabel: I.formatMessage(a.submitting),
116
- children: I.formatMessage(a.cancel)
117
- }), /* @__PURE__ */ m(o, {
121
+ loadingAriaLabel: F.formatMessage(o.submitting),
122
+ children: F.formatMessage(o.cancel)
123
+ }), /* @__PURE__ */ h(s, {
118
124
  variant: "primary",
119
125
  type: "submit",
120
- disabled: Z,
121
- children: I.formatMessage(a.save)
126
+ disabled: ie,
127
+ children: F.formatMessage(o.save)
122
128
  })] })
123
129
  })
124
130
  ]
125
131
  });
126
- return F === void 0 ? $ : /* @__PURE__ */ m(r.Provider, {
127
- value: F,
132
+ return P === void 0 ? $ : /* @__PURE__ */ h(i.Provider, {
133
+ value: P,
128
134
  children: $
129
135
  });
130
136
  };
131
- export { E as t };
137
+ export { D as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-template-editor",
3
- "version": "2.2.20",
3
+ "version": "2.2.21",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^16.12.0",