@scattered-light/loomiere-mojave 0.24.0 → 0.25.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.
@@ -0,0 +1,50 @@
1
+ # LineItemGrid
2
+
3
+ The Base UI LineItemGrid styled by the theme. Editable lines (a journal entry, an invoice) on the Table styles. Cells hold controls, so their padding drops to the table's block padding and the controls fill the cell. The line-number column is narrow and in the tertiary color; the remove column is as narrow as its button. Footer rows stick to the bottom of the scroll box (maxHeight caps it): the table clips instead of hiding its overflow, because overflow: hidden would make the table the scroll container and the footer would never stick. A footer row's data-tone colors its figures with the status text colors (the -dark steps, which pass as text on the tray). The words in the cell carry the state; color only adds.
4
+
5
+ Use `Loomiere.LineItemGrid` (`import { LineItemGrid } from '@base-ui/react/line-item-grid'` in an app) and give each part the class below; the styles target those classes, not Base UI's own markup.
6
+
7
+ Base UI docs: https://base-ui.com/react/components/line-item-grid
8
+
9
+ ## Classes
10
+
11
+ | Class | Data attributes it answers to |
12
+ |---|---|
13
+ | `LineItemGrid` | `data-read-only` |
14
+ | `LineItemGridScroll` | |
15
+ | `LineItemGridTable` | |
16
+ | `Input` | |
17
+ | `FieldRoot` | |
18
+ | `ComboboxRoot` | |
19
+ | `MoneyField` | |
20
+ | `SelectTrigger` | |
21
+ | `LineItemGridNumberCol` | |
22
+ | `LineItemGridRemoveCol` | |
23
+ | `LineItemGridNumber` | |
24
+ | `LineItemGridRemove` | |
25
+ | `LineItemGridAdd` | |
26
+
27
+ Base UI sets the state attributes (`data-checked`, `data-open`, `data-disabled`...) itself. Set `data-size`, `data-emphasis`, `data-variant` and `data-color` yourself; `data-color` takes any palette name (`primary`, `secondary`, `error`...) and repaints the part in it.
28
+
29
+ ## Example
30
+
31
+ From the LineItemGrid stories (`Default`):
32
+
33
+ ```tsx
34
+ export const Default: Story = {
35
+ args: { label: '', columns: [], rows: [], getRowId: () => '', renderCell: () => null },
36
+ render: () => <Editor />,
37
+ play: async ({ canvasElement }) => {
38
+ const canvas = within(canvasElement);
39
+ await expect(canvas.getByText(/out of balance/)).toBeTruthy();
40
+ await userEvent.click(canvas.getByRole('button', { name: 'Add line' }));
41
+ await expect(canvas.getByRole('textbox', { name: 'Account, line 3' })).toHaveFocus();
42
+ await userEvent.click(canvas.getByRole('button', { name: 'Remove line 3' }));
43
+ await expect(canvas.queryByRole('textbox', { name: 'Account, line 3' })).toBeNull();
44
+ },
45
+ };
46
+
47
+ /** A posted entry: text in the cells, no add or remove. */
48
+ ```
49
+
50
+ The preview also shows `ReadOnly`.