@apliteni/apliteni-ui 0.27.0 → 0.30.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 (44) hide show
  1. package/package.json +1 -1
  2. package/react/README.md +49 -1
  3. package/react/dist/index.css +11 -1
  4. package/react/dist/index.d.ts +61 -2
  5. package/react/dist/index.js +514 -121
  6. package/src/components/back.js +57 -0
  7. package/src/components/command-palette.js +597 -0
  8. package/src/components/confirm.js +3 -2
  9. package/src/components/drawer.js +31 -2
  10. package/src/components/dropdown.js +192 -17
  11. package/src/components/feedback.js +2 -2
  12. package/src/components/index.js +5 -2
  13. package/src/components/loading.js +3 -2
  14. package/src/components/nav.js +15 -7
  15. package/src/components/overlay.js +67 -14
  16. package/src/components/shell.js +11 -2
  17. package/src/components/tabs.js +7 -1
  18. package/src/components/tooltip.js +237 -0
  19. package/src/components/topbar.js +9 -4
  20. package/src/index.css +3 -0
  21. package/src/index.js +3 -0
  22. package/src/inline.js +6 -0
  23. package/src/motion.js +43 -2
  24. package/src/styles/back.css +42 -0
  25. package/src/styles/badge.css +5 -7
  26. package/src/styles/base.css +8 -7
  27. package/src/styles/card.css +12 -8
  28. package/src/styles/code.css +3 -4
  29. package/src/styles/command-palette.css +321 -0
  30. package/src/styles/confirm.css +11 -11
  31. package/src/styles/drawer.css +57 -15
  32. package/src/styles/dropdown.css +70 -11
  33. package/src/styles/feedback.css +2 -0
  34. package/src/styles/footer.css +3 -4
  35. package/src/styles/input.css +1 -1
  36. package/src/styles/layout.css +3 -2
  37. package/src/styles/loading.css +5 -0
  38. package/src/styles/nav.css +12 -8
  39. package/src/styles/success.css +3 -2
  40. package/src/styles/table.css +4 -5
  41. package/src/styles/tabs.css +3 -0
  42. package/src/styles/tooltip.css +65 -0
  43. package/src/styles/topbar.css +3 -4
  44. package/src/tokens/tokens.css +8 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.27.0",
3
+ "version": "0.30.0",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
package/react/README.md CHANGED
@@ -29,7 +29,24 @@ import '@apliteni/apliteni-ui/react/css'; // React components' shell styles (mo
29
29
  import { DataTable, Modal, Button } from '@apliteni/apliteni-ui/react';
30
30
  ```
31
31
 
32
- Components: `DataTable`, `Pagination`, `Modal`, `Button`, `Badge`, `Card`, `Icon`.
32
+ Components: `DataTable`, `Pagination`, `Modal`, `Drawer`, `CommandPalette`, `Button`, `Badge`, `Card`, `Icon`.
33
+
34
+ `CommandPalette` renders the kit's `commandPalette()` markup, class for class, and imports the
35
+ kit's ranking rather than repeating it — so a palette a server rendered and the same palette
36
+ after a keystroke put the same row first. Three differences from the vanilla one. Two are
37
+ because a React host already owns the state the wiring would: it has no Cmd+K binding, since
38
+ `open` is the host's prop to set from whatever key it wants; and a destructive row names an
39
+ `onConfirm` callback rather than the id of a confirm dialog, which is refused the same way — a
40
+ `danger` row with neither renders disabled. `rank={false}` hands the query back through
41
+ `onQueryChange` for a palette a server feeds.
42
+
43
+ The third is not a design decision and is going: **one Escape closes a `Modal` and the palette
44
+ under it.** The React palette and the React `Modal` each register their own listener on the
45
+ document, and `inert` does not stop a document listener, so the question and the surface it was
46
+ asked about close together. The vanilla pair does not do this — every kit overlay is on one
47
+ stack there, and Escape closes the top one only. The React half joins that shared dialog stack
48
+ when this branch is rebased onto the drawer branch, which is where `dialog.ts` lands; until then,
49
+ open a `Modal` from a palette row knowing both will close.
33
50
 
34
51
  `Pagination` renders the kit's `pagination()` markup, class for class, so its styles come from
35
52
  `@apliteni/apliteni-ui/css` rather than from this bundle. One deliberate difference: it takes no
@@ -47,6 +64,37 @@ controls, disabled controls, controls inside a closed disclosure and elements wi
47
64
  negative tabindex are skipped. Tab and Shift+Tab wrap at the ends of the same list.
48
65
  Escape and a click on the scrim dismiss the dialog and return focus to its opener.
49
66
 
67
+ The Modal fades in and out: the scrim fades and the panel rises a few pixels. After `open`
68
+ turns false it stays mounted until that transition ends, then unmounts. While it leaves,
69
+ focus is already back on the opener and the dialog takes no clicks.
70
+
71
+ ## Drawer
72
+
73
+ A panel that slides in from an edge of the screen over a scrim. It renders the vanilla
74
+ `drawer()` markup, class for class, so it looks and moves like the kit's drawer, and like
75
+ `Pagination` its styles come from `@apliteni/apliteni-ui/css` rather than from this bundle.
76
+ Group what goes inside it the way `drawerSection()` does — a heading over a `<dl>` of label
77
+ and value rows — rather than in cards; the rules are on Guidelines / Drawers.
78
+
79
+ ```tsx
80
+ <Drawer open={open} title="Transaction" onClose={() => setOpen(false)}
81
+ side="right" size="md" footer={<Button onClick={save}>Save</Button>}>
82
+
83
+ </Drawer>
84
+ ```
85
+
86
+ `side` is `right` (default), `left`, `top` or `bottom`. `size` is `sm`, `md` (default) or
87
+ `lg`, measured along the slide. `closeLabel` names the close button (default "Close").
88
+ Focus, Escape, the scrim, Tab and the return of focus behave as the Modal's do. Like the
89
+ Modal, it stays mounted until its exit slide ends. It is portalled to `document.body`.
90
+
91
+ React Modals, Drawers and CommandPalettes share one stack. When one is open over another,
92
+ only the top one takes Escape and Tab, and closing it hands focus back to the one below —
93
+ so a destructive palette row that opens a Modal takes one Escape to answer, not one that
94
+ closes both. The vanilla `drawer()`, `confirm()` and `commandPalette()` keep a separate
95
+ stack that this one cannot see, so do not open a React dialog and a vanilla overlay over
96
+ each other on the same page.
97
+
50
98
  ## Work on them
51
99
 
52
100
  From the repo root — one `npm install` covers the workspace:
@@ -25,7 +25,12 @@
25
25
  backdrop-filter: blur(2px);
26
26
  display: grid;
27
27
  place-items: center;
28
- z-index: 50;
28
+ z-index: calc(var(--z-overlay) + 1);
29
+ opacity: 0;
30
+ transition: opacity var(--dur-med) var(--ease);
31
+ }
32
+ .rx-scrim.is-open {
33
+ opacity: 1;
29
34
  }
30
35
  .rx-modal {
31
36
  width: min(480px, 92vw);
@@ -34,6 +39,11 @@
34
39
  border-radius: var(--radius-xl);
35
40
  box-shadow: var(--shadow-lg);
36
41
  overflow: hidden;
42
+ transform: translateY(8px);
43
+ transition: transform var(--dur-med) var(--ease);
44
+ }
45
+ .rx-scrim.is-open .rx-modal {
46
+ transform: none;
37
47
  }
38
48
  .rx-modal__head {
39
49
  display: flex;
@@ -23,9 +23,11 @@ declare function Badge({ variant, children }: {
23
23
  children: ReactNode;
24
24
  }): react.JSX.Element;
25
25
 
26
- declare function Card({ title, sub, children }: {
26
+ type Level = 2 | 3 | 4 | 5 | 6;
27
+ declare function Card({ title, sub, level, children }: {
27
28
  title?: ReactNode;
28
29
  sub?: ReactNode;
30
+ level?: Level;
29
31
  children?: ReactNode;
30
32
  }): react.JSX.Element;
31
33
 
@@ -38,6 +40,63 @@ type ModalProps = {
38
40
  };
39
41
  declare function Modal({ open, title, onClose, footer, children }: ModalProps): react.ReactPortal | null;
40
42
 
43
+ type DrawerProps = {
44
+ open: boolean;
45
+ title: string;
46
+ onClose: () => void;
47
+ side?: 'right' | 'left' | 'top' | 'bottom';
48
+ size?: 'sm' | 'md' | 'lg';
49
+ footer?: ReactNode;
50
+ children?: ReactNode;
51
+ closeLabel?: string;
52
+ };
53
+ declare function Drawer({ open, title, onClose, side, size, footer, children, closeLabel, }: DrawerProps): react.ReactPortal | null;
54
+
55
+ type CommandItem = {
56
+ id: string;
57
+ label: string;
58
+ description?: string;
59
+ icon?: string;
60
+ /** Aliases a reader might type instead of the label. */
61
+ keywords?: string[];
62
+ /** Drawn as <kbd>, never read out: the row already says what it does. */
63
+ shortcut?: string | string[];
64
+ badge?: string;
65
+ /** A row that goes somewhere. Cmd or Ctrl held on Enter opens it in a tab. */
66
+ href?: string;
67
+ /** A row that destroys something. It must carry `onConfirm`, or it is disabled. */
68
+ danger?: boolean;
69
+ /** What a destructive row opens instead of running. */
70
+ onConfirm?: () => void;
71
+ disabled?: boolean;
72
+ };
73
+ type CommandGroup = {
74
+ label?: string;
75
+ items: CommandItem[];
76
+ };
77
+ type CommandPaletteProps = {
78
+ open: boolean;
79
+ onClose: () => void;
80
+ groups: CommandGroup[];
81
+ /** What the reader chose. `newTab` is Cmd or Ctrl held, for a row with an href. */
82
+ onSelect?: (item: CommandItem, meta: {
83
+ newTab: boolean;
84
+ }) => void;
85
+ label?: string;
86
+ placeholder?: string;
87
+ empty?: string;
88
+ density?: 'compact' | 'roomy';
89
+ hint?: boolean;
90
+ /**
91
+ * false → the caller ranks. `groups` is rendered in the order it is given and
92
+ * `onQueryChange` is where the query goes — the shape a palette fed by a
93
+ * server takes, where the rest of the results are not on this page to rank.
94
+ */
95
+ rank?: boolean;
96
+ onQueryChange?: (query: string) => void;
97
+ };
98
+ declare function CommandPalette({ open, onClose, groups, onSelect, label, placeholder, empty, density, hint, rank, onQueryChange, }: CommandPaletteProps): react.ReactPortal | null;
99
+
41
100
  type Column<T> = {
42
101
  key: keyof T & string;
43
102
  label: string;
@@ -163,4 +222,4 @@ declare function Denied({ title, sub, need, icon, className, children, }: Denied
163
222
  declare const PAGE_SIZES: readonly number[];
164
223
  declare const DEFAULT_PAGE_SIZE: number;
165
224
 
166
- export { Badge, BusyRegion, type BusyRegionProps, Button, type ButtonProps, Card, type Column, DEFAULT_PAGE_SIZE, DataTable, type DataTableProps, Denied, type DeniedProps, Icon, Modal, type ModalProps, PAGE_SIZES, Pagination, type PaginationProps, Skeleton, type SkeletonProps, SkeletonTable, type SkeletonTableProps, type TableSort, sortTableRows };
225
+ export { Badge, BusyRegion, type BusyRegionProps, Button, type ButtonProps, Card, type Column, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, DEFAULT_PAGE_SIZE, DataTable, type DataTableProps, Denied, type DeniedProps, Drawer, type DrawerProps, Icon, Modal, type ModalProps, PAGE_SIZES, Pagination, type PaginationProps, Skeleton, type SkeletonProps, SkeletonTable, type SkeletonTableProps, type TableSort, sortTableRows };