@betterinternship/components 3.4.2 → 3.5.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/dist/components/autocomplete.d.ts +1 -2
- package/dist/components/autocomplete.js +75 -64
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/checkbox-field.d.ts +18 -0
- package/dist/components/checkbox-field.js +25 -0
- package/dist/components/checkbox-field.js.map +1 -0
- package/dist/components/checkbox-group.d.ts +33 -0
- package/dist/components/checkbox-group.js +43 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +6 -2
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/chip-select.d.ts +11 -2
- package/dist/components/chip-select.js +9 -4
- package/dist/components/chip-select.js.map +1 -1
- package/dist/components/{form-date-picker.d.ts → date-picker.d.ts} +11 -8
- package/dist/components/date-picker.js +57 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dropdown.js +7 -2
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/form-field.d.ts +60 -5
- package/dist/components/form-field.js +55 -5
- package/dist/components/form-field.js.map +1 -1
- package/dist/components/input.js +3 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/{form-month-picker.d.ts → month-picker.d.ts} +6 -6
- package/dist/components/month-picker.js +57 -0
- package/dist/components/month-picker.js.map +1 -0
- package/dist/components/radio-group.d.ts +11 -1
- package/dist/components/radio-group.js +17 -4
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/select.js +38 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.d.ts +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/switch.js +4 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.js +5 -5
- package/dist/components/table.js.map +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/textarea.js +3 -1
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/time-input.d.ts +9 -0
- package/dist/components/time-input.js +65 -0
- package/dist/components/time-input.js.map +1 -0
- package/dist/hooks/use-field-focus.d.ts +1 -1
- package/dist/hooks/use-field-focus.js +1 -1
- package/dist/hooks/use-field-focus.js.map +1 -1
- package/dist/index.d.ts +5 -9
- package/dist/index.js +7 -11
- package/dist/index.js.map +1 -1
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +54 -2
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
- package/dist/utils.js +11 -1
- package/dist/utils.js.map +1 -1
- package/package.json +27 -40
- package/dist/components/form-checkbox-group.d.ts +0 -31
- package/dist/components/form-checkbox-group.js +0 -30
- package/dist/components/form-checkbox-group.js.map +0 -1
- package/dist/components/form-checkbox.d.ts +0 -15
- package/dist/components/form-checkbox.js +0 -15
- package/dist/components/form-checkbox.js.map +0 -1
- package/dist/components/form-date-picker.js +0 -56
- package/dist/components/form-date-picker.js.map +0 -1
- package/dist/components/form-input.d.ts +0 -11
- package/dist/components/form-input.js +0 -13
- package/dist/components/form-input.js.map +0 -1
- package/dist/components/form-month-picker.js +0 -56
- package/dist/components/form-month-picker.js.map +0 -1
- package/dist/components/form-radio.d.ts +0 -15
- package/dist/components/form-radio.js +0 -20
- package/dist/components/form-radio.js.map +0 -1
- package/dist/components/form-textarea.d.ts +0 -11
- package/dist/components/form-textarea.js +0 -12
- package/dist/components/form-textarea.js.map +0 -1
- package/dist/components/form.d.ts +0 -24
- package/dist/components/form.js +0 -71
- package/dist/components/form.js.map +0 -1
- package/dist/components/time-input-native.d.ts +0 -14
- package/dist/components/time-input-native.js +0 -62
- package/dist/components/time-input-native.js.map +0 -1
- package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -706
- package/dist/node_modules/react-hook-form/dist/index.esm.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Input } from './input.js';
|
|
5
|
+
import { useFormField } from './form-field.js';
|
|
6
|
+
import { Clock } from 'lucide-react';
|
|
7
|
+
import { Popover, PopoverAnchor, PopoverTrigger, PopoverContent } from './popover.js';
|
|
8
|
+
import { useFieldFocus, FieldChromeContext, fieldFocusOutlineClassName, fieldInteractionClassName } from '../hooks/use-field-focus.js';
|
|
9
|
+
import { cn } from '../utils.js';
|
|
10
|
+
|
|
11
|
+
function TimeInput({ value, onChange, className, ...props }) {
|
|
12
|
+
// The text input inside takes the field's id itself; this only names the picker.
|
|
13
|
+
const field = useFormField();
|
|
14
|
+
const pickerLabel = `Choose ${(field?.labelText ?? props['aria-label'] ?? 'time').toLowerCase()}`;
|
|
15
|
+
const [open, setOpen] = React.useState(false);
|
|
16
|
+
const formatTime = (time) => {
|
|
17
|
+
if (!time)
|
|
18
|
+
return '';
|
|
19
|
+
const [hour, minute] = time.split(':');
|
|
20
|
+
return `${String(Number(hour) % 12 || 12).padStart(2, '0')}:${minute} ${Number(hour) >= 12 ? 'PM' : 'AM'}`;
|
|
21
|
+
};
|
|
22
|
+
const [draft, setDraft] = React.useState(() => formatTime(value));
|
|
23
|
+
React.useEffect(() => { setDraft(formatTime(value)); }, [value]);
|
|
24
|
+
const disabled = props.disabled;
|
|
25
|
+
const { keyboardFocus, focusProps } = useFieldFocus();
|
|
26
|
+
const updatePart = (part, next) => {
|
|
27
|
+
const [hour = '09', minute = '00'] = (value || '09:00').split(':');
|
|
28
|
+
const currentHour = Number(hour);
|
|
29
|
+
const nextHour = part === 'hour'
|
|
30
|
+
? Number(next) % 12 + (currentHour >= 12 ? 12 : 0)
|
|
31
|
+
: part === 'period' ? currentHour % 12 + (next === 'PM' ? 12 : 0) : currentHour;
|
|
32
|
+
onChange?.(`${String(nextHour).padStart(2, '0')}:${part === 'minute' ? next : minute}`);
|
|
33
|
+
};
|
|
34
|
+
return (jsx("div", { className: className, children: jsxs(Popover, { open: open, onOpenChange: setOpen, children: [jsx(PopoverAnchor, { asChild: true, children: jsx("div", { ...focusProps, className: cn('relative', !disabled && fieldInteractionClassName, !disabled && keyboardFocus && fieldFocusOutlineClassName), children: jsxs(FieldChromeContext, { value: true, children: [jsx(Input, { ...props, type: "text", placeholder: props.placeholder ?? 'HH:MM AM/PM', value: draft, onChange: (event) => {
|
|
35
|
+
const next = event.target.value;
|
|
36
|
+
// Permit incomplete time segments while typing, but no arbitrary text.
|
|
37
|
+
if (!/^\d{0,2}(:[0-5]?\d?)?(\s?[AaPp]?[Mm]?)?$/.test(next))
|
|
38
|
+
return;
|
|
39
|
+
const parts = next.match(/^(\d{1,2})/);
|
|
40
|
+
if (parts && Number(parts[1]) > 23)
|
|
41
|
+
return;
|
|
42
|
+
setDraft(next);
|
|
43
|
+
if (!next.trim()) {
|
|
44
|
+
onChange?.(undefined);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const match = next.trim().match(/^(\d{1,2}):(\d{2})\s*(AM|PM)?$/i);
|
|
48
|
+
if (!match)
|
|
49
|
+
return;
|
|
50
|
+
let hour = Number(match[1]);
|
|
51
|
+
const minute = Number(match[2]);
|
|
52
|
+
if (minute > 59 || hour > 23 || (match[3] && (hour < 1 || hour > 12)))
|
|
53
|
+
return;
|
|
54
|
+
if (match[3])
|
|
55
|
+
hour = hour % 12 + (match[3].toUpperCase() === 'PM' ? 12 : 0);
|
|
56
|
+
onChange?.(`${String(hour).padStart(2, '0')}:${match[2]}`);
|
|
57
|
+
}, onBlur: (event) => {
|
|
58
|
+
setDraft(formatTime(value));
|
|
59
|
+
props.onBlur?.(event);
|
|
60
|
+
}, onClick: (event) => { props.onClick?.(event); if (!event.defaultPrevented && !disabled && !props.readOnly)
|
|
61
|
+
setOpen(true); }, className: "pr-11" }), jsx(PopoverTrigger, { asChild: true, children: jsx("button", { type: "button", disabled: disabled || props.readOnly, "aria-label": pickerLabel, className: "absolute inset-y-0 right-0 z-20 flex w-11 items-center justify-center rounded-control-lg text-muted-foreground hover:text-foreground disabled:opacity-50", children: jsx(Clock, { className: "size-4", "aria-hidden": "true" }) }) })] }) }) }), jsx(PopoverContent, { align: "start", sideOffset: 6, className: "w-72", "aria-label": pickerLabel, onOpenAutoFocus: event => event.preventDefault(), children: jsxs("div", { className: "grid grid-cols-3 gap-2", children: [jsx("div", { children: jsx("select", { "aria-label": "Hour", className: "h-form-control rounded-control-lg border border-input bg-background px-field-padding-x text-base text-foreground", value: String(Number(value?.split(':')[0] ?? 9) % 12 || 12).padStart(2, '0'), onChange: event => updatePart('hour', event.target.value), children: Array.from({ length: 12 }, (_, hour) => { const text = String(hour + 1).padStart(2, '0'); return jsx("option", { value: text, children: text }, text); }) }) }), jsx("div", { children: jsx("select", { "aria-label": "Minute", className: "h-form-control rounded-control-lg border border-input bg-background px-field-padding-x text-base text-foreground", value: value?.split(':')[1] ?? '00', onChange: event => updatePart('minute', event.target.value), children: Array.from({ length: 60 }, (_, minute) => { const text = String(minute).padStart(2, '0'); return jsx("option", { value: text, children: text }, text); }) }) }), jsx("div", { children: jsxs("select", { "aria-label": "AM or PM", className: "h-form-control rounded-control-lg border border-input bg-background px-field-padding-x text-base text-foreground", value: Number(value?.split(':')[0] ?? 9) >= 12 ? 'PM' : 'AM', onChange: event => updatePart('period', event.target.value), children: [jsx("option", { value: "AM", children: "AM" }), jsx("option", { value: "PM", children: "PM" })] }) })] }) })] }) }));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { TimeInput };
|
|
65
|
+
//# sourceMappingURL=time-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-input.js","sources":["../../src/components/time-input.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\n\r\nimport { Input } from '@/components/input';\r\nimport { useFormField } from './form-field';\r\nimport { Clock } from 'lucide-react';\r\nimport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from './popover';\r\nimport { FieldChromeContext, fieldInteractionClassName, fieldFocusOutlineClassName, useFieldFocus } from '@/hooks/use-field-focus';\r\nimport { cn } from '@/utils';\r\n\r\n/** A time input with a picker. Unlabelled: put it in a `FormField` for a label. */\r\nexport type TimeInputProps = {\r\n /** \"HH:MM\" */\r\n value?: string;\r\n onChange?: (v?: string) => void;\r\n className?: string;\r\n} & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'>;\r\n\r\nexport function TimeInput({\r\n value,\r\n onChange,\r\n className,\r\n ...props\r\n}: TimeInputProps) {\r\n // The text input inside takes the field's id itself; this only names the picker.\r\n const field = useFormField();\r\n const pickerLabel = `Choose ${(field?.labelText ?? props['aria-label'] ?? 'time').toLowerCase()}`;\r\n const [open, setOpen] = React.useState(false);\r\n const formatTime = (time?: string) => {\r\n if (!time) return '';\r\n const [hour, minute] = time.split(':');\r\n return `${String(Number(hour) % 12 || 12).padStart(2, '0')}:${minute} ${Number(hour) >= 12 ? 'PM' : 'AM'}`;\r\n };\r\n const [draft, setDraft] = React.useState(() => formatTime(value));\r\n React.useEffect(() => { setDraft(formatTime(value)); }, [value]);\r\n const disabled = props.disabled;\r\n const { keyboardFocus, focusProps } = useFieldFocus();\r\n const updatePart = (part: 'hour' | 'minute' | 'period', next: string) => {\r\n const [hour = '09', minute = '00'] = (value || '09:00').split(':');\r\n const currentHour = Number(hour);\r\n const nextHour = part === 'hour'\r\n ? Number(next) % 12 + (currentHour >= 12 ? 12 : 0)\r\n : part === 'period' ? currentHour % 12 + (next === 'PM' ? 12 : 0) : currentHour;\r\n onChange?.(`${String(nextHour).padStart(2, '0')}:${part === 'minute' ? next : minute}`);\r\n };\r\n return (\r\n <div className={className}>\r\n <Popover open={open} onOpenChange={setOpen}>\r\n <PopoverAnchor asChild>\r\n <div {...focusProps} className={cn('relative', !disabled && fieldInteractionClassName, !disabled && keyboardFocus && fieldFocusOutlineClassName)}>\r\n <FieldChromeContext value={true}>\r\n <Input\r\n {...props}\r\n type=\"text\"\r\n placeholder={props.placeholder ?? 'HH:MM AM/PM'}\r\n value={draft}\r\n onChange={(event) => {\r\n const next = event.target.value;\r\n // Permit incomplete time segments while typing, but no arbitrary text.\r\n if (!/^\\d{0,2}(:[0-5]?\\d?)?(\\s?[AaPp]?[Mm]?)?$/.test(next)) return;\r\n const parts = next.match(/^(\\d{1,2})/);\r\n if (parts && Number(parts[1]) > 23) return;\r\n setDraft(next);\r\n if (!next.trim()) { onChange?.(undefined); return; }\r\n const match = next.trim().match(/^(\\d{1,2}):(\\d{2})\\s*(AM|PM)?$/i);\r\n if (!match) return;\r\n let hour = Number(match[1]);\r\n const minute = Number(match[2]);\r\n if (minute > 59 || hour > 23 || (match[3] && (hour < 1 || hour > 12))) return;\r\n if (match[3]) hour = hour % 12 + (match[3].toUpperCase() === 'PM' ? 12 : 0);\r\n onChange?.(`${String(hour).padStart(2, '0')}:${match[2]}`);\r\n }}\r\n onBlur={(event) => {\r\n setDraft(formatTime(value));\r\n props.onBlur?.(event);\r\n }}\r\n onClick={(event) => { props.onClick?.(event); if (!event.defaultPrevented && !disabled && !props.readOnly) setOpen(true); }}\r\n className=\"pr-11\"\r\n />\r\n <PopoverTrigger asChild>\r\n <button type=\"button\" disabled={disabled || props.readOnly} aria-label={pickerLabel} className=\"absolute inset-y-0 right-0 z-20 flex w-11 items-center justify-center rounded-control-lg text-muted-foreground hover:text-foreground disabled:opacity-50\"><Clock className=\"size-4\" aria-hidden=\"true\" /></button>\r\n </PopoverTrigger>\r\n </FieldChromeContext>\r\n </div>\r\n </PopoverAnchor>\r\n <PopoverContent align=\"start\" sideOffset={6} className=\"w-72\" aria-label={pickerLabel} onOpenAutoFocus={event => event.preventDefault()}>\r\n <div className=\"grid grid-cols-3 gap-2\">\r\n <div>\r\n <select aria-label=\"Hour\" className=\"h-form-control rounded-control-lg border border-input bg-background px-field-padding-x text-base text-foreground\" value={String(Number(value?.split(':')[0] ?? 9) % 12 || 12).padStart(2, '0')} onChange={event => updatePart('hour', event.target.value)}>\r\n {Array.from({ length: 12 }, (_, hour) => { const text = String(hour + 1).padStart(2, '0'); return <option key={text} value={text}>{text}</option>; })}\r\n </select>\r\n </div>\r\n <div>\r\n <select aria-label=\"Minute\" className=\"h-form-control rounded-control-lg border border-input bg-background px-field-padding-x text-base text-foreground\" value={value?.split(':')[1] ?? '00'} onChange={event => updatePart('minute', event.target.value)}>\r\n {Array.from({ length: 60 }, (_, minute) => { const text = String(minute).padStart(2, '0'); return <option key={text} value={text}>{text}</option>; })}\r\n </select>\r\n </div>\r\n <div>\r\n <select aria-label=\"AM or PM\" className=\"h-form-control rounded-control-lg border border-input bg-background px-field-padding-x text-base text-foreground\" value={Number(value?.split(':')[0] ?? 9) >= 12 ? 'PM' : 'AM'} onChange={event => updatePart('period', event.target.value)}>\r\n <option value=\"AM\">AM</option><option value=\"PM\">PM</option>\r\n </select>\r\n </div>\r\n </div>\r\n </PopoverContent>\r\n </Popover>\r\n </div>\r\n );\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;AAmBM;;AAOJ;AACA;AACA;AACA;AACE;AAAW;AACX;AACA;AACF;AACA;;AAEA;;AAEA;;AAEE;AACA;;AAEE;AACF;AACF;AACA;AAYQ;;AAEA;;;;;;AAIA;AAAoB;;;;AAEpB;;;;;;;;;AAMF;AAEE;AACA;AACF;AAC2G;AA+BnH;;"}
|
|
@@ -12,7 +12,7 @@ export declare const fieldInteractionClassName: string;
|
|
|
12
12
|
* regular text, a white surface, and a border that only darkens on hover.
|
|
13
13
|
* Buttons already show the focus outline for keyboard focus only.
|
|
14
14
|
*/
|
|
15
|
-
export declare const fieldTriggerClassName = "h-form-control min-h-form-control max-h-form-control text-base font-normal text-foreground enabled:hover:text-foreground bg-background enabled:hover:bg-background border-input enabled:hover:border-input-hover";
|
|
15
|
+
export declare const fieldTriggerClassName = "h-form-control min-h-form-control max-h-form-control text-base font-normal text-foreground enabled:hover:text-foreground bg-background enabled:hover:bg-background border-input enabled:hover:border-input-hover aria-invalid:border-destructive enabled:aria-invalid:hover:border-destructive disabled:pointer-events-auto disabled:cursor-not-allowed";
|
|
16
16
|
/**
|
|
17
17
|
* Set by a component that draws the field chrome around an Input itself (for
|
|
18
18
|
* example Autocomplete, whose icons sit beside the input), so the Input
|
|
@@ -17,7 +17,7 @@ const fieldInteractionClassName = cn('rounded-control-lg', interactiveControlCla
|
|
|
17
17
|
* regular text, a white surface, and a border that only darkens on hover.
|
|
18
18
|
* Buttons already show the focus outline for keyboard focus only.
|
|
19
19
|
*/
|
|
20
|
-
const fieldTriggerClassName = 'h-form-control min-h-form-control max-h-form-control text-base font-normal text-foreground enabled:hover:text-foreground bg-background enabled:hover:bg-background border-input enabled:hover:border-input-hover';
|
|
20
|
+
const fieldTriggerClassName = 'h-form-control min-h-form-control max-h-form-control text-base font-normal text-foreground enabled:hover:text-foreground bg-background enabled:hover:bg-background border-input enabled:hover:border-input-hover aria-invalid:border-destructive enabled:aria-invalid:hover:border-destructive disabled:pointer-events-auto disabled:cursor-not-allowed';
|
|
21
21
|
/**
|
|
22
22
|
* Set by a component that draws the field chrome around an Input itself (for
|
|
23
23
|
* example Autocomplete, whose icons sit beside the input), so the Input
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-field-focus.js","sources":["../../src/hooks/use-field-focus.ts"],"sourcesContent":["'use client';\r\n\r\nimport { createContext, useContext, useRef, useState } from 'react';\r\nimport { cn } from '@/utils';\r\nimport { interactiveControlClassName } from '@/lib/interaction-styles';\r\n\r\n/**\r\n * Shared input field chrome (see \"Input fields and menus\" in COMPONENT-DESIGN.md).\r\n *\r\n * Fields keep their border when clicked or selected. Keyboard focus shows the\r\n * same outline as Button.\r\n */\r\nexport const fieldFocusOutlineClassName = 'outline-3 outline-offset-4 outline-landing-blue';\r\n\r\n/** Hover lift and press feedback shared with Button. */\r\nexport const fieldInteractionClassName = cn('rounded-control-lg', interactiveControlClassName);\r\n\r\n/**\r\n * Button-based field triggers (Dropdown, Select, date and month pickers): 16px\r\n * regular text, a white surface, and a border that only darkens on hover.\r\n * Buttons already show the focus outline for keyboard focus only.\r\n */\r\nexport const fieldTriggerClassName =\r\n 'h-form-control min-h-form-control max-h-form-control text-base font-normal text-foreground enabled:hover:text-foreground bg-background enabled:hover:bg-background border-input enabled:hover:border-input-hover';\r\n\r\n/**\r\n * Set by a component that draws the field chrome around an Input itself (for\r\n * example Autocomplete, whose icons sit beside the input), so the Input\r\n * doesn't lift or outline separately.\r\n */\r\nexport const FieldChromeContext = createContext(false);\r\nexport const useFieldChromeOwned = () => useContext(FieldChromeContext);\r\n\r\n/** A pointer press within this window counts the next focus as a click or tap. */\r\nconst POINTER_FOCUS_WINDOW = 800;\r\n\r\n/**\r\n * Text inputs match :focus-visible even when clicked, so CSS alone can't show\r\n * an outline for keyboard focus only. Spread `focusProps` on the field (or its\r\n * wrapper) and apply the outline while `keyboardFocus` is true.\r\n */\r\nexport function useFieldFocus() {\r\n const lastPointer = useRef(-Infinity);\r\n const [keyboardFocus, setKeyboardFocus] = useState(false);\r\n\r\n const focusProps = {\r\n onPointerDown: () => {\r\n lastPointer.current = performance.now();\r\n },\r\n onFocus: () => {\r\n setKeyboardFocus(performance.now() - lastPointer.current > POINTER_FOCUS_WINDOW);\r\n },\r\n onBlur: () => setKeyboardFocus(false),\r\n };\r\n\r\n return { keyboardFocus, focusProps };\r\n}\r\n\r\n/** Call a consumer's handler and then ours, so neither replaces the other. */\r\nexport function chain<E>(\r\n theirs: ((event: E) => void) | undefined,\r\n ours: (event: E) => void,\r\n) {\r\n return (event: E) => {\r\n theirs?.(event);\r\n ours(event);\r\n };\r\n}\r\n"],"names":[],"mappings":";;;;;AAMA;;;;;AAKG;AACI;AAEP;AACO;AAEP;;;;AAIG;AACI;AAGP;;;;AAIG;;AAEI;AAEP;AACA;AAEA;;;;AAIG;;AAED;;AAGA;;AAEI;;;AAGA;;AAEF;;AAGF;AACF;AAEA;AACM;;AAKF;;AAEF;AACF;;"}
|
|
1
|
+
{"version":3,"file":"use-field-focus.js","sources":["../../src/hooks/use-field-focus.ts"],"sourcesContent":["'use client';\r\n\r\nimport { createContext, useContext, useRef, useState } from 'react';\r\nimport { cn } from '@/utils';\r\nimport { interactiveControlClassName } from '@/lib/interaction-styles';\r\n\r\n/**\r\n * Shared input field chrome (see \"Input fields and menus\" in COMPONENT-DESIGN.md).\r\n *\r\n * Fields keep their border when clicked or selected. Keyboard focus shows the\r\n * same outline as Button.\r\n */\r\nexport const fieldFocusOutlineClassName = 'outline-3 outline-offset-4 outline-landing-blue';\r\n\r\n/** Hover lift and press feedback shared with Button. */\r\nexport const fieldInteractionClassName = cn('rounded-control-lg', interactiveControlClassName);\r\n\r\n/**\r\n * Button-based field triggers (Dropdown, Select, date and month pickers): 16px\r\n * regular text, a white surface, and a border that only darkens on hover.\r\n * Buttons already show the focus outline for keyboard focus only.\r\n */\r\nexport const fieldTriggerClassName =\r\n 'h-form-control min-h-form-control max-h-form-control text-base font-normal text-foreground enabled:hover:text-foreground bg-background enabled:hover:bg-background border-input enabled:hover:border-input-hover aria-invalid:border-destructive enabled:aria-invalid:hover:border-destructive disabled:pointer-events-auto disabled:cursor-not-allowed';\r\n\r\n/**\r\n * Set by a component that draws the field chrome around an Input itself (for\r\n * example Autocomplete, whose icons sit beside the input), so the Input\r\n * doesn't lift or outline separately.\r\n */\r\nexport const FieldChromeContext = createContext(false);\r\nexport const useFieldChromeOwned = () => useContext(FieldChromeContext);\r\n\r\n/** A pointer press within this window counts the next focus as a click or tap. */\r\nconst POINTER_FOCUS_WINDOW = 800;\r\n\r\n/**\r\n * Text inputs match :focus-visible even when clicked, so CSS alone can't show\r\n * an outline for keyboard focus only. Spread `focusProps` on the field (or its\r\n * wrapper) and apply the outline while `keyboardFocus` is true.\r\n */\r\nexport function useFieldFocus() {\r\n const lastPointer = useRef(-Infinity);\r\n const [keyboardFocus, setKeyboardFocus] = useState(false);\r\n\r\n const focusProps = {\r\n onPointerDown: () => {\r\n lastPointer.current = performance.now();\r\n },\r\n onFocus: () => {\r\n setKeyboardFocus(performance.now() - lastPointer.current > POINTER_FOCUS_WINDOW);\r\n },\r\n onBlur: () => setKeyboardFocus(false),\r\n };\r\n\r\n return { keyboardFocus, focusProps };\r\n}\r\n\r\n/** Call a consumer's handler and then ours, so neither replaces the other. */\r\nexport function chain<E>(\r\n theirs: ((event: E) => void) | undefined,\r\n ours: (event: E) => void,\r\n) {\r\n return (event: E) => {\r\n theirs?.(event);\r\n ours(event);\r\n };\r\n}\r\n"],"names":[],"mappings":";;;;;AAMA;;;;;AAKG;AACI;AAEP;AACO;AAEP;;;;AAIG;AACI;AAGP;;;;AAIG;;AAEI;AAEP;AACA;AAEA;;;;AAIG;;AAED;;AAGA;;AAEI;;;AAGA;;AAEF;;AAGF;AACF;AAEA;AACM;;AAKF;;AAEF;AACF;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -27,14 +27,11 @@ export * from './components/option-list';
|
|
|
27
27
|
export * from './components/select';
|
|
28
28
|
export * from './components/label';
|
|
29
29
|
export * from './components/form-field';
|
|
30
|
-
export * from './components/
|
|
31
|
-
export * from './components/
|
|
32
|
-
export * from './components/
|
|
33
|
-
export * from './components/
|
|
34
|
-
export * from './components/
|
|
35
|
-
export * from './components/form-date-picker';
|
|
36
|
-
export * from './components/form-month-picker';
|
|
37
|
-
export * from './components/time-input-native';
|
|
30
|
+
export * from './components/checkbox-group';
|
|
31
|
+
export * from './components/checkbox-field';
|
|
32
|
+
export * from './components/date-picker';
|
|
33
|
+
export * from './components/month-picker';
|
|
34
|
+
export * from './components/time-input';
|
|
38
35
|
export * from './components/page-header';
|
|
39
36
|
export * from './components/popover';
|
|
40
37
|
export * from './components/skeleton';
|
|
@@ -71,4 +68,3 @@ export * from './components/animated-shiny-text';
|
|
|
71
68
|
export { default as MagneticButton } from './components/magnetic-button';
|
|
72
69
|
export * from './components/carousel';
|
|
73
70
|
export * from './components/input-otp';
|
|
74
|
-
export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField as HookFormField, useFormField, } from './components/form';
|
package/dist/index.js
CHANGED
|
@@ -23,15 +23,12 @@ export { FilterChip, FilterChipGroup } from './components/filter-chip.js';
|
|
|
23
23
|
export { CheckboxList, FilterMenu, optionListClassName, optionRowClassName } from './components/option-list.js';
|
|
24
24
|
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from './components/select.js';
|
|
25
25
|
export { FieldLabel, Label } from './components/label.js';
|
|
26
|
-
export { FormField } from './components/form-field.js';
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export { FormDatePicker } from './components/form-date-picker.js';
|
|
33
|
-
export { FormMonthPicker } from './components/form-month-picker.js';
|
|
34
|
-
export { TimeInputNative } from './components/time-input-native.js';
|
|
26
|
+
export { FormField, FormFieldReset, useFormField, useFormFieldControl } from './components/form-field.js';
|
|
27
|
+
export { CheckboxGroup } from './components/checkbox-group.js';
|
|
28
|
+
export { CheckboxField } from './components/checkbox-field.js';
|
|
29
|
+
export { DatePicker } from './components/date-picker.js';
|
|
30
|
+
export { MonthPicker } from './components/month-picker.js';
|
|
31
|
+
export { TimeInput } from './components/time-input.js';
|
|
35
32
|
export { PageHeader } from './components/page-header.js';
|
|
36
33
|
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from './components/popover.js';
|
|
37
34
|
export { Skeleton } from './components/skeleton.js';
|
|
@@ -52,7 +49,7 @@ export { DropdownGroup, DropdownOption, GroupableNavDropdown, GroupableRadioDrop
|
|
|
52
49
|
export { HoverCard, HoverCardContent, HoverCardTrigger } from './components/hover-card.js';
|
|
53
50
|
export { Paginator } from './components/paginator.js';
|
|
54
51
|
export { Progress } from './components/progress.js';
|
|
55
|
-
export { RadioGroup, RadioGroupItem } from './components/radio-group.js';
|
|
52
|
+
export { RadioGroup, RadioGroupItem, RadioVisual } from './components/radio-group.js';
|
|
56
53
|
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger } from './components/sheet.js';
|
|
57
54
|
export { Slider } from './components/slider.js';
|
|
58
55
|
export { Timeline, TimelineItem } from './components/timeline.js';
|
|
@@ -67,5 +64,4 @@ export { AnimatedShinyText } from './components/animated-shiny-text.js';
|
|
|
67
64
|
export { default as MagneticButton } from './components/magnetic-button.js';
|
|
68
65
|
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from './components/carousel.js';
|
|
69
66
|
export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from './components/input-otp.js';
|
|
70
|
-
export { Form, FormControl, FormDescription, FormItem, FormLabel, FormMessage, FormField as HookFormField, useFormField } from './components/form.js';
|
|
71
67
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3030,7 +3030,59 @@ const getDefaultConfig = () => {
|
|
|
3030
3030
|
orderSensitiveModifiers: ['*', '**', 'after', 'backdrop', 'before', 'details-content', 'file', 'first-letter', 'first-line', 'marker', 'placeholder', 'selection']
|
|
3031
3031
|
};
|
|
3032
3032
|
};
|
|
3033
|
-
const twMerge = /*#__PURE__*/createTailwindMerge(getDefaultConfig);
|
|
3034
3033
|
|
|
3035
|
-
|
|
3034
|
+
/**
|
|
3035
|
+
* @param baseConfig Config where other config will be merged into. This object will be mutated.
|
|
3036
|
+
* @param configExtension Partial config to merge into the `baseConfig`.
|
|
3037
|
+
*/
|
|
3038
|
+
const mergeConfigs = (baseConfig, {
|
|
3039
|
+
cacheSize,
|
|
3040
|
+
prefix,
|
|
3041
|
+
experimentalParseClassName,
|
|
3042
|
+
extend = {},
|
|
3043
|
+
override = {}
|
|
3044
|
+
}) => {
|
|
3045
|
+
overrideProperty(baseConfig, 'cacheSize', cacheSize);
|
|
3046
|
+
overrideProperty(baseConfig, 'prefix', prefix);
|
|
3047
|
+
overrideProperty(baseConfig, 'experimentalParseClassName', experimentalParseClassName);
|
|
3048
|
+
overrideConfigProperties(baseConfig.theme, override.theme);
|
|
3049
|
+
overrideConfigProperties(baseConfig.classGroups, override.classGroups);
|
|
3050
|
+
overrideConfigProperties(baseConfig.conflictingClassGroups, override.conflictingClassGroups);
|
|
3051
|
+
overrideConfigProperties(baseConfig.conflictingClassGroupModifiers, override.conflictingClassGroupModifiers);
|
|
3052
|
+
overrideProperty(baseConfig, 'orderSensitiveModifiers', override.orderSensitiveModifiers);
|
|
3053
|
+
mergeConfigProperties(baseConfig.theme, extend.theme);
|
|
3054
|
+
mergeConfigProperties(baseConfig.classGroups, extend.classGroups);
|
|
3055
|
+
mergeConfigProperties(baseConfig.conflictingClassGroups, extend.conflictingClassGroups);
|
|
3056
|
+
mergeConfigProperties(baseConfig.conflictingClassGroupModifiers, extend.conflictingClassGroupModifiers);
|
|
3057
|
+
mergeArrayProperties(baseConfig, extend, 'orderSensitiveModifiers');
|
|
3058
|
+
return baseConfig;
|
|
3059
|
+
};
|
|
3060
|
+
const overrideProperty = (baseObject, overrideKey, overrideValue) => {
|
|
3061
|
+
if (overrideValue !== undefined) {
|
|
3062
|
+
baseObject[overrideKey] = overrideValue;
|
|
3063
|
+
}
|
|
3064
|
+
};
|
|
3065
|
+
const overrideConfigProperties = (baseObject, overrideObject) => {
|
|
3066
|
+
if (overrideObject) {
|
|
3067
|
+
for (const key in overrideObject) {
|
|
3068
|
+
overrideProperty(baseObject, key, overrideObject[key]);
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
};
|
|
3072
|
+
const mergeConfigProperties = (baseObject, mergeObject) => {
|
|
3073
|
+
if (mergeObject) {
|
|
3074
|
+
for (const key in mergeObject) {
|
|
3075
|
+
mergeArrayProperties(baseObject, mergeObject, key);
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
};
|
|
3079
|
+
const mergeArrayProperties = (baseObject, mergeObject, key) => {
|
|
3080
|
+
const mergeValue = mergeObject[key];
|
|
3081
|
+
if (mergeValue !== undefined) {
|
|
3082
|
+
baseObject[key] = baseObject[key] ? baseObject[key].concat(mergeValue) : mergeValue;
|
|
3083
|
+
}
|
|
3084
|
+
};
|
|
3085
|
+
const extendTailwindMerge = (configExtension, ...createConfig) => typeof configExtension === 'function' ? createTailwindMerge(getDefaultConfig, configExtension, ...createConfig) : createTailwindMerge(() => mergeConfigs(getDefaultConfig(), configExtension), ...createConfig);
|
|
3086
|
+
|
|
3087
|
+
export { createTailwindMerge, extendTailwindMerge, fromTheme, getDefaultConfig, mergeConfigs, twJoin };
|
|
3036
3088
|
//# sourceMappingURL=bundle-mjs.js.map
|