@underpin/ui 0.0.0-stage → 2.0.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/LICENSE +21 -0
- package/README.md +45 -2
- package/components/autocomplete.d.ts +25 -0
- package/components/autocomplete.js +71 -0
- package/components/autocomplete.js.map +1 -0
- package/components/avatar.d.ts +5 -0
- package/components/avatar.js +26 -0
- package/components/avatar.js.map +1 -0
- package/components/badge.d.ts +36 -0
- package/components/badge.js +140 -0
- package/components/badge.js.map +1 -0
- package/components/bar-list.d.ts +133 -0
- package/components/bar-list.js +204 -0
- package/components/bar-list.js.map +1 -0
- package/components/breakdown-card.d.ts +30 -0
- package/components/breakdown-card.js +43 -0
- package/components/breakdown-card.js.map +1 -0
- package/components/button-group.d.ts +17 -0
- package/components/button-group.js +27 -0
- package/components/button-group.js.map +1 -0
- package/components/button.d.ts +39 -0
- package/components/button.js +128 -0
- package/components/button.js.map +1 -0
- package/components/calendar.d.ts +27 -0
- package/components/calendar.js +95 -0
- package/components/calendar.js.map +1 -0
- package/components/callout.d.ts +26 -0
- package/components/callout.js +71 -0
- package/components/callout.js.map +1 -0
- package/components/card.d.ts +55 -0
- package/components/card.js +96 -0
- package/components/card.js.map +1 -0
- package/components/chart.d.ts +32 -0
- package/components/chart.js +43 -0
- package/components/chart.js.map +1 -0
- package/components/checkbox.d.ts +15 -0
- package/components/checkbox.js +42 -0
- package/components/checkbox.js.map +1 -0
- package/components/code-block.d.ts +21 -0
- package/components/code-block.js +35 -0
- package/components/code-block.js.map +1 -0
- package/components/collapse.d.ts +14 -0
- package/components/collapse.js +25 -0
- package/components/collapse.js.map +1 -0
- package/components/combobox.d.ts +71 -0
- package/components/combobox.js +155 -0
- package/components/combobox.js.map +1 -0
- package/components/copy-button.d.ts +29 -0
- package/components/copy-button.js +100 -0
- package/components/copy-button.js.map +1 -0
- package/components/copy-input.d.ts +15 -0
- package/components/copy-input.js +51 -0
- package/components/copy-input.js.map +1 -0
- package/components/date-picker-trigger.d.ts +12 -0
- package/components/date-picker-trigger.js +30 -0
- package/components/date-picker-trigger.js.map +1 -0
- package/components/date-picker.d.ts +36 -0
- package/components/date-picker.js +70 -0
- package/components/date-picker.js.map +1 -0
- package/components/detail-row.d.ts +51 -0
- package/components/detail-row.js +77 -0
- package/components/detail-row.js.map +1 -0
- package/components/dialog.d.ts +121 -0
- package/components/dialog.js +327 -0
- package/components/dialog.js.map +1 -0
- package/components/disabled-reason.d.ts +31 -0
- package/components/disabled-reason.js +67 -0
- package/components/disabled-reason.js.map +1 -0
- package/components/empty-state.d.ts +41 -0
- package/components/empty-state.js +84 -0
- package/components/empty-state.js.map +1 -0
- package/components/entity-avatar.d.ts +54 -0
- package/components/entity-avatar.js +68 -0
- package/components/entity-avatar.js.map +1 -0
- package/components/form-section.d.ts +22 -0
- package/components/form-section.js +38 -0
- package/components/form-section.js.map +1 -0
- package/components/form.d.ts +199 -0
- package/components/form.js +456 -0
- package/components/form.js.map +1 -0
- package/components/formatted-number.d.ts +21 -0
- package/components/formatted-number.js +13 -0
- package/components/formatted-number.js.map +1 -0
- package/components/heading.d.ts +23 -0
- package/components/heading.js +44 -0
- package/components/heading.js.map +1 -0
- package/components/icon-swap.d.ts +15 -0
- package/components/icon-swap.js +29 -0
- package/components/icon-swap.js.map +1 -0
- package/components/inline-action.d.ts +21 -0
- package/components/inline-action.js +36 -0
- package/components/inline-action.js.map +1 -0
- package/components/input.d.ts +51 -0
- package/components/input.js +52 -0
- package/components/input.js.map +1 -0
- package/components/kbd.d.ts +17 -0
- package/components/kbd.js +34 -0
- package/components/kbd.js.map +1 -0
- package/components/label.d.ts +10 -0
- package/components/label.js +20 -0
- package/components/label.js.map +1 -0
- package/components/menu.d.ts +77 -0
- package/components/menu.js +189 -0
- package/components/menu.js.map +1 -0
- package/components/nav-button.d.ts +34 -0
- package/components/nav-button.js +71 -0
- package/components/nav-button.js.map +1 -0
- package/components/nav.d.ts +39 -0
- package/components/nav.js +68 -0
- package/components/nav.js.map +1 -0
- package/components/number-input.d.ts +16 -0
- package/components/number-input.js +25 -0
- package/components/number-input.js.map +1 -0
- package/components/page.d.ts +14 -0
- package/components/page.js +23 -0
- package/components/page.js.map +1 -0
- package/components/pagination.d.ts +15 -0
- package/components/pagination.js +63 -0
- package/components/pagination.js.map +1 -0
- package/components/ping.d.ts +38 -0
- package/components/ping.js +50 -0
- package/components/ping.js.map +1 -0
- package/components/popover.d.ts +5 -0
- package/components/popover.js +25 -0
- package/components/popover.js.map +1 -0
- package/components/radio-group.d.ts +35 -0
- package/components/radio-group.js +81 -0
- package/components/radio-group.js.map +1 -0
- package/components/relative-time.d.ts +25 -0
- package/components/relative-time.js +51 -0
- package/components/relative-time.js.map +1 -0
- package/components/saved-mark.d.ts +15 -0
- package/components/saved-mark.js +45 -0
- package/components/saved-mark.js.map +1 -0
- package/components/search-input.d.ts +13 -0
- package/components/search-input.js +44 -0
- package/components/search-input.js.map +1 -0
- package/components/section-header.d.ts +83 -0
- package/components/section-header.js +170 -0
- package/components/section-header.js.map +1 -0
- package/components/segmented-control.d.ts +24 -0
- package/components/segmented-control.js +70 -0
- package/components/segmented-control.js.map +1 -0
- package/components/select.d.ts +28 -0
- package/components/select.js +129 -0
- package/components/select.js.map +1 -0
- package/components/shortcut-keys.d.ts +14 -0
- package/components/shortcut-keys.js +32 -0
- package/components/shortcut-keys.js.map +1 -0
- package/components/shortcuts-dialog.d.ts +10 -0
- package/components/shortcuts-dialog.js +92 -0
- package/components/shortcuts-dialog.js.map +1 -0
- package/components/skeleton.d.ts +8 -0
- package/components/skeleton.js +23 -0
- package/components/skeleton.js.map +1 -0
- package/components/sparkline.d.ts +25 -0
- package/components/sparkline.js +70 -0
- package/components/sparkline.js.map +1 -0
- package/components/stack.d.ts +21 -0
- package/components/stack.js +45 -0
- package/components/stack.js.map +1 -0
- package/components/stat-strip.d.ts +43 -0
- package/components/stat-strip.js +151 -0
- package/components/stat-strip.js.map +1 -0
- package/components/steps.d.ts +19 -0
- package/components/steps.js +25 -0
- package/components/steps.js.map +1 -0
- package/components/switch.d.ts +16 -0
- package/components/switch.js +29 -0
- package/components/switch.js.map +1 -0
- package/components/tabs.d.ts +18 -0
- package/components/tabs.js +65 -0
- package/components/tabs.js.map +1 -0
- package/components/text-link.d.ts +16 -0
- package/components/text-link.js +32 -0
- package/components/text-link.js.map +1 -0
- package/components/textarea.d.ts +10 -0
- package/components/textarea.js +23 -0
- package/components/textarea.js.map +1 -0
- package/components/theme.d.ts +28 -0
- package/components/theme.js +158 -0
- package/components/theme.js.map +1 -0
- package/components/time-series-chart.d.ts +122 -0
- package/components/time-series-chart.js +722 -0
- package/components/time-series-chart.js.map +1 -0
- package/components/toaster.d.ts +3 -0
- package/components/toaster.js +44 -0
- package/components/toaster.js.map +1 -0
- package/components/tooltip.d.ts +64 -0
- package/components/tooltip.js +126 -0
- package/components/tooltip.js.map +1 -0
- package/components/view-picker.d.ts +20 -0
- package/components/view-picker.js +24 -0
- package/components/view-picker.js.map +1 -0
- package/fonts/inter-OFL.txt +93 -0
- package/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/fonts/inter-cyrillic.woff2 +0 -0
- package/fonts/inter-greek-ext.woff2 +0 -0
- package/fonts/inter-greek.woff2 +0 -0
- package/fonts/inter-latin-ext.woff2 +0 -0
- package/fonts/inter-latin.woff2 +0 -0
- package/fonts/inter-vietnamese.woff2 +0 -0
- package/fonts.css +83 -0
- package/lib/animation.d.ts +14 -0
- package/lib/animation.js +20 -0
- package/lib/animation.js.map +1 -0
- package/lib/aria.d.ts +5 -0
- package/lib/aria.js +12 -0
- package/lib/aria.js.map +1 -0
- package/lib/chart-curve.d.ts +13 -0
- package/lib/chart-curve.js +79 -0
- package/lib/chart-curve.js.map +1 -0
- package/lib/classes.d.ts +134 -0
- package/lib/classes.js +152 -0
- package/lib/classes.js.map +1 -0
- package/lib/color.d.ts +25 -0
- package/lib/color.js +149 -0
- package/lib/color.js.map +1 -0
- package/lib/day.d.ts +9 -0
- package/lib/day.js +20 -0
- package/lib/day.js.map +1 -0
- package/lib/design-tokens.d.ts +56 -0
- package/lib/design-tokens.js +196 -0
- package/lib/design-tokens.js.map +1 -0
- package/lib/icon.d.ts +17 -0
- package/lib/icon.js +34 -0
- package/lib/icon.js.map +1 -0
- package/lib/icons.d.ts +23 -0
- package/lib/icons.js +28 -0
- package/lib/icons.js.map +1 -0
- package/lib/interactive.d.ts +21 -0
- package/lib/interactive.js +31 -0
- package/lib/interactive.js.map +1 -0
- package/lib/media.d.ts +58 -0
- package/lib/media.js +116 -0
- package/lib/media.js.map +1 -0
- package/lib/segmented.d.ts +57 -0
- package/lib/segmented.js +83 -0
- package/lib/segmented.js.map +1 -0
- package/lib/shortcuts.d.ts +94 -0
- package/lib/shortcuts.js +271 -0
- package/lib/shortcuts.js.map +1 -0
- package/lib/slot.d.ts +9 -0
- package/lib/slot.js +18 -0
- package/lib/slot.js.map +1 -0
- package/lib/time-series.d.ts +100 -0
- package/lib/time-series.js +144 -0
- package/lib/time-series.js.map +1 -0
- package/lib/tone.d.ts +6 -0
- package/lib/tone.js +0 -0
- package/lib/variants.d.ts +12 -0
- package/lib/variants.js +14 -0
- package/lib/variants.js.map +1 -0
- package/package.json +116 -4
- package/styles.css +619 -0
- package/tokens.d.ts +104 -0
- package/tokens.js +108 -0
- package/tokens.js.map +1 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dateToDay, dayToDate } from "../lib/day.js";
|
|
3
|
+
import { Button } from "./button.js";
|
|
4
|
+
import { Calendar, useCalendarFocus } from "./calendar.js";
|
|
5
|
+
import { DatePickerTrigger } from "./date-picker-trigger.js";
|
|
6
|
+
import { DisabledReason } from "./disabled-reason.js";
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
// src/components/date-picker.tsx
|
|
11
|
+
/**
|
|
12
|
+
* A single date, picked from a calendar in a popover. Replaces `<input type="date">`, whose
|
|
13
|
+
* widget every browser draws its own way and none of them on brand.
|
|
14
|
+
*/
|
|
15
|
+
function DatePicker({ value, onChange, min, max, placeholder, formatDay, clearable = false, id, disabled, disabledReason, className, ...props }) {
|
|
16
|
+
const [open, setOpen] = useState(false);
|
|
17
|
+
const { ref: calendarRef, initialFocus } = useCalendarFocus();
|
|
18
|
+
const selected = dayToDate(value);
|
|
19
|
+
const before = dayToDate(min);
|
|
20
|
+
const after = dayToDate(max);
|
|
21
|
+
function pick(date) {
|
|
22
|
+
onChange(date ? dateToDay(date) : "");
|
|
23
|
+
setOpen(false);
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
26
|
+
open,
|
|
27
|
+
onOpenChange: (next) => setOpen(next && !disabledReason),
|
|
28
|
+
children: [/* @__PURE__ */ jsx(DisabledReason, {
|
|
29
|
+
reason: disabledReason,
|
|
30
|
+
children: /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
31
|
+
id,
|
|
32
|
+
...props,
|
|
33
|
+
render: /* @__PURE__ */ jsx(DatePickerTrigger, {
|
|
34
|
+
value,
|
|
35
|
+
placeholder,
|
|
36
|
+
formatDay,
|
|
37
|
+
disabled,
|
|
38
|
+
className
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
}), /* @__PURE__ */ jsxs(PopoverContent, {
|
|
42
|
+
ref: calendarRef,
|
|
43
|
+
align: "start",
|
|
44
|
+
initialFocus,
|
|
45
|
+
className: "w-auto min-w-0 p-4",
|
|
46
|
+
children: [/* @__PURE__ */ jsx(Calendar, {
|
|
47
|
+
mode: "single",
|
|
48
|
+
required: !clearable,
|
|
49
|
+
autoFocus: true,
|
|
50
|
+
defaultMonth: selected,
|
|
51
|
+
selected,
|
|
52
|
+
startMonth: before,
|
|
53
|
+
endMonth: after,
|
|
54
|
+
disabled: [...before ? [{ before }] : [], ...after ? [{ after }] : []],
|
|
55
|
+
onSelect: pick
|
|
56
|
+
}), clearable && selected && /* @__PURE__ */ jsx("div", {
|
|
57
|
+
className: "mt-3 flex justify-end",
|
|
58
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
59
|
+
variant: "ghost",
|
|
60
|
+
size: "sm",
|
|
61
|
+
onClick: () => pick(void 0),
|
|
62
|
+
children: "Clear"
|
|
63
|
+
})
|
|
64
|
+
})]
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export { DatePicker };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=date-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker.js","names":[],"sources":["../../src/components/date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport { useState } from \"react\"\nimport { dateToDay, dayToDate } from \"../lib/day\"\nimport { Button } from \"./button\"\nimport { Calendar, useCalendarFocus } from \"./calendar\"\nimport { DatePickerTrigger } from \"./date-picker-trigger\"\nimport { DisabledReason } from \"./disabled-reason\"\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\"\n\nexport interface DatePickerProps {\n /** The selected day as \"YYYY-MM-DD\", or empty for none. */\n value?: string\n\n onChange: (value: string) => void\n\n /** Earliest and latest selectable day, both \"YYYY-MM-DD\" and both inclusive. */\n min?: string\n max?: string\n\n /** Shown on the trigger while nothing is selected. */\n placeholder?: string\n\n /**\n * Names the selected \"YYYY-MM-DD\" day on the trigger. The app supplies it, so the day reads\n * in the app's own locale and time zone like every other date beside it.\n */\n formatDay: (day: string) => string\n\n /**\n * Lets the reader remove the date: a second click on the selected day, or the Clear button\n * under the calendar. Set it on an optional date; a required one only ever changes.\n */\n clearable?: boolean\n\n id?: string\n disabled?: boolean\n /** Why the date cannot be changed: the trigger stays focusable, reads it, and never opens. */\n disabledReason?: string\n className?: string\n\n /** Labels the trigger for screen readers, for a field with no visible `<label>`. */\n \"aria-label\"?: string\n \"aria-describedby\"?: string\n \"aria-invalid\"?: boolean\n \"aria-required\"?: boolean\n onBlur?: () => void\n}\n\n/**\n * A single date, picked from a calendar in a popover. Replaces `<input type=\"date\">`, whose\n * widget every browser draws its own way and none of them on brand.\n */\nexport function DatePicker({\n value,\n onChange,\n min,\n max,\n placeholder,\n formatDay,\n clearable = false,\n id,\n disabled,\n disabledReason,\n className,\n ...props\n}: DatePickerProps) {\n const [open, setOpen] = useState(false)\n const { ref: calendarRef, initialFocus } = useCalendarFocus()\n const selected = dayToDate(value)\n const before = dayToDate(min)\n const after = dayToDate(max)\n\n function pick(date: Date | undefined) {\n onChange(date ? dateToDay(date) : \"\")\n setOpen(false)\n }\n\n return (\n // A trigger under a reason takes the pointer, so a request to open is dropped here too.\n <Popover open={open} onOpenChange={next => setOpen(next && !disabledReason)}>\n <DisabledReason reason={disabledReason}>\n <PopoverTrigger\n id={id}\n {...props}\n render={\n <DatePickerTrigger\n value={value}\n placeholder={placeholder}\n formatDay={formatDay}\n disabled={disabled}\n className={className}\n />\n }\n />\n </DisabledReason>\n\n <PopoverContent\n ref={calendarRef}\n align=\"start\"\n initialFocus={initialFocus}\n className=\"w-auto min-w-0 p-4\"\n >\n <Calendar\n mode=\"single\"\n required={!clearable}\n // Not the DOM attribute: it seeds react-day-picker's own focused day, which its arrow\n // keys move from. `initialFocus` on the popup puts the browser's focus on that same\n // day; Base UI would otherwise take it to the back arrow and the two would disagree.\n // oxlint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n // react-day-picker opens on today unless told otherwise; it does not read `selected`.\n defaultMonth={selected}\n selected={selected}\n startMonth={before}\n endMonth={after}\n disabled={[...(before ? [{ before }] : []), ...(after ? [{ after }] : [])]}\n onSelect={pick}\n />\n\n {clearable && selected && (\n <div className=\"mt-3 flex justify-end\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => pick(undefined)}>\n Clear\n </Button>\n </div>\n )}\n </PopoverContent>\n </Popover>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAqDA,SAAgB,WAAW,EACzB,OACA,UACA,KACA,KACA,aACA,WACA,YAAY,OACZ,IACA,UACA,gBACA,WACA,GAAG,SACe;CAClB,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,EAAE,KAAK,aAAa,iBAAiB,iBAAiB;CAC5D,MAAM,WAAW,UAAU,KAAK;CAChC,MAAM,SAAS,UAAU,GAAG;CAC5B,MAAM,QAAQ,UAAU,GAAG;CAE3B,SAAS,KAAK,MAAwB;EACpC,SAAS,OAAO,UAAU,IAAI,IAAI,EAAE;EACpC,QAAQ,KAAK;CACf;CAEA,OAEE,qBAAC,SAAD;EAAe;EAAM,eAAc,SAAQ,QAAQ,QAAQ,CAAC,cAAc;EAA1E,UAAA,CACE,oBAAC,gBAAD;GAAgB,QAAQ;GACtB,UAAA,oBAAC,gBAAD;IACM;IACJ,GAAI;IACJ,QACE,oBAAC,mBAAD;KACS;KACM;KACF;KACD;KACC;IACZ,CAAA;GAEJ,CAAA;EACa,CAAA,GAEhB,qBAAC,gBAAD;GACE,KAAK;GACL,OAAM;GACQ;GACd,WAAU;GAJZ,UAAA,CAME,oBAAC,UAAD;IACE,MAAK;IACL,UAAU,CAAC;IAKX,WAAA;IAEA,cAAc;IACJ;IACV,YAAY;IACZ,UAAU;IACV,UAAU,CAAC,GAAI,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAI,GAAI,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAE;IACzE,UAAU;GACX,CAAA,GAEA,aAAa,YACZ,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,QAAD;KAAQ,SAAQ;KAAQ,MAAK;KAAK,eAAe,KAAK,KAAA,CAAS;KAAG,UAAA;IAE1D,CAAA;GACL,CAAA,CAEO;EACT,CAAA,CAAA;;AAEb"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/variants.js";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
declare const detailRowVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
density: {
|
|
6
|
+
form: {
|
|
7
|
+
root: string;
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
below: string;
|
|
11
|
+
};
|
|
12
|
+
comfortable: {
|
|
13
|
+
root: string;
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
};
|
|
17
|
+
compact: {
|
|
18
|
+
root: string;
|
|
19
|
+
label: string;
|
|
20
|
+
value: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
root: string;
|
|
25
|
+
label: string;
|
|
26
|
+
value: string;
|
|
27
|
+
below: string;
|
|
28
|
+
}, undefined, undefined, undefined, undefined>;
|
|
29
|
+
type DetailRowProps = useRender.ComponentProps<"div"> & VariantProps<typeof detailRowVariants> & {
|
|
30
|
+
/**
|
|
31
|
+
* Row label. Pass a `Label` when the row wraps a form field so the label
|
|
32
|
+
* keeps its `htmlFor` wiring.
|
|
33
|
+
*/
|
|
34
|
+
label: ReactNode;
|
|
35
|
+
description?: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Extra classes for the value column, e.g. `sm:items-end` to keep a button
|
|
38
|
+
* at its intrinsic width instead of stretching.
|
|
39
|
+
*/
|
|
40
|
+
valueClassName?: string;
|
|
41
|
+
/** Full-width content under the label and the control, such as chips. `form` only. */
|
|
42
|
+
below?: ReactNode;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* One "label plus value" line, in the three densities the app uses: `form` for an editable
|
|
46
|
+
* settings row (label and description left, control right), `comfortable` for a detail card's
|
|
47
|
+
* `<dl>`, `compact` for a sidebar timeline. Rows sit in a `divide-y` parent, which draws the
|
|
48
|
+
* hairlines between them.
|
|
49
|
+
*/
|
|
50
|
+
export declare function DetailRow({ density, label, description, valueClassName, below, className, children, render, ...props }: DetailRowProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import "../lib/classes.js";
|
|
2
|
+
import { slot } from "../lib/slot.js";
|
|
3
|
+
import { variants } from "../lib/variants.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import { isValidElement } from "react";
|
|
7
|
+
// src/components/detail-row.tsx
|
|
8
|
+
const detailRowVariants = variants({
|
|
9
|
+
slots: {
|
|
10
|
+
root: "",
|
|
11
|
+
label: "",
|
|
12
|
+
value: "",
|
|
13
|
+
below: ""
|
|
14
|
+
},
|
|
15
|
+
variants: { density: {
|
|
16
|
+
form: {
|
|
17
|
+
root: "grid items-start gap-x-8 gap-y-3 py-5 has-disabled:[&_label]:cursor-default @xl:grid-cols-[minmax(0,1fr)_minmax(0,20rem)]",
|
|
18
|
+
label: "flex min-w-0 flex-col gap-1",
|
|
19
|
+
value: "flex w-full min-w-0 flex-col gap-2 @xl:justify-self-end",
|
|
20
|
+
below: "col-span-full flex min-w-0 flex-col gap-3"
|
|
21
|
+
},
|
|
22
|
+
comfortable: {
|
|
23
|
+
root: "grid items-start gap-x-8 gap-y-1 py-3 sm:grid-cols-[minmax(0,12rem)_minmax(0,1fr)]",
|
|
24
|
+
label: "text-ink-muted text-sm",
|
|
25
|
+
value: "min-w-0 text-sm"
|
|
26
|
+
},
|
|
27
|
+
compact: {
|
|
28
|
+
root: "flex items-baseline justify-between gap-4 py-2 first:pt-0 last:pb-0",
|
|
29
|
+
label: "text-ink-muted",
|
|
30
|
+
value: "tabular-nums"
|
|
31
|
+
}
|
|
32
|
+
} },
|
|
33
|
+
defaultVariants: { density: "comfortable" }
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* One "label plus value" line, in the three densities the app uses: `form` for an editable
|
|
37
|
+
* settings row (label and description left, control right), `comfortable` for a detail card's
|
|
38
|
+
* `<dl>`, `compact` for a sidebar timeline. Rows sit in a `divide-y` parent, which draws the
|
|
39
|
+
* hairlines between them.
|
|
40
|
+
*/
|
|
41
|
+
function DetailRow({ density = "comfortable", label, description, valueClassName, below, className, children, render, ...props }) {
|
|
42
|
+
const styles = detailRowVariants({ density });
|
|
43
|
+
const isForm = density === "form";
|
|
44
|
+
const LabelTag = isForm ? "div" : "dt";
|
|
45
|
+
const ValueTag = isForm ? "div" : "dd";
|
|
46
|
+
return useRender({
|
|
47
|
+
render,
|
|
48
|
+
defaultTagName: "div",
|
|
49
|
+
props: {
|
|
50
|
+
className: styles.root({ className }),
|
|
51
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52
|
+
/* @__PURE__ */ jsxs(LabelTag, {
|
|
53
|
+
className: styles.label(),
|
|
54
|
+
children: [isForm ? /* @__PURE__ */ jsx("div", {
|
|
55
|
+
className: "font-medium text-sm",
|
|
56
|
+
children: label
|
|
57
|
+
}) : label, description && (isValidElement(description) ? slot(description, { className: "max-w-prose text-copy text-ink-muted" }) : /* @__PURE__ */ jsx("p", {
|
|
58
|
+
className: "max-w-prose text-copy text-ink-muted",
|
|
59
|
+
children: description
|
|
60
|
+
}))]
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ jsx(ValueTag, {
|
|
63
|
+
className: styles.value({ className: valueClassName }),
|
|
64
|
+
children
|
|
65
|
+
}),
|
|
66
|
+
isForm && below && /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: styles.below(),
|
|
68
|
+
children: below
|
|
69
|
+
})
|
|
70
|
+
] }),
|
|
71
|
+
...props
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export { DetailRow };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=detail-row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detail-row.js","names":[],"sources":["../../src/components/detail-row.tsx"],"sourcesContent":["import { useRender } from \"@base-ui/react/use-render\"\nimport { isValidElement, type ReactNode } from \"react\"\nimport { descriptionClasses } from \"../lib/classes\"\nimport { slot } from \"../lib/slot\"\nimport { variants, type VariantProps } from \"../lib/variants\"\n\nconst detailRowVariants = variants({\n slots: {\n root: \"\",\n label: \"\",\n value: \"\",\n below: \"\",\n },\n\n variants: {\n density: {\n form: {\n // Two columns once the row's own container is wide enough for both, not once the\n // viewport is: the same row sits in a settings panel and in a dialog, and a viewport\n // breakpoint would split a 400px dialog into a 20rem control beside a word-per-line\n // label. A row with no `@container` ancestor stays stacked, which is the safe read.\n // A label's click does nothing while its control is disabled, so it drops the pointer.\n root: \"grid items-start gap-x-8 gap-y-3 py-5 has-disabled:[&_label]:cursor-default @xl:grid-cols-[minmax(0,1fr)_minmax(0,20rem)]\",\n label: \"flex min-w-0 flex-col gap-1\",\n value: \"flex w-full min-w-0 flex-col gap-2 @xl:justify-self-end\",\n below: \"col-span-full flex min-w-0 flex-col gap-3\",\n },\n comfortable: {\n root: \"grid items-start gap-x-8 gap-y-1 py-3 sm:grid-cols-[minmax(0,12rem)_minmax(0,1fr)]\",\n label: \"text-ink-muted text-sm\",\n value: \"min-w-0 text-sm\",\n },\n compact: {\n root: \"flex items-baseline justify-between gap-4 py-2 first:pt-0 last:pb-0\",\n label: \"text-ink-muted\",\n value: \"tabular-nums\",\n },\n },\n },\n\n defaultVariants: {\n density: \"comfortable\",\n },\n})\n\ntype DetailRowProps = useRender.ComponentProps<\"div\"> &\n VariantProps<typeof detailRowVariants> & {\n /**\n * Row label. Pass a `Label` when the row wraps a form field so the label\n * keeps its `htmlFor` wiring.\n */\n label: ReactNode\n description?: ReactNode\n /**\n * Extra classes for the value column, e.g. `sm:items-end` to keep a button\n * at its intrinsic width instead of stretching.\n */\n valueClassName?: string\n /** Full-width content under the label and the control, such as chips. `form` only. */\n below?: ReactNode\n }\n\n/**\n * One \"label plus value\" line, in the three densities the app uses: `form` for an editable\n * settings row (label and description left, control right), `comfortable` for a detail card's\n * `<dl>`, `compact` for a sidebar timeline. Rows sit in a `divide-y` parent, which draws the\n * hairlines between them.\n */\nexport function DetailRow({\n density = \"comfortable\",\n label,\n description,\n valueClassName,\n below,\n className,\n children,\n render,\n ...props\n}: DetailRowProps) {\n const styles = detailRowVariants({ density })\n const isForm = density === \"form\"\n const LabelTag = isForm ? \"div\" : \"dt\"\n const ValueTag = isForm ? \"div\" : \"dd\"\n\n return useRender({\n render,\n defaultTagName: \"div\",\n props: {\n className: styles.root({ className }),\n children: (\n <>\n <LabelTag className={styles.label()}>\n {isForm ? <div className=\"font-medium text-sm\">{label}</div> : label}\n\n {description &&\n (isValidElement(description) ? (\n slot(description, { className: descriptionClasses })\n ) : (\n <p className={descriptionClasses}>{description}</p>\n ))}\n </LabelTag>\n\n <ValueTag className={styles.value({ className: valueClassName })}>{children}</ValueTag>\n\n {isForm && below && <div className={styles.below()}>{below}</div>}\n </>\n ),\n ...props,\n },\n })\n}\n"],"mappings":";;;;;;;AAMA,MAAM,oBAAoB,SAAS;CACjC,OAAO;EACL,MAAM;EACN,OAAO;EACP,OAAO;EACP,OAAO;CACT;CAEA,UAAU,EACR,SAAS;EACP,MAAM;GAMJ,MAAM;GACN,OAAO;GACP,OAAO;GACP,OAAO;EACT;EACA,aAAa;GACX,MAAM;GACN,OAAO;GACP,OAAO;EACT;EACA,SAAS;GACP,MAAM;GACN,OAAO;GACP,OAAO;EACT;CACF,EACF;CAEA,iBAAiB,EACf,SAAS,cACX;AACF,CAAC;;;;;;;AAyBD,SAAgB,UAAU,EACxB,UAAU,eACV,OACA,aACA,gBACA,OACA,WACA,UACA,QACA,GAAG,SACc;CACjB,MAAM,SAAS,kBAAkB,EAAE,QAAQ,CAAC;CAC5C,MAAM,SAAS,YAAY;CAC3B,MAAM,WAAW,SAAS,QAAQ;CAClC,MAAM,WAAW,SAAS,QAAQ;CAElC,OAAO,UAAU;EACf;EACA,gBAAgB;EAChB,OAAO;GACL,WAAW,OAAO,KAAK,EAAE,UAAU,CAAC;GACpC,UACE,qBAAA,UAAA,EAAA,UAAA;IACE,qBAAC,UAAD;KAAU,WAAW,OAAO,MAAM;KAAlC,UAAA,CACG,SAAS,oBAAC,OAAD;MAAK,WAAU;MAAuB,UAAA;KAAW,CAAA,IAAI,OAE9D,gBACE,eAAe,WAAW,IACzB,KAAK,aAAa,EAAE,WAAA,uCAA8B,CAAC,IAEnD,oBAAC,KAAD;MAAG,WAAA;MAAgC,UAAA;KAAe,CAAA,EAE9C;;IAEV,oBAAC,UAAD;KAAU,WAAW,OAAO,MAAM,EAAE,WAAW,eAAe,CAAC;KAAI;IAAmB,CAAA;IAErF,UAAU,SAAS,oBAAC,OAAD;KAAK,WAAW,OAAO,MAAM;KAAI,UAAA;IAAW,CAAA;GAChE,EAAA,CAAA;GAEJ,GAAG;EACL;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { VariantProps } from "../lib/variants.js";
|
|
2
|
+
import { Button } from "./button.js";
|
|
3
|
+
import { SectionHeader } from "./section-header.js";
|
|
4
|
+
import { CSSProperties, ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
+
import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
|
|
6
|
+
import { Drawer } from "@base-ui/react/drawer";
|
|
7
|
+
/**
|
|
8
|
+
* Whether the dialog this sits in is open as the phone bottom sheet, for content that differs
|
|
9
|
+
* between the two shapes. It follows the dialog, not the viewport, so it holds while open.
|
|
10
|
+
*/
|
|
11
|
+
declare function useDialogSheet(): boolean;
|
|
12
|
+
/** The drawer root's props less the swipe and snap ones, which only the sheet could use. */
|
|
13
|
+
type DialogProps = Omit<Drawer.Root.Props, "swipeDirection" | "snapPoints" | "snapPoint" | "defaultSnapPoint" | "onSnapPointChange" | "snapToSequentialPoints">;
|
|
14
|
+
/**
|
|
15
|
+
* The root is a Base UI Drawer at every width. A drawer is a dialog with swipe parts added, so
|
|
16
|
+
* its root drives the dialog's own popup as well as the sheet. With one root type for both
|
|
17
|
+
* shapes, nothing above the popup changes when the viewport crosses `sm`.
|
|
18
|
+
*/
|
|
19
|
+
declare function Dialog(props: DialogProps): import("react").JSX.Element;
|
|
20
|
+
declare function DialogTrigger(props: Dialog$1.Trigger.Props): import("react").JSX.Element;
|
|
21
|
+
declare function DialogTitle(props: Dialog$1.Title.Props): import("react").JSX.Element;
|
|
22
|
+
declare function DialogDescription(props: Dialog$1.Description.Props): import("react").JSX.Element;
|
|
23
|
+
declare const dialogContentVariants: import("tailwind-variants").TVReturnType<{
|
|
24
|
+
size: {
|
|
25
|
+
xs: string;
|
|
26
|
+
sm: string;
|
|
27
|
+
md: string;
|
|
28
|
+
lg: string;
|
|
29
|
+
xl: string;
|
|
30
|
+
"2xl": string;
|
|
31
|
+
"3xl": string;
|
|
32
|
+
"4xl": string;
|
|
33
|
+
"5xl": string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Pin the dialog near the top of the viewport instead of centering it, so its height can
|
|
37
|
+
* change without the whole thing jumping. A dialog opened from inside another one carries
|
|
38
|
+
* Base UI's `data-nested` and sits a little lower, so the stack is visible as a stack. Each
|
|
39
|
+
* portal is its own subtree, so no sibling selector can see the one underneath.
|
|
40
|
+
*/
|
|
41
|
+
fixed: {
|
|
42
|
+
true: string;
|
|
43
|
+
false: string;
|
|
44
|
+
};
|
|
45
|
+
}, undefined, string[], undefined, undefined, undefined>;
|
|
46
|
+
interface DialogContentProps extends Omit<Dialog$1.Popup.Props, "className" | "render" | "style">, VariantProps<typeof dialogContentVariants> {
|
|
47
|
+
className?: string;
|
|
48
|
+
style?: CSSProperties;
|
|
49
|
+
/** The element the popup renders as, such as a form, in either shape. */
|
|
50
|
+
render?: ReactElement;
|
|
51
|
+
/**
|
|
52
|
+
* Hide the close button in the top right corner, for a dialog that must be dismissed
|
|
53
|
+
* through one of its own actions.
|
|
54
|
+
*/
|
|
55
|
+
hideClose?: boolean;
|
|
56
|
+
/** Open and close at once, for a dialog a shortcut summons. A sheet still slides. */
|
|
57
|
+
instant?: boolean;
|
|
58
|
+
}
|
|
59
|
+
declare function DialogContent(props: DialogContentProps): import("react").JSX.Element;
|
|
60
|
+
/**
|
|
61
|
+
* What a dialog is showing, kept alive through its close animation. A dialog driven by
|
|
62
|
+
* `open={!!row}` loses `row` the instant it closes, so its body unmounts and the popup fades
|
|
63
|
+
* out as an empty box with a stray footer. Render what this returns instead of the state
|
|
64
|
+
* itself, and the last row stays on screen until the animation ends.
|
|
65
|
+
*/
|
|
66
|
+
export declare function useDialogValue<T>(value: T | null | undefined): T | null;
|
|
67
|
+
/**
|
|
68
|
+
* The padded block a dialog's content sits in, holding its own header when that header has no
|
|
69
|
+
* hairline of its own. A dialog whose body scrolls or splits into panes lays out those regions
|
|
70
|
+
* itself instead, so the column names and the panes reach the popup's edges.
|
|
71
|
+
*/
|
|
72
|
+
declare function DialogBody({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
73
|
+
declare const dialogHeaderVariants: import("tailwind-variants").TVReturnType<{
|
|
74
|
+
/**
|
|
75
|
+
* Give the header its own band: a hairline and the padding to sit on. It belongs to a
|
|
76
|
+
* dialog that owns its body as a region: one that scrolls under the header, or splits
|
|
77
|
+
* into panes. A dialog whose body is a single `DialogBody` block holds its header inside
|
|
78
|
+
* that block instead, with nothing drawn under it.
|
|
79
|
+
*/
|
|
80
|
+
bordered: {
|
|
81
|
+
true: string;
|
|
82
|
+
};
|
|
83
|
+
}, undefined, "relative", undefined, undefined, undefined>;
|
|
84
|
+
type DialogHeaderProps = Omit<ComponentProps<typeof SectionHeader>, "title" | "description"> & VariantProps<typeof dialogHeaderVariants> & {
|
|
85
|
+
title: ReactNode;
|
|
86
|
+
description?: ReactNode;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The standard dialog heading: a card-scale `SectionHeader` whose title and description are wired to
|
|
90
|
+
* Base UI's `DialogTitle` / `DialogDescription` for accessibility. Extra children render after
|
|
91
|
+
* them, and the dialog's X sits at the end of the row, centred on the title line.
|
|
92
|
+
*/
|
|
93
|
+
declare function DialogHeader({ title, description, bordered, className, children, ...props }: DialogHeaderProps): import("react").JSX.Element;
|
|
94
|
+
/**
|
|
95
|
+
* The band a dialog's actions sit in: a hairline, the canvas fill that sets it apart from the
|
|
96
|
+
* white body above, and room past the home indicator on a bottom sheet. Every dialog with
|
|
97
|
+
* actions wears it, whether or not its header has a hairline of its own.
|
|
98
|
+
*/
|
|
99
|
+
declare function DialogFooter({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
100
|
+
declare function DialogClose(props: ComponentProps<typeof Button>): import("react").JSX.Element;
|
|
101
|
+
type SideDrawerProps = Omit<Drawer.Root.Props, "children"> & {
|
|
102
|
+
/**
|
|
103
|
+
* The element that opens the panel, and closes it while it is open. It stays outside the
|
|
104
|
+
* panel, so a shell whose bar owns the toggle keeps one button for both states.
|
|
105
|
+
*/
|
|
106
|
+
trigger: ReactElement;
|
|
107
|
+
/**
|
|
108
|
+
* Where the panel and its scrim start, measured from the top of the viewport: a CSS length
|
|
109
|
+
* for a shell with a sticky bar that stays above them. They span the full height by default.
|
|
110
|
+
*/
|
|
111
|
+
offset?: string;
|
|
112
|
+
/** Classes for the panel itself. */
|
|
113
|
+
className?: string;
|
|
114
|
+
children: ReactNode;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* A panel sliding in from the left edge over a scrim: the phone's navigation drawer. Escape,
|
|
118
|
+
* a tap on the scrim, a swipe to the left and a press on the trigger all close it.
|
|
119
|
+
*/
|
|
120
|
+
declare function SideDrawer({ trigger, offset, className, children, ...props }: SideDrawerProps): import("react").JSX.Element;
|
|
121
|
+
export { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, SideDrawer, useDialogSheet };
|