@galaxy-io/dls 2.0.2 → 2.1.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.
@@ -12,12 +12,28 @@ export declare enum ThemeSwitcherSize {
12
12
  /** 40px control. */
13
13
  X_LARGE = "X_LARGE"
14
14
  }
15
+ /** Surface set; ThemeSwitcher passes the step to ToggleInput. */
16
+ export declare enum ThemeSwitcherVariant {
17
+ /** `background.base`. */
18
+ BASE = "BASE",
19
+ /** `background.primary`. The default. */
20
+ PRIMARY = "PRIMARY",
21
+ /** `background.secondary`. */
22
+ SECONDARY = "SECONDARY",
23
+ /** `background.tertiary`. */
24
+ TERTIARY = "TERTIARY"
25
+ }
15
26
  export interface ThemeSwitcherProps extends AriaAttributes {
16
27
  /**
17
28
  * Control rung: 20 / 24 / 32 / 36 / 40px tall.
18
29
  * @default ThemeSwitcherSize.MEDIUM
19
30
  */
20
31
  size?: ThemeSwitcherSize;
32
+ /**
33
+ * Track fill, one surface step.
34
+ * @default ThemeSwitcherVariant.PRIMARY
35
+ */
36
+ variant?: ThemeSwitcherVariant;
21
37
  /**
22
38
  * Show only the icons; each segment's name moves to its `aria-label` and tooltip. For tight spots such as a sidebar footer or a user menu.
23
39
  * @default false
@@ -1,6 +1,6 @@
1
1
  import { GalaxyTheme } from "./enums.js";
2
2
  import { useGalaxyTheme } from "./useGalaxyTheme.js";
3
- import ToggleInput, { ToggleInputSize } from "../inputs/ToggleInput.js";
3
+ import ToggleInput, { ToggleInputSize, ToggleInputVariant } from "../inputs/ToggleInput.js";
4
4
  import { forwardRef } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { MonitorIcon, MoonIcon, SunIcon } from "@phosphor-icons/react";
@@ -29,6 +29,18 @@ var ThemeSwitcherSize = /* @__PURE__ */ function(ThemeSwitcherSize) {
29
29
  ThemeSwitcherSize["X_LARGE"] = "X_LARGE";
30
30
  return ThemeSwitcherSize;
31
31
  }({});
32
+ /** Surface set; ThemeSwitcher passes the step to ToggleInput. */
33
+ var ThemeSwitcherVariant = /* @__PURE__ */ function(ThemeSwitcherVariant) {
34
+ /** `background.base`. */
35
+ ThemeSwitcherVariant["BASE"] = "BASE";
36
+ /** `background.primary`. The default. */
37
+ ThemeSwitcherVariant["PRIMARY"] = "PRIMARY";
38
+ /** `background.secondary`. */
39
+ ThemeSwitcherVariant["SECONDARY"] = "SECONDARY";
40
+ /** `background.tertiary`. */
41
+ ThemeSwitcherVariant["TERTIARY"] = "TERTIARY";
42
+ return ThemeSwitcherVariant;
43
+ }({});
32
44
  /** The three built-in themes, in the 1.x order, each with its glyph. */
33
45
  var THEME_SWITCHER_OPTIONS = [
34
46
  {
@@ -73,8 +85,15 @@ var THEME_SWITCHER_SIZE_TO_TOGGLE_INPUT_SIZE_MAP = {
73
85
  ["LARGE"]: ToggleInputSize.LARGE,
74
86
  ["X_LARGE"]: ToggleInputSize.X_LARGE
75
87
  };
88
+ /** ThemeSwitcher's surface step is ToggleInput's surface step. */
89
+ var THEME_SWITCHER_VARIANT_TO_TOGGLE_INPUT_VARIANT_MAP = {
90
+ ["BASE"]: ToggleInputVariant.BASE,
91
+ ["PRIMARY"]: ToggleInputVariant.PRIMARY,
92
+ ["SECONDARY"]: ToggleInputVariant.SECONDARY,
93
+ ["TERTIARY"]: ToggleInputVariant.TERTIARY
94
+ };
76
95
  /** The System / Dark / Light control, bound to the nearest `GalaxyProvider`. */
77
- var ThemeSwitcher = forwardRef(function ThemeSwitcher({ size = "MEDIUM", isIconOnly = false, label, ariaLabel = "Theme", fillWidth = false, className, style, ...rest }, ref) {
96
+ var ThemeSwitcher = forwardRef(function ThemeSwitcher({ size = "MEDIUM", variant = "PRIMARY", isIconOnly = false, label, ariaLabel = "Theme", fillWidth = false, className, style, ...rest }, ref) {
78
97
  const { selectedTheme, setTheme } = useGalaxyTheme();
79
98
  return /* @__PURE__ */ jsx(ToggleInput, {
80
99
  ref,
@@ -82,6 +101,7 @@ var ThemeSwitcher = forwardRef(function ThemeSwitcher({ size = "MEDIUM", isIconO
82
101
  value: selectedTheme,
83
102
  onChange: setTheme,
84
103
  size: THEME_SWITCHER_SIZE_TO_TOGGLE_INPUT_SIZE_MAP[size],
104
+ variant: THEME_SWITCHER_VARIANT_TO_TOGGLE_INPUT_VARIANT_MAP[variant],
85
105
  ...label === void 0 ? { ariaLabel } : { label },
86
106
  fillWidth,
87
107
  ...rest,
@@ -91,4 +111,4 @@ var ThemeSwitcher = forwardRef(function ThemeSwitcher({ size = "MEDIUM", isIconO
91
111
  });
92
112
  ThemeSwitcher.displayName = "ThemeSwitcher";
93
113
  //#endregion
94
- export { ThemeSwitcherSize, ThemeSwitcher as default };
114
+ export { ThemeSwitcherSize, ThemeSwitcherVariant, ThemeSwitcher as default };
@@ -1,5 +1,6 @@
1
1
  import { type Icon as PhosphorIcon } from "@phosphor-icons/react";
2
2
  import { type AriaAttributes, type CSSProperties, type MouseEvent, type ReactNode } from "react";
3
+ import type { Space } from "../theme/enums.js";
3
4
  /** Card fill (Constitution V-A surface set). */
4
5
  export declare enum WidgetVariant {
5
6
  /** `background.base`. */
@@ -40,7 +41,7 @@ export interface WidgetGroupContextValue {
40
41
  export declare const WidgetGroupContext: import("react").Context<WidgetGroupContextValue | null>;
41
42
  /** Every Widget prop except the two coupled pairs (`isInteractive` / `onClick`, `isCollapsible` / `header`). */
42
43
  interface WidgetBaseProps extends AriaAttributes {
43
- /** The body: a column with the size's inset (none with `isFlush`) and gap. */
44
+ /** The body: a column with the size's inset (none with `isFlush`) and `gap`. */
44
45
  children?: ReactNode;
45
46
  /**
46
47
  * Surface fill of the card.
@@ -52,6 +53,12 @@ interface WidgetBaseProps extends AriaAttributes {
52
53
  * @default WidgetSize.MEDIUM
53
54
  */
54
55
  size?: WidgetSize;
56
+ /**
57
+ * Space between the body's children, from the space scale. `0` stacks them edge to edge (a
58
+ * flush chart over a table).
59
+ * @default the size's gap: 8 / 12 / 16
60
+ */
61
+ gap?: Space;
55
62
  /**
56
63
  * The header row's title. A string renders as a medium `Text` at the size's step; a node renders
57
64
  * as-is and must not contain controls (put them in `actions`). Omit it for a body-only card.
@@ -1,5 +1,6 @@
1
1
  import Text, { TextSize, TextVariant, TextWeight } from "../text/Text.js";
2
2
  import { useControlledOpenState } from "../hooks/useControlledOpenState.js";
3
+ import { gapToCss } from "../utils/css.js";
3
4
  import Divider from "../layout/Divider.js";
4
5
  import Icon, { IconVariant } from "../icons/Icon.js";
5
6
  import IconSlot from "../icons/internal/IconSlot.js";
@@ -113,7 +114,7 @@ var Panel = /*#__PURE__*/ styled("section")({
113
114
  class: "gx-Widget-Panel-p1u3h98q",
114
115
  propsAsIs: false
115
116
  });
116
- /** The body region: a column of the children. */
117
+ /** The body region: a column of the children, spaced by `--gx-widget-gap`. */
117
118
  var Body = /*#__PURE__*/ styled("div")({
118
119
  name: "Body",
119
120
  class: "gx-Widget-Body-b1t0k6w8",
@@ -143,12 +144,18 @@ var WIDGET_SIZE_TO_ROW_CSS_MAP = {
143
144
  ["MEDIUM"]: "gx-Widget-MEDIUM-m14youd7",
144
145
  ["LARGE"]: "gx-Widget-LARGE-lmk1xrm"
145
146
  };
146
- /** Body inset and gap. */
147
+ /** Body inset. */
147
148
  var WIDGET_SIZE_TO_BODY_CSS_MAP = {
148
149
  ["SMALL"]: "gx-Widget-SMALL-s1qcxaeu",
149
150
  ["MEDIUM"]: "gx-Widget-MEDIUM-m1niqf43",
150
151
  ["LARGE"]: "gx-Widget-LARGE-l1wi0lfv"
151
152
  };
153
+ /** The body gap when `gap` is unset: the same step as the inset. */
154
+ var WIDGET_SIZE_TO_GAP_MAP = {
155
+ ["SMALL"]: 8,
156
+ ["MEDIUM"]: 12,
157
+ ["LARGE"]: 16
158
+ };
152
159
  var WIDGET_SIZE_TO_TEXT_SIZE_MAP = {
153
160
  ["SMALL"]: TextSize.BODY_SM,
154
161
  ["MEDIUM"]: TextSize.BODY_MD,
@@ -181,7 +188,7 @@ var INTERACTIVE_CSS = "gx-Widget-INTERACTIVE_CSS-i11hrzgx";
181
188
  var DISABLED_CSS = "gx-Widget-DISABLED_CSS-d27d11a";
182
189
  /** Chosen: a `text.primary` hairline, also on hover (declared after the hover states, so it wins). */
183
190
  var SELECTED_CSS = "gx-Widget-SELECTED_CSS-s13jeom8";
184
- /** `isFlush`: no body inset (the gap stays); the body clips its content inside the corners it shares. */
191
+ /** `isFlush`: no body inset (`gap` stays); the body clips its content inside the corners it shares. */
185
192
  var FLUSH_CSS = "gx-Widget-FLUSH_CSS-f18mgbxd";
186
193
  /** A flush body with no header row above it rounds the card's top corners. */
187
194
  var FLUSH_TOP_CORNERS_CSS = "gx-Widget-FLUSH_TOP_CORNERS_CSS-f1djym4t";
@@ -217,7 +224,7 @@ var headerColors = (isOpen, isDisabled) => match({
217
224
  /** Whether a slot has something to render. */
218
225
  var hasContent = (node) => node !== void 0 && node !== null && node !== false;
219
226
  /** A card: a bordered surface with an optional (collapsible) header, actions, footer and states. */
220
- var Widget = forwardRef(function Widget({ children, variant = "PRIMARY", size = "MEDIUM", header, subheader, icon, actions, footer, isFlush = false, isCollapsible = false, hasCaret = true, isOpen: isOpenProp, defaultIsOpen = false, onOpenChange, isDisabled = false, isLoading = false, isSelected, isInteractive = false, onClick, ariaLabel, id, className, style, ...rest }, ref) {
227
+ var Widget = forwardRef(function Widget({ children, variant = "PRIMARY", size = "MEDIUM", gap, header, subheader, icon, actions, footer, isFlush = false, isCollapsible = false, hasCaret = true, isOpen: isOpenProp, defaultIsOpen = false, onOpenChange, isDisabled = false, isLoading = false, isSelected, isInteractive = false, onClick, ariaLabel, id, className, style, ...rest }, ref) {
221
228
  const baseId = useId();
222
229
  const rootId = id ?? baseId;
223
230
  const titleId = `${baseId}-title`;
@@ -259,6 +266,7 @@ var Widget = forwardRef(function Widget({ children, variant = "PRIMARY", size =
259
266
  hasHeaderRow && /* @__PURE__ */ jsx(Divider, {}),
260
267
  /* @__PURE__ */ jsx(Body, {
261
268
  id: bodyId,
269
+ style: { "--gx-widget-gap": gapToCss(gap ?? WIDGET_SIZE_TO_GAP_MAP[size]) },
262
270
  className: cx(WIDGET_SIZE_TO_BODY_CSS_MAP[size], isFlush && FLUSH_CSS, isFlush && !hasHeaderRow && FLUSH_TOP_CORNERS_CSS, isFlush && !hasFooter && FLUSH_BOTTOM_CORNERS_CSS),
263
271
  children: isLoading ? /* @__PURE__ */ jsx(Loading, { children: /* @__PURE__ */ jsx(Spinner, {
264
272
  variant: SpinnerVariant.SECONDARY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxy-io/dls",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "Galaxy Design Language System",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",