@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
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import "../../../../styles/combobox-with-api-pagination.css";
|
|
2
|
-
import { ComboboxItemValue as q } from "@ariakit/react";
|
|
3
|
-
import { Combobox as u, LoadingIndicator as H, InlineNotice as J, Text as K } from "@box/blueprint-web";
|
|
4
|
-
import { Search as Q, Loader as X } from "@box/blueprint-web-assets/icons/Fill";
|
|
5
|
-
import { IconIconOnLightSecondary as Y, Size6 as C, Size1 as Z } from "@box/blueprint-web-assets/tokens/tokens";
|
|
6
|
-
import { useRef as I, useCallback as $, useState as oo, useMemo as y, useEffect as M, forwardRef as eo } from "react";
|
|
7
|
-
import { useIntl as V, FormattedMessage as T } from "react-intl";
|
|
8
|
-
import i from "./messages.js";
|
|
9
|
-
import { useAsyncList as to } from "./use-async-list.js";
|
|
10
|
-
import { useTrackVisibility as ro } from "./utils/use-intersection-observer.js";
|
|
11
|
-
import { jsx as r, jsxs as N, Fragment as no } from "react/jsx-runtime";
|
|
12
|
-
const io = "_container_16dlc_1", so = "_highlightOptionText_16dlc_7", ao = "_option_16dlc_20", lo = "_errorComboboxOption_16dlc_24", co = "_errorComboboxOptionText_16dlc_29", d = {
|
|
13
|
-
container: io,
|
|
14
|
-
highlightOptionText: so,
|
|
15
|
-
option: ao,
|
|
16
|
-
errorComboboxOption: lo,
|
|
17
|
-
errorComboboxOptionText: co
|
|
18
|
-
}, S = /* @__PURE__ */ eo(({
|
|
19
|
-
onTryAgain: p
|
|
20
|
-
}, m) => {
|
|
21
|
-
const {
|
|
22
|
-
formatMessage: h
|
|
23
|
-
} = V();
|
|
24
|
-
return /* @__PURE__ */ N(no, {
|
|
25
|
-
children: [/* @__PURE__ */ r(J, {
|
|
26
|
-
variant: "error",
|
|
27
|
-
variantIconAriaLabel: h(i.loadingResultsErrorIconLabel),
|
|
28
|
-
children: /* @__PURE__ */ r(T, {
|
|
29
|
-
...i.loadingResultsErrorMessage
|
|
30
|
-
})
|
|
31
|
-
}), /* @__PURE__ */ r(u.Option, {
|
|
32
|
-
ref: m,
|
|
33
|
-
className: d.errorComboboxOption,
|
|
34
|
-
onClick: p,
|
|
35
|
-
children: /* @__PURE__ */ N(K, {
|
|
36
|
-
as: "span",
|
|
37
|
-
className: d.errorComboboxOptionText,
|
|
38
|
-
color: "textOnLightLink",
|
|
39
|
-
variant: "bodyDefaultBold",
|
|
40
|
-
children: [/* @__PURE__ */ r(T, {
|
|
41
|
-
...i.loadingResultsErrorAction
|
|
42
|
-
}), /* @__PURE__ */ r(X, {
|
|
43
|
-
color: "currentColor",
|
|
44
|
-
height: "12px",
|
|
45
|
-
width: "12px"
|
|
46
|
-
})]
|
|
47
|
-
})
|
|
48
|
-
})]
|
|
49
|
-
});
|
|
50
|
-
}), _ = "__LOADING__", R = "__LOADING_ERROR__", uo = "0px 0px 20px 0px", po = /* @__PURE__ */ r(Q, {
|
|
51
|
-
color: Y,
|
|
52
|
-
height: C,
|
|
53
|
-
role: "presentation",
|
|
54
|
-
style: {
|
|
55
|
-
padding: Z,
|
|
56
|
-
boxSizing: "border-box"
|
|
57
|
-
},
|
|
58
|
-
width: C
|
|
59
|
-
}), Eo = (p) => {
|
|
60
|
-
const {
|
|
61
|
-
defaultFetcher: m,
|
|
62
|
-
searchFetcher: h,
|
|
63
|
-
onInputValueChange: f,
|
|
64
|
-
value: D,
|
|
65
|
-
noResultMessage: F,
|
|
66
|
-
loadingAriaLabel: k,
|
|
67
|
-
multiselect: g = !1,
|
|
68
|
-
...P
|
|
69
|
-
} = p, {
|
|
70
|
-
formatMessage: a
|
|
71
|
-
} = V(), b = I(null), o = to({
|
|
72
|
-
async load({
|
|
73
|
-
marker: t,
|
|
74
|
-
searchInput: e,
|
|
75
|
-
signal: v
|
|
76
|
-
}) {
|
|
77
|
-
const c = await (e === "" ? m : h)({
|
|
78
|
-
signal: v,
|
|
79
|
-
marker: t,
|
|
80
|
-
searchInput: e
|
|
81
|
-
});
|
|
82
|
-
return {
|
|
83
|
-
items: c.options,
|
|
84
|
-
marker: c.marker
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}), A = I(!1), w = $(() => {
|
|
88
|
-
A.current || (o.reload(), A.current = !0);
|
|
89
|
-
}, []), [n, L] = oo(D), x = y(() => Array.isArray(n) ? n.filter((t) => !o.items.some((e) => e.value === t.value)) : [], [n, o.items]), B = (t) => {
|
|
90
|
-
const {
|
|
91
|
-
value: e,
|
|
92
|
-
level: v,
|
|
93
|
-
...O
|
|
94
|
-
} = t;
|
|
95
|
-
if (e === _)
|
|
96
|
-
return o.hasNextPage ? /* @__PURE__ */ r(u.Option, {
|
|
97
|
-
...O,
|
|
98
|
-
ref: W,
|
|
99
|
-
disabled: !0,
|
|
100
|
-
value: e,
|
|
101
|
-
children: /* @__PURE__ */ r(H, {
|
|
102
|
-
"aria-label": a(i.loadingMoreAriaLabel),
|
|
103
|
-
style: {
|
|
104
|
-
position: "unset"
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
}) : null;
|
|
108
|
-
if (e === R && o.hasError && !o.isEmpty)
|
|
109
|
-
return /* @__PURE__ */ r(S, {
|
|
110
|
-
onTryAgain: () => {
|
|
111
|
-
var s;
|
|
112
|
-
o.loadMore(), (s = b.current) == null || s.focus();
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
if (x.some((s) => s.value === e))
|
|
116
|
-
return null;
|
|
117
|
-
const c = () => n ? Array.isArray(n) ? n.some((s) => s.value === e) : n.value === e : !1;
|
|
118
|
-
return /* @__PURE__ */ r(u.Option, {
|
|
119
|
-
...O,
|
|
120
|
-
className: d.option,
|
|
121
|
-
disabled: c(),
|
|
122
|
-
value: e,
|
|
123
|
-
children: /* @__PURE__ */ r(q, {
|
|
124
|
-
className: d.highlightOptionText,
|
|
125
|
-
value: e
|
|
126
|
-
})
|
|
127
|
-
});
|
|
128
|
-
}, z = (t) => {
|
|
129
|
-
f == null || f(t), o.search(t);
|
|
130
|
-
}, G = () => {
|
|
131
|
-
var t;
|
|
132
|
-
o.reload(), (t = b.current) == null || t.focus();
|
|
133
|
-
};
|
|
134
|
-
let l;
|
|
135
|
-
o.hasError && !o.isLoading ? l = /* @__PURE__ */ r(S, {
|
|
136
|
-
onTryAgain: G
|
|
137
|
-
}) : o.isEmpty && !o.isLoading ? l = F || a(i.noResults) : l = void 0;
|
|
138
|
-
const [W, {
|
|
139
|
-
rootRef: j,
|
|
140
|
-
isVisible: E
|
|
141
|
-
}] = ro({
|
|
142
|
-
rootMargin: uo
|
|
143
|
-
});
|
|
144
|
-
M(() => {
|
|
145
|
-
o.searchInput === "" && !g && L(void 0);
|
|
146
|
-
}, [o.searchInput, g]), M(() => {
|
|
147
|
-
if (!(E && o.hasNextPage))
|
|
148
|
-
return;
|
|
149
|
-
const e = setTimeout(() => {
|
|
150
|
-
o.loadMore();
|
|
151
|
-
}, 100);
|
|
152
|
-
return () => {
|
|
153
|
-
clearTimeout(e);
|
|
154
|
-
};
|
|
155
|
-
}, [E]);
|
|
156
|
-
const U = y(() => {
|
|
157
|
-
const t = o.hasNextPage ? {
|
|
158
|
-
id: _,
|
|
159
|
-
value: _
|
|
160
|
-
} : null, e = !t && o.hasError && !o.isEmpty ? {
|
|
161
|
-
id: R,
|
|
162
|
-
value: R
|
|
163
|
-
} : null;
|
|
164
|
-
return [...o.items, ...x, t, e].filter(Boolean);
|
|
165
|
-
}, [o.hasNextPage, o.hasError, o.isEmpty, o.items, x]);
|
|
166
|
-
return /* @__PURE__ */ r(u, {
|
|
167
|
-
as: "input",
|
|
168
|
-
...P,
|
|
169
|
-
ref: b,
|
|
170
|
-
clearButtonAriaLabel: a(i.clearButtonAriaLabel),
|
|
171
|
-
endComboboxIcon: po,
|
|
172
|
-
focusLoop: !1,
|
|
173
|
-
getPopoverRef: j,
|
|
174
|
-
loading: o.isReloading,
|
|
175
|
-
loadingAriaLabel: k || a(i.loadingAriaLabel),
|
|
176
|
-
multiselect: g,
|
|
177
|
-
noResultMessage: l,
|
|
178
|
-
onFocus: w,
|
|
179
|
-
onInputValueChange: z,
|
|
180
|
-
onValueChange: L,
|
|
181
|
-
options: U,
|
|
182
|
-
renderOption: B,
|
|
183
|
-
value: n
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
export {
|
|
187
|
-
Eo as ComboboxWithApiPagination
|
|
188
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ComboboxWithApiPagination as n } from "./combobox-with-api-pagination.js";
|
|
2
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
3
|
-
const c = (e) => {
|
|
4
|
-
const {
|
|
5
|
-
label: o,
|
|
6
|
-
defaultFetcher: t,
|
|
7
|
-
searchFetcher: r,
|
|
8
|
-
...i
|
|
9
|
-
} = e;
|
|
10
|
-
return /* @__PURE__ */ a(n, {
|
|
11
|
-
...i,
|
|
12
|
-
defaultFetcher: t,
|
|
13
|
-
label: o,
|
|
14
|
-
searchFetcher: r
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
c as SingleLevelTaxonomyField
|
|
19
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
|
-
import { type PaginationQueryInput, type TaxonomyComboboxOption, type TaxonomyFetcherResponse } from './types';
|
|
3
|
-
interface ComboboxWithApiPaginationProps {
|
|
4
|
-
defaultFetcher: (input: PaginationQueryInput) => Promise<TaxonomyFetcherResponse>;
|
|
5
|
-
searchFetcher?: (input: PaginationQueryInput) => Promise<TaxonomyFetcherResponse>;
|
|
6
|
-
includeTextInputOption?: boolean;
|
|
7
|
-
noResultMessage?: ReactElement | string;
|
|
8
|
-
onInputValueChange?: (inputValue: string) => void;
|
|
9
|
-
value: TaxonomyComboboxOption | TaxonomyComboboxOption[];
|
|
10
|
-
label: string;
|
|
11
|
-
loadingAriaLabel?: string;
|
|
12
|
-
multiselect?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare const ComboboxWithApiPagination: (props: ComboboxWithApiPaginationProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
|
-
export interface PaginationQueryInput {
|
|
3
|
-
marker?: string;
|
|
4
|
-
searchInput?: string;
|
|
5
|
-
/**
|
|
6
|
-
* Abort signal that will be used to cancel the request in your fetching function
|
|
7
|
-
*/
|
|
8
|
-
signal?: AbortSignal;
|
|
9
|
-
}
|
|
10
|
-
export interface TaxonomyResponseOption {
|
|
11
|
-
displayName: string;
|
|
12
|
-
id: string;
|
|
13
|
-
level?: number;
|
|
14
|
-
}
|
|
15
|
-
export interface TaxonomyResponse {
|
|
16
|
-
marker?: string;
|
|
17
|
-
options: TaxonomyResponseOption[];
|
|
18
|
-
}
|
|
19
|
-
export interface TaxonomyFetcherResponse {
|
|
20
|
-
marker?: string;
|
|
21
|
-
options: TaxonomyComboboxOption[];
|
|
22
|
-
}
|
|
23
|
-
export interface TaxonomyComboboxOption {
|
|
24
|
-
id: string;
|
|
25
|
-
value: string;
|
|
26
|
-
level?: number;
|
|
27
|
-
parentId?: string;
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface SingleLevelTaxonomyFieldProps {
|
|
31
|
-
defaultOpen?: boolean;
|
|
32
|
-
experimentalVirtualization?: boolean;
|
|
33
|
-
multiselect?: boolean;
|
|
34
|
-
noResultMessage?: ReactElement | string;
|
|
35
|
-
portalElement?: HTMLElement | (() => HTMLElement);
|
|
36
|
-
label: string;
|
|
37
|
-
value: TaxonomyComboboxOption | TaxonomyComboboxOption[];
|
|
38
|
-
onValueChange: (value: string) => void;
|
|
39
|
-
defaultFetcher: (input: PaginationQueryInput) => Promise<TaxonomyFetcherResponse>;
|
|
40
|
-
searchFetcher: (input: PaginationQueryInput) => Promise<TaxonomyFetcherResponse>;
|
|
41
|
-
}
|
/package/esm/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/messages.js
RENAMED
|
File without changes
|
/package/esm/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/request.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/types/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/messages.d.ts
RENAMED
|
File without changes
|
/package/types/lib/components/{metadata-taxonomy-field → combobox-with-api-pagination}/request.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|