@startupjs-ui/table 0.1.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [0.1.3](https://github.com/startupjs/startupjs-ui/compare/v0.1.2...v0.1.3) (2025-12-29)
7
+
8
+ **Note:** Version bump only for package @startupjs-ui/table
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.1.2](https://github.com/startupjs/startupjs-ui/compare/v0.1.1...v0.1.2) (2025-12-29)
15
+
16
+
17
+ ### Features
18
+
19
+ * add mdx and docs packages. Refactor docs to get rid of any @startupjs/ui usage and use startupjs-ui instead ([703c926](https://github.com/startupjs/startupjs-ui/commit/703c92636efb0421ffd11783f692fc892b74018f))
20
+ * **table:** refactor Table, Thead, Tbody, Tr, Th, Td components ([5994d66](https://github.com/startupjs/startupjs-ui/commit/5994d666d082c2aff3807a5892e035d8776763a2))
package/README.mdx ADDED
@@ -0,0 +1,225 @@
1
+ import { Sandbox } from '@startupjs-ui/docs'
2
+ import {
3
+ Table,
4
+ Thead,
5
+ Tbody,
6
+ Tr,
7
+ Th,
8
+ Td,
9
+ TablePropsJsonSchema,
10
+ TheadPropsJsonSchema,
11
+ TbodyPropsJsonSchema,
12
+ TrPropsJsonSchema,
13
+ ThPropsJsonSchema,
14
+ TdPropsJsonSchema
15
+ } from './index'
16
+ import Span from '@startupjs-ui/span'
17
+
18
+ # Table
19
+
20
+ The Table component arranges data in rows and columns. Use Thead for headers, Tbody for rows, and Tr/Th/Td for cells. Section and cell components accept Div props for layout and interaction.
21
+
22
+ ```jsx
23
+ import { Table, Thead, Tbody, Tr, Th, Td } from 'startupjs-ui'
24
+ ```
25
+
26
+ ## Simple example
27
+
28
+ ```jsx example
29
+ return (
30
+ <Table>
31
+ <Thead>
32
+ <Tr>
33
+ <Th>
34
+ <Span bold>First</Span>
35
+ </Th>
36
+ <Th>
37
+ <Span bold>Second</Span>
38
+ </Th>
39
+ </Tr>
40
+ </Thead>
41
+ <Tbody>
42
+ <Tr>
43
+ <Td>
44
+ <Span>First 1</Span>
45
+ </Td>
46
+ <Td>
47
+ <Span>Second 1</Span>
48
+ </Td>
49
+ </Tr>
50
+ <Tr>
51
+ <Td>
52
+ <Span>First 2</Span>
53
+ </Td>
54
+ <Td>
55
+ <Span>Second 3</Span>
56
+ </Td>
57
+ </Tr>
58
+ </Tbody>
59
+ </Table>
60
+ )
61
+ ```
62
+
63
+ ## Styling
64
+
65
+ ```jsx example
66
+ const tableStyle = {
67
+ backgroundColor: '#fff'
68
+ }
69
+
70
+ const hoverOptions = {
71
+ style: {
72
+ cursor: 'default'
73
+ },
74
+ hoverStyle: {
75
+ backgroundColor: '#ebf8fd'
76
+ },
77
+ activeStyle: {
78
+ opacity: 1,
79
+ backgroundColor: '#ebf8fd'
80
+ },
81
+ onPress: () => undefined
82
+ }
83
+
84
+ return (
85
+ <Table style={tableStyle}>
86
+ <Thead>
87
+ <Tr>
88
+ <Th {...hoverOptions}>
89
+ <Span bold italic>First</Span>
90
+ </Th>
91
+ <Th {...hoverOptions}>Second</Th>
92
+ <Th {...hoverOptions}>Third</Th>
93
+ </Tr>
94
+ </Thead>
95
+ <Tbody>
96
+ <Tr {...hoverOptions}>
97
+ <Td>
98
+ <Span italic>First 1</Span>
99
+ </Td>
100
+ <Td>Second 1</Td>
101
+ <Td>Third 1</Td>
102
+ </Tr>
103
+ <Tr {...hoverOptions}>
104
+ <Td>
105
+ <Span italic>First 2</Span>
106
+ </Td>
107
+ <Td>Second 2</Td>
108
+ <Td>Third 2</Td>
109
+ </Tr>
110
+ </Tbody>
111
+ </Table>
112
+ )
113
+ ```
114
+
115
+ ## Sandbox
116
+
117
+ ### Table
118
+
119
+ export const TableSandbox = (props) => (
120
+ <Table {...props}>
121
+ <Thead>
122
+ <Tr>
123
+ <Th>First</Th>
124
+ <Th>Second</Th>
125
+ </Tr>
126
+ </Thead>
127
+ <Tbody>
128
+ <Tr>
129
+ <Td>First 1</Td>
130
+ <Td>Second 1</Td>
131
+ </Tr>
132
+ </Tbody>
133
+ </Table>
134
+ )
135
+
136
+ <Sandbox
137
+ Component={TableSandbox}
138
+ propsJsonSchema={TablePropsJsonSchema}
139
+ />
140
+
141
+ ### Thead
142
+
143
+ export const TheadSandbox = (props) => (
144
+ <Table>
145
+ <Thead {...props}>
146
+ <Tr>
147
+ <Th>Header</Th>
148
+ </Tr>
149
+ </Thead>
150
+ </Table>
151
+ )
152
+
153
+ <Sandbox
154
+ Component={TheadSandbox}
155
+ propsJsonSchema={TheadPropsJsonSchema}
156
+ />
157
+
158
+ ### Tbody
159
+
160
+ export const TbodySandbox = (props) => (
161
+ <Table>
162
+ <Tbody {...props}>
163
+ <Tr>
164
+ <Td>Cell</Td>
165
+ </Tr>
166
+ </Tbody>
167
+ </Table>
168
+ )
169
+
170
+ <Sandbox
171
+ Component={TbodySandbox}
172
+ propsJsonSchema={TbodyPropsJsonSchema}
173
+ />
174
+
175
+ ### Tr
176
+
177
+ export const TrSandbox = (props) => (
178
+ <Table>
179
+ <Tbody>
180
+ <Tr {...props}>
181
+ <Td>Cell</Td>
182
+ <Td>Cell</Td>
183
+ </Tr>
184
+ </Tbody>
185
+ </Table>
186
+ )
187
+
188
+ <Sandbox
189
+ Component={TrSandbox}
190
+ propsJsonSchema={TrPropsJsonSchema}
191
+ />
192
+
193
+ ### Th
194
+
195
+ export const ThSandbox = (props) => (
196
+ <Table>
197
+ <Thead>
198
+ <Tr>
199
+ <Th {...props}>Header</Th>
200
+ </Tr>
201
+ </Thead>
202
+ </Table>
203
+ )
204
+
205
+ <Sandbox
206
+ Component={ThSandbox}
207
+ propsJsonSchema={ThPropsJsonSchema}
208
+ />
209
+
210
+ ### Td
211
+
212
+ export const TdSandbox = (props) => (
213
+ <Table>
214
+ <Tbody>
215
+ <Tr>
216
+ <Td {...props}>Cell</Td>
217
+ </Tr>
218
+ </Tbody>
219
+ </Table>
220
+ )
221
+
222
+ <Sandbox
223
+ Component={TdSandbox}
224
+ propsJsonSchema={TdPropsJsonSchema}
225
+ />
@@ -0,0 +1,2 @@
1
+ .root
2
+ width 100%
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from 'react'
2
+ import { View, type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import './index.cssx.styl'
6
+
7
+ export const _PropsJsonSchema = {/* TableProps */} // used in docs generation
8
+
9
+ export interface TableProps {
10
+ /** Custom styles applied to the table container */
11
+ style?: StyleProp<ViewStyle>
12
+ /** Table content rendered inside */
13
+ children?: ReactNode
14
+ }
15
+
16
+ function Table ({ style, children }: TableProps): ReactNode {
17
+ return pug`
18
+ View.root(style=style)= children
19
+ `
20
+ }
21
+
22
+ export default observer(themed('Table', Table))
@@ -0,0 +1,25 @@
1
+ import { type ReactNode } from 'react'
2
+ import { type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import Div, { type DivProps } from '@startupjs-ui/div'
6
+
7
+ export const _PropsJsonSchema = {/* TbodyProps */} // used in docs generation
8
+
9
+ export interface TbodyProps extends DivProps {
10
+ /** Custom styles applied to the body container */
11
+ style?: StyleProp<ViewStyle>
12
+ /** Body content rendered inside */
13
+ children?: ReactNode
14
+ }
15
+
16
+ function Tbody ({ style, children, ...props }: TbodyProps): ReactNode {
17
+ return pug`
18
+ Div(
19
+ ...props
20
+ style=style
21
+ )= children
22
+ `
23
+ }
24
+
25
+ export default observer(themed('Tbody', Tbody))
@@ -0,0 +1,3 @@
1
+ .root
2
+ padding 1u 2u
3
+ flex 1
package/Td/index.tsx ADDED
@@ -0,0 +1,55 @@
1
+ import { useEffect, type ReactNode } from 'react'
2
+ import { type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer, $ } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import Div, { type DivProps } from '@startupjs-ui/div'
6
+ import Span from '@startupjs-ui/span'
7
+ import './index.cssx.styl'
8
+
9
+ export const _PropsJsonSchema = {/* TdProps */} // used in docs generation
10
+
11
+ export interface TdProps extends DivProps {
12
+ /** Custom styles applied to the cell container */
13
+ style?: StyleProp<ViewStyle>
14
+ /** Cell content rendered inside */
15
+ children?: ReactNode
16
+ /** Collapse text into a single line with ellipsis, tap to toggle @default false */
17
+ ellipsis?: boolean
18
+ }
19
+
20
+ function Td ({
21
+ style,
22
+ children,
23
+ ellipsis = false,
24
+ ...props
25
+ }: TdProps): ReactNode {
26
+ const $full = $()
27
+
28
+ useEffect(() => () => $full.del(), [$full])
29
+
30
+ const options: Record<string, any> = {}
31
+
32
+ if (ellipsis) {
33
+ options.onPress = () => $full.set(!$full.get())
34
+ if (!$full.get()) {
35
+ options.numberOfLines = 1
36
+ options.ellipsizeMode = 'tail'
37
+ }
38
+ }
39
+
40
+ return pug`
41
+ Div.root(
42
+ ...props
43
+ style=style
44
+ )
45
+ if typeof children === 'string'
46
+ Span(
47
+ ...options
48
+ )= children
49
+ else
50
+ = children
51
+
52
+ `
53
+ }
54
+
55
+ export default observer(themed('Td', Td))
@@ -0,0 +1,3 @@
1
+ .root
2
+ padding 1u 2u
3
+ flex 1
package/Th/index.tsx ADDED
@@ -0,0 +1,56 @@
1
+ import { useEffect, type ReactNode } from 'react'
2
+ import { type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer, $ } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import Div, { type DivProps } from '@startupjs-ui/div'
6
+ import Span from '@startupjs-ui/span'
7
+ import './index.cssx.styl'
8
+
9
+ export const _PropsJsonSchema = {/* ThProps */} // used in docs generation
10
+
11
+ export interface ThProps extends DivProps {
12
+ /** Custom styles applied to the header cell container */
13
+ style?: StyleProp<ViewStyle>
14
+ /** Header cell content rendered inside */
15
+ children?: ReactNode
16
+ /** Collapse text into a single line with ellipsis, tap to toggle @default false */
17
+ ellipsis?: boolean
18
+ }
19
+
20
+ function Th ({
21
+ style,
22
+ children,
23
+ ellipsis = false,
24
+ ...props
25
+ }: ThProps): ReactNode {
26
+ const $full = $()
27
+
28
+ useEffect(() => () => $full.del(), [$full])
29
+
30
+ const options: Record<string, any> = {}
31
+
32
+ if (ellipsis) {
33
+ options.onPress = () => $full.set(!$full.get())
34
+ if (!$full.get()) {
35
+ options.numberOfLines = 1
36
+ options.ellipsizeMode = 'tail'
37
+ }
38
+ }
39
+
40
+ return pug`
41
+ Div.root(
42
+ ...props
43
+ style=style
44
+ )
45
+ if typeof children === 'string'
46
+ Span(
47
+ ...options
48
+ bold
49
+ )= children
50
+ else
51
+ = children
52
+
53
+ `
54
+ }
55
+
56
+ export default observer(themed('Th', Th))
@@ -0,0 +1,3 @@
1
+ .bordered
2
+ border-color var(--color-border-main)
3
+ border-bottom-width 1px
@@ -0,0 +1,34 @@
1
+ import { type ReactNode } from 'react'
2
+ import { type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import Div, { type DivProps } from '@startupjs-ui/div'
6
+ import './index.cssx.styl'
7
+
8
+ export const _PropsJsonSchema = {/* TheadProps */} // used in docs generation
9
+
10
+ export interface TheadProps extends DivProps {
11
+ /** Custom styles applied to the header container */
12
+ style?: StyleProp<ViewStyle>
13
+ /** Header content rendered inside */
14
+ children?: ReactNode
15
+ /** Add bottom border to the header @default true */
16
+ bordered?: boolean
17
+ }
18
+
19
+ function Thead ({
20
+ style,
21
+ children,
22
+ bordered = true,
23
+ ...props
24
+ }: TheadProps): ReactNode {
25
+ return pug`
26
+ Div(
27
+ ...props
28
+ style=[style]
29
+ styleName=[{ bordered }]
30
+ )= children
31
+ `
32
+ }
33
+
34
+ export default observer(themed('Thead', Thead))
package/Tr/index.tsx ADDED
@@ -0,0 +1,26 @@
1
+ import { type ReactNode } from 'react'
2
+ import { type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import Div, { type DivProps } from '@startupjs-ui/div'
6
+
7
+ export const _PropsJsonSchema = {/* TrProps */} // used in docs generation
8
+
9
+ export interface TrProps extends DivProps {
10
+ /** Custom styles applied to the row container */
11
+ style?: StyleProp<ViewStyle>
12
+ /** Row content rendered inside */
13
+ children?: ReactNode
14
+ }
15
+
16
+ function Tr ({ style, children, ...props }: TrProps): ReactNode {
17
+ return pug`
18
+ Div(
19
+ ...props
20
+ style=style
21
+ row
22
+ )= children
23
+ `
24
+ }
25
+
26
+ export default observer(themed('Tr', Tr))
package/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /* eslint-disable */
2
+ // DO NOT MODIFY THIS FILE - IT IS AUTOMATICALLY GENERATED ON COMMITS.
3
+
4
+ export { default as Table, type TableProps } from './Table';
5
+ export { default as Thead, type TheadProps } from './Thead';
6
+ export { default as Tbody, type TbodyProps } from './Tbody';
7
+ export { default as Tr, type TrProps } from './Tr';
8
+ export { default as Th, type ThProps } from './Th';
9
+ export { default as Td, type TdProps } from './Td';
10
+ export { _PropsJsonSchema as TablePropsJsonSchema } from './Table';
11
+ export { _PropsJsonSchema as TheadPropsJsonSchema } from './Thead';
12
+ export { _PropsJsonSchema as TbodyPropsJsonSchema } from './Tbody';
13
+ export { _PropsJsonSchema as TrPropsJsonSchema } from './Tr';
14
+ export { _PropsJsonSchema as ThPropsJsonSchema } from './Th';
15
+ export { _PropsJsonSchema as TdPropsJsonSchema } from './Td';
package/index.tsx ADDED
@@ -0,0 +1,13 @@
1
+ export { default as Table, type TableProps } from './Table'
2
+ export { default as Thead, type TheadProps } from './Thead'
3
+ export { default as Tbody, type TbodyProps } from './Tbody'
4
+ export { default as Tr, type TrProps } from './Tr'
5
+ export { default as Th, type ThProps } from './Th'
6
+ export { default as Td, type TdProps } from './Td'
7
+
8
+ export { _PropsJsonSchema as TablePropsJsonSchema } from './Table'
9
+ export { _PropsJsonSchema as TheadPropsJsonSchema } from './Thead'
10
+ export { _PropsJsonSchema as TbodyPropsJsonSchema } from './Tbody'
11
+ export { _PropsJsonSchema as TrPropsJsonSchema } from './Tr'
12
+ export { _PropsJsonSchema as ThPropsJsonSchema } from './Th'
13
+ export { _PropsJsonSchema as TdPropsJsonSchema } from './Td'
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@startupjs-ui/table",
3
+ "version": "0.1.3",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "main": "index.tsx",
8
+ "types": "index.d.ts",
9
+ "type": "module",
10
+ "dependencies": {
11
+ "@startupjs-ui/core": "^0.1.3",
12
+ "@startupjs-ui/div": "^0.1.3",
13
+ "@startupjs-ui/span": "^0.1.3"
14
+ },
15
+ "peerDependencies": {
16
+ "react": "*",
17
+ "react-native": "*",
18
+ "startupjs": "*"
19
+ },
20
+ "gitHead": "fd964ebc3892d3dd0a6c85438c0af619cc50c3f0"
21
+ }