@godxjp/ui 2.1.0 → 5.0.0

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 (46) hide show
  1. package/BRAND.md +39 -29
  2. package/CHANGELOG.md +554 -10
  3. package/README.md +143 -168
  4. package/config/eslint.js +54 -0
  5. package/config/prettier.cjs +20 -0
  6. package/config/tsconfig.base.json +22 -0
  7. package/config/vitest.base.ts +26 -0
  8. package/dist/MiniMonth-YAmPGEpC.d.ts +143 -0
  9. package/dist/Table.types-BbsxoIYE.d.ts +352 -0
  10. package/dist/color-DO0qqUAb.d.ts +38 -0
  11. package/dist/components/composites.d.ts +963 -0
  12. package/dist/components/composites.js +7340 -0
  13. package/dist/components/composites.js.map +1 -0
  14. package/dist/components/primitives.d.ts +2633 -163
  15. package/dist/components/primitives.js +7264 -165
  16. package/dist/components/primitives.js.map +1 -1
  17. package/dist/components/shell.d.ts +82 -12
  18. package/dist/components/shell.js +168 -162
  19. package/dist/components/shell.js.map +1 -1
  20. package/dist/hooks.d.ts +83 -8
  21. package/dist/hooks.js +497 -83
  22. package/dist/hooks.js.map +1 -1
  23. package/dist/i18n.d.ts +55 -3
  24. package/dist/i18n.js +456 -5
  25. package/dist/i18n.js.map +1 -1
  26. package/dist/index.d.ts +24 -5
  27. package/dist/index.js +12522 -267
  28. package/dist/index.js.map +1 -1
  29. package/dist/padding-DY0JV5Ja.d.ts +16 -0
  30. package/dist/preferences.d.ts +132 -0
  31. package/dist/preferences.js +262 -0
  32. package/dist/preferences.js.map +1 -0
  33. package/dist/props.d.ts +86 -0
  34. package/dist/props.js +16 -0
  35. package/dist/props.js.map +1 -0
  36. package/dist/size-CQwNvOWd.d.ts +19 -0
  37. package/dist/{data.d.ts → types-LTj-2bl-.d.ts} +7 -12
  38. package/dist/useTableViews-D5NIAJ7h.d.ts +154 -0
  39. package/package.json +92 -34
  40. package/src/tokens/tailwind.css +158 -0
  41. package/dist/components/screens.d.ts +0 -51
  42. package/dist/components/screens.js +0 -806
  43. package/dist/components/screens.js.map +0 -1
  44. package/dist/data.js +0 -93
  45. package/dist/data.js.map +0 -1
  46. package/src/tokens/tokens.css +0 -765
@@ -0,0 +1,352 @@
1
+ import { RowData, Row as Row$1, ColumnDef, VisibilityState, ColumnPinningState, Table } from '@tanstack/react-table';
2
+ import { ComponentProps, ReactNode, MouseEvent, CSSProperties, Ref, HTMLAttributes } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { C as ColorProp, D as DensityProp } from './color-DO0qqUAb.js';
5
+
6
+ type GutterValue = number | [number, number] | Partial<Record<Breakpoint, number>>;
7
+ type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
8
+ type Justify = "start" | "end" | "center" | "space-around" | "space-between" | "space-evenly";
9
+ type Align = "top" | "middle" | "bottom" | "stretch";
10
+ interface RowProps extends Omit<ComponentProps<"div">, "children"> {
11
+ /** Horizontal gap (px), or [horizontal, vertical], or per-breakpoint object. */
12
+ gutter?: GutterValue;
13
+ /** Flex justify on the cross axis. */
14
+ justify?: Justify;
15
+ /** Flex align on the main axis. */
16
+ align?: Align;
17
+ /** Wrap children when sum > 24 cols (default true). */
18
+ wrap?: boolean;
19
+ children?: ReactNode;
20
+ }
21
+ declare function useRowGutter(): [number, number];
22
+ declare function Row({ gutter, justify, align, wrap, className, style, children, ...rest }: RowProps): react_jsx_runtime.JSX.Element;
23
+
24
+ /**
25
+ * Tag — Ant-Design label chip.
26
+ *
27
+ * <Tag>basic</Tag>
28
+ * <Tag color="success">done</Tag>
29
+ * <Tag color="oklch(56% 0.15 240)">custom hue</Tag>
30
+ * <Tag closable onClose={() => …}>removable</Tag>
31
+ * <Tag bordered={false}>borderless</Tag>
32
+ *
33
+ * Distinct from <Badge>: Badge is for status pills (a numeric or
34
+ * single short word), Tag is for labels (potentially many in a row,
35
+ * potentially closable).
36
+ */
37
+ /**
38
+ * Tag accepts the framework's full semantic palette except `"secondary"`
39
+ * (that one is reserved for Typography text-dimming). Aliased from the
40
+ * shared `ColorProp` so the vocabulary stays in lockstep with Alert,
41
+ * Result, Timeline, etc.
42
+ */
43
+ type TagPresetColor = Exclude<ColorProp, "secondary">;
44
+ interface TagProps extends Omit<ComponentProps<"span">, "color"> {
45
+ /** Preset hue or a custom CSS color. */
46
+ color?: TagPresetColor | string;
47
+ /** Show outline (default `true`). Borderless = solid-tinted background only. */
48
+ bordered?: boolean;
49
+ /** Show an × button. Calls `onClose`. */
50
+ closable?: boolean;
51
+ onClose?: (e: MouseEvent<HTMLButtonElement>) => void;
52
+ /** Leading icon. */
53
+ icon?: ReactNode;
54
+ }
55
+ declare function Tag({ color, bordered, closable, onClose, icon, className, style, children, ...rest }: TagProps): react_jsx_runtime.JSX.Element;
56
+
57
+ /**
58
+ * @godxjp/ui Table — type surface.
59
+ *
60
+ * Split out of `Table.tsx` in Stage 4 of the refactor (Plan §3) so
61
+ * the primitive file focuses on rendering + state, while consumers
62
+ * and the `<DataTable>` composite consume a focused type module.
63
+ *
64
+ * Also hosts the TanStack `ColumnMeta` augmentation — every consumer
65
+ * that touches a `meta` field benefits from the typed interface.
66
+ */
67
+
68
+ type TableStickySide = "left" | "right";
69
+ type TableStickyConfig = TableStickySide | false | {
70
+ side: TableStickySide;
71
+ from?: Breakpoint;
72
+ };
73
+ declare module "@tanstack/react-table" {
74
+ /**
75
+ * Primitive-level `ColumnMeta` — fields consumed by the `<Table>`
76
+ * primitive itself: cell rendering, sort UI in headers, sticky
77
+ * positioning.
78
+ *
79
+ * Composite-only fields (`filterable`, `filterLabel`,
80
+ * `filterOptions`, `hideable`) live in
81
+ * `composites/data-table/DataTable.types.ts` and are merged into
82
+ * `ColumnMeta` whenever a consumer imports from
83
+ * `@godxjp/ui/components/composites`.
84
+ */
85
+ interface ColumnMeta<TData extends RowData, TValue> {
86
+ className?: string;
87
+ headerClassName?: string;
88
+ cellClassName?: string | ((row: Row$1<TData>) => string | undefined);
89
+ style?: CSSProperties;
90
+ headerStyle?: CSSProperties;
91
+ cellStyle?: CSSProperties | ((row: Row$1<TData>) => CSSProperties | undefined);
92
+ sortable?: boolean;
93
+ sticky?: TableStickyConfig;
94
+ }
95
+ }
96
+
97
+ type TableDensity = DensityProp;
98
+ type TableColumn<TData, TValue = unknown> = ColumnDef<TData, TValue>;
99
+ type TableColumnVisibility = VisibilityState;
100
+ type TableRowKey<TData> = Extract<keyof TData, string> | ((row: TData, index: number) => string | number);
101
+ type TableFilterOperator = "eq" | "neq" | "contains" | "startsWith" | "endsWith" | "gt" | "gte" | "lt" | "lte" | "between" | "in";
102
+ interface TableFilter {
103
+ key: string;
104
+ operator?: TableFilterOperator;
105
+ value?: string | number | boolean | null;
106
+ valueLabel?: ReactNode;
107
+ }
108
+ interface TableSort {
109
+ key: string;
110
+ direction: "asc" | "desc";
111
+ }
112
+ /** Multi-sort: ordered list whose head is the primary key. */
113
+ type TableSortState = TableSort | TableSort[] | null;
114
+ /** Numbered pagination (default behaviour for general lists). */
115
+ interface TablePaginationNumberedConfig {
116
+ type?: "numbered";
117
+ current: number;
118
+ pageSize: number;
119
+ total: number;
120
+ pageSizeOptions?: number[];
121
+ showSizeChanger?: boolean;
122
+ hideOnSinglePage?: boolean;
123
+ disabled?: boolean;
124
+ showTotal?: (total: number, range: [number, number]) => ReactNode;
125
+ onChange?: (page: number, pageSize: number) => void;
126
+ }
127
+ /** Load-more pagination (feed-like activity / notification lists). */
128
+ interface TablePaginationLoadMoreConfig {
129
+ type: "load-more";
130
+ hasMore: boolean;
131
+ onLoadMore: () => void;
132
+ currentCount: number;
133
+ total: number;
134
+ batchSize?: number;
135
+ loadingMore?: boolean;
136
+ loadMoreLabel?: ReactNode;
137
+ progressLabel?: (currentCount: number, total: number) => ReactNode;
138
+ }
139
+ /** Cursor pagination (time-series jump-to-period for kintai / payroll). */
140
+ interface TablePaginationCursorConfig {
141
+ type: "cursor";
142
+ value: string;
143
+ onChange: (value: string) => void;
144
+ label: ReactNode;
145
+ prevLabel?: ReactNode;
146
+ nextLabel?: ReactNode;
147
+ jumpToLatestLabel?: ReactNode;
148
+ /** HTML input type — `"month"` (default), `"date"`, or `"week"`. */
149
+ inputType?: "month" | "date" | "week";
150
+ onPrev?: () => void;
151
+ onNext?: () => void;
152
+ onJumpToLatest?: () => void;
153
+ disabled?: boolean;
154
+ }
155
+ type TablePaginationVariantConfig = TablePaginationNumberedConfig | TablePaginationLoadMoreConfig | TablePaginationCursorConfig;
156
+ interface TableViewSnapshot {
157
+ filters?: TableFilter[];
158
+ sort?: TableSort | null;
159
+ columnVisibility?: TableColumnVisibility;
160
+ }
161
+ interface TableViewItem extends TableViewSnapshot {
162
+ key: string;
163
+ label: ReactNode;
164
+ count?: ReactNode;
165
+ dotColor?: string;
166
+ disabled?: boolean;
167
+ deletable?: boolean;
168
+ }
169
+ interface TableViewsConfig {
170
+ items: TableViewItem[];
171
+ activeKey?: string;
172
+ onActiveKeyChange?: (key: string) => void;
173
+ onViewApply?: (view: TableViewItem) => void;
174
+ onDeleteView?: (view: TableViewItem) => void;
175
+ onItemsChange?: (items: TableViewItem[]) => void;
176
+ saveable?: boolean;
177
+ saveLabel?: ReactNode;
178
+ deleteLabel?: string;
179
+ onSaveCurrent?: () => void;
180
+ }
181
+ interface TableToolbarSearchConfig {
182
+ value: string;
183
+ onValueChange: (value: string) => void;
184
+ onSearch?: (value: string) => void;
185
+ onClear?: () => void;
186
+ placeholder?: string;
187
+ ariaLabel?: string;
188
+ inputRef?: Ref<HTMLInputElement>;
189
+ suffix?: ReactNode;
190
+ disabled?: boolean;
191
+ }
192
+ interface TableToolbarButtonConfig {
193
+ label?: ReactNode;
194
+ onClick?: () => void;
195
+ disabled?: boolean;
196
+ }
197
+ interface TableToolbarFilterConfig extends TableToolbarButtonConfig {
198
+ count?: number;
199
+ }
200
+ type TableToolbarColumnConfig = TableToolbarButtonConfig;
201
+ interface TableToolbarConfig {
202
+ search?: false | TableToolbarSearchConfig;
203
+ filter?: false | TableToolbarFilterConfig;
204
+ columns?: false | TableToolbarColumnConfig;
205
+ primaryAction?: false | ReactNode | TableToolbarButtonConfig;
206
+ actions?: ReactNode;
207
+ }
208
+ interface TableBatchActionsContext<TData> {
209
+ selectedRowKeys: string[];
210
+ selectedRows: Row$1<TData>[];
211
+ totalSelectableCount: number;
212
+ selectAllVisible: () => void;
213
+ clearSelection: () => void;
214
+ }
215
+ interface TableBatchActionsConfig<TData> {
216
+ selectedRowKeys: string[];
217
+ onSelectedRowKeysChange: (keys: string[]) => void;
218
+ actions: ReactNode | ((context: TableBatchActionsContext<TData>) => ReactNode);
219
+ getCheckboxDisabled?: (row: Row$1<TData>) => boolean;
220
+ selectedLabel?: (count: number) => ReactNode;
221
+ selectAllLabel?: (count: number) => ReactNode;
222
+ clearLabel?: ReactNode;
223
+ }
224
+ interface TableFilterOption {
225
+ value: string;
226
+ label: ReactNode;
227
+ disabled?: boolean;
228
+ }
229
+ interface TableFilterItem {
230
+ key: string;
231
+ label: ReactNode;
232
+ value?: string;
233
+ valueLabel?: ReactNode;
234
+ operator?: TableFilterOperator;
235
+ options?: TableFilterOption[];
236
+ onValueChange?: (value: string) => void;
237
+ color?: TagPresetColor | string;
238
+ closable?: boolean;
239
+ onClose?: () => void;
240
+ }
241
+ type TableFilterBar = ReactNode | TableFilterItem[];
242
+ type TablePagination = ReactNode | false | TablePaginationVariantConfig;
243
+ type TableToolbar = ReactNode | false | TableToolbarConfig;
244
+ type TableViews = ReactNode | false | TableViewsConfig;
245
+ /** Expand-row config (rule 32 — no `expanded`-singular / `expand` synonyms). */
246
+ interface TableExpandableConfig<TData> {
247
+ /** Rows whose expand panel is open. */
248
+ expandedRowKeys?: string[];
249
+ defaultExpandedRowKeys?: string[];
250
+ onExpandedRowsChange?: (keys: string[]) => void;
251
+ /** Renders the inline detail panel. */
252
+ renderExpandedRow: (row: Row$1<TData>) => ReactNode;
253
+ /** Allows more than one open expand panel at a time. Default `false`. */
254
+ allowMultiple?: boolean;
255
+ /** Hide the expand toggle for rows that have no detail panel. */
256
+ rowExpandable?: (row: Row$1<TData>) => boolean;
257
+ }
258
+ /** Inline-edit config — single editing row, multi-row dirty tracking. */
259
+ interface TableEditingConfig<TData> {
260
+ /** The row currently in editing mode. `null` exits editing. */
261
+ rowId: string | null;
262
+ onStart?: (rowId: string) => void;
263
+ onCommit?: (rowId: string, patch: Record<string, unknown>) => void;
264
+ onCancel?: (rowId: string) => void;
265
+ /** Renders an inline editor for a cell. Return `null` to fall back to the column's normal cell. */
266
+ renderEditCell?: (column: TableColumn<TData, unknown>, row: Row$1<TData>) => ReactNode;
267
+ /** Rows that should be read-only (confirmed records / locked rows). */
268
+ isRowReadOnly?: (row: Row$1<TData>) => boolean;
269
+ /** Row + cell ids that carry unsaved changes — for the warning dot + footer banner. */
270
+ dirtyRowIds?: string[];
271
+ dirtyCellIds?: string[];
272
+ /** Footer banner — show "N rows unsaved" + Save-all / Cancel-all controls. */
273
+ onSaveAll?: () => void;
274
+ onCancelAll?: () => void;
275
+ saveAllLabel?: ReactNode;
276
+ cancelAllLabel?: ReactNode;
277
+ unsavedLabel?: (count: number) => ReactNode;
278
+ }
279
+ /** Row-group config — either a key resolver or a richer descriptor. */
280
+ interface TableGroupDescriptor {
281
+ key: string;
282
+ label: ReactNode;
283
+ count?: ReactNode;
284
+ total?: ReactNode;
285
+ }
286
+ type TableGroupBy<TData> = (row: TData) => string | TableGroupDescriptor | undefined;
287
+ /** Tree-row config. Children are resolved per parent row. */
288
+ interface TableTreeConfig<TData> {
289
+ children: (row: TData) => TData[] | undefined;
290
+ defaultExpandedNodes?: string[];
291
+ expandedNodes?: string[];
292
+ onExpandedNodesChange?: (keys: string[]) => void;
293
+ /** Hard cap on nesting depth (defaults to a reasonable 8). */
294
+ maxDepth?: number;
295
+ }
296
+ /** Column-pinning callback (TanStack-canonical name). */
297
+ type TableColumnPinningChange = (pinning: ColumnPinningState) => void;
298
+ /**
299
+ * Selection slice the slim primitive understands — strictly the
300
+ * checkbox column wiring. The batch action band that surfaces
301
+ * actions lives on the `<DataTable>` composite (Stage 4b, v5.0.0).
302
+ */
303
+ interface TableSelectionConfig<TData> {
304
+ selectedRowKeys: string[];
305
+ onSelectedRowKeysChange: (keys: string[]) => void;
306
+ getCheckboxDisabled?: (row: Row$1<TData>) => boolean;
307
+ }
308
+ interface TableProps<TData> extends Omit<HTMLAttributes<HTMLTableElement>, "children"> {
309
+ columns: TableColumn<TData, unknown>[];
310
+ data: TData[];
311
+ density?: TableDensity;
312
+ containerClassName?: string;
313
+ stickyHeader?: boolean;
314
+ rowKey?: TableRowKey<TData>;
315
+ getRowId?: (row: TData, index: number) => string;
316
+ caption?: ReactNode;
317
+ defaultColumnVisibility?: TableColumnVisibility;
318
+ columnVisibility?: TableColumnVisibility;
319
+ onColumnVisibilityChange?: (columnVisibility: TableColumnVisibility) => void;
320
+ /**
321
+ * Active sort. Pass a single `TableSort` for single-key sort (legacy)
322
+ * or `TableSort[]` for multi-sort (shift-click adds keys; canon ⑤).
323
+ */
324
+ sort?: TableSortState;
325
+ onSortChange?: (sort: TableSortState) => void;
326
+ /** Enable per-column horizontal resize handles (canon ⑤). */
327
+ resizable?: boolean;
328
+ /** Inline expand-row config (canon ⑥). */
329
+ expandable?: TableExpandableConfig<TData>;
330
+ /** Inline editing config (canon ⑦). */
331
+ editing?: TableEditingConfig<TData>;
332
+ /** Row-group descriptor — same vocabulary as TanStack `getGroupedRowModel`. */
333
+ groupBy?: TableGroupBy<TData>;
334
+ /** Tree-row resolver (canon ⑧, hierarchical rows). */
335
+ tree?: TableTreeConfig<TData>;
336
+ /** Receives column-pinning changes from the column manager lock toggle (canon ⑨). */
337
+ onColumnPinningChange?: TableColumnPinningChange;
338
+ /** Checkbox-column wiring. Use the `<DataTable>` composite for the batch action band. */
339
+ selection?: TableSelectionConfig<TData>;
340
+ footer?: ReactNode;
341
+ empty?: ReactNode;
342
+ rowClassName?: string | ((row: Row$1<TData>) => string | undefined);
343
+ /**
344
+ * Pre-built TanStack `useReactTable` instance, supplied by the
345
+ * `<DataTable>` composite. When provided, the primitive skips
346
+ * its internal `useReactTable` and consumes the externally-managed
347
+ * instance.
348
+ */
349
+ instance?: Table<TData>;
350
+ }
351
+
352
+ export { type Align as A, type Breakpoint as B, useRowGutter as C, type GutterValue as G, type Justify as J, Row as R, type TableBatchActionsConfig as T, type RowProps as a, type TableColumn as b, type TableColumnPinningChange as c, type TableColumnVisibility as d, type TableDensity as e, type TableEditingConfig as f, type TableExpandableConfig as g, type TableFilter as h, type TableFilterBar as i, type TableFilterOption as j, type TableGroupBy as k, type TablePagination as l, type TableProps as m, type TableRowKey as n, type TableSelectionConfig as o, type TableSort as p, type TableSortState as q, type TableToolbar as r, type TableToolbarConfig as s, type TableTreeConfig as t, type TableViewItem as u, type TableViewSnapshot as v, type TableViews as w, Tag as x, type TagPresetColor as y, type TagProps as z };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Shared density prop-vocabulary per cardinal rule 23 §B.
3
+ *
4
+ * Different from `SizeProp` — density rescales the surrounding padding /
5
+ * row-height tokens (`--density-element-*`) while size targets the
6
+ * primitive's own visual axis. Tables and lists use `density` to fit
7
+ * more rows on screen without shrinking the type.
8
+ */
9
+ type DensityProp = "compact" | "default" | "comfortable";
10
+
11
+ /**
12
+ * Shared semantic-color prop-vocabulary per cardinal rule 23 §B.
13
+ *
14
+ * Every primitive that exposes a `color` prop picks from this superset.
15
+ * Each value maps 1:1 to a CSS variable (`--info`, `--success`,
16
+ * `--warning`, `--destructive`, `--attention`, `--primary`, `--secondary`)
17
+ * — same semantic slot across the whole system, only the hue / intensity
18
+ * scale shifts per primitive (cardinal rule 21 — `data-accent` rebinds
19
+ * `--primary`'s hue without renaming the slot).
20
+ *
21
+ * Existing primitives (AlertColor, ResultColor, ProgressColor,
22
+ * TagPresetColor, TimelineColor, TypographyColor) each accept a subset
23
+ * — point their aliases at `Extract<ColorProp, …>` instead of
24
+ * redeclaring the literals inline.
25
+ *
26
+ * Vocabulary note: the canonical name for the danger slot in this
27
+ * palette is `"destructive"` — every primitive that exposes a `color`
28
+ * prop now uses that name. The shared `StatusProp` (form-field
29
+ * validation) uses `"error"` deliberately — form errors are NOT
30
+ * destructive actions; the two concerns deserve distinct verbs.
31
+ */
32
+ type ColorProp = "default" | "info" | "success" | "warning" | "destructive" | "attention" | "primary" | "secondary";
33
+ /** Subset accepted by feedback primitives — same 5-slot ladder used
34
+ * by Alert / Result / Progress (no brand `primary`, no text-only
35
+ * `secondary` / `attention`). */
36
+ type FeedbackColorProp = Extract<ColorProp, "default" | "info" | "success" | "warning" | "destructive">;
37
+
38
+ export type { ColorProp as C, DensityProp as D, FeedbackColorProp as F };