@ultraviolet/ui 3.0.0 → 3.1.1

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,11 +1,12 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
3
  import { ArrowDownIcon } from "@ultraviolet/icons";
4
4
  import { assignInlineVars } from "@vanilla-extract/dynamic";
5
5
  import { useReducer, Children } from "react";
6
6
  import { useTheme } from "../../theme/ThemeProvider.js";
7
7
  import { CopyButton } from "../CopyButton/index.js";
8
8
  import { Expandable } from "../Expandable/index.js";
9
+ import { Label } from "../Label/index.js";
9
10
  import { Stack } from "../Stack/index.js";
10
11
  import { Text } from "../Text/index.js";
11
12
  import { snippetContainer, stackStyle, buttonContainer, showMoreContainer, showMoreButton, centeredText, animatedArrowIcon, pretext, line, prefix, rowsVar } from "./styles.css.js";
@@ -55,7 +56,10 @@ const Snippet = ({
55
56
  rows = 4,
56
57
  noExpandable = false,
57
58
  onCopy,
58
- style
59
+ style,
60
+ helper,
61
+ label,
62
+ labelDescription
59
63
  }) => {
60
64
  const theme = useTheme();
61
65
  const [showMore, setShowMore] = useReducer(
@@ -67,81 +71,85 @@ const Snippet = ({
67
71
  const multiline = numberOfLines > 1;
68
72
  const hasShowMoreButton = numberOfLines > rows && multiline && !noExpandable;
69
73
  const minHeight = rows * Number.parseFloat(theme.typography.code.lineHeight) * 16 + Number.parseFloat(theme.space[4]) * 16;
70
- return /* @__PURE__ */ jsx(
71
- "div",
72
- {
73
- className: `${className ? `${className} ` : ""}${snippetContainer[multiline ? "multiline" : "oneLine"]}`,
74
- "data-testid": dataTestId,
75
- style,
76
- children: /* @__PURE__ */ jsxs(Stack, { className: stackStyle, children: [
77
- hasShowMoreButton ? /* @__PURE__ */ jsx(Expandable, { minHeight, opened: showMore, children: /* @__PURE__ */ jsx(
78
- CodeContent,
79
- {
80
- lines,
81
- multiline,
82
- noExpandable,
83
- prefix: prefix2,
84
- rows,
85
- children
86
- }
87
- ) }) : /* @__PURE__ */ jsx(
88
- CodeContent,
89
- {
90
- lines,
91
- multiline,
92
- noExpandable,
93
- prefix: prefix2,
94
- rows,
95
- children
96
- }
97
- ),
98
- /* @__PURE__ */ jsx(
99
- "div",
100
- {
101
- className: buttonContainer[multiline && numberOfLines > 1 ? "multiline" : "oneLine"],
102
- children: /* @__PURE__ */ jsx(
103
- CopyButton,
104
- {
105
- copiedText,
106
- copyText,
107
- onCopy,
108
- sentiment: "neutral",
109
- value: children
110
- }
111
- )
112
- }
113
- ),
114
- hasShowMoreButton ? /* @__PURE__ */ jsx("div", { className: showMoreContainer[showMore ? "true" : "false"], children: /* @__PURE__ */ jsx(
115
- "button",
116
- {
117
- "aria-expanded": showMore,
118
- className: showMoreButton,
119
- onClick: setShowMore,
120
- type: "button",
121
- children: /* @__PURE__ */ jsxs(
122
- Text,
123
- {
124
- as: "span",
125
- className: centeredText,
126
- sentiment: "neutral",
127
- variant: "bodySmallStrong",
128
- children: [
129
- showMore ? hideText : showText,
130
- " ",
131
- /* @__PURE__ */ jsx(
132
- ArrowDownIcon,
133
- {
134
- className: animatedArrowIcon[showMore ? "true" : "false"]
135
- }
136
- )
137
- ]
138
- }
139
- )
140
- }
141
- ) }) : null
142
- ] })
143
- }
144
- );
74
+ return /* @__PURE__ */ jsxs(Stack, { direction: "column", gap: 1, width: "100%", children: [
75
+ label ? /* @__PURE__ */ jsx(Label, { labelDescription, children: label }) : null,
76
+ /* @__PURE__ */ jsx(
77
+ "div",
78
+ {
79
+ className: `${className ? `${className} ` : ""}${snippetContainer[multiline ? "multiline" : "oneLine"]}`,
80
+ "data-testid": dataTestId,
81
+ style,
82
+ children: /* @__PURE__ */ jsxs(Stack, { className: stackStyle, children: [
83
+ hasShowMoreButton ? /* @__PURE__ */ jsx(Expandable, { minHeight, opened: showMore, children: /* @__PURE__ */ jsx(
84
+ CodeContent,
85
+ {
86
+ lines,
87
+ multiline,
88
+ noExpandable,
89
+ prefix: prefix2,
90
+ rows,
91
+ children
92
+ }
93
+ ) }) : /* @__PURE__ */ jsx(
94
+ CodeContent,
95
+ {
96
+ lines,
97
+ multiline,
98
+ noExpandable,
99
+ prefix: prefix2,
100
+ rows,
101
+ children
102
+ }
103
+ ),
104
+ /* @__PURE__ */ jsx(
105
+ "div",
106
+ {
107
+ className: buttonContainer[multiline && numberOfLines > 1 ? "multiline" : "oneLine"],
108
+ children: /* @__PURE__ */ jsx(
109
+ CopyButton,
110
+ {
111
+ copiedText,
112
+ copyText,
113
+ onCopy,
114
+ sentiment: "neutral",
115
+ value: children
116
+ }
117
+ )
118
+ }
119
+ ),
120
+ hasShowMoreButton ? /* @__PURE__ */ jsx("div", { className: showMoreContainer[showMore ? "true" : "false"], children: /* @__PURE__ */ jsx(
121
+ "button",
122
+ {
123
+ "aria-expanded": showMore,
124
+ className: showMoreButton,
125
+ onClick: setShowMore,
126
+ type: "button",
127
+ children: /* @__PURE__ */ jsxs(
128
+ Text,
129
+ {
130
+ as: "span",
131
+ className: centeredText,
132
+ sentiment: "neutral",
133
+ variant: "bodySmallStrong",
134
+ children: [
135
+ showMore ? hideText : showText,
136
+ " ",
137
+ /* @__PURE__ */ jsx(
138
+ ArrowDownIcon,
139
+ {
140
+ className: animatedArrowIcon[showMore ? "true" : "false"]
141
+ }
142
+ )
143
+ ]
144
+ }
145
+ )
146
+ }
147
+ ) }) : null
148
+ ] })
149
+ }
150
+ ),
151
+ helper ? /* @__PURE__ */ jsx(Text, { as: "p", prominence: "weak", sentiment: "neutral", variant: "caption", children: helper }) : null
152
+ ] });
145
153
  };
146
154
  export {
147
155
  Snippet
@@ -7,15 +7,15 @@ export declare const tagInputContainer: import("@vanilla-extract/recipes").Runti
7
7
  size: {
8
8
  large: {
9
9
  padding: `calc(var(--${string}) - 1px) var(--${string})`;
10
- height: `var(--${string})`;
10
+ minHeight: `var(--${string})`;
11
11
  };
12
12
  small: {
13
13
  padding: `calc(var(--${string}) - 1px) var(--${string})`;
14
- height: `var(--${string})`;
14
+ minHeight: `var(--${string})`;
15
15
  };
16
16
  medium: {
17
17
  padding: `calc(var(--${string}) - 1px) var(--${string})`;
18
- height: `var(--${string})`;
18
+ minHeight: `var(--${string})`;
19
19
  };
20
20
  };
21
21
  }>;
@@ -26,4 +26,4 @@ export declare const TextInput: import("react").ForwardRefExoticComponent<{
26
26
  value?: string;
27
27
  defaultValue?: string;
28
28
  onChangeValue?: (value: string) => void;
29
- } & Pick<InputHTMLAttributes<HTMLInputElement>, "style" | "disabled" | "id" | "autoComplete" | "role" | "autoFocus" | "tabIndex" | "aria-atomic" | "aria-label" | "aria-labelledby" | "aria-live" | "onFocus" | "onBlur" | "onChange" | "onKeyDown" | "onKeyUp" | "name" | "placeholder" | "readOnly" | "required"> & import("react").RefAttributes<HTMLInputElement>>;
29
+ } & Pick<InputHTMLAttributes<HTMLInputElement>, "style" | "disabled" | "id" | "autoComplete" | "role" | "autoFocus" | "tabIndex" | "aria-atomic" | "aria-label" | "aria-labelledby" | "aria-live" | "onFocus" | "onBlur" | "onChange" | "onKeyDown" | "onKeyUp" | "name" | "required" | "placeholder" | "readOnly"> & import("react").RefAttributes<HTMLInputElement>>;