@simplysm/solid 13.0.98 → 13.0.100

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/docs/data.md CHANGED
@@ -1,125 +1,167 @@
1
1
  # Data Components
2
2
 
3
- Source: `src/components/data/**/*.tsx`
3
+ Source: `src/components/data/**`
4
4
 
5
- ## Table
5
+ ## `Table`
6
6
 
7
- Styled HTML table with border-separated cells.
7
+ Simple HTML table component with border and padding styles.
8
8
 
9
- ```ts
10
- interface TableProps extends JSX.HTMLAttributes<HTMLTableElement> {
11
- inset?: boolean; // borderless style for embedding
9
+ ```typescript
10
+ export interface TableProps extends JSX.HTMLAttributes<HTMLTableElement> {
11
+ inset?: boolean;
12
12
  }
13
13
  ```
14
14
 
15
+ | Prop | Type | Description |
16
+ |------|------|-------------|
17
+ | `inset` | `boolean` | Remove outer border and rounded corners |
18
+
15
19
  ### Sub-components
16
20
 
17
- - **`Table.Row`** -- `<tr>` element. Extends `JSX.HTMLAttributes<HTMLTableRowElement>`.
18
- - **`Table.HeaderCell`** -- `<th>` element with bold text and muted background. Extends `JSX.ThHTMLAttributes<HTMLTableCellElement>`.
19
- - **`Table.Cell`** -- `<td>` element with borders. Extends `JSX.TdHTMLAttributes<HTMLTableCellElement>`.
21
+ - **`Table.Row`** -- Table row (`<tr>`)
22
+ - **`Table.HeaderCell`** -- Header cell (`<th>`) with bold text and muted background
23
+ - **`Table.Cell`** -- Body cell (`<td>`)
24
+
25
+ ---
20
26
 
21
- ## List
27
+ ## `List`
22
28
 
23
- Vertical list container with nesting support via `ListContext`.
29
+ Container component for list items with tree-view keyboard navigation (Space/Enter, ArrowUp/Down, ArrowLeft/Right, Home/End).
24
30
 
25
- ```ts
26
- interface ListProps extends JSX.HTMLAttributes<HTMLDivElement> {
27
- inset?: boolean; // borderless style
31
+ ```typescript
32
+ export interface ListProps extends JSX.HTMLAttributes<HTMLDivElement> {
33
+ inset?: boolean;
28
34
  }
29
35
  ```
30
36
 
31
- Uses `ListContext` to track nesting level for indentation.
37
+ | Prop | Type | Description |
38
+ |------|------|-------------|
39
+ | `inset` | `boolean` | Transparent background, no outer border |
40
+
41
+ ### Sub-components
42
+
43
+ - **`List.Item`** -- Interactive list item (see `ListItem` below)
44
+
45
+ ---
46
+
47
+ ## `ListContext`
32
48
 
33
- ### ListContext
49
+ Context for tracking nesting level in nested lists.
34
50
 
35
- ```ts
36
- interface ListContextValue {
51
+ ```typescript
52
+ export interface ListContextValue {
37
53
  level: number;
38
54
  }
39
55
 
40
- const ListContext: Context<ListContextValue>; // default: { level: 0 }
41
- function useListContext(): ListContextValue;
56
+ export const ListContext: Context<ListContextValue>;
57
+ export const useListContext: () => ListContextValue;
42
58
  ```
43
59
 
44
- ### ListItem
60
+ ---
45
61
 
46
- Interactive list item with selection, expansion, and ripple support.
62
+ ## `ListItem.styles`
47
63
 
48
- ```ts
49
- interface ListItemProps extends Omit<JSX.HTMLAttributes<HTMLButtonElement>, "onClick"> {
50
- selected?: boolean;
51
- disabled?: boolean;
52
- readOnly?: boolean;
53
- size?: ComponentSize;
54
- open?: boolean;
55
- onOpenChange?: (open: boolean) => void;
56
- onClick?: (e: MouseEvent) => void;
57
- }
58
- ```
64
+ Shared style constants for list items.
65
+
66
+ | Export | Type | Description |
67
+ |--------|------|-------------|
68
+ | `listItemBaseClass` | `string` | Base item styles |
69
+ | `listItemSizeClasses` | `Record<ComponentSize, string>` | Size-specific padding |
70
+ | `listItemSelectedClass` | `string` | Selected state styles |
71
+ | `listItemDisabledClass` | `string` | Disabled state styles |
72
+ | `listItemReadonlyClass` | `string` | Read-only state styles |
73
+ | `listItemIndentGuideClass` | `string` | Indent guide line styles |
74
+ | `listItemBasePadLeft` | `Record<ComponentSize, number>` | Base left padding per size (rem) |
75
+ | `LIST_ITEM_INDENT_SIZE` | `number` | Indent size per nesting level (1.5 rem) |
76
+ | `listItemContentClass` | `string` | Item content area styles |
77
+ | `getListItemSelectedIconClass` | `(selected: boolean) => string` | Selection icon color |
59
78
 
60
- - **`ListItem.Children`** -- Nested content rendered inside a `Collapse`. Children are wrapped in a nested `List`.
79
+ ---
61
80
 
62
- ## Pagination
81
+ ## `Pagination`
63
82
 
64
- Page navigation control with first/prev/next/last buttons.
83
+ Page navigation component with first/prev/next/last buttons and page number buttons.
65
84
 
66
- ```ts
67
- interface PaginationProps extends JSX.HTMLAttributes<HTMLElement> {
85
+ ```typescript
86
+ export interface PaginationProps extends JSX.HTMLAttributes<HTMLElement> {
68
87
  page: number;
69
88
  onPageChange?: (page: number) => void;
70
89
  totalPageCount: number;
71
- displayPageCount?: number; // default: 10
90
+ displayPageCount?: number;
72
91
  size?: ComponentSize;
73
92
  }
74
93
  ```
75
94
 
76
- ## DataSheet
95
+ | Prop | Type | Description |
96
+ |------|------|-------------|
97
+ | `page` | `number` | Current page (1-based) |
98
+ | `onPageChange` | `(page: number) => void` | Page change callback |
99
+ | `totalPageCount` | `number` | Total number of pages |
100
+ | `displayPageCount` | `number` | Visible page buttons. Default: `10` |
101
+ | `size` | `ComponentSize` | Button size |
77
102
 
78
- Spreadsheet-like data grid with sorting, selection, expansion, reorder, column resize, and configuration.
103
+ ---
79
104
 
80
- ```ts
81
- interface DataSheetProps<TItem> {
82
- items: TItem[];
83
- getItemKey: (item: TItem) => string | number | undefined;
84
- getItemChildren?: (item: TItem, index: number, depth: number) => TItem[] | undefined;
105
+ ## `DataSheet`
106
+
107
+ Feature-rich data grid with sorting, pagination, selection, tree expansion, column resizing/reordering, fixed columns, and config persistence.
108
+
109
+ ```typescript
110
+ export interface DataSheetProps<TItem> {
111
+ items?: TItem[];
85
112
  storageKey?: string;
113
+ hideConfigBar?: boolean;
86
114
  inset?: boolean;
115
+ contentStyle?: JSX.CSSProperties | string;
116
+ sorts?: SortingDef[];
117
+ onSortsChange?: (sorts: SortingDef[]) => void;
118
+ autoSort?: boolean;
87
119
  page?: number;
88
120
  onPageChange?: (page: number) => void;
89
121
  totalPageCount?: number;
90
- sorts?: SortingDef[];
91
- onSortsChange?: (sorts: SortingDef[]) => void;
122
+ pageSize?: number;
123
+ displayPageCount?: number;
92
124
  selectionMode?: "single" | "multiple";
93
- selectedKeys?: (string | number)[];
94
- onSelectedKeysChange?: (keys: (string | number)[]) => void;
95
- onSelect?: (result: { items: TItem[]; keys: (string | number)[] }) => void;
96
- onReorder?: (event: DataSheetReorderEvent<TItem>) => void;
125
+ selection?: TItem[];
126
+ onSelectionChange?: (items: TItem[]) => void;
127
+ autoSelect?: boolean;
128
+ isItemSelectable?: (item: TItem) => boolean | string;
129
+ expandedItems?: TItem[];
130
+ onExpandedItemsChange?: (items: TItem[]) => void;
131
+ itemChildren?: (item: TItem, index: number) => TItem[] | undefined;
132
+ cellClass?: (item: TItem, colKey: string) => string | undefined;
133
+ cellStyle?: (item: TItem, colKey: string) => string | undefined;
134
+ onItemsReorder?: (event: DataSheetReorderEvent<TItem>) => void;
97
135
  class?: string;
98
- style?: JSX.CSSProperties;
99
136
  children: JSX.Element;
100
137
  }
101
138
  ```
102
139
 
103
- ### Sub-components
104
-
105
- - **`DataSheet.Column<TItem>`** -- Column definition.
140
+ ### `DataSheetColumnProps`
106
141
 
107
- ```ts
108
- interface DataSheetColumnProps<TItem> {
142
+ ```typescript
143
+ export interface DataSheetColumnProps<TItem> {
109
144
  key: string;
110
145
  header?: string | string[];
111
- width?: string;
112
- minWidth?: string;
146
+ headerContent?: () => JSX.Element;
147
+ headerStyle?: string;
148
+ summary?: () => JSX.Element;
149
+ tooltip?: string;
113
150
  fixed?: boolean;
114
- align?: "left" | "center" | "right";
151
+ hidden?: boolean;
152
+ collapse?: boolean;
153
+ width?: string;
154
+ class?: string;
115
155
  sortable?: boolean;
116
- sortKey?: string;
117
156
  resizable?: boolean;
118
- summary?: (items: TItem[]) => JSX.Element;
119
157
  children: (ctx: DataSheetCellContext<TItem>) => JSX.Element;
120
158
  }
159
+ ```
160
+
161
+ ### `DataSheetCellContext`
121
162
 
122
- interface DataSheetCellContext<TItem> {
163
+ ```typescript
164
+ export interface DataSheetCellContext<TItem> {
123
165
  item: TItem;
124
166
  index: number;
125
167
  row: number;
@@ -127,90 +169,174 @@ interface DataSheetCellContext<TItem> {
127
169
  }
128
170
  ```
129
171
 
130
- ### DataSheet.Config
172
+ ### `SortingDef`
131
173
 
132
- Column visibility and order configuration dialog, persisted via storage.
133
-
134
- ```ts
135
- interface DataSheetConfig {
136
- columns: DataSheetConfigColumn[];
174
+ ```typescript
175
+ export interface SortingDef {
176
+ key: string;
177
+ desc: boolean;
137
178
  }
179
+ ```
138
180
 
139
- interface DataSheetConfigColumn {
140
- key: string;
141
- hidden?: boolean;
142
- width?: string;
181
+ ### `DataSheetReorderEvent`
182
+
183
+ ```typescript
184
+ export interface DataSheetReorderEvent<TItem> {
185
+ item: TItem;
186
+ targetItem: TItem;
187
+ position: DataSheetDragPosition;
143
188
  }
189
+
190
+ export type DataSheetDragPosition = "before" | "after" | "inside";
144
191
  ```
145
192
 
146
- ### Related Types
193
+ ### `DataSheetConfig` / `DataSheetConfigColumn`
147
194
 
148
- ```ts
149
- interface SortingDef {
150
- key: string;
151
- desc: boolean;
195
+ ```typescript
196
+ export interface DataSheetConfig {
197
+ columnRecord?: Partial<Record<string, DataSheetConfigColumn>>;
152
198
  }
153
199
 
154
- interface DataSheetReorderEvent<TItem> {
155
- item: TItem;
156
- position: "before" | "after" | "inside";
157
- target: TItem;
200
+ export interface DataSheetConfigColumn {
201
+ fixed?: boolean;
202
+ width?: string;
203
+ displayOrder?: number;
204
+ hidden?: boolean;
158
205
  }
159
206
  ```
160
207
 
161
- ## Calendar
208
+ ### `FlatItem`
162
209
 
163
- Month calendar displaying items on date cells.
210
+ ```typescript
211
+ export interface FlatItem<TItem> {
212
+ item: TItem;
213
+ index: number;
214
+ row: number;
215
+ depth: number;
216
+ hasChildren: boolean;
217
+ parent?: TItem;
218
+ }
219
+ ```
164
220
 
165
- ```ts
166
- interface CalendarProps<TValue> extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children"> {
167
- year: number;
168
- month: number;
169
- onYearChange?: (year: number) => void;
170
- onMonthChange?: (month: number) => void;
171
- items?: TValue[];
172
- getItemDate?: (item: TValue) => DateOnly;
173
- renderItem?: (item: TValue, index: number) => JSX.Element;
174
- onDateClick?: (date: DateOnly) => void;
175
- size?: ComponentSize;
176
- class?: string;
177
- style?: JSX.CSSProperties;
221
+ ---
222
+
223
+ ## `DataSheet.styles`
224
+
225
+ Shared style constants for DataSheet rendering. Key exports:
226
+
227
+ | Export | Description |
228
+ |--------|-------------|
229
+ | `dataSheetContainerClass` | Container class |
230
+ | `tableClass` | Table element class |
231
+ | `thClass` / `tdClass` | Header/body cell classes |
232
+ | `summaryThClass` | Summary row header class |
233
+ | `sortableThClass` | Sortable header class |
234
+ | `fixedClass` / `fixedLastClass` | Fixed column classes |
235
+ | `resizerClass` | Column resize handle class |
236
+ | `resizeIndicatorClass` | Resize drag indicator class |
237
+ | `featureThClass` / `featureTdClass` | Feature column classes |
238
+ | `expandToggleClass` | Expand toggle button class |
239
+ | `selectSingleClass` | Single select icon class |
240
+ | `reorderHandleClass` | Drag reorder handle class |
241
+ | `reorderIndicatorClass` | Reorder drag indicator class |
242
+ | `toolbarClass` | Toolbar class |
243
+ | `trRowClass` | Body row class with hover/selected overlays |
244
+ | `configButtonClass` | Settings button class |
245
+
246
+ ---
247
+
248
+ ## `Calendar`
249
+
250
+ Monthly calendar grid displaying items by date.
251
+
252
+ ```typescript
253
+ export interface CalendarProps<TValue> extends Omit<
254
+ JSX.HTMLAttributes<HTMLTableElement>,
255
+ "children"
256
+ > {
257
+ items: TValue[];
258
+ getItemDate: (item: TValue, index: number) => DateOnly;
259
+ renderItem: (item: TValue, index: number) => JSX.Element;
260
+ yearMonth?: DateOnly;
261
+ onYearMonthChange?: (value: DateOnly) => void;
262
+ weekStartDay?: number;
263
+ minDaysInFirstWeek?: number;
178
264
  }
179
265
  ```
180
266
 
181
- ## Kanban
267
+ | Prop | Type | Description |
268
+ |------|------|-------------|
269
+ | `items` | `TValue[]` | Data items to display |
270
+ | `getItemDate` | `(item, index) => DateOnly` | Extract date from item |
271
+ | `renderItem` | `(item, index) => JSX.Element` | Render item content |
272
+ | `yearMonth` | `DateOnly` | Displayed month |
273
+ | `onYearMonthChange` | `(value: DateOnly) => void` | Month change callback |
274
+ | `weekStartDay` | `number` | Week start day (0=Sun). Default: `0` |
275
+ | `minDaysInFirstWeek` | `number` | Min days in first week. Default: `1` |
182
276
 
183
- Kanban board with drag-and-drop cards between lanes.
277
+ ---
184
278
 
185
- ```ts
186
- interface KanbanProps<TCardValue, TLaneValue> extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children"> {
187
- onDrop?: (info: KanbanDropInfo<TLaneValue, TCardValue>) => void;
188
- children: JSX.Element;
279
+ ## `Kanban`
280
+
281
+ Drag-and-drop kanban board with lanes, cards, and multi-select support.
282
+
283
+ ### Types
284
+
285
+ ```typescript
286
+ export interface KanbanCardRef<TLaneValue, TCardValue> {
287
+ value: TCardValue | undefined;
288
+ laneValue: TLaneValue | undefined;
289
+ heightOnDrag: number;
189
290
  }
190
291
 
191
- interface KanbanDropInfo<TLaneValue, TCardValue> {
192
- card: KanbanCardRef<TLaneValue, TCardValue>;
193
- target: KanbanDropTarget<TCardValue>;
292
+ export interface KanbanDropInfo<TLaneValue, TCardValue> {
293
+ sourceValue?: TCardValue;
294
+ targetLaneValue?: TLaneValue;
295
+ targetCardValue?: TCardValue;
296
+ position?: "before" | "after";
194
297
  }
195
- ```
196
298
 
197
- ### Sub-components
299
+ export interface KanbanDropTarget<TCardValue> {
300
+ element: HTMLElement;
301
+ value: TCardValue | undefined;
302
+ position: "before" | "after";
303
+ }
198
304
 
199
- - **`Kanban.Lane<TLaneValue>`** -- Lane container.
305
+ export interface KanbanCardProps<TCardValue = unknown> {
306
+ value?: TCardValue;
307
+ draggable?: boolean;
308
+ selectable?: boolean;
309
+ contentClass?: string;
310
+ children?: JSX.Element;
311
+ }
312
+ ```
200
313
 
201
- ```ts
202
- interface KanbanLaneProps<TLaneValue> extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children"> {
203
- value: TLaneValue;
204
- header?: JSX.Element;
205
- children: JSX.Element;
314
+ ### `KanbanContextValue`
315
+
316
+ ```typescript
317
+ export interface KanbanContextValue<TLaneValue, TCardValue> {
318
+ dragCard: Accessor<KanbanCardRef<TLaneValue, TCardValue> | undefined>;
319
+ setDragCard: Setter<KanbanCardRef<TLaneValue, TCardValue> | undefined>;
320
+ onDropTo: (targetLaneValue, targetCardValue, position) => void;
321
+ selectedValues: Accessor<TCardValue[]>;
322
+ setSelectedValues: (updater) => void;
323
+ toggleSelection: (value: TCardValue) => void;
206
324
  }
207
325
  ```
208
326
 
209
- - **`Kanban.Card<TCardValue>`** -- Draggable card.
327
+ ### `KanbanLaneContextValue`
210
328
 
211
- ```ts
212
- interface KanbanCardProps<TCardValue> extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children"> {
213
- value: TCardValue;
214
- children: JSX.Element;
329
+ ```typescript
330
+ export interface KanbanLaneContextValue<TLaneValue, TCardValue> {
331
+ value: Accessor<TLaneValue | undefined>;
332
+ dropTarget: Accessor<KanbanDropTarget<TCardValue> | undefined>;
333
+ setDropTarget: (target) => void;
334
+ registerCard: (id, info) => void;
335
+ unregisterCard: (id) => void;
215
336
  }
216
337
  ```
338
+
339
+ ### Hooks
340
+
341
+ - **`useKanbanContext()`** -- Access board-level context
342
+ - **`useKanbanLaneContext()`** -- Access lane-level context