@tidbcloud/uikit 2.0.0-beta.64 → 2.0.0-beta.65

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.65
4
+
5
+ ### Patch Changes
6
+
7
+ - add MediaQuery
8
+
3
9
  ## 2.0.0-beta.64
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ const styles = require("./styles.cjs");
5
+ const useProps = 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/MantineProvider/use-props/use-props.cjs");
6
+ function MediaQuery(props) {
7
+ var _a;
8
+ const { children, smallerThan, largerThan, query, styles: styles$1, className } = useProps.useProps("MediaQuery", {}, props);
9
+ const { classes, cx } = styles.default({ smallerThan, largerThan, query, styles: styles$1 });
10
+ if (children === void 0) {
11
+ return void 0;
12
+ }
13
+ const child = React.Children.only(children);
14
+ if (typeof child === "object" && child !== null && "props" in child) {
15
+ return React.cloneElement(child, {
16
+ className: cx(classes.media, (_a = child.props) == null ? void 0 : _a.className, className)
17
+ });
18
+ }
19
+ return child;
20
+ }
21
+ exports.MediaQuery = MediaQuery;
@@ -0,0 +1,18 @@
1
+ import { MantineTheme } from '@mantine/core';
2
+ import { CSSObject } from '@mantine/emotion';
3
+ import { default as React } from 'react';
4
+ import { MediaQueryNumberSize } from './styles.js';
5
+ export interface MediaQueryProps {
6
+ className?: string;
7
+ /** Child that should be shown at given breakpoint, it must accept className prop */
8
+ children: React.ReactNode;
9
+ /** Styles applied to child when viewport is smaller than given breakpoint */
10
+ smallerThan?: MediaQueryNumberSize;
11
+ /** Styles applied to child when viewport is larger than given breakpoint */
12
+ largerThan?: MediaQueryNumberSize;
13
+ /** Any other media query */
14
+ query?: string;
15
+ /** Styles applied to child when breakpoint matches */
16
+ styles: CSSObject | ((theme: MantineTheme) => CSSObject);
17
+ }
18
+ export declare function MediaQuery(props: MediaQueryProps): string | number | boolean | Iterable<React.ReactNode> | React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined;
@@ -0,0 +1,18 @@
1
+ import { MantineTheme } from '@mantine/core';
2
+ import { CSSObject } from '@mantine/emotion';
3
+ import { default as React } from 'react';
4
+ import { MediaQueryNumberSize } from './styles.js';
5
+ export interface MediaQueryProps {
6
+ className?: string;
7
+ /** Child that should be shown at given breakpoint, it must accept className prop */
8
+ children: React.ReactNode;
9
+ /** Styles applied to child when viewport is smaller than given breakpoint */
10
+ smallerThan?: MediaQueryNumberSize;
11
+ /** Styles applied to child when viewport is larger than given breakpoint */
12
+ largerThan?: MediaQueryNumberSize;
13
+ /** Any other media query */
14
+ query?: string;
15
+ /** Styles applied to child when breakpoint matches */
16
+ styles: CSSObject | ((theme: MantineTheme) => CSSObject);
17
+ }
18
+ export declare function MediaQuery(props: MediaQueryProps): string | number | boolean | Iterable<React.ReactNode> | React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined;
@@ -0,0 +1,21 @@
1
+ import React__default, { Children } from "react";
2
+ import useStyles from "./styles.js";
3
+ import { useProps } 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/MantineProvider/use-props/use-props.js";
4
+ function MediaQuery(props) {
5
+ var _a;
6
+ const { children, smallerThan, largerThan, query, styles, className } = useProps("MediaQuery", {}, props);
7
+ const { classes, cx } = useStyles({ smallerThan, largerThan, query, styles });
8
+ if (children === void 0) {
9
+ return void 0;
10
+ }
11
+ const child = Children.only(children);
12
+ if (typeof child === "object" && child !== null && "props" in child) {
13
+ return React__default.cloneElement(child, {
14
+ className: cx(classes.media, (_a = child.props) == null ? void 0 : _a.className, className)
15
+ });
16
+ }
17
+ return child;
18
+ }
19
+ export {
20
+ MediaQuery
21
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const createStyles = require("../../node_modules/.pnpm/@mantine_emotion@7.13.2_@emotion_cache@11.13.1_@emotion_react@11.13.3_@types_react@18.3.11_re_v5yho7ri2fgh4vhey6nnpomqsu/node_modules/@mantine/emotion/esm/create-styles.cjs");
4
+ const rem = 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/units-converters/rem.cjs");
5
+ const px = 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/units-converters/px.cjs");
6
+ function getBreakpointValue(theme, breakpoint) {
7
+ return breakpoint in theme.breakpoints && typeof breakpoint !== "number" ? px.px(theme.breakpoints[breakpoint]) : px.px(breakpoint);
8
+ }
9
+ const useStyles = createStyles.createStyles((theme, { smallerThan, largerThan, query, styles }, u) => {
10
+ const media = {};
11
+ const _styles = typeof styles === "function" ? styles(theme) : styles;
12
+ if (largerThan !== void 0 && smallerThan !== void 0) {
13
+ media[`@media (min-width: ${rem.em(getBreakpointValue(theme, largerThan))}) and (max-width: ${rem.em(
14
+ getBreakpointValue(theme, smallerThan) - 0.1
15
+ )})`] = _styles;
16
+ } else {
17
+ if (largerThan !== void 0) {
18
+ media[u.largerThan(largerThan)] = _styles;
19
+ }
20
+ if (smallerThan !== void 0) {
21
+ media[u.smallerThan(smallerThan)] = _styles;
22
+ }
23
+ }
24
+ if (query) {
25
+ media[`@media ${query}`] = _styles;
26
+ }
27
+ return { media };
28
+ });
29
+ exports.default = useStyles;
@@ -0,0 +1,15 @@
1
+ import { MantineTheme, MantineSize } from '@mantine/core';
2
+ import { CSSObject } from '@mantine/emotion';
3
+ export type MediaQueryNumberSize = MantineSize | number | (string & {});
4
+ export interface MediaQueryStylesParams {
5
+ smallerThan?: MediaQueryNumberSize;
6
+ largerThan?: MediaQueryNumberSize;
7
+ styles?: CSSObject | ((theme: MantineTheme) => CSSObject);
8
+ query?: string;
9
+ }
10
+ declare const _default: (params: MediaQueryStylesParams) => {
11
+ classes: Record<"media", string>;
12
+ cx: (...args: any) => string;
13
+ theme: MantineTheme;
14
+ };
15
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import { MantineTheme, MantineSize } from '@mantine/core';
2
+ import { CSSObject } from '@mantine/emotion';
3
+ export type MediaQueryNumberSize = MantineSize | number | (string & {});
4
+ export interface MediaQueryStylesParams {
5
+ smallerThan?: MediaQueryNumberSize;
6
+ largerThan?: MediaQueryNumberSize;
7
+ styles?: CSSObject | ((theme: MantineTheme) => CSSObject);
8
+ query?: string;
9
+ }
10
+ declare const _default: (params: MediaQueryStylesParams) => {
11
+ classes: Record<"media", string>;
12
+ cx: (...args: any) => string;
13
+ theme: MantineTheme;
14
+ };
15
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { createStyles } from "../../node_modules/.pnpm/@mantine_emotion@7.13.2_@emotion_cache@11.13.1_@emotion_react@11.13.3_@types_react@18.3.11_re_v5yho7ri2fgh4vhey6nnpomqsu/node_modules/@mantine/emotion/esm/create-styles.js";
2
+ import { em } 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/units-converters/rem.js";
3
+ import { px } 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/units-converters/px.js";
4
+ function getBreakpointValue(theme, breakpoint) {
5
+ return breakpoint in theme.breakpoints && typeof breakpoint !== "number" ? px(theme.breakpoints[breakpoint]) : px(breakpoint);
6
+ }
7
+ const useStyles = createStyles((theme, { smallerThan, largerThan, query, styles }, u) => {
8
+ const media = {};
9
+ const _styles = typeof styles === "function" ? styles(theme) : styles;
10
+ if (largerThan !== void 0 && smallerThan !== void 0) {
11
+ media[`@media (min-width: ${em(getBreakpointValue(theme, largerThan))}) and (max-width: ${em(
12
+ getBreakpointValue(theme, smallerThan) - 0.1
13
+ )})`] = _styles;
14
+ } else {
15
+ if (largerThan !== void 0) {
16
+ media[u.largerThan(largerThan)] = _styles;
17
+ }
18
+ if (smallerThan !== void 0) {
19
+ media[u.smallerThan(smallerThan)] = _styles;
20
+ }
21
+ }
22
+ if (query) {
23
+ media[`@media ${query}`] = _styles;
24
+ }
25
+ return { media };
26
+ });
27
+ export {
28
+ useStyles as default
29
+ };
@@ -10,6 +10,7 @@ const useColorScheme = require("../hooks/useColorScheme.cjs");
10
10
  const index = require("../node_modules/.pnpm/@mantine_dropzone@7.13.2_@mantine_core@7.13.2_patch_hash_v5k5cxye7xaihpcgowhgciky7a_@mantine__qr3rnaubensmzqdmx5ctws3cmy/node_modules/@mantine/dropzone/esm/index.cjs");
11
11
  const index$1 = require("./notifier/index.cjs");
12
12
  const index$2 = require("./Typography/index.cjs");
13
+ const index$3 = require("./MediaQuery/index.cjs");
13
14
  const AppShell = 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/AppShell/AppShell.cjs");
14
15
  const AspectRatio = 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/AspectRatio/AspectRatio.cjs");
15
16
  const Center = 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/Center/Center.cjs");
@@ -136,6 +137,7 @@ exports.Dropzone = index.Dropzone;
136
137
  exports.notifier = index$1.notifier;
137
138
  exports.TYPOGRAPHY_STYLES_MAP = index$2.TYPOGRAPHY_STYLES_MAP;
138
139
  exports.Typography = index$2.Typography;
140
+ exports.MediaQuery = index$3.MediaQuery;
139
141
  exports.AppShell = AppShell.AppShell;
140
142
  exports.AspectRatio = AspectRatio.AspectRatio;
141
143
  exports.Center = Center.Center;
@@ -43,3 +43,4 @@ export type { CalendarProps, CalendarBaseProps, DatePickerType, DatePickerProps,
43
43
  export { TextInput, type TextInputProps } from './TextInput/index.js';
44
44
  export { notifier } from './notifier/index.js';
45
45
  export { Typography, TYPOGRAPHY_STYLES_MAP, type TypographyProps } from './Typography/index.js';
46
+ export { MediaQuery, type MediaQueryProps } from './MediaQuery/index.js';
@@ -43,3 +43,4 @@ export type { CalendarProps, CalendarBaseProps, DatePickerType, DatePickerProps,
43
43
  export { TextInput, type TextInputProps } from './TextInput/index.js';
44
44
  export { notifier } from './notifier/index.js';
45
45
  export { Typography, TYPOGRAPHY_STYLES_MAP, type TypographyProps } from './Typography/index.js';
46
+ export { MediaQuery, type MediaQueryProps } from './MediaQuery/index.js';
@@ -8,6 +8,7 @@ import { useColorScheme } from "../hooks/useColorScheme.js";
8
8
  import { Dropzone } from "../node_modules/.pnpm/@mantine_dropzone@7.13.2_@mantine_core@7.13.2_patch_hash_v5k5cxye7xaihpcgowhgciky7a_@mantine__qr3rnaubensmzqdmx5ctws3cmy/node_modules/@mantine/dropzone/esm/index.js";
9
9
  import { notifier } from "./notifier/index.js";
10
10
  import { TYPOGRAPHY_STYLES_MAP, Typography } from "./Typography/index.js";
11
+ import { MediaQuery } from "./MediaQuery/index.js";
11
12
  import { AppShell } 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/AppShell/AppShell.js";
12
13
  import { AspectRatio } 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/AspectRatio/AspectRatio.js";
13
14
  import { Center } 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/Center/Center.js";
@@ -196,6 +197,7 @@ export {
196
197
  MS_POWERPOINT_MIME_TYPE,
197
198
  MS_WORD_MIME_TYPE,
198
199
  Mark,
200
+ MediaQuery,
199
201
  Menu,
200
202
  Modal,
201
203
  ModalsProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidbcloud/uikit",
3
- "version": "2.0.0-beta.64",
3
+ "version": "2.0.0-beta.65",
4
4
  "description": "tidbcloud uikit",
5
5
  "type": "module",
6
6
  "main": "dist/primitive/index.cjs",