@optimum-intelligence/opti-ui 0.7.5 → 0.8.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/CHANGELOG.md +77 -0
- package/README.md +24 -11
- package/dist/components/alert/Alert.d.ts +5 -2
- package/dist/components/alert/Alert.js +67 -65
- package/dist/components/alert/Alert.js.map +1 -1
- package/dist/components/app-shell/AppShell.d.ts +19 -7
- package/dist/components/app-shell/AppShell.js +329 -303
- package/dist/components/app-shell/AppShell.js.map +1 -1
- package/dist/components/calendar/Calendar.js +140 -136
- package/dist/components/calendar/Calendar.js.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +8 -2
- package/dist/components/combobox/Combobox.js +182 -202
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/data-table/DataTable.d.ts +23 -11
- package/dist/components/data-table/DataTable.js +148 -88
- package/dist/components/data-table/DataTable.js.map +1 -1
- package/dist/components/data-table/DataTableContent.js +1 -1
- package/dist/components/data-table/DataTableFilters.d.ts +56 -4
- package/dist/components/data-table/DataTableFilters.js +492 -77
- package/dist/components/data-table/DataTableFilters.js.map +1 -1
- package/dist/components/data-table/types.d.ts +13 -2
- package/dist/components/data-table/useDataTable.d.ts +1 -1
- package/dist/components/data-table/useDataTable.js +251 -229
- package/dist/components/data-table/useDataTable.js.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +5 -0
- package/dist/components/date-picker/DatePicker.js +148 -140
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/date-picker/DateRangePicker.d.ts +2 -0
- package/dist/components/date-picker/DateRangePicker.js +171 -164
- package/dist/components/date-picker/DateRangePicker.js.map +1 -1
- package/dist/components/date-picker/PickerField.d.ts +6 -3
- package/dist/components/date-picker/PickerField.js +166 -159
- package/dist/components/date-picker/PickerField.js.map +1 -1
- package/dist/components/dialog/ConfirmDialog.d.ts +5 -2
- package/dist/components/dialog/ConfirmDialog.js +79 -77
- package/dist/components/dialog/ConfirmDialog.js.map +1 -1
- package/dist/components/dialog/Dialog.d.ts +5 -2
- package/dist/components/dialog/Dialog.js +65 -63
- package/dist/components/dialog/Dialog.js.map +1 -1
- package/dist/components/drawer/Drawer.d.ts +13 -4
- package/dist/components/drawer/Drawer.js +122 -164
- package/dist/components/drawer/Drawer.js.map +1 -1
- package/dist/components/field/Field.d.ts +38 -9
- package/dist/components/field/Field.js +66 -1
- package/dist/components/field/Field.js.map +1 -1
- package/dist/components/file-upload/FileUpload.js +2 -0
- package/dist/components/file-upload/FileUpload.js.map +1 -1
- package/dist/components/input/Input.d.ts +9 -16
- package/dist/components/input/Input.js +124 -206
- package/dist/components/input/Input.js.map +1 -1
- package/dist/components/map/Map.d.ts +29 -3
- package/dist/components/map/Map.js +332 -160
- package/dist/components/map/Map.js.map +1 -1
- package/dist/components/map/colors.d.ts +2 -2
- package/dist/components/map/colors.js +12 -3
- package/dist/components/map/colors.js.map +1 -1
- package/dist/components/number-field/NumberField.d.ts +12 -3
- package/dist/components/number-field/NumberField.js +109 -130
- package/dist/components/number-field/NumberField.js.map +1 -1
- package/dist/components/pagination/Pagination.js +135 -186
- package/dist/components/pagination/Pagination.js.map +1 -1
- package/dist/components/search-input/SearchInput.d.ts +5 -2
- package/dist/components/search-input/SearchInput.js +47 -45
- package/dist/components/search-input/SearchInput.js.map +1 -1
- package/dist/components/select/Select.d.ts +13 -3
- package/dist/components/select/Select.js +144 -139
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/spinner/Spinner.d.ts +6 -2
- package/dist/components/spinner/Spinner.js +42 -40
- package/dist/components/spinner/Spinner.js.map +1 -1
- package/dist/components/stepper/Stepper.js +44 -40
- package/dist/components/stepper/Stepper.js.map +1 -1
- package/dist/components/toast/Toast.d.ts +17 -1
- package/dist/components/toast/Toast.js +65 -33
- package/dist/components/toast/Toast.js.map +1 -1
- package/dist/components.json +393 -59
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -3
- package/dist/labels/Labels.d.ts +85 -0
- package/dist/labels/Labels.js +92 -0
- package/dist/labels/Labels.js.map +1 -0
- package/dist/llms-full.txt +231 -45
- package/dist/llms.txt +10 -4
- package/dist/opti-ui.css +212 -18
- package/dist/theme/ThemeProvider.d.ts +8 -4
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/utils/media.d.ts +9 -2
- package/dist/utils/media.js +10 -3
- package/dist/utils/media.js.map +1 -1
- package/package.json +5 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import { useLabels } from "../../labels/Labels.js";
|
|
3
4
|
import { CheckIcon, XIcon } from "../../icons/index.js";
|
|
4
5
|
import { c } from "react/compiler-runtime";
|
|
5
6
|
import "react";
|
|
@@ -19,7 +20,7 @@ var defaultLabels = {
|
|
|
19
20
|
* <Stepper current={1} steps={[{ label: 'Vehicle' }, { label: 'Date' }, { label: 'Route' }, { label: 'Summary' }]} />
|
|
20
21
|
*/
|
|
21
22
|
function Stepper(t0) {
|
|
22
|
-
const $ = c(
|
|
23
|
+
const $ = c(29);
|
|
23
24
|
let className;
|
|
24
25
|
let labels;
|
|
25
26
|
let props;
|
|
@@ -52,27 +53,30 @@ function Stepper(t0) {
|
|
|
52
53
|
const current = t1 === void 0 ? 0 : t1;
|
|
53
54
|
const orientation = t2 === void 0 ? "horizontal" : t2;
|
|
54
55
|
const size = t3 === void 0 ? "md" : t3;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const t4 = useLabels();
|
|
57
|
+
let t5;
|
|
58
|
+
if ($[9] !== labels || $[10] !== t4.stepper) {
|
|
59
|
+
t5 = {
|
|
58
60
|
...defaultLabels,
|
|
61
|
+
...t4.stepper,
|
|
59
62
|
...labels
|
|
60
63
|
};
|
|
61
64
|
$[9] = labels;
|
|
62
|
-
$[10] = t4;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if ($[11] !== className) {
|
|
67
|
-
t5 = cx("oui-stepper", className);
|
|
68
|
-
$[11] = className;
|
|
69
|
-
$[12] = t5;
|
|
70
|
-
} else t5 = $[12];
|
|
65
|
+
$[10] = t4.stepper;
|
|
66
|
+
$[11] = t5;
|
|
67
|
+
} else t5 = $[11];
|
|
68
|
+
const text = t5;
|
|
71
69
|
let t6;
|
|
72
|
-
if ($[
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
if ($[12] !== className) {
|
|
71
|
+
t6 = cx("oui-stepper", className);
|
|
72
|
+
$[12] = className;
|
|
73
|
+
$[13] = t6;
|
|
74
|
+
} else t6 = $[13];
|
|
75
|
+
let t7;
|
|
76
|
+
if ($[14] !== current || $[15] !== steps || $[16] !== text) {
|
|
77
|
+
let t8;
|
|
78
|
+
if ($[18] !== current || $[19] !== steps.length || $[20] !== text) {
|
|
79
|
+
t8 = (step, index) => {
|
|
76
80
|
const status = step.status ?? (index < current ? "complete" : index === current ? "current" : "upcoming");
|
|
77
81
|
return /* @__PURE__ */ jsxs("li", {
|
|
78
82
|
className: "oui-stepper__step",
|
|
@@ -113,36 +117,36 @@ function Stepper(t0) {
|
|
|
113
117
|
})]
|
|
114
118
|
}, step.id ?? index);
|
|
115
119
|
};
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
} else
|
|
121
|
-
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
} else
|
|
127
|
-
let
|
|
128
|
-
if ($[
|
|
129
|
-
|
|
120
|
+
$[18] = current;
|
|
121
|
+
$[19] = steps.length;
|
|
122
|
+
$[20] = text;
|
|
123
|
+
$[21] = t8;
|
|
124
|
+
} else t8 = $[21];
|
|
125
|
+
t7 = steps.map(t8);
|
|
126
|
+
$[14] = current;
|
|
127
|
+
$[15] = steps;
|
|
128
|
+
$[16] = text;
|
|
129
|
+
$[17] = t7;
|
|
130
|
+
} else t7 = $[17];
|
|
131
|
+
let t8;
|
|
132
|
+
if ($[22] !== orientation || $[23] !== props || $[24] !== ref || $[25] !== size || $[26] !== t6 || $[27] !== t7) {
|
|
133
|
+
t8 = /* @__PURE__ */ jsx("ol", {
|
|
130
134
|
ref,
|
|
131
|
-
className:
|
|
135
|
+
className: t6,
|
|
132
136
|
"data-orientation": orientation,
|
|
133
137
|
"data-size": size,
|
|
134
138
|
...props,
|
|
135
|
-
children:
|
|
139
|
+
children: t7
|
|
136
140
|
});
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[25] = t5;
|
|
141
|
+
$[22] = orientation;
|
|
142
|
+
$[23] = props;
|
|
143
|
+
$[24] = ref;
|
|
144
|
+
$[25] = size;
|
|
142
145
|
$[26] = t6;
|
|
143
146
|
$[27] = t7;
|
|
144
|
-
|
|
145
|
-
|
|
147
|
+
$[28] = t8;
|
|
148
|
+
} else t8 = $[28];
|
|
149
|
+
return t8;
|
|
146
150
|
}
|
|
147
151
|
//#endregion
|
|
148
152
|
export { Stepper };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.js","names":["React","cx","CheckIcon","XIcon","StepStatus","StepItem","id","label","ReactNode","description","status","icon","StepperLabels","complete","current","upcoming","error","defaultLabels","StepperProps","OlHTMLAttributes","HTMLOListElement","ref","Ref","steps","orientation","size","labels","Partial","Stepper","t0","$","_c","className","props","t1","t2","t3","undefined","t4","
|
|
1
|
+
{"version":3,"file":"Stepper.js","names":["React","cx","CheckIcon","XIcon","useLabels","StepStatus","StepItem","id","label","ReactNode","description","status","icon","StepperLabels","complete","current","upcoming","error","defaultLabels","StepperProps","OlHTMLAttributes","HTMLOListElement","ref","Ref","steps","orientation","size","labels","Partial","Stepper","t0","$","_c","className","props","t1","t2","t3","undefined","t4","t5","stepper","text","t6","t7","t8","length","step","index","map","_c"],"sources":["../../../src/components/stepper/Stepper.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx } from '../../utils/cx';\nimport { CheckIcon, XIcon } from '../../icons';\nimport { useLabels } from '../../labels/Labels';\n\nexport type StepStatus = 'complete' | 'current' | 'upcoming' | 'error';\n\nexport interface StepItem {\n /** Stable key; falls back to the index. */\n id?: string;\n label: React.ReactNode;\n description?: React.ReactNode;\n /** Overrides the status derived from `current`. */\n status?: StepStatus;\n /** Replaces the number / check mark inside the marker. */\n icon?: React.ReactNode;\n}\n\nexport interface StepperLabels {\n complete: string;\n current: string;\n upcoming: string;\n error: string;\n}\n\nconst defaultLabels: StepperLabels = {\n complete: 'Completed',\n current: 'Current',\n upcoming: 'Not started',\n error: 'Failed',\n};\n\nexport interface StepperProps extends React.OlHTMLAttributes<HTMLOListElement> {\n /** Ref to the `<ol>` element. */\n ref?: React.Ref<HTMLOListElement>;\n /** The steps in order. */\n steps: StepItem[];\n /** Index of the active step. Earlier steps are complete; `steps.length` completes all of them. */\n current?: number;\n /** Lay the steps out in a row or a column. */\n orientation?: 'horizontal' | 'vertical';\n /** Marker and text size. */\n size?: 'sm' | 'md';\n /** Screen-reader text for each status. */\n labels?: Partial<StepperLabels>;\n}\n\n/**\n * Progress through an ordered sequence: a wizard, a checkout, a background job's phases. Below 640px a\n * horizontal stepper turns compact: a segmented progress bar under the current step (\"2/4 · Date\").\n *\n * @example\n * <Stepper current={1} steps={[{ label: 'Vehicle' }, { label: 'Date' }, { label: 'Route' }, { label: 'Summary' }]} />\n */\nexport function Stepper({\n steps,\n current = 0,\n orientation = 'horizontal',\n size = 'md',\n labels,\n className,\n ref,\n ...props\n}: StepperProps) {\n const text = { ...defaultLabels, ...useLabels().stepper, ...labels };\n return (\n <ol ref={ref} className={cx('oui-stepper', className)} data-orientation={orientation} data-size={size} {...props}>\n {steps.map((step, index) => {\n const status: StepStatus =\n step.status ?? (index < current ? 'complete' : index === current ? 'current' : 'upcoming');\n return (\n <li\n key={step.id ?? index}\n className=\"oui-stepper__step\"\n data-status={status}\n aria-current={status === 'current' ? 'step' : undefined}\n >\n <span className=\"oui-stepper__marker\" aria-hidden>\n {step.icon ?? (status === 'complete' ? <CheckIcon strokeWidth={3} /> : status === 'error' ? <XIcon strokeWidth={3} /> : index + 1)}\n </span>\n <span className=\"oui-stepper__text\">\n {/* \"2/4 ·\" before the label; only the compact layout below 640px shows it. */}\n <span className=\"oui-stepper__count\" aria-hidden>\n {index + 1}/{steps.length}\n </span>\n <span className=\"oui-stepper__label\">\n {step.label}\n <span className=\"oui-visually-hidden\"> ({text[status]})</span>\n </span>\n {step.description && <span className=\"oui-stepper__description\">{step.description}</span>}\n </span>\n </li>\n );\n })}\n </ol>\n );\n}\n"],"mappings":";;;;;;;;AAyBA,IAAMkB,gBAA+B;CACnCJ,UAAU;CACVC,SAAS;CACTC,UAAU;CACVC,OAAO;AACT;;;;;;;;AAwBA,SAAOY,QAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAN;CAAA,IAAAO;CAAA,IAAAZ;CAAA,IAAAE;CAAA,IAAAW;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAN,EAAA,OAAAD,IAAA;EAAiB,CAAA,CAAAN,OAAAT,SAAAoB,IAAAV,aAAAW,IAAAV,MAAAW,IAAAV,QAAAM,WAAAX,KAAA,GAAAY,SAAAJ;EASTC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAJ;EAAAI,EAAA,KAAAG;EAAAH,EAAA,KAAAT;EAAAS,EAAA,KAAAP;EAAAO,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAA;EAAAJ,YAAAF,EAAA;EAAAJ,SAAAI,EAAA;EAAAG,QAAAH,EAAA;EAAAT,MAAAS,EAAA;EAAAP,QAAAO,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;EAAAM,KAAAN,EAAA;CAAA;CAPb,MAAAhB,UAAAoB,OAAAG,KAAAA,IAAA,IAAAH;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 'success' | 'warning' | 'danger' | 'neutral';
|
|
4
4
|
export type ToastPlacement = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'bottom-center' | 'top-center';
|
|
5
|
+
/** Extra per-toast options, passed as `data` when adding a toast. */
|
|
6
|
+
export interface ToastData {
|
|
7
|
+
/** Replaces the tone's icon; `null` shows none. */
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
/** Custom content under the title and description: a link, a progress bar, a list… */
|
|
10
|
+
content?: React.ReactNode;
|
|
11
|
+
}
|
|
5
12
|
export interface ToastProviderProps extends Omit<BaseToast.Provider.Props, 'children'> {
|
|
6
13
|
/** App content; toasts render over it. */
|
|
7
14
|
children?: React.ReactNode;
|
|
@@ -13,11 +20,20 @@ export interface ToastProviderProps extends Omit<BaseToast.Provider.Props, 'chil
|
|
|
13
20
|
/**
|
|
14
21
|
* Mount once near the app root. Then call `useToast()` anywhere below, or pass
|
|
15
22
|
* a `toastManager` from `createToastManager()` to trigger toasts outside React.
|
|
23
|
+
* Bottom toasts sit `--oui-toast-offset-bottom` above the screen edge; AppShell sets it for its mobile tab bar.
|
|
16
24
|
*/
|
|
17
25
|
export declare function ToastProvider({ children, placement, viewportClassName, ...props }: ToastProviderProps): React.JSX.Element;
|
|
18
26
|
type AddOptions = Parameters<ReturnType<typeof BaseToast.useToastManager>['add']>[0];
|
|
19
27
|
type ToneOptions = Omit<AddOptions, 'type'>;
|
|
20
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Toast API with tone shortcuts: `toast.success({ title })`. `data` takes a custom `icon` and `content`
|
|
30
|
+
* (`ToastData`), and `toast.promise()` shows a loading toast that turns into success or error.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const toast = useToast();
|
|
34
|
+
* toast.success({ title: 'Route saved', data: { content: <Link href="/routes/12">Open route</Link> } });
|
|
35
|
+
* toast.promise(save(), { loading: 'Saving…', success: 'Saved', error: 'Could not save' });
|
|
36
|
+
*/
|
|
21
37
|
export declare function useToast(): {
|
|
22
38
|
toasts: import("@base-ui/react").ToastObject<any>[];
|
|
23
39
|
add: <T extends any = any>(options: import("@base-ui/react").ToastManagerAddOptions<T>) => string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { usePortalContainer } from "../../utils/portal.js";
|
|
3
3
|
import { cx } from "../../utils/cx.js";
|
|
4
|
+
import { useLabels } from "../../labels/Labels.js";
|
|
4
5
|
import { CircleCheckIcon, CircleXIcon, InfoIcon, TriangleAlertIcon, XIcon } from "../../icons/index.js";
|
|
6
|
+
import { Spinner } from "../spinner/Spinner.js";
|
|
5
7
|
import { c } from "react/compiler-runtime";
|
|
6
8
|
import "react";
|
|
7
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -11,47 +13,69 @@ var icons = {
|
|
|
11
13
|
info: /* @__PURE__ */ jsx(InfoIcon, {}),
|
|
12
14
|
success: /* @__PURE__ */ jsx(CircleCheckIcon, {}),
|
|
13
15
|
warning: /* @__PURE__ */ jsx(TriangleAlertIcon, {}),
|
|
14
|
-
danger: /* @__PURE__ */ jsx(CircleXIcon, {})
|
|
16
|
+
danger: /* @__PURE__ */ jsx(CircleXIcon, {}),
|
|
17
|
+
error: /* @__PURE__ */ jsx(CircleXIcon, {}),
|
|
18
|
+
loading: /* @__PURE__ */ jsx(Spinner, {
|
|
19
|
+
size: "sm",
|
|
20
|
+
label: null
|
|
21
|
+
})
|
|
15
22
|
};
|
|
16
23
|
function ToastList() {
|
|
17
|
-
const $ = c(
|
|
24
|
+
const $ = c(5);
|
|
18
25
|
const { toasts } = Toast.useToastManager();
|
|
26
|
+
const text = useLabels();
|
|
19
27
|
let t0;
|
|
20
|
-
if ($[0] !== toasts) {
|
|
21
|
-
|
|
22
|
-
$[
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
if ($[0] !== text || $[1] !== toasts) {
|
|
29
|
+
let t1;
|
|
30
|
+
if ($[3] !== text) {
|
|
31
|
+
t1 = (toast) => {
|
|
32
|
+
const data = toast.data;
|
|
33
|
+
const icon = data?.icon !== void 0 ? data.icon : toast.type && icons[toast.type];
|
|
34
|
+
return /* @__PURE__ */ jsx(Toast.Root, {
|
|
35
|
+
toast,
|
|
36
|
+
className: "oui-toast",
|
|
37
|
+
children: /* @__PURE__ */ jsxs(Toast.Content, {
|
|
38
|
+
className: "oui-toast__content",
|
|
39
|
+
children: [
|
|
40
|
+
icon && /* @__PURE__ */ jsx("span", {
|
|
41
|
+
className: "oui-toast__icon",
|
|
42
|
+
children: icon
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsxs("div", {
|
|
45
|
+
className: "oui-toast__text",
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(Toast.Title, { className: "oui-toast__title" }),
|
|
48
|
+
/* @__PURE__ */ jsx(Toast.Description, { className: "oui-toast__description" }),
|
|
49
|
+
data?.content && /* @__PURE__ */ jsx("div", {
|
|
50
|
+
className: "oui-toast__body",
|
|
51
|
+
children: data.content
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
toast.actionProps && /* @__PURE__ */ jsx(Toast.Action, { className: "oui-toast__action" }),
|
|
56
|
+
/* @__PURE__ */ jsx(Toast.Close, {
|
|
57
|
+
className: "oui-toast__close",
|
|
58
|
+
"aria-label": text.close,
|
|
59
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
}, toast.id);
|
|
64
|
+
};
|
|
65
|
+
$[3] = text;
|
|
66
|
+
$[4] = t1;
|
|
67
|
+
} else t1 = $[4];
|
|
68
|
+
t0 = toasts.map(t1);
|
|
69
|
+
$[0] = text;
|
|
70
|
+
$[1] = toasts;
|
|
71
|
+
$[2] = t0;
|
|
72
|
+
} else t0 = $[2];
|
|
25
73
|
return t0;
|
|
26
74
|
}
|
|
27
|
-
function _temp(toast) {
|
|
28
|
-
return /* @__PURE__ */ jsx(Toast.Root, {
|
|
29
|
-
toast,
|
|
30
|
-
className: "oui-toast",
|
|
31
|
-
children: /* @__PURE__ */ jsxs(Toast.Content, {
|
|
32
|
-
className: "oui-toast__content",
|
|
33
|
-
children: [
|
|
34
|
-
toast.type && icons[toast.type] && /* @__PURE__ */ jsx("span", {
|
|
35
|
-
className: "oui-toast__icon",
|
|
36
|
-
children: icons[toast.type]
|
|
37
|
-
}),
|
|
38
|
-
/* @__PURE__ */ jsxs("div", {
|
|
39
|
-
className: "oui-toast__text",
|
|
40
|
-
children: [/* @__PURE__ */ jsx(Toast.Title, { className: "oui-toast__title" }), /* @__PURE__ */ jsx(Toast.Description, { className: "oui-toast__description" })]
|
|
41
|
-
}),
|
|
42
|
-
toast.actionProps && /* @__PURE__ */ jsx(Toast.Action, { className: "oui-toast__action" }),
|
|
43
|
-
/* @__PURE__ */ jsx(Toast.Close, {
|
|
44
|
-
className: "oui-toast__close",
|
|
45
|
-
"aria-label": "Close",
|
|
46
|
-
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
47
|
-
})
|
|
48
|
-
]
|
|
49
|
-
})
|
|
50
|
-
}, toast.id);
|
|
51
|
-
}
|
|
52
75
|
/**
|
|
53
76
|
* Mount once near the app root. Then call `useToast()` anywhere below, or pass
|
|
54
77
|
* a `toastManager` from `createToastManager()` to trigger toasts outside React.
|
|
78
|
+
* Bottom toasts sit `--oui-toast-offset-bottom` above the screen edge; AppShell sets it for its mobile tab bar.
|
|
55
79
|
*/
|
|
56
80
|
function ToastProvider(t0) {
|
|
57
81
|
const $ = c(18);
|
|
@@ -119,7 +143,15 @@ function ToastProvider(t0) {
|
|
|
119
143
|
} else t6 = $[17];
|
|
120
144
|
return t6;
|
|
121
145
|
}
|
|
122
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* Toast API with tone shortcuts: `toast.success({ title })`. `data` takes a custom `icon` and `content`
|
|
148
|
+
* (`ToastData`), and `toast.promise()` shows a loading toast that turns into success or error.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* const toast = useToast();
|
|
152
|
+
* toast.success({ title: 'Route saved', data: { content: <Link href="/routes/12">Open route</Link> } });
|
|
153
|
+
* toast.promise(save(), { loading: 'Saving…', success: 'Saved', error: 'Could not save' });
|
|
154
|
+
*/
|
|
123
155
|
function useToast() {
|
|
124
156
|
const $ = c(13);
|
|
125
157
|
const manager = Toast.useToastManager();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","names":["React","Toast","BaseToast","cx","usePortalContainer","CircleCheckIcon","CircleXIcon","InfoIcon","TriangleAlertIcon","XIcon","ToastTone","ToastPlacement","icons","Partial","Record","
|
|
1
|
+
{"version":3,"file":"Toast.js","names":["React","Toast","BaseToast","cx","usePortalContainer","useLabels","Spinner","CircleCheckIcon","CircleXIcon","InfoIcon","TriangleAlertIcon","XIcon","ToastTone","ToastPlacement","ToastData","icon","ReactNode","content","icons","Partial","Record","info","success","warning","danger","error","loading","ToastList","$","_c","toasts","useToastManager","text","t0","t1","toast","data","undefined","type","id","actionProps","close","map","ToastProviderProps","Omit","Provider","Props","children","placement","viewportClassName","ToastProvider","props","container","t2","t3","Symbol","for","t4","t5","t6","AddOptions","Parameters","ReturnType","ToneOptions","useToast","manager","options","add","options_0","options_1","options_2","options_3","priority","show","createToastManager","_c","BaseToast"],"sources":["../../../src/components/toast/Toast.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Toast as BaseToast } from '@base-ui/react/toast';\nimport { cx } from '../../utils/cx';\nimport { usePortalContainer } from '../../utils/portal';\nimport { useLabels } from '../../labels/Labels';\nimport { Spinner } from '../spinner/Spinner';\nimport { CircleCheckIcon, CircleXIcon, InfoIcon, TriangleAlertIcon, XIcon } from '../../icons';\n\nexport type ToastTone = 'info' | 'success' | 'warning' | 'danger' | 'neutral';\n\nexport type ToastPlacement = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'bottom-center' | 'top-center';\n\n/** Extra per-toast options, passed as `data` when adding a toast. */\nexport interface ToastData {\n /** Replaces the tone's icon; `null` shows none. */\n icon?: React.ReactNode;\n /** Custom content under the title and description: a link, a progress bar, a list… */\n content?: React.ReactNode;\n}\n\n// `error` and `loading` are the types `toast.promise()` sets.\nconst icons: Partial<Record<string, React.ReactNode>> = {\n info: <InfoIcon />,\n success: <CircleCheckIcon />,\n warning: <TriangleAlertIcon />,\n danger: <CircleXIcon />,\n error: <CircleXIcon />,\n loading: <Spinner size=\"sm\" label={null} />,\n};\n\nfunction ToastList() {\n const { toasts } = BaseToast.useToastManager();\n const text = useLabels();\n return toasts.map((toast) => {\n const data = toast.data as ToastData | undefined;\n const icon = data?.icon !== undefined ? data.icon : toast.type && icons[toast.type];\n return (\n <BaseToast.Root key={toast.id} toast={toast} className=\"oui-toast\">\n <BaseToast.Content className=\"oui-toast__content\">\n {icon && <span className=\"oui-toast__icon\">{icon}</span>}\n <div className=\"oui-toast__text\">\n <BaseToast.Title className=\"oui-toast__title\" />\n <BaseToast.Description className=\"oui-toast__description\" />\n {data?.content && <div className=\"oui-toast__body\">{data.content}</div>}\n </div>\n {toast.actionProps && <BaseToast.Action className=\"oui-toast__action\" />}\n <BaseToast.Close className=\"oui-toast__close\" aria-label={text.close}>\n <XIcon />\n </BaseToast.Close>\n </BaseToast.Content>\n </BaseToast.Root>\n );\n });\n}\n\nexport interface ToastProviderProps extends Omit<BaseToast.Provider.Props, 'children'> {\n /** App content; toasts render over it. */\n children?: React.ReactNode;\n /** Screen corner or edge where toasts stack. */\n placement?: ToastPlacement;\n /** Class for the viewport (positioning container). */\n viewportClassName?: string;\n}\n\n/**\n * Mount once near the app root. Then call `useToast()` anywhere below, or pass\n * a `toastManager` from `createToastManager()` to trigger toasts outside React.\n * Bottom toasts sit `--oui-toast-offset-bottom` above the screen edge; AppShell sets it for its mobile tab bar.\n */\nexport function ToastProvider({ children, placement = 'bottom-right', viewportClassName, ...props }: ToastProviderProps) {\n const container = usePortalContainer();\n return (\n <BaseToast.Provider {...props}>\n {children}\n <BaseToast.Portal container={container}>\n <BaseToast.Viewport className={cx('oui-toast-viewport', viewportClassName)} data-placement={placement}>\n <ToastList />\n </BaseToast.Viewport>\n </BaseToast.Portal>\n </BaseToast.Provider>\n );\n}\n\ntype AddOptions = Parameters<ReturnType<typeof BaseToast.useToastManager>['add']>[0];\ntype ToneOptions = Omit<AddOptions, 'type'>;\n\n/**\n * Toast API with tone shortcuts: `toast.success({ title })`. `data` takes a custom `icon` and `content`\n * (`ToastData`), and `toast.promise()` shows a loading toast that turns into success or error.\n *\n * @example\n * const toast = useToast();\n * toast.success({ title: 'Route saved', data: { content: <Link href=\"/routes/12\">Open route</Link> } });\n * toast.promise(save(), { loading: 'Saving…', success: 'Saved', error: 'Could not save' });\n */\nexport function useToast() {\n const manager = BaseToast.useToastManager();\n return {\n ...manager,\n show: (options: AddOptions & { type?: ToastTone }) => manager.add(options),\n info: (options: ToneOptions) => manager.add({ ...options, type: 'info' }),\n success: (options: ToneOptions) => manager.add({ ...options, type: 'success' }),\n warning: (options: ToneOptions) => manager.add({ ...options, type: 'warning' }),\n danger: (options: ToneOptions) => manager.add({ ...options, type: 'danger', priority: 'high' }),\n };\n}\n\nexport const createToastManager = BaseToast.createToastManager;\n"],"mappings":";;;;;;;;;;;AAqBA,IAAMkB,QAAkD;CACtDG,MAAM,oBAAC,UAAD,CAAS,CAAA;CACfC,SAAS,oBAAC,iBAAD,CAAgB,CAAA;CACzBC,SAAS,oBAAC,mBAAD,CAAkB,CAAA;CAC3BC,QAAQ,oBAAC,aAAD,CAAY,CAAA;CACpBC,OAAO,oBAAC,aAAD,CAAY,CAAA;CACnBC,SAAS,oBAAC,SAAD;EAAS,MAAK;EAAK,OAAO;CAAK,CAAA;AAC1C;AAEA,SAAAC,YAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACE,MAAA,EAAAC,WAAmB5B,MAAS6B,gBAAiB;CAC7C,MAAAC,OAAa3B,UAAU;CAAE,IAAA4B;CAAA,IAAA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