@behavioral-agentic-design-system/core 0.42.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/package.json +25 -9
- package/scripts/a11y-lint.cjs +25 -1
- package/scripts/check-spec.mjs +73 -0
- package/scripts/deal-directions.mjs +186 -0
- package/scripts/health-report.mjs +20 -14
- package/scripts/lib/counted-lint.mjs +100 -0
- package/scripts/lib/marketing-library.mjs +129 -0
- package/scripts/lib/on-system.mjs +249 -0
- package/scripts/lib/random.mjs +22 -0
- package/scripts/lib/spec-parse.d.mts +25 -0
- package/scripts/lib/spec-parse.mjs +188 -0
- package/scripts/lib/tells.mjs +128 -0
- package/scripts/lint-css-vars.mjs +175 -0
- package/scripts/lint-html-nesting.mjs +116 -0
- package/scripts/lint-live-ctas.mjs +138 -0
- package/scripts/on-system-score.mjs +95 -0
- package/scripts/slop-rules.mjs +1 -1
- package/scripts/source-images.mjs +180 -0
- package/scripts/ux-tells.mjs +78 -0
- package/src/api/brand-colors.ts +3 -0
- package/src/api/brand-fonts.ts +3 -0
- package/src/api/brand-mark.ts +6 -1
- package/src/api/dev-write-guard.ts +53 -0
- package/src/api/layers/file.ts +7 -4
- package/src/api/onboarding-extract.ts +85 -30
- package/src/api/onboarding.ts +3 -0
- package/src/api/save-tokens.ts +3 -0
- package/src/app/layout.tsx +6 -0
- package/src/app/preview/canvas/page.tsx +12 -0
- package/src/app/preview/components/page.tsx +734 -0
- package/src/app/preview/studio/blank-screen.tsx +143 -0
- package/src/app/preview/studio/page.tsx +7 -0
- package/src/app/shell.tsx +160 -44
- package/src/components/canvas/canvas.tsx +458 -0
- package/src/components/canvas/layout.ts +72 -0
- package/src/components/canvas/parse-canvas.ts +32 -0
- package/src/components/canvas/sample.ts +90 -0
- package/src/components/canvas/spec-frame.tsx +43 -0
- package/src/components/canvas/types.ts +33 -0
- package/src/components/docs-tab.tsx +7 -7
- package/src/components/home-recent.tsx +73 -0
- package/src/components/home-tab.tsx +13 -13
- package/src/components/layers-tab.tsx +2 -2
- package/src/components/markdown-preview.tsx +60 -12
- package/src/components/studio/control-panel.tsx +299 -0
- package/src/components/studio/control-row.tsx +77 -0
- package/src/components/studio/preview-frame.tsx +165 -0
- package/src/components/studio/preview-pane.tsx +247 -0
- package/src/components/studio/studio.tsx +133 -128
- package/src/components/studio/types.ts +218 -0
- package/src/components/studio/use-studio-tweaks.ts +128 -0
- package/src/components/studio/use-studio-view-state.ts +72 -0
- package/src/components/ui/autocomplete.tsx +1 -1
- package/src/components/ui/color-picker.tsx +20 -4
- package/src/components/ui/data-table.tsx +64 -3
- package/src/components/ui/date-field.tsx +1 -1
- package/src/components/ui/editable.tsx +1 -0
- package/src/components/ui/faceted-filter.tsx +187 -0
- package/src/components/ui/gauge-chart.tsx +18 -4
- package/src/components/ui/inline-edit.tsx +175 -0
- package/src/components/ui/month-picker.tsx +1 -1
- package/src/components/ui/number-input.tsx +28 -5
- package/src/components/ui/otp-input.tsx +208 -0
- package/src/components/ui/phone-input.tsx +274 -0
- package/src/components/ui/search-input.tsx +1 -1
- package/src/components/ui/tags-input.tsx +1 -1
- package/src/components/ui/timer.tsx +1 -0
- package/src/components/ui/transfer-list.tsx +13 -26
- package/src/components/ui/week-picker.tsx +1 -1
- package/src/components/ui/year-picker.tsx +1 -1
- package/src/data/component-added.json +958 -0
- package/src/data/docs-index.ts +13 -1
- package/src/hooks/use-global-mono-font.ts +1 -0
- package/src/hooks/use-global-primary-color.ts +1 -0
- package/src/hooks/use-global-sans-font.ts +1 -0
- package/src/hooks/use-global-serif-font.ts +1 -0
- package/src/hooks/use-global-type-scale.ts +17 -2
- package/src/hooks/use-mobile.ts +2 -0
- package/src/hooks/use-sync-type-scale.ts +7 -11
- package/src/lib/spec-parse.ts +4 -0
- package/src/lib/svg-sanitize.ts +19 -9
- package/src/stories/Autocomplete.stories.tsx +2 -0
- package/src/stories/Canvas.stories.tsx +45 -0
- package/src/stories/ColorPicker.stories.tsx +40 -0
- package/src/stories/DataTable.stories.tsx +30 -0
- package/src/stories/DateField.stories.tsx +21 -0
- package/src/stories/Editable.stories.tsx +2 -0
- package/src/stories/FacetedFilter.stories.tsx +197 -0
- package/src/stories/GaugeChart.stories.tsx +9 -3
- package/src/stories/InlineEdit.stories.tsx +106 -0
- package/src/stories/MarkdownPreview.stories.tsx +53 -0
- package/src/stories/MonthPicker.stories.tsx +21 -0
- package/src/stories/NumberInput.stories.tsx +25 -0
- package/src/stories/OtpInput.stories.tsx +110 -0
- package/src/stories/PhoneInput.stories.tsx +127 -0
- package/src/stories/SearchInput.stories.tsx +2 -0
- package/src/stories/TagsInput.stories.tsx +2 -0
- package/src/stories/Timer.stories.tsx +26 -0
- package/src/stories/TransferList.stories.tsx +4 -0
- package/src/stories/WeekPicker.stories.tsx +21 -0
- package/src/stories/YearPicker.stories.tsx +21 -0
- package/src/stories/story-groups.json +22 -16
- package/src/tokens.json +82 -54
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* International phone number input that composes a country dial-code select
|
|
8
|
+
* with a tel Input into a single E.164-formatted field.
|
|
9
|
+
*
|
|
10
|
+
* No libphonenumber validation — just UI composition. The consuming form is
|
|
11
|
+
* responsible for any deeper phone-number validation it needs.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* <PhoneInput
|
|
15
|
+
* value={phone}
|
|
16
|
+
* onChange={setPhone}
|
|
17
|
+
* defaultCountry="GB"
|
|
18
|
+
* aria-label="Phone number"
|
|
19
|
+
* />
|
|
20
|
+
*
|
|
21
|
+
* Accessibility: the outer element is role="group" with an aria-label or
|
|
22
|
+
* aria-labelledby so screen readers announce it as a composite field. Tab
|
|
23
|
+
* moves from the country select to the number input.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export type Country = {
|
|
27
|
+
iso: string;
|
|
28
|
+
dialCode: string;
|
|
29
|
+
flag: string;
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const COUNTRIES: Country[] = [
|
|
34
|
+
{ iso: "US", dialCode: "+1", flag: "🇺🇸", name: "United States" },
|
|
35
|
+
{ iso: "CA", dialCode: "+1", flag: "🇨🇦", name: "Canada" },
|
|
36
|
+
{ iso: "GB", dialCode: "+44", flag: "🇬🇧", name: "United Kingdom" },
|
|
37
|
+
{ iso: "AU", dialCode: "+61", flag: "🇦🇺", name: "Australia" },
|
|
38
|
+
{ iso: "DE", dialCode: "+49", flag: "🇩🇪", name: "Germany" },
|
|
39
|
+
{ iso: "FR", dialCode: "+33", flag: "🇫🇷", name: "France" },
|
|
40
|
+
{ iso: "JP", dialCode: "+81", flag: "🇯🇵", name: "Japan" },
|
|
41
|
+
{ iso: "BR", dialCode: "+55", flag: "🇧🇷", name: "Brazil" },
|
|
42
|
+
{ iso: "IN", dialCode: "+91", flag: "🇮🇳", name: "India" },
|
|
43
|
+
{ iso: "MX", dialCode: "+52", flag: "🇲🇽", name: "Mexico" },
|
|
44
|
+
{ iso: "IT", dialCode: "+39", flag: "🇮🇹", name: "Italy" },
|
|
45
|
+
{ iso: "ES", dialCode: "+34", flag: "🇪🇸", name: "Spain" },
|
|
46
|
+
{ iso: "NL", dialCode: "+31", flag: "🇳🇱", name: "Netherlands" },
|
|
47
|
+
{ iso: "KR", dialCode: "+82", flag: "🇰🇷", name: "South Korea" },
|
|
48
|
+
{ iso: "SG", dialCode: "+65", flag: "🇸🇬", name: "Singapore" },
|
|
49
|
+
{ iso: "SE", dialCode: "+46", flag: "🇸🇪", name: "Sweden" },
|
|
50
|
+
{ iso: "NO", dialCode: "+47", flag: "🇳🇴", name: "Norway" },
|
|
51
|
+
{ iso: "DK", dialCode: "+45", flag: "🇩🇰", name: "Denmark" },
|
|
52
|
+
{ iso: "NZ", dialCode: "+64", flag: "🇳🇿", name: "New Zealand" },
|
|
53
|
+
{ iso: "ZA", dialCode: "+27", flag: "🇿🇦", name: "South Africa" },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
function findCountry(iso: string): Country {
|
|
57
|
+
return COUNTRIES.find((c) => c.iso === iso) ?? COUNTRIES[0];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Parse an E.164 value (+<dialCode><localNumber>) back into its parts.
|
|
62
|
+
* Returns null when the value doesn't start with "+".
|
|
63
|
+
*/
|
|
64
|
+
function parseE164(
|
|
65
|
+
value: string,
|
|
66
|
+
countries: Country[],
|
|
67
|
+
): { country: Country; localNumber: string } | null {
|
|
68
|
+
if (!value.startsWith("+")) return null;
|
|
69
|
+
// Try longest dial code first so "+1" doesn't greedily match "+10" countries.
|
|
70
|
+
const sorted = [...countries].sort((a, b) => b.dialCode.length - a.dialCode.length);
|
|
71
|
+
for (const country of sorted) {
|
|
72
|
+
if (value.startsWith(country.dialCode)) {
|
|
73
|
+
return { country, localNumber: value.slice(country.dialCode.length) };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface PhoneInputProps
|
|
80
|
+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> {
|
|
81
|
+
/** E.164 formatted phone number value (e.g. "+14155550182"). Omit for uncontrolled. */
|
|
82
|
+
value?: string;
|
|
83
|
+
/** Called with the new E.164 string whenever the country or number changes. */
|
|
84
|
+
onChange?: (value: string) => void;
|
|
85
|
+
/** ISO 2-letter country code, default "US". */
|
|
86
|
+
defaultCountry?: string;
|
|
87
|
+
disabled?: boolean;
|
|
88
|
+
/** When true, applies the destructive ring/border to both the select and the input. */
|
|
89
|
+
error?: boolean;
|
|
90
|
+
className?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const PhoneInput = React.forwardRef<HTMLInputElement, PhoneInputProps>(
|
|
94
|
+
(
|
|
95
|
+
{
|
|
96
|
+
value,
|
|
97
|
+
onChange,
|
|
98
|
+
defaultCountry = "US",
|
|
99
|
+
disabled = false,
|
|
100
|
+
error = false,
|
|
101
|
+
className,
|
|
102
|
+
id,
|
|
103
|
+
"aria-label": ariaLabel,
|
|
104
|
+
"aria-labelledby": ariaLabelledby,
|
|
105
|
+
"aria-describedby": ariaDescribedby,
|
|
106
|
+
name,
|
|
107
|
+
...rest
|
|
108
|
+
},
|
|
109
|
+
ref,
|
|
110
|
+
) => {
|
|
111
|
+
const isControlled = value !== undefined;
|
|
112
|
+
|
|
113
|
+
const controlled = React.useMemo(() => {
|
|
114
|
+
if (!isControlled || !value) return null;
|
|
115
|
+
return parseE164(value, COUNTRIES);
|
|
116
|
+
}, [isControlled, value]);
|
|
117
|
+
|
|
118
|
+
// The chosen country is always state. Re-deriving it from the value alone loses the choice for countries that
|
|
119
|
+
// share a dial code (US and CA are both +1), so Canada snapped back to the United States.
|
|
120
|
+
const [country, setCountry] = React.useState<Country>(
|
|
121
|
+
() => controlled?.country ?? findCountry(defaultCountry),
|
|
122
|
+
);
|
|
123
|
+
// What the user typed, with their spaces and brackets. The emitted value is digits only.
|
|
124
|
+
const [typed, setTyped] = React.useState(controlled?.localNumber ?? "");
|
|
125
|
+
|
|
126
|
+
// A controlled value that points at a different dial code is an outside change (a form reset, a loaded
|
|
127
|
+
// record): follow it. The same dial code keeps whichever country the user picked.
|
|
128
|
+
React.useEffect(() => {
|
|
129
|
+
if (!isControlled) return;
|
|
130
|
+
if (controlled && controlled.country.dialCode !== country.dialCode) setCountry(controlled.country);
|
|
131
|
+
}, [isControlled, controlled, country.dialCode]);
|
|
132
|
+
|
|
133
|
+
const activeCountry = country;
|
|
134
|
+
const digitsOf = (text: string) => text.replace(/\D/g, "");
|
|
135
|
+
// Show what was typed while it still matches the controlled value's digits; otherwise show the value.
|
|
136
|
+
const activeLocalNumber =
|
|
137
|
+
isControlled && digitsOf(typed) !== (controlled?.localNumber ?? "")
|
|
138
|
+
? (controlled?.localNumber ?? "")
|
|
139
|
+
: typed;
|
|
140
|
+
const e164 = digitsOf(activeLocalNumber) ? `${activeCountry.dialCode}${digitsOf(activeLocalNumber)}` : "";
|
|
141
|
+
|
|
142
|
+
function handleCountryChange(e: React.ChangeEvent<HTMLSelectElement>) {
|
|
143
|
+
const next = findCountry(e.target.value);
|
|
144
|
+
setCountry(next);
|
|
145
|
+
const digits = digitsOf(activeLocalNumber);
|
|
146
|
+
onChange?.(digits ? `${next.dialCode}${digits}` : "");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function handleNumberChange(e: React.ChangeEvent<HTMLInputElement>) {
|
|
150
|
+
// Keep digits and the punctuation people type; emit digits only, so "(415) 555-0182" is "+14155550182".
|
|
151
|
+
const raw = e.target.value.replace(/[^\d\s\-().]/g, "");
|
|
152
|
+
setTyped(raw);
|
|
153
|
+
const digits = digitsOf(raw);
|
|
154
|
+
onChange?.(digits ? `${activeCountry.dialCode}${digits}` : "");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const reactId = React.useId();
|
|
158
|
+
const inputId = id ?? `phone-input-${reactId}`;
|
|
159
|
+
const selectId = `${inputId}-country`;
|
|
160
|
+
|
|
161
|
+
const groupAriaProps: React.AriaAttributes & { role: string } = {
|
|
162
|
+
role: "group",
|
|
163
|
+
};
|
|
164
|
+
if (ariaLabel) {
|
|
165
|
+
groupAriaProps["aria-label"] = ariaLabel;
|
|
166
|
+
} else if (ariaLabelledby) {
|
|
167
|
+
groupAriaProps["aria-labelledby"] = ariaLabelledby;
|
|
168
|
+
} else {
|
|
169
|
+
groupAriaProps["aria-label"] = "Phone number";
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div
|
|
174
|
+
data-slot="phone-input"
|
|
175
|
+
data-disabled={disabled || undefined}
|
|
176
|
+
data-invalid={error || undefined}
|
|
177
|
+
className={cn("flex w-full min-w-0", className)}
|
|
178
|
+
{...groupAriaProps}
|
|
179
|
+
>
|
|
180
|
+
{/* Country dial-code select */}
|
|
181
|
+
<div className="relative shrink-0">
|
|
182
|
+
<select
|
|
183
|
+
id={selectId}
|
|
184
|
+
data-slot="phone-input-country"
|
|
185
|
+
value={activeCountry.iso}
|
|
186
|
+
onChange={handleCountryChange}
|
|
187
|
+
disabled={disabled}
|
|
188
|
+
aria-label={`Country code — ${activeCountry.name} (${activeCountry.dialCode})`}
|
|
189
|
+
aria-invalid={error || undefined}
|
|
190
|
+
className={cn(
|
|
191
|
+
// Base
|
|
192
|
+
"h-9 min-w-0 appearance-none rounded-l-md rounded-r-none border border-r-0 border-input",
|
|
193
|
+
"bg-transparent px-2 pr-7 text-base text-foreground outline-none",
|
|
194
|
+
"dark:bg-input/30 md:text-sm",
|
|
195
|
+
// States
|
|
196
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
197
|
+
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
198
|
+
// Error
|
|
199
|
+
error &&
|
|
200
|
+
"border-destructive ring-destructive/20 focus-visible:ring-destructive/40 dark:ring-destructive/40",
|
|
201
|
+
)}
|
|
202
|
+
style={{
|
|
203
|
+
transitionProperty: "color, box-shadow",
|
|
204
|
+
transitionDuration: "var(--duration-fast)",
|
|
205
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
206
|
+
}}
|
|
207
|
+
>
|
|
208
|
+
{COUNTRIES.map((country) => (
|
|
209
|
+
<option key={country.iso} value={country.iso}>
|
|
210
|
+
{country.flag} {country.dialCode}
|
|
211
|
+
</option>
|
|
212
|
+
))}
|
|
213
|
+
</select>
|
|
214
|
+
{/* Chevron icon */}
|
|
215
|
+
<svg
|
|
216
|
+
aria-hidden="true"
|
|
217
|
+
viewBox="0 0 16 16"
|
|
218
|
+
className="pointer-events-none absolute right-1.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"
|
|
219
|
+
fill="none"
|
|
220
|
+
stroke="currentColor"
|
|
221
|
+
strokeWidth={1.5}
|
|
222
|
+
strokeLinecap="round"
|
|
223
|
+
strokeLinejoin="round"
|
|
224
|
+
>
|
|
225
|
+
<path d="M4 6l4 4 4-4" />
|
|
226
|
+
</svg>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
{/* A plain <form> posts this: the visible input holds only the local part, so it carries no name. */}
|
|
230
|
+
{name ? <input type="hidden" name={name} value={e164} /> : null}
|
|
231
|
+
|
|
232
|
+
{/* Local number input */}
|
|
233
|
+
<input
|
|
234
|
+
ref={ref}
|
|
235
|
+
id={inputId}
|
|
236
|
+
data-slot="phone-input-number"
|
|
237
|
+
type="tel"
|
|
238
|
+
inputMode="tel"
|
|
239
|
+
autoComplete="tel-national"
|
|
240
|
+
value={activeLocalNumber}
|
|
241
|
+
onChange={handleNumberChange}
|
|
242
|
+
disabled={disabled}
|
|
243
|
+
aria-invalid={error || undefined}
|
|
244
|
+
aria-describedby={ariaDescribedby}
|
|
245
|
+
placeholder="(555) 000-0000"
|
|
246
|
+
className={cn(
|
|
247
|
+
// Base
|
|
248
|
+
"min-w-0 flex-1 rounded-l-none rounded-r-md border border-l-0 border-input",
|
|
249
|
+
"h-9 bg-transparent px-3 py-1 text-base outline-none",
|
|
250
|
+
"selection:bg-primary selection:text-primary-foreground md:text-sm",
|
|
251
|
+
"dark:bg-input/30",
|
|
252
|
+
// States
|
|
253
|
+
"placeholder:text-muted-foreground",
|
|
254
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
255
|
+
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
256
|
+
// Error
|
|
257
|
+
error &&
|
|
258
|
+
"border-destructive ring-destructive/20 focus-visible:ring-destructive/40 dark:ring-destructive/40",
|
|
259
|
+
)}
|
|
260
|
+
style={{
|
|
261
|
+
transitionProperty: "color, box-shadow",
|
|
262
|
+
transitionDuration: "var(--duration-fast)",
|
|
263
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
264
|
+
}}
|
|
265
|
+
{...rest}
|
|
266
|
+
/>
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
},
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
PhoneInput.displayName = "PhoneInput";
|
|
273
|
+
|
|
274
|
+
export { PhoneInput };
|
|
@@ -197,7 +197,7 @@ export function TagsInput({
|
|
|
197
197
|
setActiveIndex((i) => (i <= 0 ? 0 : i - 1));
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
|
-
if (e.key === "Enter") {
|
|
200
|
+
if (e.key === "Enter" && !e.nativeEvent.isComposing) {
|
|
201
201
|
e.preventDefault();
|
|
202
202
|
if (isOpen && activeIndex >= 0) {
|
|
203
203
|
selectSuggestion(filteredSuggestions[activeIndex]);
|
|
@@ -172,6 +172,7 @@ function Timer({
|
|
|
172
172
|
{/* Entering the DOM on completion triggers exactly one polite
|
|
173
173
|
announcement — the only tick worth interrupting for. */}
|
|
174
174
|
{completed && (
|
|
175
|
+
// allow-conditional-aria-live intentional one-shot completion announce — mounting triggers a single polite read and the region then leaves the DOM
|
|
175
176
|
<span data-slot="timer-announcement" role="status" className="sr-only">
|
|
176
177
|
{completeAnnouncement}
|
|
177
178
|
</span>
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { cn } from "../../lib/utils"
|
|
12
12
|
import { Button } from "../ui/button"
|
|
13
13
|
import { Badge } from "../ui/badge"
|
|
14
|
+
import { Checkbox } from "../ui/checkbox"
|
|
14
15
|
import { Input } from "../ui/input"
|
|
15
16
|
|
|
16
17
|
// ────────────────────────────────────────────────────────────────────────────
|
|
@@ -154,32 +155,18 @@ function Panel({ label, items, checked, onToggle, searchable }: PanelProps) {
|
|
|
154
155
|
transitionTimingFunction: "var(--ease-out)",
|
|
155
156
|
}}
|
|
156
157
|
>
|
|
157
|
-
{/*
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
width="10"
|
|
170
|
-
height="8"
|
|
171
|
-
viewBox="0 0 10 8"
|
|
172
|
-
fill="none"
|
|
173
|
-
stroke="currentColor"
|
|
174
|
-
strokeWidth="1.5"
|
|
175
|
-
strokeLinecap="round"
|
|
176
|
-
strokeLinejoin="round"
|
|
177
|
-
aria-hidden="true"
|
|
178
|
-
>
|
|
179
|
-
<polyline points="1 4 3.5 6.5 9 1" />
|
|
180
|
-
</svg>
|
|
181
|
-
)}
|
|
182
|
-
</span>
|
|
158
|
+
{/* Decorative, not the real control: the <li role="option"> above already
|
|
159
|
+
handles the click/toggle. A second focusable checkbox nested in the
|
|
160
|
+
same row would double the controls a screen reader announces for one
|
|
161
|
+
choice — tabIndex, pointer-events, and aria-hidden are what make the
|
|
162
|
+
real Checkbox primitive safe to use purely as a visual here. */}
|
|
163
|
+
<Checkbox
|
|
164
|
+
size="sm"
|
|
165
|
+
checked={isChecked}
|
|
166
|
+
tabIndex={-1}
|
|
167
|
+
aria-hidden
|
|
168
|
+
className="pointer-events-none"
|
|
169
|
+
/>
|
|
183
170
|
<span className="min-w-0 truncate" title={item}>
|
|
184
171
|
{item}
|
|
185
172
|
</span>
|
|
@@ -147,7 +147,7 @@ function WeekPicker({
|
|
|
147
147
|
className,
|
|
148
148
|
id,
|
|
149
149
|
}: WeekPickerProps) {
|
|
150
|
-
const isControlled = value !== undefined
|
|
150
|
+
const isControlled = value !== undefined || onValueChange !== undefined
|
|
151
151
|
const [internalValue, setInternalValue] = React.useState<Date | undefined>(
|
|
152
152
|
defaultValue ? isoWeekStart(defaultValue) : undefined
|
|
153
153
|
)
|
|
@@ -64,7 +64,7 @@ function YearPicker({
|
|
|
64
64
|
const resolvedMin = minYear ?? currentYear - 100
|
|
65
65
|
const resolvedMax = maxYear ?? currentYear + 10
|
|
66
66
|
|
|
67
|
-
const isControlled = value !== undefined
|
|
67
|
+
const isControlled = value !== undefined || onValueChange !== undefined
|
|
68
68
|
const [internalValue, setInternalValue] = React.useState<number | undefined>(
|
|
69
69
|
defaultValue
|
|
70
70
|
)
|