@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.
- 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/heading.d.ts +2 -1
- package/es/typography/heading.js +11 -18
- package/es/typography/heading.js.map +1 -1
- package/es/typography/style/_index.scss +0 -18
- package/es/typography/style/index.css +0 -13
- package/es/typography/text.d.ts +2 -1
- package/es/typography/text.js +4 -2
- package/es/typography/text.js.map +1 -1
- package/es/typography/types.d.ts +1 -1
- 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/heading.d.ts +2 -1
- package/lib/typography/heading.js +11 -18
- package/lib/typography/heading.js.map +1 -1
- package/lib/typography/style/_index.scss +0 -18
- package/lib/typography/style/index.css +0 -13
- package/lib/typography/text.d.ts +2 -1
- package/lib/typography/text.js +4 -2
- package/lib/typography/text.js.map +1 -1
- package/lib/typography/types.d.ts +1 -1
- 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/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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GAAG,UAAU,mBAAmB,CAAC,CAAC,IAAI;SACtC,GAAG,UAAU,eAAe,IAAI,UAAU,IAAI;QAChD,CAAC;OAKE,OAAO,EAAE,OAAO,IAAI,OAAO;OAC3B,eAAe,WAAW,IAAI;iBAJhC,CAME,iBAAA,GAAA,kBAAA,KAAC,QAAD;QAAM,WAAW,GAAG,UAAU;kBAAe,IAAI;QAAa,CAAA,EAC7D,IAAI,UACH,iBAAA,GAAA,kBAAA,MAAC,QAAD;QAAM,WAAW,GAAG,UAAU;kBAA9B,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,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;CAC/C,MAAM,YAAYC,gBAAAA,aAAa,SAAS,cAAc,WAAW,cAAc;CAC/E,MAAM,YAAY,QAAQ,cAAc,iBAAiB;AAEzD,KAAI,WAAW,UAAU,KACvB,SAAQ,KAAK,uEAAuE;CAGtF,MAAM,YAAY,WAAW,UAAU;CAGvC,MAAM,CAAC,WAAW,iBAAA,GAAA,MAAA,WAA8C;CAChE,MAAM,CAAC,WAAW,iBAAA,GAAA,MAAA,UAAoC,KAAK;CAG3D,MAAM,CAAC,aAAa,mBAAA,GAAA,MAAA,UAA2B,EAAE;CACjD,MAAM,WAAW,cAAc,WAAW,WAAW,WAAW,WAAW;CAG3E,MAAM,CAAC,cAAc,oBAAA,GAAA,MAAA,UACnB,cAAc,mBAAmB,EAAE,CACpC;AA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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"}
|
|
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:
|
|
5
|
+
declare const Heading: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { Heading };
|
|
7
8
|
//# sourceMappingURL=heading.d.ts.map
|
|
@@ -5,29 +5,22 @@ let react = require("react");
|
|
|
5
5
|
react = require_runtime.__toESM(react);
|
|
6
6
|
let classnames = require("classnames");
|
|
7
7
|
classnames = require_runtime.__toESM(classnames);
|
|
8
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
8
|
//#region src/typography/heading.tsx
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const cls = (0, classnames.default)(require_general.getPrefixCls("typography", (0, react.useContext)(require_config_context.ConfigContext).prefixCls, customisedCls), className);
|
|
14
|
-
return react.default.createElement(htmlType, {
|
|
15
|
-
...otherProps,
|
|
16
|
-
ref,
|
|
17
|
-
className: cls
|
|
18
|
-
}, children);
|
|
19
|
-
});
|
|
20
|
-
Component.displayName = displayName;
|
|
21
|
-
return Component;
|
|
22
|
-
};
|
|
23
|
-
const Heading = (props) => {
|
|
24
|
-
const { level = 1, ...otherProps } = props;
|
|
9
|
+
const Heading = react.default.forwardRef((props, ref) => {
|
|
10
|
+
const { level = 1, prefixCls: customisedCls, className, children, ...otherProps } = props;
|
|
11
|
+
const prefixCls = require_general.getPrefixCls("typography", (0, react.useContext)(require_config_context.ConfigContext).prefixCls, customisedCls);
|
|
25
12
|
if (level < 1 || level > 6) {
|
|
26
13
|
console.warn("The heading level parameter is invalid.");
|
|
27
14
|
return null;
|
|
28
15
|
}
|
|
29
|
-
|
|
30
|
-
}
|
|
16
|
+
const cls = (0, classnames.default)(prefixCls, className);
|
|
17
|
+
return react.default.createElement(`h${level}`, {
|
|
18
|
+
...otherProps,
|
|
19
|
+
ref,
|
|
20
|
+
className: cls
|
|
21
|
+
}, children);
|
|
22
|
+
});
|
|
23
|
+
Heading.displayName = "Heading";
|
|
31
24
|
//#endregion
|
|
32
25
|
exports.default = Heading;
|
|
33
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.js","names":["React","getPrefixCls","ConfigContext"],"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
|
|
1
|
+
{"version":3,"file":"heading.js","names":["React","getPrefixCls","ConfigContext"],"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,UAAUA,MAAAA,QAAM,YACnB,OAAO,QAAQ;CACd,MAAM,EAAE,QAAQ,GAAG,WAAW,eAAe,WAAW,UAAU,GAAG,eAAe;CAEpF,MAAM,YAAYC,gBAAAA,aAAa,eAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACY,WAAW,cAAc;AAEpF,KAAI,QAAQ,KAAK,QAAQ,GAAG;AAC1B,UAAQ,KAAK,0CAA0C;AACvD,SAAO;;CAET,MAAM,OAAA,GAAA,WAAA,SAAiB,WAAW,UAAU;AAE5C,QAAOF,MAAAA,QAAM,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
|
}
|
package/lib/typography/text.d.ts
CHANGED
|
@@ -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:
|
|
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
|
package/lib/typography/text.js
CHANGED
|
@@ -11,7 +11,7 @@ const tagGenerator = (isRequired, tag, element) => {
|
|
|
11
11
|
if (!isRequired) return element;
|
|
12
12
|
return react.default.createElement(tag, {}, element);
|
|
13
13
|
};
|
|
14
|
-
const Text = (props) => {
|
|
14
|
+
const Text = react.default.forwardRef((props, ref) => {
|
|
15
15
|
const { code = false, del = false, underline = false, strong = false, italic = false, mark = false, sub = false, sup = false, className, children, prefixCls: customisedCls, ...otherProps } = props;
|
|
16
16
|
let Node = tagGenerator(code, "code", children);
|
|
17
17
|
Node = tagGenerator(del, "del", Node);
|
|
@@ -24,10 +24,12 @@ const Text = (props) => {
|
|
|
24
24
|
const cls = (0, classnames.default)(className, require_general.getPrefixCls("typography", (0, react.useContext)(require_config_context.ConfigContext).prefixCls, customisedCls));
|
|
25
25
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
26
26
|
...otherProps,
|
|
27
|
+
ref,
|
|
27
28
|
className: cls,
|
|
28
29
|
children: Node
|
|
29
30
|
});
|
|
30
|
-
};
|
|
31
|
+
});
|
|
32
|
+
Text.displayName = "Text";
|
|
31
33
|
//#endregion
|
|
32
34
|
exports.default = Text;
|
|
33
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":["React","getPrefixCls","ConfigContext"],"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
|
|
1
|
+
{"version":3,"file":"text.js","names":["React","getPrefixCls","ConfigContext"],"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,QAAOA,MAAAA,QAAM,cAAc,KAAK,EAAE,EAAE,QAAQ;;AAG9C,MAAM,OAAOA,MAAAA,QAAM,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,OAAA,GAAA,WAAA,SAAiB,WADLC,gBAAAA,aAAa,eAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACY,WAAW,cAAc,CACxC;AAE5C,QACE,iBAAA,GAAA,kBAAA,KAAC,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?:
|
|
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,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.10",
|
|
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.10",
|
|
59
|
+
"@tiny-design/tokens": "1.0.10"
|
|
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
|
-
}
|