@pythia-software/query-table-ui 0.4.1 → 0.5.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.
package/README.md CHANGED
@@ -10,6 +10,34 @@ and selection toolbar.
10
10
  npm install @pythia-software/query-table-core @pythia-software/query-table-react @pythia-software/query-table-ui react react-dom
11
11
  ```
12
12
 
13
+ ## Tag/set filters
14
+
15
+ Set `filter.editor: "set"` on a `textarray` field to use the native WHERE
16
+ multi-select editor, with ANY / ALL / NONE / EMPTY modes, badge presentation,
17
+ removable tags, keyboard controls, and a mobile bottom sheet. For stable tag
18
+ keys, also set `arrayCaseSensitive: true` and provide static `{ value, label }`
19
+ options. NONE includes empty/missing arrays while excluding every selected key.
20
+ Other fields and existing predicates keep their current editors.
21
+
22
+ ```ts
23
+ filter: {
24
+ editor: "set",
25
+ arrayCaseSensitive: true,
26
+ values: {
27
+ source: "static",
28
+ options: [{ value: "bug", label: "Bug" }, { value: "feature", label: "Feature" }],
29
+ },
30
+ }
31
+ ```
32
+
33
+ `FilterValueProvider` renders both selected chips and choices. Unknown selected
34
+ keys remain removable rather than being silently discarded. The editor honors
35
+ `filter.ops` and the query's predicate budget; a restrictive operator allowlist
36
+ can disable modes. `classNames.setEditor` and `classNames.setBackdrop` customize
37
+ the overlay alongside the existing input/select/button slots. See
38
+ [`docs/set-filters.md`](../../docs/set-filters.md) for serialization, alias
39
+ canonicalization, backend requirements, and compatibility details.
40
+
13
41
  ## Use
14
42
 
15
43
  ```tsx
@@ -60,27 +88,92 @@ consumer-owned bulk actions can call `selection.replace(ids)` or
60
88
  `selection.retain(ids)` atomically. Existing callbacks that use only the first
61
89
  argument remain compatible.
62
90
 
91
+ ## Icons
92
+
93
+ `Icon` is the shared, hand-drawn SVG set used throughout the UI and demo. Its
94
+ 24px grid, rounded 1.8px strokes, and `currentColor` styling keep controls
95
+ cohesive without forcing every shape into the same silhouette. Drag handles
96
+ use solid dots; saved and priority stars can use a filled active state.
97
+
98
+ ```tsx
99
+ import { Icon } from "@pythia-software/query-table-ui";
100
+
101
+ <button aria-label="Copy value"><Icon name="copy" /></button>
102
+ <Icon name="star" size={20} filled />
103
+ ```
104
+
105
+ Icons default to 16px; use `size` and `className` for larger carets or scoped
106
+ styling. SVGs are decorative and excluded from keyboard focus. Keep a visible
107
+ text label or an `aria-label` on the surrounding control; give standalone
108
+ status indicators an accessible label on their wrapper.
109
+
63
110
  ## Mobile behavior
64
111
 
65
112
  The bundled theme keeps the table as a horizontally scrollable grid on narrow
66
- screens so columns remain comparable. It adds a scroll cue, touch-sized query
67
- controls, button-based reordering alongside desktop drag-and-drop, sticky row
68
- selection, single-column metric cards, and bottom-sheet menus and dialogs. Keep
69
- the standard viewport meta tag in the host page:
113
+ screens so columns remain comparable. Narrow screens (up to 760px) and short,
114
+ touch-based landscape viewports use a mobile interaction model:
115
+
116
+ - **Tap to edit or delete:** filters, sorts, and metrics become readable summaries
117
+ with pencil buttons. Remove actions live inside the editor, including removal
118
+ of an entire OR group, and support Undo. There are no inline trash buttons.
119
+ Adding a filter, sort, or metric immediately
120
+ opens its editor. Filters can be combined with OR without relying on drag-and-drop.
121
+ - **Direct ordering:** columns, sorts, and metrics have leading drag handles
122
+ directly in the query builder, with no Order buttons. Column chips stay
123
+ wrapped and can move horizontally or between rows. Keyboard arrow keys reorder
124
+ a focused handle. A drop commits the new order; cancelled gestures leave the
125
+ query unchanged. Filters have no ordering controls because their order does
126
+ not affect results. Ordinary scrolling outside a handle does not start a drag.
127
+ - **Consistent sheets:** field and value pickers, conditions, cell/header actions,
128
+ saved queries, auto-update settings, and the column editor use bottom sheets
129
+ with a scrim, a visible close action, and pull-down dismissal from the handle.
130
+ Sheets trap and restore focus, lock background scrolling, respect safe areas
131
+ and reduced motion, and fit the visible viewport when the keyboard opens.
132
+ Mobile portals preserve inherited `--qt-*` theme variables.
133
+ - **Focused column workbench:** Selected, Catalogue, and Preview sections replace
134
+ stacked desktop panels. Selected columns reorder directly using their leading
135
+ handles; draft changes still require Apply.
136
+ Layout actions remain visible in the footer.
137
+ - **Compact spacing:** mobile sheets, lists, query sections, and editors reduce
138
+ padding and redundant headings. Query chips, their buttons, and inline handles
139
+ use a 32px minimum height with zero vertical padding; long summaries can wrap.
140
+ Filter, sort, and metric inputs use 36px controls. Keyword sections have extra breathing room
141
+ and solid horizontal rules on desktop and mobile.
142
+ - **Dense query setup:** filter, sort, and metric actions share a section header.
143
+ Summaries use one line when space allows and wrap without truncating values.
144
+ Labeled condition/value and function/measure pairs replace wrapping desktop
145
+ chips. Sort direction and null-value placement use native selects; regex
146
+ extraction stays optional. Its configuration opens a dialog (a bottom sheet on small screens) with a live, worker-isolated preview of up to 100 matching rows. The preview shows original values, extracted sort values, and no-match/null states; Apply commits any syntactically valid pattern even when the preview is unavailable or still loading, while Cancel leaves the sort unchanged. Grouping uses removable tags and a field picker.
147
+ Simple metric results share two-column rows; grouped results use the full width.
148
+ - **Touch-first controls:** dedicated drag handles, 16px text inputs,
149
+ sticky bulk actions, a horizontal table scroll cue, and the device's native
150
+ share sheet when available (clipboard fallback otherwise).
151
+
152
+ Edits continue to update the query immediately, as on desktop; **Done** dismisses
153
+ the sheet. The column workbench retains its explicit **Apply columns** draft
154
+ workflow. Desktop chips, popovers, and drag-and-drop remain available.
155
+
156
+ Keep the standard viewport meta tag in the host page:
70
157
 
71
158
  ```html
72
159
  <meta name="viewport" content="width=device-width, initial-scale=1" />
73
160
  ```
74
161
 
75
162
  Applications that omit `theme.css` and use only `classNames` are responsible for
76
- providing their own responsive and touch-target styles.
163
+ providing their own responsive and touch-target styles, including styles for
164
+ the mobile summary, sheet, and reorder-list structural classes.
165
+
166
+ To run browser interaction checks, start `npm run demo`, install Playwright's
167
+ Chromium and WebKit browsers, and run `npm run test:mobile` from the repository
168
+ root. The suite covers narrow phones, small tablets, and phone landscape; it
169
+ also exercises real Chromium touch events and saves previews in `.context/`.
77
170
 
78
171
  See the [repository README](https://github.com/Pythia-Software/query-table#readme)
79
172
  for customization and backend integration details.
80
173
 
81
174
  ## SELECT editor
82
175
 
83
- `QueryBuilder` includes an **Edit columns** action. The exported `SelectColumnEditor` also accepts `{ api, onClose }` for standalone use. It supports draft column ordering, a searchable catalogue, sampled value frequencies, and a lazy-loaded CodeMirror formula editor with grouped live previews and regex inspection. Shared-definition saves and query-layout application are separate actions.
176
+ `QueryBuilder` includes a split **Add** button and **Reset** action for Columns: Add opens the field picker, while its caret opens the column customizer. Actions follow the selected chips on desktop and sit in the section header on small screens. The exported `SelectColumnEditor` also accepts `{ api, onClose }` for standalone use. It supports draft column ordering, a searchable catalogue, sampled value frequencies, and a lazy-loaded CodeMirror formula editor with grouped live previews and regex inspection. Shared-definition saves and query-layout application are separate actions.
84
177
 
85
178
  ### Filter value presentation
86
179
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, SetStateAction } from 'react';
3
3
  import { FieldDef, QueryState, RowId, FieldStats, WhereClause } from '@pythia-software/query-table-core';
4
- import { SelectionApi, ColumnDragApi, QueryTableApi, AggregationsApi, SavedQueriesApi } from '@pythia-software/query-table-react';
5
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { SelectionApi, ColumnDragApi, QueryTableApi, AggregationsApi, SavedQueriesApi } from '@pythia-software/query-table-react';
6
6
 
7
7
  interface CellContext<Row = any, V = unknown> {
8
8
  value: V;
@@ -24,6 +24,37 @@ declare const defaultRenderers: RenderRegistry;
24
24
  * the `text` fallback. */
25
25
  declare function resolveRenderer<Row>(field: FieldDef<Row>, registry: RenderRegistry<Row>): CellRenderer<Row>;
26
26
 
27
+ declare const artwork: {
28
+ add: react_jsx_runtime.JSX.Element;
29
+ close: react_jsx_runtime.JSX.Element;
30
+ check: react_jsx_runtime.JSX.Element;
31
+ chevronDown: react_jsx_runtime.JSX.Element;
32
+ chevronRight: react_jsx_runtime.JSX.Element;
33
+ arrowUp: react_jsx_runtime.JSX.Element;
34
+ arrowDown: react_jsx_runtime.JSX.Element;
35
+ arrowLeft: react_jsx_runtime.JSX.Element;
36
+ arrowRight: react_jsx_runtime.JSX.Element;
37
+ grip: react_jsx_runtime.JSX.Element;
38
+ pencil: react_jsx_runtime.JSX.Element;
39
+ star: react_jsx_runtime.JSX.Element;
40
+ undo: react_jsx_runtime.JSX.Element;
41
+ redo: react_jsx_runtime.JSX.Element;
42
+ copy: react_jsx_runtime.JSX.Element;
43
+ share: react_jsx_runtime.JSX.Element;
44
+ refresh: react_jsx_runtime.JSX.Element;
45
+ clock: react_jsx_runtime.JSX.Element;
46
+ reset: react_jsx_runtime.JSX.Element;
47
+ bookmark: react_jsx_runtime.JSX.Element;
48
+ };
49
+ type IconName = keyof typeof artwork;
50
+ interface IconProps {
51
+ name: IconName;
52
+ size?: number;
53
+ className?: string;
54
+ filled?: boolean;
55
+ }
56
+ declare function Icon({ name, size, className, filled }: IconProps): react_jsx_runtime.JSX.Element;
57
+
27
58
  interface TableClassNames {
28
59
  wrap?: string;
29
60
  table?: string;
@@ -52,6 +83,8 @@ interface QueryBuilderClassNames {
52
83
  button?: string;
53
84
  input?: string;
54
85
  select?: string;
86
+ setEditor?: string;
87
+ setBackdrop?: string;
55
88
  }
56
89
  interface MenuClassNames {
57
90
  popover?: string;
@@ -189,4 +222,4 @@ declare function PresentedFilterValue({ field, value, label }: {
189
222
  label?: string;
190
223
  }): react_jsx_runtime.JSX.Element;
191
224
 
192
- export { type CellContext, CellMenu, type CellMenuProps, type CellRenderer, DataTable, type DataTableProps, FieldPicker, type FieldPickerProps, type FilterValuePresentation, FilterValueProvider, type MenuClassNames, MetricsPanel, type MetricsPanelProps, PresentedFilterValue, QueryBuilder, type QueryBuilderClassNames, type QueryBuilderProps, type RenderRegistry, SavedQueriesModal, type SavedQueriesModalProps, SelectColumnEditor, type SelectColumnEditorProps, SelectionToolbar, type SelectionToolbarProps, type TableClassNames, defaultRenderers, resolveRenderer, safeLinkHref };
225
+ export { type CellContext, CellMenu, type CellMenuProps, type CellRenderer, DataTable, type DataTableProps, FieldPicker, type FieldPickerProps, type FilterValuePresentation, FilterValueProvider, Icon, type IconName, type IconProps, type MenuClassNames, MetricsPanel, type MetricsPanelProps, PresentedFilterValue, QueryBuilder, type QueryBuilderClassNames, type QueryBuilderProps, type RenderRegistry, SavedQueriesModal, type SavedQueriesModalProps, SelectColumnEditor, type SelectColumnEditorProps, SelectionToolbar, type SelectionToolbarProps, type TableClassNames, defaultRenderers, resolveRenderer, safeLinkHref };