@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.
- package/dist/charts/ChartLegend.js +3 -3
- package/dist/charts/ChartPrimitives.d.ts +15 -0
- package/dist/charts/ChartPrimitives.js +28 -9
- package/dist/inputs/CheckboxInput.d.ts +11 -14
- package/dist/inputs/CheckboxInput.js +10 -27
- package/dist/inputs/ColorInput.d.ts +4 -2
- package/dist/inputs/ColorInput.js +14 -28
- package/dist/inputs/CopyInput.d.ts +4 -2
- package/dist/inputs/CopyInput.js +11 -3
- package/dist/inputs/DateInput.d.ts +4 -2
- package/dist/inputs/DateInput.js +24 -31
- package/dist/inputs/Input.d.ts +82 -5
- package/dist/inputs/Input.js +111 -33
- package/dist/inputs/MultiSelectInput.d.ts +4 -4
- package/dist/inputs/MultiSelectInput.js +36 -45
- package/dist/inputs/MultiTextInput.d.ts +5 -16
- package/dist/inputs/MultiTextInput.js +24 -31
- package/dist/inputs/NumberInput.d.ts +1 -1
- package/dist/inputs/NumberInput.js +10 -2
- package/dist/inputs/PasswordInput.d.ts +4 -3
- package/dist/inputs/PasswordInput.js +6 -3
- package/dist/inputs/RadioInput.d.ts +11 -14
- package/dist/inputs/RadioInput.js +18 -34
- package/dist/inputs/SelectInput.d.ts +5 -14
- package/dist/inputs/SelectInput.js +35 -57
- package/dist/inputs/SliderInput.d.ts +9 -1
- package/dist/inputs/SliderInput.js +47 -21
- package/dist/inputs/SwitcherInput.d.ts +7 -2
- package/dist/inputs/SwitcherInput.js +7 -7
- package/dist/inputs/TextAreaInput.d.ts +5 -18
- package/dist/inputs/TextAreaInput.js +29 -57
- package/dist/inputs/TextInput.d.ts +6 -2
- package/dist/inputs/TextInput.js +2 -1
- package/dist/inputs/ToggleInput.d.ts +10 -1
- package/dist/inputs/ToggleInput.js +31 -9
- package/dist/styles.css +20 -19
- package/dist/table/TableSelectCell.js +5 -4
- package/package.json +1 -1
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import Text from "../text/Text.js";
|
|
3
3
|
import FlexWrapper, { AlignItems, FlexDirection, JustifyContent } from "../containers/FlexWrapper.js";
|
|
4
|
-
import { InputLabel } from "./Input.js";
|
|
4
|
+
import { InputLabel, InputSize, InputVariant, getInputSurfaceColor, getInputTextSize } from "./Input.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
import { styled } from "@linaria/react";
|
|
7
|
+
import { match } from "ts-pattern";
|
|
7
8
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
//#region src/inputs/SliderInput.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Rail thickness per `InputSize`. A slider has no box to fill, so it runs its
|
|
13
|
+
* own scale rather than `getInputHeight`.
|
|
14
|
+
*/
|
|
15
|
+
function getSliderRailHeight(size) {
|
|
16
|
+
return match(size).returnType().with(InputSize.SMALL, () => 2).with(InputSize.MEDIUM, () => 3).with(InputSize.LARGE, () => 4).exhaustive();
|
|
17
|
+
}
|
|
18
|
+
function getSliderHandleSize(size) {
|
|
19
|
+
return match(size).returnType().with(InputSize.SMALL, () => 6).with(InputSize.MEDIUM, () => 8).with(InputSize.LARGE, () => 10).exhaustive();
|
|
20
|
+
}
|
|
10
21
|
var _exp = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "pointer";
|
|
11
22
|
var _exp2 = () => ({ $isDisabled }) => $isDisabled ? .5 : 1;
|
|
12
23
|
var SliderWrapper = withTheme(/*#__PURE__*/ styled("div")({
|
|
@@ -18,39 +29,48 @@ var SliderWrapper = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
18
29
|
"sbeizks-1": [_exp2()]
|
|
19
30
|
}
|
|
20
31
|
}));
|
|
21
|
-
var _exp3 = () => ({
|
|
32
|
+
var _exp3 = () => ({ $size }) => `${getSliderRailHeight($size)}px`;
|
|
33
|
+
var _exp4 = () => ({ theme, $variant }) => getInputSurfaceColor(theme, $variant);
|
|
22
34
|
var SliderTrack = withTheme(/*#__PURE__*/ styled("div")({
|
|
23
35
|
name: "SliderTrack",
|
|
24
36
|
class: "s42jcip",
|
|
25
37
|
propsAsIs: false,
|
|
26
|
-
vars: {
|
|
38
|
+
vars: {
|
|
39
|
+
"s42jcip-0": [_exp3()],
|
|
40
|
+
"s42jcip-1": [_exp4()]
|
|
41
|
+
}
|
|
27
42
|
}));
|
|
28
|
-
var
|
|
43
|
+
var _exp5 = () => ({ theme }) => theme.color.icon.primary;
|
|
29
44
|
var SliderFill = withTheme(/*#__PURE__*/ styled("div")({
|
|
30
45
|
name: "SliderFill",
|
|
31
46
|
class: "s1b59sw7",
|
|
32
47
|
propsAsIs: false,
|
|
33
|
-
vars: { "s1b59sw7-0": [
|
|
48
|
+
vars: { "s1b59sw7-0": [_exp5()] }
|
|
34
49
|
}));
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
50
|
+
var _exp6 = () => ({ $percentage, $size }) => {
|
|
51
|
+
const handle = getSliderHandleSize($size);
|
|
52
|
+
return `calc(${handle / 2}px + ${$percentage}% - ${$percentage / 100 * handle}px)`;
|
|
53
|
+
};
|
|
54
|
+
var _exp8 = () => ({ $size }) => `${getSliderHandleSize($size)}px`;
|
|
55
|
+
var _exp9 = () => ({ theme }) => theme.color.icon.primary;
|
|
56
|
+
var _exp0 = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "grab";
|
|
57
|
+
var _exp1 = () => ({ $isDragging }) => $isDragging ? "none" : "left 0.1s ease-out, transform 0.1s ease-out";
|
|
58
|
+
var _exp10 = () => ({ $isDisabled }) => $isDisabled ? "none" : "auto";
|
|
59
|
+
var _exp11 = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "grabbing";
|
|
60
|
+
var _exp12 = () => ({ $isDisabled }) => $isDisabled ? "translate(-50%, -50%)" : "translate(-50%, -50%) scale(1.1)";
|
|
42
61
|
var SliderHandle = withTheme(/*#__PURE__*/ styled("div")({
|
|
43
62
|
name: "SliderHandle",
|
|
44
63
|
class: "salrebx",
|
|
45
64
|
propsAsIs: false,
|
|
46
65
|
vars: {
|
|
47
|
-
"salrebx-0": [
|
|
48
|
-
"salrebx-1": [
|
|
49
|
-
"salrebx-2": [
|
|
50
|
-
"salrebx-3": [
|
|
51
|
-
"salrebx-4": [
|
|
52
|
-
"salrebx-5": [
|
|
53
|
-
"salrebx-6": [
|
|
66
|
+
"salrebx-0": [_exp6()],
|
|
67
|
+
"salrebx-1": [_exp8()],
|
|
68
|
+
"salrebx-2": [_exp9()],
|
|
69
|
+
"salrebx-3": [_exp0()],
|
|
70
|
+
"salrebx-4": [_exp1()],
|
|
71
|
+
"salrebx-5": [_exp10()],
|
|
72
|
+
"salrebx-6": [_exp11()],
|
|
73
|
+
"salrebx-7": [_exp12()]
|
|
54
74
|
}
|
|
55
75
|
}));
|
|
56
76
|
var HiddenInput = /*#__PURE__*/ styled("input")({
|
|
@@ -64,7 +84,7 @@ var HiddenInput = /*#__PURE__*/ styled("input")({
|
|
|
64
84
|
* `onChange` fires on every pointer move. When each change is expensive, drive
|
|
65
85
|
* a preview from it and commit on `onInteractionEnd`.
|
|
66
86
|
*/
|
|
67
|
-
var SliderInput = ({ label, labelTooltip, value, onChange, onInteractionStart, onInteractionEnd, min = 0, max = 100, step = 1, isDisabled = false, width, fillWidth }) => {
|
|
87
|
+
var SliderInput = ({ variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, label, labelTooltip, value, onChange, onInteractionStart, onInteractionEnd, min = 0, max = 100, step = 1, isDisabled = false, width, fillWidth }) => {
|
|
68
88
|
const [isDragging, setIsDragging] = useState(false);
|
|
69
89
|
const sliderRef = useRef(null);
|
|
70
90
|
const isInteractingRef = useRef(false);
|
|
@@ -134,13 +154,18 @@ var SliderInput = ({ label, labelTooltip, value, onChange, onInteractionStart, o
|
|
|
134
154
|
children: [/* @__PURE__ */ jsx(InputLabel, {
|
|
135
155
|
label,
|
|
136
156
|
labelTooltip
|
|
137
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
157
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
158
|
+
size: getInputTextSize(size),
|
|
159
|
+
children: value
|
|
160
|
+
})]
|
|
138
161
|
}), /* @__PURE__ */ jsxs(SliderWrapper, {
|
|
139
162
|
ref: sliderRef,
|
|
140
163
|
$isDisabled: isDisabled,
|
|
141
164
|
onMouseDown: handleMouseDown,
|
|
142
165
|
children: [
|
|
143
166
|
/* @__PURE__ */ jsx(SliderTrack, {
|
|
167
|
+
$variant: variant,
|
|
168
|
+
$size: size,
|
|
144
169
|
$isDisabled: isDisabled,
|
|
145
170
|
children: /* @__PURE__ */ jsx(SliderFill, {
|
|
146
171
|
$percentage: percentage,
|
|
@@ -150,6 +175,7 @@ var SliderInput = ({ label, labelTooltip, value, onChange, onInteractionStart, o
|
|
|
150
175
|
}),
|
|
151
176
|
/* @__PURE__ */ jsx(SliderHandle, {
|
|
152
177
|
$percentage: percentage,
|
|
178
|
+
$size: size,
|
|
153
179
|
$isDisabled: isDisabled,
|
|
154
180
|
$isDragging: isDragging
|
|
155
181
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InputSize } from "./Input";
|
|
1
|
+
import { InputSize, InputVariant } from "./Input";
|
|
2
2
|
export interface SwitcherInputItem {
|
|
3
3
|
/** Matched against `selectedId` to decide which segment is active. */
|
|
4
4
|
id: string;
|
|
@@ -7,6 +7,11 @@ export interface SwitcherInputItem {
|
|
|
7
7
|
onClick: () => void;
|
|
8
8
|
}
|
|
9
9
|
export interface SwitcherInputProps {
|
|
10
|
+
/**
|
|
11
|
+
* Container surface color. The selected segment is a state color and stays
|
|
12
|
+
* `background.secondary` regardless. @default InputVariant.PRIMARY
|
|
13
|
+
*/
|
|
14
|
+
variant?: InputVariant;
|
|
10
15
|
/** @default InputSize.MEDIUM */
|
|
11
16
|
size?: InputSize;
|
|
12
17
|
/** Segments, left to right. */
|
|
@@ -18,5 +23,5 @@ export interface SwitcherInputProps {
|
|
|
18
23
|
* A segmented control for switching between a few mutually exclusive views.
|
|
19
24
|
* Each item carries its own `onClick`, so there is no top-level change handler.
|
|
20
25
|
*/
|
|
21
|
-
declare const SwitcherInput: ({ size, items, selectedId }: SwitcherInputProps) => import("react").JSX.Element;
|
|
26
|
+
declare const SwitcherInput: ({ variant, size, items, selectedId, }: SwitcherInputProps) => import("react").JSX.Element;
|
|
22
27
|
export default SwitcherInput;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import Text, { TextWeight } from "../text/Text.js";
|
|
3
|
-
import { InputSize } from "./Input.js";
|
|
3
|
+
import { InputSize, InputVariant, getInputBorderColor, getInputHeight, getInputSurfaceColor, getInputTextSize } from "./Input.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
import { styled } from "@linaria/react";
|
|
6
6
|
import { match } from "ts-pattern";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region src/inputs/SwitcherInput.tsx
|
|
9
|
-
var _exp = () => ({ theme }) => theme
|
|
10
|
-
var _exp2 = () => ({ theme }) => theme
|
|
9
|
+
var _exp = () => ({ theme, $variant }) => getInputSurfaceColor(theme, $variant);
|
|
10
|
+
var _exp2 = () => ({ theme, $variant }) => getInputBorderColor(theme, $variant);
|
|
11
11
|
var _exp3 = () => ({ $size }) => {
|
|
12
12
|
return match($size).with(InputSize.SMALL, () => "0 1.5px").with(InputSize.MEDIUM, () => "1px 2px").with(InputSize.LARGE, () => "2px 2px").exhaustive();
|
|
13
13
|
};
|
|
14
|
-
var _exp4 = () => ({ $size }) =>
|
|
15
|
-
return match($size).with(InputSize.SMALL, () => "24px").with(InputSize.MEDIUM, () => "28px").with(InputSize.LARGE, () => "32px").exhaustive();
|
|
16
|
-
};
|
|
14
|
+
var _exp4 = () => ({ $size }) => getInputHeight($size);
|
|
17
15
|
var StyledSwitcherInput = withTheme(/*#__PURE__*/ styled("div")({
|
|
18
16
|
name: "StyledSwitcherInput",
|
|
19
17
|
class: "sx2momv",
|
|
@@ -44,14 +42,16 @@ var StyledSwitcherInputItem = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
44
42
|
* A segmented control for switching between a few mutually exclusive views.
|
|
45
43
|
* Each item carries its own `onClick`, so there is no top-level change handler.
|
|
46
44
|
*/
|
|
47
|
-
var SwitcherInput = ({ size = InputSize.MEDIUM, items, selectedId }) => {
|
|
45
|
+
var SwitcherInput = ({ variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, items, selectedId }) => {
|
|
48
46
|
return /* @__PURE__ */ jsx(StyledSwitcherInput, {
|
|
49
47
|
$size: size,
|
|
48
|
+
$variant: variant,
|
|
50
49
|
children: items.map((item) => /* @__PURE__ */ jsx(StyledSwitcherInputItem, {
|
|
51
50
|
onClick: item.onClick,
|
|
52
51
|
$isSelected: item.id === selectedId,
|
|
53
52
|
$size: size,
|
|
54
53
|
children: /* @__PURE__ */ jsx(Text, {
|
|
54
|
+
size: getInputTextSize(size),
|
|
55
55
|
weight: item.id === selectedId ? TextWeight.MEDIUM : TextWeight.REGULAR,
|
|
56
56
|
cursor: "pointer",
|
|
57
57
|
children: item.label
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export declare enum TextAreaSize {
|
|
3
|
-
SMALL = "SMALL",
|
|
4
|
-
MEDIUM = "MEDIUM",
|
|
5
|
-
LARGE = "LARGE"
|
|
6
|
-
}
|
|
7
|
-
/** Background treatment. `TRANSPARENT` is for embedding in an existing surface. */
|
|
8
|
-
export declare enum TextAreaVariant {
|
|
9
|
-
TRANSPARENT = "TRANSPARENT",
|
|
10
|
-
BASE = "BASE",
|
|
11
|
-
PRIMARY = "PRIMARY",
|
|
12
|
-
SECONDARY = "SECONDARY",
|
|
13
|
-
TERTIARY = "TERTIARY"
|
|
14
|
-
}
|
|
1
|
+
import { InputSize, InputVariant } from "./Input";
|
|
15
2
|
export interface TextAreaInputProps {
|
|
16
3
|
/** Controlled value. */
|
|
17
4
|
value?: string;
|
|
18
5
|
onChange: (value: string) => void;
|
|
19
|
-
/** @default
|
|
20
|
-
variant?:
|
|
21
|
-
/** @default
|
|
22
|
-
size?:
|
|
6
|
+
/** Field surface color. @default InputVariant.PRIMARY */
|
|
7
|
+
variant?: InputVariant;
|
|
8
|
+
/** @default InputSize.MEDIUM */
|
|
9
|
+
size?: InputSize;
|
|
23
10
|
/** Visible rows before scrolling. @default 3 */
|
|
24
11
|
lines?: number;
|
|
25
12
|
placeholder?: string;
|
|
@@ -3,36 +3,24 @@ 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
5
|
import TextShimmer from "../text/TextShimmer.js";
|
|
6
|
-
import { InputLabel } from "./Input.js";
|
|
6
|
+
import { InputLabel, InputSize, InputVariant, getInputBorderColor, getInputFontSize, getInputLineHeight, getInputPadding, getInputPaddingValue, getInputSurfaceColor } from "./Input.js";
|
|
7
7
|
/* empty css */
|
|
8
8
|
import { styled } from "@linaria/react";
|
|
9
|
-
import { match } from "ts-pattern";
|
|
10
9
|
import { forwardRef, useState } from "react";
|
|
11
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
11
|
//#region src/inputs/TextAreaInput.tsx
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
TextAreaVariant["SECONDARY"] = "SECONDARY";
|
|
26
|
-
TextAreaVariant["TERTIARY"] = "TERTIARY";
|
|
27
|
-
return TextAreaVariant;
|
|
28
|
-
}({});
|
|
29
|
-
var _exp = () => ({ $lines, $size, theme, $height, $noPadding }) => {
|
|
30
|
-
if ($height) return "auto";
|
|
31
|
-
const lineHeight = match($size).with("SMALL", () => Number(theme.font.sans.height.body_sm.replace("px", ""))).with("MEDIUM", () => Number(theme.font.sans.height.body_md.replace("px", ""))).with("LARGE", () => Number(theme.font.sans.height.body_lg.replace("px", ""))).exhaustive();
|
|
32
|
-
if ($noPadding) return `${lineHeight * $lines}px`;
|
|
33
|
-
const padding = match($size).with("SMALL", () => 12).with("MEDIUM", () => 16).with("LARGE", () => 20).exhaustive();
|
|
34
|
-
return `${lineHeight * $lines + padding}px`;
|
|
35
|
-
};
|
|
12
|
+
/**
|
|
13
|
+
* Row count drives the height, so the box is measured rather than stepped:
|
|
14
|
+
* `lines` line-boxes plus the inset above and below. Shared by the field and by
|
|
15
|
+
* the loading placeholder that has to match it exactly.
|
|
16
|
+
*/
|
|
17
|
+
function getTextAreaMinHeight(theme, size, lines, height, noPadding) {
|
|
18
|
+
if (height) return "auto";
|
|
19
|
+
const lineHeight = Number(getInputLineHeight(theme, size).replace("px", ""));
|
|
20
|
+
if (noPadding) return `${lineHeight * lines}px`;
|
|
21
|
+
return `${lineHeight * lines + 2 * getInputPaddingValue(size)}px`;
|
|
22
|
+
}
|
|
23
|
+
var _exp = () => ({ $lines, $size, theme, $height, $noPadding }) => getTextAreaMinHeight(theme, $size, $lines, $height, $noPadding);
|
|
36
24
|
var _exp2 = () => ({ $fillWidth, $width }) => {
|
|
37
25
|
if ($fillWidth) return "100%";
|
|
38
26
|
if ($width) return getCssSizeValue($width, "0");
|
|
@@ -44,26 +32,19 @@ var _exp3 = () => ({ $height, $fillHeight }) => {
|
|
|
44
32
|
return "auto";
|
|
45
33
|
};
|
|
46
34
|
var _exp4 = () => ({ $fillHeight }) => $fillHeight ? "1" : "none";
|
|
47
|
-
var _exp5 = () => ({ theme, $variant }) =>
|
|
35
|
+
var _exp5 = () => ({ theme, $variant }) => getInputSurfaceColor(theme, $variant);
|
|
48
36
|
var _exp6 = () => ({ theme, $variant, $error, $noBorder }) => {
|
|
49
|
-
if ($noBorder) return "
|
|
37
|
+
if ($noBorder) return "transparent";
|
|
50
38
|
if ($error) return theme.color.border.error;
|
|
51
|
-
return
|
|
39
|
+
return getInputBorderColor(theme, $variant);
|
|
52
40
|
};
|
|
53
41
|
var _exp7 = () => ({ theme }) => theme.color.text.primary;
|
|
54
|
-
var _exp8 = () => ({ theme, $size }) =>
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
var _exp9 = () => ({ theme, $size }) => {
|
|
58
|
-
return match($size).with("SMALL", () => theme.font.sans.height.body_sm).with("MEDIUM", () => theme.font.sans.height.body_md).with("LARGE", () => theme.font.sans.height.body_lg).exhaustive();
|
|
59
|
-
};
|
|
42
|
+
var _exp8 = () => ({ theme, $size }) => getInputFontSize(theme, $size);
|
|
43
|
+
var _exp9 = () => ({ theme, $size }) => getInputLineHeight(theme, $size);
|
|
60
44
|
var _exp0 = () => ({ theme }) => theme.font.sans.weight.regular;
|
|
61
45
|
var _exp1 = () => ({ theme }) => theme.font.sans.family;
|
|
62
|
-
var _exp10 = () => ({ $size, $noPadding }) =>
|
|
63
|
-
|
|
64
|
-
return match($size).with("SMALL", () => "6px").with("MEDIUM", () => "8px").with("LARGE", () => "10px").exhaustive();
|
|
65
|
-
};
|
|
66
|
-
var _exp11 = () => ({ theme }) => theme.color.border.primary;
|
|
46
|
+
var _exp10 = () => ({ $size, $noPadding }) => $noPadding ? "0" : getInputPadding($size);
|
|
47
|
+
var _exp11 = () => ({ theme, $variant }) => getInputBorderColor(theme, $variant);
|
|
67
48
|
var _exp12 = () => ({ theme }) => theme.color.border.selected;
|
|
68
49
|
var _exp13 = () => ({ theme }) => theme.color.text.disabled;
|
|
69
50
|
var StyledTextArea = withTheme(/*#__PURE__*/ styled("textarea")({
|
|
@@ -101,13 +82,7 @@ var TextAreaWrapper = /*#__PURE__*/ styled("div")({
|
|
|
101
82
|
"tu0hnok-2": [_exp16()]
|
|
102
83
|
}
|
|
103
84
|
});
|
|
104
|
-
var _exp17 = () => ({ $lines, $size, theme, $height, $noPadding }) =>
|
|
105
|
-
if ($height) return "auto";
|
|
106
|
-
const lineHeight = match($size).with("SMALL", () => Number(theme.font.sans.height.body_sm.replace("px", ""))).with("MEDIUM", () => Number(theme.font.sans.height.body_md.replace("px", ""))).with("LARGE", () => Number(theme.font.sans.height.body_lg.replace("px", ""))).exhaustive();
|
|
107
|
-
if ($noPadding) return `${lineHeight * $lines}px`;
|
|
108
|
-
const padding = match($size).with("SMALL", () => 12).with("MEDIUM", () => 16).with("LARGE", () => 20).exhaustive();
|
|
109
|
-
return `${lineHeight * $lines + padding}px`;
|
|
110
|
-
};
|
|
85
|
+
var _exp17 = () => ({ $lines, $size, theme, $height, $noPadding }) => getTextAreaMinHeight(theme, $size, $lines, $height, $noPadding);
|
|
111
86
|
var _exp18 = () => ({ $fillWidth, $width }) => {
|
|
112
87
|
if ($fillWidth) return "100%";
|
|
113
88
|
if ($width) return getCssSizeValue($width, "0");
|
|
@@ -119,15 +94,12 @@ var _exp19 = () => ({ $height, $fillHeight }) => {
|
|
|
119
94
|
return "auto";
|
|
120
95
|
};
|
|
121
96
|
var _exp20 = () => ({ $fillHeight }) => $fillHeight ? "1" : "none";
|
|
122
|
-
var _exp21 = () => ({ theme, $variant }) =>
|
|
97
|
+
var _exp21 = () => ({ theme, $variant }) => getInputSurfaceColor(theme, $variant);
|
|
123
98
|
var _exp22 = () => ({ theme, $variant, $noBorder }) => {
|
|
124
99
|
if ($noBorder) return "transparent";
|
|
125
|
-
return
|
|
126
|
-
};
|
|
127
|
-
var _exp23 = () => ({ $size, $noPadding }) => {
|
|
128
|
-
if ($noPadding) return "0";
|
|
129
|
-
return match($size).with("SMALL", () => "6px").with("MEDIUM", () => "8px").with("LARGE", () => "10px").exhaustive();
|
|
100
|
+
return getInputBorderColor(theme, $variant);
|
|
130
101
|
};
|
|
102
|
+
var _exp23 = () => ({ $size, $noPadding }) => $noPadding ? "0" : getInputPadding($size);
|
|
131
103
|
var LoadingContainer = withTheme(/*#__PURE__*/ styled("div")({
|
|
132
104
|
name: "LoadingContainer",
|
|
133
105
|
class: "l48iv0n",
|
|
@@ -144,9 +116,9 @@ var LoadingContainer = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
144
116
|
}));
|
|
145
117
|
var DEFAULT_STATE = { error: void 0 };
|
|
146
118
|
var TEXTAREA_SIZE_TO_SHIMMER_HEIGHT_MAP = {
|
|
147
|
-
[
|
|
148
|
-
[
|
|
149
|
-
[
|
|
119
|
+
[InputSize.SMALL]: 12,
|
|
120
|
+
[InputSize.MEDIUM]: 14,
|
|
121
|
+
[InputSize.LARGE]: 16
|
|
150
122
|
};
|
|
151
123
|
/**
|
|
152
124
|
* A multi-line text field. Not resizable by the user — size it with `lines`,
|
|
@@ -155,7 +127,7 @@ var TEXTAREA_SIZE_TO_SHIMMER_HEIGHT_MAP = {
|
|
|
155
127
|
* Note this one takes `required`/`disabled` rather than the `isRequired`/
|
|
156
128
|
* `isDisabled` the other inputs use.
|
|
157
129
|
*/
|
|
158
|
-
var TextAreaInput = forwardRef(({ variant =
|
|
130
|
+
var TextAreaInput = forwardRef(({ variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, lines = 3, value, min, max, placeholder, label, labelTooltip, error, required, disabled, autoFocus, onChange, onKeyDown, onBlur, onFocus, width, height, fillWidth, fillHeight, noBorder, noPadding, isLoading }, ref) => {
|
|
159
131
|
const [state, setState] = useState(DEFAULT_STATE);
|
|
160
132
|
const handleFocus = (e) => {
|
|
161
133
|
setState({
|
|
@@ -244,4 +216,4 @@ var TextAreaInput = forwardRef(({ variant = "PRIMARY", size = "MEDIUM", lines =
|
|
|
244
216
|
});
|
|
245
217
|
TextAreaInput.displayName = "TextAreaInput";
|
|
246
218
|
//#endregion
|
|
247
|
-
export {
|
|
219
|
+
export { TextAreaInput as default };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type InputProps } from "./Input";
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Every `InputProps` field except `type` and `parse`, which are fixed to text.
|
|
4
|
+
* `onFocus` is omitted because the field owns focus to clear its length error,
|
|
5
|
+
* and `step` is numeric-only.
|
|
6
|
+
*/
|
|
7
|
+
export type TextInputProps = Omit<InputProps<string>, "type" | "parse" | "onFocus" | "step">;
|
|
4
8
|
/**
|
|
5
9
|
* A single-line text field. The default input.
|
|
6
10
|
*
|
package/dist/inputs/TextInput.js
CHANGED
|
@@ -9,7 +9,7 @@ var DEFAULT_STATE = { error: "" };
|
|
|
9
9
|
* `min`/`max` bound the *character count*, not a numeric range — the field
|
|
10
10
|
* validates length on blur and shows its own error. A `error` you pass wins.
|
|
11
11
|
*/
|
|
12
|
-
var TextInput = forwardRef(({ size, value, min, max, placeholder, label, labelTooltip, leading, trailing, error, isRequired, isDisabled, autoFocus, onChange, onKeyDown, onBlur, fillWidth, width, isMonospace }, ref) => {
|
|
12
|
+
var TextInput = forwardRef(({ variant, size, value, min, max, placeholder, label, labelTooltip, leading, trailing, error, isRequired, isDisabled, autoFocus, onChange, onKeyDown, onBlur, fillWidth, width, isMonospace }, ref) => {
|
|
13
13
|
const [state, setState] = useState(DEFAULT_STATE);
|
|
14
14
|
const handleFocus = () => {
|
|
15
15
|
setState({
|
|
@@ -31,6 +31,7 @@ var TextInput = forwardRef(({ size, value, min, max, placeholder, label, labelTo
|
|
|
31
31
|
return /* @__PURE__ */ jsx(Input, {
|
|
32
32
|
parse: String,
|
|
33
33
|
onChange,
|
|
34
|
+
variant,
|
|
34
35
|
size,
|
|
35
36
|
ref,
|
|
36
37
|
type: "text",
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import { InputSize, InputVariant } from "./Input";
|
|
1
2
|
export interface ToggleInputProps {
|
|
3
|
+
/**
|
|
4
|
+
* Off-state track color. The on-state track is a state color and stays
|
|
5
|
+
* `icon.primary`. @default InputVariant.PRIMARY
|
|
6
|
+
*/
|
|
7
|
+
variant?: InputVariant;
|
|
8
|
+
/** Track size — a hit target, so it runs 28×16 / 32×18 / 36×20px.
|
|
9
|
+
* @default InputSize.MEDIUM */
|
|
10
|
+
size?: InputSize;
|
|
2
11
|
/** Label rendered above the switch, like the other inputs. */
|
|
3
12
|
label?: string;
|
|
4
13
|
/** Adds an info icon beside the label with this content on hover. */
|
|
@@ -18,5 +27,5 @@ export interface ToggleInputProps {
|
|
|
18
27
|
* Use it for settings that apply immediately. For something that only takes
|
|
19
28
|
* effect on submit, a `CheckboxInput` reads more honestly.
|
|
20
29
|
*/
|
|
21
|
-
declare const ToggleInput: ({ label, labelTooltip, value, onChange, isDisabled, width, fillWidth, }: ToggleInputProps) => import("react").JSX.Element;
|
|
30
|
+
declare const ToggleInput: ({ variant, size, label, labelTooltip, value, onChange, isDisabled, width, fillWidth, }: ToggleInputProps) => import("react").JSX.Element;
|
|
22
31
|
export default ToggleInput;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import FlexWrapper, { AlignItems, JustifyContent } from "../containers/FlexWrapper.js";
|
|
3
|
-
import { InputLabel } from "./Input.js";
|
|
3
|
+
import { InputLabel, InputSize, InputVariant, getInputSurfaceColor } from "./Input.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
import { styled } from "@linaria/react";
|
|
6
|
+
import { match } from "ts-pattern";
|
|
6
7
|
import { useCallback } from "react";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
//#region src/inputs/ToggleInput.tsx
|
|
10
|
+
function getToggleTrackWidth(size) {
|
|
11
|
+
return match(size).returnType().with(InputSize.SMALL, () => 28).with(InputSize.MEDIUM, () => 32).with(InputSize.LARGE, () => 36).exhaustive();
|
|
12
|
+
}
|
|
13
|
+
function getToggleTrackHeight(size) {
|
|
14
|
+
return match(size).returnType().with(InputSize.SMALL, () => 16).with(InputSize.MEDIUM, () => 18).with(InputSize.LARGE, () => 20).exhaustive();
|
|
15
|
+
}
|
|
16
|
+
/** The thumb fills the track minus its border and inset on each side — 12 / 14 / 16px. */
|
|
17
|
+
function getToggleThumbSize(size) {
|
|
18
|
+
return getToggleTrackHeight(size) - 4;
|
|
19
|
+
}
|
|
9
20
|
var _exp = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "pointer";
|
|
10
21
|
var _exp2 = () => ({ $isDisabled }) => $isDisabled ? .5 : 1;
|
|
11
22
|
var ToggleWrapper = withTheme(/*#__PURE__*/ styled("div")({
|
|
@@ -17,26 +28,34 @@ var ToggleWrapper = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
17
28
|
"t1t8zlu-1": [_exp2()]
|
|
18
29
|
}
|
|
19
30
|
}));
|
|
20
|
-
var _exp3 = () => ({
|
|
21
|
-
var _exp4 = () => ({
|
|
31
|
+
var _exp3 = () => ({ $size }) => `${getToggleTrackWidth($size)}px`;
|
|
32
|
+
var _exp4 = () => ({ $size }) => `${getToggleTrackHeight($size)}px`;
|
|
33
|
+
var _exp6 = () => ({ theme, $variant, $isChecked }) => $isChecked ? theme.color.icon.primary : getInputSurfaceColor(theme, $variant);
|
|
34
|
+
var _exp8 = () => ({ theme }) => theme.color.border.primary;
|
|
22
35
|
var ToggleTrack = withTheme(/*#__PURE__*/ styled("div")({
|
|
23
36
|
name: "ToggleTrack",
|
|
24
37
|
class: "t1br7yd",
|
|
25
38
|
propsAsIs: false,
|
|
26
39
|
vars: {
|
|
27
40
|
"t1br7yd-0": [_exp3()],
|
|
28
|
-
"t1br7yd-1": [_exp4()]
|
|
41
|
+
"t1br7yd-1": [_exp4()],
|
|
42
|
+
"t1br7yd-2": [_exp6()],
|
|
43
|
+
"t1br7yd-3": [_exp8()]
|
|
29
44
|
}
|
|
30
45
|
}));
|
|
31
|
-
var
|
|
32
|
-
var
|
|
46
|
+
var _exp9 = () => ({ $size, $isChecked }) => $isChecked ? `calc(100% - ${getToggleThumbSize($size)}px - 1.5px)` : `1.5px`;
|
|
47
|
+
var _exp1 = () => ({ $size }) => `${getToggleThumbSize($size)}px`;
|
|
48
|
+
var _exp10 = () => ({ theme, $isChecked }) => $isChecked ? theme.color.background.primary : theme.color.background.primaryAlt;
|
|
49
|
+
var _exp11 = () => ({ theme }) => theme.color.border.primary;
|
|
33
50
|
var ToggleThumb = withTheme(/*#__PURE__*/ styled("div")({
|
|
34
51
|
name: "ToggleThumb",
|
|
35
52
|
class: "t1xwadc7",
|
|
36
53
|
propsAsIs: false,
|
|
37
54
|
vars: {
|
|
38
|
-
"t1xwadc7-0": [
|
|
39
|
-
"t1xwadc7-1": [
|
|
55
|
+
"t1xwadc7-0": [_exp9()],
|
|
56
|
+
"t1xwadc7-1": [_exp1()],
|
|
57
|
+
"t1xwadc7-2": [_exp10()],
|
|
58
|
+
"t1xwadc7-3": [_exp11()]
|
|
40
59
|
}
|
|
41
60
|
}));
|
|
42
61
|
var HiddenInput = /*#__PURE__*/ styled("input")({
|
|
@@ -50,7 +69,7 @@ var HiddenInput = /*#__PURE__*/ styled("input")({
|
|
|
50
69
|
* Use it for settings that apply immediately. For something that only takes
|
|
51
70
|
* effect on submit, a `CheckboxInput` reads more honestly.
|
|
52
71
|
*/
|
|
53
|
-
var ToggleInput = ({ label, labelTooltip, value, onChange, isDisabled = false, width, fillWidth }) => {
|
|
72
|
+
var ToggleInput = ({ variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, label, labelTooltip, value, onChange, isDisabled = false, width, fillWidth }) => {
|
|
54
73
|
const handleClick = useCallback(() => {
|
|
55
74
|
if (!isDisabled) onChange(!value);
|
|
56
75
|
}, [
|
|
@@ -86,9 +105,12 @@ var ToggleInput = ({ label, labelTooltip, value, onChange, isDisabled = false, w
|
|
|
86
105
|
"aria-disabled": isDisabled,
|
|
87
106
|
tabIndex: isDisabled ? -1 : 0,
|
|
88
107
|
children: [/* @__PURE__ */ jsx(ToggleTrack, {
|
|
108
|
+
$variant: variant,
|
|
109
|
+
$size: size,
|
|
89
110
|
$isChecked: value,
|
|
90
111
|
$isDisabled: isDisabled,
|
|
91
112
|
children: /* @__PURE__ */ jsx(ToggleThumb, {
|
|
113
|
+
$size: size,
|
|
92
114
|
$isChecked: value,
|
|
93
115
|
$isDisabled: isDisabled
|
|
94
116
|
})
|