@tiny-design/react 1.0.4 → 1.0.10

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.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/es/alert/style/_index.scss +0 -0
  4. package/es/alert/style/_mixin.scss +0 -0
  5. package/es/avatar/style/_index.scss +0 -0
  6. package/es/back-top/style/_index.scss +0 -0
  7. package/es/badge/style/_index.scss +0 -0
  8. package/es/breadcrumb/style/_index.scss +0 -0
  9. package/es/button/style/_index.scss +0 -0
  10. package/es/button/style/_mixin.scss +0 -0
  11. package/es/button/style/index.css +1 -1
  12. package/es/carousel/style/_index.scss +0 -0
  13. package/es/checkbox/style/_index.scss +0 -0
  14. package/es/collapse/style/_index.scss +0 -0
  15. package/es/date-picker/style/_index.scss +0 -0
  16. package/es/divider/style/_index.scss +0 -0
  17. package/es/empty/style/_index.scss +0 -0
  18. package/es/flip/style/_index.scss +0 -0
  19. package/es/form/style/_index.scss +0 -0
  20. package/es/grid/style/_index.scss +0 -0
  21. package/es/index.d.ts +2 -2
  22. package/es/index.js +2 -2
  23. package/es/input/style/_index.scss +0 -0
  24. package/es/input/style/_mixin.scss +0 -0
  25. package/es/input-number/style/_index.scss +0 -0
  26. package/es/input-password/style/_index.scss +0 -0
  27. package/es/layout/sidebar.js +2 -5
  28. package/es/layout/sidebar.js.map +1 -1
  29. package/es/layout/style/_index.scss +0 -0
  30. package/es/list/list.js.map +1 -1
  31. package/es/loader/style/_index.scss +0 -0
  32. package/es/loading-bar/style/_index.scss +0 -0
  33. package/es/message/style/_index.scss +0 -0
  34. package/es/modal/style/_index.scss +0 -0
  35. package/es/native-select/style/_index.scss +0 -0
  36. package/es/notification/style/_index.scss +0 -0
  37. package/es/overlay/style/_index.scss +0 -0
  38. package/es/pop-confirm/style/_index.scss +0 -0
  39. package/es/popover/style/_index.scss +0 -0
  40. package/es/popup/style/_index.scss +0 -0
  41. package/es/progress/style/_index.scss +0 -0
  42. package/es/radio/style/_index.scss +0 -0
  43. package/es/rate/rate.js +2 -5
  44. package/es/rate/rate.js.map +1 -1
  45. package/es/rate/style/_index.scss +0 -0
  46. package/es/split/style/_index.scss +0 -0
  47. package/es/style/_component.scss +1 -1
  48. package/es/style/base.css +12 -3
  49. package/es/style/index.scss +0 -0
  50. package/es/switch/style/_index.scss +0 -0
  51. package/es/switch/style/_mixin.scss +0 -0
  52. package/es/switch/style/index.css +3 -3
  53. package/es/table/table.js.map +1 -1
  54. package/es/tag/style/_index.scss +0 -0
  55. package/es/textarea/style/_index.scss +0 -0
  56. package/es/time-picker/style/_index.scss +0 -0
  57. package/es/timeline/style/_index.scss +0 -0
  58. package/es/tooltip/style/_index.scss +0 -0
  59. package/es/typography/heading.d.ts +2 -1
  60. package/es/typography/heading.js +11 -18
  61. package/es/typography/heading.js.map +1 -1
  62. package/es/typography/style/_index.scss +0 -18
  63. package/es/typography/style/index.css +0 -13
  64. package/es/typography/text.d.ts +2 -1
  65. package/es/typography/text.js +4 -2
  66. package/es/typography/text.js.map +1 -1
  67. package/es/typography/types.d.ts +1 -1
  68. package/es/with-spin/index.d.ts +1 -0
  69. package/es/with-spin/style/_index.scss +5 -0
  70. package/es/with-spin/style/index.css +3 -0
  71. package/es/with-spin/with-spin.d.ts +9 -0
  72. package/es/with-spin/with-spin.js +20 -0
  73. package/es/with-spin/with-spin.js.map +1 -0
  74. package/lib/alert/style/_index.scss +0 -0
  75. package/lib/alert/style/_mixin.scss +0 -0
  76. package/lib/avatar/style/_index.scss +0 -0
  77. package/lib/back-top/style/_index.scss +0 -0
  78. package/lib/badge/style/_index.scss +0 -0
  79. package/lib/breadcrumb/style/_index.scss +0 -0
  80. package/lib/button/style/_index.scss +0 -0
  81. package/lib/button/style/_mixin.scss +0 -0
  82. package/lib/button/style/index.css +1 -1
  83. package/lib/carousel/style/_index.scss +0 -0
  84. package/lib/checkbox/style/_index.scss +0 -0
  85. package/lib/collapse/style/_index.scss +0 -0
  86. package/lib/date-picker/style/_index.scss +0 -0
  87. package/lib/divider/style/_index.scss +0 -0
  88. package/lib/empty/style/_index.scss +0 -0
  89. package/lib/flip/style/_index.scss +0 -0
  90. package/lib/form/style/_index.scss +0 -0
  91. package/lib/grid/style/_index.scss +0 -0
  92. package/lib/index.d.ts +2 -2
  93. package/lib/index.js +96 -96
  94. package/lib/input/style/_index.scss +0 -0
  95. package/lib/input/style/_mixin.scss +0 -0
  96. package/lib/input-number/style/_index.scss +0 -0
  97. package/lib/input-password/style/_index.scss +0 -0
  98. package/lib/layout/sidebar.js +2 -5
  99. package/lib/layout/sidebar.js.map +1 -1
  100. package/lib/layout/style/_index.scss +0 -0
  101. package/lib/list/list.js.map +1 -1
  102. package/lib/loader/style/_index.scss +0 -0
  103. package/lib/loading-bar/style/_index.scss +0 -0
  104. package/lib/message/style/_index.scss +0 -0
  105. package/lib/modal/style/_index.scss +0 -0
  106. package/lib/native-select/style/_index.scss +0 -0
  107. package/lib/notification/style/_index.scss +0 -0
  108. package/lib/overlay/style/_index.scss +0 -0
  109. package/lib/pop-confirm/style/_index.scss +0 -0
  110. package/lib/popover/style/_index.scss +0 -0
  111. package/lib/popup/style/_index.scss +0 -0
  112. package/lib/progress/style/_index.scss +0 -0
  113. package/lib/radio/style/_index.scss +0 -0
  114. package/lib/rate/rate.js +2 -5
  115. package/lib/rate/rate.js.map +1 -1
  116. package/lib/rate/style/_index.scss +0 -0
  117. package/lib/split/style/_index.scss +0 -0
  118. package/lib/style/_component.scss +1 -1
  119. package/lib/style/base.css +12 -3
  120. package/lib/style/index.scss +0 -0
  121. package/lib/switch/style/_index.scss +0 -0
  122. package/lib/switch/style/_mixin.scss +0 -0
  123. package/lib/switch/style/index.css +3 -3
  124. package/lib/table/table.js.map +1 -1
  125. package/lib/tag/style/_index.scss +0 -0
  126. package/lib/textarea/style/_index.scss +0 -0
  127. package/lib/time-picker/style/_index.scss +0 -0
  128. package/lib/timeline/style/_index.scss +0 -0
  129. package/lib/tooltip/style/_index.scss +0 -0
  130. package/lib/typography/heading.d.ts +2 -1
  131. package/lib/typography/heading.js +11 -18
  132. package/lib/typography/heading.js.map +1 -1
  133. package/lib/typography/style/_index.scss +0 -18
  134. package/lib/typography/style/index.css +0 -13
  135. package/lib/typography/text.d.ts +2 -1
  136. package/lib/typography/text.js +4 -2
  137. package/lib/typography/text.js.map +1 -1
  138. package/lib/typography/types.d.ts +1 -1
  139. package/lib/with-spin/style/_index.scss +5 -0
  140. package/lib/with-spin/style/index.css +3 -0
  141. package/lib/with-spin/with-spin.d.ts +9 -0
  142. package/lib/with-spin/with-spin.js +22 -0
  143. package/lib/with-spin/with-spin.js.map +1 -0
  144. package/package.json +19 -15
  145. package/es/icon/icon.d.ts +0 -8
  146. package/es/icon/icon.js +0 -25
  147. package/es/icon/icon.js.map +0 -1
  148. package/es/icon/index.d.ts +0 -1
  149. package/es/icon/index.js +0 -9
  150. package/es/icon/index.js.map +0 -1
  151. package/es/icon/style/_index.scss +0 -16
  152. package/es/icon/style/index.css +0 -987
  153. package/es/icon/types.d.ts +0 -15
  154. package/lib/icon/icon.d.ts +0 -8
  155. package/lib/icon/icon.js +0 -28
  156. package/lib/icon/icon.js.map +0 -1
  157. package/lib/icon/index.js +0 -8
  158. package/lib/icon/index.js.map +0 -1
  159. package/lib/icon/style/_index.scss +0 -16
  160. package/lib/icon/style/index.css +0 -987
  161. package/lib/icon/types.d.ts +0 -15
  162. /package/es/{icon → with-spin}/style/index.d.ts +0 -0
  163. /package/es/{icon → with-spin}/style/index.js +0 -0
  164. /package/lib/{icon → with-spin}/style/index.d.ts +0 -0
  165. /package/lib/{icon → with-spin}/style/index.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"table.js","names":["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) => handlePageCh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,GAAG,UAAU,gBAAgB,GACtD,GAAG,UAAU,wBAAwB,cAAc,IAAI,aAAa,cAAc,UACpF,CAAC;mBAAE;SAAQ,CAAA,EACZ,oBAAC,QAAD;SAAM,WAAW,WAAW,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,oBAAC,SAAD;KAAO,WAAW,GAAG,UAAU;eAC5B,aAAa;KACR,CAAA,CACF;;GACJ,CAAA,EACL,kBACC,oBAACA,oBAAD;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":["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,OAAO;CACvD,MAAM,MAAO,OAAe;AAC5B,QAAO,QAAQ,KAAA,IAAY,MAAM;;AAGnC,MAAM,YAAgB,QAAW,cAA2B;AAC1D,QAAQ,OAAe;;AAGzB,MAAM,QAAQ,MAAM,YAAwC,OAAO,QAAQ;CACzE,MAAM,EACJ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AAO;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"}
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,7 +1,8 @@
1
1
  import { HeadingProps } from "./types.js";
2
+ import React from "react";
2
3
 
3
4
  //#region src/typography/heading.d.ts
4
- declare const Heading: (props: HeadingProps) => JSX.Element | null;
5
+ declare const Heading: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
5
6
  //#endregion
6
7
  export { Heading };
7
8
  //# sourceMappingURL=heading.d.ts.map
@@ -2,29 +2,22 @@ import { ConfigContext } from "../config-provider/config-context.js";
2
2
  import { getPrefixCls } from "../_utils/general.js";
3
3
  import React, { useContext } from "react";
4
4
  import classNames from "classnames";
5
- import { jsx } from "react/jsx-runtime";
6
5
  //#region src/typography/heading.tsx
7
- const headingGenerator = (htmlType, displayName) => {
8
- const Component = React.forwardRef((props, ref) => {
9
- const { prefixCls: customisedCls, className, children, ...otherProps } = props;
10
- const cls = classNames(getPrefixCls("typography", useContext(ConfigContext).prefixCls, customisedCls), className);
11
- return React.createElement(htmlType, {
12
- ...otherProps,
13
- ref,
14
- className: cls
15
- }, children);
16
- });
17
- Component.displayName = displayName;
18
- return Component;
19
- };
20
- const Heading = (props) => {
21
- const { level = 1, ...otherProps } = props;
6
+ const Heading = React.forwardRef((props, ref) => {
7
+ const { level = 1, prefixCls: customisedCls, className, children, ...otherProps } = props;
8
+ const prefixCls = getPrefixCls("typography", useContext(ConfigContext).prefixCls, customisedCls);
22
9
  if (level < 1 || level > 6) {
23
10
  console.warn("The heading level parameter is invalid.");
24
11
  return null;
25
12
  }
26
- return /* @__PURE__ */ jsx(headingGenerator(`h${level}`, `H${level}`), { ...otherProps });
27
- };
13
+ const cls = classNames(prefixCls, className);
14
+ return React.createElement(`h${level}`, {
15
+ ...otherProps,
16
+ ref,
17
+ className: cls
18
+ }, children);
19
+ });
20
+ Heading.displayName = "Heading";
28
21
  //#endregion
29
22
  export { Heading as default };
30
23
 
@@ -1 +1 @@
1
- {"version":3,"file":"heading.js","names":[],"sources":["../../src/typography/heading.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { HeadingProps } from './types';\n\nconst headingGenerator = (htmlType: string, displayName: string) => {\n const Component = React.forwardRef<HTMLHeadingElement, HeadingProps>(\n (props: HeadingProps, ref): JSX.Element => {\n const { prefixCls: customisedCls, className, children, ...otherProps } = props;\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);\n const cls = classNames(prefixCls, className);\n\n return React.createElement(\n htmlType,\n {\n ...otherProps,\n ref,\n className: cls,\n },\n children\n );\n }\n );\n\n Component.displayName = displayName;\n\n return Component;\n};\n\nconst Heading = (props: HeadingProps): JSX.Element | null => {\n const { level = 1, ...otherProps } = props;\n if (level < 1 || level > 6) {\n console.warn('The heading level parameter is invalid.');\n return null;\n }\n const Component = headingGenerator(`h${level}`, `H${level}`);\n return <Component {...otherProps} />;\n};\n\nexport default Heading;\n"],"mappings":";;;;;;AAMA,MAAM,oBAAoB,UAAkB,gBAAwB;CAClE,MAAM,YAAY,MAAM,YACrB,OAAqB,QAAqB;EACzC,MAAM,EAAE,WAAW,eAAe,WAAW,UAAU,GAAG,eAAe;EAGzE,MAAM,MAAM,WADM,aAAa,cADT,WAAW,cAAc,CACY,WAAW,cAAc,EAClD,UAAU;AAE5C,SAAO,MAAM,cACX,UACA;GACE,GAAG;GACH;GACA,WAAW;GACZ,EACD,SACD;GAEJ;AAED,WAAU,cAAc;AAExB,QAAO;;AAGT,MAAM,WAAW,UAA4C;CAC3D,MAAM,EAAE,QAAQ,GAAG,GAAG,eAAe;AACrC,KAAI,QAAQ,KAAK,QAAQ,GAAG;AAC1B,UAAQ,KAAK,0CAA0C;AACvD,SAAO;;AAGT,QAAO,oBADW,iBAAiB,IAAI,SAAS,IAAI,QAAQ,EACrD,EAAW,GAAI,YAAc,CAAA"}
1
+ {"version":3,"file":"heading.js","names":[],"sources":["../../src/typography/heading.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { HeadingProps } from './types';\n\nconst Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(\n (props, ref) => {\n const { level = 1, prefixCls: customisedCls, className, children, ...otherProps } = props;\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);\n\n if (level < 1 || level > 6) {\n console.warn('The heading level parameter is invalid.');\n return null;\n }\n const cls = classNames(prefixCls, className);\n\n return React.createElement(\n `h${level}`,\n {\n ...otherProps,\n ref,\n className: cls,\n },\n children\n );\n }\n);\n\nHeading.displayName = 'Heading';\n\nexport default Heading;\n"],"mappings":";;;;;AAMA,MAAM,UAAU,MAAM,YACnB,OAAO,QAAQ;CACd,MAAM,EAAE,QAAQ,GAAG,WAAW,eAAe,WAAW,UAAU,GAAG,eAAe;CAEpF,MAAM,YAAY,aAAa,cADT,WAAW,cAAc,CACY,WAAW,cAAc;AAEpF,KAAI,QAAQ,KAAK,QAAQ,GAAG;AAC1B,UAAQ,KAAK,0CAA0C;AACvD,SAAO;;CAET,MAAM,MAAM,WAAW,WAAW,UAAU;AAE5C,QAAO,MAAM,cACX,IAAI,SACJ;EACE,GAAG;EACH;EACA,WAAW;EACZ,EACD,SACD;EAEJ;AAED,QAAQ,cAAc"}
@@ -4,8 +4,6 @@ $tp-prefix: #{$prefix}-typography;
4
4
 
5
5
  .#{$tp-prefix} {
6
6
  box-sizing: border-box;
7
- font-family: $font-family;
8
-
9
7
  & + h1.#{$tp-prefix},
10
8
  & + h2.#{$tp-prefix},
11
9
  & + h3.#{$tp-prefix},
@@ -46,22 +44,6 @@ $tp-prefix: #{$prefix}-typography;
46
44
  background-color: var(--ty-typography-mark-bg);
47
45
  }
48
46
 
49
- u {
50
- text-decoration: underline;
51
- }
52
-
53
- del {
54
- text-decoration: line-through;
55
- }
56
-
57
- strong {
58
- font-weight: 600;
59
- }
60
-
61
- i {
62
- font-style: italic;
63
- }
64
-
65
47
  sup {
66
48
  vertical-align: super;
67
49
  }
@@ -1,6 +1,5 @@
1
1
  .ty-typography {
2
2
  box-sizing: border-box;
3
- font-family: -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue", arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
4
3
  }
5
4
  .ty-typography + h1.ty-typography, .ty-typography + h2.ty-typography, .ty-typography + h3.ty-typography, .ty-typography + h4.ty-typography {
6
5
  margin-top: 1.2em;
@@ -31,18 +30,6 @@
31
30
  padding: 0;
32
31
  background-color: var(--ty-typography-mark-bg);
33
32
  }
34
- .ty-typography u {
35
- text-decoration: underline;
36
- }
37
- .ty-typography del {
38
- text-decoration: line-through;
39
- }
40
- .ty-typography strong {
41
- font-weight: 600;
42
- }
43
- .ty-typography i {
44
- font-style: italic;
45
- }
46
33
  .ty-typography sup {
47
34
  vertical-align: super;
48
35
  }
@@ -1,7 +1,8 @@
1
1
  import { TextProps } from "./types.js";
2
+ import React from "react";
2
3
 
3
4
  //#region src/typography/text.d.ts
4
- declare const Text: (props: TextProps) => JSX.Element;
5
+ declare const Text: React.ForwardRefExoticComponent<Omit<TextProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
5
6
  //#endregion
6
7
  export { Text };
7
8
  //# sourceMappingURL=text.d.ts.map
@@ -8,7 +8,7 @@ const tagGenerator = (isRequired, tag, element) => {
8
8
  if (!isRequired) return element;
9
9
  return React.createElement(tag, {}, element);
10
10
  };
11
- const Text = (props) => {
11
+ const Text = React.forwardRef((props, ref) => {
12
12
  const { code = false, del = false, underline = false, strong = false, italic = false, mark = false, sub = false, sup = false, className, children, prefixCls: customisedCls, ...otherProps } = props;
13
13
  let Node = tagGenerator(code, "code", children);
14
14
  Node = tagGenerator(del, "del", Node);
@@ -21,10 +21,12 @@ const Text = (props) => {
21
21
  const cls = classNames(className, getPrefixCls("typography", useContext(ConfigContext).prefixCls, customisedCls));
22
22
  return /* @__PURE__ */ jsx("span", {
23
23
  ...otherProps,
24
+ ref,
24
25
  className: cls,
25
26
  children: Node
26
27
  });
27
- };
28
+ });
29
+ Text.displayName = "Text";
28
30
  //#endregion
29
31
  export { Text as default };
30
32
 
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":[],"sources":["../../src/typography/text.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { TextProps } from './types';\n\nconst tagGenerator = (\n isRequired: boolean,\n tag: string,\n element: React.ReactNode\n): React.ReactNode => {\n if (!isRequired) return element;\n return React.createElement(tag, {}, element);\n};\n\nconst Text = (props: TextProps): JSX.Element => {\n const {\n code = false,\n del = false,\n underline = false,\n strong = false,\n italic = false,\n mark = false,\n sub = false,\n sup = false,\n className,\n children,\n prefixCls: customisedCls,\n ...otherProps\n } = props;\n\n let Node = tagGenerator(code, 'code', children);\n Node = tagGenerator(del, 'del', Node);\n Node = tagGenerator(underline, 'u', Node);\n Node = tagGenerator(strong, 'strong', Node);\n Node = tagGenerator(italic, 'i', Node);\n Node = tagGenerator(mark, 'mark', Node);\n Node = tagGenerator(sub, 'sub', Node);\n Node = tagGenerator(sup, 'sup', Node);\n\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);\n const cls = classNames(className, prefixCls);\n\n return (\n <span {...otherProps} className={cls}>\n {Node}\n </span>\n );\n};\n\nexport default Text;\n"],"mappings":";;;;;;AAMA,MAAM,gBACJ,YACA,KACA,YACoB;AACpB,KAAI,CAAC,WAAY,QAAO;AACxB,QAAO,MAAM,cAAc,KAAK,EAAE,EAAE,QAAQ;;AAG9C,MAAM,QAAQ,UAAkC;CAC9C,MAAM,EACJ,OAAO,OACP,MAAM,OACN,YAAY,OACZ,SAAS,OACT,SAAS,OACT,OAAO,OACP,MAAM,OACN,MAAM,OACN,WACA,UACA,WAAW,eACX,GAAG,eACD;CAEJ,IAAI,OAAO,aAAa,MAAM,QAAQ,SAAS;AAC/C,QAAO,aAAa,KAAK,OAAO,KAAK;AACrC,QAAO,aAAa,WAAW,KAAK,KAAK;AACzC,QAAO,aAAa,QAAQ,UAAU,KAAK;AAC3C,QAAO,aAAa,QAAQ,KAAK,KAAK;AACtC,QAAO,aAAa,MAAM,QAAQ,KAAK;AACvC,QAAO,aAAa,KAAK,OAAO,KAAK;AACrC,QAAO,aAAa,KAAK,OAAO,KAAK;CAIrC,MAAM,MAAM,WAAW,WADL,aAAa,cADT,WAAW,cAAc,CACY,WAAW,cAAc,CACxC;AAE5C,QACE,oBAAC,QAAD;EAAM,GAAI;EAAY,WAAW;YAC9B;EACI,CAAA"}
1
+ {"version":3,"file":"text.js","names":[],"sources":["../../src/typography/text.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { TextProps } from './types';\n\nconst tagGenerator = (\n isRequired: boolean,\n tag: string,\n element: React.ReactNode\n): React.ReactNode => {\n if (!isRequired) return element;\n return React.createElement(tag, {}, element);\n};\n\nconst Text = React.forwardRef<HTMLSpanElement, TextProps>(\n (props, ref) => {\n const {\n code = false,\n del = false,\n underline = false,\n strong = false,\n italic = false,\n mark = false,\n sub = false,\n sup = false,\n className,\n children,\n prefixCls: customisedCls,\n ...otherProps\n } = props;\n\n let Node = tagGenerator(code, 'code', children);\n Node = tagGenerator(del, 'del', Node);\n Node = tagGenerator(underline, 'u', Node);\n Node = tagGenerator(strong, 'strong', Node);\n Node = tagGenerator(italic, 'i', Node);\n Node = tagGenerator(mark, 'mark', Node);\n Node = tagGenerator(sub, 'sub', Node);\n Node = tagGenerator(sup, 'sup', Node);\n\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('typography', configContext.prefixCls, customisedCls);\n const cls = classNames(className, prefixCls);\n\n return (\n <span {...otherProps} ref={ref} className={cls}>\n {Node}\n </span>\n );\n }\n);\n\nText.displayName = 'Text';\n\nexport default Text;\n"],"mappings":";;;;;;AAMA,MAAM,gBACJ,YACA,KACA,YACoB;AACpB,KAAI,CAAC,WAAY,QAAO;AACxB,QAAO,MAAM,cAAc,KAAK,EAAE,EAAE,QAAQ;;AAG9C,MAAM,OAAO,MAAM,YAChB,OAAO,QAAQ;CACd,MAAM,EACJ,OAAO,OACP,MAAM,OACN,YAAY,OACZ,SAAS,OACT,SAAS,OACT,OAAO,OACP,MAAM,OACN,MAAM,OACN,WACA,UACA,WAAW,eACX,GAAG,eACD;CAEJ,IAAI,OAAO,aAAa,MAAM,QAAQ,SAAS;AAC/C,QAAO,aAAa,KAAK,OAAO,KAAK;AACrC,QAAO,aAAa,WAAW,KAAK,KAAK;AACzC,QAAO,aAAa,QAAQ,UAAU,KAAK;AAC3C,QAAO,aAAa,QAAQ,KAAK,KAAK;AACtC,QAAO,aAAa,MAAM,QAAQ,KAAK;AACvC,QAAO,aAAa,KAAK,OAAO,KAAK;AACrC,QAAO,aAAa,KAAK,OAAO,KAAK;CAIrC,MAAM,MAAM,WAAW,WADL,aAAa,cADT,WAAW,cAAc,CACY,WAAW,cAAc,CACxC;AAE5C,QACE,oBAAC,QAAD;EAAM,GAAI;EAAiB;EAAK,WAAW;YACxC;EACI,CAAA;EAGZ;AAED,KAAK,cAAc"}
@@ -9,7 +9,7 @@ interface ParagraphProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElem
9
9
  children?: React.ReactNode;
10
10
  }
11
11
  interface HeadingProps extends BaseProps, React.PropsWithRef<React.HTMLAttributes<HTMLHeadingElement>> {
12
- level?: number;
12
+ level?: 1 | 2 | 3 | 4 | 5 | 6;
13
13
  children?: React.ReactNode;
14
14
  }
15
15
  interface TextProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElements['span']> {
@@ -0,0 +1 @@
1
+ import { withSpin } from "./with-spin.js";
@@ -0,0 +1,5 @@
1
+ @use '../../style/variables' as *;
2
+
3
+ .#{$prefix}-icon-spin {
4
+ animation: ty-rotate 1s linear infinite;
5
+ }
@@ -0,0 +1,3 @@
1
+ .ty-icon-spin {
2
+ animation: ty-rotate 1s linear infinite;
3
+ }
@@ -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,20 @@
1
+ import { forwardRef } from "react";
2
+ import classNames from "classnames";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/with-spin/with-spin.tsx
5
+ function withSpin(Icon) {
6
+ const SpinIcon = forwardRef((props, ref) => {
7
+ const { className, ...rest } = props;
8
+ return /* @__PURE__ */ jsx(Icon, {
9
+ ref,
10
+ className: classNames("ty-icon-spin", className),
11
+ ...rest
12
+ });
13
+ });
14
+ SpinIcon.displayName = `withSpin(${Icon.displayName || "Icon"})`;
15
+ return SpinIcon;
16
+ }
17
+ //#endregion
18
+ export { withSpin };
19
+
20
+ //# 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,WAAW,YAAsC,OAAO,QAAQ;EACpE,MAAM,EAAE,WAAW,GAAG,SAAS;AAE/B,SACE,oBAAC,MAAD;GACO;GACL,WAAW,WAAW,gBAAgB,UAAU;GAChD,GAAI;GACJ,CAAA;GAEJ;AAGF,UAAS,cAAc,YADV,KAAK,eAAe,OACO;AAExC,QAAO"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -51,7 +51,7 @@
51
51
  height: 1em;
52
52
  position: relative;
53
53
  border-width: 2px;
54
- border-color: currentColor currentColor transparent transparent;
54
+ border-color: currentcolor currentcolor transparent transparent;
55
55
  border-style: solid;
56
56
  border-radius: 50%;
57
57
  animation: ty-rotate-reverse 600ms infinite linear;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/lib/index.d.ts CHANGED
@@ -28,7 +28,6 @@ import { Empty } from "./empty/empty.js";
28
28
  import { Flex } from "./flex/flex.js";
29
29
  import { DefaultFlip } from "./flip/index.js";
30
30
  import { DefaultForm } from "./form/index.js";
31
- import { Icon } from "./icon/icon.js";
32
31
  import { Image } from "./image/image.js";
33
32
  import { DefaultInput } from "./input/index.js";
34
33
  import { InputNumber } from "./input-number/input-number.js";
@@ -81,8 +80,9 @@ import { Tree } from "./tree/tree.js";
81
80
  import { DefaultTypo } from "./typography/index.js";
82
81
  import { Upload } from "./upload/upload.js";
83
82
  import { withLocale } from "./intl-provider/with-locale.js";
83
+ import { withSpin } from "./with-spin/with-spin.js";
84
84
  import { en_US } from "./locale/en_US.js";
85
85
  import { zh_CN } from "./locale/zh_CN.js";
86
86
  import { useLocale } from "./_utils/use-locale.js";
87
87
  import { ThemeMode, useTheme } from "./_utils/use-theme.js";
88
- export { Alert, DefaultAnchor as Anchor, AspectRatio, AutoComplete, DefaultAvatar as Avatar, BackTop, Badge, DefaultBreadcrumb as Breadcrumb, DefaultButton as Button, Calendar, DefaultCard as Card, DefaultCarousel as Carousel, Cascader, DefaultCheckbox as Checkbox, Col, DefaultCollapse as Collapse, ColorPicker, ConfigProvider, CopyToClipboard, Countdown, DatePicker, DefaultDesc as Descriptions, Divider, Drawer, Dropdown, Empty, Flex, DefaultFlip as Flip, DefaultForm as Form, Icon, Image, DefaultInput as Input, InputNumber, InputPassword, IntlProvider, Keyboard, DefaultLayout as Layout, Link, DefaultList as List, Loader, _default as LoadingBar, type Locale, DefaultMenu as Menu, messageContainer as Message, ModalWithContext as Modal, DefaultSelect as NativeSelect, notificationContainer as Notification, Overlay, Pagination, PopConfirm, Popover, Progress, DefaultRadio as Radio, Rate, Result, Row, ScrollIndicator, Segmented, DefaultSelect$1 as Select, Skeleton, Slider, Space, DefaultSpeedDial as SpeedDial, Split, SplitButton, Statistic, DefaultSteps as Steps, Sticky, StrengthIndicator, Switch, Table, DefaultTabs as Tabs, DefaultTag as Tag, Textarea, type ThemeMode, TimePicker, DefaultTimeline as Timeline, Tooltip, Transfer, Transition, Tree, DefaultTypo as Typography, Upload, en_US, useLocale, useTheme, withLocale, zh_CN };
88
+ export { Alert, DefaultAnchor as Anchor, AspectRatio, AutoComplete, DefaultAvatar as Avatar, BackTop, Badge, DefaultBreadcrumb as Breadcrumb, DefaultButton as Button, Calendar, DefaultCard as Card, DefaultCarousel as Carousel, Cascader, DefaultCheckbox as Checkbox, Col, DefaultCollapse as Collapse, ColorPicker, ConfigProvider, CopyToClipboard, Countdown, DatePicker, DefaultDesc as Descriptions, Divider, Drawer, Dropdown, Empty, Flex, DefaultFlip as Flip, DefaultForm as Form, Image, DefaultInput as Input, InputNumber, InputPassword, IntlProvider, Keyboard, DefaultLayout as Layout, Link, DefaultList as List, Loader, _default as LoadingBar, type Locale, DefaultMenu as Menu, messageContainer as Message, ModalWithContext as Modal, DefaultSelect as NativeSelect, notificationContainer as Notification, Overlay, Pagination, PopConfirm, Popover, Progress, DefaultRadio as Radio, Rate, Result, Row, ScrollIndicator, Segmented, DefaultSelect$1 as Select, Skeleton, Slider, Space, DefaultSpeedDial as SpeedDial, Split, SplitButton, Statistic, DefaultSteps as Steps, Sticky, StrengthIndicator, Switch, Table, DefaultTabs as Tabs, DefaultTag as Tag, Textarea, type ThemeMode, TimePicker, DefaultTimeline as Timeline, Tooltip, Transfer, Transition, Tree, DefaultTypo as Typography, Upload, en_US, useLocale, useTheme, withLocale, withSpin, zh_CN };