@box/metadata-editor 0.51.1 → 0.52.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.
- package/chunks/metadata-editor-field-wrapper.js +18 -16
- package/esm/index.js +16 -16
- package/esm/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js +191 -0
- package/esm/lib/components/combobox-with-api-pagination/index.js +4 -0
- package/esm/lib/components/combobox-with-api-pagination/utils/use-controllable-state.js +40 -0
- package/esm/lib/components/interactive-text/interactive-text.js +16 -10
- package/esm/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.js +57 -50
- package/esm/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.js +39 -30
- package/esm/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.js +43 -34
- package/esm/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +39 -30
- package/esm/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.js +37 -28
- package/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/single-level-taxonomy-field.js +8 -0
- package/esm/lib/components/metadata-editor-fields/components/update-mode-field-wrapper/update-mode-field-wrapper.js +8 -8
- package/esm/lib/components/metadata-instance-list/subcomponents/metadata-instance-entry/metadata-instance-entry.js +19 -21
- package/package.json +3 -3
- package/styles/interactive-text.css +1 -0
- package/styles/metadata-instance-entry.css +1 -1
- package/types/index.d.ts +1 -1
- package/types/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.d.ts +2 -0
- package/types/lib/components/combobox-with-api-pagination/index.d.ts +2 -0
- package/types/lib/components/combobox-with-api-pagination/types.d.ts +35 -0
- package/types/lib/components/combobox-with-api-pagination/utils/use-controllable-state.d.ts +8 -0
- package/types/lib/components/interactive-text/interactive-text.d.ts +2 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/types.d.ts +21 -0
- package/types/lib/components/metadata-editor-fields/types.d.ts +1 -0
- package/types/lib/test-utils/sample-data.d.ts +1 -1
- package/esm/lib/components/metadata-taxonomy-field/combobox-with-api-pagination.js +0 -188
- package/esm/lib/components/metadata-taxonomy-field/single-level-taxonomy-field.js +0 -19
- package/types/lib/components/metadata-taxonomy-field/combobox-with-api-pagination.d.ts +0 -15
- package/types/lib/components/metadata-taxonomy-field/types.d.ts +0 -41
- /package/esm/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/messages.js +0 -0
- /package/esm/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/request.js +0 -0
- /package/esm/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/use-async-list.js +0 -0
- /package/esm/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/utils/use-intersection-observer.js +0 -0
- /package/esm/lib/components/{metadata-taxonomy-field → metadata-editor-fields/components/metadata-taxonomy-field}/index.js +0 -0
- /package/i18n/json/src/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/messages.json +0 -0
- /package/types/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/messages.d.ts +0 -0
- /package/types/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/request.d.ts +0 -0
- /package/types/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/use-async-list.d.ts +0 -0
- /package/types/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/utils/use-intersection-observer.d.ts +0 -0
- /package/types/lib/components/{metadata-taxonomy-field → metadata-editor-fields/components/metadata-taxonomy-field}/index.d.ts +0 -0
- /package/types/lib/components/{metadata-taxonomy-field → metadata-editor-fields/components/metadata-taxonomy-field}/single-level-taxonomy-field.d.ts +0 -0
@@ -13,48 +13,50 @@ const W = "_noAttributesText_vykxc_1", M = "_fieldWrapper_vykxc_5", N = "_hasSug
|
|
13
13
|
hasSuggestion: N,
|
14
14
|
error: T
|
15
15
|
}, E = ({
|
16
|
-
disableForm:
|
17
|
-
portalElement:
|
16
|
+
disableForm: n,
|
17
|
+
portalElement: a,
|
18
18
|
field: e,
|
19
19
|
index: p
|
20
20
|
}) => {
|
21
21
|
const {
|
22
22
|
setFieldValue: d
|
23
|
-
} = x(), [
|
24
|
-
if (!
|
23
|
+
} = x(), [l, i] = h(!0), r = k[e.type], g = r && !e.hidden, m = !_(e.updateMode), s = `metadata.fields[${p}]`;
|
24
|
+
if (!g)
|
25
25
|
return null;
|
26
26
|
if (m)
|
27
27
|
return /* @__PURE__ */ o(v, {
|
28
28
|
fieldNamePrefix: s,
|
29
29
|
fieldType: e.type,
|
30
|
-
children: /* @__PURE__ */ o(
|
31
|
-
|
30
|
+
children: /* @__PURE__ */ o(r, {
|
31
|
+
description: e.description,
|
32
|
+
disableForm: n,
|
32
33
|
fieldNamePrefix: s,
|
33
34
|
label: e.displayName,
|
34
|
-
portalElement:
|
35
|
+
portalElement: a
|
35
36
|
})
|
36
37
|
}, e.key);
|
37
38
|
const {
|
38
39
|
aiSuggestion: t,
|
39
40
|
value: f
|
40
|
-
} = e,
|
41
|
+
} = e, c = t && l;
|
41
42
|
return /* @__PURE__ */ F("div", {
|
42
43
|
className: u.fieldWrapper,
|
43
|
-
children: [/* @__PURE__ */ o(
|
44
|
-
className: S(
|
45
|
-
|
44
|
+
children: [/* @__PURE__ */ o(r, {
|
45
|
+
className: S(c && u.hasSuggestion),
|
46
|
+
description: e.description,
|
47
|
+
disableForm: n,
|
46
48
|
fieldNamePrefix: `metadata.fields[${p}]`,
|
47
49
|
label: e.displayName,
|
48
|
-
portalElement:
|
49
|
-
}),
|
50
|
+
portalElement: a
|
51
|
+
}), c && /* @__PURE__ */ o(A, {
|
50
52
|
aiSuggestion: t,
|
51
53
|
onAiSuggestionAppend: () => {
|
52
54
|
const y = e.type === "multiSelect" ? [f, t].flat() : t;
|
53
|
-
d(`${s}.value`, y),
|
55
|
+
d(`${s}.value`, y), i(!1);
|
54
56
|
},
|
55
|
-
onAiSuggestionIgnore: () =>
|
57
|
+
onAiSuggestionIgnore: () => i(!1),
|
56
58
|
onAiSuggestionReplace: () => {
|
57
|
-
d(`${s}.value`, t),
|
59
|
+
d(`${s}.value`, t), i(!1);
|
58
60
|
}
|
59
61
|
})]
|
60
62
|
}, e.key);
|
package/esm/index.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import { AddMetadataTemplateDropdown as o } from "./lib/components/add-metadata-template-dropdown/add-metadata-template-dropdown.js";
|
2
2
|
import { FilterDropdownMenu as r } from "./lib/components/filter-dropdown-menu/index.js";
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import {
|
3
|
+
import { SingleLevelTaxonomyField as m } from "./lib/components/metadata-editor-fields/components/metadata-taxonomy-field/single-level-taxonomy-field.js";
|
4
|
+
import { MetadataEmptyState as f } from "./lib/components/metadata-empty-state/metadata-empty-state.js";
|
5
|
+
import { DeleteConfirmationModal as l } from "./lib/components/metadata-instance-editor/subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
|
6
|
+
import { MetadataInstanceFormHeader as i } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
|
7
|
+
import { CustomInstanceNewField as s } from "./lib/components/metadata-instance-editor/subcomponents/custom-instance-new-field/custom-instance-new-field.js";
|
8
|
+
import { MetadataInstanceForm as I } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js";
|
9
|
+
import { MetadataInstanceList as C } from "./lib/components/metadata-instance-list/metadata-instance-list.js";
|
10
|
+
import { MetadataInstanceHeader as A } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance-header/metadata-instance-header.js";
|
11
11
|
import { UnsavedChangesModal as w } from "./lib/components/unsaved-changes-modal/unsaved-changes-modal.js";
|
12
12
|
import { defaultInitialValues as U, defaultMetadataValueMap as g } from "./lib/defaults.js";
|
13
13
|
import { MetadataEditor as E } from "./lib/metadata-editor.js";
|
@@ -17,16 +17,16 @@ export {
|
|
17
17
|
o as AddMetadataTemplateDropdown,
|
18
18
|
T as AutofillContext,
|
19
19
|
V as AutofillContextProvider,
|
20
|
-
|
21
|
-
|
20
|
+
s as CustomInstanceNewField,
|
21
|
+
l as DeleteConfirmationModal,
|
22
22
|
r as FilterDropdownMenu,
|
23
23
|
E as MetadataEditor,
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
f as MetadataEmptyState,
|
25
|
+
I as MetadataInstanceForm,
|
26
|
+
i as MetadataInstanceFormHeader,
|
27
|
+
A as MetadataInstanceHeader,
|
28
|
+
C as MetadataInstanceList,
|
29
|
+
m as SingleLevelTaxonomyField,
|
30
30
|
w as UnsavedChangesModal,
|
31
31
|
L as UpdateMode,
|
32
32
|
U as defaultInitialValues,
|
@@ -0,0 +1,191 @@
|
|
1
|
+
import "../../../../styles/combobox-with-api-pagination.css";
|
2
|
+
import { ComboboxItemValue as U } from "@ariakit/react";
|
3
|
+
import { Combobox as p, LoadingIndicator as q, InlineNotice as H, Text as J } from "@box/blueprint-web";
|
4
|
+
import { Search as K, Loader as Q } from "@box/blueprint-web-assets/icons/Fill";
|
5
|
+
import { IconIconOnLightSecondary as X, Size6 as C, Size1 as Y } from "@box/blueprint-web-assets/tokens/tokens";
|
6
|
+
import { useRef as E, useCallback as Z, useMemo as v, useEffect as $, forwardRef as oo } from "react";
|
7
|
+
import { useIntl as T, FormattedMessage as y } from "react-intl";
|
8
|
+
import i from "./messages.js";
|
9
|
+
import { useAsyncList as eo } from "./use-async-list.js";
|
10
|
+
import { useControllableState as ro } from "./utils/use-controllable-state.js";
|
11
|
+
import { useTrackVisibility as to } from "./utils/use-intersection-observer.js";
|
12
|
+
import { jsx as t, jsxs as I, Fragment as no } from "react/jsx-runtime";
|
13
|
+
const io = "_container_16dlc_1", ao = "_highlightOptionText_16dlc_7", so = "_option_16dlc_20", lo = "_errorComboboxOption_16dlc_24", co = "_errorComboboxOptionText_16dlc_29", d = {
|
14
|
+
container: io,
|
15
|
+
highlightOptionText: ao,
|
16
|
+
option: so,
|
17
|
+
errorComboboxOption: lo,
|
18
|
+
errorComboboxOptionText: co
|
19
|
+
}, M = /* @__PURE__ */ oo(({
|
20
|
+
onTryAgain: f
|
21
|
+
}, h) => {
|
22
|
+
const {
|
23
|
+
formatMessage: s
|
24
|
+
} = T();
|
25
|
+
return /* @__PURE__ */ I(no, {
|
26
|
+
children: [/* @__PURE__ */ t(H, {
|
27
|
+
variant: "error",
|
28
|
+
variantIconAriaLabel: s(i.loadingResultsErrorIconLabel),
|
29
|
+
children: /* @__PURE__ */ t(y, {
|
30
|
+
...i.loadingResultsErrorMessage
|
31
|
+
})
|
32
|
+
}), /* @__PURE__ */ t(p.Option, {
|
33
|
+
ref: h,
|
34
|
+
className: d.errorComboboxOption,
|
35
|
+
onClick: f,
|
36
|
+
children: /* @__PURE__ */ I(J, {
|
37
|
+
as: "span",
|
38
|
+
className: d.errorComboboxOptionText,
|
39
|
+
color: "textOnLightLink",
|
40
|
+
variant: "bodyDefaultBold",
|
41
|
+
children: [/* @__PURE__ */ t(y, {
|
42
|
+
...i.loadingResultsErrorAction
|
43
|
+
}), /* @__PURE__ */ t(Q, {
|
44
|
+
color: "currentColor",
|
45
|
+
height: "12px",
|
46
|
+
width: "12px"
|
47
|
+
})]
|
48
|
+
})
|
49
|
+
})]
|
50
|
+
});
|
51
|
+
}), x = "__LOADING__", O = "__LOADING_ERROR__", uo = "0px 0px 20px 0px", mo = /* @__PURE__ */ t(K, {
|
52
|
+
color: X,
|
53
|
+
height: C,
|
54
|
+
role: "presentation",
|
55
|
+
style: {
|
56
|
+
padding: Y,
|
57
|
+
boxSizing: "border-box"
|
58
|
+
},
|
59
|
+
width: C
|
60
|
+
}), Eo = (f) => {
|
61
|
+
const {
|
62
|
+
defaultFetcher: h,
|
63
|
+
onInputValueChange: s,
|
64
|
+
value: N,
|
65
|
+
onValueChange: S,
|
66
|
+
noResultMessage: V,
|
67
|
+
defaultValue: D,
|
68
|
+
loadingAriaLabel: P,
|
69
|
+
multiselect: _ = !1,
|
70
|
+
...k
|
71
|
+
} = f, {
|
72
|
+
formatMessage: l
|
73
|
+
} = T(), g = E(null), o = eo({
|
74
|
+
async load({
|
75
|
+
marker: e,
|
76
|
+
searchInput: r,
|
77
|
+
signal: u
|
78
|
+
}) {
|
79
|
+
const m = await h({
|
80
|
+
signal: u,
|
81
|
+
marker: e,
|
82
|
+
searchInput: r
|
83
|
+
});
|
84
|
+
return {
|
85
|
+
items: m.options,
|
86
|
+
marker: m.marker
|
87
|
+
};
|
88
|
+
}
|
89
|
+
}), R = E(!1), F = Z(() => {
|
90
|
+
R.current || (o.reload(), R.current = !0);
|
91
|
+
}, []), [n, A] = ro({
|
92
|
+
prop: N,
|
93
|
+
defaultProp: D,
|
94
|
+
onChange: S
|
95
|
+
}), b = v(() => Array.isArray(n) ? n.filter((e) => !o.items.some((r) => r.value === e.value)) : [], [n, o.items]), w = (e) => {
|
96
|
+
const {
|
97
|
+
value: r,
|
98
|
+
...u
|
99
|
+
} = e;
|
100
|
+
if (r === x)
|
101
|
+
return o.hasNextPage ? /* @__PURE__ */ t(p.Option, {
|
102
|
+
...u,
|
103
|
+
ref: G,
|
104
|
+
disabled: !0,
|
105
|
+
value: r,
|
106
|
+
children: /* @__PURE__ */ t(q, {
|
107
|
+
"aria-label": l(i.loadingMoreAriaLabel),
|
108
|
+
style: {
|
109
|
+
position: "unset"
|
110
|
+
}
|
111
|
+
})
|
112
|
+
}) : null;
|
113
|
+
if (r === O && o.hasError && !o.isEmpty)
|
114
|
+
return /* @__PURE__ */ t(M, {
|
115
|
+
onTryAgain: () => {
|
116
|
+
var a;
|
117
|
+
o.loadMore(), (a = g.current) == null || a.focus();
|
118
|
+
}
|
119
|
+
});
|
120
|
+
if (b.some((a) => a.value === r))
|
121
|
+
return null;
|
122
|
+
const m = () => n ? Array.isArray(n) ? n.some((a) => a.value === r) : n.value === r : !1;
|
123
|
+
return /* @__PURE__ */ t(p.Option, {
|
124
|
+
...u,
|
125
|
+
className: d.option,
|
126
|
+
disabled: m(),
|
127
|
+
value: r,
|
128
|
+
children: /* @__PURE__ */ t(U, {
|
129
|
+
className: d.highlightOptionText,
|
130
|
+
value: r
|
131
|
+
})
|
132
|
+
});
|
133
|
+
}, B = (e) => {
|
134
|
+
s == null || s(e), o.search(e), e.trim() === "" && !_ && A(null);
|
135
|
+
}, z = () => {
|
136
|
+
var e;
|
137
|
+
o.reload(), (e = g.current) == null || e.focus();
|
138
|
+
};
|
139
|
+
let c;
|
140
|
+
o.hasError && !o.isLoading ? c = /* @__PURE__ */ t(M, {
|
141
|
+
onTryAgain: z
|
142
|
+
}) : o.isEmpty && !o.isLoading ? c = V || l(i.noResults) : c = void 0;
|
143
|
+
const [G, {
|
144
|
+
rootRef: W,
|
145
|
+
isVisible: L
|
146
|
+
}] = to({
|
147
|
+
rootMargin: uo
|
148
|
+
});
|
149
|
+
$(() => {
|
150
|
+
if (!(L && o.hasNextPage))
|
151
|
+
return;
|
152
|
+
const r = setTimeout(() => {
|
153
|
+
o.loadMore();
|
154
|
+
}, 100);
|
155
|
+
return () => {
|
156
|
+
clearTimeout(r);
|
157
|
+
};
|
158
|
+
}, [L]);
|
159
|
+
const j = v(() => {
|
160
|
+
const e = o.hasNextPage ? {
|
161
|
+
id: x,
|
162
|
+
value: x
|
163
|
+
} : null, r = !e && o.hasError && !o.isEmpty ? {
|
164
|
+
id: O,
|
165
|
+
value: O
|
166
|
+
} : null;
|
167
|
+
return [...o.items, ...b, e, r].filter(Boolean);
|
168
|
+
}, [o.hasNextPage, o.hasError, o.isEmpty, o.items, b]);
|
169
|
+
return /* @__PURE__ */ t(p, {
|
170
|
+
as: "input",
|
171
|
+
...k,
|
172
|
+
ref: g,
|
173
|
+
clearButtonAriaLabel: l(i.clearButtonAriaLabel),
|
174
|
+
endComboboxIcon: mo,
|
175
|
+
focusLoop: !1,
|
176
|
+
getPopoverRef: W,
|
177
|
+
loading: o.isReloading,
|
178
|
+
loadingAriaLabel: P || l(i.loadingAriaLabel),
|
179
|
+
multiselect: _,
|
180
|
+
noResultMessage: c,
|
181
|
+
onFocus: F,
|
182
|
+
onInputValueChange: B,
|
183
|
+
onValueChange: A,
|
184
|
+
options: j,
|
185
|
+
renderOption: w,
|
186
|
+
value: n
|
187
|
+
});
|
188
|
+
};
|
189
|
+
export {
|
190
|
+
Eo as ComboboxWithApiPagination
|
191
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import * as s from "react";
|
2
|
+
function a(e) {
|
3
|
+
const n = s.useRef(e);
|
4
|
+
return s.useEffect(() => {
|
5
|
+
n.current = e;
|
6
|
+
}), s.useMemo(() => (...o) => {
|
7
|
+
var t;
|
8
|
+
return (t = n.current) == null ? void 0 : t.call(n, ...o);
|
9
|
+
}, []);
|
10
|
+
}
|
11
|
+
function R({
|
12
|
+
prop: e,
|
13
|
+
defaultProp: n,
|
14
|
+
onChange: o = () => {
|
15
|
+
}
|
16
|
+
}) {
|
17
|
+
const [t, c] = C({
|
18
|
+
defaultProp: n,
|
19
|
+
onChange: o
|
20
|
+
}), r = e !== void 0, i = r ? e : t, l = a(o), d = s.useCallback((u) => {
|
21
|
+
if (r) {
|
22
|
+
const f = typeof u == "function" ? u(e) : u;
|
23
|
+
f !== e && l(f);
|
24
|
+
} else
|
25
|
+
c(u);
|
26
|
+
}, [r, e, c, l]);
|
27
|
+
return [i, d];
|
28
|
+
}
|
29
|
+
function C({
|
30
|
+
defaultProp: e,
|
31
|
+
onChange: n
|
32
|
+
}) {
|
33
|
+
const o = s.useState(e), [t] = o, c = s.useRef(t), r = a(n);
|
34
|
+
return s.useEffect(() => {
|
35
|
+
c.current !== t && (r(t), c.current = t);
|
36
|
+
}, [t, c, r]), o;
|
37
|
+
}
|
38
|
+
export {
|
39
|
+
R as useControllableState
|
40
|
+
};
|
@@ -1,26 +1,32 @@
|
|
1
|
-
import
|
2
|
-
import {
|
1
|
+
import "../../../../styles/interactive-text.css";
|
2
|
+
import { Focusable as n } from "@ariakit/react";
|
3
|
+
import { Tooltip as a, Text as s } from "@box/blueprint-web";
|
4
|
+
import m from "clsx";
|
3
5
|
import { jsx as t } from "react/jsx-runtime";
|
4
|
-
const l =
|
6
|
+
const x = "_interactiveText_2jv0p_1", l = {
|
7
|
+
interactiveText: x
|
8
|
+
}, d = ({
|
5
9
|
tooltipText: r,
|
6
|
-
|
10
|
+
className: i,
|
11
|
+
children: c,
|
7
12
|
...e
|
8
13
|
}) => {
|
9
14
|
const {
|
10
|
-
as:
|
15
|
+
as: o = "span"
|
11
16
|
} = e;
|
12
17
|
return /* @__PURE__ */ t(a, {
|
13
18
|
__checkInteractivity: !1,
|
14
19
|
content: r,
|
15
|
-
children: /* @__PURE__ */ t(
|
16
|
-
render: /* @__PURE__ */ t(
|
17
|
-
as:
|
20
|
+
children: /* @__PURE__ */ t(n, {
|
21
|
+
render: /* @__PURE__ */ t(s, {
|
22
|
+
as: o,
|
23
|
+
className: m(l.interactiveText, i),
|
18
24
|
...e,
|
19
|
-
children:
|
25
|
+
children: c
|
20
26
|
})
|
21
27
|
})
|
22
28
|
});
|
23
29
|
};
|
24
30
|
export {
|
25
|
-
|
31
|
+
d as default
|
26
32
|
};
|
@@ -1,64 +1,71 @@
|
|
1
|
-
import { DateI18nProvider as
|
2
|
-
import { useFormikContext as F, getIn as
|
3
|
-
import { useMemo as
|
4
|
-
import { useIntl as
|
5
|
-
import { convertToDatePickerValue as
|
6
|
-
import { useDateInternationalization as
|
7
|
-
import
|
8
|
-
import
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
import { DateI18nProvider as T, DatePicker as P } from "@box/blueprint-web";
|
2
|
+
import { useFormikContext as F, getIn as V, Field as b } from "formik";
|
3
|
+
import { useMemo as A } from "react";
|
4
|
+
import { useIntl as C } from "react-intl";
|
5
|
+
import { convertToDatePickerValue as I, convertToFormikValue as L } from "./date-conversion-utils.js";
|
6
|
+
import { useDateInternationalization as w } from "./use-date-internationalization.js";
|
7
|
+
import a from "../../../../messages.js";
|
8
|
+
import N from "../../../interactive-text/interactive-text.js";
|
9
|
+
import { jsx as o } from "react/jsx-runtime";
|
10
|
+
const G = ({
|
11
|
+
description: s,
|
12
|
+
disableForm: m,
|
13
|
+
fieldNamePrefix: d,
|
14
|
+
label: r,
|
15
|
+
portalElement: f,
|
14
16
|
className: u
|
15
17
|
}) => {
|
16
|
-
const
|
17
|
-
values:
|
18
|
-
setFieldTouched:
|
19
|
-
setFieldValue:
|
18
|
+
const t = `${d}.value`, e = C(), {
|
19
|
+
values: h,
|
20
|
+
setFieldTouched: p,
|
21
|
+
setFieldValue: D
|
20
22
|
} = F(), {
|
21
|
-
localTimezone:
|
22
|
-
} =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
p(
|
32
|
-
}, k = () => {
|
33
|
-
h(a, !0);
|
23
|
+
localTimezone: M
|
24
|
+
} = w(e.locale), c = V(h, t), g = A(() => I(c), [c]), k = {
|
25
|
+
clearDatePickerAriaLabel: e.formatMessage(a.clearSelectedDate),
|
26
|
+
nextMonthAriaLabel: e.formatMessage(a.switchToNextMonth),
|
27
|
+
openCalendarDropdownAriaLabel: e.formatMessage(a.openCalendar),
|
28
|
+
previousMonthAriaLabel: e.formatMessage(a.switchToNextMonth)
|
29
|
+
}, v = (n) => {
|
30
|
+
const l = L(n, M);
|
31
|
+
D(t, l);
|
32
|
+
}, x = () => {
|
33
|
+
p(t, !0);
|
34
34
|
};
|
35
|
-
return /* @__PURE__ */
|
36
|
-
"data-testid": `${
|
37
|
-
children: /* @__PURE__ */
|
35
|
+
return /* @__PURE__ */ o("div", {
|
36
|
+
"data-testid": `${r}-field`,
|
37
|
+
children: /* @__PURE__ */ o(T, {
|
38
38
|
locale: e.locale,
|
39
|
-
children: /* @__PURE__ */
|
40
|
-
name:
|
39
|
+
children: /* @__PURE__ */ o(b, {
|
40
|
+
name: t,
|
41
41
|
children: ({
|
42
|
-
field:
|
43
|
-
meta:
|
44
|
-
}) => /* @__PURE__ */
|
45
|
-
...
|
46
|
-
...
|
47
|
-
calendarAriaLabel: e.formatMessage(
|
42
|
+
field: n,
|
43
|
+
meta: l
|
44
|
+
}) => /* @__PURE__ */ o(P, {
|
45
|
+
...n,
|
46
|
+
...k,
|
47
|
+
calendarAriaLabel: e.formatMessage(a.selectDate),
|
48
48
|
className: u,
|
49
|
-
error:
|
50
|
-
isDisabled:
|
51
|
-
label:
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
error: l.error,
|
50
|
+
isDisabled: m,
|
51
|
+
label: s ? ({
|
52
|
+
...i
|
53
|
+
}) => N({
|
54
|
+
as: "span",
|
55
|
+
tooltipText: s,
|
56
|
+
children: r,
|
57
|
+
...i
|
58
|
+
}) : r,
|
59
|
+
onBlur: () => x(),
|
60
|
+
onChange: (i) => v(i),
|
61
|
+
portalElement: f,
|
62
|
+
value: g
|
56
63
|
})
|
57
64
|
})
|
58
65
|
})
|
59
66
|
});
|
60
67
|
};
|
61
68
|
export {
|
62
|
-
|
63
|
-
|
69
|
+
G as MetadataDateField,
|
70
|
+
G as default
|
64
71
|
};
|
@@ -1,47 +1,56 @@
|
|
1
|
-
import { Select as l, SELECT_EMPTY_VALUE as
|
2
|
-
import { useFormikContext as
|
3
|
-
import { useIntl as
|
1
|
+
import { Select as l, SELECT_EMPTY_VALUE as s } from "@box/blueprint-web";
|
2
|
+
import { useFormikContext as E, getIn as F, Field as M } from "formik";
|
3
|
+
import { useIntl as V, FormattedMessage as C } from "react-intl";
|
4
4
|
import d from "../../../../messages.js";
|
5
|
-
import
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
import T from "../../../interactive-text/interactive-text.js";
|
6
|
+
import { jsx as t, jsxs as I } from "react/jsx-runtime";
|
7
|
+
const A = ({
|
8
|
+
className: i,
|
9
|
+
description: n,
|
10
|
+
disableForm: h,
|
11
|
+
fieldNamePrefix: c,
|
12
|
+
label: r,
|
13
|
+
options: v,
|
14
|
+
portalElement: p
|
13
15
|
}) => {
|
14
16
|
const {
|
15
|
-
setFieldValue:
|
16
|
-
values:
|
17
|
-
} =
|
17
|
+
setFieldValue: x,
|
18
|
+
values: f
|
19
|
+
} = E(), g = V(), m = `${c}.value`, o = v || F(f, `${c}.options`, []).map(({
|
18
20
|
key: a
|
19
|
-
}) => a), u =
|
21
|
+
}) => a), u = g.formatMessage(d.selectValuePlaceholder);
|
20
22
|
return /* @__PURE__ */ t("div", {
|
21
|
-
"data-testid": `${
|
22
|
-
children: /* @__PURE__ */ t(
|
23
|
-
name:
|
23
|
+
"data-testid": `${r}-field`,
|
24
|
+
children: /* @__PURE__ */ t(M, {
|
25
|
+
name: m,
|
24
26
|
children: ({
|
25
27
|
field: a
|
26
28
|
}) => /* @__PURE__ */ t(l, {
|
27
|
-
className:
|
28
|
-
disabled:
|
29
|
-
label:
|
29
|
+
className: i,
|
30
|
+
disabled: h,
|
31
|
+
label: n ? ({
|
32
|
+
...e
|
33
|
+
}) => T({
|
34
|
+
as: "label",
|
35
|
+
tooltipText: n,
|
36
|
+
children: r,
|
37
|
+
...e
|
38
|
+
}) : r,
|
30
39
|
onValueChange: (e) => {
|
31
|
-
|
40
|
+
x(m, e === s ? "" : e);
|
32
41
|
},
|
33
42
|
placeholder: u,
|
34
43
|
...a,
|
35
|
-
value: a.value ===
|
36
|
-
children: /* @__PURE__ */
|
37
|
-
container:
|
44
|
+
value: a.value === s ? "" : a.value,
|
45
|
+
children: /* @__PURE__ */ I(l.Content, {
|
46
|
+
container: p,
|
38
47
|
children: [/* @__PURE__ */ t(l.Option, {
|
39
48
|
text: u,
|
40
|
-
value:
|
41
|
-
children: /* @__PURE__ */ t(
|
49
|
+
value: s,
|
50
|
+
children: /* @__PURE__ */ t(C, {
|
42
51
|
...d.selectValuePlaceholder
|
43
52
|
})
|
44
|
-
}),
|
53
|
+
}), o == null ? void 0 : o.map((e) => /* @__PURE__ */ t(l.Option, {
|
45
54
|
text: e,
|
46
55
|
value: e,
|
47
56
|
children: e
|
@@ -52,6 +61,6 @@ const T = ({
|
|
52
61
|
});
|
53
62
|
};
|
54
63
|
export {
|
55
|
-
|
56
|
-
|
64
|
+
A as MetadataEnumField,
|
65
|
+
A as default
|
57
66
|
};
|