tntd 3.0.0-beta.25 → 3.0.0-beta.26

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.
@@ -11,7 +11,7 @@ import { default as AntdDrawer } from 'antd/es/drawer';
11
11
  import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver';
12
12
  import classNames from 'classnames';
13
13
  import { doUpperTitle } from '../utils';
14
- import React, { useEffect } from 'react';
14
+ import React, { useCallback, useEffect } from 'react';
15
15
  import { Button } from '../button';
16
16
  import Icon from '../icon';
17
17
  const DefaultFooter = ({
@@ -42,6 +42,7 @@ export const Drawer = _a => {
42
42
  footer,
43
43
  showFooter,
44
44
  onClose,
45
+ afterClose,
45
46
  onSubmit,
46
47
  onCancel,
47
48
  onOk,
@@ -58,9 +59,18 @@ export const Drawer = _a => {
58
59
  unUpperConverted,
59
60
  title
60
61
  } = _a,
61
- rest = __rest(_a, ["closable", "className", "footer", "showFooter", "onClose", "onSubmit", "onCancel", "onOk", "okText", "cancelText", "locale", "okType", "cancelType", "confirmLoading", "okButtonProps", "cancelButtonProps", "clickOnBlankToClose", "upperCaseIgnore", "unUpperConverted", "title"]);
62
+ rest = __rest(_a, ["closable", "className", "footer", "showFooter", "onClose", "afterClose", "onSubmit", "onCancel", "onOk", "okText", "cancelText", "locale", "okType", "cancelType", "confirmLoading", "okButtonProps", "cancelButtonProps", "clickOnBlankToClose", "upperCaseIgnore", "unUpperConverted", "title"]);
62
63
  const drawerDom = React.useRef(null);
63
- const _onCancel = onCancel || onClose;
64
+ const _onCancel = useCallback(() => {
65
+ if (onCancel) {
66
+ onCancel();
67
+ } else if (onClose) {
68
+ onClose();
69
+ }
70
+ if (afterClose) {
71
+ afterClose();
72
+ }
73
+ }, [onCancel, onClose, afterClose]);
64
74
  const _onOk = onOk || onSubmit;
65
75
  useEffect(() => {
66
76
  if (clickOnBlankToClose) {
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../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,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,GACnB,CACH,CACG,CACP,CACA,CACQ,CACT,CACP,CAAA;QACH,CAAC,CACc,CAClB,CAAA;IACH,CAAC,CACc,CAClB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { ConfigConsumer } from 'antd/es/config-provider'\nimport type { DrawerProps as AntdDrawerProps } from 'antd/es/drawer'\nimport { default as AntdDrawer } from 'antd/es/drawer'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport classNames from 'classnames'\nimport type { BaseButtonProps } from 'antd/es/button/button'\nimport type { TntButtonType } from '../button/button'\nimport { doUpperTitle } from '../utils'\nimport React, { FC, useEffect, useRef } from 'react'\nimport { Button } from '../button'\nimport Icon from '../icon'\nconst DefaultFooter = ({\n locale,\n onCancel,\n onOk,\n okText,\n okType,\n cancelText,\n confirmLoading,\n okButtonProps,\n cancelButtonProps,\n cancelType,\n}: {\n locale?: {\n okText?: string\n cancelText?: string\n }\n onCancel?: () => void\n onOk?: () => void\n okText: string\n cancelText: string\n okType?: TntButtonType\n cancelType: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n}) => {\n return (\n <>\n <Button onClick={onCancel} type={cancelType || 'default'} {...cancelButtonProps}>\n {cancelText || locale?.cancelText}\n </Button>\n <Button onClick={onOk} type={okType || 'primary'} loading={confirmLoading} {...okButtonProps}>\n {okText || locale?.okText}\n </Button>\n </>\n )\n}\n\ninterface CustomDrawerProps extends AntdDrawerProps {\n footer?: React.ReactNode\n showFooter?: boolean\n onClose?: () => void\n onSubmit?: () => void\n onCancel?: () => void\n onOk?: () => void\n okText?: string\n cancelText?: string\n locale?: {\n okText?: string\n cancelText?: string\n }\n okType?: TntButtonType\n cancelType?: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n clickOnBlankToClose: boolean\n upperCaseIgnore?: []\n unUpperConverted: boolean\n}\n\nexport const Drawer: FC<CustomDrawerProps> = ({\n closable = true,\n className,\n footer,\n showFooter,\n onClose,\n onSubmit,\n onCancel,\n onOk,\n okText = '',\n cancelText = '',\n locale,\n okType = 'primary',\n cancelType = 'default',\n confirmLoading = false,\n okButtonProps = {},\n cancelButtonProps = {},\n clickOnBlankToClose = false,\n upperCaseIgnore,\n unUpperConverted,\n title,\n ...rest\n}) => {\n const drawerDom = React.useRef<EventTarget | null>(null)\n const _onCancel = onCancel || onClose\n const _onOk = onOk || onSubmit\n\n useEffect(() => {\n if (clickOnBlankToClose) {\n const handleOutsideClick = (event: Event) => {\n const drawer = drawerDom.current as Node\n const targetElement = event.target as Node\n\n let isInDrawer = false\n if (drawer && targetElement) {\n isInDrawer = drawer.contains(targetElement as Node) || targetElement === drawer\n }\n drawerDom.current = null\n if (rest.visible && !isInDrawer && _onCancel) {\n _onCancel()\n }\n }\n document.removeEventListener('click', handleOutsideClick)\n document.addEventListener('click', handleOutsideClick)\n return () => {\n document.removeEventListener('click', handleOutsideClick)\n }\n }\n }, [rest.visible, clickOnBlankToClose, _onCancel])\n\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('drawer')\n return (\n <LocaleReceiver componentName=\"Drawer\" defaultLocale={locale}>\n {(locale) => {\n return (\n <div\n onClick={(event: React.MouseEvent<HTMLDivElement>) => {\n drawerDom.current = event.target\n }}\n >\n <AntdDrawer\n className={classNames(prefixCls, 'tnt-drawer', className, {\n [`${prefixCls}-contain-closable`]: closable !== false,\n [`${prefixCls}-footer`]: showFooter || footer,\n })}\n closable={false}\n onClose={_onCancel}\n width={480}\n {...rest}\n title={!unUpperConverted ? doUpperTitle(title, upperCaseIgnore) : title}\n >\n <>\n {closable !== false && (\n <Icon type=\"close\" className={`${prefixCls}-close`} onClick={_onCancel} />\n )}\n {rest.children}\n {(showFooter || footer) && (\n <div className={`${prefixCls}-footer-style`}>\n {footer || (\n <DefaultFooter\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n cancelButtonProps={cancelButtonProps}\n okType={okType}\n locale={locale}\n okText={okText}\n cancelType={cancelType}\n cancelText={cancelText}\n onOk={_onOk}\n onCancel={_onCancel}\n />\n )}\n </div>\n )}\n </>\n </AntdDrawer>\n </div>\n )\n }}\n </LocaleReceiver>\n )\n }}\n </ConfigConsumer>\n )\n}\n"]}
1
+ {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../src/drawer/drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,cAAc,MAAM,wCAAwC,CAAA;AACnE,OAAO,UAAU,MAAM,YAAY,CAAA;AAGnC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,KAAK,EAAE,EAAM,WAAW,EAAE,SAAS,EAAU,MAAM,OAAO,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,MAAM,aAAa,GAAG,CAAC,EACrB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,EACN,UAAU,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,UAAU,GAeX,EAAE,EAAE;IACH,OAAO,CACL;QACE,oBAAC,MAAM,kBAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,IAAI,SAAS,IAAM,iBAAiB,GAC5E,UAAU,KAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,CAC1B;QACT,oBAAC,MAAM,kBAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,IAAI,SAA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C9C,CAAC,EACF,QAAQ,EAAE,KAAK,EACf,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,GAAG,IACN,IAAI,IACR,KAAK,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK;oBAEvE;wBACG,QAAQ,KAAK,KAAK,IAAI,CACrB,oBAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,GAAG,SAAS,QAAQ,EAAE,OAAO,EAAE,SAAS,GAAI,CAC3E;wBACA,IAAI,CAAC,QAAQ;wBACb,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CACzB,6BAAK,SAAS,EAAE,GAAG,SAAS,eAAe,IACxC,MAAM,IAAI,CACT,oBAAC,aAAa,IACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,GACnB,CACH,CACG,CACP,CACA,CACQ,CACT,CACP,CAAA;QACH,CAAC,CACc,CAClB,CAAA;IACH,CAAC,CACc,CAClB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { ConfigConsumer } from 'antd/es/config-provider'\nimport type { DrawerProps as AntdDrawerProps } from 'antd/es/drawer'\nimport { default as AntdDrawer } from 'antd/es/drawer'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport classNames from 'classnames'\nimport type { BaseButtonProps } from 'antd/es/button/button'\nimport type { TntButtonType } from '../button/button'\nimport { doUpperTitle } from '../utils'\nimport React, { FC, useCallback, useEffect, useRef } from 'react'\nimport { Button } from '../button'\nimport Icon from '../icon'\nconst DefaultFooter = ({\n locale,\n onCancel,\n onOk,\n okText,\n okType,\n cancelText,\n confirmLoading,\n okButtonProps,\n cancelButtonProps,\n cancelType,\n}: {\n locale?: {\n okText?: string\n cancelText?: string\n }\n onCancel?: () => void\n onOk?: () => void\n okText: string\n cancelText: string\n okType?: TntButtonType\n cancelType: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n}) => {\n return (\n <>\n <Button onClick={onCancel} type={cancelType || 'default'} {...cancelButtonProps}>\n {cancelText || locale?.cancelText}\n </Button>\n <Button onClick={onOk} type={okType || 'primary'} loading={confirmLoading} {...okButtonProps}>\n {okText || locale?.okText}\n </Button>\n </>\n )\n}\n\ninterface CustomDrawerProps extends AntdDrawerProps {\n footer?: React.ReactNode\n showFooter?: boolean\n onClose?: () => void\n onSubmit?: () => void\n onCancel?: () => void\n afterClose?: () => void\n onOk?: () => void\n okText?: string\n cancelText?: string\n locale?: {\n okText?: string\n cancelText?: string\n }\n okType?: TntButtonType\n cancelType?: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n clickOnBlankToClose: boolean\n upperCaseIgnore?: []\n unUpperConverted: boolean\n}\n\nexport const Drawer: FC<CustomDrawerProps> = ({\n closable = true,\n className,\n footer,\n showFooter,\n onClose,\n afterClose,\n onSubmit,\n onCancel,\n onOk,\n okText = '',\n cancelText = '',\n locale,\n okType = 'primary',\n cancelType = 'default',\n confirmLoading = false,\n okButtonProps = {},\n cancelButtonProps = {},\n clickOnBlankToClose = false,\n upperCaseIgnore,\n unUpperConverted,\n title,\n ...rest\n}) => {\n const drawerDom = React.useRef<EventTarget | null>(null)\n const _onCancel = useCallback(() => {\n if (onCancel) {\n onCancel()\n } else if (onClose) {\n onClose()\n }\n if (afterClose) {\n afterClose()\n }\n }, [onCancel, onClose, afterClose])\n const _onOk = onOk || onSubmit\n\n useEffect(() => {\n if (clickOnBlankToClose) {\n const handleOutsideClick = (event: Event) => {\n const drawer = drawerDom.current as Node\n const targetElement = event.target as Node\n\n let isInDrawer = false\n if (drawer && targetElement) {\n isInDrawer = drawer.contains(targetElement as Node) || targetElement === drawer\n }\n drawerDom.current = null\n if (rest.visible && !isInDrawer && _onCancel) {\n _onCancel()\n }\n }\n document.removeEventListener('click', handleOutsideClick)\n document.addEventListener('click', handleOutsideClick)\n return () => {\n document.removeEventListener('click', handleOutsideClick)\n }\n }\n }, [rest.visible, clickOnBlankToClose, _onCancel])\n\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('drawer')\n return (\n <LocaleReceiver componentName=\"Drawer\" defaultLocale={locale}>\n {(locale) => {\n return (\n <div\n onClick={(event: React.MouseEvent<HTMLDivElement>) => {\n drawerDom.current = event.target\n }}\n >\n <AntdDrawer\n className={classNames(prefixCls, 'tnt-drawer', className, {\n [`${prefixCls}-contain-closable`]: closable !== false,\n [`${prefixCls}-footer`]: showFooter || footer,\n })}\n closable={false}\n onClose={_onCancel}\n width={480}\n {...rest}\n title={!unUpperConverted ? doUpperTitle(title, upperCaseIgnore) : title}\n >\n <>\n {closable !== false && (\n <Icon type=\"close\" className={`${prefixCls}-close`} onClick={_onCancel} />\n )}\n {rest.children}\n {(showFooter || footer) && (\n <div className={`${prefixCls}-footer-style`}>\n {footer || (\n <DefaultFooter\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n cancelButtonProps={cancelButtonProps}\n okType={okType}\n locale={locale}\n okText={okText}\n cancelType={cancelType}\n cancelText={cancelText}\n onOk={_onOk}\n onCancel={_onCancel}\n />\n )}\n </div>\n )}\n </>\n </AntdDrawer>\n </div>\n )\n }}\n </LocaleReceiver>\n )\n }}\n </ConfigConsumer>\n )\n}\n"]}
@@ -47,10 +47,12 @@ export const useExpandFixed = () => {
47
47
  if (!classname) return;
48
48
  container.current = document.querySelector(`.${classname}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`);
49
49
  observer.current = new MutationObserver(expand);
50
- observer.current.observe(container.current, {
51
- childList: true,
52
- attributes: true
53
- });
50
+ if (container.current) {
51
+ observer.current.observe(container.current, {
52
+ childList: true,
53
+ attributes: true
54
+ });
55
+ }
54
56
  };
55
57
  const setChangedKey = key => {
56
58
  activeKeyRef.current = key;
@@ -1 +1 @@
1
- {"version":3,"file":"use-expand-fixed.js","sourceRoot":"","sources":["../../../src/table/hooks/use-expand-fixed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAUzC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,WAAW,GAAG,MAAM,CAAU,cAAc,EAAE,CAAC,CAAA;IACrD,MAAM,YAAY,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAA;IAChD,MAAM,eAAe,GAAG,MAAM,CAAS;QACrC,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,IAAI;KACX,CAAC,CAAA;IACF,MAAM,SAAS,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAA;IACrD,MAAM,QAAQ,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAA;IAEtD,MAAM,MAAM,GAAG,CAAC,GAAgC,EAAE,EAAE;QAClD,MAAM,IAAI,GACP,QAAQ,CAAC,aAAa,CACrB,IAAI,WAAW,CAAC,OAAO,qCAAqC,GAAG,cAAc,CAC3D;YACnB,QAAQ,CAAC,aAAa,CACrB,IAAI,WAAW,CAAC,OAAO,sCAAsC,GAAG,cAAc,CAC5D,CAAA;QACtB,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAClC,IAAI,WAAW,CAAC,OAAO,0CAA0C,GAAG,cAAc,CACjE,CAAA;QACnB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CACjC,IAAI,WAAW,CAAC,OAAO,yCAAyC,GAAG,cAAc,CAChE,CAAA;QACnB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AAA;IAC7B,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;QAChC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;KAC9B;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QACrC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;KACrB;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { useEffect, useRef } from 'react'\nimport { makeRandomCode } from '../utils'\n\nexport type keyType = string | number | null\n\ninterface OldDom {\n main: HTMLDivElement | null\n right: HTMLDivElement | null\n left: HTMLDivElement | null\n}\n\nexport const useExpandFixed = () => {\n const curTableKey = useRef<keyType>(makeRandomCode())\n const activeKeyRef = useRef<string | null>(null)\n const oldActiveKeyRef = useRef<OldDom>({\n main: null,\n right: null,\n left: null,\n })\n const container = useRef<HTMLDivElement | null>(null)\n const observer = useRef<MutationObserver | null>(null)\n\n const getDom = (key: string | number | undefined) => {\n const main =\n (document.querySelector(\n `.${curTableKey.current} .ant-table-scroll [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement) ||\n (document.querySelector(\n `.${curTableKey.current} .ant-table-default [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement)\n const right = document.querySelector(\n `.${curTableKey.current} .ant-table-fixed-right [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement\n const left = document.querySelector(\n `.${curTableKey.current} .ant-table-fixed-left [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement\n return [main, right, left]\n }\n\n const expand = async () => {\n const [main, right, left] = getDom(String(activeKeyRef.current) || '')\n const border = 2\n const height = main?.offsetHeight - border || 0\n if (right) {\n right.setAttribute('style', `display: inline-block; height: ${height}px; overflow: hidden;`)\n }\n\n if (left) {\n left.setAttribute('style', `display: inline-block; height: ${height}px; overflow: hidden;`)\n }\n\n if (main) {\n // 解决 expandIconAsCell为true 且 iconCell的td元素为display: none;时, 展开内容滚动到最右边,会多出一部分iconCell所占据的空间 的问题\n const td = main.childNodes[1] as HTMLDivElement\n\n const colspan = td.getAttribute('colspan') || 0\n const Oldcolspan = td.getAttribute('oldcolspan') || 0\n const newColspan = Oldcolspan ? Oldcolspan : Number(colspan) + 1 + ''\n if (!Oldcolspan) td.setAttribute('oldcolspan', newColspan)\n\n td.setAttribute('colspan', newColspan)\n //\n }\n\n oldActiveKeyRef.current = {\n main,\n right,\n left,\n }\n }\n\n const ob = () => {\n const classname = curTableKey.current\n if (!classname) return\n\n container.current = document.querySelector(\n `.${classname}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`\n ) as HTMLDivElement\n\n observer.current = new MutationObserver(expand)\n observer.current.observe(container.current, {\n childList: true, // 子节点的变动\n attributes: true,\n })\n }\n\n const setChangedKey = (key: string) => {\n activeKeyRef.current = key\n }\n\n const trigger = (key: string) => {\n setChangedKey(key)\n const className = curTableKey.current\n if (!className) return\n const dom = document?.querySelector(\n `.${className}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`\n )\n dom?.setAttribute('c-data', 'Mutation')\n }\n\n useEffect(() => {\n ob()\n }, [curTableKey.current])\n\n return [curTableKey.current, trigger as (key: string) => void] as const\n}\n\nexport const findRowKey = (\n record: any,\n rowKey: string | ((record: any, index: number) => string)\n) => {\n let res: string | number = ''\n if (typeof rowKey === 'function') {\n res = [record].map(rowKey)[0]\n } else if (typeof rowKey === 'string') {\n res = record[rowKey]\n }\n\n return res\n}\n"]}
1
+ {"version":3,"file":"use-expand-fixed.js","sourceRoot":"","sources":["../../../src/table/hooks/use-expand-fixed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAUzC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,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AAE,IAAI;aACjB,CAAC,CAAA;SACH;IACH,CAAC,CAAA;IAED,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,EAAE;QACpC,YAAY,CAAC,OAAO,GAAG,GAAG,CAAA;IAC5B,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE;QAC9B,aAAa,CAAC,GAAG,CAAC,CAAA;QAClB,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAA;QACrC,IAAI,CAAC,SAAS;YAAE,OAAM;QACtB,MAAM,GAAG,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,CACjC,IAAI,SAAS,iGAAiG,CAC/G,CAAA;QACD,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACzC,CAAC,CAAA;IAED,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,EAAE,CAAA;IACN,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;IAEzB,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,OAAgC,CAAU,CAAA;AACzE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAW,EACX,MAAyD,EACzD,EAAE;IACF,IAAI,GAAG,GAAoB,EAAE,CAAA;IAC7B,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;QAChC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;KAC9B;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QACrC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;KACrB;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { useEffect, useRef } from 'react'\nimport { makeRandomCode } from '../utils'\n\nexport type keyType = string | number | null\n\ninterface OldDom {\n main: HTMLDivElement | null\n right: HTMLDivElement | null\n left: HTMLDivElement | null\n}\n\nexport const useExpandFixed = () => {\n const curTableKey = useRef<keyType>(makeRandomCode())\n const activeKeyRef = useRef<string | null>(null)\n const oldActiveKeyRef = useRef<OldDom>({\n main: null,\n right: null,\n left: null,\n })\n const container = useRef<HTMLDivElement | null>(null)\n const observer = useRef<MutationObserver | null>(null)\n\n const getDom = (key: string | number | undefined) => {\n const main =\n (document.querySelector(\n `.${curTableKey.current} .ant-table-scroll [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement) ||\n (document.querySelector(\n `.${curTableKey.current} .ant-table-default [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement)\n const right = document.querySelector(\n `.${curTableKey.current} .ant-table-fixed-right [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement\n const left = document.querySelector(\n `.${curTableKey.current} .ant-table-fixed-left [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement\n return [main, right, left]\n }\n\n const expand = async () => {\n const [main, right, left] = getDom(String(activeKeyRef.current) || '')\n const border = 2\n const height = main?.offsetHeight - border || 0\n if (right) {\n right.setAttribute('style', `display: inline-block; height: ${height}px; overflow: hidden;`)\n }\n\n if (left) {\n left.setAttribute('style', `display: inline-block; height: ${height}px; overflow: hidden;`)\n }\n\n if (main) {\n // 解决 expandIconAsCell为true 且 iconCell的td元素为display: none;时, 展开内容滚动到最右边,会多出一部分iconCell所占据的空间 的问题\n const td = main.childNodes[1] as HTMLDivElement\n\n const colspan = td.getAttribute('colspan') || 0\n const Oldcolspan = td.getAttribute('oldcolspan') || 0\n const newColspan = Oldcolspan ? Oldcolspan : Number(colspan) + 1 + ''\n if (!Oldcolspan) td.setAttribute('oldcolspan', newColspan)\n\n td.setAttribute('colspan', newColspan)\n //\n }\n\n oldActiveKeyRef.current = {\n main,\n right,\n left,\n }\n }\n\n const ob = () => {\n const classname = curTableKey.current\n if (!classname) return\n\n container.current = document.querySelector(\n `.${classname}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`\n ) as HTMLDivElement\n\n observer.current = new MutationObserver(expand)\n if(container.current) {\n observer.current.observe(container.current, {\n childList: true, // 子节点的变动\n attributes: true,\n })\n }\n }\n\n const setChangedKey = (key: string) => {\n activeKeyRef.current = key\n }\n\n const trigger = (key: string) => {\n setChangedKey(key)\n const className = curTableKey.current\n if (!className) return\n const dom = document?.querySelector(\n `.${className}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`\n )\n dom?.setAttribute('c-data', 'Mutation')\n }\n\n useEffect(() => {\n ob()\n }, [curTableKey.current])\n\n return [curTableKey.current, trigger as (key: string) => void] as const\n}\n\nexport const findRowKey = (\n record: any,\n rowKey: string | ((record: any, index: number) => string)\n) => {\n let res: string | number = ''\n if (typeof rowKey === 'function') {\n res = [record].map(rowKey)[0]\n } else if (typeof rowKey === 'string') {\n res = record[rowKey]\n }\n\n return res\n}\n"]}
@@ -1886,6 +1886,16 @@
1886
1886
  .tntd-select:not(.tntd-select-customize-input) .tntd-select-selector input {
1887
1887
  cursor: pointer
1888
1888
  }
1889
+ // compact的样式 start
1890
+ .ant-input-group.ant-input-group-compact>.tntd-select>.tntd-select-selector{
1891
+ border-radius: 0;
1892
+ }
1893
+ .ant-input-group.ant-input-group-compact>*:last-child,
1894
+ .ant-input-group.ant-input-group-compact>.tntd-select:last-child>.tntd-select-selector{
1895
+ border-top-right-radius: @border-radius-base;
1896
+ border-bottom-right-radius: @border-radius-base;
1897
+ }
1898
+ // compact的样式 end
1889
1899
 
1890
1900
  .tntd-select-show-search.tntd-select:not(.tntd-select-customize-input) .tntd-select-selector {
1891
1901
  cursor: text
@@ -12,6 +12,7 @@ import * as React from 'react';
12
12
  import Col from '../grid-v4/col';
13
13
  import Tooltip from '../tooltip';
14
14
  import { FormContext } from './context';
15
+ import { doUpperTitle } from '../utils';
15
16
  function toTooltipProps(tooltip) {
16
17
  if (!tooltip) {
17
18
  return null;
@@ -36,6 +37,7 @@ const FormItemLabel = ({
36
37
  }) => {
37
38
  // const [formLocale] = useLocaleReceiver('Form');
38
39
  if (!label) return null;
40
+ label = doUpperTitle(label);
39
41
  return React.createElement(FormContext.Consumer, {
40
42
  key: "label"
41
43
  }, ({
@@ -1 +1 @@
1
- {"version":3,"file":"FormItemLabel.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,GAAG,MAAM,gBAAgB,CAAA;AAIhC,OAAO,OAAO,MAAM,YAAY,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAUvC,SAAS,cAAc,CAAC,OAAyB;IAC/C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;QACjE,OAAO,OAA8B,CAAA;KACtC;IAED,OAAO;QACL,KAAK,EAAE,OAAO;KACf,CAAA;AACH,CAAC;AAYD,MAAM,aAAa,GAA6E,CAAC,EAC/F,SAAS,EACT,KAAK,EACL,OAAO,EACP,QAAQ,EACR,UAAU,EACV,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,OAAO,GACR,EAAE,EAAE;IACH,kDAAkD;IAElD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,OAAO,CACL,oBAAC,WAAW,CAAC,QAAQ,IAAC,GAAG,EAAC,OAAO,IAC9B,CAAC,EACA,QAAQ,EACR,UAAU,EAAE,iBAAiB,EAC7B,QAAQ,EAAE,eAAe,EACzB,SAAS,EACT,KAAK,EAAE,YAAY,GACF,EAAE,EAAE;QACrB,MAAM,cAAc,GAAa,QAAQ,IAAI,eAA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CAAgC;QAChC,IAAI,YAAY,KAAK,UAAU,IAAI,CAAC,QAAQ,EAAE;YAC5C,aAAa,GAAG,CACd;gBACG,aAAa;gBACd,8BAAM,SAAS,EAAE,GAAG,SAAS,gBAAgB,EAAE,KAAK,EAAC,EAAE,GAEhD,CACN,CACJ,CAAA;SACF;QAED,MAAM,cAAc,GAAG,UAAU,CAAC;YAChC,CAAC,GAAG,SAAS,gBAAgB,CAAC,EAAE,QAAQ;YACxC,CAAC,GAAG,SAAS,8BAA8B,CAAC,EAAE,YAAY,KAAK,UAAU;YACzE,CAAC,GAAG,SAAS,gBAAgB,CAAC,EAAE,CAAC,aAAa;SAC/C,CAAC,CAAA;QAEF,OAAO,CACL,oBAAC,GAAG,oBAAK,cAAc,IAAE,SAAS,EAAE,iBAAiB;YACnD,+BACE,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAE5C,aAAa,CACR,CACJ,CACP,CAAA;IACH,CAAC,CACoB,CACxB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,aAAa,CAAA","sourcesContent":["import Icon from '../icon'\nimport classNames from 'classnames'\nimport * as React from 'react'\nimport type { ColProps } from '../grid-v4/col'\nimport Col from '../grid-v4/col'\n// import { useLocaleReceiver } from '../locale-provider/LocaleReceiver';\n// import defaultLocale from '../locale/default';\nimport type { TooltipProps } from '../tooltip'\nimport Tooltip from '../tooltip'\nimport type { FormContextProps } from './context'\nimport { FormContext } from './context'\nimport type { RequiredMark } from './Form'\nimport type { FormLabelAlign } from './interface'\n\nexport type WrapperTooltipProps = TooltipProps & {\n icon?: React.ReactElement\n}\n\nexport type LabelTooltipType = WrapperTooltipProps | React.ReactNode\n\nfunction toTooltipProps(tooltip: LabelTooltipType): WrapperTooltipProps | null {\n if (!tooltip) {\n return null\n }\n\n if (typeof tooltip === 'object' && !React.isValidElement(tooltip)) {\n return tooltip as WrapperTooltipProps\n }\n\n return {\n title: tooltip,\n }\n}\n\nexport interface FormItemLabelProps {\n colon?: boolean\n htmlFor?: string\n label?: React.ReactNode\n labelAlign?: FormLabelAlign\n labelCol?: ColProps\n requiredMark?: RequiredMark\n tooltip?: LabelTooltipType\n}\n\nconst FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixCls: string }> = ({\n prefixCls,\n label,\n htmlFor,\n labelCol,\n labelAlign,\n colon,\n required,\n requiredMark,\n tooltip,\n}) => {\n // const [formLocale] = useLocaleReceiver('Form');\n\n if (!label) return null\n\n return (\n <FormContext.Consumer key=\"label\">\n {({\n vertical,\n labelAlign: contextLabelAlign,\n labelCol: contextLabelCol,\n labelWrap,\n colon: contextColon,\n }: FormContextProps) => {\n const mergedLabelCol: ColProps = labelCol || contextLabelCol || {}\n\n const mergedLabelAlign: FormLabelAlign | undefined = labelAlign || contextLabelAlign\n\n const labelClsBasic = `${prefixCls}-item-label`\n const labelColClassName = classNames(\n labelClsBasic,\n mergedLabelAlign === 'left' && `${labelClsBasic}-left`,\n mergedLabelCol.className,\n {\n [`${labelClsBasic}-wrap`]: !!labelWrap,\n }\n )\n\n let labelChildren = label\n // Keep label is original where there should have no colon\n const computedColon = colon === true || (contextColon !== false && colon !== false)\n const haveColon = computedColon && !vertical\n // Remove duplicated user input colon\n if (haveColon && typeof label === 'string' && (label as string).trim() !== '') {\n labelChildren = (label as string).replace(/[:|:]\\s*$/, '')\n }\n\n // Tooltip\n const tooltipProps = toTooltipProps(tooltip)\n if (tooltipProps) {\n const { icon = <Icon type=\"question-circle\" />, ...restTooltipProps } = tooltipProps\n const tooltipNode = (\n <Tooltip {...restTooltipProps}>\n {React.cloneElement(icon, { className: `${prefixCls}-item-tooltip`, title: '' })}\n </Tooltip>\n )\n\n labelChildren = (\n <>\n {labelChildren}\n {tooltipNode}\n </>\n )\n }\n\n // Add required mark if optional\n if (requiredMark === 'optional' && !required) {\n labelChildren = (\n <>\n {labelChildren}\n <span className={`${prefixCls}-item-optional`} title=\"\">\n {/* {formLocale?.optional || defaultLocale.Form?.optional} */}\n </span>\n </>\n )\n }\n\n const labelClassName = classNames({\n [`${prefixCls}-item-required`]: required,\n [`${prefixCls}-item-required-mark-optional`]: requiredMark === 'optional',\n [`${prefixCls}-item-no-colon`]: !computedColon,\n })\n\n return (\n <Col {...mergedLabelCol} className={labelColClassName}>\n <label\n htmlFor={htmlFor}\n className={labelClassName}\n title={typeof label === 'string' ? label : ''}\n >\n {labelChildren}\n </label>\n </Col>\n )\n }}\n </FormContext.Consumer>\n )\n}\n\nexport default FormItemLabel\n"]}
1
+ {"version":3,"file":"FormItemLabel.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,GAAG,MAAM,gBAAgB,CAAA;AAIhC,OAAO,OAAO,MAAM,YAAY,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAIvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAQvC,SAAS,cAAc,CAAC,OAAyB;IAC/C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;QACjE,OAAO,OAA8B,CAAA;KACtC;IAED,OAAO;QACL,KAAK,EAAE,OAAO;KACf,CAAA;AACH,CAAC;AAYD,MAAM,aAAa,GAA6E,CAAC,EAC/F,SAAS,EACT,KAAK,EACL,OAAO,EACP,QAAQ,EACR,UAAU,EACV,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,OAAO,GACR,EAAE,EAAE;IACH,kDAAkD;IAElD,IAAI,CA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,EAAjC,gBAAgB,UAAK,YAAY,EAA9E,QAA+D,CAAe,CAAA;YACpF,MAAM,WAAW,GAAG,CAClB,oBAAC,OAAO,oBAAK,gBAAgB,GAC1B,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,SAAS,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CACxE,CACX,CAAA;YAED,aAAa,GAAG,CACd;gBACG,aAAa;gBACb,WAAW,CACX,CACJ,CAAA;SACF;QAED,gCAAgC;QAChC,IAAI,YAAY,KAAK,UAAU,IAAI,CAAC,QAAQ,EAAE;YAC5C,aAAa,GAAG,CACd;gBACG,aAAa;gBACd,8BAAM,SAAS,EAAE,GAAG,SAAS,gBAAgB,EAAE,KAAK,EAAC,EAAE,GAEhD,CACN,CACJ,CAAA;SACF;QAED,MAAM,cAAc,GAAG,UAAU,CAAC;YAChC,CAAC,GAAG,SAAS,gBAAgB,CAAC,EAAE,QAAQ;YACxC,CAAC,GAAG,SAAS,8BAA8B,CAAC,EAAE,YAAY,KAAK,UAAU;YACzE,CAAC,GAAG,SAAS,gBAAgB,CAAC,EAAE,CAAC,aAAa;SAC/C,CAAC,CAAA;QAEF,OAAO,CACL,oBAAC,GAAG,oBAAK,cAAc,IAAE,SAAS,EAAE,iBAAiB;YACnD,+BACE,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAE5C,aAAa,CACR,CACJ,CACP,CAAA;IACH,CAAC,CACoB,CACxB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,aAAa,CAAA","sourcesContent":["import Icon from '../icon'\nimport classNames from 'classnames'\nimport * as React from 'react'\nimport type { ColProps } from '../grid-v4/col'\nimport Col from '../grid-v4/col'\n// import { useLocaleReceiver } from '../locale-provider/LocaleReceiver';\n// import defaultLocale from '../locale/default';\nimport type { TooltipProps } from '../tooltip'\nimport Tooltip from '../tooltip'\nimport type { FormContextProps } from './context'\nimport { FormContext } from './context'\nimport type { RequiredMark } from './Form'\nimport type { FormLabelAlign } from './interface'\n\nimport { doUpperTitle } from '../utils'\n\nexport type WrapperTooltipProps = TooltipProps & {\n icon?: React.ReactElement\n}\n\nexport type LabelTooltipType = WrapperTooltipProps | React.ReactNode\n\nfunction toTooltipProps(tooltip: LabelTooltipType): WrapperTooltipProps | null {\n if (!tooltip) {\n return null\n }\n\n if (typeof tooltip === 'object' && !React.isValidElement(tooltip)) {\n return tooltip as WrapperTooltipProps\n }\n\n return {\n title: tooltip,\n }\n}\n\nexport interface FormItemLabelProps {\n colon?: boolean\n htmlFor?: string\n label?: React.ReactNode\n labelAlign?: FormLabelAlign\n labelCol?: ColProps\n requiredMark?: RequiredMark\n tooltip?: LabelTooltipType\n}\n\nconst FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixCls: string }> = ({\n prefixCls,\n label,\n htmlFor,\n labelCol,\n labelAlign,\n colon,\n required,\n requiredMark,\n tooltip,\n}) => {\n // const [formLocale] = useLocaleReceiver('Form');\n\n if (!label) return null\n label = doUpperTitle(label)\n\n return (\n <FormContext.Consumer key=\"label\">\n {({\n vertical,\n labelAlign: contextLabelAlign,\n labelCol: contextLabelCol,\n labelWrap,\n colon: contextColon,\n }: FormContextProps) => {\n const mergedLabelCol: ColProps = labelCol || contextLabelCol || {}\n\n const mergedLabelAlign: FormLabelAlign | undefined = labelAlign || contextLabelAlign\n\n const labelClsBasic = `${prefixCls}-item-label`\n const labelColClassName = classNames(\n labelClsBasic,\n mergedLabelAlign === 'left' && `${labelClsBasic}-left`,\n mergedLabelCol.className,\n {\n [`${labelClsBasic}-wrap`]: !!labelWrap,\n }\n )\n\n let labelChildren = label\n // Keep label is original where there should have no colon\n const computedColon = colon === true || (contextColon !== false && colon !== false)\n const haveColon = computedColon && !vertical\n // Remove duplicated user input colon\n if (haveColon && typeof label === 'string' && (label as string).trim() !== '') {\n labelChildren = (label as string).replace(/[:|:]\\s*$/, '')\n }\n\n // Tooltip\n const tooltipProps = toTooltipProps(tooltip)\n if (tooltipProps) {\n const { icon = <Icon type=\"question-circle\" />, ...restTooltipProps } = tooltipProps\n const tooltipNode = (\n <Tooltip {...restTooltipProps}>\n {React.cloneElement(icon, { className: `${prefixCls}-item-tooltip`, title: '' })}\n </Tooltip>\n )\n\n labelChildren = (\n <>\n {labelChildren}\n {tooltipNode}\n </>\n )\n }\n\n // Add required mark if optional\n if (requiredMark === 'optional' && !required) {\n labelChildren = (\n <>\n {labelChildren}\n <span className={`${prefixCls}-item-optional`} title=\"\">\n {/* {formLocale?.optional || defaultLocale.Form?.optional} */}\n </span>\n </>\n )\n }\n\n const labelClassName = classNames({\n [`${prefixCls}-item-required`]: required,\n [`${prefixCls}-item-required-mark-optional`]: requiredMark === 'optional',\n [`${prefixCls}-item-no-colon`]: !computedColon,\n })\n\n return (\n <Col {...mergedLabelCol} className={labelColClassName}>\n <label\n htmlFor={htmlFor}\n className={labelClassName}\n title={typeof label === 'string' ? label : ''}\n >\n {labelChildren}\n </label>\n </Col>\n )\n }}\n </FormContext.Consumer>\n )\n}\n\nexport default FormItemLabel\n"]}
@@ -8,6 +8,7 @@ interface CustomDrawerProps extends AntdDrawerProps {
8
8
  onClose?: () => void;
9
9
  onSubmit?: () => void;
10
10
  onCancel?: () => void;
11
+ afterClose?: () => void;
11
12
  onOk?: () => void;
12
13
  okText?: string;
13
14
  cancelText?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../src/drawer/drawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,KAAK,EAAE,EAAE,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C,EAAE,KAAK,CAAC,SAAS,CAAA;IACxB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,IAAI,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,UAAU,CAAC,EAAE,aAAa,CAAA;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,eAAe,CAAA;IAC/B,iBAAiB,CAAC,EAAE,eAAe,CAAA;IACnC,mBAAmB,EAAE,OAAO,CAAA;IAC5B,eAAe,CAAC,EAAE,EAAE,CAAA;IACpB,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAED,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAqHxC,CAAA"}
@@ -54,6 +54,7 @@ var Drawer = exports.Drawer = function Drawer(_a) {
54
54
  footer = _a.footer,
55
55
  showFooter = _a.showFooter,
56
56
  onClose = _a.onClose,
57
+ afterClose = _a.afterClose,
57
58
  onSubmit = _a.onSubmit,
58
59
  onCancel = _a.onCancel,
59
60
  onOk = _a.onOk,
@@ -77,9 +78,18 @@ var Drawer = exports.Drawer = function Drawer(_a) {
77
78
  upperCaseIgnore = _a.upperCaseIgnore,
78
79
  unUpperConverted = _a.unUpperConverted,
79
80
  title = _a.title,
80
- rest = __rest(_a, ["closable", "className", "footer", "showFooter", "onClose", "onSubmit", "onCancel", "onOk", "okText", "cancelText", "locale", "okType", "cancelType", "confirmLoading", "okButtonProps", "cancelButtonProps", "clickOnBlankToClose", "upperCaseIgnore", "unUpperConverted", "title"]);
81
+ rest = __rest(_a, ["closable", "className", "footer", "showFooter", "onClose", "afterClose", "onSubmit", "onCancel", "onOk", "okText", "cancelText", "locale", "okType", "cancelType", "confirmLoading", "okButtonProps", "cancelButtonProps", "clickOnBlankToClose", "upperCaseIgnore", "unUpperConverted", "title"]);
81
82
  var drawerDom = _react["default"].useRef(null);
82
- var _onCancel = onCancel || onClose;
83
+ var _onCancel = (0, _react.useCallback)(function () {
84
+ if (onCancel) {
85
+ onCancel();
86
+ } else if (onClose) {
87
+ onClose();
88
+ }
89
+ if (afterClose) {
90
+ afterClose();
91
+ }
92
+ }, [onCancel, onClose, afterClose]);
83
93
  var _onOk = onOk || onSubmit;
84
94
  (0, _react.useEffect)(function () {
85
95
  if (clickOnBlankToClose) {
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../src/drawer/drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAAwD;AAExD,4DAAsD;AACtD,4FAAmE;AACnE,4DAAmC;AAGnC,oCAAuC;AACvC,+CAAoD;AACpD,sCAAkC;AAClC,mDAA0B;AAC1B,MAAM,aAAa,GAAG,CAAC,EACrB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,EACN,UAAU,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,UAAU,GAeX,EAAE,EAAE;IACH,OAAO,CACL;QACE,8BAAC,eAAM,kBAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,IAAI,SAAS,IAAM,iBAAiB,GAC5E,UAAU,KAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,CAC1B;QACT,8BAAC,eAAM,kBAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,IAAI,SA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K,KAAK,IAAI,CACrB,8BAAC,cAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,GAAG,SAAS,QAAQ,EAAE,OAAO,EAAE,SAAS,GAAI,CAC3E;wBACA,IAAI,CAAC,QAAQ;wBACb,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CACzB,uCAAK,SAAS,EAAE,GAAG,SAAS,eAAe,IACxC,MAAM,IAAI,CACT,8BAAC,aAAa,IACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,GACnB,CACH,CACG,CACP,CACA,CACQ,CACT,CACP,CAAA;QACH,CAAC,CACc,CAClB,CAAA;IACH,CAAC,CACc,CAClB,CAAA;AACH,CAAC,CAAA;AA3GY,QAAA,MAAM,UA2GlB","sourcesContent":["import { ConfigConsumer } from 'antd/lib/config-provider'\nimport type { DrawerProps as AntdDrawerProps } from 'antd/lib/drawer'\nimport { default as AntdDrawer } from 'antd/lib/drawer'\nimport LocaleReceiver from 'antd/lib/locale-provider/LocaleReceiver'\nimport classNames from 'classnames'\nimport type { BaseButtonProps } from 'antd/lib/button/button'\nimport type { TntButtonType } from '../button/button'\nimport { doUpperTitle } from '../utils'\nimport React, { FC, useEffect, useRef } from 'react'\nimport { Button } from '../button'\nimport Icon from '../icon'\nconst DefaultFooter = ({\n locale,\n onCancel,\n onOk,\n okText,\n okType,\n cancelText,\n confirmLoading,\n okButtonProps,\n cancelButtonProps,\n cancelType,\n}: {\n locale?: {\n okText?: string\n cancelText?: string\n }\n onCancel?: () => void\n onOk?: () => void\n okText: string\n cancelText: string\n okType?: TntButtonType\n cancelType: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n}) => {\n return (\n <>\n <Button onClick={onCancel} type={cancelType || 'default'} {...cancelButtonProps}>\n {cancelText || locale?.cancelText}\n </Button>\n <Button onClick={onOk} type={okType || 'primary'} loading={confirmLoading} {...okButtonProps}>\n {okText || locale?.okText}\n </Button>\n </>\n )\n}\n\ninterface CustomDrawerProps extends AntdDrawerProps {\n footer?: React.ReactNode\n showFooter?: boolean\n onClose?: () => void\n onSubmit?: () => void\n onCancel?: () => void\n onOk?: () => void\n okText?: string\n cancelText?: string\n locale?: {\n okText?: string\n cancelText?: string\n }\n okType?: TntButtonType\n cancelType?: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n clickOnBlankToClose: boolean\n upperCaseIgnore?: []\n unUpperConverted: boolean\n}\n\nexport const Drawer: FC<CustomDrawerProps> = ({\n closable = true,\n className,\n footer,\n showFooter,\n onClose,\n onSubmit,\n onCancel,\n onOk,\n okText = '',\n cancelText = '',\n locale,\n okType = 'primary',\n cancelType = 'default',\n confirmLoading = false,\n okButtonProps = {},\n cancelButtonProps = {},\n clickOnBlankToClose = false,\n upperCaseIgnore,\n unUpperConverted,\n title,\n ...rest\n}) => {\n const drawerDom = React.useRef<EventTarget | null>(null)\n const _onCancel = onCancel || onClose\n const _onOk = onOk || onSubmit\n\n useEffect(() => {\n if (clickOnBlankToClose) {\n const handleOutsideClick = (event: Event) => {\n const drawer = drawerDom.current as Node\n const targetElement = event.target as Node\n\n let isInDrawer = false\n if (drawer && targetElement) {\n isInDrawer = drawer.contains(targetElement as Node) || targetElement === drawer\n }\n drawerDom.current = null\n if (rest.visible && !isInDrawer && _onCancel) {\n _onCancel()\n }\n }\n document.removeEventListener('click', handleOutsideClick)\n document.addEventListener('click', handleOutsideClick)\n return () => {\n document.removeEventListener('click', handleOutsideClick)\n }\n }\n }, [rest.visible, clickOnBlankToClose, _onCancel])\n\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('drawer')\n return (\n <LocaleReceiver componentName=\"Drawer\" defaultLocale={locale}>\n {(locale) => {\n return (\n <div\n onClick={(event: React.MouseEvent<HTMLDivElement>) => {\n drawerDom.current = event.target\n }}\n >\n <AntdDrawer\n className={classNames(prefixCls, 'tnt-drawer', className, {\n [`${prefixCls}-contain-closable`]: closable !== false,\n [`${prefixCls}-footer`]: showFooter || footer,\n })}\n closable={false}\n onClose={_onCancel}\n width={480}\n {...rest}\n title={!unUpperConverted ? doUpperTitle(title, upperCaseIgnore) : title}\n >\n <>\n {closable !== false && (\n <Icon type=\"close\" className={`${prefixCls}-close`} onClick={_onCancel} />\n )}\n {rest.children}\n {(showFooter || footer) && (\n <div className={`${prefixCls}-footer-style`}>\n {footer || (\n <DefaultFooter\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n cancelButtonProps={cancelButtonProps}\n okType={okType}\n locale={locale}\n okText={okText}\n cancelType={cancelType}\n cancelText={cancelText}\n onOk={_onOk}\n onCancel={_onCancel}\n />\n )}\n </div>\n )}\n </>\n </AntdDrawer>\n </div>\n )\n }}\n </LocaleReceiver>\n )\n }}\n </ConfigConsumer>\n )\n}\n"]}
1
+ {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../src/drawer/drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAAwD;AAExD,4DAAsD;AACtD,4FAAmE;AACnE,4DAAmC;AAGnC,oCAAuC;AACvC,+CAAiE;AACjE,sCAAkC;AAClC,mDAA0B;AAC1B,MAAM,aAAa,GAAG,CAAC,EACrB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,EACN,UAAU,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,UAAU,GAeX,EAAE,EAAE;IACH,OAAO,CACL;QACE,8BAAC,eAAM,kBAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,U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SAAS,EAAE,IAAA,oBAAU,EAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;wBACxD,CAAC,GAAG,SAAS,mBAAmB,CAAC,EAAE,QAAQ,KAAK,KAAK;wBACrD,CAAC,GAAG,SAAS,SAAS,CAAC,EAAE,UAAU,IAAI,MAAM;qBAC9C,CAAC,EACF,QAAQ,EAAE,KAAK,EACf,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,GAAG,IACN,IAAI,IACR,KAAK,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAA,oBAAY,EAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK;oBAEvE;wBACG,QAAQ,KAAK,KAAK,IAAI,CACrB,8BAAC,cAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,GAAG,SAAS,QAAQ,EAAE,OAAO,EAAE,SAAS,GAAI,CAC3E;wBACA,IAAI,CAAC,QAAQ;wBACb,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CACzB,uCAAK,SAAS,EAAE,GAAG,SAAS,eAAe,IACxC,MAAM,IAAI,CACT,8BAAC,aAAa,IACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,GACnB,CACH,CACG,CACP,CACA,CACQ,CACT,CACP,CAAA;QACH,CAAC,CACc,CAClB,CAAA;IACH,CAAC,CACc,CAClB,CAAA;AACH,CAAC,CAAA;AArHY,QAAA,MAAM,UAqHlB","sourcesContent":["import { ConfigConsumer } from 'antd/lib/config-provider'\nimport type { DrawerProps as AntdDrawerProps } from 'antd/lib/drawer'\nimport { default as AntdDrawer } from 'antd/lib/drawer'\nimport LocaleReceiver from 'antd/lib/locale-provider/LocaleReceiver'\nimport classNames from 'classnames'\nimport type { BaseButtonProps } from 'antd/lib/button/button'\nimport type { TntButtonType } from '../button/button'\nimport { doUpperTitle } from '../utils'\nimport React, { FC, useCallback, useEffect, useRef } from 'react'\nimport { Button } from '../button'\nimport Icon from '../icon'\nconst DefaultFooter = ({\n locale,\n onCancel,\n onOk,\n okText,\n okType,\n cancelText,\n confirmLoading,\n okButtonProps,\n cancelButtonProps,\n cancelType,\n}: {\n locale?: {\n okText?: string\n cancelText?: string\n }\n onCancel?: () => void\n onOk?: () => void\n okText: string\n cancelText: string\n okType?: TntButtonType\n cancelType: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n}) => {\n return (\n <>\n <Button onClick={onCancel} type={cancelType || 'default'} {...cancelButtonProps}>\n {cancelText || locale?.cancelText}\n </Button>\n <Button onClick={onOk} type={okType || 'primary'} loading={confirmLoading} {...okButtonProps}>\n {okText || locale?.okText}\n </Button>\n </>\n )\n}\n\ninterface CustomDrawerProps extends AntdDrawerProps {\n footer?: React.ReactNode\n showFooter?: boolean\n onClose?: () => void\n onSubmit?: () => void\n onCancel?: () => void\n afterClose?: () => void\n onOk?: () => void\n okText?: string\n cancelText?: string\n locale?: {\n okText?: string\n cancelText?: string\n }\n okType?: TntButtonType\n cancelType?: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n clickOnBlankToClose: boolean\n upperCaseIgnore?: []\n unUpperConverted: boolean\n}\n\nexport const Drawer: FC<CustomDrawerProps> = ({\n closable = true,\n className,\n footer,\n showFooter,\n onClose,\n afterClose,\n onSubmit,\n onCancel,\n onOk,\n okText = '',\n cancelText = '',\n locale,\n okType = 'primary',\n cancelType = 'default',\n confirmLoading = false,\n okButtonProps = {},\n cancelButtonProps = {},\n clickOnBlankToClose = false,\n upperCaseIgnore,\n unUpperConverted,\n title,\n ...rest\n}) => {\n const drawerDom = React.useRef<EventTarget | null>(null)\n const _onCancel = useCallback(() => {\n if (onCancel) {\n onCancel()\n } else if (onClose) {\n onClose()\n }\n if (afterClose) {\n afterClose()\n }\n }, [onCancel, onClose, afterClose])\n const _onOk = onOk || onSubmit\n\n useEffect(() => {\n if (clickOnBlankToClose) {\n const handleOutsideClick = (event: Event) => {\n const drawer = drawerDom.current as Node\n const targetElement = event.target as Node\n\n let isInDrawer = false\n if (drawer && targetElement) {\n isInDrawer = drawer.contains(targetElement as Node) || targetElement === drawer\n }\n drawerDom.current = null\n if (rest.visible && !isInDrawer && _onCancel) {\n _onCancel()\n }\n }\n document.removeEventListener('click', handleOutsideClick)\n document.addEventListener('click', handleOutsideClick)\n return () => {\n document.removeEventListener('click', handleOutsideClick)\n }\n }\n }, [rest.visible, clickOnBlankToClose, _onCancel])\n\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('drawer')\n return (\n <LocaleReceiver componentName=\"Drawer\" defaultLocale={locale}>\n {(locale) => {\n return (\n <div\n onClick={(event: React.MouseEvent<HTMLDivElement>) => {\n drawerDom.current = event.target\n }}\n >\n <AntdDrawer\n className={classNames(prefixCls, 'tnt-drawer', className, {\n [`${prefixCls}-contain-closable`]: closable !== false,\n [`${prefixCls}-footer`]: showFooter || footer,\n })}\n closable={false}\n onClose={_onCancel}\n width={480}\n {...rest}\n title={!unUpperConverted ? doUpperTitle(title, upperCaseIgnore) : title}\n >\n <>\n {closable !== false && (\n <Icon type=\"close\" className={`${prefixCls}-close`} onClick={_onCancel} />\n )}\n {rest.children}\n {(showFooter || footer) && (\n <div className={`${prefixCls}-footer-style`}>\n {footer || (\n <DefaultFooter\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n cancelButtonProps={cancelButtonProps}\n okType={okType}\n locale={locale}\n okText={okText}\n cancelType={cancelType}\n cancelText={cancelText}\n onOk={_onOk}\n onCancel={_onCancel}\n />\n )}\n </div>\n )}\n </>\n </AntdDrawer>\n </div>\n )\n }}\n </LocaleReceiver>\n )\n }}\n </ConfigConsumer>\n )\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-expand-fixed.d.ts","sourceRoot":"","sources":["../../../src/table/hooks/use-expand-fixed.ts"],"names":[],"mappings":"AAGA,oBAAY,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAQ5C,eAAO,MAAM,cAAc,iCA6FqB,MAAM,KAAK,IAAI,CAC9D,CAAA;AAED,eAAO,MAAM,UAAU,WACb,GAAG,6BACgB,GAAG,SAAS,MAAM,KAAK,MAAM,qBAUzD,CAAA"}
1
+ {"version":3,"file":"use-expand-fixed.d.ts","sourceRoot":"","sources":["../../../src/table/hooks/use-expand-fixed.ts"],"names":[],"mappings":"AAGA,oBAAY,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAQ5C,eAAO,MAAM,cAAc,iCA+FqB,MAAM,KAAK,IAAI,CAC9D,CAAA;AAED,eAAO,MAAM,UAAU,WACb,GAAG,6BACgB,GAAG,SAAS,MAAM,KAAK,MAAM,qBAUzD,CAAA"}
@@ -77,10 +77,12 @@ var useExpandFixed = exports.useExpandFixed = function useExpandFixed() {
77
77
  if (!classname) return;
78
78
  container.current = document.querySelector(".".concat(classname, ".ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table"));
79
79
  observer.current = new MutationObserver(expand);
80
- observer.current.observe(container.current, {
81
- childList: true,
82
- attributes: true
83
- });
80
+ if (container.current) {
81
+ observer.current.observe(container.current, {
82
+ childList: true,
83
+ attributes: true
84
+ });
85
+ }
84
86
  };
85
87
  var setChangedKey = function setChangedKey(key) {
86
88
  activeKeyRef.current = key;
@@ -1 +1 @@
1
- {"version":3,"file":"use-expand-fixed.js","sourceRoot":"","sources":["../../../src/table/hooks/use-expand-fixed.ts"],"names":[],"mappings":";;;AAAA,iCAAyC;AACzC,oCAAyC;AAUlC,MAAM,cAAc,GAAG,GAAG,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ils'\n\nexport type keyType = string | number | null\n\ninterface OldDom {\n main: HTMLDivElement | null\n right: HTMLDivElement | null\n left: HTMLDivElement | null\n}\n\nexport const useExpandFixed = () => {\n const curTableKey = useRef<keyType>(makeRandomCode())\n const activeKeyRef = useRef<string | null>(null)\n const oldActiveKeyRef = useRef<OldDom>({\n main: null,\n right: null,\n left: null,\n })\n const container = useRef<HTMLDivElement | null>(null)\n const observer = useRef<MutationObserver | null>(null)\n\n const getDom = (key: string | number | undefined) => {\n const main =\n (document.querySelector(\n `.${curTableKey.current} .ant-table-scroll [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement) ||\n (document.querySelector(\n `.${curTableKey.current} .ant-table-default [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement)\n const right = document.querySelector(\n `.${curTableKey.current} .ant-table-fixed-right [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement\n const left = document.querySelector(\n `.${curTableKey.current} .ant-table-fixed-left [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement\n return [main, right, left]\n }\n\n const expand = async () => {\n const [main, right, left] = getDom(String(activeKeyRef.current) || '')\n const border = 2\n const height = main?.offsetHeight - border || 0\n if (right) {\n right.setAttribute('style', `display: inline-block; height: ${height}px; overflow: hidden;`)\n }\n\n if (left) {\n left.setAttribute('style', `display: inline-block; height: ${height}px; overflow: hidden;`)\n }\n\n if (main) {\n // 解决 expandIconAsCell为true 且 iconCell的td元素为display: none;时, 展开内容滚动到最右边,会多出一部分iconCell所占据的空间 的问题\n const td = main.childNodes[1] as HTMLDivElement\n\n const colspan = td.getAttribute('colspan') || 0\n const Oldcolspan = td.getAttribute('oldcolspan') || 0\n const newColspan = Oldcolspan ? Oldcolspan : Number(colspan) + 1 + ''\n if (!Oldcolspan) td.setAttribute('oldcolspan', newColspan)\n\n td.setAttribute('colspan', newColspan)\n //\n }\n\n oldActiveKeyRef.current = {\n main,\n right,\n left,\n }\n }\n\n const ob = () => {\n const classname = curTableKey.current\n if (!classname) return\n\n container.current = document.querySelector(\n `.${classname}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`\n ) as HTMLDivElement\n\n observer.current = new MutationObserver(expand)\n observer.current.observe(container.current, {\n childList: true, // 子节点的变动\n attributes: true,\n })\n }\n\n const setChangedKey = (key: string) => {\n activeKeyRef.current = key\n }\n\n const trigger = (key: string) => {\n setChangedKey(key)\n const className = curTableKey.current\n if (!className) return\n const dom = document?.querySelector(\n `.${className}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`\n )\n dom?.setAttribute('c-data', 'Mutation')\n }\n\n useEffect(() => {\n ob()\n }, [curTableKey.current])\n\n return [curTableKey.current, trigger as (key: string) => void] as const\n}\n\nexport const findRowKey = (\n record: any,\n rowKey: string | ((record: any, index: number) => string)\n) => {\n let res: string | number = ''\n if (typeof rowKey === 'function') {\n res = [record].map(rowKey)[0]\n } else if (typeof rowKey === 'string') {\n res = record[rowKey]\n }\n\n return res\n}\n"]}
1
+ {"version":3,"file":"use-expand-fixed.js","sourceRoot":"","sources":["../../../src/table/hooks/use-expand-fixed.ts"],"names":[],"mappings":";;;AAAA,iCAAyC;AACzC,oCAAyC;AAUlC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,WAAW,GAAG,IAAA,cAAM,EAAU,IAAA,sBAAc,GAAE,CAAC,CAAA;IACrD,MAAM,YAAY,GAAG,IAAA,cAAM,EAAgB,IAAI,CAAC,CAAA;IAChD,MAAM,eAAe,GAAG,IAAA,cAAM,EAAS;QACrC,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,IAAI;KACX,CAAC,CAAA;IACF,MAAM,SAAS,GAAG,IAAA,cAAM,EAAwB,IAAI,CAAC,CAAA;IACrD,MAAM,QAAQ,GAAG,IAAA,cAAM,EAA0B,IAAI,CAAC,CAAA;IAEtD,MAAM,MAAM,GAAG,CAAC,GAAgC,EAAE,EAA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,CAAE,aAAa,CACjC,IAAI,SAAS,iGAAiG,CAC/G,CAAA;QACD,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACzC,CAAC,CAAA;IAED,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,EAAE,EAAE,CAAA;IACN,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;IAEzB,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,OAAgC,CAAU,CAAA;AACzE,CAAC,CAAA;AAhGY,QAAA,cAAc,kBAgG1B;AAEM,MAAM,UAAU,GAAG,CACxB,MAAW,EACX,MAAyD,EACzD,EAAE;IACF,IAAI,GAAG,GAAoB,EAAE,CAAA;IAC7B,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;QAChC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;KAC9B;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QACrC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;KACrB;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAZY,QAAA,UAAU,cAYtB","sourcesContent":["import { useEffect, useRef } from 'react'\nimport { makeRandomCode } from '../utils'\n\nexport type keyType = string | number | null\n\ninterface OldDom {\n main: HTMLDivElement | null\n right: HTMLDivElement | null\n left: HTMLDivElement | null\n}\n\nexport const useExpandFixed = () => {\n const curTableKey = useRef<keyType>(makeRandomCode())\n const activeKeyRef = useRef<string | null>(null)\n const oldActiveKeyRef = useRef<OldDom>({\n main: null,\n right: null,\n left: null,\n })\n const container = useRef<HTMLDivElement | null>(null)\n const observer = useRef<MutationObserver | null>(null)\n\n const getDom = (key: string | number | undefined) => {\n const main =\n (document.querySelector(\n `.${curTableKey.current} .ant-table-scroll [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement) ||\n (document.querySelector(\n `.${curTableKey.current} .ant-table-default [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement)\n const right = document.querySelector(\n `.${curTableKey.current} .ant-table-fixed-right [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement\n const left = document.querySelector(\n `.${curTableKey.current} .ant-table-fixed-left [data-row-key=\"${key}-extra-row\"]`\n ) as HTMLDivElement\n return [main, right, left]\n }\n\n const expand = async () => {\n const [main, right, left] = getDom(String(activeKeyRef.current) || '')\n const border = 2\n const height = main?.offsetHeight - border || 0\n if (right) {\n right.setAttribute('style', `display: inline-block; height: ${height}px; overflow: hidden;`)\n }\n\n if (left) {\n left.setAttribute('style', `display: inline-block; height: ${height}px; overflow: hidden;`)\n }\n\n if (main) {\n // 解决 expandIconAsCell为true 且 iconCell的td元素为display: none;时, 展开内容滚动到最右边,会多出一部分iconCell所占据的空间 的问题\n const td = main.childNodes[1] as HTMLDivElement\n\n const colspan = td.getAttribute('colspan') || 0\n const Oldcolspan = td.getAttribute('oldcolspan') || 0\n const newColspan = Oldcolspan ? Oldcolspan : Number(colspan) + 1 + ''\n if (!Oldcolspan) td.setAttribute('oldcolspan', newColspan)\n\n td.setAttribute('colspan', newColspan)\n //\n }\n\n oldActiveKeyRef.current = {\n main,\n right,\n left,\n }\n }\n\n const ob = () => {\n const classname = curTableKey.current\n if (!classname) return\n\n container.current = document.querySelector(\n `.${classname}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`\n ) as HTMLDivElement\n\n observer.current = new MutationObserver(expand)\n if(container.current) {\n observer.current.observe(container.current, {\n childList: true, // 子节点的变动\n attributes: true,\n })\n }\n }\n\n const setChangedKey = (key: string) => {\n activeKeyRef.current = key\n }\n\n const trigger = (key: string) => {\n setChangedKey(key)\n const className = curTableKey.current\n if (!className) return\n const dom = document?.querySelector(\n `.${className}.ant-table-wrapper.collapse-panel > .ant-spin-nested-loading > .ant-spin-container > .ant-table`\n )\n dom?.setAttribute('c-data', 'Mutation')\n }\n\n useEffect(() => {\n ob()\n }, [curTableKey.current])\n\n return [curTableKey.current, trigger as (key: string) => void] as const\n}\n\nexport const findRowKey = (\n record: any,\n rowKey: string | ((record: any, index: number) => string)\n) => {\n let res: string | number = ''\n if (typeof rowKey === 'function') {\n res = [record].map(rowKey)[0]\n } else if (typeof rowKey === 'string') {\n res = record[rowKey]\n }\n\n return res\n}\n"]}
@@ -1886,6 +1886,16 @@
1886
1886
  .tntd-select:not(.tntd-select-customize-input) .tntd-select-selector input {
1887
1887
  cursor: pointer
1888
1888
  }
1889
+ // compact的样式 start
1890
+ .ant-input-group.ant-input-group-compact>.tntd-select>.tntd-select-selector{
1891
+ border-radius: 0;
1892
+ }
1893
+ .ant-input-group.ant-input-group-compact>*:last-child,
1894
+ .ant-input-group.ant-input-group-compact>.tntd-select:last-child>.tntd-select-selector{
1895
+ border-top-right-radius: @border-radius-base;
1896
+ border-bottom-right-radius: @border-radius-base;
1897
+ }
1898
+ // compact的样式 end
1889
1899
 
1890
1900
  .tntd-select-show-search.tntd-select:not(.tntd-select-customize-input) .tntd-select-selector {
1891
1901
  cursor: text
@@ -1 +1 @@
1
- {"version":3,"file":"FormItemLabel.d.ts","sourceRoot":"","sources":["../../src/tntd-form/FormItemLabel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAI9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,oBAAY,mBAAmB,GAAG,YAAY,GAAG;IAC/C,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAA;CAC1B,CAAA;AAED,oBAAY,gBAAgB,GAAG,mBAAmB,GAAG,KAAK,CAAC,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AE,QAAQ,CAAA;IACnB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAkG3F,CAAA;AAED,eAAe,aAAa,CAAA"}
@@ -10,6 +10,7 @@ var React = _interopRequireWildcard(require("react"));
10
10
  var _col = _interopRequireDefault(require("../grid-v4/col"));
11
11
  var _tooltip = _interopRequireDefault(require("../tooltip"));
12
12
  var _context = require("./context");
13
+ var _utils = require("../utils");
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -48,6 +49,7 @@ var FormItemLabel = function FormItemLabel(_ref) {
48
49
  tooltip = _ref.tooltip;
49
50
  // const [formLocale] = useLocaleReceiver('Form');
50
51
  if (!label) return null;
52
+ label = (0, _utils.doUpperTitle)(label);
51
53
  return React.createElement(_context.FormContext.Consumer, {
52
54
  key: "label"
53
55
  }, function (_ref2) {
@@ -1 +1 @@
1
- {"version":3,"file":"FormItemLabel.js","sourceRoot":"","sources":["../../src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AC,EAAE,YAAY,KAAK,UAAU;YACzE,CAAC,GAAG,SAAS,gBAAgB,CAAC,EAAE,CAAC,aAAa;SAC/C,CAAC,CAAA;QAEF,OAAO,CACL,oBAAC,aAAG,oBAAK,cAAc,IAAE,SAAS,EAAE,iBAAiB;YACnD,+BACE,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAE5C,aAAa,CACR,CACJ,CACP,CAAA;IACH,CAAC,CACoB,CACxB,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,aAAa,CAAA","sourcesContent":["import Icon from '../icon'\nimport classNames from 'classnames'\nimport * as React from 'react'\nimport type { ColProps } from '../grid-v4/col'\nimport Col from '../grid-v4/col'\n// import { useLocaleReceiver } from '../locale-provider/LocaleReceiver';\n// import defaultLocale from '../locale/default';\nimport type { TooltipProps } from '../tooltip'\nimport Tooltip from '../tooltip'\nimport type { FormContextProps } from './context'\nimport { FormContext } from './context'\nimport type { RequiredMark } from './Form'\nimport type { FormLabelAlign } from './interface'\n\nexport type WrapperTooltipProps = TooltipProps & {\n icon?: React.ReactElement\n}\n\nexport type LabelTooltipType = WrapperTooltipProps | React.ReactNode\n\nfunction toTooltipProps(tooltip: LabelTooltipType): WrapperTooltipProps | null {\n if (!tooltip) {\n return null\n }\n\n if (typeof tooltip === 'object' && !React.isValidElement(tooltip)) {\n return tooltip as WrapperTooltipProps\n }\n\n return {\n title: tooltip,\n }\n}\n\nexport interface FormItemLabelProps {\n colon?: boolean\n htmlFor?: string\n label?: React.ReactNode\n labelAlign?: FormLabelAlign\n labelCol?: ColProps\n requiredMark?: RequiredMark\n tooltip?: LabelTooltipType\n}\n\nconst FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixCls: string }> = ({\n prefixCls,\n label,\n htmlFor,\n labelCol,\n labelAlign,\n colon,\n required,\n requiredMark,\n tooltip,\n}) => {\n // const [formLocale] = useLocaleReceiver('Form');\n\n if (!label) return null\n\n return (\n <FormContext.Consumer key=\"label\">\n {({\n vertical,\n labelAlign: contextLabelAlign,\n labelCol: contextLabelCol,\n labelWrap,\n colon: contextColon,\n }: FormContextProps) => {\n const mergedLabelCol: ColProps = labelCol || contextLabelCol || {}\n\n const mergedLabelAlign: FormLabelAlign | undefined = labelAlign || contextLabelAlign\n\n const labelClsBasic = `${prefixCls}-item-label`\n const labelColClassName = classNames(\n labelClsBasic,\n mergedLabelAlign === 'left' && `${labelClsBasic}-left`,\n mergedLabelCol.className,\n {\n [`${labelClsBasic}-wrap`]: !!labelWrap,\n }\n )\n\n let labelChildren = label\n // Keep label is original where there should have no colon\n const computedColon = colon === true || (contextColon !== false && colon !== false)\n const haveColon = computedColon && !vertical\n // Remove duplicated user input colon\n if (haveColon && typeof label === 'string' && (label as string).trim() !== '') {\n labelChildren = (label as string).replace(/[:|:]\\s*$/, '')\n }\n\n // Tooltip\n const tooltipProps = toTooltipProps(tooltip)\n if (tooltipProps) {\n const { icon = <Icon type=\"question-circle\" />, ...restTooltipProps } = tooltipProps\n const tooltipNode = (\n <Tooltip {...restTooltipProps}>\n {React.cloneElement(icon, { className: `${prefixCls}-item-tooltip`, title: '' })}\n </Tooltip>\n )\n\n labelChildren = (\n <>\n {labelChildren}\n {tooltipNode}\n </>\n )\n }\n\n // Add required mark if optional\n if (requiredMark === 'optional' && !required) {\n labelChildren = (\n <>\n {labelChildren}\n <span className={`${prefixCls}-item-optional`} title=\"\">\n {/* {formLocale?.optional || defaultLocale.Form?.optional} */}\n </span>\n </>\n )\n }\n\n const labelClassName = classNames({\n [`${prefixCls}-item-required`]: required,\n [`${prefixCls}-item-required-mark-optional`]: requiredMark === 'optional',\n [`${prefixCls}-item-no-colon`]: !computedColon,\n })\n\n return (\n <Col {...mergedLabelCol} className={labelColClassName}>\n <label\n htmlFor={htmlFor}\n className={labelClassName}\n title={typeof label === 'string' ? label : ''}\n >\n {labelChildren}\n </label>\n </Col>\n )\n }}\n </FormContext.Consumer>\n )\n}\n\nexport default FormItemLabel\n"]}
1
+ {"version":3,"file":"FormItemLabel.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA0B;AAC1B,4DAAmC;AACnC,6CAA8B;AAE9B,yDAAgC;AAIhC,yDAAgC;AAEhC,uCAAuC;AAIvC,oCAAuC;AAQvC,SAAS,cAAc,CAAC,OAAyB;IAC/C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;QACjE,OAAO,OAA8B,CAAA;KACtC;IAED,OAAO;QACL,KAAK,EAAE,OAAO;KACf,CAAA;AACH,CAAC;AAYD,MAAM,aAAa,GAA6E,CAAC,EAC/F,SAAS,EACT,KAAK,EACL,OAAO,EACP,QAAQ,EACR,UAAU,EACV,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,OAAO,GACR,EAAE,EAAE;IACH,kDAAkD;IAElD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,KAAK,GAAG,IAAA,oBAAY,EAAC,KAAK,CAAC,CAAA;IAE3B,OAAO,CACL,oBAAC,qBAAW,CAAC,QAAQ,IAAC,GAAG,EAAC,OAAO,IAC9B,CAAC,EACA,QAAQ,EACR,UAAU,EAAE,iBAAiB,EAC7B,QAAQ,EAAE,eAAe,EACzB,SAAS,EACT,KAAK,EAAE,YAAY,GACF,EAAE,EAAE;QACrB,MAAM,cAAc,GAAa,QAAQ,IAAI,eAAe,IAAI,EAAE,CAAA;QAElE,MAAM,gBAAgB,GAA+B,UAAU,IAAI,iBAAiB,CAAA;QAEpF,MAAM,aAAa,GAAG,GAAG,SAAS,aAAa,CAAA;QAC/C,MAAM,iB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AAS,gBAAgB,EAAE,KAAK,EAAC,EAAE,GAEhD,CACN,CACJ,CAAA;SACF;QAED,MAAM,cAAc,GAAG,IAAA,oBAAU,EAAC;YAChC,CAAC,GAAG,SAAS,gBAAgB,CAAC,EAAE,QAAQ;YACxC,CAAC,GAAG,SAAS,8BAA8B,CAAC,EAAE,YAAY,KAAK,UAAU;YACzE,CAAC,GAAG,SAAS,gBAAgB,CAAC,EAAE,CAAC,aAAa;SAC/C,CAAC,CAAA;QAEF,OAAO,CACL,oBAAC,aAAG,oBAAK,cAAc,IAAE,SAAS,EAAE,iBAAiB;YACnD,+BACE,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAE5C,aAAa,CACR,CACJ,CACP,CAAA;IACH,CAAC,CACoB,CACxB,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,aAAa,CAAA","sourcesContent":["import Icon from '../icon'\nimport classNames from 'classnames'\nimport * as React from 'react'\nimport type { ColProps } from '../grid-v4/col'\nimport Col from '../grid-v4/col'\n// import { useLocaleReceiver } from '../locale-provider/LocaleReceiver';\n// import defaultLocale from '../locale/default';\nimport type { TooltipProps } from '../tooltip'\nimport Tooltip from '../tooltip'\nimport type { FormContextProps } from './context'\nimport { FormContext } from './context'\nimport type { RequiredMark } from './Form'\nimport type { FormLabelAlign } from './interface'\n\nimport { doUpperTitle } from '../utils'\n\nexport type WrapperTooltipProps = TooltipProps & {\n icon?: React.ReactElement\n}\n\nexport type LabelTooltipType = WrapperTooltipProps | React.ReactNode\n\nfunction toTooltipProps(tooltip: LabelTooltipType): WrapperTooltipProps | null {\n if (!tooltip) {\n return null\n }\n\n if (typeof tooltip === 'object' && !React.isValidElement(tooltip)) {\n return tooltip as WrapperTooltipProps\n }\n\n return {\n title: tooltip,\n }\n}\n\nexport interface FormItemLabelProps {\n colon?: boolean\n htmlFor?: string\n label?: React.ReactNode\n labelAlign?: FormLabelAlign\n labelCol?: ColProps\n requiredMark?: RequiredMark\n tooltip?: LabelTooltipType\n}\n\nconst FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixCls: string }> = ({\n prefixCls,\n label,\n htmlFor,\n labelCol,\n labelAlign,\n colon,\n required,\n requiredMark,\n tooltip,\n}) => {\n // const [formLocale] = useLocaleReceiver('Form');\n\n if (!label) return null\n label = doUpperTitle(label)\n\n return (\n <FormContext.Consumer key=\"label\">\n {({\n vertical,\n labelAlign: contextLabelAlign,\n labelCol: contextLabelCol,\n labelWrap,\n colon: contextColon,\n }: FormContextProps) => {\n const mergedLabelCol: ColProps = labelCol || contextLabelCol || {}\n\n const mergedLabelAlign: FormLabelAlign | undefined = labelAlign || contextLabelAlign\n\n const labelClsBasic = `${prefixCls}-item-label`\n const labelColClassName = classNames(\n labelClsBasic,\n mergedLabelAlign === 'left' && `${labelClsBasic}-left`,\n mergedLabelCol.className,\n {\n [`${labelClsBasic}-wrap`]: !!labelWrap,\n }\n )\n\n let labelChildren = label\n // Keep label is original where there should have no colon\n const computedColon = colon === true || (contextColon !== false && colon !== false)\n const haveColon = computedColon && !vertical\n // Remove duplicated user input colon\n if (haveColon && typeof label === 'string' && (label as string).trim() !== '') {\n labelChildren = (label as string).replace(/[:|:]\\s*$/, '')\n }\n\n // Tooltip\n const tooltipProps = toTooltipProps(tooltip)\n if (tooltipProps) {\n const { icon = <Icon type=\"question-circle\" />, ...restTooltipProps } = tooltipProps\n const tooltipNode = (\n <Tooltip {...restTooltipProps}>\n {React.cloneElement(icon, { className: `${prefixCls}-item-tooltip`, title: '' })}\n </Tooltip>\n )\n\n labelChildren = (\n <>\n {labelChildren}\n {tooltipNode}\n </>\n )\n }\n\n // Add required mark if optional\n if (requiredMark === 'optional' && !required) {\n labelChildren = (\n <>\n {labelChildren}\n <span className={`${prefixCls}-item-optional`} title=\"\">\n {/* {formLocale?.optional || defaultLocale.Form?.optional} */}\n </span>\n </>\n )\n }\n\n const labelClassName = classNames({\n [`${prefixCls}-item-required`]: required,\n [`${prefixCls}-item-required-mark-optional`]: requiredMark === 'optional',\n [`${prefixCls}-item-no-colon`]: !computedColon,\n })\n\n return (\n <Col {...mergedLabelCol} className={labelColClassName}>\n <label\n htmlFor={htmlFor}\n className={labelClassName}\n title={typeof label === 'string' ? label : ''}\n >\n {labelChildren}\n </label>\n </Col>\n )\n }}\n </FormContext.Consumer>\n )\n}\n\nexport default FormItemLabel\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tntd",
3
- "version": "3.0.0-beta.25",
3
+ "version": "3.0.0-beta.26",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "start": "heft start --storybook",
@@ -36,7 +36,7 @@
36
36
  "rc-segmented": "~2.2.2",
37
37
  "rc-field-form": "~1.34.0",
38
38
  "scroll-into-view-if-needed": "^2.2.25",
39
- "@tntd/icons": "^1.0.7",
39
+ "@tntd/icons": "^1.0.8",
40
40
  "@ant-design/colors": "^3.1.0",
41
41
  "rc-resize-observer": "~1.4.0"
42
42
  },
@@ -106,4 +106,4 @@
106
106
  "main": "lib/index.js",
107
107
  "module": "es/index.js",
108
108
  "typings": "lib/index.d.ts"
109
- }
109
+ }