@k8o/arte-odyssey 1.4.2 → 2.0.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/components/accordion/accordion-button.js +8 -7
- package/dist/components/accordion/accordion-item.js +1 -1
- package/dist/components/accordion/accordion-panel.js +1 -1
- package/dist/components/accordion/accordion.js +1 -11
- package/dist/components/alert/alert.js +3 -4
- package/dist/components/alert/alert.stories.js +6 -2
- package/dist/components/anchor/anchor.js +3 -2
- package/dist/components/baseline-status/baseline-status.js +2 -2
- package/dist/components/breadcrumb/breadcrumb.js +9 -2
- package/dist/components/button/button.js +6 -6
- package/dist/components/card/card.js +3 -3
- package/dist/components/card/card.stories.js +20 -18
- package/dist/components/card/interactive-card.js +4 -12
- package/dist/components/dialog/dialog.js +1 -1
- package/dist/components/drawer/drawer.stories.js +6 -6
- package/dist/components/dropdown-menu/dropdown-menu.js +4 -4
- package/dist/components/dropdown-menu/dropdown-menu.stories.js +16 -16
- package/dist/components/form/autocomplete/autocomplete.d.ts +11 -3
- package/dist/components/form/autocomplete/autocomplete.js +6 -6
- package/dist/components/form/autocomplete/autocomplete.stories.js +6 -2
- package/dist/components/form/checkbox/checkbox.d.ts +10 -2
- package/dist/components/form/checkbox/checkbox.js +16 -6
- package/dist/components/form/file-field/file-field.js +3 -3
- package/dist/components/form/number-field/number-field.d.ts +12 -4
- package/dist/components/form/number-field/number-field.js +21 -13
- package/dist/components/form/number-field/number-field.stories.js +2 -7
- package/dist/components/form/radio/radio.d.ts +12 -3
- package/dist/components/form/radio/radio.js +4 -2
- package/dist/components/form/radio/radio.stories.js +14 -39
- package/dist/components/form/range-field/range-field.d.ts +13 -5
- package/dist/components/form/range-field/range-field.js +19 -9
- package/dist/components/form/range-field/range-field.stories.js +11 -104
- package/dist/components/form/select/select.d.ts +10 -2
- package/dist/components/form/select/select.js +2 -2
- package/dist/components/form/select/select.stories.js +1 -4
- package/dist/components/form/text-field/text-field.d.ts +10 -2
- package/dist/components/form/text-field/text-field.js +1 -1
- package/dist/components/form/text-field/text-field.stories.js +1 -5
- package/dist/components/form/textarea/textarea.d.ts +10 -2
- package/dist/components/form/textarea/textarea.js +1 -1
- package/dist/components/form/textarea/textarea.stories.js +1 -5
- package/dist/components/icon-button/icon-button.js +3 -3
- package/dist/components/icon-button/icon-button.stories.js +1 -4
- package/dist/components/icon-link/icon-link.d.ts +1 -1
- package/dist/components/icon-link/icon-link.js +3 -2
- package/dist/components/icon-link/icon-link.stories.js +7 -1
- package/dist/components/icons/icons.stories.js +0 -5
- package/dist/components/icons/index.d.ts +0 -1
- package/dist/components/icons/index.js +0 -1
- package/dist/components/link-button/link-button.d.ts +2 -1
- package/dist/components/link-button/link-button.js +9 -6
- package/dist/components/link-button/link-button.stories.js +21 -2
- package/dist/components/list-box/list-box.js +6 -8
- package/dist/components/list-box/list-box.stories.js +10 -19
- package/dist/components/modal/modal.js +1 -1
- package/dist/components/modal/modal.stories.js +2 -2
- package/dist/components/popover/popover.stories.js +3 -3
- package/dist/components/progress/progress.js +2 -2
- package/dist/components/scroll-linked/scroll-linked.js +1 -1
- package/dist/components/scroll-linked/scroll-linked.stories.js +7 -7
- package/dist/components/separator/separator.d.ts +1 -0
- package/dist/components/separator/separator.js +21 -12
- package/dist/components/separator/separator.stories.js +12 -0
- package/dist/components/tabs/tabs.js +3 -3
- package/dist/components/tabs/tabs.stories.js +33 -26
- package/dist/components/text-tag/text-tag.js +1 -1
- package/dist/components/tooltip/tooltip.js +1 -1
- package/dist/components/tooltip/tooltip.stories.js +3 -3
- package/dist/styles/index.css +0 -3
- package/package.json +20 -20
- package/dist/components/icons/zenn.d.ts +0 -6
- package/dist/components/icons/zenn.js +0 -41
|
@@ -84,7 +84,7 @@ const Root = ({
|
|
|
84
84
|
}),
|
|
85
85
|
[isDisabled, isInvalid, acceptedFiles, onFileDelete, openFilePicker]
|
|
86
86
|
);
|
|
87
|
-
return /* @__PURE__ */
|
|
87
|
+
return /* @__PURE__ */ jsx(FileFieldProvider, { value: contextValue, children: /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
88
88
|
/* @__PURE__ */ jsx(
|
|
89
89
|
"input",
|
|
90
90
|
{
|
|
@@ -104,7 +104,7 @@ const Root = ({
|
|
|
104
104
|
}
|
|
105
105
|
),
|
|
106
106
|
children
|
|
107
|
-
] });
|
|
107
|
+
] }) });
|
|
108
108
|
};
|
|
109
109
|
const Trigger = ({ renderItem }) => {
|
|
110
110
|
const context = useFileFieldContext();
|
|
@@ -126,7 +126,7 @@ const ItemList = ({ showWebkitRelativePath, clearable }) => {
|
|
|
126
126
|
return /* @__PURE__ */ jsxs(
|
|
127
127
|
"li",
|
|
128
128
|
{
|
|
129
|
-
className: "flex items-center justify-between rounded-
|
|
129
|
+
className: "flex items-center justify-between rounded-lg border border-border-base bg-bg-base px-3 py-2",
|
|
130
130
|
children: [
|
|
131
131
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
132
132
|
/* @__PURE__ */ jsx("span", { className: "font-medium text-fg-base text-sm", children: showWebkitRelativePath ? file.webkitRelativePath : file.name }),
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
-
type
|
|
2
|
+
type BaseProps = {
|
|
3
3
|
id?: string;
|
|
4
4
|
describedbyId?: string | undefined;
|
|
5
5
|
isInvalid: boolean;
|
|
6
6
|
isDisabled: boolean;
|
|
7
7
|
isRequired: boolean;
|
|
8
|
-
value: number;
|
|
9
|
-
defaultValue?: number;
|
|
10
|
-
onChange: (value: number) => void;
|
|
11
8
|
step?: number;
|
|
12
9
|
precision?: number;
|
|
13
10
|
max?: number;
|
|
14
11
|
min?: number;
|
|
15
12
|
placeholder?: string;
|
|
16
13
|
};
|
|
14
|
+
type ControlledProps = {
|
|
15
|
+
value: number;
|
|
16
|
+
onChange: (value: number) => void;
|
|
17
|
+
defaultValue?: never;
|
|
18
|
+
};
|
|
19
|
+
type UncontrolledProps = {
|
|
20
|
+
defaultValue?: number;
|
|
21
|
+
value?: never;
|
|
22
|
+
onChange?: (value: number) => void;
|
|
23
|
+
};
|
|
24
|
+
type Props = BaseProps & (ControlledProps | UncontrolledProps);
|
|
17
25
|
export declare const NumberField: FC<Props>;
|
|
18
26
|
export {};
|
|
@@ -18,22 +18,30 @@ const NumberField = ({
|
|
|
18
18
|
min = -9007199254740991,
|
|
19
19
|
placeholder
|
|
20
20
|
}) => {
|
|
21
|
+
const isControlled = value !== void 0;
|
|
22
|
+
const initialValue = defaultValue ?? value ?? 0;
|
|
23
|
+
const [internalValue, setInternalValue] = useState(initialValue);
|
|
21
24
|
const [displayValue, setDisplayValue] = useState(
|
|
22
|
-
|
|
25
|
+
initialValue.toFixed(precision)
|
|
23
26
|
);
|
|
24
|
-
const [prevValue, setPrevValue] = useState(
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
if (value !== prevValue) {
|
|
27
|
+
const [prevValue, setPrevValue] = useState(initialValue);
|
|
28
|
+
const currentValue = isControlled ? value : internalValue;
|
|
29
|
+
if (isControlled && value !== prevValue) {
|
|
28
30
|
setDisplayValue(value.toFixed(precision));
|
|
29
31
|
setPrevValue(value);
|
|
30
32
|
}
|
|
33
|
+
const handleChange = (newValue) => {
|
|
34
|
+
if (!isControlled) {
|
|
35
|
+
setInternalValue(newValue);
|
|
36
|
+
}
|
|
37
|
+
onChange?.(newValue);
|
|
38
|
+
};
|
|
31
39
|
return /* @__PURE__ */ jsxs(
|
|
32
40
|
"div",
|
|
33
41
|
{
|
|
34
42
|
className: cn(
|
|
35
|
-
"relative flex h-12 w-full items-center justify-between gap-2 rounded-
|
|
36
|
-
"focus-within:
|
|
43
|
+
"relative flex h-12 w-full items-center justify-between gap-2 rounded-lg border border-border-base bg-bg-base",
|
|
44
|
+
"focus-within:border-transparent focus-within:outline-hidden focus-within:ring-2 focus-within:ring-border-info",
|
|
37
45
|
"has-aria-invalid:border-border-error",
|
|
38
46
|
"has-disabled:cursor-not-allowed has-disabled:border-border-mute has-disabled:bg-bg-mute has-disabled:has-hover:hover:bg-bg-mute"
|
|
39
47
|
),
|
|
@@ -46,7 +54,7 @@ const NumberField = ({
|
|
|
46
54
|
"aria-required": isRequired,
|
|
47
55
|
"aria-valuemax": max,
|
|
48
56
|
"aria-valuemin": min,
|
|
49
|
-
"aria-valuenow":
|
|
57
|
+
"aria-valuenow": currentValue,
|
|
50
58
|
autoComplete: "off",
|
|
51
59
|
autoCorrect: "off",
|
|
52
60
|
className: cn(
|
|
@@ -58,7 +66,7 @@ const NumberField = ({
|
|
|
58
66
|
inputMode: "decimal",
|
|
59
67
|
onBlur: () => {
|
|
60
68
|
const newValue = between(cast(displayValue, precision), min, max);
|
|
61
|
-
|
|
69
|
+
handleChange(newValue);
|
|
62
70
|
setDisplayValue(newValue.toFixed(precision));
|
|
63
71
|
},
|
|
64
72
|
onChange: (e) => {
|
|
@@ -74,7 +82,7 @@ const NumberField = ({
|
|
|
74
82
|
min,
|
|
75
83
|
max
|
|
76
84
|
);
|
|
77
|
-
|
|
85
|
+
handleChange(newValue);
|
|
78
86
|
setDisplayValue(newValue.toFixed(precision));
|
|
79
87
|
}
|
|
80
88
|
if (e.key === "ArrowDown") {
|
|
@@ -83,7 +91,7 @@ const NumberField = ({
|
|
|
83
91
|
min,
|
|
84
92
|
max
|
|
85
93
|
);
|
|
86
|
-
|
|
94
|
+
handleChange(newValue);
|
|
87
95
|
setDisplayValue(newValue.toFixed(precision));
|
|
88
96
|
}
|
|
89
97
|
},
|
|
@@ -109,7 +117,7 @@ const NumberField = ({
|
|
|
109
117
|
min,
|
|
110
118
|
max
|
|
111
119
|
);
|
|
112
|
-
|
|
120
|
+
handleChange(newValue);
|
|
113
121
|
setDisplayValue(newValue.toFixed(precision));
|
|
114
122
|
},
|
|
115
123
|
tabIndex: -1,
|
|
@@ -134,7 +142,7 @@ const NumberField = ({
|
|
|
134
142
|
min,
|
|
135
143
|
max
|
|
136
144
|
);
|
|
137
|
-
|
|
145
|
+
handleChange(newValue);
|
|
138
146
|
setDisplayValue(newValue.toFixed(precision));
|
|
139
147
|
},
|
|
140
148
|
tabIndex: -1,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
1
|
import { expect } from "storybook/test";
|
|
4
2
|
import { NumberField } from "./number-field";
|
|
5
3
|
const meta = {
|
|
@@ -7,11 +5,8 @@ const meta = {
|
|
|
7
5
|
component: NumberField,
|
|
8
6
|
args: {
|
|
9
7
|
id: "textfield",
|
|
10
|
-
describedbyId: "numberfield-feedback"
|
|
11
|
-
|
|
12
|
-
render: (args) => {
|
|
13
|
-
const [value, setValue] = useState(0);
|
|
14
|
-
return /* @__PURE__ */ jsx(NumberField, { ...args, onChange: setValue, value });
|
|
8
|
+
describedbyId: "numberfield-feedback",
|
|
9
|
+
defaultValue: 0
|
|
15
10
|
},
|
|
16
11
|
parameters: {
|
|
17
12
|
a11y: {
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import type { ChangeEventHandler, FC } from 'react';
|
|
2
2
|
import type { Option } from '../../../types/variables';
|
|
3
|
-
type
|
|
3
|
+
type BaseProps = {
|
|
4
|
+
name: string;
|
|
4
5
|
labelId: string;
|
|
5
6
|
isDisabled: boolean;
|
|
7
|
+
options: readonly Option[];
|
|
8
|
+
};
|
|
9
|
+
type ControlledProps = {
|
|
6
10
|
value: string;
|
|
7
|
-
defaultValue?: string;
|
|
8
11
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
9
|
-
|
|
12
|
+
defaultValue?: never;
|
|
13
|
+
};
|
|
14
|
+
type UncontrolledProps = {
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
value?: never;
|
|
17
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
10
18
|
};
|
|
19
|
+
type Props = BaseProps & (ControlledProps | UncontrolledProps);
|
|
11
20
|
export declare const Radio: FC<Props>;
|
|
12
21
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "./../../../helpers/cn";
|
|
3
3
|
const Radio = ({
|
|
4
|
+
name,
|
|
4
5
|
labelId,
|
|
5
6
|
isDisabled,
|
|
6
7
|
value,
|
|
@@ -28,13 +29,14 @@ const Radio = ({
|
|
|
28
29
|
/* @__PURE__ */ jsx(
|
|
29
30
|
"input",
|
|
30
31
|
{
|
|
31
|
-
checked: value === option.value,
|
|
32
|
+
checked: value !== void 0 ? value === option.value : void 0,
|
|
32
33
|
className: cn(
|
|
33
34
|
"cursor-pointer",
|
|
34
35
|
"disabled:cursor-not-allowed disabled:bg-bg-mute"
|
|
35
36
|
),
|
|
36
|
-
defaultChecked: defaultValue === option.value,
|
|
37
|
+
defaultChecked: defaultValue !== void 0 ? defaultValue === option.value : void 0,
|
|
37
38
|
disabled: isDisabled,
|
|
39
|
+
name,
|
|
38
40
|
onChange,
|
|
39
41
|
type: "radio",
|
|
40
42
|
value: option.value
|
|
@@ -1,51 +1,26 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
1
|
import { Radio } from "./radio";
|
|
4
2
|
const meta = {
|
|
5
3
|
title: "components/form/radio",
|
|
6
|
-
component: Radio
|
|
4
|
+
component: Radio,
|
|
5
|
+
args: {
|
|
6
|
+
name: "radio-group",
|
|
7
|
+
labelId: "radio",
|
|
8
|
+
options: [
|
|
9
|
+
{ value: "0", label: "\u306F\u3044" },
|
|
10
|
+
{ value: "1", label: "\u3044\u3044\u3048" }
|
|
11
|
+
],
|
|
12
|
+
defaultValue: "0"
|
|
13
|
+
}
|
|
7
14
|
};
|
|
8
15
|
var radio_stories_default = meta;
|
|
9
16
|
const Default = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{ value: "0", label: "\u306F\u3044" },
|
|
13
|
-
{ value: "1", label: "\u3044\u3044\u3048" }
|
|
14
|
-
];
|
|
15
|
-
const [value, setValue] = useState("0");
|
|
16
|
-
return /* @__PURE__ */ jsx(
|
|
17
|
-
Radio,
|
|
18
|
-
{
|
|
19
|
-
isDisabled: false,
|
|
20
|
-
labelId: "radio",
|
|
21
|
-
onChange: (e) => {
|
|
22
|
-
setValue(e.target.value);
|
|
23
|
-
},
|
|
24
|
-
options,
|
|
25
|
-
value
|
|
26
|
-
}
|
|
27
|
-
);
|
|
17
|
+
args: {
|
|
18
|
+
isDisabled: false
|
|
28
19
|
}
|
|
29
20
|
};
|
|
30
21
|
const Disabled = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{ value: "0", label: "\u306F\u3044" },
|
|
34
|
-
{ value: "1", label: "\u3044\u3044\u3048" }
|
|
35
|
-
];
|
|
36
|
-
const [value, setValue] = useState("0");
|
|
37
|
-
return /* @__PURE__ */ jsx(
|
|
38
|
-
Radio,
|
|
39
|
-
{
|
|
40
|
-
isDisabled: true,
|
|
41
|
-
labelId: "radio",
|
|
42
|
-
onChange: (e) => {
|
|
43
|
-
setValue(e.target.value);
|
|
44
|
-
},
|
|
45
|
-
options,
|
|
46
|
-
value
|
|
47
|
-
}
|
|
48
|
-
);
|
|
22
|
+
args: {
|
|
23
|
+
isDisabled: true
|
|
49
24
|
}
|
|
50
25
|
};
|
|
51
26
|
export {
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import type
|
|
2
|
-
type
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
type BaseProps = {
|
|
3
3
|
id?: string;
|
|
4
4
|
describedbyId?: string | undefined;
|
|
5
5
|
isInvalid: boolean;
|
|
6
6
|
isDisabled: boolean;
|
|
7
7
|
isRequired: boolean;
|
|
8
|
-
value: number;
|
|
9
|
-
defaultValue?: number;
|
|
10
|
-
onChange: (value: number) => void;
|
|
11
8
|
step?: number;
|
|
12
9
|
max?: number;
|
|
13
10
|
min?: number;
|
|
14
11
|
showValue?: boolean;
|
|
15
12
|
unit?: string;
|
|
16
13
|
};
|
|
14
|
+
type ControlledProps = {
|
|
15
|
+
value: number;
|
|
16
|
+
onChange: (value: number) => void;
|
|
17
|
+
defaultValue?: never;
|
|
18
|
+
};
|
|
19
|
+
type UncontrolledProps = {
|
|
20
|
+
defaultValue?: number;
|
|
21
|
+
value?: never;
|
|
22
|
+
onChange?: (value: number) => void;
|
|
23
|
+
};
|
|
24
|
+
type Props = BaseProps & (ControlledProps | UncontrolledProps);
|
|
17
25
|
export declare const RangeField: FC<Props>;
|
|
18
26
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
2
3
|
import { cn } from "./../../../helpers/cn";
|
|
3
4
|
const RangeField = ({
|
|
4
5
|
id,
|
|
@@ -15,7 +16,17 @@ const RangeField = ({
|
|
|
15
16
|
showValue = true,
|
|
16
17
|
unit = ""
|
|
17
18
|
}) => {
|
|
18
|
-
|
|
19
|
+
const isControlled = value !== void 0;
|
|
20
|
+
const initialValue = defaultValue ?? value ?? min;
|
|
21
|
+
const [internalValue, setInternalValue] = useState(initialValue);
|
|
22
|
+
const currentValue = isControlled ? value : internalValue;
|
|
23
|
+
const handleChange = (newValue) => {
|
|
24
|
+
if (!isControlled) {
|
|
25
|
+
setInternalValue(newValue);
|
|
26
|
+
}
|
|
27
|
+
onChange?.(newValue);
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-4", children: [
|
|
19
30
|
/* @__PURE__ */ jsx(
|
|
20
31
|
"input",
|
|
21
32
|
{
|
|
@@ -23,30 +34,29 @@ const RangeField = ({
|
|
|
23
34
|
"aria-invalid": isInvalid,
|
|
24
35
|
"aria-valuemax": max,
|
|
25
36
|
"aria-valuemin": min,
|
|
26
|
-
"aria-valuenow":
|
|
37
|
+
"aria-valuenow": currentValue,
|
|
27
38
|
className: cn(
|
|
28
|
-
"h-2 flex-1 cursor-pointer
|
|
29
|
-
"
|
|
30
|
-
"focus:outline-none focus:ring-2 focus:ring-border-info focus:ring-opacity-50",
|
|
39
|
+
"h-2 flex-1 cursor-pointer rounded-full bg-bg-subtle",
|
|
40
|
+
"focus:outline-none focus:ring-2 focus:ring-border-info",
|
|
31
41
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
32
42
|
isInvalid && "ring-2 ring-border-error"
|
|
33
43
|
),
|
|
34
|
-
defaultValue,
|
|
44
|
+
defaultValue: isControlled ? void 0 : defaultValue,
|
|
35
45
|
disabled: isDisabled,
|
|
36
46
|
id,
|
|
37
47
|
max,
|
|
38
48
|
min,
|
|
39
49
|
onChange: (e) => {
|
|
40
|
-
|
|
50
|
+
handleChange(Number(e.target.value));
|
|
41
51
|
},
|
|
42
52
|
required: isRequired,
|
|
43
53
|
step,
|
|
44
54
|
type: "range",
|
|
45
|
-
value
|
|
55
|
+
value: isControlled ? value : void 0
|
|
46
56
|
}
|
|
47
57
|
),
|
|
48
58
|
showValue && /* @__PURE__ */ jsxs("span", { className: "w-16 text-fg-base text-sm", children: [
|
|
49
|
-
|
|
59
|
+
currentValue,
|
|
50
60
|
unit
|
|
51
61
|
] })
|
|
52
62
|
] });
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
2
|
import { RangeField } from "./range-field";
|
|
4
3
|
const meta = {
|
|
5
4
|
title: "components/form/RangeField",
|
|
@@ -16,140 +15,48 @@ const meta = {
|
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
var range_field_stories_default = meta;
|
|
24
|
-
const Default = {
|
|
25
|
-
render: (args) => {
|
|
26
|
-
const [value, setValue] = useState(args.value || 50);
|
|
27
|
-
return /* @__PURE__ */ jsx("div", { className: "w-80", children: /* @__PURE__ */ jsx(
|
|
28
|
-
RangeField,
|
|
29
|
-
{
|
|
30
|
-
...args,
|
|
31
|
-
onChange: (newValue) => {
|
|
32
|
-
setValue(newValue);
|
|
33
|
-
args.onChange(newValue);
|
|
34
|
-
},
|
|
35
|
-
value
|
|
36
|
-
}
|
|
37
|
-
) });
|
|
38
|
-
},
|
|
18
|
+
decorators: [
|
|
19
|
+
(Story) => /* @__PURE__ */ jsx("div", { className: "w-80", children: /* @__PURE__ */ jsx(Story, {}) })
|
|
20
|
+
],
|
|
39
21
|
args: {
|
|
40
|
-
value: 50,
|
|
41
22
|
min: 0,
|
|
42
23
|
max: 100,
|
|
43
24
|
step: 1,
|
|
44
25
|
isInvalid: false,
|
|
45
26
|
isDisabled: false,
|
|
46
27
|
isRequired: false,
|
|
47
|
-
showValue: true
|
|
28
|
+
showValue: true,
|
|
29
|
+
defaultValue: 50
|
|
48
30
|
}
|
|
49
31
|
};
|
|
32
|
+
var range_field_stories_default = meta;
|
|
33
|
+
const Default = {};
|
|
50
34
|
const WithUnit = {
|
|
51
|
-
render: (args) => {
|
|
52
|
-
const [value, setValue] = useState(args.value || 200);
|
|
53
|
-
return /* @__PURE__ */ jsx("div", { className: "w-80", children: /* @__PURE__ */ jsx(
|
|
54
|
-
RangeField,
|
|
55
|
-
{
|
|
56
|
-
...args,
|
|
57
|
-
onChange: (newValue) => {
|
|
58
|
-
setValue(newValue);
|
|
59
|
-
args.onChange(newValue);
|
|
60
|
-
},
|
|
61
|
-
value
|
|
62
|
-
}
|
|
63
|
-
) });
|
|
64
|
-
},
|
|
65
35
|
args: {
|
|
66
|
-
value: 200,
|
|
67
36
|
min: 100,
|
|
68
37
|
max: 500,
|
|
69
38
|
step: 10,
|
|
70
39
|
unit: "px",
|
|
71
|
-
|
|
72
|
-
isDisabled: false,
|
|
73
|
-
isRequired: false,
|
|
74
|
-
showValue: true
|
|
40
|
+
defaultValue: 200
|
|
75
41
|
}
|
|
76
42
|
};
|
|
77
43
|
const WithoutValue = {
|
|
78
|
-
render: (args) => {
|
|
79
|
-
const [value, setValue] = useState(args.value || 75);
|
|
80
|
-
return /* @__PURE__ */ jsx("div", { className: "w-80", children: /* @__PURE__ */ jsx(
|
|
81
|
-
RangeField,
|
|
82
|
-
{
|
|
83
|
-
...args,
|
|
84
|
-
onChange: (newValue) => {
|
|
85
|
-
setValue(newValue);
|
|
86
|
-
args.onChange(newValue);
|
|
87
|
-
},
|
|
88
|
-
value
|
|
89
|
-
}
|
|
90
|
-
) });
|
|
91
|
-
},
|
|
92
44
|
args: {
|
|
93
|
-
value: 75,
|
|
94
|
-
min: 0,
|
|
95
|
-
max: 100,
|
|
96
45
|
step: 5,
|
|
97
46
|
showValue: false,
|
|
98
|
-
|
|
99
|
-
isDisabled: false,
|
|
100
|
-
isRequired: false
|
|
47
|
+
defaultValue: 75
|
|
101
48
|
}
|
|
102
49
|
};
|
|
103
50
|
const Disabled = {
|
|
104
|
-
render: (args) => {
|
|
105
|
-
const [value, setValue] = useState(args.value || 30);
|
|
106
|
-
return /* @__PURE__ */ jsx("div", { className: "w-80", children: /* @__PURE__ */ jsx(
|
|
107
|
-
RangeField,
|
|
108
|
-
{
|
|
109
|
-
...args,
|
|
110
|
-
onChange: (newValue) => {
|
|
111
|
-
setValue(newValue);
|
|
112
|
-
args.onChange(newValue);
|
|
113
|
-
},
|
|
114
|
-
value
|
|
115
|
-
}
|
|
116
|
-
) });
|
|
117
|
-
},
|
|
118
51
|
args: {
|
|
119
|
-
value: 30,
|
|
120
|
-
min: 0,
|
|
121
|
-
max: 100,
|
|
122
|
-
step: 1,
|
|
123
|
-
isInvalid: false,
|
|
124
52
|
isDisabled: true,
|
|
125
|
-
|
|
126
|
-
showValue: true
|
|
53
|
+
defaultValue: 30
|
|
127
54
|
}
|
|
128
55
|
};
|
|
129
56
|
const Invalid = {
|
|
130
|
-
render: (args) => {
|
|
131
|
-
const [value, setValue] = useState(args.value || 90);
|
|
132
|
-
return /* @__PURE__ */ jsx("div", { className: "w-80", children: /* @__PURE__ */ jsx(
|
|
133
|
-
RangeField,
|
|
134
|
-
{
|
|
135
|
-
...args,
|
|
136
|
-
onChange: (newValue) => {
|
|
137
|
-
setValue(newValue);
|
|
138
|
-
args.onChange(newValue);
|
|
139
|
-
},
|
|
140
|
-
value
|
|
141
|
-
}
|
|
142
|
-
) });
|
|
143
|
-
},
|
|
144
57
|
args: {
|
|
145
|
-
value: 90,
|
|
146
|
-
min: 0,
|
|
147
|
-
max: 100,
|
|
148
|
-
step: 1,
|
|
149
58
|
isInvalid: true,
|
|
150
|
-
|
|
151
|
-
isRequired: false,
|
|
152
|
-
showValue: true
|
|
59
|
+
defaultValue: 90
|
|
153
60
|
}
|
|
154
61
|
};
|
|
155
62
|
export {
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import type { ChangeEventHandler, FC } from 'react';
|
|
2
2
|
import type { Option } from '../../../types/variables';
|
|
3
|
-
type
|
|
3
|
+
type BaseProps = {
|
|
4
4
|
id: string;
|
|
5
5
|
describedbyId: string | undefined;
|
|
6
6
|
isInvalid: boolean;
|
|
7
7
|
isDisabled: boolean;
|
|
8
8
|
isRequired: boolean;
|
|
9
9
|
options: readonly Option[];
|
|
10
|
+
};
|
|
11
|
+
type ControlledProps = {
|
|
10
12
|
value: string;
|
|
11
|
-
defaultValue?: string;
|
|
12
13
|
onChange: ChangeEventHandler<HTMLSelectElement>;
|
|
14
|
+
defaultValue?: never;
|
|
15
|
+
};
|
|
16
|
+
type UncontrolledProps = {
|
|
17
|
+
defaultValue?: string;
|
|
18
|
+
value?: never;
|
|
19
|
+
onChange?: ChangeEventHandler<HTMLSelectElement>;
|
|
13
20
|
};
|
|
21
|
+
type Props = BaseProps & (ControlledProps | UncontrolledProps);
|
|
14
22
|
export declare const Select: FC<Props>;
|
|
15
23
|
export {};
|
|
@@ -20,7 +20,7 @@ const Select = ({
|
|
|
20
20
|
"aria-invalid": isInvalid,
|
|
21
21
|
"aria-required": isRequired,
|
|
22
22
|
className: cn(
|
|
23
|
-
"w-full appearance-none rounded-
|
|
23
|
+
"w-full appearance-none rounded-lg border border-border-base bg-bg-base px-3 py-2 text-fg-base",
|
|
24
24
|
"aria-invalid:border-border-error",
|
|
25
25
|
"disabled:cursor-not-allowed disabled:border-border-mute disabled:bg-bg-mute disabled:hover:bg-bg-mute",
|
|
26
26
|
"focus-visible:border-transparent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-info"
|
|
@@ -33,7 +33,7 @@ const Select = ({
|
|
|
33
33
|
children: options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
|
|
34
34
|
}
|
|
35
35
|
),
|
|
36
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
36
|
+
/* @__PURE__ */ jsx("div", { className: "absolute top-2/4 right-3 -translate-y-1/2", children: /* @__PURE__ */ jsx(ChevronIcon, { direction: "down", size: "sm" }) })
|
|
37
37
|
] });
|
|
38
38
|
};
|
|
39
39
|
export {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChangeEventHandler, FC } from 'react';
|
|
2
|
-
type
|
|
2
|
+
type BaseProps = {
|
|
3
3
|
id?: string;
|
|
4
4
|
name?: string;
|
|
5
5
|
describedbyId?: string | undefined;
|
|
@@ -7,9 +7,17 @@ type Props = {
|
|
|
7
7
|
isDisabled: boolean;
|
|
8
8
|
isRequired: boolean;
|
|
9
9
|
placeholder?: string;
|
|
10
|
+
};
|
|
11
|
+
type ControlledProps = {
|
|
12
|
+
value: string;
|
|
13
|
+
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
14
|
+
defaultValue?: never;
|
|
15
|
+
};
|
|
16
|
+
type UncontrolledProps = {
|
|
10
17
|
defaultValue?: string;
|
|
11
|
-
value?:
|
|
18
|
+
value?: never;
|
|
12
19
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
13
20
|
};
|
|
21
|
+
type Props = BaseProps & (ControlledProps | UncontrolledProps);
|
|
14
22
|
export declare const TextField: FC<Props>;
|
|
15
23
|
export {};
|
|
@@ -19,7 +19,7 @@ const TextField = ({
|
|
|
19
19
|
"aria-invalid": isInvalid,
|
|
20
20
|
"aria-required": isRequired,
|
|
21
21
|
className: cn(
|
|
22
|
-
"w-full rounded-
|
|
22
|
+
"w-full rounded-lg border border-border-base bg-bg-base px-3 py-2",
|
|
23
23
|
"aria-invalid:border-border-error",
|
|
24
24
|
"disabled:cursor-not-allowed disabled:border-border-mute disabled:bg-bg-mute disabled:hover:bg-bg-mute",
|
|
25
25
|
"focus-visible:border-transparent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-info"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ChangeEventHandler, type FC } from 'react';
|
|
2
|
-
type
|
|
2
|
+
type BaseProps = {
|
|
3
3
|
id: string;
|
|
4
4
|
name?: string;
|
|
5
5
|
describedbyId: string | undefined;
|
|
@@ -10,9 +10,17 @@ type Props = {
|
|
|
10
10
|
rows?: number;
|
|
11
11
|
fullHeight?: boolean;
|
|
12
12
|
autoResize?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type ControlledProps = {
|
|
15
|
+
value: string;
|
|
16
|
+
onChange: ChangeEventHandler<HTMLTextAreaElement>;
|
|
17
|
+
defaultValue?: never;
|
|
18
|
+
};
|
|
19
|
+
type UncontrolledProps = {
|
|
13
20
|
defaultValue?: string;
|
|
14
|
-
value?:
|
|
21
|
+
value?: never;
|
|
15
22
|
onChange?: ChangeEventHandler<HTMLTextAreaElement>;
|
|
16
23
|
};
|
|
24
|
+
type Props = BaseProps & (ControlledProps | UncontrolledProps);
|
|
17
25
|
export declare const Textarea: FC<Props>;
|
|
18
26
|
export {};
|