@box/metadata-editor 0.74.4 → 0.74.5

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/utils.js CHANGED
@@ -1,42 +1,43 @@
1
1
  import "../styles/utils.css";
2
2
  import { BoxAiLogo as n } from "@box/blueprint-web-assets/icons/Logo";
3
3
  import c from "../esm/lib/components/interactive-text/interactive-text.js";
4
- import { jsxs as i, jsx as o } from "react/jsx-runtime";
5
- const _ = "_noAttributesText_ycjhh_753", h = "_fieldWrapper_ycjhh_757", b = "_hasSuggestion_ycjhh_762", p = "_error_ycjhh_770", g = "_dateField_ycjhh_782", x = "_suggestionApplied_ycjhh_786", d = "_comboboxContainer_ycjhh_786", u = "_labelWrapper_ycjhh_800", m = "_labelText_ycjhh_806", y = "_labelIcon_ycjhh_809", t = {
6
- noAttributesText: _,
7
- fieldWrapper: h,
4
+ import { convertISOStringToUTCDate as i } from "../esm/lib/utils/convertDate.js";
5
+ import { jsxs as _, jsx as o } from "react/jsx-runtime";
6
+ const h = "_noAttributesText_ycjhh_753", p = "_fieldWrapper_ycjhh_757", b = "_hasSuggestion_ycjhh_762", g = "_error_ycjhh_770", x = "_dateField_ycjhh_782", d = "_suggestionApplied_ycjhh_786", m = "_comboboxContainer_ycjhh_786", u = "_labelWrapper_ycjhh_800", y = "_labelText_ycjhh_806", j = "_labelIcon_ycjhh_809", t = {
7
+ noAttributesText: h,
8
+ fieldWrapper: p,
8
9
  hasSuggestion: b,
9
- error: p,
10
- dateField: g,
11
- suggestionApplied: x,
12
- comboboxContainer: d,
10
+ error: g,
11
+ dateField: x,
12
+ suggestionApplied: d,
13
+ comboboxContainer: m,
13
14
  labelWrapper: u,
14
- labelText: m,
15
- labelIcon: y
16
- }, I = (e, l, a = !1, s = "label") => (r) => /* @__PURE__ */ i("div", {
15
+ labelText: y,
16
+ labelIcon: j
17
+ }, f = (e, r, a = !1, s = "label") => (l) => /* @__PURE__ */ _("div", {
17
18
  className: t.labelWrapper,
18
- children: [l ? /* @__PURE__ */ o(c, {
19
+ children: [r ? /* @__PURE__ */ o(c, {
19
20
  as: s,
20
21
  className: t.labelText,
21
- tooltipText: l,
22
- ...r,
22
+ tooltipText: r,
23
+ ...l,
23
24
  children: e
24
25
  }) : /* @__PURE__ */ o("label", {
25
26
  className: t.labelText,
26
- ...r,
27
+ ...l,
27
28
  children: e
28
29
  }), a && /* @__PURE__ */ o(n, {
29
30
  className: t.labelIcon
30
31
  })]
31
- }), S = (e) => {
32
+ }), C = (e) => {
32
33
  try {
33
- return new Date(e).toISOString();
34
+ return i(e).toISOString();
34
35
  } catch {
35
36
  return null;
36
37
  }
37
38
  };
38
39
  export {
39
- I as g,
40
+ f as g,
40
41
  t as s,
41
- S as t
42
+ C as t
42
43
  };
@@ -1,61 +1,58 @@
1
- import { DateI18nProvider as T, DatePicker as V } from "@box/blueprint-web";
2
- import { useFormikContext as A, getIn as C, Field as w } from "formik";
3
- import { forwardRef as I, useMemo as N } from "react";
4
- import { useIntl as z } from "react-intl";
5
- import { convertToDatePickerValue as B, convertToFormikValue as O } from "./date-conversion-utils.js";
6
- import { useDateInternationalization as $ } from "./use-date-internationalization.js";
1
+ import { DateI18nProvider as L, DatePicker as P } from "@box/blueprint-web";
2
+ import { useFormikContext as A, getIn as I, Field as T } from "formik";
3
+ import { forwardRef as w, useMemo as S } from "react";
4
+ import { useIntl as V } from "react-intl";
5
+ import { convertIsoStringToCalendarDate as N, convertCalendarDateToISOString as O } from "../../../../utils/convertDate.js";
7
6
  import a from "../../../../messages.js";
8
- import { g as j } from "../../../../../../chunks/utils.js";
9
- import { jsx as r } from "react/jsx-runtime";
10
- const Q = /* @__PURE__ */ I(({
11
- className: s,
12
- description: c,
13
- isAiSuggestionApplied: m,
14
- disableForm: d,
7
+ import { g as B } from "../../../../../../chunks/utils.js";
8
+ import { jsx as t } from "react/jsx-runtime";
9
+ const H = /* @__PURE__ */ w(({
10
+ className: i,
11
+ description: d,
12
+ isAiSuggestionApplied: c,
13
+ disableForm: m,
15
14
  fieldNamePrefix: f,
16
- label: n,
15
+ label: l,
17
16
  onValueEdited: u,
18
- portalElement: p,
19
- updateModePrefix: h
20
- }, D) => {
21
- const o = `${h ?? f}.value`, e = z(), {
22
- values: g,
17
+ portalElement: h,
18
+ updateModePrefix: p
19
+ }, g) => {
20
+ const r = `${p ?? f}.value`, e = V(), {
21
+ values: D,
23
22
  setFieldTouched: M,
24
- setFieldValue: k
25
- } = A(), {
26
- localTimezone: v
27
- } = $(e.locale), i = C(g, o), b = N(() => B(i), [i]), F = {
23
+ setFieldValue: v
24
+ } = A(), s = I(D, r), b = S(() => N(s), [s]), k = {
28
25
  clearDatePickerAriaLabel: e.formatMessage(a.clearSelectedDate),
29
26
  nextMonthAriaLabel: e.formatMessage(a.switchToNextMonth),
30
27
  openCalendarDropdownAriaLabel: e.formatMessage(a.openCalendar),
31
28
  previousMonthAriaLabel: e.formatMessage(a.switchToNextMonth)
32
- }, P = (t) => {
33
- const l = O(t, v);
34
- k(o, l), u();
29
+ }, C = (o) => {
30
+ const n = O(o);
31
+ v(r, n), u();
35
32
  }, x = () => {
36
- M(o, !0);
33
+ M(r, !0);
37
34
  };
38
- return /* @__PURE__ */ r("div", {
39
- "data-testid": `${n}-field`,
40
- children: /* @__PURE__ */ r(T, {
35
+ return /* @__PURE__ */ t("div", {
36
+ "data-testid": `${l}-field`,
37
+ children: /* @__PURE__ */ t(L, {
41
38
  locale: e.locale,
42
- children: /* @__PURE__ */ r(w, {
43
- name: o,
39
+ children: /* @__PURE__ */ t(T, {
40
+ name: r,
44
41
  children: ({
45
- field: t,
46
- meta: l
47
- }) => /* @__PURE__ */ r(V, {
48
- ...t,
49
- ...F,
50
- ref: D,
42
+ field: o,
43
+ meta: n
44
+ }) => /* @__PURE__ */ t(P, {
45
+ ...o,
46
+ ...k,
47
+ ref: g,
51
48
  calendarAriaLabel: e.formatMessage(a.selectDate),
52
- className: s,
53
- error: l.error,
54
- isDisabled: d,
55
- label: j(n, c, m, "span"),
49
+ className: i,
50
+ error: n.error,
51
+ isDisabled: m,
52
+ label: B(l, d, c, "span"),
56
53
  onBlur: () => x(),
57
- onChange: (L) => P(L),
58
- portalElement: p,
54
+ onChange: (F) => C(F),
55
+ portalElement: h,
59
56
  value: b
60
57
  })
61
58
  })
@@ -63,6 +60,6 @@ const Q = /* @__PURE__ */ I(({
63
60
  });
64
61
  });
65
62
  export {
66
- Q as MetadataDateField,
67
- Q as default
63
+ H as MetadataDateField,
64
+ H as default
68
65
  };
@@ -1,8 +1,9 @@
1
1
  import "@box/blueprint-web-assets/icons/Logo";
2
2
  import "../interactive-text/interactive-text.js";
3
- import { g as i, t as g } from "../../../../chunks/utils.js";
3
+ import { g as m, t as p } from "../../../../chunks/utils.js";
4
+ import "../../utils/convertDate.js";
4
5
  import "react/jsx-runtime";
5
6
  export {
6
- i as getFieldLabel,
7
- g as tryParseDateSuggestion
7
+ m as getFieldLabel,
8
+ p as tryParseDateSuggestion
8
9
  };
@@ -1,30 +1,31 @@
1
1
  import "../../../../../../styles/metadata-instance-entry.css";
2
2
  import { Text as f } from "@box/blueprint-web";
3
3
  import { FormattedDate as y } from "react-intl";
4
- import l from "../../../interactive-text/interactive-text.js";
5
- import { MetadataEntryDisplay as p } from "./metadata-entry-display.js";
6
- import { jsxs as u, jsx as r } from "react/jsx-runtime";
7
- const x = "_metadataInstanceEntry_gwoh6_1", h = {
8
- metadataInstanceEntry: x
9
- }, T = ({
4
+ import { convertISOStringToUTCDate as l } from "../../../../utils/convertDate.js";
5
+ import p from "../../../interactive-text/interactive-text.js";
6
+ import { MetadataEntryDisplay as u } from "./metadata-entry-display.js";
7
+ import { jsxs as x, jsx as r } from "react/jsx-runtime";
8
+ const g = "_metadataInstanceEntry_gwoh6_1", h = {
9
+ metadataInstanceEntry: g
10
+ }, V = ({
10
11
  description: n,
11
12
  name: a,
12
13
  shouldHideEmptyValues: i,
13
- type: e,
14
+ type: o,
14
15
  value: t,
15
16
  taxonomyNodeFetcher: m,
16
- taxonomyKey: s,
17
- scope: c
17
+ taxonomyKey: c,
18
+ scope: s
18
19
  }) => {
19
- const o = (() => {
20
+ const e = (() => {
20
21
  if (typeof t == "number")
21
22
  return t.toString();
22
23
  if (!t)
23
24
  return null;
24
25
  if (Array.isArray(t))
25
26
  return t.join(", ");
26
- if (e === "date" && typeof t == "string") {
27
- const d = new Date(t);
27
+ if (o === "date" && typeof t == "string") {
28
+ const d = l(t);
28
29
  return /* @__PURE__ */ r(y, {
29
30
  day: "numeric",
30
31
  month: "long",
@@ -34,29 +35,29 @@ const x = "_metadataInstanceEntry_gwoh6_1", h = {
34
35
  }
35
36
  return t;
36
37
  })();
37
- return i && !o ? null : /* @__PURE__ */ u("div", {
38
+ return i && !e ? null : /* @__PURE__ */ x("div", {
38
39
  className: h.metadataInstanceEntry,
39
40
  children: [/* @__PURE__ */ r(f, {
40
41
  as: "p",
41
42
  color: "textOnLightSecondary",
42
43
  variant: "bodyDefaultBold",
43
- children: n ? /* @__PURE__ */ r(l, {
44
+ children: n ? /* @__PURE__ */ r(p, {
44
45
  as: "span",
45
46
  color: "textOnLightSecondary",
46
47
  tooltipText: n,
47
48
  variant: "bodyDefaultBold",
48
49
  children: a
49
50
  }) : a
50
- }), /* @__PURE__ */ r(p, {
51
- formattedValue: o,
52
- scope: c,
53
- taxonomyKey: s,
51
+ }), /* @__PURE__ */ r(u, {
52
+ formattedValue: e,
53
+ scope: s,
54
+ taxonomyKey: c,
54
55
  taxonomyNodeFetcher: m,
55
- type: e,
56
+ type: o,
56
57
  value: t
57
58
  })]
58
59
  });
59
60
  };
60
61
  export {
61
- T as MetadataInstanceEntry
62
+ V as MetadataInstanceEntry
62
63
  };
@@ -0,0 +1,35 @@
1
+ import { parseDate as O } from "@box/blueprint-web";
2
+ const T = 1e3, u = 60 * T, f = /\d{4}-\d{2}-\d{2}/, a = /T\d{2}:\d{2}:\d{2}(\.\d{1,3})?/, _ = /(Z$)/, S = /(?:[+-](?:([0-2]\d$)|([0-2]\d(?:00|30)$)|([0-2]\d:(?:00|30)$)))/, i = new RegExp(`^(${f.source})(${a.source})?(${_.source}|${S.source})?$`), d = 1, E = 2, M = 3, D = 4, m = 5, l = 6, $ = 7, N = 8;
3
+ function I(n) {
4
+ if (!i.test(n))
5
+ return n;
6
+ const t = n.split(i), e = t[d], c = t[E], r = t[M], o = t[D];
7
+ let s = e;
8
+ return c ? s = e + c : s += "T00:00:00", r || (s += ".000"), o ? t[m] ? n : t[l] ? `${s + o}:00` : t[$] ? `${s + o.substring(0, 3)}:${o.substring(3)}` : (t[N], n) : `${s}Z`;
9
+ }
10
+ function p(n) {
11
+ const t = new Date(I(n)), e = t.getTime(), r = t.getTimezoneOffset() * u, o = e + r;
12
+ return new Date(o);
13
+ }
14
+ function C(n) {
15
+ let t = "";
16
+ if (n) {
17
+ const e = n.toString();
18
+ t = I(e);
19
+ }
20
+ return t;
21
+ }
22
+ function L(n) {
23
+ try {
24
+ const t = n.split("T")[0];
25
+ return O(t);
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
30
+ export {
31
+ C as convertCalendarDateToISOString,
32
+ p as convertISOStringToUTCDate,
33
+ I as convertISOStringtoRFC3339String,
34
+ L as convertIsoStringToCalendarDate
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.74.4",
3
+ "version": "0.74.5",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.5",
6
6
  "@box/blueprint-web": "^7.30.3",
@@ -53,5 +53,5 @@
53
53
  "**/*.css"
54
54
  ],
55
55
  "license": "SEE LICENSE IN LICENSE",
56
- "gitHead": "ffcc1cbaa370936326a1cbb15687343c1c7638dd"
56
+ "gitHead": "358e36d5987fed9a870896011a51539da15931c9"
57
57
  }
@@ -3,7 +3,7 @@ export declare const ComboboxWithApiPagination: import("react").ForwardRefExotic
3
3
  defaultFetcher(input: import("./types").PaginationQueryInput): Promise<import("./types").FetcherResponse<BaseOptionType>>;
4
4
  placeholder?: string;
5
5
  includeTextInputOption?: boolean;
6
- noResultMessage?: string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
6
+ noResultMessage?: import("react").ReactElement | string;
7
7
  onInputValueChange?: (inputValue: string) => void;
8
8
  multiselect?: boolean;
9
9
  onValueChange?: (selectedOptions: BaseOptionType[]) => void;
@@ -1,6 +1,6 @@
1
1
  export declare const FilterDropdownMenu: {
2
2
  Root: {
3
- (props: import("@ariakit/react").ComboboxProviderProps<import("@ariakit/core/cjs/combobox/combobox-store").ComboboxStoreSelectedValue>): import("react/jsx-runtime").JSX.Element;
3
+ (props: import("@ariakit/react").ComboboxProviderProps): import("react/jsx-runtime").JSX.Element;
4
4
  displayName: string;
5
5
  };
6
6
  Trigger: {
@@ -8,19 +8,19 @@ export declare const FilterDropdownMenu: {
8
8
  displayName: string;
9
9
  };
10
10
  Content: {
11
- (props: import("@ariakit/react").MenuProps<"div">): import("react/jsx-runtime").JSX.Element;
11
+ (props: import("@ariakit/react").MenuProps): import("react/jsx-runtime").JSX.Element;
12
12
  displayName: string;
13
13
  };
14
14
  Item: {
15
- (props: import("@ariakit/react").ComboboxItemProps<"div">): import("react/jsx-runtime").JSX.Element;
15
+ (props: import("@ariakit/react").ComboboxItemProps): import("react/jsx-runtime").JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  List: {
19
- (props: import("@ariakit/react").ComboboxListProps<"div">): import("react/jsx-runtime").JSX.Element;
19
+ (props: import("@ariakit/react").ComboboxListProps): import("react/jsx-runtime").JSX.Element;
20
20
  displayName: string;
21
21
  };
22
22
  Search: {
23
- (props: import("@ariakit/react").ComboboxProps<"input">): import("react/jsx-runtime").JSX.Element;
23
+ (props: import("@ariakit/react").ComboboxProps): import("react/jsx-runtime").JSX.Element;
24
24
  displayName: string;
25
25
  };
26
26
  EmptyState: {
@@ -1,3 +1,3 @@
1
1
  import { type Labelable, type TextProps } from '@box/blueprint-web';
2
- export declare const getFieldLabel: (fieldName: string, fieldDescription: string | undefined, isAiSuggestionApplied?: boolean, as?: TextProps['as']) => Labelable['label'];
2
+ export declare const getFieldLabel: (fieldName: string, fieldDescription: string | undefined, isAiSuggestionApplied?: boolean, as?: TextProps["as"]) => Labelable["label"];
3
3
  export declare const tryParseDateSuggestion: (suggestedDate: string) => string;
@@ -1,2 +1,2 @@
1
1
  import { type AutofillContextProviderProps } from './autofill-context';
2
- export declare function withApiWrapper<P extends object>(WrappedComponent: React.ComponentType<P>): ({ isAiSuggestionsFeatureEnabled, fetchSuggestions, ...props }: P & Omit<AutofillContextProviderProps, 'children'>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare function withApiWrapper<P extends object>(WrappedComponent: React.ComponentType<P>): ({ isAiSuggestionsFeatureEnabled, fetchSuggestions, ...props }: P & Omit<AutofillContextProviderProps, "children">) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import { type CalendarDate } from '@box/blueprint-web';
2
+ export type CalendarDateType = InstanceType<typeof CalendarDate>;
3
+ /**
4
+ * Will convert ISO8601-compatible dates (with zone designators)
5
+ * 2018-06-13T00:00:00.000-0500
6
+ * or
7
+ * 2018-06-13T00:00:00.000-05
8
+ *
9
+ * to
10
+ * 2018-06-13T00:00:00.000-05:00
11
+ *
12
+ * Equivalent formats between the two (e.g., uzing 'Z') will remain unchanged.
13
+ * If the date format cannot be converted, it will pass along the existing value
14
+ *
15
+ * @public
16
+ * @param isoString - the date to be converted
17
+ * @returns converted date format, if applicable
18
+ */
19
+ export declare function convertISOStringtoRFC3339String(isoString: string): string;
20
+ /**
21
+ * Will convert
22
+ * 2018-06-13T00:00:00.000Z
23
+ * to
24
+ * 2018-06-13T07:00:00.000Z
25
+ *
26
+ * This is the opposite of convertDateToUnixMidnightTime
27
+ *
28
+ * @public
29
+ * @param isoString - ISO string in UTC time zone
30
+ * @returns date in UTC time zone
31
+ */
32
+ export declare function convertISOStringToUTCDate(isoString: string): Date;
33
+ export declare function convertCalendarDateToISOString(datePickerValue: CalendarDateType): string;
34
+ export declare function convertIsoStringToCalendarDate(isoString: string): CalendarDateType;
@@ -1,16 +0,0 @@
1
- import { parseAbsoluteToLocal as r, toCalendarDate as n, toZoned as a } from "@box/blueprint-web";
2
- const i = (e) => {
3
- try {
4
- const o = r(e);
5
- return n(o);
6
- } catch {
7
- return null;
8
- }
9
- }, u = (e, o) => {
10
- let t = "";
11
- return e && (t = a(e, o).toAbsoluteString()), t;
12
- };
13
- export {
14
- i as convertToDatePickerValue,
15
- u as convertToFormikValue
16
- };
@@ -1,3 +0,0 @@
1
- import { type CalendarDateType } from './types';
2
- export declare const convertToDatePickerValue: (formikValue: string) => import("@internationalized/date").CalendarDate;
3
- export declare const convertToFormikValue: (datePickerValue: CalendarDateType, localTimezone: string) => string;