@eifi1/ui-kit 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -25
- package/dist/chart.d.ts +11 -8
- package/dist/components/amount-input.d.ts +28 -8
- package/dist/components/amount-input.js +3 -1
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +21 -0
- package/dist/components/autocomplete.js +128 -103
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-group.d.ts +11 -8
- package/dist/components/calculator.d.ts +11 -8
- package/dist/components/column-mapper.d.ts +182 -0
- package/dist/components/column-mapper.js +375 -0
- package/dist/components/column-mapper.js.map +1 -0
- package/dist/components/combobox-core.d.ts +39 -2
- package/dist/components/combobox-core.js +29 -6
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +80 -2
- package/dist/components/combobox.js +448 -311
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +11 -8
- package/dist/components/confirm-dialog.js +7 -8
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.d.ts +8 -5
- package/dist/components/country-select.d.ts +50 -7
- package/dist/components/country-select.js +65 -9
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +11 -8
- package/dist/components/danger-confirm.js +13 -3
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/date-picker.d.ts +41 -0
- package/dist/components/date-picker.js +269 -8
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +35 -1
- package/dist/components/entity-combobox.js +148 -112
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +11 -8
- package/dist/components/field-parts.d.ts +116 -6
- package/dist/components/field-parts.js +84 -0
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-strip.d.ts +105 -0
- package/dist/components/field-strip.js +46 -0
- package/dist/components/field-strip.js.map +1 -0
- package/dist/components/file-button.d.ts +11 -8
- package/dist/components/file-dropzone.d.ts +11 -8
- package/dist/components/form-actions.d.ts +10 -7
- package/dist/components/form-actions.js +8 -2
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/iban-input.d.ts +11 -8
- package/dist/components/icon-picker.d.ts +10 -1
- package/dist/components/icon-picker.js +12 -4
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/language-select.d.ts +11 -8
- package/dist/components/money-field.d.ts +14 -8
- package/dist/components/money-field.js.map +1 -1
- package/dist/components/month-picker.js +2 -1
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +26 -1
- package/dist/components/multi-entity-combobox.js +143 -102
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/number-field.d.ts +11 -8
- package/dist/components/number-input.d.ts +11 -8
- package/dist/components/numpad-sheet.d.ts +11 -8
- package/dist/components/phone-input.d.ts +11 -8
- package/dist/components/reauth-dialog.d.ts +2 -2
- package/dist/components/reauth-dialog.js +6 -8
- package/dist/components/reauth-dialog.js.map +1 -1
- package/dist/components/series-chart.d.ts +11 -8
- package/dist/components/settings-fields.d.ts +11 -8
- package/dist/components/share-card.d.ts +10 -7
- package/dist/components/swatch-picker.d.ts +17 -1
- package/dist/components/swatch-picker.js +10 -4
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/text-link.d.ts +10 -7
- package/dist/components/tile-radio.d.ts +20 -0
- package/dist/components/tile-radio.js +25 -8
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.d.ts +11 -8
- package/dist/components/toggle-group.js +2 -2
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/trigger-aria.d.ts +3 -0
- package/dist/components/trigger-aria.js +3 -1
- package/dist/components/trigger-aria.js.map +1 -1
- package/dist/components/ui.d.ts +8 -5
- package/dist/components/ui.js +5 -11
- package/dist/components/ui.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +1 -1
- package/dist/feedback/feedback-attachment.js +156 -56
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +1 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +3 -2
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +68 -287
- package/dist/feedback/feedback-thread.js +8 -1
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/{kit-labels-R8mIAc9N.d.ts → feedback-BxeQVzwq.d.ts} +405 -22
- package/dist/{feedback-attachment-NhUm7Zga.d.ts → feedback-attachment-fGAzZPf0.d.ts} +112 -10
- package/dist/feedback.d.ts +66 -2
- package/dist/hooks/use-file-drop.d.ts +11 -8
- package/dist/i18n/defaults.d.ts +11 -8
- package/dist/i18n/defaults.js +3 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +11 -8
- package/dist/i18n/german.js +36 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +7 -4
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +11 -8
- package/dist/i18n/locales/de-CH.d.ts +11 -8
- package/dist/i18n/locales/en.d.ts +11 -8
- package/dist/i18n/locales/en.js +7 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +11 -8
- package/dist/i18n/locales/es.js +37 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +11 -8
- package/dist/i18n/locales/fr.js +36 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +11 -8
- package/dist/i18n/locales/hu.js +38 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +11 -8
- package/dist/i18n/locales/it.js +37 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +11 -8
- package/dist/i18n/locales/zh.js +34 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +11 -8
- package/dist/i18n/review.js +20 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/column-mapping.d.ts +81 -0
- package/dist/lib/column-mapping.js +108 -0
- package/dist/lib/column-mapping.js.map +1 -0
- package/dist/lib/table-text.d.ts +109 -1
- package/dist/lib/table-text.js +122 -1
- package/dist/lib/table-text.js.map +1 -1
- package/dist/rhf/fields.d.ts +89 -11
- package/dist/rhf/fields.js +124 -0
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form.d.ts +11 -8
- package/dist/rhf.d.ts +12 -9
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +10 -7
- package/dist/shell/top-bar-brand.d.ts +11 -8
- package/dist/shell/topbar-action-menu.d.ts +36 -3
- package/dist/shell/topbar-action-menu.js +74 -33
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +10 -7
- package/dist/table-text.d.ts +1 -1
- package/dist/wizard/stepper-nav.d.ts +41 -10
- package/dist/wizard/stepper-nav.js +4 -0
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard.d.ts +11 -8
- package/package.json +1 -1
- package/src/components/amount-input.tsx +20 -1
- package/src/components/autocomplete.tsx +172 -111
- package/src/components/column-mapper.tsx +666 -0
- package/src/components/combobox-core.tsx +82 -9
- package/src/components/combobox.tsx +614 -332
- package/src/components/confirm-dialog.tsx +12 -8
- package/src/components/country-select.tsx +135 -22
- package/src/components/danger-confirm.tsx +91 -12
- package/src/components/date-picker.tsx +423 -10
- package/src/components/entity-combobox.tsx +217 -126
- package/src/components/field-parts.tsx +224 -5
- package/src/components/field-strip.tsx +149 -0
- package/src/components/form-actions.tsx +32 -4
- package/src/components/icon-picker.tsx +23 -4
- package/src/components/money-field.tsx +3 -0
- package/src/components/month-picker.tsx +2 -1
- package/src/components/multi-entity-combobox.tsx +207 -120
- package/src/components/reauth-dialog.tsx +17 -18
- package/src/components/swatch-picker.tsx +29 -5
- package/src/components/tile-radio.tsx +74 -13
- package/src/components/toggle-group.tsx +2 -2
- package/src/components/trigger-aria.ts +5 -0
- package/src/components/ui.tsx +7 -33
- package/src/feedback/feedback-attachment.tsx +308 -61
- package/src/feedback/feedback-dialog.tsx +7 -3
- package/src/feedback/feedback-inbox.tsx +3 -2
- package/src/feedback/feedback-thread.tsx +47 -4
- package/src/i18n/defaults.ts +2 -0
- package/src/i18n/german.ts +42 -0
- package/src/i18n/kit-labels.tsx +4 -0
- package/src/i18n/locales/en.ts +27 -5
- package/src/i18n/locales/es.ts +41 -0
- package/src/i18n/locales/fr.ts +42 -0
- package/src/i18n/locales/hu.ts +37 -0
- package/src/i18n/locales/it.ts +41 -0
- package/src/i18n/locales/zh.ts +32 -0
- package/src/i18n/review.ts +19 -0
- package/src/index.ts +18 -0
- package/src/lib/column-mapping.ts +234 -0
- package/src/lib/table-text.ts +271 -0
- package/src/rhf/fields.tsx +254 -0
- package/src/rhf.ts +2 -1
- package/src/shell/topbar-action-menu.tsx +134 -38
- package/src/wizard/stepper-nav.tsx +35 -1
- package/dist/components/field-anatomy.d.ts +0 -95
- package/dist/components/field-anatomy.js +0 -84
- package/dist/components/field-anatomy.js.map +0 -1
- package/src/components/field-anatomy.tsx +0 -190
|
@@ -6,47 +6,64 @@ import { cn } from "../lib/cn.js";
|
|
|
6
6
|
import { FieldChevron, FieldLabel, FIELD_TRIGGER, FIELD_FLOATING_PAD, FIELD_INVALID } from "./ui.js";
|
|
7
7
|
import {
|
|
8
8
|
ComboboxPanel,
|
|
9
|
+
endHintRowProps,
|
|
10
|
+
offersCreate,
|
|
9
11
|
useComboboxCore,
|
|
10
12
|
useComboboxFieldError
|
|
11
13
|
} from "./combobox-core.js";
|
|
12
14
|
import { DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, useKitLabels } from "../i18n/kit-labels.js";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
15
|
+
import {
|
|
16
|
+
EndHintRow,
|
|
17
|
+
FieldCaption,
|
|
18
|
+
LABEL_IN_ROW,
|
|
19
|
+
LockedReason,
|
|
20
|
+
StaticLabelRow,
|
|
21
|
+
useFieldHint,
|
|
22
|
+
useLockReason
|
|
23
|
+
} from "./field-parts.js";
|
|
24
|
+
import { mergeDescribedBy } from "./choice-parts.js";
|
|
25
|
+
import { useCommitReason } from "./write-lock.js";
|
|
26
|
+
function EntityCombobox(props) {
|
|
27
|
+
const {
|
|
28
|
+
value,
|
|
29
|
+
onChange,
|
|
30
|
+
clearValue = null,
|
|
31
|
+
options,
|
|
32
|
+
loadOptions,
|
|
33
|
+
loading,
|
|
34
|
+
label,
|
|
35
|
+
placeholder,
|
|
36
|
+
searchPlaceholder,
|
|
37
|
+
emptyLabel,
|
|
38
|
+
clearable,
|
|
39
|
+
clearLabel,
|
|
40
|
+
closeLabel,
|
|
41
|
+
disabled,
|
|
42
|
+
disabledReason,
|
|
43
|
+
commit,
|
|
44
|
+
onCreate,
|
|
45
|
+
createLabel,
|
|
46
|
+
createEmptyLabel,
|
|
47
|
+
createCommit,
|
|
48
|
+
className,
|
|
49
|
+
invalid,
|
|
50
|
+
error,
|
|
51
|
+
hint,
|
|
52
|
+
filter,
|
|
53
|
+
minChars,
|
|
54
|
+
debounceMs,
|
|
55
|
+
loadErrorLabel,
|
|
56
|
+
"aria-label": ariaLabel,
|
|
57
|
+
// The control's own wiring, taken off `rest` so it lands on the TRIGGER rather than
|
|
58
|
+
// the wrapper — see MultiEntityCombobox: `Field`'s render-prop spreads `{ id,
|
|
59
|
+
// aria-describedby, aria-invalid, aria-required }`, and on the role-less wrapper
|
|
60
|
+
// div the label's `htmlFor` named nothing and the hint described nothing.
|
|
61
|
+
id,
|
|
62
|
+
"aria-describedby": ariaDescribedBy,
|
|
63
|
+
"aria-invalid": ariaInvalid,
|
|
64
|
+
"aria-required": ariaRequired,
|
|
65
|
+
...rest
|
|
66
|
+
} = props;
|
|
50
67
|
const core = useComboboxCore({
|
|
51
68
|
options,
|
|
52
69
|
loadOptions,
|
|
@@ -69,14 +86,25 @@ function EntityCombobox({
|
|
|
69
86
|
});
|
|
70
87
|
const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
|
|
71
88
|
const { open, results, resolve, setOpen, rememberOption, query, triggerRef } = core;
|
|
89
|
+
const lock = useLockReason(commit, disabledReason);
|
|
90
|
+
const inert = lock.locked || Boolean(disabled);
|
|
91
|
+
if (lock.locked && open) setOpen(false);
|
|
92
|
+
const createReason = useCommitReason(createCommit, void 0);
|
|
72
93
|
const listboxId = useId();
|
|
73
94
|
const chosen = value == null || value === clearValue ? null : value;
|
|
74
95
|
const selectedOption = chosen == null ? null : resolve(chosen);
|
|
75
96
|
const q = query.trim();
|
|
76
|
-
const showCreate =
|
|
77
|
-
|
|
97
|
+
const showCreate = offersCreate(
|
|
98
|
+
onCreate,
|
|
99
|
+
q,
|
|
100
|
+
results.map((o) => o.label),
|
|
101
|
+
createEmptyLabel
|
|
102
|
+
);
|
|
103
|
+
const showClear = Boolean(clearable && chosen != null && !inert);
|
|
78
104
|
const triggerText = selectedOption?.label ?? placeholder ?? "";
|
|
105
|
+
const withLock = (trigger) => lock.locked ? /* @__PURE__ */ jsx(LockedReason, { lock, className: "block", children: trigger }) : trigger;
|
|
79
106
|
const choose = (o) => {
|
|
107
|
+
if (lock.locked) return;
|
|
80
108
|
rememberOption(o);
|
|
81
109
|
onChange(o.value);
|
|
82
110
|
core.closeToTrigger();
|
|
@@ -88,78 +116,84 @@ function EntityCombobox({
|
|
|
88
116
|
// handlers that open the panel cannot be clobbered from outside.
|
|
89
117
|
/* @__PURE__ */ jsxs("div", { ...rest, className: cn("relative", className), children: [
|
|
90
118
|
label !== void 0 && hintParts.labelHint === void 0 && /* @__PURE__ */ jsx(FieldLabel, { children: label }),
|
|
91
|
-
/* @__PURE__ */ jsx(EndHintRow, { hint
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
119
|
+
/* @__PURE__ */ jsx(EndHintRow, { ...endHintRowProps("hint" in props, label !== void 0, hintParts.labelHint), children: withLock(
|
|
120
|
+
/* @__PURE__ */ jsxs(
|
|
121
|
+
"button",
|
|
122
|
+
{
|
|
123
|
+
ref: triggerRef,
|
|
124
|
+
id,
|
|
125
|
+
type: "button",
|
|
126
|
+
role: "combobox",
|
|
127
|
+
"aria-expanded": open,
|
|
128
|
+
"aria-controls": listboxId,
|
|
129
|
+
"aria-haspopup": "listbox",
|
|
130
|
+
"aria-label": ariaLabel ?? (typeof label === "string" ? common.fieldValue(label, triggerText) : void 0),
|
|
131
|
+
disabled: lock.locked ? void 0 : disabled,
|
|
132
|
+
"aria-disabled": lock.locked || void 0,
|
|
133
|
+
"aria-invalid": field.isInvalid || void 0,
|
|
134
|
+
"aria-describedby": mergeDescribedBy(field.describedBy, lock.locked && lock.reasonId),
|
|
135
|
+
"aria-required": ariaRequired,
|
|
136
|
+
onClick: () => !inert && setOpen((o) => !o),
|
|
137
|
+
onKeyDown: (e) => {
|
|
138
|
+
if (inert) return;
|
|
139
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
setOpen(true);
|
|
142
|
+
} else if (showClear && !open && (e.key === "Delete" || e.key === "Backspace")) {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
onChange(clearValue);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
className: cn(
|
|
148
|
+
FIELD_TRIGGER,
|
|
149
|
+
"pe-9",
|
|
150
|
+
label !== void 0 && FIELD_FLOATING_PAD,
|
|
151
|
+
inert && "cursor-not-allowed opacity-50",
|
|
152
|
+
field.isInvalid && FIELD_INVALID
|
|
153
|
+
),
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
156
|
+
selectedOption?.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: selectedOption.icon }),
|
|
157
|
+
/* @__PURE__ */ jsx(
|
|
158
|
+
"span",
|
|
159
|
+
{
|
|
160
|
+
className: cn(
|
|
161
|
+
"truncate",
|
|
162
|
+
// A chosen value is the field's VALUE, so it is set in the same ink an
|
|
163
|
+
// <input>'s value is — FIELD_BASE's own text colour, inherited rather
|
|
164
|
+
// than restated (Keksdose dev#477). It used to be one notch lighter
|
|
165
|
+
// than the typeahead fields beside it, which is visible when a picker
|
|
166
|
+
// and a text field share a form row. Nothing selected keeps the
|
|
167
|
+
// placeholder tone (`--text-placeholder`), which every field here
|
|
168
|
+
// agrees on.
|
|
169
|
+
!selectedOption && "text-[var(--text-placeholder)]"
|
|
170
|
+
),
|
|
171
|
+
children: selectedOption?.label ?? placeholder ?? ""
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
] }),
|
|
175
|
+
showClear ? (
|
|
176
|
+
/* eslint-disable-next-line jsx-a11y/click-events-have-key-events -- tabIndex -1 inside
|
|
177
|
+
the trigger <button>, so it never holds focus and a key handler here could
|
|
178
|
+
never fire; the keys go to the trigger, where Delete and Backspace clear. */
|
|
179
|
+
/* @__PURE__ */ jsx(
|
|
180
|
+
"span",
|
|
181
|
+
{
|
|
182
|
+
role: "button",
|
|
183
|
+
tabIndex: -1,
|
|
184
|
+
"aria-label": labels.clear,
|
|
185
|
+
onClick: (e) => {
|
|
186
|
+
e.stopPropagation();
|
|
187
|
+
onChange(clearValue);
|
|
188
|
+
},
|
|
189
|
+
className: "absolute end-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-[var(--text-placeholder)] hover:text-[var(--text-secondary)]",
|
|
190
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
) : /* @__PURE__ */ jsx(FieldChevron, {})
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
)
|
|
163
197
|
) }),
|
|
164
198
|
label !== void 0 && hintParts.labelHint !== void 0 && /* @__PURE__ */ jsx(StaticLabelRow, { hint: hintParts.labelHint, children: /* @__PURE__ */ jsx(FieldLabel, { className: LABEL_IN_ROW, children: label }) }),
|
|
165
199
|
/* @__PURE__ */ jsx(
|
|
@@ -176,10 +210,12 @@ function EntityCombobox({
|
|
|
176
210
|
onChoose: choose,
|
|
177
211
|
showCreate,
|
|
178
212
|
onCreate: () => {
|
|
213
|
+
if (lock.locked) return;
|
|
179
214
|
onCreate?.(q);
|
|
180
215
|
core.closeToTrigger();
|
|
181
216
|
},
|
|
182
|
-
createContent: labels.create(q)
|
|
217
|
+
createContent: q ? labels.create(q) : createEmptyLabel,
|
|
218
|
+
createDisabledReason: createReason
|
|
183
219
|
}
|
|
184
220
|
),
|
|
185
221
|
/* @__PURE__ */ jsx(FieldCaption, { parts: hintParts }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/entity-combobox.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { FieldChevron, FieldLabel, FIELD_TRIGGER, FIELD_FLOATING_PAD, FIELD_INVALID } from \"./ui\";\nimport {\n ComboboxPanel,\n useComboboxCore,\n useComboboxFieldError,\n type ComboClearValue,\n type ComboOption,\n} from \"./combobox-core\";\nimport { DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\nimport { EndHintRow, FieldCaption, LABEL_IN_ROW, StaticLabelRow, useFieldHint } from \"./field-parts\";\n\nexport type { ComboClearValue, ComboOption } from \"./combobox-core\";\n\n/** `onChange` is the kit's — \"a selection was made\", carrying values — rather\n * than the div's form event, so the DOM's spelling of it is omitted. */\nexport interface EntityComboboxProps<V extends string | number, C extends ComboClearValue = null>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {\n /** Selected id; `null`, `undefined` or `clearValue` when nothing is selected. */\n value: V | C | null | undefined;\n /** Selecting an option emits its value; the clear button emits `clearValue`. */\n onChange: (value: V | C) => void;\n /**\n * What the clear button emits. Default `null`. Pass `\"\"` for a form whose schema\n * wants an empty string for \"no choice\" (a zod `z.string()` field), rather than\n * mapping `null` in every `onChange` — the type of `onChange` follows it, so the\n * mapping cannot be forgotten on one field and not another. The picker also reads\n * the value back as empty, so `value=\"\"` shows the placeholder and no \"×\".\n * See {@link ComboClearValue} for why the choice is closed.\n */\n clearValue?: C;\n /** Already-loaded options (client-side filtered). Also used to resolve the\n * trigger label for the current `value`. */\n options?: ComboOption<V>[];\n /** Async option source, debounced and called on open + as the query changes\n * (at `minChars` and up). Stale responses are ignored; a rejection empties the\n * list and says `loadErrorLabel` instead of leaving the last query's rows up. When set, `options` is used only for label\n * resolution, not as the result list. */\n loadOptions?: (query: string) => Promise<ComboOption<V>[]>;\n /** External loading flag (OR-ed with the internal async state). */\n loading?: boolean;\n label?: ReactNode;\n placeholder?: string;\n searchPlaceholder?: string;\n emptyLabel?: string;\n clearable?: boolean;\n clearLabel?: string;\n /** The phone sheet's close button. Its own prop rather than a reuse of\n * `clearLabel`: \"clear the selection\" and \"close this screen\" are different\n * actions, and on a full-screen sheet the close button is the only way out —\n * so it is the one control here that MUST be in the reader's language. */\n closeLabel?: string;\n disabled?: boolean;\n /** When set, a \"create\" row appears for a non-empty query with no exact match. */\n onCreate?: (query: string) => void;\n createLabel?: (query: string) => string;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /** What is wrong with the value, as {@link Input}'s `error`: rendered under the\n * field, on the trigger's `aria-describedby`, and implies `invalid`. */\n error?: ReactNode;\n /**\n * Standing advice — {@link Combobox}'s `hint`, so the pickers read like every other\n * field (keksdose K4): plain TEXT is a caption under the field on the trigger's\n * `aria-describedby`, before any error; a {@link FieldHint} \"?\" rides the label line,\n * or with no label sits at the trigger's end edge, outside the box.\n */\n hint?: ReactNode;\n /** Narrow `options` client-side by the query. Default `true`; `false` shows them\n * as given (a server-ranked list). */\n filter?: boolean;\n /** Offer nothing, and call no `loadOptions`, below this many characters. Default\n * `0`, i.e. the list loads as the panel opens. */\n minChars?: number;\n /** `loadOptions` debounce. Default 150 ms. */\n debounceMs?: number;\n /** Shown when `loadOptions` rejects. Default: `combobox.loadError`. */\n loadErrorLabel?: string;\n}\n\n/**\n * An id-keyed, searchable entity picker: a field-styled trigger showing the\n * selected item's label, and a portalled dropdown of `{label, sublabel, icon}`\n * options — loaded up front via `options` or lazily via `loadOptions`. Built on\n * the shared field/anchor/dismiss/search primitives (no cmdk/Radix). For picking\n * several entities use {@link MultiEntityCombobox}.\n */\nexport function EntityCombobox<V extends string | number, C extends ComboClearValue = null>({\n value,\n onChange,\n clearValue = null as C,\n options,\n loadOptions,\n loading,\n label,\n placeholder,\n searchPlaceholder,\n emptyLabel,\n clearable,\n clearLabel,\n closeLabel,\n disabled,\n onCreate,\n createLabel,\n className,\n invalid,\n error,\n hint,\n filter,\n minChars,\n debounceMs,\n loadErrorLabel,\n \"aria-label\": ariaLabel,\n // The control's own wiring, taken off `rest` so it lands on the TRIGGER rather than\n // the wrapper — see MultiEntityCombobox: `Field`'s render-prop spreads `{ id,\n // aria-describedby, aria-invalid, aria-required }`, and on the role-less wrapper\n // div the label's `htmlFor` named nothing and the hint described nothing.\n id,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n \"aria-required\": ariaRequired,\n ...rest\n}: EntityComboboxProps<V, C>) {\n const core = useComboboxCore<V>({\n options,\n loadOptions,\n loading,\n filter,\n minChars,\n debounceMs,\n });\n const hintParts = useFieldHint(hint, ariaDescribedBy);\n const field = useComboboxFieldError(\n error,\n invalid || ariaInvalid === true || ariaInvalid === \"true\",\n hintParts.describedBy,\n );\n // The props are the per-instance overrides, the provider the app-wide ones; a\n // prop left `undefined` falls through to the provider rather than masking it.\n const labels = useKitLabels(\"combobox\", DEFAULT_COMBOBOX_LABELS, {\n search: searchPlaceholder,\n noResults: emptyLabel,\n clear: clearLabel,\n create: createLabel,\n });\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const { open, results, resolve, setOpen, rememberOption, query, triggerRef } = core;\n // One id per instance, generated here rather than in the core: `aria-controls` on\n // the trigger has to name the list while the list is still closed, so the id\n // belongs to whoever renders both ends of it.\n const listboxId = useId();\n\n // The clear value is \"nothing selected\" too, whichever one the caller picked.\n const chosen: V | null = value == null || value === clearValue ? null : (value as V);\n const selectedOption = chosen == null ? null : resolve(chosen);\n const q = query.trim();\n const showCreate =\n Boolean(onCreate) && q.length > 0 && !results.some((o) => o.label.toLowerCase() === q.toLowerCase());\n const showClear = Boolean(clearable && chosen != null && !disabled);\n /** What the closed control is showing — the second half of its accessible name. */\n const triggerText = selectedOption?.label ?? placeholder ?? \"\";\n\n const choose = (o: ComboOption<V>) => {\n rememberOption(o);\n onChange(o.value);\n // Back to the trigger, not to <body>: the panel that held focus is about to\n // unmount, and a keyboard user who just answered this field should be standing\n // on it, ready to Tab to the next one.\n core.closeToTrigger();\n };\n\n return (\n // `rest` dresses the wrapper, which has no role; the accessible NAME — and the\n // id, description, invalid and required state above — go on the trigger, which\n // has one. Spread FIRST so the trigger's ARIA and the\n // handlers that open the panel cannot be clobbered from outside.\n <div {...rest} className={cn(\"relative\", className)}>\n {label !== undefined && hintParts.labelHint === undefined && <FieldLabel>{label}</FieldLabel>}\n <EndHintRow hint={label === undefined ? hintParts.labelHint : undefined}>\n <button\n ref={triggerRef}\n id={id}\n type=\"button\"\n // A combobox, not a button. The distinction is not pedantry: this control\n // carried `aria-invalid`, which `button` does not support, so a required\n // field left empty painted a rose border and told a reader nothing at all —\n // and ESLint flagged it as exactly that (`role-supports-aria-props`). The\n // fix the audit asked for is the role that describes what this IS: a closed\n // choice that expands into the list named below. `combobox` supports\n // `aria-invalid`, so the border and the announcement finally agree.\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n // The label is a floating <span>, not a <label for>, so without this the\n // trigger's accessible name is whatever value happens to be selected —\n // \"Checking\" with nothing saying it is the account. The label AND the\n // value, because `aria-label` replaces the content rather than adding to\n // it, and a control that announces only its name has lost the answer.\n // A caller's own name wins over the composition: two fields labelled\n // \"Account\" on a transfer form are the from and the to, and only the\n // caller knows which is which.\n aria-label={\n ariaLabel ??\n (typeof label === \"string\" ? common.fieldValue(label, triggerText) : undefined)\n }\n disabled={disabled}\n aria-invalid={field.isInvalid || undefined}\n aria-describedby={field.describedBy}\n aria-required={ariaRequired}\n onClick={() => !disabled && setOpen((o) => !o)}\n // Down/Up opens the list from the closed trigger, per the APG. Enter and\n // Space already do it through the button's own click.\n onKeyDown={(e) => {\n if (disabled) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n setOpen(true);\n }\n }}\n className={cn(\n FIELD_TRIGGER,\n \"pe-9\",\n label !== undefined && FIELD_FLOATING_PAD,\n disabled && \"cursor-not-allowed opacity-50\",\n field.isInvalid && FIELD_INVALID,\n )}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {selectedOption?.icon && <span className=\"shrink-0\">{selectedOption.icon}</span>}\n <span\n className={cn(\n \"truncate\",\n // A chosen value is the field's VALUE, so it is set in the same ink an\n // <input>'s value is — FIELD_BASE's own text colour, inherited rather\n // than restated (Keksdose dev#477). It used to be one notch lighter\n // than the typeahead fields beside it, which is visible when a picker\n // and a text field share a form row. Nothing selected keeps the\n // placeholder tone (`--text-placeholder`), which every field here\n // agrees on.\n !selectedOption && \"text-[var(--text-placeholder)]\",\n )}\n >\n {selectedOption?.label ?? placeholder ?? \"\"}\n </span>\n </span>\n {showClear ? (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events -- tabIndex -1 inside\n the trigger <button>, so it never holds focus and a key handler here could\n never fire; the keys go to the trigger. A pointer shortcut only. */\n <span\n role=\"button\"\n tabIndex={-1}\n aria-label={labels.clear}\n onClick={(e) => {\n e.stopPropagation();\n onChange(clearValue);\n }}\n className=\"absolute end-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-[var(--text-placeholder)] hover:text-[var(--text-secondary)]\"\n >\n <X className=\"size-4\" />\n </span>\n ) : (\n <FieldChevron />\n )}\n </button>\n </EndHintRow>\n {/* With a \"?\" the label shares the top strip with it — after the trigger, so the\n \"?\" follows the control in the tab order, as on Input and Select. */}\n {label !== undefined && hintParts.labelHint !== undefined && (\n <StaticLabelRow hint={hintParts.labelHint}>\n <FieldLabel className={LABEL_IN_ROW}>{label}</FieldLabel>\n </StaticLabelRow>\n )}\n <ComboboxPanel\n core={core}\n listboxId={listboxId}\n // On a phone the panel becomes a full-screen sheet, which needs the field's\n // own label to say what it is asking for (live #200).\n sheetTitle={label ?? placeholder}\n searchPlaceholder={labels.search}\n emptyLabel={labels.noResults}\n closeLabel={closeLabel}\n loadErrorLabel={loadErrorLabel}\n isSelected={(v) => v === value}\n onChoose={choose}\n showCreate={showCreate}\n onCreate={() => {\n onCreate?.(q);\n core.closeToTrigger();\n }}\n createContent={labels.create(q)}\n />\n <FieldCaption parts={hintParts} />\n {field.errorEl}\n </div>\n );\n}\n"],"mappings":";AAoLmE,cAmDzD,YAnDyD;AApLnE,SAAS,aAAa;AAEtB,SAAS,SAAS;AAClB,SAAS,UAAU;AACnB,SAAS,cAAc,YAAY,eAAe,oBAAoB,qBAAqB;AAC3F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,yBAAyB,uBAAuB,oBAAoB;AAC7E,SAAS,YAAY,cAAc,cAAc,gBAAgB,oBAAoB;AA6E9E,SAAS,eAA4E;AAAA,EAC1F;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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AA,kBACnB,SAAS,CAAC,MAAM;AACd,sBAAE,gBAAgB;AAClB,6BAAS,UAAU;AAAA,kBACrB;AAAA,kBACA,WAAU;AAAA,kBAEV,8BAAC,KAAE,WAAU,UAAS;AAAA;AAAA,cACxB;AAAA,gBAEA,oBAAC,gBAAa;AAAA;AAAA;AAAA,MAElB,GACF;AAAA,MAGC,UAAU,UAAa,UAAU,cAAc,UAC9C,oBAAC,kBAAe,MAAM,UAAU,WAC9B,8BAAC,cAAW,WAAW,cAAe,iBAAM,GAC9C;AAAA,MAEF;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UAGA,YAAY,SAAS;AAAA,UACrB,mBAAmB,OAAO;AAAA,UAC1B,YAAY,OAAO;AAAA,UACnB;AAAA,UACA;AAAA,UACA,YAAY,CAAC,MAAM,MAAM;AAAA,UACzB,UAAU;AAAA,UACV;AAAA,UACA,UAAU,MAAM;AACd,uBAAW,CAAC;AACZ,iBAAK,eAAe;AAAA,UACtB;AAAA,UACA,eAAe,OAAO,OAAO,CAAC;AAAA;AAAA,MAChC;AAAA,MACA,oBAAC,gBAAa,OAAO,WAAW;AAAA,MAC/B,MAAM;AAAA,OACT;AAAA;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/entity-combobox.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { FieldChevron, FieldLabel, FIELD_TRIGGER, FIELD_FLOATING_PAD, FIELD_INVALID } from \"./ui\";\nimport {\n ComboboxPanel,\n endHintRowProps,\n offersCreate,\n useComboboxCore,\n useComboboxFieldError,\n type ComboClearValue,\n type ComboOption,\n} from \"./combobox-core\";\nimport { DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\nimport {\n EndHintRow,\n FieldCaption,\n LABEL_IN_ROW,\n LockedReason,\n StaticLabelRow,\n useFieldHint,\n useLockReason,\n} from \"./field-parts\";\nimport { mergeDescribedBy } from \"./choice-parts\";\nimport { useCommitReason } from \"./write-lock\";\n\nexport type { ComboClearValue, ComboOption } from \"./combobox-core\";\n\n/** `onChange` is the kit's — \"a selection was made\", carrying values — rather\n * than the div's form event, so the DOM's spelling of it is omitted. */\nexport interface EntityComboboxProps<V extends string | number, C extends ComboClearValue = null>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {\n /** Selected id; `null`, `undefined` or `clearValue` when nothing is selected. */\n value: V | C | null | undefined;\n /** Selecting an option emits its value; the clear button emits `clearValue`. */\n onChange: (value: V | C) => void;\n /**\n * What the clear button emits. Default `null`. Pass `\"\"` for a form whose schema\n * wants an empty string for \"no choice\" (a zod `z.string()` field), rather than\n * mapping `null` in every `onChange` — the type of `onChange` follows it, so the\n * mapping cannot be forgotten on one field and not another. The picker also reads\n * the value back as empty, so `value=\"\"` shows the placeholder and no \"×\".\n * See {@link ComboClearValue} for why the choice is closed.\n */\n clearValue?: C;\n /** Already-loaded options (client-side filtered). Also used to resolve the\n * trigger label for the current `value`. */\n options?: ComboOption<V>[];\n /** Async option source, debounced and called on open + as the query changes\n * (at `minChars` and up). Stale responses are ignored; a rejection empties the\n * list and says `loadErrorLabel` instead of leaving the last query's rows up. When set, `options` is used only for label\n * resolution, not as the result list. */\n loadOptions?: (query: string) => Promise<ComboOption<V>[]>;\n /** External loading flag (OR-ed with the internal async state). */\n loading?: boolean;\n label?: ReactNode;\n placeholder?: string;\n searchPlaceholder?: string;\n emptyLabel?: string;\n /** Offer a clear \"×\" in place of the chevron while something is chosen; it emits\n * `clearValue`. A pointer shortcut inside the trigger, out of the tab order — the\n * keyboard's way is Delete or Backspace on the CLOSED trigger (0.23, as\n * {@link CountrySelect}). Not offered while `disabled` or locked. */\n clearable?: boolean;\n clearLabel?: string;\n /** The phone sheet's close button. Its own prop rather than a reuse of\n * `clearLabel`: \"clear the selection\" and \"close this screen\" are different\n * actions, and on a full-screen sheet the close button is the only way out —\n * so it is the one control here that MUST be in the reader's language. */\n closeLabel?: string;\n disabled?: boolean;\n /**\n * Why the choice cannot be changed — {@link Button}'s `disabledReason`, for a picker\n * that SAVES on change (keksdose G2: the statement's account, where picking IS the\n * write). The trigger stays focusable and `aria-disabled`, the list does not open,\n * the clear \"×\" is gone and `onChange` never fires; the reason is in the kit\n * {@link Tooltip} and on the trigger's `aria-describedby`. Wins over `disabled`.\n * {@link CountrySelect}'s lock, which is built on the same core.\n */\n disabledReason?: ReactNode;\n /**\n * This picker COMMITS — choosing saves. Under a locked {@link WriteLockProvider} it is\n * locked the `disabledReason` way with the lock's reason (which wins over its own).\n * A picker inside a form with its own Save stays editable under the lock: leave this\n * off there and put `commit` on the Save. No provider, or an unlocked one: no effect.\n */\n commit?: boolean;\n /** When set, a \"create\" row appears for a non-empty query with no exact match. */\n onCreate?: (query: string) => void;\n createLabel?: (query: string) => string;\n /**\n * Offer the create row with NOTHING typed too, worded as this — keksdose G9's\n * \"Create cash account\", which mints a record under a default name and so needs no\n * query. `onCreate` then receives `\"\"`. Left out, the row needs a query, as before.\n * See {@link InlineEntityCombobox}'s `createEmptyLabel`.\n */\n createEmptyLabel?: string;\n /**\n * The create row WRITES (it mints the record on the server) while picking does not.\n * Under a locked {@link WriteLockProvider} the row stays in the list but cannot be\n * taken, with the lock's reason as its second line — the picker itself stays live.\n * keksdose dev#496: on the read-only demo choosing is draft state, minting is not.\n */\n createCommit?: boolean;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /** What is wrong with the value, as {@link Input}'s `error`: rendered under the\n * field, on the trigger's `aria-describedby`, and implies `invalid`. */\n error?: ReactNode;\n /**\n * Standing advice — {@link Combobox}'s `hint`, so the pickers read like every other\n * field (keksdose K4): plain TEXT is a caption under the field on the trigger's\n * `aria-describedby`, before any error; a {@link FieldHint} \"?\" rides the label line,\n * or with no label sits at the trigger's end edge, outside the box.\n */\n hint?: ReactNode;\n /** Narrow `options` client-side by the query. Default `true`; `false` shows them\n * as given (a server-ranked list). */\n filter?: boolean;\n /** Offer nothing, and call no `loadOptions`, below this many characters. Default\n * `0`, i.e. the list loads as the panel opens. */\n minChars?: number;\n /** `loadOptions` debounce. Default 150 ms. */\n debounceMs?: number;\n /** Shown when `loadOptions` rejects. Default: `combobox.loadError`. */\n loadErrorLabel?: string;\n}\n\n/**\n * An id-keyed, searchable entity picker: a field-styled trigger showing the\n * selected item's label, and a portalled dropdown of `{label, sublabel, icon}`\n * options — loaded up front via `options` or lazily via `loadOptions`. Built on\n * the shared field/anchor/dismiss/search primitives (no cmdk/Radix). For picking\n * several entities use {@link MultiEntityCombobox}.\n */\nexport function EntityCombobox<V extends string | number, C extends ComboClearValue = null>(\n props: EntityComboboxProps<V, C>,\n) {\n const {\n value,\n onChange,\n clearValue = null as C,\n options,\n loadOptions,\n loading,\n label,\n placeholder,\n searchPlaceholder,\n emptyLabel,\n clearable,\n clearLabel,\n closeLabel,\n disabled,\n disabledReason,\n commit,\n onCreate,\n createLabel,\n createEmptyLabel,\n createCommit,\n className,\n invalid,\n error,\n hint,\n filter,\n minChars,\n debounceMs,\n loadErrorLabel,\n \"aria-label\": ariaLabel,\n // The control's own wiring, taken off `rest` so it lands on the TRIGGER rather than\n // the wrapper — see MultiEntityCombobox: `Field`'s render-prop spreads `{ id,\n // aria-describedby, aria-invalid, aria-required }`, and on the role-less wrapper\n // div the label's `htmlFor` named nothing and the hint described nothing.\n id,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n \"aria-required\": ariaRequired,\n ...rest\n } = props;\n const core = useComboboxCore<V>({\n options,\n loadOptions,\n loading,\n filter,\n minChars,\n debounceMs,\n });\n const hintParts = useFieldHint(hint, ariaDescribedBy);\n const field = useComboboxFieldError(\n error,\n invalid || ariaInvalid === true || ariaInvalid === \"true\",\n hintParts.describedBy,\n );\n // The props are the per-instance overrides, the provider the app-wide ones; a\n // prop left `undefined` falls through to the provider rather than masking it.\n const labels = useKitLabels(\"combobox\", DEFAULT_COMBOBOX_LABELS, {\n search: searchPlaceholder,\n noResults: emptyLabel,\n clear: clearLabel,\n create: createLabel,\n });\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const { open, results, resolve, setOpen, rememberOption, query, triggerRef } = core;\n // The lock: this picker's own reason, or the provider's under `commit`.\n const lock = useLockReason(commit, disabledReason);\n const inert = lock.locked || Boolean(disabled);\n // A lock arriving while the list is up closes it — adjusted while\n // rendering, as the core adjusts its own query, so no frame offers a pick that would\n // be thrown away.\n if (lock.locked && open) setOpen(false);\n // The create row's own lock, for a picker whose choosing is draft and whose create\n // is the write (`createCommit`).\n const createReason = useCommitReason(createCommit, undefined);\n // One id per instance, generated here rather than in the core: `aria-controls` on\n // the trigger has to name the list while the list is still closed, so the id\n // belongs to whoever renders both ends of it.\n const listboxId = useId();\n\n // The clear value is \"nothing selected\" too, whichever one the caller picked.\n const chosen: V | null = value == null || value === clearValue ? null : (value as V);\n const selectedOption = chosen == null ? null : resolve(chosen);\n const q = query.trim();\n const showCreate = offersCreate(\n onCreate,\n q,\n results.map((o) => o.label),\n createEmptyLabel,\n );\n const showClear = Boolean(clearable && chosen != null && !inert);\n /** What the closed control is showing — the second half of its accessible name. */\n const triggerText = selectedOption?.label ?? placeholder ?? \"\";\n // While locked the trigger sits in the reason's Tooltip — in a fragment with a hidden\n // copy of the reason, Button's anatomy — `block` so a full-width field stays full width.\n const withLock = (trigger: ReactNode) =>\n lock.locked ? (\n <LockedReason lock={lock} className=\"block\">\n {trigger}\n </LockedReason>\n ) : (\n trigger\n );\n\n const choose = (o: ComboOption<V>) => {\n if (lock.locked) return;\n rememberOption(o);\n onChange(o.value);\n // Back to the trigger, not to <body>: the panel that held focus is about to\n // unmount, and a keyboard user who just answered this field should be standing\n // on it, ready to Tab to the next one.\n core.closeToTrigger();\n };\n\n return (\n // `rest` dresses the wrapper, which has no role; the accessible NAME — and the\n // id, description, invalid and required state above — go on the trigger, which\n // has one. Spread FIRST so the trigger's ARIA and the\n // handlers that open the panel cannot be clobbered from outside.\n <div {...rest} className={cn(\"relative\", className)}>\n {label !== undefined && hintParts.labelHint === undefined && <FieldLabel>{label}</FieldLabel>}\n <EndHintRow {...endHintRowProps(\"hint\" in props, label !== undefined, hintParts.labelHint)}>\n {withLock(\n <button\n ref={triggerRef}\n id={id}\n type=\"button\"\n // A combobox, not a button. The distinction is not pedantry: this control\n // carried `aria-invalid`, which `button` does not support, so a required\n // field left empty painted a rose border and told a reader nothing at all —\n // and ESLint flagged it as exactly that (`role-supports-aria-props`). The\n // fix the audit asked for is the role that describes what this IS: a closed\n // choice that expands into the list named below. `combobox` supports\n // `aria-invalid`, so the border and the announcement finally agree.\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n // The label is a floating <span>, not a <label for>, so without this the\n // trigger's accessible name is whatever value happens to be selected —\n // \"Checking\" with nothing saying it is the account. The label AND the\n // value, because `aria-label` replaces the content rather than adding to\n // it, and a control that announces only its name has lost the answer.\n // A caller's own name wins over the composition: two fields labelled\n // \"Account\" on a transfer form are the from and the to, and only the\n // caller knows which is which.\n aria-label={\n ariaLabel ??\n (typeof label === \"string\" ? common.fieldValue(label, triggerText) : undefined)\n }\n // The focusable kind of disabled while locked (Button's rule): a native\n // `disabled` would take the field out of the tab order, and the reason with it.\n disabled={lock.locked ? undefined : disabled}\n aria-disabled={lock.locked || undefined}\n aria-invalid={field.isInvalid || undefined}\n aria-describedby={mergeDescribedBy(field.describedBy, lock.locked && lock.reasonId)}\n aria-required={ariaRequired}\n onClick={() => !inert && setOpen((o) => !o)}\n // Down/Up opens the list from the closed trigger, per the APG. Enter and\n // Space already do it through the button's own click.\n onKeyDown={(e) => {\n if (inert) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n setOpen(true);\n } else if (showClear && !open && (e.key === \"Delete\" || e.key === \"Backspace\")) {\n // The keyboard's clear: the \"×\" is a pointer shortcut out of the tab\n // order, so without this a cleared-by-mouse field was set-only from the\n // keyboard. The closed trigger only — CountrySelect's rule (0.23).\n e.preventDefault();\n onChange(clearValue);\n }\n }}\n className={cn(\n FIELD_TRIGGER,\n \"pe-9\",\n label !== undefined && FIELD_FLOATING_PAD,\n inert && \"cursor-not-allowed opacity-50\",\n field.isInvalid && FIELD_INVALID,\n )}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {selectedOption?.icon && <span className=\"shrink-0\">{selectedOption.icon}</span>}\n <span\n className={cn(\n \"truncate\",\n // A chosen value is the field's VALUE, so it is set in the same ink an\n // <input>'s value is — FIELD_BASE's own text colour, inherited rather\n // than restated (Keksdose dev#477). It used to be one notch lighter\n // than the typeahead fields beside it, which is visible when a picker\n // and a text field share a form row. Nothing selected keeps the\n // placeholder tone (`--text-placeholder`), which every field here\n // agrees on.\n !selectedOption && \"text-[var(--text-placeholder)]\",\n )}\n >\n {selectedOption?.label ?? placeholder ?? \"\"}\n </span>\n </span>\n {showClear ? (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events -- tabIndex -1 inside\n the trigger <button>, so it never holds focus and a key handler here could\n never fire; the keys go to the trigger, where Delete and Backspace clear. */\n <span\n role=\"button\"\n tabIndex={-1}\n aria-label={labels.clear}\n onClick={(e) => {\n e.stopPropagation();\n onChange(clearValue);\n }}\n className=\"absolute end-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-[var(--text-placeholder)] hover:text-[var(--text-secondary)]\"\n >\n <X className=\"size-4\" />\n </span>\n ) : (\n <FieldChevron />\n )}\n </button>,\n )}\n </EndHintRow>\n {/* With a \"?\" the label shares the top strip with it — after the trigger, so the\n \"?\" follows the control in the tab order, as on Input and Select. */}\n {label !== undefined && hintParts.labelHint !== undefined && (\n <StaticLabelRow hint={hintParts.labelHint}>\n <FieldLabel className={LABEL_IN_ROW}>{label}</FieldLabel>\n </StaticLabelRow>\n )}\n <ComboboxPanel\n core={core}\n listboxId={listboxId}\n // On a phone the panel becomes a full-screen sheet, which needs the field's\n // own label to say what it is asking for (live #200).\n sheetTitle={label ?? placeholder}\n searchPlaceholder={labels.search}\n emptyLabel={labels.noResults}\n closeLabel={closeLabel}\n loadErrorLabel={loadErrorLabel}\n isSelected={(v) => v === value}\n onChoose={choose}\n showCreate={showCreate}\n onCreate={() => {\n if (lock.locked) return;\n onCreate?.(q);\n core.closeToTrigger();\n }}\n createContent={q ? labels.create(q) : createEmptyLabel}\n createDisabledReason={createReason}\n />\n <FieldCaption parts={hintParts} />\n {field.errorEl}\n </div>\n );\n}\n"],"mappings":";AA2OM,cAoFM,YApFN;AA3ON,SAAS,aAAa;AAEtB,SAAS,SAAS;AAClB,SAAS,UAAU;AACnB,SAAS,cAAc,YAAY,eAAe,oBAAoB,qBAAqB;AAC3F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,yBAAyB,uBAAuB,oBAAoB;AAC7E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AA+GzB,SAAS,eACd,OACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,IAKd;AAAA,IACA,oBAAoB;AAAA,IACpB,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,GAAG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
7
|
import './series-chart-ticks.js';
|
|
8
8
|
import './series-chart-budget.js';
|
|
9
|
-
import '../
|
|
9
|
+
import '../feedback-BxeQVzwq.js';
|
|
10
|
+
import '../feedback-attachment-fGAzZPf0.js';
|
|
11
|
+
import '../feedback/feedback-inbox.js';
|
|
12
|
+
import 'lucide-react';
|
|
13
|
+
import './tooltip.js';
|
|
14
|
+
import '../hooks/use-anchored-rect.js';
|
|
15
|
+
import '../lib/clipping.js';
|
|
10
16
|
import '../data-table-labels-B7OdnM0S.js';
|
|
11
17
|
import './data-table-sort.js';
|
|
12
18
|
import './swipeable-row.js';
|
|
@@ -14,11 +20,7 @@ import './mini-calendar.js';
|
|
|
14
20
|
import './calendar-heatmap.js';
|
|
15
21
|
import './popover.js';
|
|
16
22
|
import './chip.js';
|
|
17
|
-
import 'lucide-react';
|
|
18
23
|
import './field-sync.js';
|
|
19
|
-
import './tooltip.js';
|
|
20
|
-
import '../hooks/use-anchored-rect.js';
|
|
21
|
-
import '../lib/clipping.js';
|
|
22
24
|
import '../wizard/types.js';
|
|
23
25
|
import '../tour/tour.js';
|
|
24
26
|
import '../search/command-palette.js';
|
|
@@ -38,9 +40,6 @@ import './dialog-frame.js';
|
|
|
38
40
|
import './modal.js';
|
|
39
41
|
import '../hooks/use-search-param-state.js';
|
|
40
42
|
import './measured-grid.js';
|
|
41
|
-
import '../feedback-attachment-NhUm7Zga.js';
|
|
42
|
-
import '../feedback/feedback-thread.js';
|
|
43
|
-
import '../feedback/feedback-inbox.js';
|
|
44
43
|
import './account-settings-labels.js';
|
|
45
44
|
import './floating-panel.js';
|
|
46
45
|
import './bulk-action-bar.js';
|
|
@@ -70,6 +69,10 @@ import './inline-edit-field.js';
|
|
|
70
69
|
import '../lib/iban.js';
|
|
71
70
|
import '../lib/phone.js';
|
|
72
71
|
import './sign-chip.js';
|
|
72
|
+
import './column-mapper.js';
|
|
73
|
+
import '../lib/column-mapping.js';
|
|
74
|
+
import '../lib/table-text.js';
|
|
75
|
+
import './field-parts.js';
|
|
73
76
|
|
|
74
77
|
/** Which chart of a facing pair. Physical, like the axes: charts do not mirror in RTL. */
|
|
75
78
|
type FacingSide = "left" | "right";
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* The pieces of a field's anatomy the kit's fields share — the static label, the hint
|
|
6
|
+
* (caption or "?"), the caption and the error under a field, the label strip over a
|
|
7
|
+
* bare group, the write lock on a control that saves itself. Private to the package —
|
|
8
|
+
* not re-exported from the barrel, except `FieldLabel` and `FLOATING_LABEL_STATIC`,
|
|
9
|
+
* which ui.tsx re-exports as it always has.
|
|
7
10
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
11
|
+
* One file since 0.23: until then the pickers' half (`field-anatomy.tsx`: the date and
|
|
12
|
+
* month pickers, whose trigger is a button in a wrapper of their own, and the groups
|
|
13
|
+
* with no field box) sat beside this one with its own copies of `isTextHint` and the
|
|
14
|
+
* caption class (keksdose K4: "uniform field anatomy … today it is a patchwork").
|
|
15
|
+
*
|
|
16
|
+
* Nothing here imports `ui.tsx`: `ui.tsx` imports this, and so do the combobox family,
|
|
17
|
+
* the pickers and the native choice controls — the lint's no-cycle rule holds it.
|
|
18
|
+
*/
|
|
19
|
+
declare const STATIC_LABEL_TYPE = "text-[11px] leading-tight text-[var(--text-muted)] peer-disabled:opacity-50";
|
|
20
|
+
declare const FLOATING_LABEL_STATIC: string;
|
|
21
|
+
/**
|
|
22
|
+
* The floating label for a custom-dropdown trigger (a `<span>`, since the trigger is a
|
|
23
|
+
* button not a labelable input). Same placement as {@link FloatingField}'s static label,
|
|
24
|
+
* so every labelled field lines up. Render inside a `relative` wrapper, before the trigger.
|
|
10
25
|
*/
|
|
26
|
+
interface FieldLabelProps extends ComponentPropsWithoutRef<"span"> {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
declare function FieldLabel({ children, className, ...rest }: FieldLabelProps): react.JSX.Element;
|
|
11
30
|
/**
|
|
12
31
|
* Whether a `hint` is a CAPTION (plain text: a non-empty string or a number) or
|
|
13
32
|
* something for the label line (a {@link FieldHint} "?", or any other node).
|
|
@@ -110,5 +129,96 @@ declare function LockedReason({ lock, className, children, }: {
|
|
|
110
129
|
* ChoiceCardGroup's `InGroupContext`, for the plain checkbox.
|
|
111
130
|
*/
|
|
112
131
|
declare const RequiredStarOnLegend: react.Context<boolean>;
|
|
132
|
+
/** `undefined`, `null`, `false` and `""` are what a caller's `cond && "…"` evaluates to
|
|
133
|
+
* when there is nothing to say; none of them is content. A numeric `0` is. */
|
|
134
|
+
declare function hasContent(node: ReactNode): boolean;
|
|
135
|
+
interface FieldMessages {
|
|
136
|
+
/** `invalid`, a message, or an `aria-invalid` from outside (a form library). */
|
|
137
|
+
isInvalid: boolean;
|
|
138
|
+
/** The caller's description, then the caption, then the error — the standing
|
|
139
|
+
* advice before the news, as `useFieldError` in ui.tsx orders them. */
|
|
140
|
+
describedBy: string | undefined;
|
|
141
|
+
/** The caption and the error, for under the field; `null` when there is neither. */
|
|
142
|
+
below: ReactNode;
|
|
143
|
+
/** The hint for the LABEL line (a `FieldHint`), or `undefined` when the hint is a
|
|
144
|
+
* caption or there is none. */
|
|
145
|
+
labelHint: ReactNode;
|
|
146
|
+
}
|
|
147
|
+
/** `hint` / `error` / `invalid` resolved the way `Select` resolves them. */
|
|
148
|
+
declare function useFieldMessages({ hint, error, invalid, describedBy, ariaInvalid, }: {
|
|
149
|
+
hint?: ReactNode;
|
|
150
|
+
error?: ReactNode;
|
|
151
|
+
invalid?: boolean;
|
|
152
|
+
describedBy?: string;
|
|
153
|
+
ariaInvalid?: unknown;
|
|
154
|
+
}): FieldMessages;
|
|
155
|
+
/**
|
|
156
|
+
* The field and what is under it, as one box — `FieldGroup` in ui.tsx, for the same
|
|
157
|
+
* reasons written there. Nothing of its own while there is nothing under the field and
|
|
158
|
+
* the caller passed no `error` key (the DOM is exactly what it was before these props);
|
|
159
|
+
* once `error` is passed the box is kept even with no message, so the trigger is never
|
|
160
|
+
* reparented — and remounted, losing focus — as the message comes and goes.
|
|
161
|
+
*/
|
|
162
|
+
declare function FieldBox({ below, reserve, children, }: {
|
|
163
|
+
below: ReactNode;
|
|
164
|
+
reserve: boolean;
|
|
165
|
+
children: ReactNode;
|
|
166
|
+
}): react.JSX.Element;
|
|
167
|
+
/**
|
|
168
|
+
* The static label in a trigger field's top strip — a {@link FieldLabel}, or, with a
|
|
169
|
+
* `FieldHint`, the label and its "?" laid out on ONE flex row (dev#468: two absolute
|
|
170
|
+
* offsets guessing at the same baseline put the "?" three pixels above its word).
|
|
171
|
+
* `FloatingField`'s static-label row, except that it stops at `end-9`: the date and
|
|
172
|
+
* month triggers keep that column (`pe-9`) for the calendar glyph or the clear ×, and a
|
|
173
|
+
* long label truncates before it rather than putting the "?" on top of it.
|
|
174
|
+
*/
|
|
175
|
+
declare function FieldLabelLine({ label, hint }: {
|
|
176
|
+
label: ReactNode;
|
|
177
|
+
hint?: ReactNode;
|
|
178
|
+
}): react.JSX.Element;
|
|
179
|
+
/**
|
|
180
|
+
* How tall the strip over a bare group is — the values {@link FieldStrip}'s `pad` takes,
|
|
181
|
+
* public since 0.23 (keksdose G8), so the names say what the CONTENT needs rather than
|
|
182
|
+
* which kit group first needed it (until 0.23 they were `toggle` and `tiles`).
|
|
183
|
+
*
|
|
184
|
+
* - `"field"` — 16px. keksdose's `ClearedStatusPicker` (live #288 rework, #431,
|
|
185
|
+
* measured): *"16px of label strip plus a 26px group is exactly a labelled Input"*,
|
|
186
|
+
* so a status group in a row of 42px fields ends where they end. The label's line
|
|
187
|
+
* box runs into the group's top hairline, but the ACTIVE fill — the thing feedback
|
|
188
|
+
* #117 was about — starts at 19px, below the label's 17.75px. For content with a
|
|
189
|
+
* border and an inset of its own; ToggleGroup's `labelPlacement="strip"`.
|
|
190
|
+
* - `"clear"` — 20px, keksdose's `FlagPicker` and location field (`pt-5`). A tile has
|
|
191
|
+
* no inset fill: its selection IS its frame, a 2px dark border-and-ring from the
|
|
192
|
+
* tile's top edge, so the tile has to start below the whole label line — and so does
|
|
193
|
+
* anything else with no inset: a map, a row of buttons, a line of text. SwatchPicker,
|
|
194
|
+
* IconPicker, and FieldStrip's default.
|
|
195
|
+
*/
|
|
196
|
+
declare const LABEL_STRIP_PAD: {
|
|
197
|
+
readonly field: "pt-4";
|
|
198
|
+
readonly clear: "pt-5";
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* The 11px label (and its `FieldHint`) over a group that is NOT a field — keksdose K2:
|
|
202
|
+
* a segmented control or a row of swatches standing in a form row beside labelled
|
|
203
|
+
* inputs, whose label must sit on the same line as theirs (`top-1`, `inset-x-3`, the
|
|
204
|
+
* type of a field's static label) without the group growing a field's border round
|
|
205
|
+
* it. `id` goes on the label so the group can be `aria-labelledby` it.
|
|
206
|
+
*
|
|
207
|
+
* `relative` is load-bearing twice over: the row is positioned against it, and a
|
|
208
|
+
* caller's `sr-only` label cannot escape it (sr-only-containment).
|
|
209
|
+
*
|
|
210
|
+
* Any other attribute (`rest`) lands on the wrapper — {@link FieldStrip} makes it the
|
|
211
|
+
* `role="group"` its label names. The kit's own groups pass none, so their wrapper is
|
|
212
|
+
* the bare box it was in 0.22.
|
|
213
|
+
*/
|
|
214
|
+
declare function LabelStrip({ labelId, label, hint, disabled, pad, className, children, ...rest }: Omit<ComponentPropsWithoutRef<"div">, "children"> & {
|
|
215
|
+
labelId: string;
|
|
216
|
+
label: ReactNode;
|
|
217
|
+
hint?: ReactNode;
|
|
218
|
+
/** Dim the label with its group, as `peer-disabled:` dims a field's own. */
|
|
219
|
+
disabled?: boolean;
|
|
220
|
+
pad: keyof typeof LABEL_STRIP_PAD;
|
|
221
|
+
children: ReactNode;
|
|
222
|
+
}): react.JSX.Element;
|
|
113
223
|
|
|
114
|
-
export { EndHintRow, FIELD_CAPTION_CLASS, FieldCaption, type FieldHintParts, LABEL_IN_ROW, type LockReason, LockedReason, RequiredStarOnLegend, StaticLabelRow, isTextHint, useFieldHint, useLockReason };
|
|
224
|
+
export { EndHintRow, FIELD_CAPTION_CLASS, FLOATING_LABEL_STATIC, FieldBox, FieldCaption, type FieldHintParts, FieldLabel, FieldLabelLine, type FieldLabelProps, type FieldMessages, LABEL_IN_ROW, LABEL_STRIP_PAD, LabelStrip, type LockReason, LockedReason, RequiredStarOnLegend, STATIC_LABEL_TYPE, StaticLabelRow, hasContent, isTextHint, useFieldHint, useFieldMessages, useLockReason };
|