@galaxy-io/dls 1.4.15 → 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/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 +15 -15
- package/dist/table/TableSelectCell.js +5 -4
- package/package.json +1 -1
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
export declare enum CheckboxInputVariant {
|
|
3
|
-
PRIMARY = "PRIMARY",
|
|
4
|
-
SECONDARY = "SECONDARY"
|
|
5
|
-
}
|
|
6
|
-
/** Box size. Two steps only — this is a hit target, not a type scale. */
|
|
7
|
-
export declare enum CheckboxInputSize {
|
|
8
|
-
SMALL = "SMALL",
|
|
9
|
-
MEDIUM = "MEDIUM"
|
|
10
|
-
}
|
|
1
|
+
import { InputSize, InputVariant } from "./Input";
|
|
11
2
|
export interface CheckboxInputProps {
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Unchecked fill color. The checked fill is a state color and stays
|
|
5
|
+
* `background.primaryAlt` so the tick keeps its contrast. Unlike the field
|
|
6
|
+
* inputs, `TRANSPARENT` keeps the hairline border here — without it the box
|
|
7
|
+
* would be invisible. @default InputVariant.PRIMARY
|
|
8
|
+
*/
|
|
9
|
+
variant?: InputVariant;
|
|
10
|
+
/** Box 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 checkbox holds none of its own. */
|
|
17
14
|
isChecked: boolean;
|
|
18
15
|
/** Draw a dash instead of a tick — for a partially-selected group. */
|
|
@@ -3,24 +3,12 @@ import Text, { TextVariant } from "../text/Text.js";
|
|
|
3
3
|
import Icon, { IconVariant, IconWeight } from "../icons/Icon.js";
|
|
4
4
|
import FlexWrapper, { AlignItems } from "../containers/FlexWrapper.js";
|
|
5
5
|
import RequiredMarker from "../text/RequiredMarker.js";
|
|
6
|
+
import { InputSize, InputVariant, getInputControlSize, getInputSurfaceColor } from "./Input.js";
|
|
6
7
|
/* empty css */
|
|
7
8
|
import { styled } from "@linaria/react";
|
|
8
|
-
import { match } from "ts-pattern";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { CheckIcon, MinusIcon } from "@phosphor-icons/react";
|
|
11
11
|
//#region src/inputs/CheckboxInput.tsx
|
|
12
|
-
/** Fill color when checked. */
|
|
13
|
-
var CheckboxInputVariant = /* @__PURE__ */ function(CheckboxInputVariant) {
|
|
14
|
-
CheckboxInputVariant["PRIMARY"] = "PRIMARY";
|
|
15
|
-
CheckboxInputVariant["SECONDARY"] = "SECONDARY";
|
|
16
|
-
return CheckboxInputVariant;
|
|
17
|
-
}({});
|
|
18
|
-
/** Box size. Two steps only — this is a hit target, not a type scale. */
|
|
19
|
-
var CheckboxInputSize = /* @__PURE__ */ function(CheckboxInputSize) {
|
|
20
|
-
CheckboxInputSize["SMALL"] = "SMALL";
|
|
21
|
-
CheckboxInputSize["MEDIUM"] = "MEDIUM";
|
|
22
|
-
return CheckboxInputSize;
|
|
23
|
-
}({});
|
|
24
12
|
var _exp = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "pointer";
|
|
25
13
|
var _exp2 = () => ({ $isDisabled }) => $isDisabled ? .5 : 1;
|
|
26
14
|
var _exp3 = () => ({ theme }) => theme.color.border.selected;
|
|
@@ -34,14 +22,9 @@ var CheckboxContainer = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
34
22
|
"cythikj-2": [_exp3()]
|
|
35
23
|
}
|
|
36
24
|
}));
|
|
37
|
-
var _exp5 = () => ({ $size }) =>
|
|
38
|
-
return match($size).with("SMALL", () => "12px").with("MEDIUM", () => "16px").exhaustive();
|
|
39
|
-
};
|
|
25
|
+
var _exp5 = () => ({ $size }) => getInputControlSize($size);
|
|
40
26
|
var _exp6 = () => ({ theme }) => theme.color.border.primary;
|
|
41
|
-
var _exp7 = () => ({ theme, $isChecked, $isIndeterminate }) => $isChecked || $isIndeterminate ? theme.color.background.primaryAlt : theme
|
|
42
|
-
var _exp8 = () => ({ 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
|
-
};
|
|
27
|
+
var _exp7 = () => ({ theme, $variant, $isChecked, $isIndeterminate }) => $isChecked || $isIndeterminate ? theme.color.background.primaryAlt : getInputSurfaceColor(theme, $variant);
|
|
45
28
|
var CheckboxWrapper = withTheme(/*#__PURE__*/ styled("div")({
|
|
46
29
|
name: "CheckboxWrapper",
|
|
47
30
|
class: "c1f4v2sg",
|
|
@@ -49,13 +32,14 @@ var CheckboxWrapper = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
49
32
|
vars: {
|
|
50
33
|
"c1f4v2sg-0": [_exp5()],
|
|
51
34
|
"c1f4v2sg-1": [_exp6()],
|
|
52
|
-
"c1f4v2sg-2": [_exp7()]
|
|
53
|
-
"c1f4v2sg-3": [_exp8()]
|
|
35
|
+
"c1f4v2sg-2": [_exp7()]
|
|
54
36
|
}
|
|
55
37
|
}));
|
|
38
|
+
/** The tick sits inside the box, so it runs a step under `getInputIconSize`. */
|
|
56
39
|
var CHECKBOX_INPUT_SIZE_TO_ICON_SIZE_MAP = {
|
|
57
|
-
[
|
|
58
|
-
[
|
|
40
|
+
[InputSize.SMALL]: 10,
|
|
41
|
+
[InputSize.MEDIUM]: 12,
|
|
42
|
+
[InputSize.LARGE]: 14
|
|
59
43
|
};
|
|
60
44
|
/**
|
|
61
45
|
* A checkbox with an optional label. Fully controlled — you own `isChecked`.
|
|
@@ -63,7 +47,7 @@ var CHECKBOX_INPUT_SIZE_TO_ICON_SIZE_MAP = {
|
|
|
63
47
|
* `isIndeterminate` is purely visual and does not change what `onChange`
|
|
64
48
|
* reports; the callback still flips against `isChecked`.
|
|
65
49
|
*/
|
|
66
|
-
var CheckboxInput = ({ variant =
|
|
50
|
+
var CheckboxInput = ({ variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, isChecked, isIndeterminate = false, label, isRequired = false, isDisabled = false, onChange, ariaLabel, stopClickPropagation = false }) => {
|
|
67
51
|
const handleClick = (event) => {
|
|
68
52
|
if (stopClickPropagation) event.stopPropagation();
|
|
69
53
|
if (!isDisabled) onChange(!isChecked, event);
|
|
@@ -105,7 +89,6 @@ var CheckboxInput = ({ variant = "PRIMARY", size = "MEDIUM", isChecked, isIndete
|
|
|
105
89
|
$size: size,
|
|
106
90
|
$isChecked: isChecked,
|
|
107
91
|
$isIndeterminate: isIndeterminate,
|
|
108
|
-
$isDisabled: isDisabled,
|
|
109
92
|
children: renderIcon()
|
|
110
93
|
}), label && /* @__PURE__ */ jsxs(FlexWrapper, {
|
|
111
94
|
alignItems: AlignItems.CENTER,
|
|
@@ -118,4 +101,4 @@ var CheckboxInput = ({ variant = "PRIMARY", size = "MEDIUM", isChecked, isIndete
|
|
|
118
101
|
});
|
|
119
102
|
};
|
|
120
103
|
//#endregion
|
|
121
|
-
export {
|
|
104
|
+
export { CheckboxInput as default };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { InputSize } from "./Input";
|
|
1
|
+
import { InputSize, InputVariant } from "./Input";
|
|
2
2
|
export interface ColorInputProps {
|
|
3
3
|
label?: string;
|
|
4
|
+
/** Trigger surface color. @default InputVariant.PRIMARY */
|
|
5
|
+
variant?: InputVariant;
|
|
4
6
|
/** @default InputSize.MEDIUM */
|
|
5
7
|
size?: InputSize;
|
|
6
8
|
/** Controlled hex value, e.g. `"#1a1a1a"`. */
|
|
@@ -31,5 +33,5 @@ export interface ColorInputProps {
|
|
|
31
33
|
* `onPreviewChange` fires throughout the drag while `onChange` fires on commit —
|
|
32
34
|
* drive a live preview from the first and persist from the second.
|
|
33
35
|
*/
|
|
34
|
-
declare const ColorInput: ({ label, size, value, placeholder, onChange, onPreviewChange, width, fillWidth, isDisabled, isRequired, error, pinnedHex, isOpen: controlledIsOpen, onOpenChange, children, }: ColorInputProps) => import("react").JSX.Element;
|
|
36
|
+
declare const ColorInput: ({ label, variant, size, value, placeholder, onChange, onPreviewChange, width, fillWidth, isDisabled, isRequired, error, pinnedHex, isOpen: controlledIsOpen, onOpenChange, children, }: ColorInputProps) => import("react").JSX.Element;
|
|
35
37
|
export default ColorInput;
|
|
@@ -4,37 +4,32 @@ import { hexToHsva, hsvaToHex } from "../utils/colors.js";
|
|
|
4
4
|
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
5
5
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
6
6
|
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
|
+
import Spacing from "../containers/Spacing.js";
|
|
8
|
+
import { InputLabel, InputSize, InputVariant, getInputBorderColor, getInputHeight, getInputIconSize, getInputPadding, getInputSurfaceColor, getInputTextSize } from "./Input.js";
|
|
7
9
|
import Dropdown, { DropdownVariant } from "../dropdown/Dropdown.js";
|
|
8
10
|
import GridWrapper from "../containers/GridWrapper.js";
|
|
9
|
-
import Spacing from "../containers/Spacing.js";
|
|
10
|
-
import { InputLabel, InputSize } from "./Input.js";
|
|
11
11
|
/* empty css */
|
|
12
12
|
import { styled } from "@linaria/react";
|
|
13
|
-
import { match } from "ts-pattern";
|
|
14
13
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
15
14
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
15
|
import { CaretDownIcon } from "@phosphor-icons/react";
|
|
17
16
|
import { Hue, Saturation } from "@uiw/react-color";
|
|
18
17
|
//#region src/inputs/ColorInput.tsx
|
|
19
|
-
var _exp = () => ({ $size }) => {
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
var _exp2 = () => ({ $size }) => {
|
|
23
|
-
return match($size).with(InputSize.SMALL, () => "24px").with(InputSize.MEDIUM, () => "28px").with(InputSize.LARGE, () => "32px").exhaustive();
|
|
24
|
-
};
|
|
18
|
+
var _exp = () => ({ $size }) => `0 ${getInputPadding($size)}`;
|
|
19
|
+
var _exp2 = () => ({ $size }) => getInputHeight($size);
|
|
25
20
|
var _exp3 = () => ({ $width, $fillWidth }) => $fillWidth ? "100%" : $width ? getCssSizeValue($width) : "auto";
|
|
26
21
|
var _exp4 = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "pointer";
|
|
27
22
|
var _exp5 = () => ({ $isDisabled }) => $isDisabled ? .5 : 1;
|
|
28
|
-
var _exp6 = () => ({ theme }) => theme
|
|
29
|
-
var _exp7 = () => ({ theme, $isActive, $isError }) => {
|
|
23
|
+
var _exp6 = () => ({ theme, $variant }) => getInputSurfaceColor(theme, $variant);
|
|
24
|
+
var _exp7 = () => ({ theme, $variant, $isActive, $isError }) => {
|
|
30
25
|
if ($isActive) return theme.color.border.selected;
|
|
31
26
|
if ($isError) return theme.color.border.error;
|
|
32
|
-
return theme
|
|
27
|
+
return getInputBorderColor(theme, $variant);
|
|
33
28
|
};
|
|
34
|
-
var _exp8 = () => ({ theme, $isActive, $isDisabled }) => {
|
|
35
|
-
if ($isDisabled) return theme
|
|
29
|
+
var _exp8 = () => ({ theme, $variant, $isActive, $isDisabled }) => {
|
|
30
|
+
if ($isDisabled) return getInputBorderColor(theme, $variant);
|
|
36
31
|
if ($isActive) return theme.color.border.selected;
|
|
37
|
-
return theme
|
|
32
|
+
return getInputBorderColor(theme, $variant);
|
|
38
33
|
};
|
|
39
34
|
var StyledColorInput = withTheme(/*#__PURE__*/ styled("div")({
|
|
40
35
|
name: "StyledColorInput",
|
|
@@ -123,23 +118,13 @@ var safeNormalizeHex = (hex) => {
|
|
|
123
118
|
return null;
|
|
124
119
|
}
|
|
125
120
|
};
|
|
126
|
-
var COLOR_INPUT_SIZE_TO_TEXT_SIZE = {
|
|
127
|
-
[InputSize.SMALL]: TextSize.BODY_MD,
|
|
128
|
-
[InputSize.MEDIUM]: TextSize.BODY_MD,
|
|
129
|
-
[InputSize.LARGE]: TextSize.BODY_MD
|
|
130
|
-
};
|
|
131
|
-
var COLOR_INPUT_SIZE_TO_ICON_SIZE = {
|
|
132
|
-
[InputSize.SMALL]: 14,
|
|
133
|
-
[InputSize.MEDIUM]: 16,
|
|
134
|
-
[InputSize.LARGE]: 18
|
|
135
|
-
};
|
|
136
121
|
/**
|
|
137
122
|
* A hex color field with a picker popover. Fully controlled.
|
|
138
123
|
*
|
|
139
124
|
* `onPreviewChange` fires throughout the drag while `onChange` fires on commit —
|
|
140
125
|
* drive a live preview from the first and persist from the second.
|
|
141
126
|
*/
|
|
142
|
-
var ColorInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select color...", onChange, onPreviewChange, width, fillWidth = false, isDisabled = false, isRequired = false, error, pinnedHex = [], isOpen: controlledIsOpen, onOpenChange, children }) => {
|
|
127
|
+
var ColorInput = ({ label, variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, value, placeholder = "Select color...", onChange, onPreviewChange, width, fillWidth = false, isDisabled = false, isRequired = false, error, pinnedHex = [], isOpen: controlledIsOpen, onOpenChange, children }) => {
|
|
143
128
|
const [localState, setLocalState] = useState({
|
|
144
129
|
isOpen: false,
|
|
145
130
|
isHovered: false
|
|
@@ -328,6 +313,7 @@ var ColorInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
328
313
|
children
|
|
329
314
|
}) : /* @__PURE__ */ jsxs(StyledColorInput, {
|
|
330
315
|
$size: size,
|
|
316
|
+
$variant: variant,
|
|
331
317
|
$isActive: isOpen,
|
|
332
318
|
$isDisabled: isDisabled,
|
|
333
319
|
$isError: !!error,
|
|
@@ -347,7 +333,7 @@ var ColorInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
347
333
|
gap: 8,
|
|
348
334
|
children: [value && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ColorInputPreviewSwatch, { $color: value }), /* @__PURE__ */ jsx(Spacing, { left: 4 })] }), /* @__PURE__ */ jsx(Text, {
|
|
349
335
|
variant: textVariant,
|
|
350
|
-
size:
|
|
336
|
+
size: getInputTextSize(size),
|
|
351
337
|
isEllipsis: true,
|
|
352
338
|
cursor: !isDisabled ? "pointer" : "not-allowed",
|
|
353
339
|
children: displayValue
|
|
@@ -356,7 +342,7 @@ var ColorInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
356
342
|
/* @__PURE__ */ jsx(Spacing, { left: 8 }),
|
|
357
343
|
/* @__PURE__ */ jsx(Icon, {
|
|
358
344
|
component: CaretDownIcon,
|
|
359
|
-
size:
|
|
345
|
+
size: getInputIconSize(size),
|
|
360
346
|
variant: isOpen || localState.isHovered ? IconVariant.SECONDARY : IconVariant.TERTIARY
|
|
361
347
|
})
|
|
362
348
|
]
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { InputSize } from "./Input";
|
|
1
|
+
import { InputSize, InputVariant } from "./Input";
|
|
2
2
|
export interface CopyInputProps {
|
|
3
3
|
/** The text shown and copied. Read-only — there is no `onChange`. */
|
|
4
4
|
value: string;
|
|
5
5
|
label?: string;
|
|
6
6
|
/** Adds an info icon beside the label with this content on hover. */
|
|
7
7
|
labelTooltip?: string | React.ReactNode;
|
|
8
|
+
/** Field surface color. @default InputVariant.PRIMARY */
|
|
9
|
+
variant?: InputVariant;
|
|
8
10
|
/** @default InputSize.MEDIUM */
|
|
9
11
|
size?: InputSize;
|
|
10
12
|
/** A number is px. */
|
|
@@ -18,7 +20,7 @@ export interface CopyInputProps {
|
|
|
18
20
|
* The trailing button confirms the copy itself, so you don't need to.
|
|
19
21
|
*/
|
|
20
22
|
declare const CopyInput: {
|
|
21
|
-
({ value, label, labelTooltip, size, width, fillWidth, isMonospace, }: CopyInputProps): import("react").JSX.Element;
|
|
23
|
+
({ value, label, labelTooltip, variant, size, width, fillWidth, isMonospace, }: CopyInputProps): import("react").JSX.Element;
|
|
22
24
|
displayName: string;
|
|
23
25
|
};
|
|
24
26
|
export default CopyInput;
|
package/dist/inputs/CopyInput.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Button, { ButtonSize, ButtonVariant } from "../buttons/Button.js";
|
|
2
2
|
import FlexWrapper, { AlignItems } from "../containers/FlexWrapper.js";
|
|
3
|
-
import { InputSize } from "./Input.js";
|
|
3
|
+
import { InputSize, InputVariant } from "./Input.js";
|
|
4
4
|
import TextInput from "./TextInput.js";
|
|
5
5
|
import { useCallback, useRef, useState } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -11,11 +11,18 @@ var INPUT_SIZE_TO_BUTTON_SIZE = {
|
|
|
11
11
|
[InputSize.MEDIUM]: ButtonSize.MEDIUM,
|
|
12
12
|
[InputSize.LARGE]: ButtonSize.LARGE
|
|
13
13
|
};
|
|
14
|
+
var INPUT_VARIANT_TO_BUTTON_VARIANT = {
|
|
15
|
+
[InputVariant.TRANSPARENT]: ButtonVariant.TERTIARY,
|
|
16
|
+
[InputVariant.BASE]: ButtonVariant.SECONDARY,
|
|
17
|
+
[InputVariant.PRIMARY]: ButtonVariant.SECONDARY,
|
|
18
|
+
[InputVariant.SECONDARY]: ButtonVariant.SECONDARY,
|
|
19
|
+
[InputVariant.TERTIARY]: ButtonVariant.SECONDARY
|
|
20
|
+
};
|
|
14
21
|
/**
|
|
15
22
|
* A read-only field with a copy-to-clipboard button — API keys, IDs, share links.
|
|
16
23
|
* The trailing button confirms the copy itself, so you don't need to.
|
|
17
24
|
*/
|
|
18
|
-
var CopyInput = ({ value, label, labelTooltip, size = InputSize.MEDIUM, width, fillWidth, isMonospace = false }) => {
|
|
25
|
+
var CopyInput = ({ value, label, labelTooltip, variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, width, fillWidth, isMonospace = false }) => {
|
|
19
26
|
const [copied, setCopied] = useState(false);
|
|
20
27
|
const inputRef = useRef(null);
|
|
21
28
|
const handleCopy = useCallback(() => {
|
|
@@ -35,13 +42,14 @@ var CopyInput = ({ value, label, labelTooltip, size = InputSize.MEDIUM, width, f
|
|
|
35
42
|
labelTooltip,
|
|
36
43
|
value,
|
|
37
44
|
onChange: () => {},
|
|
45
|
+
variant,
|
|
38
46
|
size,
|
|
39
47
|
width,
|
|
40
48
|
fillWidth,
|
|
41
49
|
isMonospace
|
|
42
50
|
}), /* @__PURE__ */ jsx(Button, {
|
|
43
51
|
icon: copied ? CheckIcon : CopyIcon,
|
|
44
|
-
variant:
|
|
52
|
+
variant: INPUT_VARIANT_TO_BUTTON_VARIANT[variant],
|
|
45
53
|
size: INPUT_SIZE_TO_BUTTON_SIZE[size],
|
|
46
54
|
onClick: handleCopy
|
|
47
55
|
})]
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { InputSize } from "./Input";
|
|
1
|
+
import { InputSize, InputVariant } from "./Input";
|
|
2
2
|
export interface DateInputProps {
|
|
3
3
|
label?: string;
|
|
4
|
+
/** Trigger surface color. @default InputVariant.PRIMARY */
|
|
5
|
+
variant?: InputVariant;
|
|
4
6
|
/** @default InputSize.MEDIUM */
|
|
5
7
|
size?: InputSize;
|
|
6
8
|
/** Controlled value. `null` shows the placeholder. */
|
|
@@ -28,5 +30,5 @@ export declare function defaultDateFormat(date: Date): string;
|
|
|
28
30
|
*
|
|
29
31
|
* Works in `Date` objects throughout; there is no string parsing to get wrong.
|
|
30
32
|
*/
|
|
31
|
-
declare const DateInput: ({ label, size, value, placeholder, onChange, width, fillWidth, isDisabled, isRequired, error, minDate, maxDate, format, }: DateInputProps) => import("react").JSX.Element;
|
|
33
|
+
declare const DateInput: ({ label, variant, size, value, placeholder, onChange, width, fillWidth, isDisabled, isRequired, error, minDate, maxDate, format, }: DateInputProps) => import("react").JSX.Element;
|
|
32
34
|
export default DateInput;
|
package/dist/inputs/DateInput.js
CHANGED
|
@@ -3,14 +3,13 @@ import { getCssSizeValue } from "../utils/linaria.js";
|
|
|
3
3
|
import Text, { TextSize, TextVariant, TextWeight } from "../text/Text.js";
|
|
4
4
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
5
5
|
import FlexWrapper, { AlignItems, FlexDirection, JustifyContent } from "../containers/FlexWrapper.js";
|
|
6
|
+
import Spacing from "../containers/Spacing.js";
|
|
7
|
+
import { InputLabel, InputSize, InputVariant, getInputBorderColor, getInputHeight, getInputIconSize, getInputPadding, getInputSurfaceColor, getInputTextSize } from "./Input.js";
|
|
6
8
|
import Dropdown, { DropdownVariant } from "../dropdown/Dropdown.js";
|
|
7
9
|
import GridWrapper from "../containers/GridWrapper.js";
|
|
8
|
-
import
|
|
9
|
-
import { InputLabel, InputSize } from "./Input.js";
|
|
10
|
-
import SelectInput, { SelectInputVariant } from "./SelectInput.js";
|
|
10
|
+
import SelectInput from "./SelectInput.js";
|
|
11
11
|
/* empty css */
|
|
12
12
|
import { styled } from "@linaria/react";
|
|
13
|
-
import { match } from "ts-pattern";
|
|
14
13
|
import { useCallback, useMemo, useRef, useState } from "react";
|
|
15
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
15
|
import { CalendarBlankIcon, CaretLeftIcon, CaretRightIcon } from "@phosphor-icons/react";
|
|
@@ -63,25 +62,28 @@ var DATE_DAY_TO_LABEL = {
|
|
|
63
62
|
["FRIDAY"]: "Fri",
|
|
64
63
|
["SATURDAY"]: "Sat"
|
|
65
64
|
};
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
var INPUT_VARIANT_TO_DROPDOWN_VARIANT = {
|
|
66
|
+
[InputVariant.TRANSPARENT]: DropdownVariant.TRANSPARENT,
|
|
67
|
+
[InputVariant.BASE]: DropdownVariant.PRIMARY,
|
|
68
|
+
[InputVariant.PRIMARY]: DropdownVariant.PRIMARY,
|
|
69
|
+
[InputVariant.SECONDARY]: DropdownVariant.SECONDARY,
|
|
70
|
+
[InputVariant.TERTIARY]: DropdownVariant.TERTIARY
|
|
71
71
|
};
|
|
72
|
+
var _exp = () => ({ $size }) => `0 ${getInputPadding($size)}`;
|
|
73
|
+
var _exp2 = () => ({ $size }) => getInputHeight($size);
|
|
72
74
|
var _exp3 = () => ({ $width, $fillWidth }) => $fillWidth ? "100%" : $width ? getCssSizeValue($width) : "auto";
|
|
73
75
|
var _exp4 = () => ({ $isDisabled }) => $isDisabled ? "not-allowed" : "pointer";
|
|
74
76
|
var _exp5 = () => ({ $isDisabled }) => $isDisabled ? .5 : 1;
|
|
75
|
-
var _exp6 = () => ({ theme }) => theme
|
|
76
|
-
var _exp7 = () => ({ theme, $isActive, $isError }) => {
|
|
77
|
+
var _exp6 = () => ({ theme, $variant }) => getInputSurfaceColor(theme, $variant);
|
|
78
|
+
var _exp7 = () => ({ theme, $variant, $isActive, $isError }) => {
|
|
77
79
|
if ($isActive) return theme.color.border.selected;
|
|
78
80
|
if ($isError) return theme.color.border.error;
|
|
79
|
-
return theme
|
|
81
|
+
return getInputBorderColor(theme, $variant);
|
|
80
82
|
};
|
|
81
|
-
var _exp8 = () => ({ theme, $isActive, $isDisabled }) => {
|
|
82
|
-
if ($isDisabled) return theme
|
|
83
|
+
var _exp8 = () => ({ theme, $variant, $isActive, $isDisabled }) => {
|
|
84
|
+
if ($isDisabled) return getInputBorderColor(theme, $variant);
|
|
83
85
|
if ($isActive) return theme.color.border.selected;
|
|
84
|
-
return theme
|
|
86
|
+
return getInputBorderColor(theme, $variant);
|
|
85
87
|
};
|
|
86
88
|
var StyledDateInput = withTheme(/*#__PURE__*/ styled("div")({
|
|
87
89
|
name: "StyledDateInput",
|
|
@@ -131,16 +133,6 @@ var DayCell = withTheme(/*#__PURE__*/ styled("button")({
|
|
|
131
133
|
"d60emtx-4": [_exp11()]
|
|
132
134
|
}
|
|
133
135
|
}));
|
|
134
|
-
var DATE_INPUT_SIZE_TO_TEXT_SIZE = {
|
|
135
|
-
[InputSize.SMALL]: TextSize.BODY_MD,
|
|
136
|
-
[InputSize.MEDIUM]: TextSize.BODY_MD,
|
|
137
|
-
[InputSize.LARGE]: TextSize.BODY_MD
|
|
138
|
-
};
|
|
139
|
-
var DATE_INPUT_SIZE_TO_ICON_SIZE = {
|
|
140
|
-
[InputSize.SMALL]: 14,
|
|
141
|
-
[InputSize.MEDIUM]: 16,
|
|
142
|
-
[InputSize.LARGE]: 18
|
|
143
|
-
};
|
|
144
136
|
var DEFAULT_MAX_DATE = /* @__PURE__ */ new Date();
|
|
145
137
|
function defaultDateFormat(date) {
|
|
146
138
|
return date.toLocaleDateString("en-US", {
|
|
@@ -157,7 +149,7 @@ var getInitialViewDate = (value) => {
|
|
|
157
149
|
*
|
|
158
150
|
* Works in `Date` objects throughout; there is no string parsing to get wrong.
|
|
159
151
|
*/
|
|
160
|
-
var DateInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select date...", onChange, width, fillWidth = false, isDisabled = false, isRequired = false, error, minDate = new Date(1970, 0, 1), maxDate = DEFAULT_MAX_DATE, format = defaultDateFormat }) => {
|
|
152
|
+
var DateInput = ({ label, variant = InputVariant.PRIMARY, size = InputSize.MEDIUM, value, placeholder = "Select date...", onChange, width, fillWidth = false, isDisabled = false, isRequired = false, error, minDate = new Date(1970, 0, 1), maxDate = DEFAULT_MAX_DATE, format = defaultDateFormat }) => {
|
|
161
153
|
const [state, setState] = useState({
|
|
162
154
|
isOpen: false,
|
|
163
155
|
isHovered: false,
|
|
@@ -383,7 +375,7 @@ var DateInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
383
375
|
onClick: (e) => e.stopPropagation(),
|
|
384
376
|
onMouseDown: (e) => e.stopPropagation(),
|
|
385
377
|
children: [/* @__PURE__ */ jsx(SelectInput, {
|
|
386
|
-
variant
|
|
378
|
+
variant,
|
|
387
379
|
size: InputSize.SMALL,
|
|
388
380
|
options: monthOptions,
|
|
389
381
|
value: selectedMonthOption,
|
|
@@ -392,7 +384,7 @@ var DateInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
392
384
|
onOpenChange: handleMonthSelectOpenChange,
|
|
393
385
|
width: 120
|
|
394
386
|
}), /* @__PURE__ */ jsx(SelectInput, {
|
|
395
|
-
variant
|
|
387
|
+
variant,
|
|
396
388
|
size: InputSize.SMALL,
|
|
397
389
|
options: yearOptions,
|
|
398
390
|
value: selectedYearOption,
|
|
@@ -450,7 +442,7 @@ var DateInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
450
442
|
isRequired
|
|
451
443
|
}),
|
|
452
444
|
/* @__PURE__ */ jsx(Dropdown, {
|
|
453
|
-
variant:
|
|
445
|
+
variant: INPUT_VARIANT_TO_DROPDOWN_VARIANT[variant],
|
|
454
446
|
body: calendarBody,
|
|
455
447
|
isOpen: state.isOpen,
|
|
456
448
|
onClose: handleClose,
|
|
@@ -458,6 +450,7 @@ var DateInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
458
450
|
fillWidth,
|
|
459
451
|
children: /* @__PURE__ */ jsxs(StyledDateInput, {
|
|
460
452
|
$size: size,
|
|
453
|
+
$variant: variant,
|
|
461
454
|
$isActive: state.isOpen,
|
|
462
455
|
$isDisabled: isDisabled,
|
|
463
456
|
$isError: !!error,
|
|
@@ -474,7 +467,7 @@ var DateInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
474
467
|
children: [
|
|
475
468
|
/* @__PURE__ */ jsx(Text, {
|
|
476
469
|
variant: textVariant,
|
|
477
|
-
size:
|
|
470
|
+
size: getInputTextSize(size),
|
|
478
471
|
isEllipsis: true,
|
|
479
472
|
cursor: !isDisabled ? "pointer" : "not-allowed",
|
|
480
473
|
children: displayValue
|
|
@@ -482,7 +475,7 @@ var DateInput = ({ label, size = InputSize.MEDIUM, value, placeholder = "Select
|
|
|
482
475
|
/* @__PURE__ */ jsx(Spacing, { left: 8 }),
|
|
483
476
|
/* @__PURE__ */ jsx(Icon, {
|
|
484
477
|
component: CalendarBlankIcon,
|
|
485
|
-
size:
|
|
478
|
+
size: getInputIconSize(size),
|
|
486
479
|
variant: state.isOpen || state.isHovered ? IconVariant.SECONDARY : IconVariant.TERTIARY
|
|
487
480
|
})
|
|
488
481
|
]
|
package/dist/inputs/Input.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type Ref } from "react";
|
|
2
2
|
import { type Icon as PhosphorIcon } from "@phosphor-icons/react";
|
|
3
|
+
import type { Theme } from "../theme/types";
|
|
4
|
+
import { TextSize } from "../text/Text";
|
|
3
5
|
export interface InputLabelProps {
|
|
4
6
|
label: string;
|
|
5
7
|
/** Adds an info icon beside the label with this content on hover. */
|
|
@@ -18,8 +20,79 @@ export declare enum InputSize {
|
|
|
18
20
|
MEDIUM = "MEDIUM",
|
|
19
21
|
LARGE = "LARGE"
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Field height for an `InputSize`. The single source of truth — every input in
|
|
25
|
+
* the family routes through this. Call it from inside a Linaria interpolation:
|
|
26
|
+
*
|
|
27
|
+
* ```
|
|
28
|
+
* height: ${({ $size }) => getInputHeight($size)};
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getInputHeight(size: InputSize): string;
|
|
32
|
+
/** `getInputHeight` unwrapped, for callers that need to do arithmetic on it. */
|
|
33
|
+
export declare function getInputHeightValue(size: InputSize): number;
|
|
34
|
+
/**
|
|
35
|
+
* Horizontal inset for an `InputSize` — 6 / 8 / 12px. Returned as a number so
|
|
36
|
+
* `TextAreaInput` can fold it into its computed `min-height`; most callers want
|
|
37
|
+
* `getInputPadding` instead.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getInputPaddingValue(size: InputSize): number;
|
|
40
|
+
/** `getInputPaddingValue` as a CSS length. */
|
|
41
|
+
export declare function getInputPadding(size: InputSize): string;
|
|
42
|
+
/** Type step for an `InputSize` — `body_sm` / `body_md` / `body_lg`. */
|
|
43
|
+
export declare function getInputFontSize(theme: Theme, size: InputSize): string;
|
|
44
|
+
/** The line height paired with `getInputFontSize`. */
|
|
45
|
+
export declare function getInputLineHeight(theme: Theme, size: InputSize): string;
|
|
46
|
+
/** Icon px for an `InputSize` — 12 / 14 / 16, for icons sitting inside a field. */
|
|
47
|
+
export declare function getInputIconSize(size: InputSize): number;
|
|
48
|
+
/**
|
|
49
|
+
* `getInputFontSize` for copy that renders through `Text` rather than through a
|
|
50
|
+
* raw `<input>` — the trigger labels in `SelectInput`, `DateInput`, `ColorInput`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getInputTextSize(size: InputSize): TextSize;
|
|
53
|
+
/**
|
|
54
|
+
* Hit-target box for the boolean controls — 12 / 16 / 20px. Shared by the
|
|
55
|
+
* `CheckboxInput` square and the `RadioInput` circle, which are sized as targets
|
|
56
|
+
* rather than off the type scale, so they do not follow `getInputHeight`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getInputControlSize(size: InputSize): string;
|
|
59
|
+
/**
|
|
60
|
+
* Surface color for any input. Mirrors `DropdownVariant` so a field and the
|
|
61
|
+
* panel it sits in can be tuned to the same step of the neutral stack.
|
|
62
|
+
*
|
|
63
|
+
* Paints the *resting* surface only — state colors (checked, selected, filled)
|
|
64
|
+
* are fixed tokens and are not affected by the variant.
|
|
65
|
+
*
|
|
66
|
+
* `TRANSPARENT` drops both the fill and the border. `CheckboxInput` and
|
|
67
|
+
* `RadioInput` keep their hairline under it, or they would be invisible.
|
|
68
|
+
*/
|
|
69
|
+
export declare enum InputVariant {
|
|
70
|
+
TRANSPARENT = "TRANSPARENT",
|
|
71
|
+
BASE = "BASE",
|
|
72
|
+
PRIMARY = "PRIMARY",
|
|
73
|
+
SECONDARY = "SECONDARY",
|
|
74
|
+
TERTIARY = "TERTIARY"
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Surface fill for an `InputVariant`. The single source of truth — every input
|
|
78
|
+
* routes through this. Call it from inside a Linaria interpolation:
|
|
79
|
+
*
|
|
80
|
+
* ```
|
|
81
|
+
* background-color: ${({ theme, $variant }) => getInputSurfaceColor(theme, $variant)};
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function getInputSurfaceColor(theme: Theme, variant?: InputVariant): string;
|
|
85
|
+
/**
|
|
86
|
+
* Resting border for an `InputVariant`. Callers short-circuit their own error,
|
|
87
|
+
* focus and active colors before falling back to this.
|
|
88
|
+
*
|
|
89
|
+
* Returns `"transparent"` rather than `"none"` so the box model stays identical
|
|
90
|
+
* across variants.
|
|
91
|
+
*/
|
|
92
|
+
export declare function getInputBorderColor(theme: Theme, variant?: InputVariant): string;
|
|
21
93
|
export declare const StyledInput: import("react").ComponentType<Pick<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
22
94
|
$size: InputSize;
|
|
95
|
+
$variant?: InputVariant;
|
|
23
96
|
$width?: number | string;
|
|
24
97
|
$fillWidth?: boolean;
|
|
25
98
|
$isError?: boolean;
|
|
@@ -28,13 +101,14 @@ export declare const StyledInput: import("react").ComponentType<Pick<import("rea
|
|
|
28
101
|
$isMonospace?: boolean;
|
|
29
102
|
$isDisabled?: boolean;
|
|
30
103
|
} & {
|
|
31
|
-
theme:
|
|
104
|
+
theme: Theme;
|
|
32
105
|
} & {
|
|
33
106
|
as?: React.ElementType;
|
|
34
|
-
}, "$width" | "$fillWidth" | "$size" | "$isMonospace" | "as" | "$isError" | "$hasLeadingIcon" | "$hasTrailingAction" | "$isDisabled" | keyof import("react").ClassAttributes<HTMLInputElement> | keyof import("react").InputHTMLAttributes<HTMLInputElement>> & {
|
|
35
|
-
theme?: import("@callstack/react-theme-provider").$DeepPartial<
|
|
107
|
+
}, "$width" | "$fillWidth" | "$size" | "$variant" | "$isMonospace" | "as" | "$isError" | "$hasLeadingIcon" | "$hasTrailingAction" | "$isDisabled" | keyof import("react").ClassAttributes<HTMLInputElement> | keyof import("react").InputHTMLAttributes<HTMLInputElement>> & {
|
|
108
|
+
theme?: import("@callstack/react-theme-provider").$DeepPartial<Theme> | undefined;
|
|
36
109
|
}> & import("@callstack/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<import("react").ComponentType<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
37
110
|
$size: InputSize;
|
|
111
|
+
$variant?: InputVariant;
|
|
38
112
|
$width?: number | string;
|
|
39
113
|
$fillWidth?: boolean;
|
|
40
114
|
$isError?: boolean;
|
|
@@ -43,13 +117,14 @@ export declare const StyledInput: import("react").ComponentType<Pick<import("rea
|
|
|
43
117
|
$isMonospace?: boolean;
|
|
44
118
|
$isDisabled?: boolean;
|
|
45
119
|
} & {
|
|
46
|
-
theme:
|
|
120
|
+
theme: Theme;
|
|
47
121
|
} & {
|
|
48
122
|
as?: React.ElementType;
|
|
49
123
|
}> & {
|
|
50
124
|
__wyw_meta: unknown;
|
|
51
125
|
} & import("react").FunctionComponent<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
52
126
|
$size: InputSize;
|
|
127
|
+
$variant?: InputVariant;
|
|
53
128
|
$width?: number | string;
|
|
54
129
|
$fillWidth?: boolean;
|
|
55
130
|
$isError?: boolean;
|
|
@@ -58,7 +133,7 @@ export declare const StyledInput: import("react").ComponentType<Pick<import("rea
|
|
|
58
133
|
$isMonospace?: boolean;
|
|
59
134
|
$isDisabled?: boolean;
|
|
60
135
|
} & {
|
|
61
|
-
theme:
|
|
136
|
+
theme: Theme;
|
|
62
137
|
} & {
|
|
63
138
|
as?: React.ElementType;
|
|
64
139
|
}>, {}>;
|
|
@@ -74,6 +149,8 @@ export interface InputProps<T> {
|
|
|
74
149
|
parse: (value: T) => T;
|
|
75
150
|
/** Called with the parsed value on every keystroke. */
|
|
76
151
|
onChange: (value: T) => void;
|
|
152
|
+
/** Field surface color. @default InputVariant.PRIMARY */
|
|
153
|
+
variant?: InputVariant;
|
|
77
154
|
/** @default InputSize.MEDIUM */
|
|
78
155
|
size?: InputSize;
|
|
79
156
|
/** The underlying `<input type>`. Wrappers set it. */
|