@galaxy-io/dls 1.4.14 → 1.5.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.
Files changed (38) hide show
  1. package/dist/charts/ChartLegend.js +3 -3
  2. package/dist/charts/ChartPrimitives.d.ts +15 -0
  3. package/dist/charts/ChartPrimitives.js +28 -9
  4. package/dist/inputs/CheckboxInput.d.ts +11 -14
  5. package/dist/inputs/CheckboxInput.js +10 -27
  6. package/dist/inputs/ColorInput.d.ts +4 -2
  7. package/dist/inputs/ColorInput.js +14 -28
  8. package/dist/inputs/CopyInput.d.ts +4 -2
  9. package/dist/inputs/CopyInput.js +11 -3
  10. package/dist/inputs/DateInput.d.ts +4 -2
  11. package/dist/inputs/DateInput.js +24 -31
  12. package/dist/inputs/Input.d.ts +82 -5
  13. package/dist/inputs/Input.js +111 -33
  14. package/dist/inputs/MultiSelectInput.d.ts +4 -4
  15. package/dist/inputs/MultiSelectInput.js +36 -45
  16. package/dist/inputs/MultiTextInput.d.ts +5 -16
  17. package/dist/inputs/MultiTextInput.js +24 -31
  18. package/dist/inputs/NumberInput.d.ts +1 -1
  19. package/dist/inputs/NumberInput.js +10 -2
  20. package/dist/inputs/PasswordInput.d.ts +4 -3
  21. package/dist/inputs/PasswordInput.js +6 -3
  22. package/dist/inputs/RadioInput.d.ts +11 -14
  23. package/dist/inputs/RadioInput.js +18 -34
  24. package/dist/inputs/SelectInput.d.ts +5 -14
  25. package/dist/inputs/SelectInput.js +35 -57
  26. package/dist/inputs/SliderInput.d.ts +9 -1
  27. package/dist/inputs/SliderInput.js +47 -21
  28. package/dist/inputs/SwitcherInput.d.ts +7 -2
  29. package/dist/inputs/SwitcherInput.js +7 -7
  30. package/dist/inputs/TextAreaInput.d.ts +5 -18
  31. package/dist/inputs/TextAreaInput.js +29 -57
  32. package/dist/inputs/TextInput.d.ts +6 -2
  33. package/dist/inputs/TextInput.js +2 -1
  34. package/dist/inputs/ToggleInput.d.ts +10 -1
  35. package/dist/inputs/ToggleInput.js +31 -9
  36. package/dist/styles.css +20 -19
  37. package/dist/table/TableSelectCell.js +5 -4
  38. package/package.json +1 -1
@@ -2,40 +2,36 @@ import { withTheme } from "../theme/GalaxyTheme.js";
2
2
  import { getCssSizeValue } from "../utils/linaria.js";
3
3
  import Text, { TextSize, TextVariant } from "../text/Text.js";
4
4
  import FlexWrapper, { FlexDirection } from "../containers/FlexWrapper.js";
5
- import { InputLabel } from "./Input.js";
6
- import Chip, { ChipSize } from "../chips/Chip.js";
5
+ import { InputLabel, InputSize, InputVariant, getInputBorderColor, getInputFontSize, getInputHeight, getInputLineHeight, getInputSurfaceColor } from "./Input.js";
6
+ import Chip, { ChipSize, ChipVariant } from "../chips/Chip.js";
7
7
  /* empty css */
8
8
  import { styled } from "@linaria/react";
9
9
  import { match } from "ts-pattern";
10
10
  import { forwardRef, useCallback, useRef, useState } from "react";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
12
  //#region src/inputs/MultiTextInput.tsx
13
- /** Field height. */
14
- var MultiTextInputSize = /* @__PURE__ */ function(MultiTextInputSize) {
15
- MultiTextInputSize["SMALL"] = "SMALL";
16
- MultiTextInputSize["MEDIUM"] = "MEDIUM";
17
- MultiTextInputSize["LARGE"] = "LARGE";
18
- return MultiTextInputSize;
19
- }({});
20
- /** Color of the chips created from entered values. */
21
- var MultiTextInputVariant = /* @__PURE__ */ function(MultiTextInputVariant) {
22
- MultiTextInputVariant["PRIMARY"] = "PRIMARY";
23
- MultiTextInputVariant["SECONDARY"] = "SECONDARY";
24
- MultiTextInputVariant["TERTIARY"] = "TERTIARY";
25
- return MultiTextInputVariant;
26
- }({});
27
- var _exp = () => ({ $size }) => {
28
- return match($size).with("SMALL", () => "24px").with("MEDIUM", () => "28px").with("LARGE", () => "32px").exhaustive();
13
+ var INPUT_VARIANT_TO_CHIP_VARIANT_MAP = {
14
+ [InputVariant.TRANSPARENT]: ChipVariant.SECONDARY,
15
+ [InputVariant.BASE]: ChipVariant.SECONDARY,
16
+ [InputVariant.PRIMARY]: ChipVariant.SECONDARY,
17
+ [InputVariant.SECONDARY]: ChipVariant.PRIMARY,
18
+ [InputVariant.TERTIARY]: ChipVariant.SECONDARY
29
19
  };
20
+ var INPUT_SIZE_TO_CHIP_SIZE_MAP = {
21
+ [InputSize.SMALL]: ChipSize.SMALL,
22
+ [InputSize.MEDIUM]: ChipSize.MEDIUM,
23
+ [InputSize.LARGE]: ChipSize.LARGE
24
+ };
25
+ var _exp = () => ({ $size }) => getInputHeight($size);
30
26
  var _exp2 = () => ({ $fillWidth, $width }) => $fillWidth ? "100%" : $width ? getCssSizeValue($width) : "auto";
31
- var _exp3 = () => ({ theme, $variant }) => match($variant).with("PRIMARY", () => theme.color.background.primary).with("SECONDARY", () => theme.color.background.secondary).with("TERTIARY", () => theme.color.background.tertiary).exhaustive();
32
- var _exp4 = () => ({ theme, $isError, $isFocused }) => {
27
+ var _exp3 = () => ({ theme, $variant }) => getInputSurfaceColor(theme, $variant);
28
+ var _exp4 = () => ({ theme, $variant, $isError, $isFocused }) => {
33
29
  if ($isError) return theme.color.border.error;
34
30
  if ($isFocused) return theme.color.border.selected;
35
- return theme.color.border.primary;
31
+ return getInputBorderColor(theme, $variant);
36
32
  };
37
33
  var _exp5 = () => ({ $size }) => {
38
- return match($size).with("SMALL", () => "2px 6px").with("MEDIUM", () => "4px 6px").with("LARGE", () => "4px 8px").exhaustive();
34
+ return `${match($size).with(InputSize.SMALL, () => "2px").with(InputSize.MEDIUM, () => "4px").with(InputSize.LARGE, () => "4px").exhaustive()} ${match($size).with(InputSize.SMALL, () => "2px").with(InputSize.MEDIUM, () => "4px").with(InputSize.LARGE, () => "4px").exhaustive()}`;
39
35
  };
40
36
  var _exp6 = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "text";
41
37
  var _exp7 = () => ({ $isDisabled }) => $isDisabled ? .5 : 1;
@@ -56,12 +52,8 @@ var MultiTextInputWrapper = withTheme(/*#__PURE__*/ styled("div")({
56
52
  }
57
53
  }));
58
54
  var _exp9 = () => ({ theme }) => theme.color.text.primary;
59
- var _exp0 = () => ({ theme, $size }) => {
60
- return match($size).with("SMALL", () => theme.font.sans.size.body_md).with("MEDIUM", () => theme.font.sans.size.body_md).with("LARGE", () => theme.font.sans.size.body_lg).exhaustive();
61
- };
62
- var _exp1 = () => ({ theme, $size }) => {
63
- return match($size).with("SMALL", () => theme.font.sans.height.body_md).with("MEDIUM", () => theme.font.sans.height.body_md).with("LARGE", () => theme.font.sans.height.body_lg).exhaustive();
64
- };
55
+ var _exp0 = () => ({ theme, $size }) => getInputFontSize(theme, $size);
56
+ var _exp1 = () => ({ theme, $size }) => getInputLineHeight(theme, $size);
65
57
  var _exp10 = () => ({ theme }) => theme.font.sans.weight.regular;
66
58
  var _exp11 = () => ({ theme }) => theme.font.sans.family;
67
59
  var _exp12 = () => ({ theme }) => theme.color.text.disabled;
@@ -85,7 +77,7 @@ var StyledInput = withTheme(/*#__PURE__*/ styled("input")({
85
77
  * The in-progress draft is internal state and is *not* part of `value`; it only
86
78
  * lands there once committed.
87
79
  */
88
- var MultiTextInput = forwardRef(({ value, onChange, variant = "PRIMARY", size = "MEDIUM", placeholder, label, error, isRequired, isDisabled, autoFocus, width, fillWidth, separator = "," }, ref) => {
80
+ var MultiTextInput = forwardRef(({ value, onChange, variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, placeholder, label, error, isRequired, isDisabled, autoFocus, width, fillWidth, separator = "," }, ref) => {
89
81
  const [inputValue, setInputValue] = useState("");
90
82
  const [isFocused, setIsFocused] = useState(false);
91
83
  const inputRef = useRef(null);
@@ -156,7 +148,8 @@ var MultiTextInput = forwardRef(({ value, onChange, variant = "PRIMARY", size =
156
148
  "data-disabled": isDisabled,
157
149
  children: [value.map((item, index) => /* @__PURE__ */ jsx(Chip, {
158
150
  label: item,
159
- size: ChipSize.SMALL,
151
+ size: INPUT_SIZE_TO_CHIP_SIZE_MAP[size],
152
+ variant: INPUT_VARIANT_TO_CHIP_VARIANT_MAP[variant],
160
153
  onDismiss: isDisabled ? void 0 : () => handleRemoveChip(index)
161
154
  }, `${item}-${index}`)), /* @__PURE__ */ jsx(StyledInput, {
162
155
  ref: setRefs,
@@ -184,4 +177,4 @@ var MultiTextInput = forwardRef(({ value, onChange, variant = "PRIMARY", size =
184
177
  });
185
178
  MultiTextInput.displayName = "MultiTextInput";
186
179
  //#endregion
187
- export { MultiTextInputSize, MultiTextInputVariant, MultiTextInput as default };
180
+ export { MultiTextInput as default };
@@ -6,5 +6,5 @@ export type NumberInputProps = Omit<InputProps<number>, "type" | "parse">;
6
6
  * where they bound character count) and values outside it are clamped, not
7
7
  * rejected — `onChange` only ever sees an in-range number.
8
8
  */
9
- declare const NumberInput: ({ value, placeholder, label, size, leading, trailing, isRequired, isDisabled, min, max, step, onChange, width, fillWidth, }: NumberInputProps) => import("react").JSX.Element;
9
+ declare const NumberInput: ({ value, placeholder, label, labelTooltip, variant, size, leading, trailing, error, isRequired, isDisabled, autoFocus, min, max, step, onChange, onFocus, onBlur, onKeyDown, width, fillWidth, isMonospace, }: NumberInputProps) => import("react").JSX.Element;
10
10
  export default NumberInput;
@@ -7,17 +7,21 @@ import { jsx } from "react/jsx-runtime";
7
7
  * where they bound character count) and values outside it are clamped, not
8
8
  * rejected — `onChange` only ever sees an in-range number.
9
9
  */
10
- var NumberInput = ({ value, placeholder, label, size, leading, trailing, isRequired, isDisabled, min, max, step, onChange, width, fillWidth }) => {
10
+ var NumberInput = ({ value, placeholder, label, labelTooltip, variant, size, leading, trailing, error, isRequired, isDisabled, autoFocus, min, max, step, onChange, onFocus, onBlur, onKeyDown, width, fillWidth, isMonospace }) => {
11
11
  return /* @__PURE__ */ jsx(Input, {
12
12
  type: "number",
13
13
  value,
14
14
  placeholder,
15
15
  label,
16
+ labelTooltip,
17
+ variant,
16
18
  size,
17
19
  leading,
18
20
  trailing,
21
+ error,
19
22
  isRequired,
20
23
  isDisabled,
24
+ autoFocus,
21
25
  min,
22
26
  max,
23
27
  step,
@@ -31,9 +35,13 @@ var NumberInput = ({ value, placeholder, label, size, leading, trailing, isRequi
31
35
  max,
32
36
  onChange
33
37
  ]),
38
+ onFocus,
39
+ onBlur,
40
+ onKeyDown,
34
41
  parse: Number,
35
42
  width,
36
- fillWidth
43
+ fillWidth,
44
+ isMonospace
37
45
  });
38
46
  };
39
47
  //#endregion
@@ -1,9 +1,10 @@
1
1
  import { type InputProps } from "./Input";
2
2
  /**
3
- * Every `InputProps` field except `type` and `parse`, which are fixed. The
4
- * trailing slot is used by the reveal toggle, so passing `trailing` has no effect.
3
+ * Every `InputProps` field except `type` and `parse`, which are fixed. `trailing`
4
+ * is omitted because the reveal toggle owns that slot, and `min`/`max`/`step` are
5
+ * numeric-only.
5
6
  */
6
- export type PasswordInputProps = Omit<InputProps<string>, "type" | "parse" | "action">;
7
+ export type PasswordInputProps = Omit<InputProps<string>, "type" | "parse" | "trailing" | "min" | "max" | "step">;
7
8
  /**
8
9
  * A masked text field with a built-in reveal toggle in the trailing slot.
9
10
  * Toggling only flips the DOM `type` — the value is never transformed.
@@ -1,4 +1,4 @@
1
- import Input, { InputSize } from "./Input.js";
1
+ import Input from "./Input.js";
2
2
  import { forwardRef, useState } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { EyeIcon, EyeSlashIcon } from "@phosphor-icons/react";
@@ -8,17 +8,19 @@ var DEFAULT_STATE = { showPassword: false };
8
8
  * A masked text field with a built-in reveal toggle in the trailing slot.
9
9
  * Toggling only flips the DOM `type` — the value is never transformed.
10
10
  */
11
- var PasswordInput = forwardRef(({ size = InputSize.MEDIUM, value, placeholder, label, leading, error, isRequired, isDisabled, autoFocus, onChange, width, fillWidth, onKeyDown, onBlur, onFocus }, ref) => {
11
+ var PasswordInput = forwardRef(({ variant, size, value, placeholder, label, labelTooltip, leading, error, isRequired, isDisabled, autoFocus, onChange, width, fillWidth, onKeyDown, onBlur, onFocus, isMonospace }, ref) => {
12
12
  const [state, setState] = useState(DEFAULT_STATE);
13
13
  return /* @__PURE__ */ jsx(Input, {
14
14
  ref,
15
15
  parse: String,
16
16
  onChange,
17
+ variant,
17
18
  size,
18
19
  type: state.showPassword ? "text" : "password",
19
20
  value,
20
21
  placeholder,
21
22
  label,
23
+ labelTooltip,
22
24
  leading,
23
25
  trailing: {
24
26
  icon: state.showPassword ? EyeSlashIcon : EyeIcon,
@@ -36,7 +38,8 @@ var PasswordInput = forwardRef(({ size = InputSize.MEDIUM, value, placeholder, l
36
38
  onBlur,
37
39
  onFocus,
38
40
  width,
39
- fillWidth
41
+ fillWidth,
42
+ isMonospace
40
43
  });
41
44
  });
42
45
  PasswordInput.displayName = "PasswordInput";
@@ -1,18 +1,15 @@
1
- /** Fill color of the dot when selected. */
2
- export declare enum RadioInputVariant {
3
- PRIMARY = "PRIMARY",
4
- SECONDARY = "SECONDARY"
5
- }
6
- /** Circle size. Two steps only — this is a hit target, not a type scale. */
7
- export declare enum RadioInputSize {
8
- SMALL = "SMALL",
9
- MEDIUM = "MEDIUM"
10
- }
1
+ import { InputSize, InputVariant } from "./Input";
11
2
  export interface RadioInputProps {
12
- /** @default RadioInputVariant.PRIMARY */
13
- variant?: RadioInputVariant;
14
- /** @default RadioInputSize.MEDIUM */
15
- size?: RadioInputSize;
3
+ /**
4
+ * Unselected fill color. The selected fill is a state color and stays
5
+ * `background.primaryAlt` so the dot keeps its contrast. Unlike the field
6
+ * inputs, `TRANSPARENT` keeps the hairline border here — without it the
7
+ * circle would be invisible. @default InputVariant.PRIMARY
8
+ */
9
+ variant?: InputVariant;
10
+ /** Circle size — a hit target, so it steps 12 / 16 / 20px, not off the type scale.
11
+ * @default InputSize.MEDIUM */
12
+ size?: InputSize;
16
13
  /** Controlled state. The radio holds none of its own. */
17
14
  isSelected: boolean;
18
15
  /** Text beside the circle. */
@@ -5,24 +5,13 @@ import Icon, { IconVariant } from "../icons/Icon.js";
5
5
  import FlexWrapper, { AlignItems } from "../containers/FlexWrapper.js";
6
6
  import RequiredMarker from "../text/RequiredMarker.js";
7
7
  import Spacing from "../containers/Spacing.js";
8
+ import { InputSize, InputVariant, getInputControlSize, getInputSurfaceColor } from "./Input.js";
8
9
  /* empty css */
9
10
  import { styled } from "@linaria/react";
10
11
  import { match } from "ts-pattern";
11
12
  import { jsx, jsxs } from "react/jsx-runtime";
12
13
  import { InfoIcon } from "@phosphor-icons/react";
13
14
  //#region src/inputs/RadioInput.tsx
14
- /** Fill color of the dot when selected. */
15
- var RadioInputVariant = /* @__PURE__ */ function(RadioInputVariant) {
16
- RadioInputVariant["PRIMARY"] = "PRIMARY";
17
- RadioInputVariant["SECONDARY"] = "SECONDARY";
18
- return RadioInputVariant;
19
- }({});
20
- /** Circle size. Two steps only — this is a hit target, not a type scale. */
21
- var RadioInputSize = /* @__PURE__ */ function(RadioInputSize) {
22
- RadioInputSize["SMALL"] = "SMALL";
23
- RadioInputSize["MEDIUM"] = "MEDIUM";
24
- return RadioInputSize;
25
- }({});
26
15
  var _exp = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "pointer";
27
16
  var _exp2 = () => ({ $isDisabled }) => $isDisabled ? .5 : 1;
28
17
  var RadioContainer = /*#__PURE__*/ styled("div")({
@@ -34,14 +23,9 @@ var RadioContainer = /*#__PURE__*/ styled("div")({
34
23
  "r1pzr59l-1": [_exp2()]
35
24
  }
36
25
  });
37
- var _exp4 = () => ({ $size }) => {
38
- return match($size).with("SMALL", () => "12px").with("MEDIUM", () => "16px").exhaustive();
39
- };
26
+ var _exp4 = () => ({ $size }) => getInputControlSize($size);
40
27
  var _exp5 = () => ({ theme }) => theme.color.border.primary;
41
- var _exp6 = () => ({ theme, $isSelected }) => $isSelected ? theme.color.background.primaryAlt : theme.color.background.tertiary;
42
- var _exp7 = () => ({ theme, $isDisabled, $variant }) => {
43
- return match($variant).with("PRIMARY", () => $isDisabled ? theme.color.border.primary : theme.color.border.primary).with("SECONDARY", () => $isDisabled ? theme.color.border.primary : theme.color.border.primary).exhaustive();
44
- };
28
+ var _exp6 = () => ({ theme, $variant, $isSelected }) => $isSelected ? theme.color.background.primaryAlt : getInputSurfaceColor(theme, $variant);
45
29
  var RadioWrapper = withTheme(/*#__PURE__*/ styled("div")({
46
30
  name: "RadioWrapper",
47
31
  class: "r1mwwvky",
@@ -49,25 +33,26 @@ var RadioWrapper = withTheme(/*#__PURE__*/ styled("div")({
49
33
  vars: {
50
34
  "r1mwwvky-0": [_exp4()],
51
35
  "r1mwwvky-1": [_exp5()],
52
- "r1mwwvky-2": [_exp6()],
53
- "r1mwwvky-3": [_exp7()]
36
+ "r1mwwvky-2": [_exp6()]
54
37
  }
55
38
  }));
56
- var _exp9 = () => ({ $size }) => {
57
- return match($size).with("SMALL", () => "6px").with("MEDIUM", () => "8px").exhaustive();
58
- };
59
- var _exp0 = () => ({ theme }) => theme.color.background.primary;
60
- var _exp1 = () => ({ $isSelected }) => $isSelected ? 1 : 0;
61
- var _exp10 = () => ({ $isSelected }) => $isSelected ? "scale(1)" : "scale(0)";
39
+ /** The dot is half the circle it sits in — see `getInputControlSize`. */
40
+ function getRadioDotSize(size) {
41
+ return match(size).returnType().with(InputSize.SMALL, () => "6px").with(InputSize.MEDIUM, () => "8px").with(InputSize.LARGE, () => "10px").exhaustive();
42
+ }
43
+ var _exp8 = () => ({ $size }) => getRadioDotSize($size);
44
+ var _exp9 = () => ({ theme }) => theme.color.background.primary;
45
+ var _exp0 = () => ({ $isSelected }) => $isSelected ? 1 : 0;
46
+ var _exp1 = () => ({ $isSelected }) => $isSelected ? "scale(1)" : "scale(0)";
62
47
  var RadioDot = withTheme(/*#__PURE__*/ styled("div")({
63
48
  name: "RadioDot",
64
49
  class: "r137y8ev",
65
50
  propsAsIs: false,
66
51
  vars: {
67
- "r137y8ev-0": [_exp9()],
68
- "r137y8ev-1": [_exp0()],
69
- "r137y8ev-2": [_exp1()],
70
- "r137y8ev-3": [_exp10()]
52
+ "r137y8ev-0": [_exp8()],
53
+ "r137y8ev-1": [_exp9()],
54
+ "r137y8ev-2": [_exp0()],
55
+ "r137y8ev-3": [_exp1()]
71
56
  }
72
57
  }));
73
58
  /**
@@ -76,7 +61,7 @@ var RadioDot = withTheme(/*#__PURE__*/ styled("div")({
76
61
  * There is no group component — render several and enforce single-selection in
77
62
  * your own state.
78
63
  */
79
- var RadioInput = ({ variant = "PRIMARY", size = "MEDIUM", isSelected, label, labelTooltip, isRequired = false, isDisabled = false, onChange }) => {
64
+ var RadioInput = ({ variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, isSelected, label, labelTooltip, isRequired = false, isDisabled = false, onChange }) => {
80
65
  const handleClick = () => {
81
66
  if (!isDisabled) onChange(!isSelected);
82
67
  };
@@ -87,7 +72,6 @@ var RadioInput = ({ variant = "PRIMARY", size = "MEDIUM", isSelected, label, lab
87
72
  $variant: variant,
88
73
  $size: size,
89
74
  $isSelected: isSelected,
90
- $isDisabled: isDisabled,
91
75
  children: /* @__PURE__ */ jsx(RadioDot, {
92
76
  $size: size,
93
77
  $isSelected: isSelected
@@ -118,4 +102,4 @@ var RadioInput = ({ variant = "PRIMARY", size = "MEDIUM", isSelected, label, lab
118
102
  });
119
103
  };
120
104
  //#endregion
121
- export { RadioInputSize, RadioInputVariant, RadioInput as default };
105
+ export { RadioInput as default };
@@ -1,13 +1,6 @@
1
1
  import { IconVariant } from "../icons/Icon";
2
- import { TextSize, TextVariant } from "../text/Text";
3
- import { InputSize } from "./Input";
4
- /** Surface treatment of the closed trigger. Shared with `MultiSelectInput`. */
5
- export declare enum SelectInputVariant {
6
- BASE = "BASE",
7
- PRIMARY = "PRIMARY",
8
- SECONDARY = "SECONDARY",
9
- TERTIARY = "TERTIARY"
10
- }
2
+ import { TextVariant } from "../text/Text";
3
+ import { InputSize, InputVariant } from "./Input";
11
4
  /** One choice in a select. */
12
5
  export interface SelectInputOption {
13
6
  /** Stable identity — selection is matched on this, not on `value`. */
@@ -30,8 +23,8 @@ export interface PinnedOption {
30
23
  }
31
24
  export interface SelectInputProps {
32
25
  label?: string;
33
- /** @default SelectInputVariant.PRIMARY */
34
- variant?: SelectInputVariant;
26
+ /** Trigger surface color. @default InputVariant.PRIMARY */
27
+ variant?: InputVariant;
35
28
  /** @default InputSize.MEDIUM */
36
29
  size?: InputSize;
37
30
  /** Every choice. Order is preserved. */
@@ -63,9 +56,7 @@ export interface SelectInputProps {
63
56
  /** Debounce before `onSearch` fires, in ms. @default 300 */
64
57
  debounceMs?: number;
65
58
  }
66
- export declare const SELECT_INPUT_VARIANT_TO_ICON_VARIANT_MAP: Record<SelectInputVariant, IconVariant>;
67
- export declare const SELECT_INPUT_SIZE_TO_ICON_SIZE: Record<InputSize, number>;
68
- export declare const SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP: Record<InputSize, TextSize>;
59
+ export declare const INPUT_VARIANT_TO_ICON_VARIANT_MAP: Record<InputVariant, IconVariant>;
69
60
  /**
70
61
  * Single-choice dropdown with keyboard navigation and optional search.
71
62
  *
@@ -5,43 +5,37 @@ import Text, { TextSize, TextVariant } from "../text/Text.js";
5
5
  import FlexItem from "../containers/FlexItem.js";
6
6
  import Icon, { IconVariant, IconWeight } from "../icons/Icon.js";
7
7
  import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
8
- import Dropdown, { DropdownVariant } from "../dropdown/Dropdown.js";
9
8
  import Spacing from "../containers/Spacing.js";
10
- import { InputLabel, InputSize } from "./Input.js";
9
+ import { InputLabel, InputSize, InputVariant, getInputBorderColor, getInputFontSize, getInputHeight, getInputIconSize, getInputLineHeight, getInputPadding, getInputSurfaceColor, getInputTextSize } from "./Input.js";
10
+ import Dropdown, { DropdownVariant } from "../dropdown/Dropdown.js";
11
11
  import HorizontalDivider from "../dividers/HorizontalDivider.js";
12
12
  import { useElementWidth } from "../hooks/useElementWidth.js";
13
13
  import { useControlledOpenState, useDebouncedValue } from "./hooks.js";
14
14
  /* empty css */
15
15
  import { styled } from "@linaria/react";
16
- import { match } from "ts-pattern";
17
16
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
18
17
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
18
  import { ArrowCounterClockwiseIcon, CaretDownIcon, CheckIcon } from "@phosphor-icons/react";
20
19
  //#region src/inputs/SelectInput.tsx
21
- /** Surface treatment of the closed trigger. Shared with `MultiSelectInput`. */
22
- var SelectInputVariant = /* @__PURE__ */ function(SelectInputVariant) {
23
- SelectInputVariant["BASE"] = "BASE";
24
- SelectInputVariant["PRIMARY"] = "PRIMARY";
25
- SelectInputVariant["SECONDARY"] = "SECONDARY";
26
- SelectInputVariant["TERTIARY"] = "TERTIARY";
27
- return SelectInputVariant;
28
- }({});
29
- var _exp = () => ({ $size }) => {
30
- return match($size).with(InputSize.SMALL, () => "0 6px").with(InputSize.MEDIUM, () => "0 8px").with(InputSize.LARGE, () => "0 10px").exhaustive();
31
- };
32
- var _exp2 = () => ({ $size }) => {
33
- return match($size).with(InputSize.SMALL, () => "24px").with(InputSize.MEDIUM, () => "28px").with(InputSize.LARGE, () => "32px").exhaustive();
20
+ var INPUT_VARIANT_TO_DROPDOWN_VARIANT = {
21
+ [InputVariant.TRANSPARENT]: DropdownVariant.TRANSPARENT,
22
+ [InputVariant.BASE]: DropdownVariant.PRIMARY,
23
+ [InputVariant.PRIMARY]: DropdownVariant.PRIMARY,
24
+ [InputVariant.SECONDARY]: DropdownVariant.SECONDARY,
25
+ [InputVariant.TERTIARY]: DropdownVariant.TERTIARY
34
26
  };
27
+ var _exp = () => ({ $size }) => `0 ${getInputPadding($size)}`;
28
+ var _exp2 = () => ({ $size }) => getInputHeight($size);
35
29
  var _exp3 = () => ({ $fillWidth, $width }) => $fillWidth ? "100%" : $width ? getCssSizeValue($width) : "auto";
36
30
  var _exp4 = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "pointer";
37
31
  var _exp5 = () => ({ $isDisabled }) => $isDisabled ? .5 : 1;
38
- var _exp6 = () => ({ theme }) => theme.color.background.primary;
39
- var _exp7 = () => ({ theme, $isActive, $isError }) => {
32
+ var _exp6 = () => ({ theme, $variant }) => getInputSurfaceColor(theme, $variant);
33
+ var _exp7 = () => ({ theme, $variant, $isActive, $isError }) => {
40
34
  if ($isActive) return theme.color.border.selected;
41
35
  if ($isError) return theme.color.border.error;
42
- return theme.color.border.primary;
36
+ return getInputBorderColor(theme, $variant);
43
37
  };
44
- var _exp8 = () => ({ theme, $isActive }) => $isActive ? theme.color.border.selected : theme.color.border.primary;
38
+ var _exp8 = () => ({ theme, $variant, $isActive }) => $isActive ? theme.color.border.selected : getInputBorderColor(theme, $variant);
45
39
  var StyledSelectInput = withTheme(/*#__PURE__*/ styled("div")({
46
40
  name: "StyledSelectInput",
47
41
  class: "s1ecxi56",
@@ -57,16 +51,10 @@ var StyledSelectInput = withTheme(/*#__PURE__*/ styled("div")({
57
51
  "s1ecxi56-7": [_exp8()]
58
52
  }
59
53
  }));
60
- var _exp9 = () => ({ $size }) => {
61
- return match($size).with(InputSize.SMALL, () => "24px").with(InputSize.MEDIUM, () => "28px").with(InputSize.LARGE, () => "32px").exhaustive();
62
- };
54
+ var _exp9 = () => ({ $size }) => getInputHeight($size);
63
55
  var _exp0 = () => ({ theme }) => theme.color.text.primary;
64
- var _exp1 = () => ({ theme, $size }) => {
65
- return match($size).with(InputSize.SMALL, () => theme.font.sans.size.body_sm).with(InputSize.MEDIUM, () => theme.font.sans.size.body_md).with(InputSize.LARGE, () => theme.font.sans.size.body_lg).exhaustive();
66
- };
67
- var _exp10 = () => ({ theme, $size }) => {
68
- return match($size).with(InputSize.SMALL, () => theme.font.sans.height.body_sm).with(InputSize.MEDIUM, () => theme.font.sans.height.body_md).with(InputSize.LARGE, () => theme.font.sans.height.body_lg).exhaustive();
69
- };
56
+ var _exp1 = () => ({ theme, $size }) => getInputFontSize(theme, $size);
57
+ var _exp10 = () => ({ theme, $size }) => getInputLineHeight(theme, $size);
70
58
  var _exp11 = () => ({ theme }) => theme.font.sans.weight.medium;
71
59
  var _exp12 = () => ({ theme }) => theme.font.sans.family;
72
60
  var _exp13 = () => ({ theme }) => theme.color.text.tertiary;
@@ -106,10 +94,10 @@ var SelectInputOptionsContainer = /*#__PURE__*/ styled("div")({
106
94
  vars: { "sk260f0-0": [_exp16()] }
107
95
  });
108
96
  var _exp17 = () => ({ theme, $isSelected, $isFocused }) => {
109
- if ($isSelected || $isFocused) return theme.color.background.tertiary;
97
+ if ($isSelected || $isFocused) return theme.color.background.secondary;
110
98
  return "transparent";
111
99
  };
112
- var _exp19 = () => ({ theme }) => theme.color.background.tertiary;
100
+ var _exp19 = () => ({ theme }) => theme.color.background.secondary;
113
101
  var SelectInputOption = withTheme(/*#__PURE__*/ styled("button")({
114
102
  name: "SelectInputOption",
115
103
  class: "so10ras",
@@ -138,21 +126,12 @@ var OptionIconSlot = /*#__PURE__*/ styled("span")({
138
126
  class: "o9236d8",
139
127
  propsAsIs: false
140
128
  });
141
- var SELECT_INPUT_VARIANT_TO_ICON_VARIANT_MAP = {
142
- ["BASE"]: IconVariant.SECONDARY,
143
- ["PRIMARY"]: IconVariant.SECONDARY,
144
- ["SECONDARY"]: IconVariant.SECONDARY,
145
- ["TERTIARY"]: IconVariant.PRIMARY
146
- };
147
- var SELECT_INPUT_SIZE_TO_ICON_SIZE = {
148
- [InputSize.SMALL]: 12,
149
- [InputSize.MEDIUM]: 14,
150
- [InputSize.LARGE]: 16
151
- };
152
- var SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP = {
153
- [InputSize.SMALL]: TextSize.BODY_MD,
154
- [InputSize.MEDIUM]: TextSize.BODY_MD,
155
- [InputSize.LARGE]: TextSize.BODY_MD
129
+ var INPUT_VARIANT_TO_ICON_VARIANT_MAP = {
130
+ [InputVariant.TRANSPARENT]: IconVariant.SECONDARY,
131
+ [InputVariant.BASE]: IconVariant.SECONDARY,
132
+ [InputVariant.PRIMARY]: IconVariant.SECONDARY,
133
+ [InputVariant.SECONDARY]: IconVariant.SECONDARY,
134
+ [InputVariant.TERTIARY]: IconVariant.PRIMARY
156
135
  };
157
136
  /**
158
137
  * Single-choice dropdown with keyboard navigation and optional search.
@@ -161,7 +140,7 @@ var SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP = {
161
140
  * option back. Passing `onSearch` turns the trigger into a search box — you own
162
141
  * the filtering, so it works equally well against a local list or a server.
163
142
  */
164
- var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, options, value, placeholder = "Select an option...", onChange, width, fillWidth, dropdownWidth, isDisabled = false, isRequired = false, isOpen: controlledIsOpen, onOpenChange, onReset, pinnedOptions = [], error, onSearch, debounceMs = 300 }) => {
143
+ var SelectInput = ({ label, variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, options, value, placeholder = "Select an option...", onChange, width, fillWidth, dropdownWidth, isDisabled = false, isRequired = false, isOpen: controlledIsOpen, onOpenChange, onReset, pinnedOptions = [], error, onSearch, debounceMs = 300 }) => {
165
144
  const isSearchable = !!onSearch;
166
145
  const [isHovered, setIsHovered] = useState(false);
167
146
  const [searchTerm, setSearchTerm] = useState("");
@@ -321,7 +300,7 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
321
300
  },
322
301
  onMouseEnter: () => setFocusedOptionIndex(index),
323
302
  children: [/* @__PURE__ */ jsx(Text, {
324
- size: SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP[size],
303
+ size: getInputTextSize(size),
325
304
  cursor: !effectiveIsDisabled ? "pointer" : "not-allowed",
326
305
  isEllipsis: true,
327
306
  children: pinnedOption.label
@@ -354,7 +333,7 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
354
333
  shrink: 1,
355
334
  minWidth: 0,
356
335
  children: /* @__PURE__ */ jsx(Text, {
357
- size: SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP[size],
336
+ size: getInputTextSize(size),
358
337
  cursor: !effectiveIsDisabled ? "pointer" : "not-allowed",
359
338
  isEllipsis: true,
360
339
  variant: option.variant ?? TextVariant.PRIMARY,
@@ -372,7 +351,7 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
372
351
  style: { padding: "8px" },
373
352
  children: /* @__PURE__ */ jsx(Text, {
374
353
  variant: TextVariant.TERTIARY,
375
- size: SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP[size],
354
+ size: getInputTextSize(size),
376
355
  children: "No options found"
377
356
  })
378
357
  })
@@ -390,7 +369,7 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
390
369
  size: 12
391
370
  }), /* @__PURE__ */ jsx(Text, {
392
371
  variant: TextVariant.SECONDARY,
393
- size: SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP[size],
372
+ size: getInputTextSize(size),
394
373
  cursor: !effectiveIsDisabled ? "pointer" : "not-allowed",
395
374
  children: "Reset"
396
375
  })]
@@ -418,7 +397,7 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
418
397
  isRequired
419
398
  }),
420
399
  /* @__PURE__ */ jsx(Dropdown, {
421
- variant: DropdownVariant.PRIMARY,
400
+ variant: INPUT_VARIANT_TO_DROPDOWN_VARIANT[variant],
422
401
  body: dropdownBody,
423
402
  isOpen: visible,
424
403
  onClose: handleClose,
@@ -441,7 +420,6 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
441
420
  children: [
442
421
  /* @__PURE__ */ jsx(StyledSearchInput, {
443
422
  ref: inputRef,
444
- $variant: variant,
445
423
  $size: size,
446
424
  $isActive: visible ?? false,
447
425
  $isDisabled: effectiveIsDisabled,
@@ -464,7 +442,7 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
464
442
  deg: -180,
465
443
  children: /* @__PURE__ */ jsx(Icon, {
466
444
  component: CaretDownIcon,
467
- size: 10,
445
+ size: getInputIconSize(size),
468
446
  variant: !effectiveIsDisabled && (isHovered || visible) ? IconVariant.SECONDARY : IconVariant.TERTIARY
469
447
  })
470
448
  }) })
@@ -498,7 +476,7 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
498
476
  minWidth: 0,
499
477
  children: /* @__PURE__ */ jsx(Text, {
500
478
  variant: textVariant,
501
- size: SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP[size],
479
+ size: getInputTextSize(size),
502
480
  cursor: !effectiveIsDisabled ? "pointer" : "not-allowed",
503
481
  isEllipsis: true,
504
482
  children: selectedOption ? selectedOption.label : placeholder
@@ -511,7 +489,7 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
511
489
  deg: -180,
512
490
  children: /* @__PURE__ */ jsx(Icon, {
513
491
  component: CaretDownIcon,
514
- size: 10,
492
+ size: getInputIconSize(size),
515
493
  variant: !effectiveIsDisabled && (isHovered || visible) ? IconVariant.SECONDARY : IconVariant.TERTIARY
516
494
  })
517
495
  }) })
@@ -527,4 +505,4 @@ var SelectInput = ({ label, variant = "PRIMARY", size = InputSize.MEDIUM, option
527
505
  });
528
506
  };
529
507
  //#endregion
530
- export { SELECT_INPUT_SIZE_TO_ICON_SIZE, SELECT_INPUT_SIZE_TO_TEXT_SIZE_MAP, SELECT_INPUT_VARIANT_TO_ICON_VARIANT_MAP, SelectInputVariant, SelectInput as default };
508
+ export { INPUT_VARIANT_TO_ICON_VARIANT_MAP, SelectInput as default };
@@ -1,4 +1,12 @@
1
+ import { InputSize, InputVariant } from "./Input";
1
2
  export interface SliderInputProps {
3
+ /**
4
+ * Track color. The filled portion and the handle are state colors and stay
5
+ * `icon.primary`. @default InputVariant.PRIMARY
6
+ */
7
+ variant?: InputVariant;
8
+ /** Rail and handle size — 2/6, 3/8 or 4/10px. @default InputSize.MEDIUM */
9
+ size?: InputSize;
2
10
  label?: string;
3
11
  /** Adds an info icon beside the label with this content on hover. */
4
12
  labelTooltip?: string | React.ReactNode;
@@ -27,5 +35,5 @@ export interface SliderInputProps {
27
35
  * `onChange` fires on every pointer move. When each change is expensive, drive
28
36
  * a preview from it and commit on `onInteractionEnd`.
29
37
  */
30
- declare const SliderInput: ({ label, labelTooltip, value, onChange, onInteractionStart, onInteractionEnd, min, max, step, isDisabled, width, fillWidth, }: SliderInputProps) => import("react").JSX.Element;
38
+ declare const SliderInput: ({ variant, size, label, labelTooltip, value, onChange, onInteractionStart, onInteractionEnd, min, max, step, isDisabled, width, fillWidth, }: SliderInputProps) => import("react").JSX.Element;
31
39
  export default SliderInput;