@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.
- package/README.md +2 -1
- package/dist/alert.js +2 -2
- package/dist/button.d.ts +22 -7
- package/dist/button.js +9 -3
- package/dist/{chunk-BMVVSFAU.js → chunk-2H7CEOL5.js} +1 -1
- package/dist/chunk-77W2JTCK.js +116 -0
- package/dist/chunk-A3PPKK5J.js +23 -0
- package/dist/chunk-BAJCEDO3.js +17 -0
- package/dist/chunk-DOCL5Y45.js +14 -0
- package/dist/chunk-FKO6T5XG.js +71 -0
- package/dist/chunk-GRQMKQRL.js +21 -0
- package/dist/chunk-I5VJBLHP.js +36 -0
- package/dist/chunk-OJJPFVTC.js +154 -0
- package/dist/chunk-OUFCQ2JE.js +126 -0
- package/dist/chunk-QW7IHDAG.js +36 -0
- package/dist/chunk-U7RNP366.js +16 -0
- package/dist/chunk-URS474NU.js +228 -0
- package/dist/chunk-WHFF7XSS.js +224 -0
- package/dist/clipboard-button.d.ts +28 -0
- package/dist/clipboard-button.js +11 -0
- package/dist/code-block.d.ts +16 -0
- package/dist/code-block.js +16 -0
- package/dist/command-palette.d.ts +9 -1
- package/dist/command-palette.js +1 -1
- package/dist/docs-navigation.d.ts +64 -0
- package/dist/docs-navigation.js +15 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +107 -25
- package/dist/kbd.d.ts +8 -0
- package/dist/kbd.js +8 -0
- package/dist/link-card.d.ts +8 -0
- package/dist/link-card.js +8 -0
- package/dist/locale-picker.d.ts +18 -0
- package/dist/locale-picker.js +9 -0
- package/dist/platform-link.d.ts +15 -0
- package/dist/platform-link.js +10 -0
- package/dist/prose.d.ts +10 -0
- package/dist/prose.js +10 -0
- package/dist/scroll-header.d.ts +17 -0
- package/dist/scroll-header.js +10 -0
- package/dist/site-layout.d.ts +16 -0
- package/dist/site-layout.js +16 -0
- package/dist/styles.css +693 -0
- package/dist/toast-provider.d.ts +30 -0
- package/dist/toast-provider.js +11 -0
- package/package.json +45 -1
- package/dist/chunk-3TIYT55P.js +0 -14
- 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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oddmash/ui",
|
|
3
|
-
"version": "0.
|
|
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": {
|
package/dist/chunk-3TIYT55P.js
DELETED
|
@@ -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
|
-
};
|
package/dist/chunk-WODRU2UN.js
DELETED
|
@@ -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
|
-
};
|