deepsea-components 5.7.7 → 5.7.8

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.
@@ -1,5 +1,5 @@
1
- import { ComponentPropsWithoutRef, FC } from "react";
2
- export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
1
+ import { ComponentPropsWithoutRef, FC, ReactNode } from "react";
2
+ export type FormLabelConfig = {
3
3
  /**
4
4
  * Label 的宽度.
5
5
  */
@@ -7,9 +7,16 @@ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
7
7
  /**
8
8
  * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启
9
9
  */
10
- before?: boolean;
10
+ before?: boolean | number;
11
11
  };
12
+ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & FormLabelConfig;
13
+ export declare const FormLabelConfigContext: import("react").Context<Partial<FormLabelConfig>>;
14
+ export type FormLabelConfigProviderProps = FormLabelConfig & {
15
+ children?: ReactNode;
16
+ };
17
+ export declare const FormLabelConfigProvider: FC<FormLabelConfigProviderProps>;
12
18
  /**
13
19
  * 为 Ant Design 的 FormItem 设计的 Label 组件
14
20
  */
15
- export declare const FormLabel: FC<FormLabelProps>;
21
+ declare const FormLabel: FC<FormLabelProps>;
22
+ export default FormLabel;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -19,28 +20,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
20
  // src/components/FormLabel.tsx
20
21
  var FormLabel_exports = {};
21
22
  __export(FormLabel_exports, {
22
- FormLabel: () => FormLabel
23
+ FormLabelConfigContext: () => FormLabelConfigContext,
24
+ FormLabelConfigProvider: () => FormLabelConfigProvider,
25
+ default: () => FormLabel_default
23
26
  });
24
27
  module.exports = __toCommonJS(FormLabel_exports);
25
- var import_deepsea_tools = require("deepsea-tools");
26
28
  var import_react = require("react");
27
- var import_css = require("@emotion/css");
28
- var FormLabel = ({ className, style, before, width, ...rest }) => /* @__PURE__ */ React.createElement(import_react.Fragment, null, !!before && /* @__PURE__ */ React.createElement("div", { style: { width: 11 } }, " "), /* @__PURE__ */ React.createElement(
29
- "div",
30
- {
31
- className: (0, import_deepsea_tools.clsx)(
32
- import_css.css`
33
- text-align: justify;
34
- text-align-last: justify;
35
- `,
36
- className
37
- ),
38
- style: { width, ...style },
39
- ...rest
40
- }
41
- ));
29
+ var FormLabelConfigContext = (0, import_react.createContext)({});
30
+ var FormLabelConfigProvider = ({ width, before, children }) => /* @__PURE__ */ React.createElement(FormLabelConfigContext.Provider, { value: { width, before } }, children);
31
+ var FormLabel = (props) => {
32
+ const { width: _width, before: _before } = (0, import_react.useContext)(FormLabelConfigContext);
33
+ const { style, width = _width, before = _before, ...rest } = props;
34
+ return /* @__PURE__ */ React.createElement(import_react.Fragment, null, !!before && /* @__PURE__ */ React.createElement("div", { style: { width: 11, color: "transparent" } }, " "), /* @__PURE__ */ React.createElement("div", { style: { width, textAlign: "justify", textAlignLast: "justify", ...style }, ...rest }));
35
+ };
36
+ var FormLabel_default = FormLabel;
42
37
  // Annotate the CommonJS export names for ESM import in node:
43
38
  0 && (module.exports = {
44
- FormLabel
39
+ FormLabelConfigContext,
40
+ FormLabelConfigProvider
45
41
  });
46
42
  //# sourceMappingURL=FormLabel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/FormLabel.tsx"],
4
- "sourcesContent": ["import { clsx } from \"deepsea-tools\"\nimport { ComponentPropsWithoutRef, FC, Fragment } from \"react\"\n\nimport { css } from \"@emotion/css\"\n\nexport type FormLabelProps = ComponentPropsWithoutRef<\"div\"> & {\n /**\n * Label 的宽度.\n */\n width: number\n /**\n * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启\n */\n before?: boolean\n}\n\n/**\n * 为 Ant Design 的 FormItem 设计的 Label 组件\n */\nexport const FormLabel: FC<FormLabelProps> = ({ className, style, before, width, ...rest }) => (\n <Fragment>\n {!!before && <div style={{ width: 11 }}>&ensp;</div>}\n <div\n className={clsx(\n css`\n text-align: justify;\n text-align-last: justify;\n `,\n className,\n )}\n style={{ width, ...style }}\n {...rest}\n />\n </Fragment>\n)\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAqB;AACrB,mBAAuD;AAEvD,iBAAoB;AAgBb,IAAM,YAAgC,CAAC,EAAE,WAAW,OAAO,QAAQ,OAAO,GAAG,KAAK,MACrF,oCAAC,6BACI,CAAC,CAAC,UAAU,oCAAC,SAAI,OAAO,EAAE,OAAO,GAAG,KAAG,GAAM,GAC9C;AAAA,EAAC;AAAA;AAAA,IACG,eAAW;AAAA,MACP;AAAA;AAAA;AAAA;AAAA,MAIA;AAAA,IACJ;AAAA,IACA,OAAO,EAAE,OAAO,GAAG,MAAM;AAAA,IACxB,GAAG;AAAA;AACR,CACJ;",
4
+ "sourcesContent": ["\"use client\"\n\nimport { ComponentPropsWithoutRef, FC, Fragment, ReactNode, createContext, useContext } from \"react\"\n\nexport type FormLabelConfig = {\n /**\n * Label 的宽度.\n */\n width: number\n /**\n * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启\n */\n before?: boolean | number\n}\n\nexport type FormLabelProps = ComponentPropsWithoutRef<\"div\"> & FormLabelConfig\n\nexport const FormLabelConfigContext = createContext<Partial<FormLabelConfig>>({})\n\nexport type FormLabelConfigProviderProps = FormLabelConfig & {\n children?: ReactNode\n}\n\nexport const FormLabelConfigProvider: FC<FormLabelConfigProviderProps> = ({ width, before, children }) => (\n <FormLabelConfigContext.Provider value={{ width, before }}>{children}</FormLabelConfigContext.Provider>\n)\n\n/**\n * 为 Ant Design 的 FormItem 设计的 Label 组件\n */\nconst FormLabel: FC<FormLabelProps> = props => {\n const { width: _width, before: _before } = useContext(FormLabelConfigContext)\n const { style, width = _width, before = _before, ...rest } = props\n\n return (\n <Fragment>\n {!!before && <div style={{ width: 11, color: \"transparent\" }}>&ensp;</div>}\n <div style={{ width, textAlign: \"justify\", textAlignLast: \"justify\", ...style }} {...rest} />\n </Fragment>\n )\n}\n\nexport default FormLabel\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6F;AAetF,IAAM,6BAAyB,4BAAwC,CAAC,CAAC;AAMzE,IAAM,0BAA4D,CAAC,EAAE,OAAO,QAAQ,SAAS,MAChG,oCAAC,uBAAuB,UAAvB,EAAgC,OAAO,EAAE,OAAO,OAAO,KAAI,QAAS;AAMzE,IAAM,YAAgC,WAAS;AAC3C,QAAM,EAAE,OAAO,QAAQ,QAAQ,QAAQ,QAAI,yBAAW,sBAAsB;AAC5E,QAAM,EAAE,OAAO,QAAQ,QAAQ,SAAS,SAAS,GAAG,KAAK,IAAI;AAE7D,SACI,oCAAC,6BACI,CAAC,CAAC,UAAU,oCAAC,SAAI,OAAO,EAAE,OAAO,IAAI,OAAO,cAAc,KAAG,GAAM,GACpE,oCAAC,SAAI,OAAO,EAAE,OAAO,WAAW,WAAW,eAAe,WAAW,GAAG,MAAM,GAAI,GAAG,MAAM,CAC/F;AAER;AAEA,IAAO,oBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
- import { ComponentPropsWithoutRef, FC } from "react";
2
- export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
1
+ import { ComponentPropsWithoutRef, FC, ReactNode } from "react";
2
+ export type FormLabelConfig = {
3
3
  /**
4
4
  * Label 的宽度.
5
5
  */
@@ -7,9 +7,16 @@ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
7
7
  /**
8
8
  * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启
9
9
  */
10
- before?: boolean;
10
+ before?: boolean | number;
11
11
  };
12
+ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & FormLabelConfig;
13
+ export declare const FormLabelConfigContext: import("react").Context<Partial<FormLabelConfig>>;
14
+ export type FormLabelConfigProviderProps = FormLabelConfig & {
15
+ children?: ReactNode;
16
+ };
17
+ export declare const FormLabelConfigProvider: FC<FormLabelConfigProviderProps>;
12
18
  /**
13
19
  * 为 Ant Design 的 FormItem 设计的 Label 组件
14
20
  */
15
- export declare const FormLabel: FC<FormLabelProps>;
21
+ declare const FormLabel: FC<FormLabelProps>;
22
+ export default FormLabel;
@@ -1,33 +1,52 @@
1
- import { clsx } from "deepsea-tools";
2
- import { Fragment } from "react";
3
- import { css } from "@emotion/css";
1
+ "use client";
2
+
3
+ import { Fragment, createContext, useContext } from "react";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
  import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ export const FormLabelConfigContext = /*#__PURE__*/createContext({});
7
+ export const FormLabelConfigProvider = ({
8
+ width,
9
+ before,
10
+ children
11
+ }) => /*#__PURE__*/_jsx(FormLabelConfigContext.Provider, {
12
+ value: {
13
+ width,
14
+ before
15
+ },
16
+ children: children
17
+ });
18
+
6
19
  /**
7
20
  * 为 Ant Design 的 FormItem 设计的 Label 组件
8
21
  */
9
- export const FormLabel = ({
10
- className,
11
- style,
12
- before,
13
- width,
14
- ...rest
15
- }) => /*#__PURE__*/_jsxs(Fragment, {
16
- children: [!!before && /*#__PURE__*/_jsx("div", {
17
- style: {
18
- width: 11
19
- },
20
- children: "\u2002"
21
- }), /*#__PURE__*/_jsx("div", {
22
- className: clsx(css`
23
- text-align: justify;
24
- text-align-last: justify;
25
- `, className),
26
- style: {
27
- width,
28
- ...style
29
- },
22
+ const FormLabel = props => {
23
+ const {
24
+ width: _width,
25
+ before: _before
26
+ } = useContext(FormLabelConfigContext);
27
+ const {
28
+ style,
29
+ width = _width,
30
+ before = _before,
30
31
  ...rest
31
- })]
32
- });
32
+ } = props;
33
+ return /*#__PURE__*/_jsxs(Fragment, {
34
+ children: [!!before && /*#__PURE__*/_jsx("div", {
35
+ style: {
36
+ width: 11,
37
+ color: "transparent"
38
+ },
39
+ children: "\u2002"
40
+ }), /*#__PURE__*/_jsx("div", {
41
+ style: {
42
+ width,
43
+ textAlign: "justify",
44
+ textAlignLast: "justify",
45
+ ...style
46
+ },
47
+ ...rest
48
+ })]
49
+ });
50
+ };
51
+ export default FormLabel;
33
52
  //# sourceMappingURL=FormLabel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","Fragment","css","jsx","_jsx","jsxs","_jsxs","FormLabel","className","style","before","width","rest","children"],"sources":["../../../src/components/FormLabel.tsx"],"sourcesContent":["import { clsx } from \"deepsea-tools\"\nimport { ComponentPropsWithoutRef, FC, Fragment } from \"react\"\n\nimport { css } from \"@emotion/css\"\n\nexport type FormLabelProps = ComponentPropsWithoutRef<\"div\"> & {\n /**\n * Label 的宽度.\n */\n width: number\n /**\n * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启\n */\n before?: boolean\n}\n\n/**\n * 为 Ant Design 的 FormItem 设计的 Label 组件\n */\nexport const FormLabel: FC<FormLabelProps> = ({ className, style, before, width, ...rest }) => (\n <Fragment>\n {!!before && <div style={{ width: 11 }}>&ensp;</div>}\n <div\n className={clsx(\n css`\n text-align: justify;\n text-align-last: justify;\n `,\n className,\n )}\n style={{ width, ...style }}\n {...rest}\n />\n </Fragment>\n)\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,eAAe;AACpC,SAAuCC,QAAQ,QAAQ,OAAO;AAE9D,SAASC,GAAG,QAAQ,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAalC;AACA;AACA;AACA,OAAO,MAAMC,SAA6B,GAAGA,CAAC;EAAEC,SAAS;EAAEC,KAAK;EAAEC,MAAM;EAAEC,KAAK;EAAE,GAAGC;AAAK,CAAC,kBACtFN,KAAA,CAACL,QAAQ;EAAAY,QAAA,GACJ,CAAC,CAACH,MAAM,iBAAIN,IAAA;IAAKK,KAAK,EAAE;MAAEE,KAAK,EAAE;IAAG,CAAE;IAAAE,QAAA,EAAC;EAAM,CAAK,CAAC,eACpDT,IAAA;IACII,SAAS,EAAER,IAAI,CACXE,GAAI;AACpB;AACA;AACA,iBAAiB,EACDM,SACJ,CAAE;IACFC,KAAK,EAAE;MAAEE,KAAK;MAAE,GAAGF;IAAM,CAAE;IAAA,GACvBG;EAAI,CACX,CAAC;AAAA,CACI,CACb"}
1
+ {"version":3,"names":["Fragment","createContext","useContext","jsx","_jsx","jsxs","_jsxs","FormLabelConfigContext","FormLabelConfigProvider","width","before","children","Provider","value","FormLabel","props","_width","_before","style","rest","color","textAlign","textAlignLast"],"sources":["../../../src/components/FormLabel.tsx"],"sourcesContent":["\"use client\"\n\nimport { ComponentPropsWithoutRef, FC, Fragment, ReactNode, createContext, useContext } from \"react\"\n\nexport type FormLabelConfig = {\n /**\n * Label 的宽度.\n */\n width: number\n /**\n * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启\n */\n before?: boolean | number\n}\n\nexport type FormLabelProps = ComponentPropsWithoutRef<\"div\"> & FormLabelConfig\n\nexport const FormLabelConfigContext = createContext<Partial<FormLabelConfig>>({})\n\nexport type FormLabelConfigProviderProps = FormLabelConfig & {\n children?: ReactNode\n}\n\nexport const FormLabelConfigProvider: FC<FormLabelConfigProviderProps> = ({ width, before, children }) => (\n <FormLabelConfigContext.Provider value={{ width, before }}>{children}</FormLabelConfigContext.Provider>\n)\n\n/**\n * 为 Ant Design 的 FormItem 设计的 Label 组件\n */\nconst FormLabel: FC<FormLabelProps> = props => {\n const { width: _width, before: _before } = useContext(FormLabelConfigContext)\n const { style, width = _width, before = _before, ...rest } = props\n\n return (\n <Fragment>\n {!!before && <div style={{ width: 11, color: \"transparent\" }}>&ensp;</div>}\n <div style={{ width, textAlign: \"justify\", textAlignLast: \"justify\", ...style }} {...rest} />\n </Fragment>\n )\n}\n\nexport default FormLabel\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAuCA,QAAQ,EAAaC,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAepG,OAAO,MAAMC,sBAAsB,gBAAGN,aAAa,CAA2B,CAAC,CAAC,CAAC;AAMjF,OAAO,MAAMO,uBAAyD,GAAGA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAS,CAAC,kBACjGP,IAAA,CAACG,sBAAsB,CAACK,QAAQ;EAACC,KAAK,EAAE;IAAEJ,KAAK;IAAEC;EAAO,CAAE;EAAAC,QAAA,EAAEA;AAAQ,CAAkC,CACzG;;AAED;AACA;AACA;AACA,MAAMG,SAA6B,GAAGC,KAAK,IAAI;EAC3C,MAAM;IAAEN,KAAK,EAAEO,MAAM;IAAEN,MAAM,EAAEO;EAAQ,CAAC,GAAGf,UAAU,CAACK,sBAAsB,CAAC;EAC7E,MAAM;IAAEW,KAAK;IAAET,KAAK,GAAGO,MAAM;IAAEN,MAAM,GAAGO,OAAO;IAAE,GAAGE;EAAK,CAAC,GAAGJ,KAAK;EAElE,oBACIT,KAAA,CAACN,QAAQ;IAAAW,QAAA,GACJ,CAAC,CAACD,MAAM,iBAAIN,IAAA;MAAKc,KAAK,EAAE;QAAET,KAAK,EAAE,EAAE;QAAEW,KAAK,EAAE;MAAc,CAAE;MAAAT,QAAA,EAAC;IAAM,CAAK,CAAC,eAC1EP,IAAA;MAAKc,KAAK,EAAE;QAAET,KAAK;QAAEY,SAAS,EAAE,SAAS;QAAEC,aAAa,EAAE,SAAS;QAAE,GAAGJ;MAAM,CAAE;MAAA,GAAKC;IAAI,CAAG,CAAC;EAAA,CACvF,CAAC;AAEnB,CAAC;AAED,eAAeL,SAAS"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepsea-components",
3
- "version": "5.7.7",
3
+ "version": "5.7.8",
4
4
  "description": "格数科技自用组件库",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,9 +1,8 @@
1
- import { clsx } from "deepsea-tools"
2
- import { ComponentPropsWithoutRef, FC, Fragment } from "react"
1
+ "use client"
3
2
 
4
- import { css } from "@emotion/css"
3
+ import { ComponentPropsWithoutRef, FC, Fragment, ReactNode, createContext, useContext } from "react"
5
4
 
6
- export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
5
+ export type FormLabelConfig = {
7
6
  /**
8
7
  * Label 的宽度.
9
8
  */
@@ -11,25 +10,34 @@ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
11
10
  /**
12
11
  * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启
13
12
  */
14
- before?: boolean
13
+ before?: boolean | number
15
14
  }
16
15
 
16
+ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & FormLabelConfig
17
+
18
+ export const FormLabelConfigContext = createContext<Partial<FormLabelConfig>>({})
19
+
20
+ export type FormLabelConfigProviderProps = FormLabelConfig & {
21
+ children?: ReactNode
22
+ }
23
+
24
+ export const FormLabelConfigProvider: FC<FormLabelConfigProviderProps> = ({ width, before, children }) => (
25
+ <FormLabelConfigContext.Provider value={{ width, before }}>{children}</FormLabelConfigContext.Provider>
26
+ )
27
+
17
28
  /**
18
29
  * 为 Ant Design 的 FormItem 设计的 Label 组件
19
30
  */
20
- export const FormLabel: FC<FormLabelProps> = ({ className, style, before, width, ...rest }) => (
21
- <Fragment>
22
- {!!before && <div style={{ width: 11 }}>&ensp;</div>}
23
- <div
24
- className={clsx(
25
- css`
26
- text-align: justify;
27
- text-align-last: justify;
28
- `,
29
- className,
30
- )}
31
- style={{ width, ...style }}
32
- {...rest}
33
- />
34
- </Fragment>
35
- )
31
+ const FormLabel: FC<FormLabelProps> = props => {
32
+ const { width: _width, before: _before } = useContext(FormLabelConfigContext)
33
+ const { style, width = _width, before = _before, ...rest } = props
34
+
35
+ return (
36
+ <Fragment>
37
+ {!!before && <div style={{ width: 11, color: "transparent" }}>&ensp;</div>}
38
+ <div style={{ width, textAlign: "justify", textAlignLast: "justify", ...style }} {...rest} />
39
+ </Fragment>
40
+ )
41
+ }
42
+
43
+ export default FormLabel