@bettercms-ai/kit 3.0.1 → 3.0.2
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/dist/brand/logo.js +67 -18
- package/dist/brand/logo.js.map +1 -1
- package/dist/context.js +8 -3
- package/dist/context.js.map +1 -1
- package/dist/controls/button.js +451 -134
- package/dist/controls/button.js.map +1 -1
- package/dist/controls/choice.js +336 -95
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/code.js +245 -72
- package/dist/controls/code.js.map +1 -1
- package/dist/controls/color.js +108 -31
- package/dist/controls/color.js.map +1 -1
- package/dist/controls/date.js +268 -83
- package/dist/controls/date.js.map +1 -1
- package/dist/controls/form-picker.js +26 -9
- package/dist/controls/form-picker.js.map +1 -1
- package/dist/controls/icon.js +341 -100
- package/dist/controls/icon.js.map +1 -1
- package/dist/controls/json.js +20 -7
- package/dist/controls/json.js.map +1 -1
- package/dist/controls/link.js +561 -156
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/location.js +124 -35
- package/dist/controls/location.js.map +1 -1
- package/dist/controls/media.js +928 -267
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/number.js +80 -23
- package/dist/controls/number.js.map +1 -1
- package/dist/controls/reference.js +516 -155
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/article-shell.js +327 -86
- package/dist/controls/rich-text/article-shell.js.map +1 -1
- package/dist/controls/rich-text/author.js +78 -21
- package/dist/controls/rich-text/author.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +1084 -315
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/button.js +30 -9
- package/dist/controls/rich-text/button.js.map +1 -1
- package/dist/controls/rich-text/catalog.js +168 -51
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/columns.js +104 -31
- package/dist/controls/rich-text/columns.js.map +1 -1
- package/dist/controls/rich-text/component-card.js +790 -209
- package/dist/controls/rich-text/component-card.js.map +1 -1
- package/dist/controls/rich-text/component-panel.js +102 -40
- package/dist/controls/rich-text/component-panel.js.map +1 -1
- package/dist/controls/rich-text/control.js +101 -32
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/editor.js +423 -121
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/embed.js +184 -51
- package/dist/controls/rich-text/embed.js.map +1 -1
- package/dist/controls/rich-text/floating.js +171 -42
- package/dist/controls/rich-text/floating.js.map +1 -1
- package/dist/controls/rich-text/footnote.js +89 -28
- package/dist/controls/rich-text/footnote.js.map +1 -1
- package/dist/controls/rich-text/gallery.js +88 -27
- package/dist/controls/rich-text/gallery.js.map +1 -1
- package/dist/controls/rich-text/link-form.js +111 -34
- package/dist/controls/rich-text/link-form.js.map +1 -1
- package/dist/controls/rich-text/plain.js +8 -3
- package/dist/controls/rich-text/plain.js.map +1 -1
- package/dist/controls/rich-text/related.js +86 -25
- package/dist/controls/rich-text/related.js.map +1 -1
- package/dist/controls/rich-text/toc.js +48 -15
- package/dist/controls/rich-text/toc.js.map +1 -1
- package/dist/controls/rich-text/toolbar.js +408 -107
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/scale.js +169 -52
- package/dist/controls/scale.js.map +1 -1
- package/dist/controls/slot.js +238 -73
- package/dist/controls/slot.js.map +1 -1
- package/dist/controls/table/table-editor.js +1766 -500
- package/dist/controls/table/table-editor.js.map +1 -1
- package/dist/controls/table/table-link.js +119 -38
- package/dist/controls/table/table-link.js.map +1 -1
- package/dist/controls/table/table.js +26 -9
- package/dist/controls/table/table.js.map +1 -1
- package/dist/controls/text.js +221 -68
- package/dist/controls/text.js.map +1 -1
- package/dist/controls/unknown-value.js +79 -22
- package/dist/controls/unknown-value.js.map +1 -1
- package/dist/engine/array.js +821 -228
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/bits.js +38 -13
- package/dist/engine/bits.js.map +1 -1
- package/dist/engine/breadcrumb.js +25 -8
- package/dist/engine/breadcrumb.js.map +1 -1
- package/dist/engine/expand.js +38 -13
- package/dist/engine/expand.js.map +1 -1
- package/dist/engine/field-list.js +14 -5
- package/dist/engine/field-list.js.map +1 -1
- package/dist/engine/field-shell.js +849 -244
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +275 -78
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.js +630 -193
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/item-list.js +187 -50
- package/dist/engine/item-list.js.map +1 -1
- package/dist/engine/kit-field.js +320 -95
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.js +101 -32
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/engine/slot.js +146 -45
- package/dist/engine/slot.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/icons.js +14 -5
- package/dist/lib/icons.js.map +1 -1
- package/dist/styles.css +5821 -1
- package/dist/table/table-view.js +49 -16
- package/dist/table/table-view.js.map +1 -1
- package/dist/testing/test-form.js +14 -5
- package/dist/testing/test-form.js.map +1 -1
- package/dist/theme.js +8 -3
- package/dist/theme.js.map +1 -1
- package/dist/ui/action-tray.js +97 -24
- package/dist/ui/action-tray.js.map +1 -1
- package/dist/ui/autocomplete.js +135 -38
- package/dist/ui/autocomplete.js.map +1 -1
- package/dist/ui/button.js +108 -31
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/choice-switch.js +14 -5
- package/dist/ui/choice-switch.js.map +1 -1
- package/dist/ui/controls.js +279 -86
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/display.js +401 -116
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/expanded-editor-modal.js +100 -27
- package/dist/ui/expanded-editor-modal.js.map +1 -1
- package/dist/ui/floating-panel.js +130 -37
- package/dist/ui/floating-panel.js.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/input.js +196 -59
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/mode-bar.js +32 -11
- package/dist/ui/mode-bar.js.map +1 -1
- package/dist/ui/overlay.js +616 -179
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/path-crumbs.js +374 -113
- package/dist/ui/path-crumbs.js.map +1 -1
- package/dist/ui/select.js +311 -78
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/shortcut-hint.d.ts +3 -0
- package/dist/ui/shortcut-hint.js +33 -7
- package/dist/ui/shortcut-hint.js.map +1 -1
- package/dist/ui/spinner.js +20 -7
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/split-button.js +35 -10
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/tab.js +50 -17
- package/dist/ui/tab.js.map +1 -1
- package/dist/ui/toast.js +107 -30
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/tooltip-root.js +24 -7
- package/dist/ui/tooltip-root.js.map +1 -1
- package/package.json +2 -2
package/dist/ui/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FieldDescribedByContext, FieldLabelledByContext, useFieldDescribedBy, useFieldId, useFieldLabelledBy } from "./field-context.js";
|
|
2
2
|
import { Spinner } from "./spinner.js";
|
|
3
3
|
import { Button, HintTooltip, IconButton, RevealLink, Sparkle, TooltipScope, buttonVariants, iconButtonVariants } from "./button.js";
|
|
4
|
-
import { ShortcutHint, ShortcutHintsProvider, shortcutHintsOn, useShortcutHints } from "./shortcut-hint.js";
|
|
4
|
+
import { ShortcutHint, ShortcutHintsProvider, platformKeys, shortcutHintsOn, useShortcutHints } from "./shortcut-hint.js";
|
|
5
5
|
import { Checkbox, ChoiceCard, ChoiceList, Progress, Radio, RadioGroup, Segmented, Slider, Switch, ToggleGroup, ToggleItem } from "./controls.js";
|
|
6
6
|
import { FLOATING_LAYER, FlowBody, FlowClose, FlowFooter, FlowHeader, FlowLabel, FlowModal, HeaderStatus, HoverCard, HoverCardContent, HoverCardTrigger, Menu, MenuCheckItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Modal, ModalBody, ModalClose, ModalContent, ModalFooter, ModalHeader, ModalTrigger, MoreOptions, OptionRow, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Sheet, SheetClose, SheetContent, SheetTrigger, Tooltip, TooltipProvider, useFocusReturn } from "./overlay.js";
|
|
7
7
|
import { Avatar, AvatarStack, Badge, Card, CardHeader, Dot, EmptyState, Kbd, PageHeader, Separator, SettingsSection, Skeleton, Stat, StatusMark, StatusPill, Table, Td, Th, Tr, avatarRingSpread, badgeVariants, colorFor, statusMap } from "./display.js";
|
|
@@ -15,4 +15,4 @@ import { ActionTray, TrayMeta, TrayMore, actionTrayClass } from "./action-tray.j
|
|
|
15
15
|
import { ModeBar, ModeBarDot, ModeBarLink } from "./mode-bar.js";
|
|
16
16
|
import { Tab, TabList, TabPanel, Tabs } from "./tab.js";
|
|
17
17
|
import { KitToaster, kitToast, kitToastManager } from "./toast.js";
|
|
18
|
-
export { AGENT_PRESENCE, ActionTray, Autocomplete, Avatar, AvatarStack, Badge, Button, Card, CardHeader, Checkbox, ChoiceCard, ChoiceList, ChoiceSwitch, Dot, EmptyState, ExpandedEditorModal, FLOATING_LAYER, Field, FieldDescribedByContext, FieldLabelledByContext, FlowBody, FlowClose, FlowFooter, FlowHeader, FlowLabel, FlowModal, HeaderStatus, HelpMore, Highlight, HintTooltip, HoverCard, HoverCardContent, HoverCardTrigger, IconButton, Input, Kbd, KitToaster, Label, Menu, MenuCheckItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Modal, ModalBody, ModalClose, ModalContent, ModalFooter, ModalHeader, ModalTrigger, ModeBar, ModeBarDot, ModeBarLink, MoreOptions, OptionRow, PageHeader, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, Radio, RadioGroup, RevealLink, SEARCH_THRESHOLD, SEGMENTED_MAX, SEGMENTED_MAX_LABEL, SearchInput, Segmented, Select, Separator, SettingsSection, Sheet, SheetClose, SheetContent, SheetTrigger, ShortcutHint, ShortcutHintsProvider, Skeleton, Slider, Sparkle, Spinner, Stat, StatusMark, StatusPill, Switch, Tab, TabList, TabPanel, Table, Tabs, Td, Textarea, Th, ToggleGroup, ToggleItem, Tooltip, TooltipProvider, TooltipScope, Tr, TrayMeta, TrayMore, actionTrayClass, avatarRingSpread, badgeVariants, buttonVariants, colorFor, filterOptions, fitsSegmented, iconButtonVariants, kitToast, kitToastManager, matchPositions, matchScore, nodeText, presenceColor, presenceSlot, registerPresenceRoster, selectTriggerClass, shortcutHintsOn, statusMap, useFieldDescribedBy, useFieldId, useFieldLabelledBy, useFocusReturn, useShortcutHints };
|
|
18
|
+
export { AGENT_PRESENCE, ActionTray, Autocomplete, Avatar, AvatarStack, Badge, Button, Card, CardHeader, Checkbox, ChoiceCard, ChoiceList, ChoiceSwitch, Dot, EmptyState, ExpandedEditorModal, FLOATING_LAYER, Field, FieldDescribedByContext, FieldLabelledByContext, FlowBody, FlowClose, FlowFooter, FlowHeader, FlowLabel, FlowModal, HeaderStatus, HelpMore, Highlight, HintTooltip, HoverCard, HoverCardContent, HoverCardTrigger, IconButton, Input, Kbd, KitToaster, Label, Menu, MenuCheckItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Modal, ModalBody, ModalClose, ModalContent, ModalFooter, ModalHeader, ModalTrigger, ModeBar, ModeBarDot, ModeBarLink, MoreOptions, OptionRow, PageHeader, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, Radio, RadioGroup, RevealLink, SEARCH_THRESHOLD, SEGMENTED_MAX, SEGMENTED_MAX_LABEL, SearchInput, Segmented, Select, Separator, SettingsSection, Sheet, SheetClose, SheetContent, SheetTrigger, ShortcutHint, ShortcutHintsProvider, Skeleton, Slider, Sparkle, Spinner, Stat, StatusMark, StatusPill, Switch, Tab, TabList, TabPanel, Table, Tabs, Td, Textarea, Th, ToggleGroup, ToggleItem, Tooltip, TooltipProvider, TooltipScope, Tr, TrayMeta, TrayMore, actionTrayClass, avatarRingSpread, badgeVariants, buttonVariants, colorFor, filterOptions, fitsSegmented, iconButtonVariants, kitToast, kitToastManager, matchPositions, matchScore, nodeText, platformKeys, presenceColor, presenceSlot, registerPresenceRoster, selectTriggerClass, shortcutHintsOn, statusMap, useFieldDescribedBy, useFieldId, useFieldLabelledBy, useFocusReturn, useShortcutHints };
|
package/dist/ui/input.js
CHANGED
|
@@ -3,7 +3,7 @@ import { FieldDescribedByContext, FieldIdContext, FieldLabelledByContext, useFie
|
|
|
3
3
|
import { HintTooltip } from "./button.js";
|
|
4
4
|
import { useShortcutHints } from "./shortcut-hint.js";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import { Fragment,
|
|
6
|
+
import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
|
|
7
7
|
import { IconInfoCircle, IconSearch, IconX } from "@tabler/icons-react";
|
|
8
8
|
//#region src/ui/input.tsx
|
|
9
9
|
/**
|
|
@@ -11,6 +11,7 @@ import { IconInfoCircle, IconSearch, IconX } from "@tabler/icons-react";
|
|
|
11
11
|
* "filled" (grey, borderless) is kept only for search fields, which Figma draws grey.
|
|
12
12
|
* Heights follow buttons: sm 28 · md 32 · lg 36.
|
|
13
13
|
*/
|
|
14
|
+
var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/ui/input.tsx";
|
|
14
15
|
var joinIds = (...ids) => ids.filter(Boolean).join(" ") || void 0;
|
|
15
16
|
var base = "w-full min-w-0 rounded-kit-md border border-kit-field-border bg-kit-field-bg text-kit-fg shadow-kit-field placeholder:text-kit-fg-4 transition-[border-color,box-shadow] duration-150 hover:border-kit-field-border-hover focus:border-kit-field-border-focus focus:shadow-kit-ring-field disabled:cursor-not-allowed disabled:bg-kit-subtle disabled:opacity-60 aria-[invalid=true]:border-[var(--kit-field-invalid)]";
|
|
16
17
|
var Input = React.forwardRef(({ className, size = "md", leading, trailing, variant = "outline", ...rest }, ref) => {
|
|
@@ -27,29 +28,49 @@ var Input = React.forwardRef(({ className, size = "md", leading, trailing, varia
|
|
|
27
28
|
};
|
|
28
29
|
const h = size === "sm" ? "h-7 text-kit-sm" : size === "lg" ? "h-9 text-kit-base" : "h-8 text-kit-sm";
|
|
29
30
|
const v = variant === "filled" ? "bg-kit-muted border-transparent shadow-none hover:border-kit-line-strong" : "";
|
|
30
|
-
if (!leading && !trailing) return /* @__PURE__ */
|
|
31
|
+
if (!leading && !trailing) return /* @__PURE__ */ jsxDEV("input", {
|
|
31
32
|
ref,
|
|
32
33
|
className: cn(base, h, v, "px-2.5", className),
|
|
33
34
|
...props
|
|
34
|
-
}
|
|
35
|
-
|
|
35
|
+
}, void 0, false, {
|
|
36
|
+
fileName: _jsxFileName,
|
|
37
|
+
lineNumber: 51,
|
|
38
|
+
columnNumber: 39
|
|
39
|
+
}, void 0);
|
|
40
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
36
41
|
className: cn("relative flex items-center", className),
|
|
37
42
|
children: [
|
|
38
|
-
leading ? /* @__PURE__ */
|
|
43
|
+
leading ? /* @__PURE__ */ jsxDEV("span", {
|
|
39
44
|
className: "pointer-events-none absolute left-2.5 flex text-kit-fg-3 [&_svg]:size-4",
|
|
40
45
|
children: leading
|
|
41
|
-
}
|
|
42
|
-
|
|
46
|
+
}, void 0, false, {
|
|
47
|
+
fileName: _jsxFileName,
|
|
48
|
+
lineNumber: 55,
|
|
49
|
+
columnNumber: 11
|
|
50
|
+
}, void 0) : null,
|
|
51
|
+
/* @__PURE__ */ jsxDEV("input", {
|
|
43
52
|
ref,
|
|
44
53
|
className: cn(base, h, v, leading ? "pl-8" : "pl-2.5", trailing ? "pr-8" : "pr-2.5"),
|
|
45
54
|
...props
|
|
46
|
-
}
|
|
47
|
-
|
|
55
|
+
}, void 0, false, {
|
|
56
|
+
fileName: _jsxFileName,
|
|
57
|
+
lineNumber: 57,
|
|
58
|
+
columnNumber: 9
|
|
59
|
+
}, void 0),
|
|
60
|
+
trailing ? /* @__PURE__ */ jsxDEV("span", {
|
|
48
61
|
className: "absolute right-2 flex items-center text-kit-fg-3 [&_svg]:size-4",
|
|
49
62
|
children: trailing
|
|
50
|
-
}
|
|
63
|
+
}, void 0, false, {
|
|
64
|
+
fileName: _jsxFileName,
|
|
65
|
+
lineNumber: 58,
|
|
66
|
+
columnNumber: 21
|
|
67
|
+
}, void 0) : null
|
|
51
68
|
]
|
|
52
|
-
}
|
|
69
|
+
}, void 0, true, {
|
|
70
|
+
fileName: _jsxFileName,
|
|
71
|
+
lineNumber: 53,
|
|
72
|
+
columnNumber: 7
|
|
73
|
+
}, void 0);
|
|
53
74
|
});
|
|
54
75
|
Input.displayName = "Input";
|
|
55
76
|
var Textarea = React.forwardRef(({ className, autoGrow = true, variant = "outline", onInput, ...rest }, ref) => {
|
|
@@ -89,7 +110,7 @@ var Textarea = React.forwardRef(({ className, autoGrow = true, variant = "outlin
|
|
|
89
110
|
ro.disconnect();
|
|
90
111
|
};
|
|
91
112
|
}, [autoGrow]);
|
|
92
|
-
return /* @__PURE__ */
|
|
113
|
+
return /* @__PURE__ */ jsxDEV("textarea", {
|
|
93
114
|
ref: inner,
|
|
94
115
|
rows: props.rows ?? 2,
|
|
95
116
|
onInput: (e) => {
|
|
@@ -98,12 +119,16 @@ var Textarea = React.forwardRef(({ className, autoGrow = true, variant = "outlin
|
|
|
98
119
|
},
|
|
99
120
|
className: cn(base, "min-h-16 resize-none px-2.5 py-2 text-kit-sm leading-[20px]", variant === "filled" && "bg-kit-muted border-transparent shadow-none", className),
|
|
100
121
|
...props
|
|
101
|
-
}
|
|
122
|
+
}, void 0, false, {
|
|
123
|
+
fileName: _jsxFileName,
|
|
124
|
+
lineNumber: 109,
|
|
125
|
+
columnNumber: 7
|
|
126
|
+
}, void 0);
|
|
102
127
|
});
|
|
103
128
|
Textarea.displayName = "Textarea";
|
|
104
129
|
function SearchInput({ value, onChange, placeholder = "Search…", className, size = "md", autoFocus, shortcut, variant = "filled", count, onKeyDown, inputRef, "aria-label": ariaLabel }) {
|
|
105
130
|
const hints = useShortcutHints();
|
|
106
|
-
return /* @__PURE__ */
|
|
131
|
+
return /* @__PURE__ */ jsxDEV(Input, {
|
|
107
132
|
ref: inputRef,
|
|
108
133
|
variant,
|
|
109
134
|
size,
|
|
@@ -113,33 +138,65 @@ function SearchInput({ value, onChange, placeholder = "Search…", className, si
|
|
|
113
138
|
"aria-label": ariaLabel ?? placeholder.replace(/…$/, ""),
|
|
114
139
|
onChange: (e) => onChange(e.target.value),
|
|
115
140
|
onKeyDown,
|
|
116
|
-
leading: /* @__PURE__ */
|
|
141
|
+
leading: /* @__PURE__ */ jsxDEV(IconSearch, { "aria-hidden": true }, void 0, false, {
|
|
142
|
+
fileName: _jsxFileName,
|
|
143
|
+
lineNumber: 174,
|
|
144
|
+
columnNumber: 16
|
|
145
|
+
}, this),
|
|
117
146
|
className: cn(className, value && count ? "[&_input]:pr-28" : void 0),
|
|
118
|
-
trailing: value ? /* @__PURE__ */
|
|
147
|
+
trailing: value ? /* @__PURE__ */ jsxDEV("span", {
|
|
119
148
|
className: "flex items-center gap-1.5",
|
|
120
|
-
children: [count ? /* @__PURE__ */
|
|
149
|
+
children: [count ? /* @__PURE__ */ jsxDEV("span", {
|
|
121
150
|
"aria-live": "polite",
|
|
122
151
|
className: "whitespace-nowrap text-kit-xs tabular-nums text-kit-fg-3",
|
|
123
152
|
children: count
|
|
124
|
-
}
|
|
153
|
+
}, void 0, false, {
|
|
154
|
+
fileName: _jsxFileName,
|
|
155
|
+
lineNumber: 180,
|
|
156
|
+
columnNumber: 15
|
|
157
|
+
}, this) : null, /* @__PURE__ */ jsxDEV("button", {
|
|
125
158
|
type: "button",
|
|
126
159
|
"aria-label": "Clear search",
|
|
127
160
|
onClick: () => onChange(""),
|
|
128
161
|
className: "flex size-5 items-center justify-center rounded-kit-sm text-kit-fg-3 hover:bg-kit-selected hover:text-kit-fg [&_svg]:size-3.5",
|
|
129
|
-
children: /* @__PURE__ */
|
|
130
|
-
|
|
131
|
-
|
|
162
|
+
children: /* @__PURE__ */ jsxDEV(IconX, { "aria-hidden": true }, void 0, false, {
|
|
163
|
+
fileName: _jsxFileName,
|
|
164
|
+
lineNumber: 190,
|
|
165
|
+
columnNumber: 15
|
|
166
|
+
}, this)
|
|
167
|
+
}, void 0, false, {
|
|
168
|
+
fileName: _jsxFileName,
|
|
169
|
+
lineNumber: 184,
|
|
170
|
+
columnNumber: 13
|
|
171
|
+
}, this)]
|
|
172
|
+
}, void 0, true, {
|
|
173
|
+
fileName: _jsxFileName,
|
|
174
|
+
lineNumber: 178,
|
|
175
|
+
columnNumber: 11
|
|
176
|
+
}, this) : shortcut && hints ? /* @__PURE__ */ jsxDEV("kbd", {
|
|
132
177
|
"data-hint": "shortcuts",
|
|
133
178
|
className: "font-kit-sans text-kit-2xs text-kit-fg-3",
|
|
134
179
|
children: shortcut
|
|
135
|
-
}
|
|
136
|
-
|
|
180
|
+
}, void 0, false, {
|
|
181
|
+
fileName: _jsxFileName,
|
|
182
|
+
lineNumber: 194,
|
|
183
|
+
columnNumber: 11
|
|
184
|
+
}, this) : void 0
|
|
185
|
+
}, void 0, false, {
|
|
186
|
+
fileName: _jsxFileName,
|
|
187
|
+
lineNumber: 164,
|
|
188
|
+
columnNumber: 5
|
|
189
|
+
}, this);
|
|
137
190
|
}
|
|
138
191
|
function Label({ className, ...props }) {
|
|
139
|
-
return /* @__PURE__ */
|
|
192
|
+
return /* @__PURE__ */ jsxDEV("label", {
|
|
140
193
|
className: cn("text-kit-sm font-medium text-kit-fg", className),
|
|
141
194
|
...props
|
|
142
|
-
}
|
|
195
|
+
}, void 0, false, {
|
|
196
|
+
fileName: _jsxFileName,
|
|
197
|
+
lineNumber: 204,
|
|
198
|
+
columnNumber: 10
|
|
199
|
+
}, this);
|
|
143
200
|
}
|
|
144
201
|
/**
|
|
145
202
|
* Field = label row · help · control · error. CPO D39, the one help system (same spec as the Block Kit FieldShell):
|
|
@@ -157,92 +214,172 @@ function Field({ label, htmlFor, hint, help, helpMore, error, required, counter,
|
|
|
157
214
|
const moreId = `${id}-more`;
|
|
158
215
|
const errId = `${id}-error`;
|
|
159
216
|
const describedBy = [error ? errId : help ? helpId : null, helpMore ? moreId : null].filter(Boolean).join(" ") || void 0;
|
|
160
|
-
return /* @__PURE__ */
|
|
217
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
161
218
|
className: cn("flex flex-col gap-1.5", className),
|
|
162
219
|
children: [
|
|
163
|
-
label || actions || counter ? /* @__PURE__ */
|
|
220
|
+
label || actions || counter ? /* @__PURE__ */ jsxDEV("div", {
|
|
164
221
|
className: "flex min-h-5 items-center justify-between gap-2",
|
|
165
|
-
children: [/* @__PURE__ */
|
|
222
|
+
children: [/* @__PURE__ */ jsxDEV("span", {
|
|
166
223
|
className: "flex min-w-0 items-center gap-1",
|
|
167
|
-
children: [/* @__PURE__ */
|
|
224
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
168
225
|
htmlFor: label ? id : void 0,
|
|
169
226
|
className: "flex items-center gap-1.5 text-kit-sm text-kit-fg-2",
|
|
170
227
|
children: [
|
|
171
228
|
label,
|
|
172
|
-
required ? /* @__PURE__ */
|
|
229
|
+
required ? /* @__PURE__ */ jsxDEV(Fragment, { children: [/* @__PURE__ */ jsxDEV("span", {
|
|
173
230
|
"aria-hidden": true,
|
|
174
231
|
className: "text-kit-danger-fg",
|
|
175
232
|
children: "*"
|
|
176
|
-
}
|
|
233
|
+
}, void 0, false, {
|
|
234
|
+
fileName: _jsxFileName,
|
|
235
|
+
lineNumber: 259,
|
|
236
|
+
columnNumber: 19
|
|
237
|
+
}, this), /* @__PURE__ */ jsxDEV("span", {
|
|
177
238
|
className: "sr-only",
|
|
178
239
|
children: "(required)"
|
|
179
|
-
}
|
|
180
|
-
|
|
240
|
+
}, void 0, false, {
|
|
241
|
+
fileName: _jsxFileName,
|
|
242
|
+
lineNumber: 260,
|
|
243
|
+
columnNumber: 19
|
|
244
|
+
}, this)] }, void 0, true, {
|
|
245
|
+
fileName: _jsxFileName,
|
|
246
|
+
lineNumber: 258,
|
|
247
|
+
columnNumber: 17
|
|
248
|
+
}, this) : null,
|
|
249
|
+
hint ? /* @__PURE__ */ jsxDEV("span", {
|
|
181
250
|
className: "font-normal text-kit-fg-3",
|
|
182
251
|
children: hint
|
|
183
|
-
}
|
|
252
|
+
}, void 0, false, {
|
|
253
|
+
fileName: _jsxFileName,
|
|
254
|
+
lineNumber: 263,
|
|
255
|
+
columnNumber: 23
|
|
256
|
+
}, this) : null
|
|
184
257
|
]
|
|
185
|
-
}
|
|
258
|
+
}, void 0, true, {
|
|
259
|
+
fileName: _jsxFileName,
|
|
260
|
+
lineNumber: 255,
|
|
261
|
+
columnNumber: 13
|
|
262
|
+
}, this), helpMore ? /* @__PURE__ */ jsxDEV(HelpMore, {
|
|
186
263
|
id: moreId,
|
|
187
264
|
label: typeof label === "string" ? label : void 0,
|
|
188
265
|
children: helpMore
|
|
189
|
-
}
|
|
190
|
-
|
|
266
|
+
}, void 0, false, {
|
|
267
|
+
fileName: _jsxFileName,
|
|
268
|
+
lineNumber: 266,
|
|
269
|
+
columnNumber: 15
|
|
270
|
+
}, this) : null]
|
|
271
|
+
}, void 0, true, {
|
|
272
|
+
fileName: _jsxFileName,
|
|
273
|
+
lineNumber: 254,
|
|
274
|
+
columnNumber: 11
|
|
275
|
+
}, this), /* @__PURE__ */ jsxDEV("div", {
|
|
191
276
|
className: "flex items-center gap-1",
|
|
192
|
-
children: [counter ? /* @__PURE__ */
|
|
277
|
+
children: [counter ? /* @__PURE__ */ jsxDEV("span", {
|
|
193
278
|
className: cn("tabular-nums text-kit-xs", counter.value > counter.max ? "text-kit-danger-fg" : counter.value > counter.max * .9 ? "text-kit-warning-fg" : "text-kit-fg-3"),
|
|
194
279
|
children: [
|
|
195
280
|
counter.value,
|
|
196
281
|
"/",
|
|
197
282
|
counter.max
|
|
198
283
|
]
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
284
|
+
}, void 0, true, {
|
|
285
|
+
fileName: _jsxFileName,
|
|
286
|
+
lineNumber: 273,
|
|
287
|
+
columnNumber: 15
|
|
288
|
+
}, this) : null, actions]
|
|
289
|
+
}, void 0, true, {
|
|
290
|
+
fileName: _jsxFileName,
|
|
291
|
+
lineNumber: 271,
|
|
292
|
+
columnNumber: 11
|
|
293
|
+
}, this)]
|
|
294
|
+
}, void 0, true, {
|
|
295
|
+
fileName: _jsxFileName,
|
|
296
|
+
lineNumber: 253,
|
|
297
|
+
columnNumber: 9
|
|
298
|
+
}, this) : null,
|
|
299
|
+
help && !error ? /* @__PURE__ */ jsxDEV("p", {
|
|
203
300
|
id: helpId,
|
|
204
301
|
"data-slot": "field-help",
|
|
205
302
|
className: "-mt-0.5 text-kit-xs leading-4 text-kit-fg-3",
|
|
206
303
|
children: help
|
|
207
|
-
}
|
|
208
|
-
|
|
304
|
+
}, void 0, false, {
|
|
305
|
+
fileName: _jsxFileName,
|
|
306
|
+
lineNumber: 291,
|
|
307
|
+
columnNumber: 9
|
|
308
|
+
}, this) : null,
|
|
309
|
+
/* @__PURE__ */ jsxDEV(FieldIdContext.Provider, {
|
|
209
310
|
value: label ? id : void 0,
|
|
210
|
-
children: /* @__PURE__ */
|
|
311
|
+
children: /* @__PURE__ */ jsxDEV(FieldDescribedByContext.Provider, {
|
|
211
312
|
value: describedBy,
|
|
212
313
|
children
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
314
|
+
}, void 0, false, {
|
|
315
|
+
fileName: _jsxFileName,
|
|
316
|
+
lineNumber: 296,
|
|
317
|
+
columnNumber: 9
|
|
318
|
+
}, this)
|
|
319
|
+
}, void 0, false, {
|
|
320
|
+
fileName: _jsxFileName,
|
|
321
|
+
lineNumber: 295,
|
|
322
|
+
columnNumber: 7
|
|
323
|
+
}, this),
|
|
324
|
+
error ? /* @__PURE__ */ jsxDEV("p", {
|
|
216
325
|
id: errId,
|
|
217
326
|
role: "alert",
|
|
218
327
|
className: "text-kit-xs leading-4 text-kit-danger-fg",
|
|
219
328
|
children: error
|
|
220
|
-
}
|
|
329
|
+
}, void 0, false, {
|
|
330
|
+
fileName: _jsxFileName,
|
|
331
|
+
lineNumber: 299,
|
|
332
|
+
columnNumber: 9
|
|
333
|
+
}, this) : null
|
|
221
334
|
]
|
|
222
|
-
}
|
|
335
|
+
}, void 0, true, {
|
|
336
|
+
fileName: _jsxFileName,
|
|
337
|
+
lineNumber: 251,
|
|
338
|
+
columnNumber: 5
|
|
339
|
+
}, this);
|
|
223
340
|
}
|
|
224
341
|
/** The ⓘ next to a label: longer help in a tooltip, also read by screen readers through aria-describedby (D39). */
|
|
225
342
|
function HelpMore({ id, label, children }) {
|
|
226
|
-
return /* @__PURE__ */
|
|
227
|
-
content: /* @__PURE__ */
|
|
343
|
+
return /* @__PURE__ */ jsxDEV(HintTooltip, {
|
|
344
|
+
content: /* @__PURE__ */ jsxDEV("span", {
|
|
228
345
|
className: "block max-w-[260px] whitespace-normal font-normal leading-4",
|
|
229
346
|
children
|
|
230
|
-
}
|
|
231
|
-
|
|
347
|
+
}, void 0, false, {
|
|
348
|
+
fileName: _jsxFileName,
|
|
349
|
+
lineNumber: 310,
|
|
350
|
+
columnNumber: 27
|
|
351
|
+
}, this),
|
|
352
|
+
children: /* @__PURE__ */ jsxDEV("button", {
|
|
232
353
|
type: "button",
|
|
233
354
|
"aria-label": label ? `About ${label}` : "More about this field",
|
|
234
355
|
className: "hit-area inline-flex size-4 shrink-0 items-center justify-center rounded-kit-sm text-kit-fg-4 [--hit-size:16px] hover:text-kit-fg-2",
|
|
235
|
-
children: [/* @__PURE__ */
|
|
356
|
+
children: [/* @__PURE__ */ jsxDEV(IconInfoCircle, {
|
|
236
357
|
className: "size-3.5",
|
|
237
358
|
stroke: 1.5,
|
|
238
359
|
"aria-hidden": true
|
|
239
|
-
}
|
|
360
|
+
}, void 0, false, {
|
|
361
|
+
fileName: _jsxFileName,
|
|
362
|
+
lineNumber: 316,
|
|
363
|
+
columnNumber: 9
|
|
364
|
+
}, this), /* @__PURE__ */ jsxDEV("span", {
|
|
240
365
|
id,
|
|
241
366
|
className: "sr-only",
|
|
242
367
|
children
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
368
|
+
}, void 0, false, {
|
|
369
|
+
fileName: _jsxFileName,
|
|
370
|
+
lineNumber: 317,
|
|
371
|
+
columnNumber: 9
|
|
372
|
+
}, this)]
|
|
373
|
+
}, void 0, true, {
|
|
374
|
+
fileName: _jsxFileName,
|
|
375
|
+
lineNumber: 311,
|
|
376
|
+
columnNumber: 7
|
|
377
|
+
}, this)
|
|
378
|
+
}, void 0, false, {
|
|
379
|
+
fileName: _jsxFileName,
|
|
380
|
+
lineNumber: 310,
|
|
381
|
+
columnNumber: 5
|
|
382
|
+
}, this);
|
|
246
383
|
}
|
|
247
384
|
//#endregion
|
|
248
385
|
export { Field, FieldDescribedByContext, FieldLabelledByContext, HelpMore, Input, Label, SearchInput, Textarea, useFieldDescribedBy, useFieldId, useFieldLabelledBy };
|
package/dist/ui/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","names":[],"sources":["../../src/ui/input.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { IconInfoCircle, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { HintTooltip } from \"./button\";\nimport { useShortcutHints } from \"./shortcut-hint\";\n\n/**\n * Inputs — CPO D19: white field + 1px --field-border at rest (default \"outline\"), border darkens on hover, halo on focus.\n * \"filled\" (grey, borderless) is kept only for search fields, which Figma draws grey.\n * Heights follow buttons: sm 28 · md 32 · lg 36.\n */\nimport {\n FieldDescribedByContext,\n FieldIdContext,\n FieldLabelledByContext,\n useFieldDescribedBy,\n useFieldId,\n useFieldLabelledBy,\n useLabelFor,\n} from \"./field-context\";\n/* The Field contexts live in field-context.ts so controls in other files (Switch, Select) read the same ones. */\nexport { FieldDescribedByContext, FieldLabelledByContext, useFieldDescribedBy, useFieldId, useFieldLabelledBy };\n\nconst joinIds = (...ids: (string | undefined)[]) => ids.filter(Boolean).join(\" \") || undefined;\n\nconst base =\n \"w-full min-w-0 rounded-kit-md border border-kit-field-border bg-kit-field-bg text-kit-fg shadow-kit-field placeholder:text-kit-fg-4 transition-[border-color,box-shadow] duration-150 hover:border-kit-field-border-hover focus:border-kit-field-border-focus focus:shadow-kit-ring-field disabled:cursor-not-allowed disabled:bg-kit-subtle disabled:opacity-60 aria-[invalid=true]:border-[var(--kit-field-invalid)]\";\n\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n size?: \"sm\" | \"md\" | \"lg\";\n leading?: React.ReactNode;\n trailing?: React.ReactNode;\n variant?: \"filled\" | \"outline\";\n}\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, size = \"md\", leading, trailing, variant = \"outline\", ...rest }, ref) => {\n const fieldId = useFieldId();\n const labelledBy = useFieldLabelledBy();\n const named = rest.id ?? fieldId ?? rest[\"aria-label\"] ?? rest[\"aria-labelledby\"];\n const labelFor = useLabelFor(rest.id ?? fieldId);\n const describedBy = useFieldDescribedBy();\n const props = {\n ...rest,\n id: rest.id ?? fieldId,\n \"aria-labelledby\": rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] ? undefined : (labelFor ?? (named ? undefined : labelledBy))),\n \"aria-describedby\": joinIds(rest[\"aria-describedby\"], describedBy),\n };\n const h = size === \"sm\" ? \"h-7 text-kit-sm\" : size === \"lg\" ? \"h-9 text-kit-base\" : \"h-8 text-kit-sm\";\n const v = variant === \"filled\" ? \"bg-kit-muted border-transparent shadow-none hover:border-kit-line-strong\" : \"\";\n if (!leading && !trailing) return <input ref={ref} className={cn(base, h, v, \"px-2.5\", className)} {...props} />;\n return (\n <div className={cn(\"relative flex items-center\", className)}>\n {leading ? (\n <span className=\"pointer-events-none absolute left-2.5 flex text-kit-fg-3 [&_svg]:size-4\">{leading}</span>\n ) : null}\n <input ref={ref} className={cn(base, h, v, leading ? \"pl-8\" : \"pl-2.5\", trailing ? \"pr-8\" : \"pr-2.5\")} {...props} />\n {trailing ? <span className=\"absolute right-2 flex items-center text-kit-fg-3 [&_svg]:size-4\">{trailing}</span> : null}\n </div>\n );\n },\n);\nInput.displayName = \"Input\";\n\nexport type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & { autoGrow?: boolean; variant?: \"filled\" | \"outline\" };\n\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, autoGrow = true, variant = \"outline\", onInput, ...rest }, ref) => {\n const fieldId = useFieldId();\n const labelFor = useLabelFor(rest.id ?? fieldId);\n const describedBy = useFieldDescribedBy();\n const props = {\n ...rest,\n id: rest.id ?? fieldId,\n \"aria-labelledby\": rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] ? undefined : labelFor),\n \"aria-describedby\": joinIds(rest[\"aria-describedby\"], describedBy),\n };\n const inner = React.useRef<HTMLTextAreaElement | null>(null);\n React.useImperativeHandle(ref, () => inner.current as HTMLTextAreaElement);\n const grow = () => {\n const el = inner.current;\n if (!el || !autoGrow || !el.clientWidth) return; // hidden / zero-width: measuring now would be wrong\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight + 2}px`;\n };\n React.useLayoutEffect(grow, [props.value, autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n /* Re-measure when the WIDTH changes (a panel resize or a panel that mounts mid-animation): a height measured at a\n narrower width is stale and leaves single-line fields hundreds of px tall. Height-only changes are ignored, so\n the observer never feeds itself. */\n React.useEffect(() => {\n const el = inner.current;\n if (!el || !autoGrow || typeof ResizeObserver === \"undefined\") return;\n let w = el.clientWidth;\n let raf = 0;\n const ro = new ResizeObserver(() => {\n const nw = el.clientWidth;\n if (nw === w) return;\n w = nw;\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(grow);\n });\n ro.observe(el);\n return () => {\n cancelAnimationFrame(raf);\n ro.disconnect();\n };\n }, [autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n return (\n <textarea\n ref={inner}\n rows={props.rows ?? 2}\n onInput={(e) => {\n grow();\n onInput?.(e);\n }}\n className={cn(\n base,\n \"min-h-16 resize-none px-2.5 py-2 text-kit-sm leading-[20px]\",\n variant === \"filled\" && \"bg-kit-muted border-transparent shadow-none\",\n className,\n )}\n {...props}\n />\n );\n },\n);\nTextarea.displayName = \"Textarea\";\n\nexport function SearchInput({\n value,\n onChange,\n placeholder = \"Search…\",\n className,\n size = \"md\",\n autoFocus,\n shortcut,\n variant = \"filled\",\n count,\n onKeyDown,\n inputRef,\n \"aria-label\": ariaLabel,\n}: {\n \"aria-label\"?: string;\n value: string;\n onChange: (v: string) => void;\n placeholder?: string;\n className?: string;\n size?: \"sm\" | \"md\" | \"lg\";\n autoFocus?: boolean;\n /** Shown only while the D44 keyboard hints switch is on. */\n shortcut?: string;\n /**\n * \"filled\" (grey) for search on white surfaces (menus, sidebars, lists); \"outline\" is the standard field (field-bg,\n * field-border) for search that sits on a grey plane, where a grey fill reads as a pill, not a field (D70, the schema desk).\n */\n variant?: \"filled\" | \"outline\";\n /** a result count shown inside the field while there is a query (\"3 matches\", \"2 of 5\"); announced politely */\n count?: string;\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n inputRef?: React.Ref<HTMLInputElement>;\n}) {\n const hints = useShortcutHints();\n return (\n <Input\n ref={inputRef}\n variant={variant}\n size={size}\n autoFocus={autoFocus}\n value={value}\n placeholder={placeholder}\n aria-label={ariaLabel ?? placeholder.replace(/…$/, \"\")}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={onKeyDown}\n leading={<IconSearch aria-hidden />}\n className={cn(className, value && count ? \"[&_input]:pr-28\" : undefined)}\n trailing={\n value ? (\n <span className=\"flex items-center gap-1.5\">\n {count ? (\n <span aria-live=\"polite\" className=\"whitespace-nowrap text-kit-xs tabular-nums text-kit-fg-3\">\n {count}\n </span>\n ) : null}\n <button\n type=\"button\"\n aria-label=\"Clear search\"\n onClick={() => onChange(\"\")}\n className=\"flex size-5 items-center justify-center rounded-kit-sm text-kit-fg-3 hover:bg-kit-selected hover:text-kit-fg [&_svg]:size-3.5\"\n >\n <IconX aria-hidden />\n </button>\n </span>\n ) : shortcut && hints ? (\n <kbd data-hint=\"shortcuts\" className=\"font-kit-sans text-kit-2xs text-kit-fg-3\">\n {shortcut}\n </kbd>\n ) : undefined\n }\n />\n );\n}\n\nexport function Label({ className, ...props }: React.LabelHTMLAttributes<HTMLLabelElement>) {\n return <label className={cn(\"text-kit-sm font-medium text-kit-fg\", className)} {...props} />;\n}\n\n/**\n * Field = label row · help · control · error. CPO D39, the one help system (same spec as the Block Kit FieldShell):\n * [Label *] [hint] [i helpMore] …… [counter] [actions]\n * help: 12/16, --fg-3 (≥4.5:1 light + dark), 4px under the label, 1–2 lines\n * control\n * error: replaces the help, danger colour, under the control\n * The control gets `aria-describedby` → help + ⓘ text + error.\n * Required marker is V2 ui/input.tsx:249 (--danger-fg); the sr-only \"(required)\" names it for screen readers.\n */\nexport function Field({\n label,\n htmlFor,\n hint,\n help,\n helpMore,\n error,\n required,\n counter,\n actions,\n children,\n className,\n}: {\n label?: React.ReactNode;\n htmlFor?: string;\n /** short, quiet aside on the label row (\"Optional\", \"Shown publicly\") */\n hint?: React.ReactNode;\n /** the help line under the label */\n help?: React.ReactNode;\n /** longer explanation behind the ⓘ next to the label */\n helpMore?: React.ReactNode;\n error?: React.ReactNode;\n required?: boolean;\n counter?: { value: number; max: number };\n actions?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n}) {\n const autoId = React.useId();\n const id = htmlFor ?? autoId;\n const helpId = `${id}-help`;\n const moreId = `${id}-more`;\n const errId = `${id}-error`;\n const describedBy = [error ? errId : help ? helpId : null, helpMore ? moreId : null].filter(Boolean).join(\" \") || undefined;\n return (\n <div className={cn(\"flex flex-col gap-1.5\", className)}>\n {label || actions || counter ? (\n <div className=\"flex min-h-5 items-center justify-between gap-2\">\n <span className=\"flex min-w-0 items-center gap-1\">\n <Label htmlFor={label ? id : undefined} className=\"flex items-center gap-1.5 text-kit-sm text-kit-fg-2\">\n {label}\n {required ? (\n <>\n <span aria-hidden className=\"text-kit-danger-fg\">*</span>\n <span className=\"sr-only\">(required)</span>\n </>\n ) : null}\n {hint ? <span className=\"font-normal text-kit-fg-3\">{hint}</span> : null}\n </Label>\n {helpMore ? (\n <HelpMore id={moreId} label={typeof label === \"string\" ? label : undefined}>\n {helpMore}\n </HelpMore>\n ) : null}\n </span>\n <div className=\"flex items-center gap-1\">\n {counter ? (\n <span\n className={cn(\n \"tabular-nums text-kit-xs\",\n counter.value > counter.max\n ? \"text-kit-danger-fg\"\n : counter.value > counter.max * 0.9\n ? \"text-kit-warning-fg\"\n : \"text-kit-fg-3\",\n )}\n >\n {counter.value}/{counter.max}\n </span>\n ) : null}\n {actions}\n </div>\n </div>\n ) : null}\n {help && !error ? (\n <p id={helpId} data-slot=\"field-help\" className=\"-mt-0.5 text-kit-xs leading-4 text-kit-fg-3\">\n {help}\n </p>\n ) : null}\n <FieldIdContext.Provider value={label ? id : undefined}>\n <FieldDescribedByContext.Provider value={describedBy}>{children}</FieldDescribedByContext.Provider>\n </FieldIdContext.Provider>\n {error ? (\n <p id={errId} role=\"alert\" className=\"text-kit-xs leading-4 text-kit-danger-fg\">\n {error}\n </p>\n ) : null}\n </div>\n );\n}\n\n/** The ⓘ next to a label: longer help in a tooltip, also read by screen readers through aria-describedby (D39). */\nexport function HelpMore({ id, label, children }: { id?: string; label?: string; children: React.ReactNode }) {\n return (\n <HintTooltip content={<span className=\"block max-w-[260px] whitespace-normal font-normal leading-4\">{children}</span>}>\n <button\n type=\"button\"\n aria-label={label ? `About ${label}` : \"More about this field\"}\n className=\"hit-area inline-flex size-4 shrink-0 items-center justify-center rounded-kit-sm text-kit-fg-4 [--hit-size:16px] hover:text-kit-fg-2\"\n >\n <IconInfoCircle className=\"size-3.5\" stroke={1.5} aria-hidden />\n <span id={id} className=\"sr-only\">\n {children}\n </span>\n </button>\n </HintTooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAM,WAAW,GAAG,QAAgC,IAAI,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;AAErF,IAAM,OACJ;AASF,IAAa,QAAQ,MAAM,YACxB,EAAE,WAAW,OAAO,MAAM,SAAS,UAAU,UAAU,WAAW,GAAG,QAAQ,QAAQ;CACpF,MAAM,UAAU,WAAW;CAC3B,MAAM,aAAa,mBAAmB;CACtC,MAAM,QAAQ,KAAK,MAAM,WAAW,KAAK,iBAAiB,KAAK;CAC/D,MAAM,WAAW,YAAY,KAAK,MAAM,OAAO;CAC/C,MAAM,cAAc,oBAAoB;CACxC,MAAM,QAAQ;EACZ,GAAG;EACH,IAAI,KAAK,MAAM;EACf,mBAAmB,KAAK,uBAAuB,KAAK,gBAAgB,KAAA,IAAa,aAAa,QAAQ,KAAA,IAAY;EAClH,oBAAoB,QAAQ,KAAK,qBAAqB,WAAW;CACnE;CACA,MAAM,IAAI,SAAS,OAAO,oBAAoB,SAAS,OAAO,sBAAsB;CACpF,MAAM,IAAI,YAAY,WAAW,6EAA6E;CAC9G,IAAI,CAAC,WAAW,CAAC,UAAU,OAAO,oBAAC,SAAD;EAAY;EAAK,WAAW,GAAG,MAAM,GAAG,GAAG,UAAU,SAAS;EAAG,GAAI;CAAQ,CAAA;CAC/G,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,8BAA8B,SAAS;EAA1D,UAAA;GACG,UACC,oBAAC,QAAD;IAAM,WAAU;IAA2E,UAAA;GAAc,CAAA,IACvG;GACJ,oBAAC,SAAD;IAAY;IAAK,WAAW,GAAG,MAAM,GAAG,GAAG,UAAU,SAAS,UA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;IAAa,WAAU;IAC7C,UAAA;GACA,CAAA,IACD;GACJ,oBAAC,eAAe,UAAhB;IAAyB,OAAO,QAAQ,KAAK,KAAA;IAC3C,UAAA,oBAAC,wBAAwB,UAAzB;KAAkC,OAAO;KAAc;IAA2C,CAAA;GAC3E,CAAA;GACxB,QACC,oBAAC,KAAD;IAAG,IAAI;IAAO,MAAK;IAAQ,WAAU;IAClC,UAAA;GACA,CAAA,IACD;EACD;;AAET;;AAGA,SAAgB,SAAS,EAAE,IAAI,OAAO,YAAwE;CAC5G,OACE,oBAAC,aAAD;EAAa,SAAS,oBAAC,QAAD;GAAM,WAAU;GAA+D;EAAe,CAAA;EAClH,UAAA,qBAAC,UAAD;GACE,MAAK;GACL,cAAY,QAAQ,SAAS,UAAU;GACvC,WAAU;GAHZ,UAAA,CAKE,oBAAC,gBAAD;IAAgB,WAAU;IAAW,QAAQ;IAAK,eAAA;GAAa,CAAA,GAC/D,oBAAC,QAAD;IAAU;IAAI,WAAU;IACrB;GACG,CAAA,CACA;;CACG,CAAA;AAEjB"}
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../src/ui/input.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { IconInfoCircle, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { HintTooltip } from \"./button\";\nimport { useShortcutHints } from \"./shortcut-hint\";\n\n/**\n * Inputs — CPO D19: white field + 1px --field-border at rest (default \"outline\"), border darkens on hover, halo on focus.\n * \"filled\" (grey, borderless) is kept only for search fields, which Figma draws grey.\n * Heights follow buttons: sm 28 · md 32 · lg 36.\n */\nimport {\n FieldDescribedByContext,\n FieldIdContext,\n FieldLabelledByContext,\n useFieldDescribedBy,\n useFieldId,\n useFieldLabelledBy,\n useLabelFor,\n} from \"./field-context\";\n/* The Field contexts live in field-context.ts so controls in other files (Switch, Select) read the same ones. */\nexport { FieldDescribedByContext, FieldLabelledByContext, useFieldDescribedBy, useFieldId, useFieldLabelledBy };\n\nconst joinIds = (...ids: (string | undefined)[]) => ids.filter(Boolean).join(\" \") || undefined;\n\nconst base =\n \"w-full min-w-0 rounded-kit-md border border-kit-field-border bg-kit-field-bg text-kit-fg shadow-kit-field placeholder:text-kit-fg-4 transition-[border-color,box-shadow] duration-150 hover:border-kit-field-border-hover focus:border-kit-field-border-focus focus:shadow-kit-ring-field disabled:cursor-not-allowed disabled:bg-kit-subtle disabled:opacity-60 aria-[invalid=true]:border-[var(--kit-field-invalid)]\";\n\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n size?: \"sm\" | \"md\" | \"lg\";\n leading?: React.ReactNode;\n trailing?: React.ReactNode;\n variant?: \"filled\" | \"outline\";\n}\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, size = \"md\", leading, trailing, variant = \"outline\", ...rest }, ref) => {\n const fieldId = useFieldId();\n const labelledBy = useFieldLabelledBy();\n const named = rest.id ?? fieldId ?? rest[\"aria-label\"] ?? rest[\"aria-labelledby\"];\n const labelFor = useLabelFor(rest.id ?? fieldId);\n const describedBy = useFieldDescribedBy();\n const props = {\n ...rest,\n id: rest.id ?? fieldId,\n \"aria-labelledby\": rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] ? undefined : (labelFor ?? (named ? undefined : labelledBy))),\n \"aria-describedby\": joinIds(rest[\"aria-describedby\"], describedBy),\n };\n const h = size === \"sm\" ? \"h-7 text-kit-sm\" : size === \"lg\" ? \"h-9 text-kit-base\" : \"h-8 text-kit-sm\";\n const v = variant === \"filled\" ? \"bg-kit-muted border-transparent shadow-none hover:border-kit-line-strong\" : \"\";\n if (!leading && !trailing) return <input ref={ref} className={cn(base, h, v, \"px-2.5\", className)} {...props} />;\n return (\n <div className={cn(\"relative flex items-center\", className)}>\n {leading ? (\n <span className=\"pointer-events-none absolute left-2.5 flex text-kit-fg-3 [&_svg]:size-4\">{leading}</span>\n ) : null}\n <input ref={ref} className={cn(base, h, v, leading ? \"pl-8\" : \"pl-2.5\", trailing ? \"pr-8\" : \"pr-2.5\")} {...props} />\n {trailing ? <span className=\"absolute right-2 flex items-center text-kit-fg-3 [&_svg]:size-4\">{trailing}</span> : null}\n </div>\n );\n },\n);\nInput.displayName = \"Input\";\n\nexport type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & { autoGrow?: boolean; variant?: \"filled\" | \"outline\" };\n\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, autoGrow = true, variant = \"outline\", onInput, ...rest }, ref) => {\n const fieldId = useFieldId();\n const labelFor = useLabelFor(rest.id ?? fieldId);\n const describedBy = useFieldDescribedBy();\n const props = {\n ...rest,\n id: rest.id ?? fieldId,\n \"aria-labelledby\": rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] ? undefined : labelFor),\n \"aria-describedby\": joinIds(rest[\"aria-describedby\"], describedBy),\n };\n const inner = React.useRef<HTMLTextAreaElement | null>(null);\n React.useImperativeHandle(ref, () => inner.current as HTMLTextAreaElement);\n const grow = () => {\n const el = inner.current;\n if (!el || !autoGrow || !el.clientWidth) return; // hidden / zero-width: measuring now would be wrong\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight + 2}px`;\n };\n React.useLayoutEffect(grow, [props.value, autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n /* Re-measure when the WIDTH changes (a panel resize or a panel that mounts mid-animation): a height measured at a\n narrower width is stale and leaves single-line fields hundreds of px tall. Height-only changes are ignored, so\n the observer never feeds itself. */\n React.useEffect(() => {\n const el = inner.current;\n if (!el || !autoGrow || typeof ResizeObserver === \"undefined\") return;\n let w = el.clientWidth;\n let raf = 0;\n const ro = new ResizeObserver(() => {\n const nw = el.clientWidth;\n if (nw === w) return;\n w = nw;\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(grow);\n });\n ro.observe(el);\n return () => {\n cancelAnimationFrame(raf);\n ro.disconnect();\n };\n }, [autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n return (\n <textarea\n ref={inner}\n rows={props.rows ?? 2}\n onInput={(e) => {\n grow();\n onInput?.(e);\n }}\n className={cn(\n base,\n \"min-h-16 resize-none px-2.5 py-2 text-kit-sm leading-[20px]\",\n variant === \"filled\" && \"bg-kit-muted border-transparent shadow-none\",\n className,\n )}\n {...props}\n />\n );\n },\n);\nTextarea.displayName = \"Textarea\";\n\nexport function SearchInput({\n value,\n onChange,\n placeholder = \"Search…\",\n className,\n size = \"md\",\n autoFocus,\n shortcut,\n variant = \"filled\",\n count,\n onKeyDown,\n inputRef,\n \"aria-label\": ariaLabel,\n}: {\n \"aria-label\"?: string;\n value: string;\n onChange: (v: string) => void;\n placeholder?: string;\n className?: string;\n size?: \"sm\" | \"md\" | \"lg\";\n autoFocus?: boolean;\n /** Shown only while the D44 keyboard hints switch is on. */\n shortcut?: string;\n /**\n * \"filled\" (grey) for search on white surfaces (menus, sidebars, lists); \"outline\" is the standard field (field-bg,\n * field-border) for search that sits on a grey plane, where a grey fill reads as a pill, not a field (D70, the schema desk).\n */\n variant?: \"filled\" | \"outline\";\n /** a result count shown inside the field while there is a query (\"3 matches\", \"2 of 5\"); announced politely */\n count?: string;\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n inputRef?: React.Ref<HTMLInputElement>;\n}) {\n const hints = useShortcutHints();\n return (\n <Input\n ref={inputRef}\n variant={variant}\n size={size}\n autoFocus={autoFocus}\n value={value}\n placeholder={placeholder}\n aria-label={ariaLabel ?? placeholder.replace(/…$/, \"\")}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={onKeyDown}\n leading={<IconSearch aria-hidden />}\n className={cn(className, value && count ? \"[&_input]:pr-28\" : undefined)}\n trailing={\n value ? (\n <span className=\"flex items-center gap-1.5\">\n {count ? (\n <span aria-live=\"polite\" className=\"whitespace-nowrap text-kit-xs tabular-nums text-kit-fg-3\">\n {count}\n </span>\n ) : null}\n <button\n type=\"button\"\n aria-label=\"Clear search\"\n onClick={() => onChange(\"\")}\n className=\"flex size-5 items-center justify-center rounded-kit-sm text-kit-fg-3 hover:bg-kit-selected hover:text-kit-fg [&_svg]:size-3.5\"\n >\n <IconX aria-hidden />\n </button>\n </span>\n ) : shortcut && hints ? (\n <kbd data-hint=\"shortcuts\" className=\"font-kit-sans text-kit-2xs text-kit-fg-3\">\n {shortcut}\n </kbd>\n ) : undefined\n }\n />\n );\n}\n\nexport function Label({ className, ...props }: React.LabelHTMLAttributes<HTMLLabelElement>) {\n return <label className={cn(\"text-kit-sm font-medium text-kit-fg\", className)} {...props} />;\n}\n\n/**\n * Field = label row · help · control · error. CPO D39, the one help system (same spec as the Block Kit FieldShell):\n * [Label *] [hint] [i helpMore] …… [counter] [actions]\n * help: 12/16, --fg-3 (≥4.5:1 light + dark), 4px under the label, 1–2 lines\n * control\n * error: replaces the help, danger colour, under the control\n * The control gets `aria-describedby` → help + ⓘ text + error.\n * Required marker is V2 ui/input.tsx:249 (--danger-fg); the sr-only \"(required)\" names it for screen readers.\n */\nexport function Field({\n label,\n htmlFor,\n hint,\n help,\n helpMore,\n error,\n required,\n counter,\n actions,\n children,\n className,\n}: {\n label?: React.ReactNode;\n htmlFor?: string;\n /** short, quiet aside on the label row (\"Optional\", \"Shown publicly\") */\n hint?: React.ReactNode;\n /** the help line under the label */\n help?: React.ReactNode;\n /** longer explanation behind the ⓘ next to the label */\n helpMore?: React.ReactNode;\n error?: React.ReactNode;\n required?: boolean;\n counter?: { value: number; max: number };\n actions?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n}) {\n const autoId = React.useId();\n const id = htmlFor ?? autoId;\n const helpId = `${id}-help`;\n const moreId = `${id}-more`;\n const errId = `${id}-error`;\n const describedBy = [error ? errId : help ? helpId : null, helpMore ? moreId : null].filter(Boolean).join(\" \") || undefined;\n return (\n <div className={cn(\"flex flex-col gap-1.5\", className)}>\n {label || actions || counter ? (\n <div className=\"flex min-h-5 items-center justify-between gap-2\">\n <span className=\"flex min-w-0 items-center gap-1\">\n <Label htmlFor={label ? id : undefined} className=\"flex items-center gap-1.5 text-kit-sm text-kit-fg-2\">\n {label}\n {required ? (\n <>\n <span aria-hidden className=\"text-kit-danger-fg\">*</span>\n <span className=\"sr-only\">(required)</span>\n </>\n ) : null}\n {hint ? <span className=\"font-normal text-kit-fg-3\">{hint}</span> : null}\n </Label>\n {helpMore ? (\n <HelpMore id={moreId} label={typeof label === \"string\" ? label : undefined}>\n {helpMore}\n </HelpMore>\n ) : null}\n </span>\n <div className=\"flex items-center gap-1\">\n {counter ? (\n <span\n className={cn(\n \"tabular-nums text-kit-xs\",\n counter.value > counter.max\n ? \"text-kit-danger-fg\"\n : counter.value > counter.max * 0.9\n ? \"text-kit-warning-fg\"\n : \"text-kit-fg-3\",\n )}\n >\n {counter.value}/{counter.max}\n </span>\n ) : null}\n {actions}\n </div>\n </div>\n ) : null}\n {help && !error ? (\n <p id={helpId} data-slot=\"field-help\" className=\"-mt-0.5 text-kit-xs leading-4 text-kit-fg-3\">\n {help}\n </p>\n ) : null}\n <FieldIdContext.Provider value={label ? id : undefined}>\n <FieldDescribedByContext.Provider value={describedBy}>{children}</FieldDescribedByContext.Provider>\n </FieldIdContext.Provider>\n {error ? (\n <p id={errId} role=\"alert\" className=\"text-kit-xs leading-4 text-kit-danger-fg\">\n {error}\n </p>\n ) : null}\n </div>\n );\n}\n\n/** The ⓘ next to a label: longer help in a tooltip, also read by screen readers through aria-describedby (D39). */\nexport function HelpMore({ id, label, children }: { id?: string; label?: string; children: React.ReactNode }) {\n return (\n <HintTooltip content={<span className=\"block max-w-[260px] whitespace-normal font-normal leading-4\">{children}</span>}>\n <button\n type=\"button\"\n aria-label={label ? `About ${label}` : \"More about this field\"}\n className=\"hit-area inline-flex size-4 shrink-0 items-center justify-center rounded-kit-sm text-kit-fg-4 [--hit-size:16px] hover:text-kit-fg-2\"\n >\n <IconInfoCircle className=\"size-3.5\" stroke={1.5} aria-hidden />\n <span id={id} className=\"sr-only\">\n {children}\n </span>\n </button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GAAA,uBAAC,QAAD;IAAU;IAAI,WAAU;IACrB;GACG,GAAA,KAAA,GAAA,OAAA;;;;GACA,GAAA,IAAA,CAAA;;;;;;CACG,GAAA,KAAA,GAAA,OAAA;;;;;AAEjB"}
|
package/dist/ui/mode-bar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn } from "../lib/cn.js";
|
|
2
2
|
import { KIT_SCOPE } from "./surfaces.js";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
5
5
|
//#region src/ui/mode-bar.tsx
|
|
6
6
|
/**
|
|
7
7
|
* MODE BAR (D61 §3.7, shared with D58 view-as). One 36px strip that says "you are in a mode": an icon, a sentence and
|
|
@@ -14,12 +14,13 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
* If both apply, both show: view-as on top. Tokens only, both themes (D56).
|
|
15
15
|
* The strip sits in the app shell, outside any kit host, so its root carries the kit scope itself (like the portalled layers).
|
|
16
16
|
*/
|
|
17
|
+
var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/ui/mode-bar.tsx";
|
|
17
18
|
var TONE = {
|
|
18
19
|
info: "border-kit-info-line bg-kit-info-soft",
|
|
19
20
|
raised: "border-kit-line bg-kit-surface-raised"
|
|
20
21
|
};
|
|
21
22
|
var ModeBar = React.forwardRef(function ModeBar({ label, icon, tone = "info", align = "center", announce, className, children, ...rest }, ref) {
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
23
24
|
ref,
|
|
24
25
|
role: "region",
|
|
25
26
|
"aria-label": label,
|
|
@@ -28,36 +29,56 @@ var ModeBar = React.forwardRef(function ModeBar({ label, icon, tone = "info", al
|
|
|
28
29
|
className: cn("relative flex h-9 shrink-0 items-center gap-2 border-b px-4 text-kit-sm text-kit-fg", align === "center" ? "justify-center" : "justify-start", TONE[tone], className),
|
|
29
30
|
...rest,
|
|
30
31
|
children: [
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
32
33
|
"aria-live": "polite",
|
|
33
34
|
className: "sr-only",
|
|
34
35
|
children: announce ?? ""
|
|
35
|
-
}
|
|
36
|
-
|
|
36
|
+
}, void 0, false, {
|
|
37
|
+
fileName: _jsxFileName,
|
|
38
|
+
lineNumber: 54,
|
|
39
|
+
columnNumber: 7
|
|
40
|
+
}, this),
|
|
41
|
+
icon ? /* @__PURE__ */ jsxDEV("span", {
|
|
37
42
|
"aria-hidden": true,
|
|
38
43
|
className: "flex shrink-0 text-kit-fg-2 [&>svg]:size-4",
|
|
39
44
|
children: icon
|
|
40
|
-
}
|
|
45
|
+
}, void 0, false, {
|
|
46
|
+
fileName: _jsxFileName,
|
|
47
|
+
lineNumber: 55,
|
|
48
|
+
columnNumber: 15
|
|
49
|
+
}, this) : null,
|
|
41
50
|
children
|
|
42
51
|
]
|
|
43
|
-
}
|
|
52
|
+
}, void 0, true, {
|
|
53
|
+
fileName: _jsxFileName,
|
|
54
|
+
lineNumber: 40,
|
|
55
|
+
columnNumber: 5
|
|
56
|
+
}, this);
|
|
44
57
|
});
|
|
45
58
|
/** The quiet "·" between parts of a mode bar sentence. */
|
|
46
59
|
function ModeBarDot({ className }) {
|
|
47
|
-
return /* @__PURE__ */
|
|
60
|
+
return /* @__PURE__ */ jsxDEV("span", {
|
|
48
61
|
"aria-hidden": true,
|
|
49
62
|
className: cn("text-kit-fg-3", className),
|
|
50
63
|
children: "·"
|
|
51
|
-
}
|
|
64
|
+
}, void 0, false, {
|
|
65
|
+
fileName: _jsxFileName,
|
|
66
|
+
lineNumber: 63,
|
|
67
|
+
columnNumber: 10
|
|
68
|
+
}, this);
|
|
52
69
|
}
|
|
53
70
|
/** A text action in a mode bar ("Exit"): underlined, not a button chip. */
|
|
54
71
|
var ModeBarLink = React.forwardRef(function ModeBarLink({ className, ...rest }, ref) {
|
|
55
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ jsxDEV("button", {
|
|
56
73
|
ref,
|
|
57
74
|
type: "button",
|
|
58
75
|
className: cn("shrink-0 rounded-kit-sm px-1 font-medium text-kit-fg underline decoration-kit-fg-3 underline-offset-2 hover:decoration-kit-fg", className),
|
|
59
76
|
...rest
|
|
60
|
-
}
|
|
77
|
+
}, void 0, false, {
|
|
78
|
+
fileName: _jsxFileName,
|
|
79
|
+
lineNumber: 72,
|
|
80
|
+
columnNumber: 5
|
|
81
|
+
}, this);
|
|
61
82
|
});
|
|
62
83
|
//#endregion
|
|
63
84
|
export { ModeBar, ModeBarDot, ModeBarLink };
|
package/dist/ui/mode-bar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mode-bar.js","names":[],"sources":["../../src/ui/mode-bar.tsx"],"sourcesContent":["/**\n * MODE BAR (D61 §3.7, shared with D58 view-as). One 36px strip that says \"you are in a mode\": an icon, a sentence and\n * its actions, with a polite live-region announcement. The primitive is shared; the placement is not:\n *\n * - View as (D58): app-wide, above the top bar (it changes who you are). `tone=\"info\"`, centred. Esc does not exit.\n * - Revision preview (D61): inside the editor, under its header (it changes what you are looking at).\n * `tone=\"raised\"`, start-aligned. Esc goes back to current (the host wires it).\n *\n * If both apply, both show: view-as on top. Tokens only, both themes (D56).\n * The strip sits in the app shell, outside any kit host, so its root carries the kit scope itself (like the portalled layers).\n */\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { KIT_SCOPE } from \"./surfaces\";\n\nexport type ModeBarTone = \"info\" | \"raised\";\n\nconst TONE: Record<ModeBarTone, string> = {\n info: \"border-kit-info-line bg-kit-info-soft\",\n raised: \"border-kit-line bg-kit-surface-raised\",\n};\n\nexport interface ModeBarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"role\"> {\n /** the region's accessible name (\"View as\", \"Version preview\") */\n label: string;\n /** a 16px glyph, decorative */\n icon?: React.ReactNode;\n tone?: ModeBarTone;\n /** \"center\" (view-as) or \"start\" (revision preview) */\n align?: \"center\" | \"start\";\n /** polite announcement, read once when it changes */\n announce?: string;\n}\n\nexport const ModeBar = React.forwardRef<HTMLDivElement, ModeBarProps>(function ModeBar(\n { label, icon, tone = \"info\", align = \"center\", announce, className, children, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n role=\"region\"\n aria-label={label}\n data-mode-bar={tone}\n {...KIT_SCOPE}\n className={cn(\n \"relative flex h-9 shrink-0 items-center gap-2 border-b px-4 text-kit-sm text-kit-fg\",\n align === \"center\" ? \"justify-center\" : \"justify-start\",\n TONE[tone],\n className,\n )}\n {...rest}\n >\n <span aria-live=\"polite\" className=\"sr-only\">{announce ?? \"\"}</span>\n {icon ? <span aria-hidden className=\"flex shrink-0 text-kit-fg-2 [&>svg]:size-4\">{icon}</span> : null}\n {children}\n </div>\n );\n});\n\n/** The quiet \"·\" between parts of a mode bar sentence. */\nexport function ModeBarDot({ className }: { className?: string }) {\n return <span aria-hidden className={cn(\"text-kit-fg-3\", className)}>·</span>;\n}\n\n/** A text action in a mode bar (\"Exit\"): underlined, not a button chip. */\nexport const ModeBarLink = React.forwardRef<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>(function ModeBarLink(\n { className, ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type=\"button\"\n className={cn(\n \"shrink-0 rounded-kit-sm px-1 font-medium text-kit-fg underline decoration-kit-fg-3 underline-offset-2 hover:decoration-kit-fg\",\n className,\n )}\n {...rest}\n />\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mode-bar.js","names":[],"sources":["../../src/ui/mode-bar.tsx"],"sourcesContent":["/**\n * MODE BAR (D61 §3.7, shared with D58 view-as). One 36px strip that says \"you are in a mode\": an icon, a sentence and\n * its actions, with a polite live-region announcement. The primitive is shared; the placement is not:\n *\n * - View as (D58): app-wide, above the top bar (it changes who you are). `tone=\"info\"`, centred. Esc does not exit.\n * - Revision preview (D61): inside the editor, under its header (it changes what you are looking at).\n * `tone=\"raised\"`, start-aligned. Esc goes back to current (the host wires it).\n *\n * If both apply, both show: view-as on top. Tokens only, both themes (D56).\n * The strip sits in the app shell, outside any kit host, so its root carries the kit scope itself (like the portalled layers).\n */\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { KIT_SCOPE } from \"./surfaces\";\n\nexport type ModeBarTone = \"info\" | \"raised\";\n\nconst TONE: Record<ModeBarTone, string> = {\n info: \"border-kit-info-line bg-kit-info-soft\",\n raised: \"border-kit-line bg-kit-surface-raised\",\n};\n\nexport interface ModeBarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"role\"> {\n /** the region's accessible name (\"View as\", \"Version preview\") */\n label: string;\n /** a 16px glyph, decorative */\n icon?: React.ReactNode;\n tone?: ModeBarTone;\n /** \"center\" (view-as) or \"start\" (revision preview) */\n align?: \"center\" | \"start\";\n /** polite announcement, read once when it changes */\n announce?: string;\n}\n\nexport const ModeBar = React.forwardRef<HTMLDivElement, ModeBarProps>(function ModeBar(\n { label, icon, tone = \"info\", align = \"center\", announce, className, children, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n role=\"region\"\n aria-label={label}\n data-mode-bar={tone}\n {...KIT_SCOPE}\n className={cn(\n \"relative flex h-9 shrink-0 items-center gap-2 border-b px-4 text-kit-sm text-kit-fg\",\n align === \"center\" ? \"justify-center\" : \"justify-start\",\n TONE[tone],\n className,\n )}\n {...rest}\n >\n <span aria-live=\"polite\" className=\"sr-only\">{announce ?? \"\"}</span>\n {icon ? <span aria-hidden className=\"flex shrink-0 text-kit-fg-2 [&>svg]:size-4\">{icon}</span> : null}\n {children}\n </div>\n );\n});\n\n/** The quiet \"·\" between parts of a mode bar sentence. */\nexport function ModeBarDot({ className }: { className?: string }) {\n return <span aria-hidden className={cn(\"text-kit-fg-3\", className)}>·</span>;\n}\n\n/** A text action in a mode bar (\"Exit\"): underlined, not a button chip. */\nexport const ModeBarLink = React.forwardRef<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>(function ModeBarLink(\n { className, ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type=\"button\"\n className={cn(\n \"shrink-0 rounded-kit-sm px-1 font-medium text-kit-fg underline decoration-kit-fg-3 underline-offset-2 hover:decoration-kit-fg\",\n className,\n )}\n {...rest}\n />\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,IAAM,OAAoC;CACxC,MAAM;CACN,QAAQ;AACV;AAcA,IAAa,UAAU,MAAM,WAAyC,SAAS,QAC7E,EAAE,OAAO,MAAM,OAAO,QAAQ,QAAQ,UAAU,UAAU,WAAW,UAAU,GAAG,QAClF,KACA;CACA,OACE,uBAAC,OAAD;EACO;EACL,MAAK;EACL,cAAY;EACZ,iBAAe;EACf,GAAI;EACJ,WAAW,GACT,uFACA,UAAU,WAAW,mBAAmB,iBACxC,KAAK,OACL,SACF;EACA,GAAI;EAZN,UAAA;GAcE,uBAAC,QAAD;IAAM,aAAU;IAAS,WAAU;IAAW,UAAA,YAAY;GAAS,GAAA,KAAA,GAAA,OAAA;;;;;GAClE,OAAO,uBAAC,QAAD;IAAM,eAAA;IAAY,WAAU;IAA8C,UAAA;GAAW,GAAA,KAAA,GAAA,OAAA;;;;GAAI,GAAA,IAAA,IAAA;GAChG;EACE;;;;;;AAET,CAAC;;AAGD,SAAgB,WAAW,EAAE,aAAqC;CAChE,OAAO,uBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,GAAG,iBAAiB,SAAS;EAAG,UAAA;CAAO,GAAA,KAAA,GAAA,OAAA;;;;;AAC7E;;AAGA,IAAa,cAAc,MAAM,WAA6E,SAAS,YACrH,EAAE,WAAW,GAAG,QAChB,KACA;CACA,OACE,uBAAC,UAAD;EACO;EACL,MAAK;EACL,WAAW,GACT,iIACA,SACF;EACA,GAAI;CACL,GAAA,KAAA,GAAA,OAAA;;;;;AAEL,CAAC"}
|