@box/content-field 2.1.34 → 2.1.36

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,39 +1 @@
1
- import { useBlueprintModernization as e } from "@box/blueprint-web";
2
- import { FileDefault as t, Folder as n } from "@box/blueprint-web-assets/icons/Fill";
3
- import { Space4 as r, Space6 as i, bpSpace040 as a, bpSpace060 as o } from "@box/blueprint-web-assets/tokens/tokens";
4
- import { createElement as s } from "react";
5
- import { FileVariable as c, FolderVariable as l } from "@box/blueprint-web-assets/icons/Content";
6
- import { jsx as u } from "react/jsx-runtime";
7
- import '../styles/content-field-icon.css';var d = {
8
- contentFieldWrapper: "_contentFieldWrapper_hg8tt_1",
9
- contentField: "_contentField_hg8tt_1",
10
- inlineError: "_inlineError_hg8tt_64",
11
- contentButton: "_contentButton_hg8tt_68",
12
- error: "_error_hg8tt_82",
13
- hasSelection: "_hasSelection_hg8tt_86",
14
- disabled: "_disabled_hg8tt_99",
15
- labelWrapper: "_labelWrapper_hg8tt_116",
16
- contentLabel: "_contentLabel_hg8tt_122",
17
- variable: "_variable_hg8tt_127",
18
- variableError: "_variableError_hg8tt_131",
19
- circledIconContainer: "_circledIconContainer_hg8tt_135",
20
- clearButton: "_clearButton_hg8tt_146"
21
- }, f = ({ icon: t }) => {
22
- let { enableModernizedComponents: n } = e();
23
- return /*#__PURE__*/ s(t, {
24
- role: "presentation",
25
- height: n ? o : i,
26
- width: n ? o : i
27
- });
28
- }, p = ({ icon: t }) => {
29
- let { enableModernizedComponents: n } = e();
30
- return /* @__PURE__ */ u("div", {
31
- className: d.circledIconContainer,
32
- children: /*#__PURE__*/ s(t, {
33
- role: "presentation",
34
- height: n ? a : r,
35
- width: n ? a : r
36
- })
37
- });
38
- }, m = () => /* @__PURE__ */ u(p, { icon: n }), h = () => /* @__PURE__ */ u(p, { icon: t }), g = () => /* @__PURE__ */ u(f, { icon: l }), _ = () => /* @__PURE__ */ u(f, { icon: c });
39
- export { _ as a, f as i, h as n, g as o, m as r, d as s, p as t };
1
+ import{useBlueprintModernization}from"@box/blueprint-web";import{FileDefault,Folder}from"@box/blueprint-web-assets/icons/Fill";import{Space4,Space6,bpSpace040,bpSpace060}from"@box/blueprint-web-assets/tokens/tokens";import{createElement}from"react";import{FileVariable,FolderVariable}from"@box/blueprint-web-assets/icons/Content";import{jsx}from"react/jsx-runtime";import '../styles/content-field-icon.css';var content_field_module_default={contentFieldWrapper:`_contentFieldWrapper_hg8tt_1`,contentField:`_contentField_hg8tt_1`,inlineError:`_inlineError_hg8tt_64`,contentButton:`_contentButton_hg8tt_68`,error:`_error_hg8tt_82`,hasSelection:`_hasSelection_hg8tt_86`,disabled:`_disabled_hg8tt_99`,labelWrapper:`_labelWrapper_hg8tt_116`,contentLabel:`_contentLabel_hg8tt_122`,variable:`_variable_hg8tt_127`,variableError:`_variableError_hg8tt_131`,circledIconContainer:`_circledIconContainer_hg8tt_135`,clearButton:`_clearButton_hg8tt_146`},ContentFieldIcon=({icon})=>{let{enableModernizedComponents}=useBlueprintModernization();return createElement(icon,{role:`presentation`,height:enableModernizedComponents?bpSpace060:Space6,width:enableModernizedComponents?bpSpace060:Space6})},ContentFieldCircledIcon=({icon})=>{let{enableModernizedComponents}=useBlueprintModernization();return jsx(`div`,{className:content_field_module_default.circledIconContainer,children:createElement(icon,{role:`presentation`,height:enableModernizedComponents?bpSpace040:Space4,width:enableModernizedComponents?bpSpace040:Space4})})},ContentFieldFolderIcon=()=>jsx(ContentFieldCircledIcon,{icon:Folder}),ContentFieldFileIcon=()=>jsx(ContentFieldCircledIcon,{icon:FileDefault}),ContentFieldVariableFolderIcon=()=>jsx(ContentFieldIcon,{icon:FolderVariable}),ContentFieldVariableFileIcon=()=>jsx(ContentFieldIcon,{icon:FileVariable});export{ContentFieldVariableFileIcon as a,ContentFieldIcon as i,ContentFieldFileIcon as n,ContentFieldVariableFolderIcon as o,ContentFieldFolderIcon as r,content_field_module_default as s,ContentFieldCircledIcon as t};
package/dist/esm/index.js CHANGED
@@ -1,2 +1 @@
1
- import { ContentField as e } from "./lib/content-field.js";
2
- export { e as ContentField };
1
+ import{ContentField}from"./lib/content-field.js";export{ContentField};
@@ -1,2 +1 @@
1
- import { a as e, i as t, n, o as r, r as i, t as a } from "../../chunks/content-field-icon.js";
2
- export { a as ContentFieldCircledIcon, n as ContentFieldFileIcon, i as ContentFieldFolderIcon, t as ContentFieldIcon, e as ContentFieldVariableFileIcon, r as ContentFieldVariableFolderIcon };
1
+ import{a as ContentFieldVariableFileIcon,i as ContentFieldIcon,n as ContentFieldFileIcon,o as ContentFieldVariableFolderIcon,r as ContentFieldFolderIcon,t as ContentFieldCircledIcon}from"../../chunks/content-field-icon.js";export{ContentFieldCircledIcon,ContentFieldFileIcon,ContentFieldFolderIcon,ContentFieldIcon,ContentFieldVariableFileIcon,ContentFieldVariableFolderIcon};
@@ -1,79 +1 @@
1
- import { a as e, i as t, n, o as r, r as i, s as a } from "../../chunks/content-field-icon.js";
2
- import { useContentFieldTooltip as o } from "./hooks/useContentFieldTooltip.js";
3
- import s from "./messages.js";
4
- import { Button as c } from "@ariakit/react";
5
- import { InlineError as l, Text as u, useBlueprintModernization as d, useUniqueId as f } from "@box/blueprint-web";
6
- import { XMark as p } from "@box/blueprint-web-assets/icons/Fill";
7
- import { Space6 as m, bpSpace040 as h } from "@box/blueprint-web-assets/tokens/tokens";
8
- import g from "clsx";
9
- import { forwardRef as _, useRef as v } from "react";
10
- import { useIntl as y } from "react-intl";
11
- import { jsx as b, jsxs as x } from "react/jsx-runtime";
12
- var S = (e) => e?.type === "variable", C = ({ icon: a, variant: o, isVariableWithTitle: s }) => a ? /* @__PURE__ */ b(t, { icon: a }) : b(s ? o === "file" ? e : r : o === "file" ? n : i, {}), w = /*#__PURE__*/ _(({ icon: e, placeholder: t, onClick: n, onClear: r, title: i, error: _, clearButtonRef: w, disabled: T = !1, variant: E = "folder", triggerRef: D, ...O }, k) => {
13
- let A = y(), { enableModernizedComponents: j } = d(), { titleValue: M } = i ?? {}, N = v(null), P = M ?? t, { TooltipComponent: F, tooltipProps: I } = o(N, i), L = (e) => {
14
- N.current?.focus(), r(e);
15
- }, R = f("inline-error-"), z = S(i) && !!M, B = _ ? "error" : "standard";
16
- return /* @__PURE__ */ x("div", {
17
- ref: k,
18
- className: a.contentFieldWrapper,
19
- "data-modern": j,
20
- children: [/* @__PURE__ */ x("div", {
21
- className: a.contentField,
22
- children: [/* @__PURE__ */ b(F, {
23
- ...I,
24
- variant: B,
25
- children: /* @__PURE__ */ x(c, {
26
- ref: D,
27
- "aria-describedby": R,
28
- className: g(a.contentButton, {
29
- [a.hasSelection]: i,
30
- [a.error]: !!_,
31
- [a.disabled]: T
32
- }),
33
- disabled: T,
34
- onClick: n,
35
- type: "button",
36
- ...O,
37
- children: [/* @__PURE__ */ b(C, {
38
- icon: e,
39
- isVariableWithTitle: z,
40
- variant: E
41
- }), /* @__PURE__ */ b("div", {
42
- className: a.labelWrapper,
43
- children: /* @__PURE__ */ b(u, {
44
- ref: N,
45
- as: "span",
46
- className: g(a.contentLabel, {
47
- [a.variable]: z,
48
- [a.variableError]: z && _
49
- }),
50
- variant: z ? "bodyDefaultBold" : "bodyDefault",
51
- children: P
52
- })
53
- })]
54
- })
55
- }), M && /* @__PURE__ */ b(c, {
56
- ref: w,
57
- "aria-label": A.formatMessage(s.clearButtonLabel),
58
- className: g(a.clearButton, {
59
- [a.hasSelection]: M,
60
- [a.error]: !!_,
61
- [a.disabled]: T
62
- }),
63
- disabled: T,
64
- onClick: L,
65
- type: "button",
66
- children: /* @__PURE__ */ b(p, {
67
- height: j ? h : m,
68
- role: "presentation",
69
- width: j ? h : m
70
- })
71
- })]
72
- }), /* @__PURE__ */ b(l, {
73
- className: a.inlineError,
74
- id: R,
75
- children: _
76
- })]
77
- });
78
- });
79
- export { w as ContentField };
1
+ import{a as ContentFieldVariableFileIcon,i as ContentFieldIcon,n as ContentFieldFileIcon,o as ContentFieldVariableFolderIcon,r as ContentFieldFolderIcon,s as content_field_module_default}from"../../chunks/content-field-icon.js";import{useContentFieldTooltip}from"./hooks/useContentFieldTooltip.js";import messages_default from"./messages.js";import{Button}from"@ariakit/react";import{InlineError,Text,useBlueprintModernization,useUniqueId}from"@box/blueprint-web";import{XMark}from"@box/blueprint-web-assets/icons/Fill";import{Space6,bpSpace040}from"@box/blueprint-web-assets/tokens/tokens";import clsx from"clsx";import{forwardRef,useRef}from"react";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";var isVariable=title=>title?.type===`variable`,ContentIcon=({icon,variant,isVariableWithTitle})=>icon?jsx(ContentFieldIcon,{icon}):jsx(isVariableWithTitle?variant===`file`?ContentFieldVariableFileIcon:ContentFieldVariableFolderIcon:variant===`file`?ContentFieldFileIcon:ContentFieldFolderIcon,{}),ContentField=forwardRef(({icon,placeholder,onClick,onClear,title,error,clearButtonRef,disabled=!1,variant=`folder`,triggerRef,...rest},forwardedRef)=>{let intl=useIntl(),{enableModernizedComponents}=useBlueprintModernization(),{titleValue}=title??{},labelRef=useRef(null),textValue=titleValue??placeholder,{TooltipComponent,tooltipProps}=useContentFieldTooltip(labelRef,title),handleOnClickClearButton=event=>{labelRef.current?.focus(),onClear(event)},inlineErrorId=useUniqueId(`inline-error-`),isVariableWithTitle=isVariable(title)&&!!titleValue,tooltipVariant=error?`error`:`standard`;return jsxs(`div`,{ref:forwardedRef,className:content_field_module_default.contentFieldWrapper,"data-modern":enableModernizedComponents,children:[jsxs(`div`,{className:content_field_module_default.contentField,children:[jsx(TooltipComponent,{...tooltipProps,variant:tooltipVariant,children:jsxs(Button,{ref:triggerRef,"aria-describedby":inlineErrorId,className:clsx(content_field_module_default.contentButton,{[content_field_module_default.hasSelection]:title,[content_field_module_default.error]:!!error,[content_field_module_default.disabled]:disabled}),disabled,onClick,type:`button`,...rest,children:[jsx(ContentIcon,{icon,isVariableWithTitle,variant}),jsx(`div`,{className:content_field_module_default.labelWrapper,children:jsx(Text,{ref:labelRef,as:`span`,className:clsx(content_field_module_default.contentLabel,{[content_field_module_default.variable]:isVariableWithTitle,[content_field_module_default.variableError]:isVariableWithTitle&&error}),variant:isVariableWithTitle?`bodyDefaultBold`:`bodyDefault`,children:textValue})})]})}),titleValue&&jsx(Button,{ref:clearButtonRef,"aria-label":intl.formatMessage(messages_default.clearButtonLabel),className:clsx(content_field_module_default.clearButton,{[content_field_module_default.hasSelection]:titleValue,[content_field_module_default.error]:!!error,[content_field_module_default.disabled]:disabled}),disabled,onClick:handleOnClickClearButton,type:`button`,children:jsx(XMark,{height:enableModernizedComponents?bpSpace040:Space6,role:`presentation`,width:enableModernizedComponents?bpSpace040:Space6})})]}),jsx(InlineError,{className:content_field_module_default.inlineError,id:inlineErrorId,children:error})]})});export{ContentField};
@@ -1,15 +1 @@
1
- import { Tooltip as e, useFullTextTooltip as t } from "@box/blueprint-web";
2
- var n = (n, r) => {
3
- let { Wrapper: i, wrapperProps: a } = t({
4
- ref: n,
5
- textValue: r?.titleValue
6
- }), o = r?.type === "variable";
7
- return {
8
- TooltipComponent: o ? e : i,
9
- tooltipProps: {
10
- content: o ? r?.technicalName : r?.titleValue,
11
- wrapperProps: a
12
- }
13
- };
14
- };
15
- export { n as useContentFieldTooltip };
1
+ import{Tooltip,useFullTextTooltip}from"@box/blueprint-web";var useContentFieldTooltip=(ref,title)=>{let{Wrapper:FullTextTooltip,wrapperProps}=useFullTextTooltip({ref,textValue:title?.titleValue}),isVariable=title?.type===`variable`;return{TooltipComponent:isVariable?Tooltip:FullTextTooltip,tooltipProps:{content:isVariable?title?.technicalName:title?.titleValue,wrapperProps}}};export{useContentFieldTooltip};
@@ -1,6 +1 @@
1
- import { defineMessages as e } from "react-intl";
2
- var t = e({ clearButtonLabel: {
3
- id: "contentField.clearButtonLabel",
4
- defaultMessage: "Clear"
5
- } });
6
- export { t as default };
1
+ import{defineMessages}from"react-intl";var messages_default=defineMessages({clearButtonLabel:{id:`contentField.clearButtonLabel`,defaultMessage:`Clear`}});export{messages_default as default};
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@box/content-field",
3
- "version": "2.1.34",
3
+ "version": "2.1.36",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@ariakit/react": "^0.4.21",
7
- "@box/blueprint-web": "^16.13.0",
8
- "@box/blueprint-web-assets": "^5.5.9",
7
+ "@box/blueprint-web": "^16.13.2",
8
+ "@box/blueprint-web-assets": "^5.5.11",
9
9
  "react": "^18.0.0",
10
10
  "react-dom": "^18.0.0",
11
11
  "react-intl": "^6.4.2"
12
12
  },
13
13
  "devDependencies": {
14
- "@box/blueprint-web": "^16.13.0",
15
- "@box/blueprint-web-assets": "^5.5.9",
16
- "@box/eslint-plugin-blueprint": "2.1.10",
17
- "@box/storybook-utils": "1.1.33",
14
+ "@box/blueprint-web": "^16.13.2",
15
+ "@box/blueprint-web-assets": "^5.5.11",
16
+ "@box/eslint-plugin-blueprint": "2.1.11",
17
+ "@box/storybook-utils": "1.1.35",
18
18
  "@testing-library/react": "^15.0.6",
19
19
  "react-intl": "^6.4.2"
20
20
  },