@tidbcloud/uikit 2.0.0-beta.85 → 2.0.0-beta.87
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/CHANGELOG.md +12 -0
- package/dist/biz/Form/SegmentControl.cjs +26 -0
- package/dist/biz/Form/SegmentControl.d.cts +7 -0
- package/dist/biz/Form/SegmentControl.d.ts +7 -0
- package/dist/biz/Form/SegmentControl.js +26 -0
- package/dist/biz/Form/index.d.cts +1 -0
- package/dist/biz/Form/index.d.ts +1 -0
- package/dist/biz/Table/ProTable/helpers.cjs +22 -2
- package/dist/biz/Table/ProTable/helpers.js +22 -2
- package/dist/biz/index.cjs +2 -0
- package/dist/biz/index.js +2 -0
- package/dist/primitive/TextInput/TextInput.cjs +40 -20
- package/dist/primitive/TextInput/TextInput.d.cts +5 -1
- package/dist/primitive/TextInput/TextInput.d.ts +5 -1
- package/dist/primitive/TextInput/TextInput.js +40 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.cjs");
|
|
4
|
+
const reactHookForm = require("react-hook-form");
|
|
5
|
+
;/* empty css */
|
|
6
|
+
;/* empty css */
|
|
7
|
+
;/* empty css */
|
|
8
|
+
;/* empty css */
|
|
9
|
+
;/* empty css */
|
|
10
|
+
;/* empty css */
|
|
11
|
+
const SegmentedControl = require("../../node_modules/.pnpm/@mantine_core@7.13.2_patch_hash_v5k5cxye7xaihpcgowhgciky7a_@mantine_hooks@7.13.2_react@18.3.1_hlfamvk7n3o6ychyvm5cyru4yu/node_modules/@mantine/core/esm/components/SegmentedControl/SegmentedControl.cjs");
|
|
12
|
+
const FormSegmentedControl = ({ name, rules, ...restProps }) => {
|
|
13
|
+
const { control } = reactHookForm.useFormContext();
|
|
14
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
15
|
+
reactHookForm.Controller,
|
|
16
|
+
{
|
|
17
|
+
name,
|
|
18
|
+
control,
|
|
19
|
+
rules,
|
|
20
|
+
render: ({ field: { onChange, value } }) => {
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(SegmentedControl.SegmentedControl, { value, onChange, ...restProps });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
exports.FormSegmentedControl = FormSegmentedControl;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RegisterOptions } from 'react-hook-form';
|
|
2
|
+
import { SegmentedControlProps } from '../../primitive/index.js';
|
|
3
|
+
export interface FormSegmentedControlProps extends SegmentedControlProps {
|
|
4
|
+
name: string;
|
|
5
|
+
rules?: RegisterOptions;
|
|
6
|
+
}
|
|
7
|
+
export declare const FormSegmentedControl: ({ name, rules, ...restProps }: FormSegmentedControlProps) => import("react/jsx-runtime.js").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RegisterOptions } from 'react-hook-form';
|
|
2
|
+
import { SegmentedControlProps } from '../../primitive/index.js';
|
|
3
|
+
export interface FormSegmentedControlProps extends SegmentedControlProps {
|
|
4
|
+
name: string;
|
|
5
|
+
rules?: RegisterOptions;
|
|
6
|
+
}
|
|
7
|
+
export declare const FormSegmentedControl: ({ name, rules, ...restProps }: FormSegmentedControlProps) => import("react/jsx-runtime.js").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
+
/* empty css */
|
|
4
|
+
/* empty css */
|
|
5
|
+
/* empty css */
|
|
6
|
+
/* empty css */
|
|
7
|
+
/* empty css */
|
|
8
|
+
/* empty css */
|
|
9
|
+
import { SegmentedControl } from "../../node_modules/.pnpm/@mantine_core@7.13.2_patch_hash_v5k5cxye7xaihpcgowhgciky7a_@mantine_hooks@7.13.2_react@18.3.1_hlfamvk7n3o6ychyvm5cyru4yu/node_modules/@mantine/core/esm/components/SegmentedControl/SegmentedControl.js";
|
|
10
|
+
const FormSegmentedControl = ({ name, rules, ...restProps }) => {
|
|
11
|
+
const { control } = useFormContext();
|
|
12
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
13
|
+
Controller,
|
|
14
|
+
{
|
|
15
|
+
name,
|
|
16
|
+
control,
|
|
17
|
+
rules,
|
|
18
|
+
render: ({ field: { onChange, value } }) => {
|
|
19
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentedControl, { value, onChange, ...restProps });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
FormSegmentedControl
|
|
26
|
+
};
|
package/dist/biz/Form/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ function mergeProTableProps(props) {
|
|
|
30
30
|
const {
|
|
31
31
|
mantineTableProps = {},
|
|
32
32
|
mantinePaperProps = {},
|
|
33
|
+
mantineTableContainerProps = {},
|
|
33
34
|
mantineSkeletonProps = {},
|
|
34
35
|
mantineTableBodyProps,
|
|
35
36
|
mantineTableHeadCellProps = {},
|
|
@@ -40,6 +41,7 @@ function mergeProTableProps(props) {
|
|
|
40
41
|
mantineTableFooterRowProps = {},
|
|
41
42
|
mantineTableFooterProps = {},
|
|
42
43
|
mantineLoadingOverlayProps = {},
|
|
44
|
+
layoutMode,
|
|
43
45
|
withBorder = true,
|
|
44
46
|
loading = false,
|
|
45
47
|
enableExpanding = false,
|
|
@@ -115,6 +117,14 @@ function mergeProTableProps(props) {
|
|
|
115
117
|
},
|
|
116
118
|
mantineTableProps
|
|
117
119
|
);
|
|
120
|
+
const mTableContainerProps = mergeMProps(
|
|
121
|
+
{
|
|
122
|
+
sx: {
|
|
123
|
+
backgroundColor: "transparent"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
mantineTableContainerProps
|
|
127
|
+
);
|
|
118
128
|
const mTableBodyProps = mergeMProps((args) => {
|
|
119
129
|
var _a, _b, _c;
|
|
120
130
|
if (!(data == null ? void 0 : data.length)) {
|
|
@@ -152,11 +162,19 @@ function mergeProTableProps(props) {
|
|
|
152
162
|
sx: {
|
|
153
163
|
"&:where([data-with-row-border]):not(:last-of-type)": {
|
|
154
164
|
td: {
|
|
155
|
-
borderBottom: enableRowVirtualization ? "none !important" : void 0
|
|
165
|
+
borderBottom: enableRowVirtualization || layoutMode && layoutMode !== "semantic" ? "none !important" : void 0
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"&[data-hover]": {
|
|
169
|
+
"&:hover": {
|
|
170
|
+
"--mrt-row-hover-background-color": theme.colors.carbon[3]
|
|
156
171
|
}
|
|
157
172
|
},
|
|
158
173
|
"&:not([data-striped], [data-striped='false'])": {
|
|
159
174
|
backgroundColor: theme.colors.carbon[0]
|
|
175
|
+
},
|
|
176
|
+
"&:not([data-selected], [data-row-pinned]) td[data-column-pinned]::before": {
|
|
177
|
+
backgroundColor: "transparent"
|
|
160
178
|
}
|
|
161
179
|
}
|
|
162
180
|
};
|
|
@@ -202,7 +220,7 @@ function mergeProTableProps(props) {
|
|
|
202
220
|
);
|
|
203
221
|
const mTableFooterProps = mergeMProps(
|
|
204
222
|
{
|
|
205
|
-
sx: { outline: enableStickyFooter ? "none" : void 0 }
|
|
223
|
+
sx: { outline: enableStickyFooter ? "none !important" : void 0 }
|
|
206
224
|
},
|
|
207
225
|
mantineTableFooterProps
|
|
208
226
|
);
|
|
@@ -223,12 +241,14 @@ function mergeProTableProps(props) {
|
|
|
223
241
|
mantineSkeletonProps: mTabelSkeletonProps,
|
|
224
242
|
mantineLoadingOverlayProps: mLoadingOverlayProps,
|
|
225
243
|
mantineTableBodyProps: mTableBodyProps,
|
|
244
|
+
mantineTableContainerProps: mTableContainerProps,
|
|
226
245
|
mantineBottomToolbarProps: mBottomToolbarProps,
|
|
227
246
|
mantineTableBodyRowProps: mTableBodyRowProps,
|
|
228
247
|
mantineTableBodyCellProps: mTableBodyCellProps,
|
|
229
248
|
mantineTableFooterCellProps: mTableFooterCellProps,
|
|
230
249
|
mantineTableFooterRowProps: mTableFooterRowProps,
|
|
231
250
|
mantineTableFooterProps: mTableFooterProps,
|
|
251
|
+
layoutMode,
|
|
232
252
|
data,
|
|
233
253
|
icons: {
|
|
234
254
|
IconArrowsSort: (props2) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(index.IconSwitchVertical02, { size: 14, ...props2 }),
|
|
@@ -28,6 +28,7 @@ function mergeProTableProps(props) {
|
|
|
28
28
|
const {
|
|
29
29
|
mantineTableProps = {},
|
|
30
30
|
mantinePaperProps = {},
|
|
31
|
+
mantineTableContainerProps = {},
|
|
31
32
|
mantineSkeletonProps = {},
|
|
32
33
|
mantineTableBodyProps,
|
|
33
34
|
mantineTableHeadCellProps = {},
|
|
@@ -38,6 +39,7 @@ function mergeProTableProps(props) {
|
|
|
38
39
|
mantineTableFooterRowProps = {},
|
|
39
40
|
mantineTableFooterProps = {},
|
|
40
41
|
mantineLoadingOverlayProps = {},
|
|
42
|
+
layoutMode,
|
|
41
43
|
withBorder = true,
|
|
42
44
|
loading = false,
|
|
43
45
|
enableExpanding = false,
|
|
@@ -113,6 +115,14 @@ function mergeProTableProps(props) {
|
|
|
113
115
|
},
|
|
114
116
|
mantineTableProps
|
|
115
117
|
);
|
|
118
|
+
const mTableContainerProps = mergeMProps(
|
|
119
|
+
{
|
|
120
|
+
sx: {
|
|
121
|
+
backgroundColor: "transparent"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
mantineTableContainerProps
|
|
125
|
+
);
|
|
116
126
|
const mTableBodyProps = mergeMProps((args) => {
|
|
117
127
|
var _a, _b, _c;
|
|
118
128
|
if (!(data == null ? void 0 : data.length)) {
|
|
@@ -150,11 +160,19 @@ function mergeProTableProps(props) {
|
|
|
150
160
|
sx: {
|
|
151
161
|
"&:where([data-with-row-border]):not(:last-of-type)": {
|
|
152
162
|
td: {
|
|
153
|
-
borderBottom: enableRowVirtualization ? "none !important" : void 0
|
|
163
|
+
borderBottom: enableRowVirtualization || layoutMode && layoutMode !== "semantic" ? "none !important" : void 0
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"&[data-hover]": {
|
|
167
|
+
"&:hover": {
|
|
168
|
+
"--mrt-row-hover-background-color": theme.colors.carbon[3]
|
|
154
169
|
}
|
|
155
170
|
},
|
|
156
171
|
"&:not([data-striped], [data-striped='false'])": {
|
|
157
172
|
backgroundColor: theme.colors.carbon[0]
|
|
173
|
+
},
|
|
174
|
+
"&:not([data-selected], [data-row-pinned]) td[data-column-pinned]::before": {
|
|
175
|
+
backgroundColor: "transparent"
|
|
158
176
|
}
|
|
159
177
|
}
|
|
160
178
|
};
|
|
@@ -200,7 +218,7 @@ function mergeProTableProps(props) {
|
|
|
200
218
|
);
|
|
201
219
|
const mTableFooterProps = mergeMProps(
|
|
202
220
|
{
|
|
203
|
-
sx: { outline: enableStickyFooter ? "none" : void 0 }
|
|
221
|
+
sx: { outline: enableStickyFooter ? "none !important" : void 0 }
|
|
204
222
|
},
|
|
205
223
|
mantineTableFooterProps
|
|
206
224
|
);
|
|
@@ -221,12 +239,14 @@ function mergeProTableProps(props) {
|
|
|
221
239
|
mantineSkeletonProps: mTabelSkeletonProps,
|
|
222
240
|
mantineLoadingOverlayProps: mLoadingOverlayProps,
|
|
223
241
|
mantineTableBodyProps: mTableBodyProps,
|
|
242
|
+
mantineTableContainerProps: mTableContainerProps,
|
|
224
243
|
mantineBottomToolbarProps: mBottomToolbarProps,
|
|
225
244
|
mantineTableBodyRowProps: mTableBodyRowProps,
|
|
226
245
|
mantineTableBodyCellProps: mTableBodyCellProps,
|
|
227
246
|
mantineTableFooterCellProps: mTableFooterCellProps,
|
|
228
247
|
mantineTableFooterRowProps: mTableFooterRowProps,
|
|
229
248
|
mantineTableFooterProps: mTableFooterProps,
|
|
249
|
+
layoutMode,
|
|
230
250
|
data,
|
|
231
251
|
icons: {
|
|
232
252
|
IconArrowsSort: (props2) => /* @__PURE__ */ jsxRuntimeExports.jsx(IconSwitchVertical02, { size: 14, ...props2 }),
|
package/dist/biz/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ const TextArea = require("./Form/TextArea.cjs");
|
|
|
34
34
|
const Rating = require("./Form/Rating.cjs");
|
|
35
35
|
const context = require("./Form/context.cjs");
|
|
36
36
|
const CopyText = require("./Form/CopyText.cjs");
|
|
37
|
+
const SegmentControl = require("./Form/SegmentControl.cjs");
|
|
37
38
|
const helpers$1 = require("./TimeRangePicker/helpers.cjs");
|
|
38
39
|
exports.Dot = index.Dot;
|
|
39
40
|
exports.CodeBlock = index$1.CodeBlock;
|
|
@@ -178,6 +179,7 @@ exports.HookFormContext = context.HookFormContext;
|
|
|
178
179
|
exports.HookFormProvider = context.HookFormProvider;
|
|
179
180
|
exports.useHookFormContext = context.useHookFormContext;
|
|
180
181
|
exports.FormCopyText = CopyText.FormCopyText;
|
|
182
|
+
exports.FormSegmentedControl = SegmentControl.FormSegmentedControl;
|
|
181
183
|
exports.DEFAULT_QUICK_RANGES = helpers$1.DEFAULT_QUICK_RANGES;
|
|
182
184
|
exports.DEFAULT_TIME_FORMAT = helpers$1.DEFAULT_TIME_FORMAT;
|
|
183
185
|
exports.DEFAULT_TIME_FORMAT_WITH_TIMEZONE = helpers$1.DEFAULT_TIME_FORMAT_WITH_TIMEZONE;
|
package/dist/biz/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import { FormTextareaInput } from "./Form/TextArea.js";
|
|
|
32
32
|
import { FormRatingInput } from "./Form/Rating.js";
|
|
33
33
|
import { HookFormContext, HookFormProvider, useHookFormContext } from "./Form/context.js";
|
|
34
34
|
import { FormCopyText } from "./Form/CopyText.js";
|
|
35
|
+
import { FormSegmentedControl } from "./Form/SegmentControl.js";
|
|
35
36
|
import { DEFAULT_QUICK_RANGES, DEFAULT_TIME_FORMAT, DEFAULT_TIME_FORMAT_WITH_TIMEZONE, DEFAULT_TIME_RANGE, addOffsetUTC, formatDuration, fromTimeRangeValue, getUTCString, timeFormatter, toTimeRangeValue, toURLTimeRange, urlToTimeRange, urlToTimeRangeValue } from "./TimeRangePicker/helpers.js";
|
|
36
37
|
export {
|
|
37
38
|
CodeBlock,
|
|
@@ -57,6 +58,7 @@ export {
|
|
|
57
58
|
FormPhoneInputV2,
|
|
58
59
|
FormRadioGroup,
|
|
59
60
|
FormRatingInput,
|
|
61
|
+
FormSegmentedControl,
|
|
60
62
|
FormSelect,
|
|
61
63
|
FormSwitch,
|
|
62
64
|
FormTextInput,
|
|
@@ -8,51 +8,71 @@ const index = require("../Typography/index.cjs");
|
|
|
8
8
|
const TextInput$1 = require("../../node_modules/.pnpm/@mantine_core@7.13.2_patch_hash_v5k5cxye7xaihpcgowhgciky7a_@mantine_hooks@7.13.2_react@18.3.1_hlfamvk7n3o6ychyvm5cyru4yu/node_modules/@mantine/core/esm/components/TextInput/TextInput.cjs");
|
|
9
9
|
const getSize = require("../../node_modules/.pnpm/@mantine_core@7.13.2_patch_hash_v5k5cxye7xaihpcgowhgciky7a_@mantine_hooks@7.13.2_react@18.3.1_hlfamvk7n3o6ychyvm5cyru4yu/node_modules/@mantine/core/esm/core/utils/get-size/get-size.cjs");
|
|
10
10
|
const TextInput = React.forwardRef((props, ref) => {
|
|
11
|
-
const { leftLabel, leftSection, ...rest } = props;
|
|
11
|
+
const { leftLabel, leftLabelProps, leftSection, rightLabel, rightLabelProps, rightSection, ...rest } = props;
|
|
12
12
|
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
13
13
|
TextInput$1.TextInput,
|
|
14
14
|
{
|
|
15
15
|
...rest,
|
|
16
16
|
styles: styles.mergeStylesList([
|
|
17
17
|
(theme) => {
|
|
18
|
-
|
|
18
|
+
const withLeftLabel = !!props.leftLabel;
|
|
19
|
+
const withRightLabel = !!props.rightLabel;
|
|
20
|
+
if (!withLeftLabel && !withRightLabel) {
|
|
19
21
|
return {};
|
|
20
22
|
}
|
|
23
|
+
const sectionBaseStyles = {
|
|
24
|
+
position: "initial",
|
|
25
|
+
width: "fit-content",
|
|
26
|
+
border: `1px solid ${theme.colors.carbon[4]}`,
|
|
27
|
+
backgroundColor: theme.colors.carbon[2],
|
|
28
|
+
paddingLeft: 12,
|
|
29
|
+
paddingRight: 12,
|
|
30
|
+
"& > .mantine-Text-root": {
|
|
31
|
+
fontSize: getSize.getFontSize(props.size ?? "md")
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const wrapperBaseStyles = {
|
|
35
|
+
"--input-padding-inline-start": "var(--input-padding)"
|
|
36
|
+
};
|
|
21
37
|
return {
|
|
22
38
|
wrapper: {
|
|
23
39
|
display: "flex",
|
|
24
40
|
// see https://github.com/mantinedev/mantine/blob/master/packages/%40mantine/core/src/components/Input/Input.module.css#L70C4-L70C33I
|
|
25
41
|
// correct input left padding
|
|
26
|
-
"&[data-with-left-section]":
|
|
27
|
-
|
|
28
|
-
}
|
|
42
|
+
"&[data-with-left-section]": withLeftLabel ? wrapperBaseStyles : void 0,
|
|
43
|
+
"&[data-with-right-section]": withRightLabel ? wrapperBaseStyles : void 0
|
|
29
44
|
},
|
|
30
45
|
section: {
|
|
31
|
-
'&[data-position="left"]': {
|
|
32
|
-
|
|
33
|
-
width: "fit-content",
|
|
34
|
-
border: `1px solid ${theme.colors.carbon[4]}`,
|
|
46
|
+
'&[data-position="left"]': withLeftLabel ? {
|
|
47
|
+
...sectionBaseStyles,
|
|
35
48
|
borderRightWidth: 0,
|
|
36
|
-
paddingLeft: 12,
|
|
37
|
-
paddingRight: 12,
|
|
38
49
|
borderTopLeftRadius: theme.defaultRadius,
|
|
39
|
-
borderBottomLeftRadius: theme.defaultRadius
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
borderBottomLeftRadius: theme.defaultRadius
|
|
51
|
+
} : void 0,
|
|
52
|
+
'&[data-position="right"]': withRightLabel ? {
|
|
53
|
+
...sectionBaseStyles,
|
|
54
|
+
borderLeftWidth: 0,
|
|
55
|
+
borderTopRightRadius: theme.defaultRadius,
|
|
56
|
+
borderBottomRightRadius: theme.defaultRadius
|
|
57
|
+
} : void 0
|
|
45
58
|
},
|
|
46
59
|
input: {
|
|
47
60
|
flex: 1,
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
...withLeftLabel ? {
|
|
62
|
+
borderTopLeftRadius: 0,
|
|
63
|
+
borderBottomLeftRadius: 0
|
|
64
|
+
} : void 0,
|
|
65
|
+
...withRightLabel ? {
|
|
66
|
+
borderTopRightRadius: 0,
|
|
67
|
+
borderBottomRightRadius: 0
|
|
68
|
+
} : void 0
|
|
50
69
|
}
|
|
51
70
|
};
|
|
52
71
|
},
|
|
53
72
|
props.styles
|
|
54
73
|
]),
|
|
55
|
-
leftSection: !!leftLabel ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(index.Typography, { variant: "label-lg", children: leftLabel }) : leftSection,
|
|
74
|
+
leftSection: !!leftLabel ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(index.Typography, { variant: "label-lg", ...leftLabelProps, children: leftLabel }) : leftSection,
|
|
75
|
+
rightSection: !!rightLabel ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(index.Typography, { variant: "label-lg", ...rightLabelProps, children: rightLabel }) : rightLabel,
|
|
56
76
|
ref
|
|
57
77
|
}
|
|
58
78
|
);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { TextInputProps as MantineTextInputProps } from '@mantine/core';
|
|
2
|
+
import { TypographyProps } from '../Typography/index.js';
|
|
2
3
|
export interface TextInputProps extends MantineTextInputProps {
|
|
3
|
-
leftLabel?:
|
|
4
|
+
leftLabel?: React.ReactNode;
|
|
5
|
+
leftLabelProps?: TypographyProps;
|
|
6
|
+
rightLabel?: React.ReactNode;
|
|
7
|
+
rightLabelProps?: TypographyProps;
|
|
4
8
|
}
|
|
5
9
|
export declare const TextInput: import('react').ForwardRefExoticComponent<TextInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { TextInputProps as MantineTextInputProps } from '@mantine/core';
|
|
2
|
+
import { TypographyProps } from '../Typography/index.js';
|
|
2
3
|
export interface TextInputProps extends MantineTextInputProps {
|
|
3
|
-
leftLabel?:
|
|
4
|
+
leftLabel?: React.ReactNode;
|
|
5
|
+
leftLabelProps?: TypographyProps;
|
|
6
|
+
rightLabel?: React.ReactNode;
|
|
7
|
+
rightLabelProps?: TypographyProps;
|
|
4
8
|
}
|
|
5
9
|
export declare const TextInput: import('react').ForwardRefExoticComponent<TextInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -6,51 +6,71 @@ import { Typography } from "../Typography/index.js";
|
|
|
6
6
|
import { TextInput as TextInput$1 } from "../../node_modules/.pnpm/@mantine_core@7.13.2_patch_hash_v5k5cxye7xaihpcgowhgciky7a_@mantine_hooks@7.13.2_react@18.3.1_hlfamvk7n3o6ychyvm5cyru4yu/node_modules/@mantine/core/esm/components/TextInput/TextInput.js";
|
|
7
7
|
import { getFontSize } from "../../node_modules/.pnpm/@mantine_core@7.13.2_patch_hash_v5k5cxye7xaihpcgowhgciky7a_@mantine_hooks@7.13.2_react@18.3.1_hlfamvk7n3o6ychyvm5cyru4yu/node_modules/@mantine/core/esm/core/utils/get-size/get-size.js";
|
|
8
8
|
const TextInput = forwardRef((props, ref) => {
|
|
9
|
-
const { leftLabel, leftSection, ...rest } = props;
|
|
9
|
+
const { leftLabel, leftLabelProps, leftSection, rightLabel, rightLabelProps, rightSection, ...rest } = props;
|
|
10
10
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11
11
|
TextInput$1,
|
|
12
12
|
{
|
|
13
13
|
...rest,
|
|
14
14
|
styles: mergeStylesList([
|
|
15
15
|
(theme) => {
|
|
16
|
-
|
|
16
|
+
const withLeftLabel = !!props.leftLabel;
|
|
17
|
+
const withRightLabel = !!props.rightLabel;
|
|
18
|
+
if (!withLeftLabel && !withRightLabel) {
|
|
17
19
|
return {};
|
|
18
20
|
}
|
|
21
|
+
const sectionBaseStyles = {
|
|
22
|
+
position: "initial",
|
|
23
|
+
width: "fit-content",
|
|
24
|
+
border: `1px solid ${theme.colors.carbon[4]}`,
|
|
25
|
+
backgroundColor: theme.colors.carbon[2],
|
|
26
|
+
paddingLeft: 12,
|
|
27
|
+
paddingRight: 12,
|
|
28
|
+
"& > .mantine-Text-root": {
|
|
29
|
+
fontSize: getFontSize(props.size ?? "md")
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const wrapperBaseStyles = {
|
|
33
|
+
"--input-padding-inline-start": "var(--input-padding)"
|
|
34
|
+
};
|
|
19
35
|
return {
|
|
20
36
|
wrapper: {
|
|
21
37
|
display: "flex",
|
|
22
38
|
// see https://github.com/mantinedev/mantine/blob/master/packages/%40mantine/core/src/components/Input/Input.module.css#L70C4-L70C33I
|
|
23
39
|
// correct input left padding
|
|
24
|
-
"&[data-with-left-section]":
|
|
25
|
-
|
|
26
|
-
}
|
|
40
|
+
"&[data-with-left-section]": withLeftLabel ? wrapperBaseStyles : void 0,
|
|
41
|
+
"&[data-with-right-section]": withRightLabel ? wrapperBaseStyles : void 0
|
|
27
42
|
},
|
|
28
43
|
section: {
|
|
29
|
-
'&[data-position="left"]': {
|
|
30
|
-
|
|
31
|
-
width: "fit-content",
|
|
32
|
-
border: `1px solid ${theme.colors.carbon[4]}`,
|
|
44
|
+
'&[data-position="left"]': withLeftLabel ? {
|
|
45
|
+
...sectionBaseStyles,
|
|
33
46
|
borderRightWidth: 0,
|
|
34
|
-
paddingLeft: 12,
|
|
35
|
-
paddingRight: 12,
|
|
36
47
|
borderTopLeftRadius: theme.defaultRadius,
|
|
37
|
-
borderBottomLeftRadius: theme.defaultRadius
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
borderBottomLeftRadius: theme.defaultRadius
|
|
49
|
+
} : void 0,
|
|
50
|
+
'&[data-position="right"]': withRightLabel ? {
|
|
51
|
+
...sectionBaseStyles,
|
|
52
|
+
borderLeftWidth: 0,
|
|
53
|
+
borderTopRightRadius: theme.defaultRadius,
|
|
54
|
+
borderBottomRightRadius: theme.defaultRadius
|
|
55
|
+
} : void 0
|
|
43
56
|
},
|
|
44
57
|
input: {
|
|
45
58
|
flex: 1,
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
...withLeftLabel ? {
|
|
60
|
+
borderTopLeftRadius: 0,
|
|
61
|
+
borderBottomLeftRadius: 0
|
|
62
|
+
} : void 0,
|
|
63
|
+
...withRightLabel ? {
|
|
64
|
+
borderTopRightRadius: 0,
|
|
65
|
+
borderBottomRightRadius: 0
|
|
66
|
+
} : void 0
|
|
48
67
|
}
|
|
49
68
|
};
|
|
50
69
|
},
|
|
51
70
|
props.styles
|
|
52
71
|
]),
|
|
53
|
-
leftSection: !!leftLabel ? /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "label-lg", children: leftLabel }) : leftSection,
|
|
72
|
+
leftSection: !!leftLabel ? /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "label-lg", ...leftLabelProps, children: leftLabel }) : leftSection,
|
|
73
|
+
rightSection: !!rightLabel ? /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "label-lg", ...rightLabelProps, children: rightLabel }) : rightLabel,
|
|
54
74
|
ref
|
|
55
75
|
}
|
|
56
76
|
);
|