@tiny-design/react 1.0.4 → 1.0.9
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/LICENSE +21 -0
- package/README.md +107 -0
- package/es/alert/style/_index.scss +0 -0
- package/es/alert/style/_mixin.scss +0 -0
- package/es/avatar/style/_index.scss +0 -0
- package/es/back-top/style/_index.scss +0 -0
- package/es/badge/style/_index.scss +0 -0
- package/es/breadcrumb/style/_index.scss +0 -0
- package/es/button/style/_index.scss +0 -0
- package/es/button/style/_mixin.scss +0 -0
- package/es/button/style/index.css +1 -1
- package/es/carousel/style/_index.scss +0 -0
- package/es/checkbox/style/_index.scss +0 -0
- package/es/collapse/style/_index.scss +0 -0
- package/es/date-picker/style/_index.scss +0 -0
- package/es/divider/style/_index.scss +0 -0
- package/es/empty/style/_index.scss +0 -0
- package/es/flip/style/_index.scss +0 -0
- package/es/form/style/_index.scss +0 -0
- package/es/grid/style/_index.scss +0 -0
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/input/style/_index.scss +0 -0
- package/es/input/style/_mixin.scss +0 -0
- package/es/input-number/style/_index.scss +0 -0
- package/es/input-password/style/_index.scss +0 -0
- package/es/layout/sidebar.js +2 -5
- package/es/layout/sidebar.js.map +1 -1
- package/es/layout/style/_index.scss +0 -0
- package/es/list/list.js.map +1 -1
- package/es/loader/style/_index.scss +0 -0
- package/es/loading-bar/style/_index.scss +0 -0
- package/es/message/style/_index.scss +0 -0
- package/es/modal/style/_index.scss +0 -0
- package/es/native-select/style/_index.scss +0 -0
- package/es/notification/style/_index.scss +0 -0
- package/es/overlay/style/_index.scss +0 -0
- package/es/pop-confirm/style/_index.scss +0 -0
- package/es/popover/style/_index.scss +0 -0
- package/es/popup/style/_index.scss +0 -0
- package/es/progress/style/_index.scss +0 -0
- package/es/radio/style/_index.scss +0 -0
- package/es/rate/rate.js +2 -5
- package/es/rate/rate.js.map +1 -1
- package/es/rate/style/_index.scss +0 -0
- package/es/split/style/_index.scss +0 -0
- package/es/style/_component.scss +1 -1
- package/es/style/base.css +12 -3
- package/es/style/index.scss +0 -0
- package/es/switch/style/_index.scss +0 -0
- package/es/switch/style/_mixin.scss +0 -0
- package/es/switch/style/index.css +3 -3
- package/es/table/table.js.map +1 -1
- package/es/tag/style/_index.scss +0 -0
- package/es/textarea/style/_index.scss +0 -0
- package/es/time-picker/style/_index.scss +0 -0
- package/es/timeline/style/_index.scss +0 -0
- package/es/tooltip/style/_index.scss +0 -0
- package/es/typography/style/_index.scss +0 -0
- package/es/with-spin/index.d.ts +1 -0
- package/es/with-spin/style/_index.scss +5 -0
- package/es/with-spin/style/index.css +3 -0
- package/es/with-spin/with-spin.d.ts +9 -0
- package/es/with-spin/with-spin.js +20 -0
- package/es/with-spin/with-spin.js.map +1 -0
- package/lib/alert/style/_index.scss +0 -0
- package/lib/alert/style/_mixin.scss +0 -0
- package/lib/avatar/style/_index.scss +0 -0
- package/lib/back-top/style/_index.scss +0 -0
- package/lib/badge/style/_index.scss +0 -0
- package/lib/breadcrumb/style/_index.scss +0 -0
- package/lib/button/style/_index.scss +0 -0
- package/lib/button/style/_mixin.scss +0 -0
- package/lib/button/style/index.css +1 -1
- package/lib/carousel/style/_index.scss +0 -0
- package/lib/checkbox/style/_index.scss +0 -0
- package/lib/collapse/style/_index.scss +0 -0
- package/lib/date-picker/style/_index.scss +0 -0
- package/lib/divider/style/_index.scss +0 -0
- package/lib/empty/style/_index.scss +0 -0
- package/lib/flip/style/_index.scss +0 -0
- package/lib/form/style/_index.scss +0 -0
- package/lib/grid/style/_index.scss +0 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +96 -96
- package/lib/input/style/_index.scss +0 -0
- package/lib/input/style/_mixin.scss +0 -0
- package/lib/input-number/style/_index.scss +0 -0
- package/lib/input-password/style/_index.scss +0 -0
- package/lib/layout/sidebar.js +2 -5
- package/lib/layout/sidebar.js.map +1 -1
- package/lib/layout/style/_index.scss +0 -0
- package/lib/list/list.js.map +1 -1
- package/lib/loader/style/_index.scss +0 -0
- package/lib/loading-bar/style/_index.scss +0 -0
- package/lib/message/style/_index.scss +0 -0
- package/lib/modal/style/_index.scss +0 -0
- package/lib/native-select/style/_index.scss +0 -0
- package/lib/notification/style/_index.scss +0 -0
- package/lib/overlay/style/_index.scss +0 -0
- package/lib/pop-confirm/style/_index.scss +0 -0
- package/lib/popover/style/_index.scss +0 -0
- package/lib/popup/style/_index.scss +0 -0
- package/lib/progress/style/_index.scss +0 -0
- package/lib/radio/style/_index.scss +0 -0
- package/lib/rate/rate.js +2 -5
- package/lib/rate/rate.js.map +1 -1
- package/lib/rate/style/_index.scss +0 -0
- package/lib/split/style/_index.scss +0 -0
- package/lib/style/_component.scss +1 -1
- package/lib/style/base.css +12 -3
- package/lib/style/index.scss +0 -0
- package/lib/switch/style/_index.scss +0 -0
- package/lib/switch/style/_mixin.scss +0 -0
- package/lib/switch/style/index.css +3 -3
- package/lib/table/table.js.map +1 -1
- package/lib/tag/style/_index.scss +0 -0
- package/lib/textarea/style/_index.scss +0 -0
- package/lib/time-picker/style/_index.scss +0 -0
- package/lib/timeline/style/_index.scss +0 -0
- package/lib/tooltip/style/_index.scss +0 -0
- package/lib/typography/style/_index.scss +0 -0
- package/lib/with-spin/style/_index.scss +5 -0
- package/lib/with-spin/style/index.css +3 -0
- package/lib/with-spin/with-spin.d.ts +9 -0
- package/lib/with-spin/with-spin.js +22 -0
- package/lib/with-spin/with-spin.js.map +1 -0
- package/package.json +19 -15
- package/es/icon/icon.d.ts +0 -8
- package/es/icon/icon.js +0 -25
- package/es/icon/icon.js.map +0 -1
- package/es/icon/index.d.ts +0 -1
- package/es/icon/index.js +0 -9
- package/es/icon/index.js.map +0 -1
- package/es/icon/style/_index.scss +0 -16
- package/es/icon/style/index.css +0 -987
- package/es/icon/types.d.ts +0 -15
- package/lib/icon/icon.d.ts +0 -8
- package/lib/icon/icon.js +0 -28
- package/lib/icon/icon.js.map +0 -1
- package/lib/icon/index.js +0 -8
- package/lib/icon/index.js.map +0 -1
- package/lib/icon/style/_index.scss +0 -16
- package/lib/icon/style/index.css +0 -987
- package/lib/icon/types.d.ts +0 -15
- /package/es/{icon → with-spin}/style/index.d.ts +0 -0
- /package/es/{icon → with-spin}/style/index.js +0 -0
- /package/lib/{icon → with-spin}/style/index.d.ts +0 -0
- /package/lib/{icon → with-spin}/style/index.js +0 -0
package/lib/rate/rate.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
2
|
const require_config_context = require("../config-provider/config-context.js");
|
|
3
3
|
const require_general = require("../_utils/general.js");
|
|
4
|
-
const require_index = require("../icon/index.js");
|
|
5
4
|
const require_rate_item = require("./rate-item.js");
|
|
6
5
|
let react = require("react");
|
|
7
6
|
react = require_runtime.__toESM(react);
|
|
8
7
|
let classnames = require("classnames");
|
|
9
8
|
classnames = require_runtime.__toESM(classnames);
|
|
10
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
let _tiny_design_icons = require("@tiny-design/icons");
|
|
11
11
|
//#region src/rate/rate.tsx
|
|
12
12
|
const Rate = react.default.forwardRef((props, ref) => {
|
|
13
|
-
const { color = "#FADB14", character = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
14
|
-
name: "star-fill",
|
|
15
|
-
size: 20
|
|
16
|
-
}), clearable = true, half = false, count = 5, defaultValue = 0, disabled = false, onChange, className, style, prefixCls: customisedCls, ...otherProps } = props;
|
|
13
|
+
const { color = "#FADB14", character = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiny_design_icons.IconStarFill, { size: 20 }), clearable = true, half = false, count = 5, defaultValue = 0, disabled = false, onChange, className, style, prefixCls: customisedCls, ...otherProps } = props;
|
|
17
14
|
const prefixCls = require_general.getPrefixCls("rate", (0, react.useContext)(require_config_context.ConfigContext).prefixCls, customisedCls);
|
|
18
15
|
const cls = (0, classnames.default)(prefixCls, className);
|
|
19
16
|
const [value, setValue] = (0, react.useState)("value" in props ? props.value : defaultValue);
|
package/lib/rate/rate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate.js","names":["React","
|
|
1
|
+
{"version":3,"file":"rate.js","names":["React","IconStarFill","getPrefixCls","ConfigContext","RateItem"],"sources":["../../src/rate/rate.tsx"],"sourcesContent":["import React, { useState, useEffect, useContext } from 'react';\nimport classNames from 'classnames';\nimport { IconStarFill } from '@tiny-design/icons';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { RateProps } from './types';\nimport RateItem from './rate-item';\n\nconst Rate = React.forwardRef<HTMLUListElement, RateProps>(\n (props: RateProps, ref): JSX.Element => {\n const {\n color = '#FADB14',\n character = <IconStarFill size={20} />,\n clearable = true,\n half = false,\n count = 5,\n defaultValue = 0,\n disabled = false,\n onChange,\n className,\n style,\n prefixCls: customisedCls,\n ...otherProps\n } = props;\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('rate', configContext.prefixCls, customisedCls);\n const cls = classNames(prefixCls, className);\n const [value, setValue] = useState<number>(\n 'value' in props ? (props.value as number) : defaultValue\n );\n // tepValue is for setting the value when the mouse is hovering the bar\n const [tmpValue, setTmpValue] = useState<number>(\n 'value' in props ? (props.value as number) : defaultValue\n );\n\n /**\n * Callback when the mouse enters each star item\n * @param index\n */\n const onMouseEnter = (index: number): void => {\n !disabled && setTmpValue(index);\n };\n\n const onClick = (): void => {\n if (!disabled && clearable) {\n const val = tmpValue === value ? 0 : tmpValue;\n setTmpValue(val);\n !('value' in props) && setValue(val);\n onChange && onChange(val);\n } else {\n !('value' in props) && setValue(tmpValue);\n onChange && onChange(tmpValue);\n }\n };\n\n /**\n * When the mouse leaves the rate component\n */\n const onMouseLeave = (): void => {\n setTmpValue(value);\n };\n\n useEffect(() => {\n 'value' in props && setValue(props.value as number);\n }, [props]);\n\n return (\n <ul\n {...otherProps}\n ref={ref}\n className={cls}\n style={style}\n role=\"radiogroup\"\n aria-label=\"Rating\"\n tabIndex={disabled ? -1 : 0}\n onMouseLeave={onMouseLeave}\n onKeyDown={(e: React.KeyboardEvent) => {\n if (disabled) return;\n if (e.key === 'ArrowRight' || e.key === 'ArrowUp') {\n e.preventDefault();\n const step = half ? 0.5 : 1;\n const newVal = Math.min(tmpValue + step, count);\n setTmpValue(newVal);\n !('value' in props) && setValue(newVal);\n onChange?.(newVal);\n } else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') {\n e.preventDefault();\n const step = half ? 0.5 : 1;\n const newVal = Math.max(tmpValue - step, 0);\n setTmpValue(newVal);\n !('value' in props) && setValue(newVal);\n onChange?.(newVal);\n }\n }}>\n {Array(count)\n .fill(0)\n .map((_, idx) => (\n <RateItem\n key={idx}\n index={idx + 1}\n half={half}\n character={character}\n prefixCls={prefixCls}\n onMouseEnter={onMouseEnter}\n onClick={onClick}\n value={half ? tmpValue : Math.round(tmpValue)}\n color={color}\n />\n ))}\n </ul>\n );\n }\n);\n\nRate.displayName = 'Rate';\n\nexport default Rate;\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,OAAOA,MAAAA,QAAM,YAChB,OAAkB,QAAqB;CACtC,MAAM,EACJ,QAAQ,WACR,YAAY,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,cAAD,EAAc,MAAM,IAAM,CAAA,EACtC,YAAY,MACZ,OAAO,OACP,QAAQ,GACR,eAAe,GACf,WAAW,OACX,UACA,WACA,OACA,WAAW,eACX,GAAG,eACD;CAEJ,MAAM,YAAYC,gBAAAA,aAAa,SAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACM,WAAW,cAAc;CAC9E,MAAM,OAAA,GAAA,WAAA,SAAiB,WAAW,UAAU;CAC5C,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UACZ,WAAW,QAAS,MAAM,QAAmB,aAC9C;CAED,MAAM,CAAC,UAAU,gBAAA,GAAA,MAAA,UACf,WAAW,QAAS,MAAM,QAAm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AM,SAAS;GACtC;GACP,EATK,IASL,CACF;EACD,CAAA;EAGV;AAED,KAAK,cAAc"}
|
|
File without changes
|
|
File without changes
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
@use "../flip/style/index" as *;
|
|
26
26
|
@use "../form/style/index" as *;
|
|
27
27
|
@use "../grid/style/index" as *;
|
|
28
|
-
@use "../icon/style/index" as *;
|
|
29
28
|
@use "../image/style/index" as *;
|
|
30
29
|
@use "../input/style/index" as *;
|
|
31
30
|
@use "../input-number/style/index" as *;
|
|
@@ -76,3 +75,4 @@
|
|
|
76
75
|
@use "../tree/style/index" as *;
|
|
77
76
|
@use "../typography/style/index" as *;
|
|
78
77
|
@use "../upload/style/index" as *;
|
|
78
|
+
@use "../with-spin/style/index" as *;
|
package/lib/style/base.css
CHANGED
|
@@ -800,6 +800,7 @@ html[data-tiny-theme=dark] {
|
|
|
800
800
|
--ty-calendar-hover: #2a2a2a;
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
|
+
/* stylelint-disable scss/comment-no-empty */
|
|
803
804
|
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
|
804
805
|
/**
|
|
805
806
|
* 1. Correct the line height in all browsers.
|
|
@@ -808,7 +809,9 @@ html[data-tiny-theme=dark] {
|
|
|
808
809
|
html {
|
|
809
810
|
font-size: 14px;
|
|
810
811
|
line-height: 1.15; /* 1 */
|
|
811
|
-
-webkit-text-size-adjust: 100%;
|
|
812
|
+
-webkit-text-size-adjust: 100%;
|
|
813
|
+
-moz-text-size-adjust: 100%;
|
|
814
|
+
text-size-adjust: 100%; /* 2 */
|
|
812
815
|
}
|
|
813
816
|
|
|
814
817
|
/* Sections
|
|
@@ -1000,6 +1003,8 @@ button,
|
|
|
1000
1003
|
[type=reset],
|
|
1001
1004
|
[type=submit] {
|
|
1002
1005
|
-webkit-appearance: button;
|
|
1006
|
+
-moz-appearance: button;
|
|
1007
|
+
appearance: button;
|
|
1003
1008
|
}
|
|
1004
1009
|
|
|
1005
1010
|
/**
|
|
@@ -1082,7 +1087,9 @@ textarea {
|
|
|
1082
1087
|
* 2. Correct the outline style in Safari.
|
|
1083
1088
|
*/
|
|
1084
1089
|
[type=search] {
|
|
1085
|
-
-webkit-appearance: textfield;
|
|
1090
|
+
-webkit-appearance: textfield;
|
|
1091
|
+
-moz-appearance: textfield;
|
|
1092
|
+
appearance: textfield; /* 1 */
|
|
1086
1093
|
outline-offset: -2px; /* 2 */
|
|
1087
1094
|
}
|
|
1088
1095
|
|
|
@@ -1091,6 +1098,7 @@ textarea {
|
|
|
1091
1098
|
*/
|
|
1092
1099
|
[type=search]::-webkit-search-decoration {
|
|
1093
1100
|
-webkit-appearance: none;
|
|
1101
|
+
appearance: none;
|
|
1094
1102
|
}
|
|
1095
1103
|
|
|
1096
1104
|
/**
|
|
@@ -1098,7 +1106,8 @@ textarea {
|
|
|
1098
1106
|
* 2. Change font properties to `inherit` in Safari.
|
|
1099
1107
|
*/
|
|
1100
1108
|
::-webkit-file-upload-button {
|
|
1101
|
-
-webkit-appearance: button;
|
|
1109
|
+
-webkit-appearance: button;
|
|
1110
|
+
appearance: button; /* 1 */
|
|
1102
1111
|
font: inherit; /* 2 */
|
|
1103
1112
|
}
|
|
1104
1113
|
|
package/lib/style/index.scss
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
height: 1em;
|
|
113
113
|
position: relative;
|
|
114
114
|
border-width: 2px;
|
|
115
|
-
border-color:
|
|
115
|
+
border-color: currentcolor currentcolor transparent transparent;
|
|
116
116
|
border-style: solid;
|
|
117
117
|
border-radius: 50%;
|
|
118
118
|
animation: ty-rotate-reverse 600ms infinite linear;
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
height: 1em;
|
|
145
145
|
position: relative;
|
|
146
146
|
border-width: 2px;
|
|
147
|
-
border-color:
|
|
147
|
+
border-color: currentcolor currentcolor transparent transparent;
|
|
148
148
|
border-style: solid;
|
|
149
149
|
border-radius: 50%;
|
|
150
150
|
animation: ty-rotate-reverse 600ms infinite linear;
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
height: 1em;
|
|
177
177
|
position: relative;
|
|
178
178
|
border-width: 2px;
|
|
179
|
-
border-color:
|
|
179
|
+
border-color: currentcolor currentcolor transparent transparent;
|
|
180
180
|
border-style: solid;
|
|
181
181
|
border-radius: 50%;
|
|
182
182
|
animation: ty-rotate-reverse 600ms infinite linear;
|
package/lib/table/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":["React","ConfigContext","getPrefixCls","useVirtualScroll","Pagination"],"sources":["../../src/table/table.tsx"],"sourcesContent":["import React, { useState, useEffect, useContext, useMemo } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { useVirtualScroll } from '../_utils/use-virtual-scroll';\nimport Pagination from '../pagination';\nimport { TableProps, ColumnType, SortOrder } from './types';\n\nconst ROW_HEIGHT_MAP = { sm: 40, md: 48, lg: 56 } as const;\n\nconst getRowKey = <T,>(record: T, rowKey: string | ((record: T) => React.Key), index: number): React.Key => {\n if (typeof rowKey === 'function') return rowKey(record);\n const key = (record as any)[rowKey];\n return key !== undefined ? key : index;\n};\n\nconst getValue = <T,>(record: T, dataIndex: string): any => {\n return (record as any)[dataIndex];\n};\n\nconst Table = React.forwardRef<HTMLDivElement, TableProps>((props, ref) => {\n const {\n columns,\n dataSource = [],\n rowKey = 'key',\n loading = false,\n bordered = false,\n size,\n scroll,\n virtual = false,\n height,\n itemHeight: itemHeightProp,\n rowSelection,\n pagination,\n onChange,\n emptyText = 'No Data',\n showHeader = true,\n rowClassName,\n onRow,\n prefixCls: customisedCls,\n className,\n style,\n ...otherProps\n } = props;\n\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('table', configContext.prefixCls, customisedCls);\n const tableSize = size || configContext.componentSize || 'md';\n\n if (virtual && height == null) {\n console.warn('[tiny-ui: Table] `height` is required when `virtual` is enabled.');\n }\n\n const isVirtual = virtual && height != null;\n\n // Sorting\n const [sortField, setSortField] = useState<string | undefined>();\n const [sortOrder, setSortOrder] = useState<SortOrder>(null);\n\n // Pagination\n const [currentPage, setCurrentPage] = useState(1);\n const pageSize = pagination && pagination.pageSize ? pagination.pageSize : 10;\n\n // Selection\n const [selectedKeys, setSelectedKeys] = useState<React.Key[]>(\n rowSelection?.selectedRowKeys ?? []\n );\n\n useEffect(() => {\n if (rowSelection?.selectedRowKeys) {\n setSelectedKeys(rowSelection.selectedRowKeys);\n }\n }, [rowSelection?.selectedRowKeys]);\n\n // Initialize default sort\n useEffect(() => {\n for (const col of columns) {\n if (col.defaultSortOrder) {\n setSortField(col.dataIndex);\n setSortOrder(col.defaultSortOrder);\n break;\n }\n }\n }, []);\n\n const sortedData = useMemo(() => {\n if (!sortField || !sortOrder) return [...dataSource];\n const col = columns.find((c) => c.dataIndex === sortField);\n if (!col?.sorter) return [...dataSource];\n const sorted = [...dataSource];\n const sorterFn =\n typeof col.sorter === 'function'\n ? col.sorter\n : (a: any, b: any) => {\n const va = getValue(a, sortField);\n const vb = getValue(b, sortField);\n if (va < vb) return -1;\n if (va > vb) return 1;\n return 0;\n };\n sorted.sort((a, b) => {\n const result = sorterFn(a, b);\n return sortOrder === 'descend' ? -result : result;\n });\n return sorted;\n }, [dataSource, sortField, sortOrder, columns]);\n\n const rowHeight = itemHeightProp ?? ROW_HEIGHT_MAP[tableSize] ?? ROW_HEIGHT_MAP.md;\n const { visibleRange, totalHeight, offsetY, onScroll } = useVirtualScroll({\n itemCount: sortedData.length,\n itemHeight: rowHeight,\n containerHeight: height ?? 0,\n });\n\n const paginatedData = useMemo(() => {\n if (isVirtual) return sortedData;\n if (pagination === false) return sortedData;\n const page = pagination?.current ?? currentPage;\n const start = (page - 1) * pageSize;\n return sortedData.slice(start, start + pageSize);\n }, [sortedData, pagination, currentPage, pageSize, isVirtual]);\n\n const paginationConfig = pagination && typeof pagination === 'object' ? pagination : undefined;\n const totalItems = paginationConfig?.total ?? dataSource.length;\n const activePage = paginationConfig?.current ?? currentPage;\n\n const handleSort = (col: ColumnType) => {\n if (!col.sorter) return;\n let newOrder: SortOrder;\n if (sortField !== col.dataIndex) {\n newOrder = 'ascend';\n } else if (sortOrder === 'ascend') {\n newOrder = 'descend';\n } else if (sortOrder === 'descend') {\n newOrder = null;\n } else {\n newOrder = 'ascend';\n }\n setSortField(newOrder ? col.dataIndex : undefined);\n setSortOrder(newOrder);\n onChange?.({ current: activePage, pageSize }, { field: col.dataIndex, order: newOrder });\n };\n\n const handlePageChange = (page: number) => {\n setCurrentPage(page);\n pagination && pagination.onChange?.(page, pageSize);\n onChange?.({ current: page, pageSize }, { field: sortField, order: sortOrder });\n };\n\n const handleSelectAll = () => {\n if (!rowSelection) return;\n const allKeys = paginatedData.map((record, i) => getRowKey(record, rowKey, i));\n const allSelected = allKeys.every((k) => selectedKeys.includes(k));\n const newKeys = allSelected ? [] : allKeys;\n if (!rowSelection.selectedRowKeys) {\n setSelectedKeys(newKeys);\n }\n const newRows = allSelected ? [] : paginatedData;\n rowSelection.onChange?.(newKeys, newRows);\n };\n\n const handleSelectRow = (record: any, key: React.Key) => {\n if (!rowSelection) return;\n const isRadio = rowSelection.type === 'radio';\n let newKeys: React.Key[];\n if (isRadio) {\n newKeys = [key];\n } else {\n newKeys = selectedKeys.includes(key)\n ? selectedKeys.filter((k) => k !== key)\n : [...selectedKeys, key];\n }\n if (!rowSelection.selectedRowKeys) {\n setSelectedKeys(newKeys);\n }\n const newRows = dataSource.filter((r, i) => newKeys.includes(getRowKey(r, rowKey, i)));\n rowSelection.onChange?.(newKeys, newRows);\n };\n\n const cls = classNames(prefixCls, className, {\n [`${prefixCls}_bordered`]: bordered,\n [`${prefixCls}_${tableSize}`]: tableSize,\n [`${prefixCls}_loading`]: loading,\n });\n\n const tableStyle: React.CSSProperties = {};\n if (scroll?.x) tableStyle.minWidth = scroll.x;\n\n const wrapperStyle: React.CSSProperties = {};\n if (isVirtual) {\n wrapperStyle.height = height;\n wrapperStyle.overflowY = 'auto';\n } else if (scroll?.y) {\n wrapperStyle.maxHeight = scroll.y;\n wrapperStyle.overflowY = 'auto';\n }\n\n const allPageKeys = paginatedData.map((r, i) => getRowKey(r, rowKey, i));\n const allSelected = allPageKeys.length > 0 && allPageKeys.every((k) => selectedKeys.includes(k));\n const someSelected = allPageKeys.some((k) => selectedKeys.includes(k));\n\n const colCount = columns.length + (rowSelection ? 1 : 0);\n\n const renderRow = (record: any, rowIndex: number) => {\n const key = getRowKey(record, rowKey, rowIndex);\n const isSelected = selectedKeys.includes(key);\n const rowCls = classNames(`${prefixCls}__row`, {\n [`${prefixCls}__row_selected`]: isSelected,\n }, typeof rowClassName === 'function' ? rowClassName(record, rowIndex) : rowClassName);\n const rowProps = onRow?.(record, rowIndex) ?? {};\n return (\n <tr key={key} className={rowCls} {...rowProps}>\n {rowSelection && (\n <td className={`${prefixCls}__cell ${prefixCls}__selection-col`}>\n <input\n type={rowSelection.type === 'radio' ? 'radio' : 'checkbox'}\n checked={isSelected}\n onChange={() => handleSelectRow(record, key)}\n aria-label={`Select row ${rowIndex + 1}`}\n />\n </td>\n )}\n {columns.map((col, colIndex) => {\n const colKey = col.key ?? col.dataIndex ?? colIndex;\n const value = getValue(record, col.dataIndex);\n const tdCls = classNames(`${prefixCls}__cell`, col.className, {\n [`${prefixCls}__cell_ellipsis`]: col.ellipsis,\n [`${prefixCls}__cell_align-${col.align}`]: col.align,\n });\n return (\n <td key={colKey} className={tdCls} style={{ width: col.width }}>\n {col.render ? col.render(value, record, rowIndex) : value}\n </td>\n );\n })}\n </tr>\n );\n };\n\n const renderTbody = () => {\n if (loading) {\n return (\n <tr>\n <td\n className={`${prefixCls}__cell ${prefixCls}__loading-cell`}\n colSpan={colCount}\n >\n Loading...\n </td>\n </tr>\n );\n }\n\n if (isVirtual) {\n if (sortedData.length === 0) {\n return (\n <tr>\n <td className={`${prefixCls}__cell ${prefixCls}__empty-cell`} colSpan={colCount}>\n {emptyText}\n </td>\n </tr>\n );\n }\n const [start, end] = visibleRange;\n const topHeight = offsetY;\n const bottomHeight = totalHeight - offsetY - (end - start + 1) * rowHeight;\n return (\n <>\n {topHeight > 0 && (\n <tr className={`${prefixCls}__row_spacer`}>\n <td colSpan={colCount} style={{ height: topHeight }} />\n </tr>\n )}\n {sortedData.slice(start, end + 1).map((record, i) => renderRow(record, start + i))}\n {bottomHeight > 0 && (\n <tr className={`${prefixCls}__row_spacer`}>\n <td colSpan={colCount} style={{ height: Math.max(0, bottomHeight) }} />\n </tr>\n )}\n </>\n );\n }\n\n if (paginatedData.length === 0) {\n return (\n <tr>\n <td\n className={`${prefixCls}__cell ${prefixCls}__empty-cell`}\n colSpan={colCount}\n >\n {emptyText}\n </td>\n </tr>\n );\n }\n\n return paginatedData.map((record, rowIndex) => renderRow(record, rowIndex));\n };\n\n const theadCls = classNames(`${prefixCls}__thead`, {\n [`${prefixCls}__thead_sticky`]: isVirtual,\n });\n\n const showPagination = pagination !== false && !isVirtual;\n\n return (\n <div {...otherProps} ref={ref} className={cls} style={style}>\n <div\n className={`${prefixCls}__wrapper`}\n style={wrapperStyle}\n onScroll={isVirtual ? onScroll : undefined}\n >\n <table className={`${prefixCls}__table`} style={tableStyle}>\n {showHeader && (\n <thead className={theadCls}>\n <tr>\n {rowSelection && (\n <th className={`${prefixCls}__cell ${prefixCls}__selection-col`}>\n {rowSelection.type !== 'radio' && (\n <input\n type=\"checkbox\"\n checked={allSelected}\n ref={(el) => { if (el) el.indeterminate = someSelected && !allSelected; }}\n onChange={handleSelectAll}\n aria-label=\"Select all\"\n />\n )}\n </th>\n )}\n {columns.map((col, i) => {\n const key = col.key ?? col.dataIndex ?? i;\n const thCls = classNames(`${prefixCls}__cell`, col.className, {\n [`${prefixCls}__cell_sortable`]: !!col.sorter,\n [`${prefixCls}__cell_align-${col.align}`]: col.align,\n });\n return (\n <th\n key={key}\n className={thCls}\n style={{ width: col.width }}\n onClick={() => handleSort(col)}\n >\n <span className={`${prefixCls}__col-title`}>{col.title}</span>\n {col.sorter && (\n <span className={`${prefixCls}__sorter`}>\n <span className={classNames(`${prefixCls}__sorter-icon`, {\n [`${prefixCls}__sorter-icon_active`]: sortField === col.dataIndex && sortOrder === 'ascend',\n })}>▲</span>\n <span className={classNames(`${prefixCls}__sorter-icon`, {\n [`${prefixCls}__sorter-icon_active`]: sortField === col.dataIndex && sortOrder === 'descend',\n })}>▼</span>\n </span>\n )}\n </th>\n );\n })}\n </tr>\n </thead>\n )}\n <tbody className={`${prefixCls}__tbody`}>\n {renderTbody()}\n </tbody>\n </table>\n </div>\n {showPagination && (\n <Pagination\n current={activePage}\n total={totalItems}\n pageSize={pageSize}\n align={paginationConfig?.align ?? 'right'}\n size={paginationConfig?.size}\n disabled={paginationConfig?.disabled}\n onChange={(page) => handlePageChange(page)}\n style={{ padding: '16px 0' }}\n />\n )}\n </div>\n );\n});\n\nTable.displayName = 'Table';\nexport default Table;\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,iBAAiB;CAAE,IAAI;CAAI,IAAI;CAAI,IAAI;CAAI;AAEjD,MAAM,aAAiB,QAAW,QAA6C,UAA6B;AAC1G,KAAI,OAAO,WAAW,WAAY,QAAO,OAAO,OAAO;CACvD,MAAM,MAAO,OAAe;AAC5B,QAAO,QAAQ,KAAA,IAAY,MAAM;;AAGnC,MAAM,YAAgB,QAAW,cAA2B;AAC1D,QAAQ,OAAe;;AAGzB,MAAM,QAAQA,MAAAA,QAAM,YAAwC,OAAO,QAAQ;CACzE,MAAM,EACJ,SACA,aAAa,EAAE,EACf,SAAS,OACT,UAAU,OACV,WAAW,OACX,MACA,QACA,UAAU,OACV,QACA,YAAY,gBACZ,cACA,YACA,UACA,YAAY,WACZ,aAAa,MACb,cACA,OACA,WAAW,eACX,WACA,OACA,GAAG,eACD;CAEJ,MAAM,iBAAA,GAAA,MAAA,YAA2BC,uBAAAA,cAAc;CA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,CACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;SAAM,YAAA,GAAA,WAAA,SAAsB,GAAG,UAAU,gBAAgB,GACtD,GAAG,UAAU,wBAAwB,cAAc,IAAI,aAAa,cAAc,UACpF,CAAC;mBAAE;SAAQ,CAAA,EACZ,iBAAA,GAAA,kBAAA,KAAC,QAAD;SAAM,YAAA,GAAA,WAAA,SAAsB,GAAG,UAAU,gBAAgB,GACtD,GAAG,UAAU,wBAAwB,cAAc,IAAI,aAAa,cAAc,WACpF,CAAC;mBAAE;SAAQ,CAAA,CACP;UAEN;SAhBE,IAgBF;OAEP,CACC,EAAA,CAAA;KACC,CAAA,EAEV,iBAAA,GAAA,kBAAA,KAAC,SAAD;KAAO,WAAW,GAAG,UAAU;eAC5B,aAAa;KACR,CAAA,CACF;;GACJ,CAAA,EACL,kBACC,iBAAA,GAAA,kBAAA,KAACC,cAAAA,SAAD;GACE,SAAS;GACT,OAAO;GACG;GACV,OAAO,kBAAkB,SAAS;GAClC,MAAM,kBAAkB;GACxB,UAAU,kBAAkB;GAC5B,WAAW,SAAS,iBAAiB,KAAK;GAC1C,OAAO,EAAE,SAAS,UAAU;GAC5B,CAAA,CAEA;;EAER;AAEF,MAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"table.js","names":["React","ConfigContext","getPrefixCls","useVirtualScroll","Pagination"],"sources":["../../src/table/table.tsx"],"sourcesContent":["import React, { useState, useEffect, useContext, useMemo } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { useVirtualScroll } from '../_utils/use-virtual-scroll';\nimport Pagination from '../pagination';\nimport { TableProps, ColumnType, SortOrder } from './types';\n\nconst ROW_HEIGHT_MAP = { sm: 40, md: 48, lg: 56 } as const;\n\nconst getRowKey = <T,>(record: T, rowKey: string | ((record: T) => React.Key), index: number): React.Key => {\n if (typeof rowKey === 'function') return rowKey(record);\n const key = (record as any)[rowKey];\n return key !== undefined ? key : index;\n};\n\nconst getValue = <T,>(record: T, dataIndex: string): any => {\n return (record as any)[dataIndex];\n};\n\nconst Table = React.forwardRef<HTMLDivElement, TableProps>((props, ref) => {\n const {\n columns,\n dataSource = [],\n rowKey = 'key',\n loading = false,\n bordered = false,\n size,\n scroll,\n virtual = false,\n height,\n itemHeight: itemHeightProp,\n rowSelection,\n pagination,\n onChange,\n emptyText = 'No Data',\n showHeader = true,\n rowClassName,\n onRow,\n prefixCls: customisedCls,\n className,\n style,\n ...otherProps\n } = props;\n\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('table', configContext.prefixCls, customisedCls);\n const tableSize = size || configContext.componentSize || 'md';\n\n if (virtual && height == null) {\n console.warn('[tiny-design: Table] `height` is required when `virtual` is enabled.');\n }\n\n const isVirtual = virtual && height != null;\n\n // Sorting\n const [sortField, setSortField] = useState<string | undefined>();\n const [sortOrder, setSortOrder] = useState<SortOrder>(null);\n\n // Pagination\n const [currentPage, setCurrentPage] = useState(1);\n const pageSize = pagination && pagination.pageSize ? pagination.pageSize : 10;\n\n // Selection\n const [selectedKeys, setSelectedKeys] = useState<React.Key[]>(\n rowSelection?.selectedRowKeys ?? []\n );\n\n useEffect(() => {\n if (rowSelection?.selectedRowKeys) {\n setSelectedKeys(rowSelection.selectedRowKeys);\n }\n }, [rowSelection?.selectedRowKeys]);\n\n // Initialize default sort\n useEffect(() => {\n for (const col of columns) {\n if (col.defaultSortOrder) {\n setSortField(col.dataIndex);\n setSortOrder(col.defaultSortOrder);\n break;\n }\n }\n }, []);\n\n const sortedData = useMemo(() => {\n if (!sortField || !sortOrder) return [...dataSource];\n const col = columns.find((c) => c.dataIndex === sortField);\n if (!col?.sorter) return [...dataSource];\n const sorted = [...dataSource];\n const sorterFn =\n typeof col.sorter === 'function'\n ? col.sorter\n : (a: any, b: any) => {\n const va = getValue(a, sortField);\n const vb = getValue(b, sortField);\n if (va < vb) return -1;\n if (va > vb) return 1;\n return 0;\n };\n sorted.sort((a, b) => {\n const result = sorterFn(a, b);\n return sortOrder === 'descend' ? -result : result;\n });\n return sorted;\n }, [dataSource, sortField, sortOrder, columns]);\n\n const rowHeight = itemHeightProp ?? ROW_HEIGHT_MAP[tableSize] ?? ROW_HEIGHT_MAP.md;\n const { visibleRange, totalHeight, offsetY, onScroll } = useVirtualScroll({\n itemCount: sortedData.length,\n itemHeight: rowHeight,\n containerHeight: height ?? 0,\n });\n\n const paginatedData = useMemo(() => {\n if (isVirtual) return sortedData;\n if (pagination === false) return sortedData;\n const page = pagination?.current ?? currentPage;\n const start = (page - 1) * pageSize;\n return sortedData.slice(start, start + pageSize);\n }, [sortedData, pagination, currentPage, pageSize, isVirtual]);\n\n const paginationConfig = pagination && typeof pagination === 'object' ? pagination : undefined;\n const totalItems = paginationConfig?.total ?? dataSource.length;\n const activePage = paginationConfig?.current ?? currentPage;\n\n const handleSort = (col: ColumnType) => {\n if (!col.sorter) return;\n let newOrder: SortOrder;\n if (sortField !== col.dataIndex) {\n newOrder = 'ascend';\n } else if (sortOrder === 'ascend') {\n newOrder = 'descend';\n } else if (sortOrder === 'descend') {\n newOrder = null;\n } else {\n newOrder = 'ascend';\n }\n setSortField(newOrder ? col.dataIndex : undefined);\n setSortOrder(newOrder);\n onChange?.({ current: activePage, pageSize }, { field: col.dataIndex, order: newOrder });\n };\n\n const handlePageChange = (page: number) => {\n setCurrentPage(page);\n pagination && pagination.onChange?.(page, pageSize);\n onChange?.({ current: page, pageSize }, { field: sortField, order: sortOrder });\n };\n\n const handleSelectAll = () => {\n if (!rowSelection) return;\n const allKeys = paginatedData.map((record, i) => getRowKey(record, rowKey, i));\n const allSelected = allKeys.every((k) => selectedKeys.includes(k));\n const newKeys = allSelected ? [] : allKeys;\n if (!rowSelection.selectedRowKeys) {\n setSelectedKeys(newKeys);\n }\n const newRows = allSelected ? [] : paginatedData;\n rowSelection.onChange?.(newKeys, newRows);\n };\n\n const handleSelectRow = (record: any, key: React.Key) => {\n if (!rowSelection) return;\n const isRadio = rowSelection.type === 'radio';\n let newKeys: React.Key[];\n if (isRadio) {\n newKeys = [key];\n } else {\n newKeys = selectedKeys.includes(key)\n ? selectedKeys.filter((k) => k !== key)\n : [...selectedKeys, key];\n }\n if (!rowSelection.selectedRowKeys) {\n setSelectedKeys(newKeys);\n }\n const newRows = dataSource.filter((r, i) => newKeys.includes(getRowKey(r, rowKey, i)));\n rowSelection.onChange?.(newKeys, newRows);\n };\n\n const cls = classNames(prefixCls, className, {\n [`${prefixCls}_bordered`]: bordered,\n [`${prefixCls}_${tableSize}`]: tableSize,\n [`${prefixCls}_loading`]: loading,\n });\n\n const tableStyle: React.CSSProperties = {};\n if (scroll?.x) tableStyle.minWidth = scroll.x;\n\n const wrapperStyle: React.CSSProperties = {};\n if (isVirtual) {\n wrapperStyle.height = height;\n wrapperStyle.overflowY = 'auto';\n } else if (scroll?.y) {\n wrapperStyle.maxHeight = scroll.y;\n wrapperStyle.overflowY = 'auto';\n }\n\n const allPageKeys = paginatedData.map((r, i) => getRowKey(r, rowKey, i));\n const allSelected = allPageKeys.length > 0 && allPageKeys.every((k) => selectedKeys.includes(k));\n const someSelected = allPageKeys.some((k) => selectedKeys.includes(k));\n\n const colCount = columns.length + (rowSelection ? 1 : 0);\n\n const renderRow = (record: any, rowIndex: number) => {\n const key = getRowKey(record, rowKey, rowIndex);\n const isSelected = selectedKeys.includes(key);\n const rowCls = classNames(`${prefixCls}__row`, {\n [`${prefixCls}__row_selected`]: isSelected,\n }, typeof rowClassName === 'function' ? rowClassName(record, rowIndex) : rowClassName);\n const rowProps = onRow?.(record, rowIndex) ?? {};\n return (\n <tr key={key} className={rowCls} {...rowProps}>\n {rowSelection && (\n <td className={`${prefixCls}__cell ${prefixCls}__selection-col`}>\n <input\n type={rowSelection.type === 'radio' ? 'radio' : 'checkbox'}\n checked={isSelected}\n onChange={() => handleSelectRow(record, key)}\n aria-label={`Select row ${rowIndex + 1}`}\n />\n </td>\n )}\n {columns.map((col, colIndex) => {\n const colKey = col.key ?? col.dataIndex ?? colIndex;\n const value = getValue(record, col.dataIndex);\n const tdCls = classNames(`${prefixCls}__cell`, col.className, {\n [`${prefixCls}__cell_ellipsis`]: col.ellipsis,\n [`${prefixCls}__cell_align-${col.align}`]: col.align,\n });\n return (\n <td key={colKey} className={tdCls} style={{ width: col.width }}>\n {col.render ? col.render(value, record, rowIndex) : value}\n </td>\n );\n })}\n </tr>\n );\n };\n\n const renderTbody = () => {\n if (loading) {\n return (\n <tr>\n <td\n className={`${prefixCls}__cell ${prefixCls}__loading-cell`}\n colSpan={colCount}\n >\n Loading...\n </td>\n </tr>\n );\n }\n\n if (isVirtual) {\n if (sortedData.length === 0) {\n return (\n <tr>\n <td className={`${prefixCls}__cell ${prefixCls}__empty-cell`} colSpan={colCount}>\n {emptyText}\n </td>\n </tr>\n );\n }\n const [start, end] = visibleRange;\n const topHeight = offsetY;\n const bottomHeight = totalHeight - offsetY - (end - start + 1) * rowHeight;\n return (\n <>\n {topHeight > 0 && (\n <tr className={`${prefixCls}__row_spacer`}>\n <td colSpan={colCount} style={{ height: topHeight }} />\n </tr>\n )}\n {sortedData.slice(start, end + 1).map((record, i) => renderRow(record, start + i))}\n {bottomHeight > 0 && (\n <tr className={`${prefixCls}__row_spacer`}>\n <td colSpan={colCount} style={{ height: Math.max(0, bottomHeight) }} />\n </tr>\n )}\n </>\n );\n }\n\n if (paginatedData.length === 0) {\n return (\n <tr>\n <td\n className={`${prefixCls}__cell ${prefixCls}__empty-cell`}\n colSpan={colCount}\n >\n {emptyText}\n </td>\n </tr>\n );\n }\n\n return paginatedData.map((record, rowIndex) => renderRow(record, rowIndex));\n };\n\n const theadCls = classNames(`${prefixCls}__thead`, {\n [`${prefixCls}__thead_sticky`]: isVirtual,\n });\n\n const showPagination = pagination !== false && !isVirtual;\n\n return (\n <div {...otherProps} ref={ref} className={cls} style={style}>\n <div\n className={`${prefixCls}__wrapper`}\n style={wrapperStyle}\n onScroll={isVirtual ? onScroll : undefined}\n >\n <table className={`${prefixCls}__table`} style={tableStyle}>\n {showHeader && (\n <thead className={theadCls}>\n <tr>\n {rowSelection && (\n <th className={`${prefixCls}__cell ${prefixCls}__selection-col`}>\n {rowSelection.type !== 'radio' && (\n <input\n type=\"checkbox\"\n checked={allSelected}\n ref={(el) => { if (el) el.indeterminate = someSelected && !allSelected; }}\n onChange={handleSelectAll}\n aria-label=\"Select all\"\n />\n )}\n </th>\n )}\n {columns.map((col, i) => {\n const key = col.key ?? col.dataIndex ?? i;\n const thCls = classNames(`${prefixCls}__cell`, col.className, {\n [`${prefixCls}__cell_sortable`]: !!col.sorter,\n [`${prefixCls}__cell_align-${col.align}`]: col.align,\n });\n return (\n <th\n key={key}\n className={thCls}\n style={{ width: col.width }}\n onClick={() => handleSort(col)}\n >\n <span className={`${prefixCls}__col-title`}>{col.title}</span>\n {col.sorter && (\n <span className={`${prefixCls}__sorter`}>\n <span className={classNames(`${prefixCls}__sorter-icon`, {\n [`${prefixCls}__sorter-icon_active`]: sortField === col.dataIndex && sortOrder === 'ascend',\n })}>▲</span>\n <span className={classNames(`${prefixCls}__sorter-icon`, {\n [`${prefixCls}__sorter-icon_active`]: sortField === col.dataIndex && sortOrder === 'descend',\n })}>▼</span>\n </span>\n )}\n </th>\n );\n })}\n </tr>\n </thead>\n )}\n <tbody className={`${prefixCls}__tbody`}>\n {renderTbody()}\n </tbody>\n </table>\n </div>\n {showPagination && (\n <Pagination\n current={activePage}\n total={totalItems}\n pageSize={pageSize}\n align={paginationConfig?.align ?? 'right'}\n size={paginationConfig?.size}\n disabled={paginationConfig?.disabled}\n onChange={(page) => handlePageChange(page)}\n style={{ padding: '16px 0' }}\n />\n )}\n </div>\n );\n});\n\nTable.displayName = 'Table';\nexport default Table;\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,iBAAiB;CAAE,IAAI;CAAI,IAAI;CAAI,IAAI;CAAI;AAEjD,MAAM,aAAiB,QAAW,QAA6C,UAA6B;AAC1G,KAAI,OAAO,WAAW,WAAY,QAAO,OAAO,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
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes } from "react";
|
|
2
|
+
import { IconProps } from "@tiny-design/icons";
|
|
3
|
+
|
|
4
|
+
//#region src/with-spin/with-spin.d.ts
|
|
5
|
+
type IconComponent = ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>;
|
|
6
|
+
declare function withSpin(Icon: IconComponent): IconComponent;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { withSpin };
|
|
9
|
+
//# sourceMappingURL=with-spin.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
let classnames = require("classnames");
|
|
4
|
+
classnames = require_runtime.__toESM(classnames);
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
//#region src/with-spin/with-spin.tsx
|
|
7
|
+
function withSpin(Icon) {
|
|
8
|
+
const SpinIcon = (0, react.forwardRef)((props, ref) => {
|
|
9
|
+
const { className, ...rest } = props;
|
|
10
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
11
|
+
ref,
|
|
12
|
+
className: (0, classnames.default)("ty-icon-spin", className),
|
|
13
|
+
...rest
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
SpinIcon.displayName = `withSpin(${Icon.displayName || "Icon"})`;
|
|
17
|
+
return SpinIcon;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.withSpin = withSpin;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=with-spin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-spin.js","names":[],"sources":["../../src/with-spin/with-spin.tsx"],"sourcesContent":["import { forwardRef, type ForwardRefExoticComponent, type RefAttributes } from 'react';\nimport type { IconProps } from '@tiny-design/icons';\nimport classNames from 'classnames';\n\ntype IconComponent = ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>;\n\nexport function withSpin(Icon: IconComponent): IconComponent {\n const SpinIcon = forwardRef<SVGSVGElement, IconProps>((props, ref) => {\n const { className, ...rest } = props;\n\n return (\n <Icon\n ref={ref}\n className={classNames('ty-icon-spin', className)}\n {...rest}\n />\n );\n });\n\n const name = Icon.displayName || 'Icon';\n SpinIcon.displayName = `withSpin(${name})`;\n\n return SpinIcon;\n}\n"],"mappings":";;;;;;AAMA,SAAgB,SAAS,MAAoC;CAC3D,MAAM,YAAA,GAAA,MAAA,aAAiD,OAAO,QAAQ;EACpE,MAAM,EAAE,WAAW,GAAG,SAAS;AAE/B,SACE,iBAAA,GAAA,kBAAA,KAAC,MAAD;GACO;GACL,YAAA,GAAA,WAAA,SAAsB,gBAAgB,UAAU;GAChD,GAAI;GACJ,CAAA;GAEJ;AAGF,UAAS,cAAc,YADV,KAAK,eAAe,OACO;AAExC,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiny-design/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "A friendly UI component set for React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"author": "Di Wang<wangdicoder@gmail.com>",
|
|
25
25
|
"homepage": "https://wangdicoder.github.io/tiny-design/",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
26
29
|
"main": "lib/index.js",
|
|
27
30
|
"module": "es/index.js",
|
|
28
31
|
"typings": "lib/index.d.ts",
|
|
@@ -43,27 +46,17 @@
|
|
|
43
46
|
"lib",
|
|
44
47
|
"es"
|
|
45
48
|
],
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "npm run clean && tsdown && node scripts/build-styles.js && node scripts/inject-style-imports.js",
|
|
48
|
-
"clean": "rimraf lib es",
|
|
49
|
-
"test": "jest",
|
|
50
|
-
"test:watch": "jest --watch",
|
|
51
|
-
"test:coverage": "jest --coverage",
|
|
52
|
-
"test:update": "jest --updateSnapshot",
|
|
53
|
-
"lint": "eslint src/",
|
|
54
|
-
"lint:style": "stylelint \"src/**/*.scss\"",
|
|
55
|
-
"lint:style:fix": "npm run lint:style -- --fix"
|
|
56
|
-
},
|
|
57
49
|
"peerDependencies": {
|
|
58
50
|
"react": ">=18.0.0",
|
|
59
51
|
"react-dom": ">=18.0.0"
|
|
60
52
|
},
|
|
61
53
|
"dependencies": {
|
|
62
54
|
"@popperjs/core": "^2.11.4",
|
|
63
|
-
"@tiny-design/tokens": "workspace:*",
|
|
64
55
|
"classnames": "^2.3.1",
|
|
65
56
|
"react-transition-group": "^4.4.2",
|
|
66
|
-
"tslib": "^2.3.1"
|
|
57
|
+
"tslib": "^2.3.1",
|
|
58
|
+
"@tiny-design/icons": "1.0.9",
|
|
59
|
+
"@tiny-design/tokens": "1.0.4"
|
|
67
60
|
},
|
|
68
61
|
"devDependencies": {
|
|
69
62
|
"@testing-library/jest-dom": "^6.0.0",
|
|
@@ -83,5 +76,16 @@
|
|
|
83
76
|
"ts-jest": "^29.0.0",
|
|
84
77
|
"tsdown": "^0.21.1",
|
|
85
78
|
"typescript": "^5.4.0"
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "npm run clean && tsdown && node scripts/build-styles.js && node scripts/inject-style-imports.js",
|
|
82
|
+
"clean": "rimraf lib es",
|
|
83
|
+
"test": "jest",
|
|
84
|
+
"test:watch": "jest --watch",
|
|
85
|
+
"test:coverage": "jest --coverage",
|
|
86
|
+
"test:update": "jest --updateSnapshot",
|
|
87
|
+
"lint": "eslint src/",
|
|
88
|
+
"lint:style": "stylelint \"src/**/*.scss\"",
|
|
89
|
+
"lint:style:fix": "npm run lint:style -- --fix"
|
|
86
90
|
}
|
|
87
|
-
}
|
|
91
|
+
}
|
package/es/icon/icon.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IconProps } from "./types.js";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/icon/icon.d.ts
|
|
5
|
-
declare const Icon: React.MemoExoticComponent<React.ForwardRefExoticComponent<IconProps & React.RefAttributes<HTMLElement>>>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { Icon };
|
|
8
|
-
//# sourceMappingURL=icon.d.ts.map
|
package/es/icon/icon.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ConfigContext } from "../config-provider/config-context.js";
|
|
2
|
-
import { getPrefixCls } from "../_utils/general.js";
|
|
3
|
-
import React, { useContext } from "react";
|
|
4
|
-
import classNames from "classnames";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
//#region src/icon/icon.tsx
|
|
7
|
-
const Icon = React.memo(React.forwardRef((props, ref) => {
|
|
8
|
-
const { name, color, size, style, spin, className, prefixCls: customisedCls, ...otherProps } = props;
|
|
9
|
-
const prefixCls = getPrefixCls("icon", useContext(ConfigContext).prefixCls, customisedCls);
|
|
10
|
-
return /* @__PURE__ */ jsx("i", {
|
|
11
|
-
ref,
|
|
12
|
-
className: classNames(prefixCls, className, `ty--${name}`, { [`${prefixCls}_spin`]: spin }),
|
|
13
|
-
style: {
|
|
14
|
-
color,
|
|
15
|
-
fontSize: size,
|
|
16
|
-
...style
|
|
17
|
-
},
|
|
18
|
-
...otherProps
|
|
19
|
-
});
|
|
20
|
-
}));
|
|
21
|
-
Icon.displayName = "Icon";
|
|
22
|
-
//#endregion
|
|
23
|
-
export { Icon as default };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=icon.js.map
|
package/es/icon/icon.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"icon.js","names":[],"sources":["../../src/icon/icon.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { IconProps } from './types';\n\nconst Icon = React.memo(React.forwardRef<HTMLElement, IconProps>((props, ref) => {\n const {\n name,\n color,\n size,\n style,\n spin,\n className,\n prefixCls: customisedCls,\n ...otherProps\n } = props;\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('icon', configContext.prefixCls, customisedCls);\n const cls = classNames(prefixCls, className, `ty--${name}`, {\n [`${prefixCls}_spin`]: spin,\n });\n return <i ref={ref} className={cls} style={{ color, fontSize: size, ...style }} {...otherProps} />;\n}));\n\nIcon.displayName = 'Icon';\n\nexport default Icon;\n"],"mappings":";;;;;;AAMA,MAAM,OAAO,MAAM,KAAK,MAAM,YAAoC,OAAO,QAAQ;CAC/E,MAAM,EACJ,MACA,OACA,MACA,OACA,MACA,WACA,WAAW,eACX,GAAG,eACD;CAEJ,MAAM,YAAY,aAAa,QADT,WAAW,cAAc,CACM,WAAW,cAAc;AAI9E,QAAO,oBAAC,KAAD;EAAQ;EAAK,WAHR,WAAW,WAAW,WAAW,OAAO,QAAQ,GACzD,GAAG,UAAU,SAAS,MACxB,CAAC;EACkC,OAAO;GAAE;GAAO,UAAU;GAAM,GAAG;GAAO;EAAE,GAAI;EAAc,CAAA;EAClG,CAAC;AAEH,KAAK,cAAc"}
|
package/es/icon/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { Icon } from "./icon.js";
|
package/es/icon/index.js
DELETED
package/es/icon/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/icon/index.tsx"],"sourcesContent":["import Icon from './icon';\n\nexport default Icon;\n"],"mappings":";;AAEA,IAAA,eAAe"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
@use '../../style/variables' as *;
|
|
2
|
-
@use '../../style/font' as *;
|
|
3
|
-
|
|
4
|
-
.#{$prefix}-icon {
|
|
5
|
-
font-family: 'tiny' !important;
|
|
6
|
-
line-height: 1;
|
|
7
|
-
font-size: 16px;
|
|
8
|
-
font-style: normal;
|
|
9
|
-
-webkit-font-smoothing: antialiased;
|
|
10
|
-
-moz-osx-font-smoothing: grayscale;
|
|
11
|
-
|
|
12
|
-
&_spin:before {
|
|
13
|
-
display: inline-block;
|
|
14
|
-
animation: ty-rotate 1s linear infinite;
|
|
15
|
-
}
|
|
16
|
-
}
|