@tidbcloud/uikit 2.0.0-beta.86 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tidbcloud/uikit
2
2
 
3
+ ## 2.0.0-beta.87
4
+
5
+ ### Patch Changes
6
+
7
+ - add right label to textinput
8
+
3
9
  ## 2.0.0-beta.86
4
10
 
5
11
  ### Patch Changes
@@ -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
+ };
@@ -15,3 +15,4 @@ export * from './TextArea.js';
15
15
  export * from './Rating.js';
16
16
  export * from './context.js';
17
17
  export * from './CopyText.js';
18
+ export * from './SegmentControl.js';
@@ -15,3 +15,4 @@ export * from './TextArea.js';
15
15
  export * from './Rating.js';
16
16
  export * from './context.js';
17
17
  export * from './CopyText.js';
18
+ export * from './SegmentControl.js';
@@ -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 = {},
@@ -116,6 +117,14 @@ function mergeProTableProps(props) {
116
117
  },
117
118
  mantineTableProps
118
119
  );
120
+ const mTableContainerProps = mergeMProps(
121
+ {
122
+ sx: {
123
+ backgroundColor: "transparent"
124
+ }
125
+ },
126
+ mantineTableContainerProps
127
+ );
119
128
  const mTableBodyProps = mergeMProps((args) => {
120
129
  var _a, _b, _c;
121
130
  if (!(data == null ? void 0 : data.length)) {
@@ -163,6 +172,9 @@ function mergeProTableProps(props) {
163
172
  },
164
173
  "&:not([data-striped], [data-striped='false'])": {
165
174
  backgroundColor: theme.colors.carbon[0]
175
+ },
176
+ "&:not([data-selected], [data-row-pinned]) td[data-column-pinned]::before": {
177
+ backgroundColor: "transparent"
166
178
  }
167
179
  }
168
180
  };
@@ -229,6 +241,7 @@ function mergeProTableProps(props) {
229
241
  mantineSkeletonProps: mTabelSkeletonProps,
230
242
  mantineLoadingOverlayProps: mLoadingOverlayProps,
231
243
  mantineTableBodyProps: mTableBodyProps,
244
+ mantineTableContainerProps: mTableContainerProps,
232
245
  mantineBottomToolbarProps: mBottomToolbarProps,
233
246
  mantineTableBodyRowProps: mTableBodyRowProps,
234
247
  mantineTableBodyCellProps: mTableBodyCellProps,
@@ -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 = {},
@@ -114,6 +115,14 @@ function mergeProTableProps(props) {
114
115
  },
115
116
  mantineTableProps
116
117
  );
118
+ const mTableContainerProps = mergeMProps(
119
+ {
120
+ sx: {
121
+ backgroundColor: "transparent"
122
+ }
123
+ },
124
+ mantineTableContainerProps
125
+ );
117
126
  const mTableBodyProps = mergeMProps((args) => {
118
127
  var _a, _b, _c;
119
128
  if (!(data == null ? void 0 : data.length)) {
@@ -161,6 +170,9 @@ function mergeProTableProps(props) {
161
170
  },
162
171
  "&:not([data-striped], [data-striped='false'])": {
163
172
  backgroundColor: theme.colors.carbon[0]
173
+ },
174
+ "&:not([data-selected], [data-row-pinned]) td[data-column-pinned]::before": {
175
+ backgroundColor: "transparent"
164
176
  }
165
177
  }
166
178
  };
@@ -227,6 +239,7 @@ function mergeProTableProps(props) {
227
239
  mantineSkeletonProps: mTabelSkeletonProps,
228
240
  mantineLoadingOverlayProps: mLoadingOverlayProps,
229
241
  mantineTableBodyProps: mTableBodyProps,
242
+ mantineTableContainerProps: mTableContainerProps,
230
243
  mantineBottomToolbarProps: mBottomToolbarProps,
231
244
  mantineTableBodyRowProps: mTableBodyRowProps,
232
245
  mantineTableBodyCellProps: mTableBodyCellProps,
@@ -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
- if (!props.leftLabel) {
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
- "--input-padding-inline-start": "var(--input-padding)"
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
- position: "initial",
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
- backgroundColor: theme.colors.carbon[2],
41
- "& > .mantine-Text-root": {
42
- fontSize: getSize.getFontSize(props.size ?? "md")
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
- borderTopLeftRadius: 0,
49
- borderBottomLeftRadius: 0
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?: string;
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?: string;
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
- if (!props.leftLabel) {
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
- "--input-padding-inline-start": "var(--input-padding)"
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
- position: "initial",
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
- backgroundColor: theme.colors.carbon[2],
39
- "& > .mantine-Text-root": {
40
- fontSize: getFontSize(props.size ?? "md")
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
- borderTopLeftRadius: 0,
47
- borderBottomLeftRadius: 0
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
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidbcloud/uikit",
3
- "version": "2.0.0-beta.86",
3
+ "version": "2.0.0-beta.87",
4
4
  "description": "tidbcloud uikit",
5
5
  "type": "module",
6
6
  "main": "dist/primitive/index.cjs",