@galaxy-io/dls 2.13.7 → 2.14.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.
@@ -1,6 +1,6 @@
1
- import { type SpanProps } from "./Span.js";
1
+ import { type SpanPresetProps } from "./Span.js";
2
2
  /** `Span` props without `weight`: a `Bold` is always `TextWeight.MEDIUM`. */
3
- export type BoldProps = Omit<SpanProps, "weight">;
3
+ export type BoldProps = SpanPresetProps<"weight">;
4
4
  /** Medium-weight inline emphasis inside a `Text`; a `Span` preset. */
5
5
  declare const Bold: import("react").ForwardRefExoticComponent<BoldProps & import("react").RefAttributes<HTMLSpanElement>>;
6
6
  export default Bold;
@@ -1,6 +1,6 @@
1
- import { type SpanProps } from "./Span.js";
1
+ import { type SpanPresetProps } from "./Span.js";
2
2
  /** `Span` props without `isCode` and `family`: a `Code` is always inline code in mono. */
3
- export type CodeProps = Omit<SpanProps, "isCode" | "family">;
3
+ export type CodeProps = SpanPresetProps<"isCode" | "family">;
4
4
  /** Inline code inside a `Text`; a `Span` preset. */
5
5
  declare const Code: import("react").ForwardRefExoticComponent<CodeProps & import("react").RefAttributes<HTMLSpanElement>>;
6
6
  export default Code;
@@ -46,10 +46,18 @@ export interface CodeBlockProps extends AriaAttributes {
46
46
  * @default CodeBlockLanguage.PLAIN
47
47
  */
48
48
  language?: CodeBlockLanguage;
49
- /** Header text, such as a file name (`pipeline.yaml`). Defaults to the language's display name; there is none for `PLAIN`. */
49
+ /** Header text, such as a file name (`pipeline.yaml`). Defaults to the language's display name; there is none for `PLAIN`. Also names the scroll region for screen readers, with or without the header. */
50
50
  label?: string;
51
51
  /**
52
- * Show a copy button in the header that copies `content` exactly as passed.
52
+ * Draw the header row (the label and the copy button). `false` drops it, for a block whose host
53
+ * already names the code (a Widget or Drawer section titled with the file name); `canCopy` is
54
+ * ignored then. With `true` the header still shows only when it has a label or `canCopy`.
55
+ * Defaults to `true`, like Popover's `hasSurface`: a code block normally has its header.
56
+ * @default true
57
+ */
58
+ hasHeader?: boolean;
59
+ /**
60
+ * Show a copy button in the header that copies `content` exactly as passed. Ignored when `hasHeader` is `false`.
53
61
  * @default false
54
62
  */
55
63
  canCopy?: boolean;
@@ -12,7 +12,9 @@ import { cx } from "@linaria/core";
12
12
  /**
13
13
  * A read-only, multi-line code snippet: monospaced, optionally syntax-highlighted, with an
14
14
  * optional header (the language or a file name, and a copy button), optional line numbers, and a
15
- * diff mode that tints added and removed lines. Long lines scroll sideways; under a parent that
15
+ * diff mode that tints added and removed lines. The header shows when it has something to show (a
16
+ * label or `canCopy`); `hasHeader={false}` drops it for a bare block inside a host that already
17
+ * names the code. Long lines scroll sideways; under a parent that
16
18
  * caps the height (`Box maxHeight`), the header stays put and the code scrolls.
17
19
  *
18
20
  * Highlighting is lazy and optional: the server and the first client render show the code as
@@ -278,7 +280,7 @@ function Passthrough({ children }) {
278
280
  return /* @__PURE__ */ jsx(Fragment$1, { children });
279
281
  }
280
282
  /** Read-only code with lazy syntax highlighting, copy, line numbers and diff mode. */
281
- var CodeBlock = forwardRef(function CodeBlock({ content, language = "PLAIN", label, canCopy = false, hasLineNumbers = false, isDiff = false, id, className, style, ...rest }, ref) {
283
+ var CodeBlock = forwardRef(function CodeBlock({ content, language = "PLAIN", label, hasHeader = true, canCopy = false, hasLineNumbers = false, isDiff = false, id, className, style, ...rest }, ref) {
282
284
  const [highlighter, setHighlighter] = useState(null);
283
285
  useEffect(() => {
284
286
  if (language === "PLAIN") return;
@@ -295,7 +297,7 @@ var CodeBlock = forwardRef(function CodeBlock({ content, language = "PLAIN", lab
295
297
  }, [language]);
296
298
  const lines = toLines(content, isDiff);
297
299
  const resolvedLabel = label ?? CODE_BLOCK_LANGUAGE_TO_LABEL_MAP[language];
298
- const hasHeader = resolvedLabel !== "" || canCopy;
300
+ const isHeaderShown = hasHeader && (resolvedLabel !== "" || canCopy);
299
301
  const variables = { [GUTTER_DIGITS_VARIABLE]: String(String(lines.length).length) };
300
302
  /** The lines, with token spans when `rows` (one hast row per line) are given. */
301
303
  const renderLines = (rows) => lines.map((line, index) => {
@@ -324,7 +326,7 @@ var CodeBlock = forwardRef(function CodeBlock({ content, language = "PLAIN", lab
324
326
  ...variables,
325
327
  ...style
326
328
  },
327
- children: [hasHeader && /* @__PURE__ */ jsxs("div", {
329
+ children: [isHeaderShown && /* @__PURE__ */ jsxs("div", {
328
330
  className: HEADER_CSS,
329
331
  children: [/* @__PURE__ */ jsx(Text, {
330
332
  as: "span",
@@ -1,6 +1,6 @@
1
- import { type SpanProps } from "./Span.js";
1
+ import { type SpanPresetProps } from "./Span.js";
2
2
  /** `Span` props without `isSelectable`: a `Selectable` is always selectable. */
3
- export type SelectableProps = Omit<SpanProps, "isSelectable">;
3
+ export type SelectableProps = SpanPresetProps<"isSelectable">;
4
4
  /** User-selectable inline text inside a `Text`; a `Span` preset. */
5
5
  declare const Selectable: import("react").ForwardRefExoticComponent<SelectableProps & import("react").RefAttributes<HTMLSpanElement>>;
6
6
  export default Selectable;
@@ -23,7 +23,7 @@ export declare enum SpanVariant {
23
23
  }
24
24
  /** Identity map, so composites that hold a `SpanVariant` can hand it to a `Text` explicitly. */
25
25
  export declare const SPAN_VARIANT_TO_TEXT_VARIANT_MAP: Record<SpanVariant, TextVariant>;
26
- export interface SpanProps extends AriaAttributes {
26
+ interface SpanBaseProps extends AriaAttributes {
27
27
  /** The inline copy. */
28
28
  children?: ReactNode;
29
29
  /**
@@ -46,11 +46,6 @@ export interface SpanProps extends AriaAttributes {
46
46
  * @default false
47
47
  */
48
48
  isItalic?: boolean;
49
- /**
50
- * Underline.
51
- * @default false
52
- */
53
- isUnderlined?: boolean;
54
49
  /**
55
50
  * Strike through.
56
51
  * @default false
@@ -77,6 +72,41 @@ export interface SpanProps extends AriaAttributes {
77
72
  /** Inline style on the span; only for setting CSS custom properties. */
78
73
  style?: CSSProperties;
79
74
  }
75
+ /** A span that is not a tooltip trigger. */
76
+ interface SpanPlainProps {
77
+ /**
78
+ * Solid underline, for emphasis (a link is `Link`). Not with `hasTooltip`.
79
+ * @default false
80
+ */
81
+ isUnderlined?: boolean;
82
+ /**
83
+ * Marks the span as the trigger of the `Tooltip` that wraps it: a dotted underline, the `help`
84
+ * cursor, and a tab stop so the tooltip also opens on keyboard focus. Draws no tooltip itself.
85
+ * @default false
86
+ */
87
+ hasTooltip?: false;
88
+ }
89
+ /** A span that triggers the `Tooltip` around it. */
90
+ interface SpanTooltipTriggerProps {
91
+ /**
92
+ * Solid underline, for emphasis (a link is `Link`). Not with `hasTooltip`.
93
+ * @default false
94
+ */
95
+ isUnderlined?: false;
96
+ /**
97
+ * Marks the span as the trigger of the `Tooltip` that wraps it: a dotted underline, the `help`
98
+ * cursor, and a tab stop so the tooltip also opens on keyboard focus. Draws no tooltip itself.
99
+ * @default false
100
+ */
101
+ hasTooltip: boolean;
102
+ }
103
+ /** Span props. `hasTooltip` and `isUnderlined` are exclusive by type: one line under the text. */
104
+ export type SpanProps = SpanBaseProps & (SpanPlainProps | SpanTooltipTriggerProps);
105
+ /**
106
+ * `SpanProps` without the preset's fixed keys, keeping the `hasTooltip` / `isUnderlined` exclusion
107
+ * (a plain `Omit<SpanProps, K>` would flatten the union). For `Bold`, `Code` and `Selectable`.
108
+ */
109
+ export type SpanPresetProps<K extends keyof SpanBaseProps> = Omit<SpanBaseProps, K> & (SpanPlainProps | SpanTooltipTriggerProps);
80
110
  /** Inline formatting inside a `Text`: inherits everything, sets only what it is given. */
81
111
  declare const Span: import("react").ForwardRefExoticComponent<SpanProps & import("react").RefAttributes<HTMLSpanElement>>;
82
112
  export default Span;
package/dist/text/Span.js CHANGED
@@ -93,16 +93,22 @@ var SELECTABLE_CSS = "gx-Span-SELECTABLE_CSS-s1sv685f";
93
93
  var CODE_CSS = "gx-Span-CODE_CSS-c1acyl4p";
94
94
  /** Declared after the variant map so `hex` wins over it. */
95
95
  var HEX_CSS = "gx-Span-HEX_CSS-h2m0mhq";
96
+ /** `hasTooltip`: a dotted `UNDERLINE` at half the text color, full color on hover and keyboard focus. */
97
+ var HAS_TOOLTIP_CSS = "gx-Span-HAS_TOOLTIP_CSS-h1qnsecm";
98
+ /** `hasTooltip` with `isStrikethrough`: keeps the strike line the dotted underline would drop. */
99
+ var TOOLTIP_STRIKETHROUGH_CSS = "gx-Span-TOOLTIP_STRIKETHROUGH_CSS-t9voggt";
96
100
  /** Inline formatting inside a `Text`: inherits everything, sets only what it is given. */
97
- var Span = forwardRef(function Span({ children, variant = "INHERIT", weight, family: familyProp, isItalic = false, isUnderlined = false, isStrikethrough = false, isSelectable = false, isCode = false, hex, id, className, style, ...rest }, ref) {
101
+ var Span = forwardRef(function Span({ children, variant = "INHERIT", weight, family: familyProp, isItalic = false, isUnderlined = false, hasTooltip = false, isStrikethrough = false, isSelectable = false, isCode = false, hex, id, className, style, ...rest }, ref) {
98
102
  const family = familyProp ?? (isCode ? FontFamily.MONO : void 0);
103
+ const hasUnderline = isUnderlined && !hasTooltip;
99
104
  const variables = {};
100
105
  if (hex !== void 0) variables["--gx-span-hex"] = hex;
101
106
  return /* @__PURE__ */ jsx(Root, {
102
107
  ...rest,
103
108
  ref,
104
109
  id,
105
- className: cx(SPAN_VARIANT_TO_CSS_MAP[variant], weight !== void 0 && SPAN_WEIGHT_TO_CSS_MAP[weight], family !== void 0 && SPAN_FAMILY_TO_CSS_MAP[family], isItalic && ITALIC_CSS, isUnderlined && isStrikethrough ? UNDERLINED_STRIKETHROUGH_CSS : isUnderlined && UNDERLINED_CSS || isStrikethrough && STRIKETHROUGH_CSS, isSelectable && SELECTABLE_CSS, isCode && CODE_CSS, hex !== void 0 && HEX_CSS, className),
110
+ tabIndex: hasTooltip ? 0 : void 0,
111
+ className: cx(SPAN_VARIANT_TO_CSS_MAP[variant], weight !== void 0 && SPAN_WEIGHT_TO_CSS_MAP[weight], family !== void 0 && SPAN_FAMILY_TO_CSS_MAP[family], isItalic && ITALIC_CSS, hasUnderline && isStrikethrough ? UNDERLINED_STRIKETHROUGH_CSS : hasUnderline && UNDERLINED_CSS || isStrikethrough && STRIKETHROUGH_CSS, isSelectable && SELECTABLE_CSS, isCode && CODE_CSS, hex !== void 0 && HEX_CSS, hasTooltip && HAS_TOOLTIP_CSS, hasTooltip && isStrikethrough && TOOLTIP_STRIKETHROUGH_CSS, className),
106
112
  style: {
107
113
  ...variables,
108
114
  ...style
@@ -57,7 +57,7 @@ export declare enum TextTransform {
57
57
  }
58
58
  /** The elements `Text` may render. */
59
59
  export type TextElement = "p" | "span" | "div" | "label" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "legend" | "li";
60
- export interface TextProps extends AriaAttributes {
60
+ interface TextBaseProps extends AriaAttributes {
61
61
  /** The copy. */
62
62
  children?: ReactNode;
63
63
  /**
@@ -97,11 +97,6 @@ export interface TextProps extends AriaAttributes {
97
97
  transform?: TextTransform;
98
98
  /** Truncate to N lines with an ellipsis. `1` = single-line truncation. Needs a width-bounded parent. */
99
99
  lineClamp?: number;
100
- /**
101
- * When clamped and overflowing, hover shows the full text.
102
- * @default false
103
- */
104
- shouldTooltipOnOverflow?: boolean;
105
100
  /**
106
101
  * Prose line height (1.5) and natural wrapping for long-form copy.
107
102
  * @default false
@@ -117,11 +112,6 @@ export interface TextProps extends AriaAttributes {
117
112
  * @default false
118
113
  */
119
114
  isItalic?: boolean;
120
- /**
121
- * Underline.
122
- * @default false
123
- */
124
- isUnderlined?: boolean;
125
115
  /**
126
116
  * Strike through.
127
117
  * @default false
@@ -148,6 +138,49 @@ export interface TextProps extends AriaAttributes {
148
138
  /** Inline style on the root element; only for setting CSS custom properties. */
149
139
  style?: CSSProperties;
150
140
  }
141
+ /** Text that is not a tooltip trigger: it may underline, and may show its own cut text on hover. */
142
+ interface TextPlainProps {
143
+ /**
144
+ * When clamped and overflowing, hover shows the full text. Not with `hasTooltip`.
145
+ * @default false
146
+ */
147
+ shouldTooltipOnOverflow?: boolean;
148
+ /**
149
+ * Solid underline, for emphasis (a link is `Link`). Not with `hasTooltip`.
150
+ * @default false
151
+ */
152
+ isUnderlined?: boolean;
153
+ /**
154
+ * Marks the text as the trigger of the `Tooltip` that wraps it: a dotted underline, the `help`
155
+ * cursor, and a tab stop so the tooltip also opens on keyboard focus. Draws no tooltip itself.
156
+ * @default false
157
+ */
158
+ hasTooltip?: false;
159
+ }
160
+ /** Text that triggers the `Tooltip` around it. */
161
+ interface TextTooltipTriggerProps {
162
+ /**
163
+ * When clamped and overflowing, hover shows the full text. Not with `hasTooltip`.
164
+ * @default false
165
+ */
166
+ shouldTooltipOnOverflow?: false;
167
+ /**
168
+ * Solid underline, for emphasis (a link is `Link`). Not with `hasTooltip`.
169
+ * @default false
170
+ */
171
+ isUnderlined?: false;
172
+ /**
173
+ * Marks the text as the trigger of the `Tooltip` that wraps it: a dotted underline, the `help`
174
+ * cursor, and a tab stop so the tooltip also opens on keyboard focus. Draws no tooltip itself.
175
+ * @default false
176
+ */
177
+ hasTooltip: boolean;
178
+ }
179
+ /**
180
+ * Text props. `hasTooltip` is exclusive by type with `isUnderlined` (one line under the text) and
181
+ * with `shouldTooltipOnOverflow` (which brings its own tooltip).
182
+ */
183
+ export type TextProps = TextBaseProps & (TextPlainProps | TextTooltipTriggerProps);
151
184
  /** The text primitive: a color role, a type step, a weight and a family, all from tokens. */
152
185
  declare const Text: import("react").ForwardRefExoticComponent<TextProps & import("react").RefAttributes<HTMLElement>>;
153
186
  export default Text;
package/dist/text/Text.js CHANGED
@@ -146,7 +146,14 @@ var SINGLE_LINE_CLAMP_CSS = "gx-Text-SINGLE_LINE_CLAMP_CSS-s59kfuv";
146
146
  var MULTI_LINE_CLAMP_CSS = "gx-Text-MULTI_LINE_CLAMP_CSS-m1ukj6n6";
147
147
  /** Declared after the variant map so `hex` wins over it. */
148
148
  var HEX_CSS = "gx-Text-HEX_CSS-h1x2tvf1";
149
- var CURSOR_CSS = "gx-Text-CURSOR_CSS-c1bar1us";
149
+ /**
150
+ * `hasTooltip`: a dotted `UNDERLINE` at half the text color, full color on hover and keyboard
151
+ * focus, and the `help` cursor. Declared before `CURSOR_CSS` so an explicit `cursor` wins.
152
+ */
153
+ var HAS_TOOLTIP_CSS = "gx-Text-HAS_TOOLTIP_CSS-h1bar1us";
154
+ /** `hasTooltip` with `isStrikethrough`: keeps the strike line the dotted underline would drop. */
155
+ var TOOLTIP_STRIKETHROUGH_CSS = "gx-Text-TOOLTIP_STRIKETHROUGH_CSS-t18n1vzt";
156
+ var CURSOR_CSS = "gx-Text-CURSOR_CSS-ckhss0j";
150
157
  /** What `line-height: normal` resolves to, roughly, when a computed style reports `normal`. */
151
158
  var NORMAL_LINE_HEIGHT_RATIO = 1.2;
152
159
  /**
@@ -212,20 +219,22 @@ function OverflowTooltipText({ clamp, forwardedRef, renderRoot }) {
212
219
  });
213
220
  }
214
221
  /** The text primitive: a color role, a type step, a weight and a family, all from tokens. */
215
- var Text = forwardRef(function Text({ children, as = "p", variant = "PRIMARY", size = "BODY_MD", weight = "REGULAR", family = FontFamily.SANS, align = "left", transform = "NONE", lineClamp, shouldTooltipOnOverflow = false, isProse = false, isTabular: isTabularProp, isItalic = false, isUnderlined = false, isStrikethrough = false, isSelectable: isSelectableProp, hex, cursor, id, className, style, ...rest }, ref) {
222
+ var Text = forwardRef(function Text({ children, as = "p", variant = "PRIMARY", size = "BODY_MD", weight = "REGULAR", family = FontFamily.SANS, align = "left", transform = "NONE", lineClamp, shouldTooltipOnOverflow = false, isProse = false, isTabular: isTabularProp, isItalic = false, isUnderlined = false, hasTooltip = false, isStrikethrough = false, isSelectable: isSelectableProp, hex, cursor, id, className, style, ...rest }, ref) {
216
223
  const isTabular = isTabularProp ?? family === FontFamily.MONO;
217
224
  const isSelectable = isSelectableProp ?? isProse;
218
225
  const clamp = lineClamp !== void 0 && lineClamp > 0 ? Math.floor(lineClamp) : void 0;
219
- const hasOverflowTooltip = shouldTooltipOnOverflow && clamp !== void 0;
226
+ const hasOverflowTooltip = shouldTooltipOnOverflow && !hasTooltip && clamp !== void 0;
227
+ const hasUnderline = isUnderlined && !hasTooltip;
220
228
  const variables = {};
221
229
  if (hex !== void 0) variables["--gx-text-hex"] = hex;
222
230
  if (clamp !== void 0 && clamp > 1) variables["--gx-text-line-clamp"] = String(clamp);
223
231
  if (cursor !== void 0) variables["--gx-text-cursor"] = cursor;
224
- const rootClassName = cx(TEXT_VARIANT_TO_CSS_MAP[variant], TEXT_SIZE_TO_CSS_MAP[size], TEXT_WEIGHT_TO_CSS_MAP[weight], TEXT_FAMILY_TO_CSS_MAP[family], TEXT_ALIGN_TO_CSS_MAP[align], TEXT_TRANSFORM_TO_CSS_MAP[transform], isProse && PROSE_CSS, isSelectable ? SELECTABLE_CSS : UI_SELECT_CSS, isTabular && TABULAR_CSS, isItalic && ITALIC_CSS, isUnderlined && isStrikethrough ? UNDERLINED_STRIKETHROUGH_CSS : isUnderlined && UNDERLINED_CSS || isStrikethrough && STRIKETHROUGH_CSS, clamp === 1 && SINGLE_LINE_CLAMP_CSS, clamp !== void 0 && clamp > 1 && MULTI_LINE_CLAMP_CSS, hex !== void 0 && HEX_CSS, cursor !== void 0 && CURSOR_CSS, className);
232
+ const rootClassName = cx(TEXT_VARIANT_TO_CSS_MAP[variant], TEXT_SIZE_TO_CSS_MAP[size], TEXT_WEIGHT_TO_CSS_MAP[weight], TEXT_FAMILY_TO_CSS_MAP[family], TEXT_ALIGN_TO_CSS_MAP[align], TEXT_TRANSFORM_TO_CSS_MAP[transform], isProse && PROSE_CSS, isSelectable ? SELECTABLE_CSS : UI_SELECT_CSS, isTabular && TABULAR_CSS, isItalic && ITALIC_CSS, hasUnderline && isStrikethrough ? UNDERLINED_STRIKETHROUGH_CSS : hasUnderline && UNDERLINED_CSS || isStrikethrough && STRIKETHROUGH_CSS, hasTooltip && HAS_TOOLTIP_CSS, hasTooltip && isStrikethrough && TOOLTIP_STRIKETHROUGH_CSS, clamp === 1 && SINGLE_LINE_CLAMP_CSS, clamp !== void 0 && clamp > 1 && MULTI_LINE_CLAMP_CSS, hex !== void 0 && HEX_CSS, cursor !== void 0 && CURSOR_CSS, className);
225
233
  const renderRoot = (rootRef, handlers) => /* @__PURE__ */ jsx(Root, {
226
234
  ...rest,
227
235
  ...handlers,
228
236
  as,
237
+ tabIndex: hasTooltip ? 0 : void 0,
229
238
  ref: rootRef,
230
239
  id,
231
240
  className: rootClassName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxy-io/dls",
3
- "version": "2.13.7",
3
+ "version": "2.14.0",
4
4
  "description": "Galaxy Design Language System",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",