@oddmash/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.
Files changed (48) hide show
  1. package/README.md +2 -1
  2. package/dist/alert.js +2 -2
  3. package/dist/button.d.ts +22 -7
  4. package/dist/button.js +9 -3
  5. package/dist/{chunk-BMVVSFAU.js → chunk-2H7CEOL5.js} +1 -1
  6. package/dist/chunk-77W2JTCK.js +116 -0
  7. package/dist/chunk-A3PPKK5J.js +23 -0
  8. package/dist/chunk-BAJCEDO3.js +17 -0
  9. package/dist/chunk-DOCL5Y45.js +14 -0
  10. package/dist/chunk-FKO6T5XG.js +71 -0
  11. package/dist/chunk-GRQMKQRL.js +21 -0
  12. package/dist/chunk-I5VJBLHP.js +36 -0
  13. package/dist/chunk-OJJPFVTC.js +154 -0
  14. package/dist/chunk-OUFCQ2JE.js +126 -0
  15. package/dist/chunk-QW7IHDAG.js +36 -0
  16. package/dist/chunk-U7RNP366.js +16 -0
  17. package/dist/chunk-URS474NU.js +228 -0
  18. package/dist/chunk-WHFF7XSS.js +224 -0
  19. package/dist/clipboard-button.d.ts +28 -0
  20. package/dist/clipboard-button.js +11 -0
  21. package/dist/code-block.d.ts +16 -0
  22. package/dist/code-block.js +16 -0
  23. package/dist/command-palette.d.ts +9 -1
  24. package/dist/command-palette.js +1 -1
  25. package/dist/docs-navigation.d.ts +64 -0
  26. package/dist/docs-navigation.js +15 -0
  27. package/dist/index.d.ts +12 -1
  28. package/dist/index.js +107 -25
  29. package/dist/kbd.d.ts +8 -0
  30. package/dist/kbd.js +8 -0
  31. package/dist/link-card.d.ts +8 -0
  32. package/dist/link-card.js +8 -0
  33. package/dist/locale-picker.d.ts +18 -0
  34. package/dist/locale-picker.js +9 -0
  35. package/dist/platform-link.d.ts +15 -0
  36. package/dist/platform-link.js +10 -0
  37. package/dist/prose.d.ts +10 -0
  38. package/dist/prose.js +10 -0
  39. package/dist/scroll-header.d.ts +17 -0
  40. package/dist/scroll-header.js +10 -0
  41. package/dist/site-layout.d.ts +16 -0
  42. package/dist/site-layout.js +16 -0
  43. package/dist/styles.css +693 -0
  44. package/dist/toast-provider.d.ts +30 -0
  45. package/dist/toast-provider.js +11 -0
  46. package/package.json +45 -1
  47. package/dist/chunk-3TIYT55P.js +0 -14
  48. package/dist/chunk-WODRU2UN.js +0 -69
@@ -0,0 +1,30 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentPropsWithoutRef } from 'react';
3
+ import { ToastProps } from './toast.js';
4
+
5
+ type Tone = NonNullable<ToastProps['tone']>;
6
+ type ToastNotification = {
7
+ title: string;
8
+ description?: ReactNode;
9
+ tone?: Tone;
10
+ icon?: ReactNode;
11
+ duration?: number | null;
12
+ dismissLabel?: string;
13
+ restoreFocusTo?: HTMLElement | null;
14
+ };
15
+ type ToastController = {
16
+ showToast: (options: ToastNotification) => string;
17
+ dismissToast: (id: string) => void;
18
+ };
19
+ type ToastProviderProps = ComponentPropsWithoutRef<'div'> & {
20
+ maxVisible?: number;
21
+ dismissLabel?: string;
22
+ };
23
+ declare const useToast: () => ToastController;
24
+ declare const ToastProvider: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
25
+ maxVisible?: number;
26
+ dismissLabel?: string;
27
+ } & react.RefAttributes<HTMLDivElement>>;
28
+
29
+ export { ToastProvider, useToast };
30
+ export type { ToastController, ToastNotification, ToastProviderProps };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import {
3
+ ToastProvider,
4
+ useToast
5
+ } from "./chunk-WHFF7XSS.js";
6
+ import "./chunk-ITEJEMEF.js";
7
+ import "./chunk-54STG2JB.js";
8
+ export {
9
+ ToastProvider,
10
+ useToast
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddmash/ui",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Small, themeable React foundations for Oddmash tools.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.25.0",
@@ -134,6 +134,50 @@
134
134
  "./command-palette": {
135
135
  "types": "./dist/command-palette.d.ts",
136
136
  "import": "./dist/command-palette.js"
137
+ },
138
+ "./link-card": {
139
+ "types": "./dist/link-card.d.ts",
140
+ "import": "./dist/link-card.js"
141
+ },
142
+ "./code-block": {
143
+ "types": "./dist/code-block.d.ts",
144
+ "import": "./dist/code-block.js"
145
+ },
146
+ "./site-layout": {
147
+ "types": "./dist/site-layout.d.ts",
148
+ "import": "./dist/site-layout.js"
149
+ },
150
+ "./prose": {
151
+ "types": "./dist/prose.d.ts",
152
+ "import": "./dist/prose.js"
153
+ },
154
+ "./platform-link": {
155
+ "types": "./dist/platform-link.d.ts",
156
+ "import": "./dist/platform-link.js"
157
+ },
158
+ "./kbd": {
159
+ "types": "./dist/kbd.d.ts",
160
+ "import": "./dist/kbd.js"
161
+ },
162
+ "./docs-navigation": {
163
+ "types": "./dist/docs-navigation.d.ts",
164
+ "import": "./dist/docs-navigation.js"
165
+ },
166
+ "./scroll-header": {
167
+ "types": "./dist/scroll-header.d.ts",
168
+ "import": "./dist/scroll-header.js"
169
+ },
170
+ "./locale-picker": {
171
+ "types": "./dist/locale-picker.d.ts",
172
+ "import": "./dist/locale-picker.js"
173
+ },
174
+ "./clipboard-button": {
175
+ "types": "./dist/clipboard-button.d.ts",
176
+ "import": "./dist/clipboard-button.js"
177
+ },
178
+ "./toast-provider": {
179
+ "types": "./dist/toast-provider.d.ts",
180
+ "import": "./dist/toast-provider.js"
137
181
  }
138
182
  },
139
183
  "engines": {
@@ -1,14 +0,0 @@
1
- "use client";
2
- import {
3
- cx
4
- } from "./chunk-54STG2JB.js";
5
-
6
- // src/button.tsx
7
- import { forwardRef } from "react";
8
- import { jsx } from "react/jsx-runtime";
9
- var Button = /* @__PURE__ */ forwardRef(({ className, variant = "primary", size = "md", type = "button", ...props }, ref) => /* @__PURE__ */ jsx("button", { ...props, ref, type, className: cx("om-button", `om-button--${variant}`, `om-button--${size}`, className) }));
10
- Button.displayName = "Button";
11
-
12
- export {
13
- Button
14
- };
@@ -1,69 +0,0 @@
1
- "use client";
2
- import {
3
- Dialog,
4
- DialogContent,
5
- DialogDescription,
6
- DialogTitle,
7
- DialogTrigger
8
- } from "./chunk-ME34NDSX.js";
9
- import {
10
- Input
11
- } from "./chunk-5NGRPREI.js";
12
-
13
- // src/command-palette.tsx
14
- import { useEffect, useId, useState } from "react";
15
- import { jsx, jsxs } from "react/jsx-runtime";
16
- var CommandPalette = ({ trigger, title, description, searchLabel, emptyLabel, items, theme, container }) => {
17
- const [open, setOpen] = useState(false);
18
- const [query, setQuery] = useState("");
19
- const [active, setActive] = useState(null);
20
- const id = useId();
21
- const list = items.filter((item) => [item.label, ...item.keywords ?? []].join(" ").toLocaleLowerCase().includes(query.trim().toLocaleLowerCase()));
22
- const available = list.filter((item) => !item.disabled);
23
- const selected = available.find((item) => item.id === active) ?? available[0];
24
- useEffect(() => {
25
- if (open && selected) document.getElementById(`${id}-${list.indexOf(selected)}`)?.scrollIntoView?.({ block: "nearest" });
26
- }, [open, selected, id, list]);
27
- const select = (item) => {
28
- if (item.disabled) return;
29
- setOpen(false);
30
- setQuery("");
31
- setActive(null);
32
- item.onSelect();
33
- };
34
- return /* @__PURE__ */ jsxs(Dialog, { open, onOpenChange: (value) => {
35
- setOpen(value);
36
- if (!value) {
37
- setQuery("");
38
- setActive(null);
39
- }
40
- }, children: [
41
- /* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: trigger }),
42
- /* @__PURE__ */ jsxs(DialogContent, { theme, container, className: "om-command-palette", children: [
43
- /* @__PURE__ */ jsx(DialogTitle, { children: title }),
44
- /* @__PURE__ */ jsx(DialogDescription, { children: description }),
45
- /* @__PURE__ */ jsx(Input, { role: "combobox", "aria-label": searchLabel, "aria-autocomplete": "list", "aria-expanded": "true", "aria-controls": id, "aria-activedescendant": selected ? `${id}-${list.indexOf(selected)}` : void 0, value: query, onChange: (event) => {
46
- setQuery(event.target.value);
47
- setActive(null);
48
- }, onKeyDown: (event) => {
49
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
50
- event.preventDefault();
51
- if (!available.length) return;
52
- const index = selected ? available.indexOf(selected) : 0;
53
- setActive(available[(index + (event.key === "ArrowDown" ? 1 : available.length - 1)) % available.length].id);
54
- } else if (event.key === "Enter" && selected && !event.nativeEvent.isComposing) {
55
- event.preventDefault();
56
- select(selected);
57
- }
58
- } }),
59
- /* @__PURE__ */ jsx("div", { role: "listbox", id, "aria-label": title, className: "om-command-list", children: list.map((item, index) => /* @__PURE__ */ jsx("div", { id: `${id}-${index}`, role: "option", "aria-selected": selected?.id === item.id, "aria-disabled": item.disabled || void 0, onPointerMove: () => {
60
- if (!item.disabled) setActive(item.id);
61
- }, onMouseDown: (event) => event.preventDefault(), onClick: () => select(item), children: item.label }, item.id)) }),
62
- !list.length && /* @__PURE__ */ jsx("p", { role: "status", children: emptyLabel })
63
- ] })
64
- ] });
65
- };
66
-
67
- export {
68
- CommandPalette
69
- };