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.
- package/dist/cjs/components/FormLabel.d.ts +11 -4
- package/dist/cjs/components/FormLabel.js +14 -18
- package/dist/cjs/components/FormLabel.js.map +2 -2
- package/dist/esm/components/FormLabel.d.ts +11 -4
- package/dist/esm/components/FormLabel.js +45 -26
- package/dist/esm/components/FormLabel.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FormLabel.tsx +29 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, FC } from "react";
|
|
2
|
-
export type
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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": ["
|
|
5
|
-
"mappings": "
|
|
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\" }}> </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
|
|
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
|
-
|
|
21
|
+
declare const FormLabel: FC<FormLabelProps>;
|
|
22
|
+
export default FormLabel;
|
|
@@ -1,33 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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":["
|
|
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\" }}> </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,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { ComponentPropsWithoutRef, FC, Fragment } from "react"
|
|
1
|
+
"use client"
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { ComponentPropsWithoutRef, FC, Fragment, ReactNode, createContext, useContext } from "react"
|
|
5
4
|
|
|
6
|
-
export type
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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" }}> </div>}
|
|
38
|
+
<div style={{ width, textAlign: "justify", textAlignLast: "justify", ...style }} {...rest} />
|
|
39
|
+
</Fragment>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default FormLabel
|