@planningcenter/tapestry 4.14.0 → 4.15.0-rc.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/DataTable/ActiveFilters.d.ts +6 -1
- package/dist/components/DataTable/ActiveFilters.d.ts.map +1 -1
- package/dist/components/DataTable/ActiveFilters.js +18 -10
- package/dist/components/DataTable/ActiveFilters.js.map +1 -1
- package/dist/components/DataTable/CollectionEditorsStatic.js +2 -2
- package/dist/components/DataTable/CollectionEditorsStatic.js.map +1 -1
- package/dist/components/DataTable/DataTable.d.ts +8 -5
- package/dist/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.js +26 -14
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/DataTableColumn.d.ts +12 -3
- package/dist/components/DataTable/DataTableColumn.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableColumnTypes.js +4 -4
- package/dist/components/DataTable/DataTableColumnTypes.js.map +1 -1
- package/dist/components/DataTable/ResultsCount.d.ts +2 -2
- package/dist/components/DataTable/ResultsCount.d.ts.map +1 -1
- package/dist/components/DataTable/ResultsCount.js +8 -7
- package/dist/components/DataTable/ResultsCount.js.map +1 -1
- package/dist/components/DataTable/SelectAllBanner.d.ts.map +1 -1
- package/dist/components/DataTable/SelectAllBanner.js +5 -3
- package/dist/components/DataTable/SelectAllBanner.js.map +1 -1
- package/dist/components/DataTable/TableActions.d.ts.map +1 -1
- package/dist/components/DataTable/TableActions.js +5 -3
- package/dist/components/DataTable/TableActions.js.map +1 -1
- package/dist/components/DataTable/dateFilter.js +28 -10
- package/dist/components/DataTable/dateFilter.js.map +1 -1
- package/dist/components/DataTable/dayFilter.js +4 -3
- package/dist/components/DataTable/dayFilter.js.map +1 -1
- package/dist/components/DataTable/numberFilter.js +2 -2
- package/dist/components/DataTable/numberFilter.js.map +1 -1
- package/dist/components/DataTable/useIsNarrowViewport.d.ts.map +1 -1
- package/dist/components/DataTable/useIsNarrowViewport.js +3 -1
- package/dist/components/DataTable/useIsNarrowViewport.js.map +1 -1
- package/dist/components/DataTable/useResultsAnnouncement.d.ts.map +1 -1
- package/dist/components/DataTable/useResultsAnnouncement.js +3 -1
- package/dist/components/DataTable/useResultsAnnouncement.js.map +1 -1
- package/dist/components/DataTable/useSavedViewsClient.d.ts +9 -2
- package/dist/components/DataTable/useSavedViewsClient.d.ts.map +1 -1
- package/dist/components/DataTable/useSavedViewsClient.js +9 -2
- package/dist/components/DataTable/useSavedViewsClient.js.map +1 -1
- package/dist/components/DataTable/useShelfExpanded.d.ts +4 -3
- package/dist/components/DataTable/useShelfExpanded.d.ts.map +1 -1
- package/dist/components/DataTable/useShelfExpanded.js +21 -5
- package/dist/components/DataTable/useShelfExpanded.js.map +1 -1
- package/dist/components/DataTable/views.js +1 -4
- package/dist/components/DataTable/views.js.map +1 -1
- package/dist/components/button/ActionsDropdownIconButton.js +1 -1
- package/dist/components/button/ActionsDropdownIconButton.js.map +1 -1
- package/dist/components/button/IconButton.js +1 -1
- package/dist/components/button/IconButton.js.map +1 -1
- package/dist/components/combo-box/ComboBox.d.ts.map +1 -1
- package/dist/components/combo-box/ComboBox.js +17 -2
- package/dist/components/combo-box/ComboBox.js.map +1 -1
- package/dist/components/currency-input/CurrencyInput.d.ts +1 -1
- package/dist/components/currency-input/CurrencyInput.d.ts.map +1 -1
- package/dist/components/currency-input/CurrencyInput.js +4 -1
- package/dist/components/currency-input/CurrencyInput.js.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +1 -1
- package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
- package/dist/components/date-picker/DatePicker.js +72 -69
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/link/IconLink.js +1 -1
- package/dist/components/link/IconLink.js.map +1 -1
- package/dist/components/segmented-control/IconSegment.js +1 -1
- package/dist/components/segmented-control/IconSegment.js.map +1 -1
- package/dist/components/time-field/TimeField.d.ts.map +1 -1
- package/dist/components/time-field/TimeField.js +12 -9
- package/dist/components/time-field/TimeField.js.map +1 -1
- package/dist/reactRender.css +384 -379
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +384 -379
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/tapestryMount.css +384 -379
- package/dist/tapestryMount.css.map +1 -1
- package/dist/tapestryMountLegacy.css +384 -379
- package/dist/tapestryMountLegacy.css.map +1 -1
- package/dist/unstable.css +5 -0
- package/dist/unstable.css.map +1 -1
- package/dist/utilities/locale.d.ts +4 -4
- package/dist/utilities/locale.js +5 -34
- package/dist/utilities/locale.js.map +1 -1
- package/dist/utilities/useDateFieldLocale.js +2 -2
- package/dist/utilities/useDateFieldLocale.js.map +1 -1
- package/docs/components/DataTable.md +158 -0
- package/docs/llms.txt +3 -0
- package/package.json +5 -3
|
@@ -2,6 +2,7 @@ import { CalendarDate as $2aaf608024c21ca1$export$99faa760c7908e4f } from './../
|
|
|
2
2
|
import { today as $ad063034c8620db8$export$d0bdf45af03a6ea3, getLocalTimeZone as $ad063034c8620db8$export$aa8b41735afcabd2, isSameDay as $ad063034c8620db8$export$ea39ec197993aef0 } from './../../ext/@internationalized/date/dist/private/queries.js';
|
|
3
3
|
import { parseDate as $58246871e4652552$export$6b862160d295c8e } from './../../ext/@internationalized/date/dist/private/string.js';
|
|
4
4
|
import Icon from '../../utilities/Icon.js';
|
|
5
|
+
import { useTapestryLocale } from '../../utilities/locale.js';
|
|
5
6
|
import { useDateFieldLocale } from '../../utilities/useDateFieldLocale.js';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import React, { useState, useRef, useEffect, useMemo, useContext } from 'react';
|
|
@@ -14,10 +15,6 @@ import { ListBox, ListBoxItem } from 'react-aria-components/ListBox';
|
|
|
14
15
|
const _today = $ad063034c8620db8$export$d0bdf45af03a6ea3($ad063034c8620db8$export$aa8b41735afcabd2());
|
|
15
16
|
const MONTHS = Array.from({ length: 12 }, (_, i) => i);
|
|
16
17
|
const YEARS = Array.from({ length: 131 }, (_, i) => _today.year - 100 + i);
|
|
17
|
-
const shortMonthFormatter = new Intl.DateTimeFormat(undefined, {
|
|
18
|
-
month: "short",
|
|
19
|
-
});
|
|
20
|
-
const longMonthFormatter = new Intl.DateTimeFormat(undefined, { month: "long" });
|
|
21
18
|
function toCalendarDate(input) {
|
|
22
19
|
if (input === null)
|
|
23
20
|
return null;
|
|
@@ -39,6 +36,9 @@ function DatePickerCalendarBody({ activeOverlay, setActiveOverlay, }) {
|
|
|
39
36
|
const state = useContext(CalendarStateContext);
|
|
40
37
|
const focusedDate = state.focusedDate;
|
|
41
38
|
const today = $ad063034c8620db8$export$d0bdf45af03a6ea3($ad063034c8620db8$export$aa8b41735afcabd2());
|
|
39
|
+
const locale = useTapestryLocale();
|
|
40
|
+
const shortMonthFormatter = useMemo(() => new Intl.DateTimeFormat(locale, { month: "short" }), [locale]);
|
|
41
|
+
const longMonthFormatter = useMemo(() => new Intl.DateTimeFormat(locale, { month: "long" }), [locale]);
|
|
42
42
|
function handleOverlaySelectionChange(keys, onSelect) {
|
|
43
43
|
if (keys === "all")
|
|
44
44
|
return;
|
|
@@ -153,7 +153,7 @@ function isPartlyFilled(field) {
|
|
|
153
153
|
* @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-datepicker--docs | Storybook Documentation}
|
|
154
154
|
* @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}
|
|
155
155
|
*/
|
|
156
|
-
function DatePicker({ className, defaultValue, description, disabled, firstDayOfWeek, formatDateOnBlur = expandTwoDigitYearsViaPOSIX, hideLabel, invalid, isDateUnavailable, label, max, min, name, onBlur, onChange, onFocus, readOnly, required, size = "md", value, alwaysShowFourDigitYear = false, ...restProps }) {
|
|
156
|
+
function DatePicker({ className, defaultValue, description, disabled, firstDayOfWeek, formatDateOnBlur = expandTwoDigitYearsViaPOSIX, hideLabel, invalid, isDateUnavailable, label, max, min, name, onBlur, onChange, onFocus, onOpenChange, readOnly, required, size = "md", value, alwaysShowFourDigitYear = false, ...restProps }) {
|
|
157
157
|
const convertedMin = toCalendarDate(min) ?? undefined;
|
|
158
158
|
const convertedMax = toCalendarDate(max) ?? undefined;
|
|
159
159
|
const combinedClassName = classNames("tds-field tds-date-picker", {
|
|
@@ -186,73 +186,76 @@ function DatePicker({ className, defaultValue, description, disabled, firstDayOf
|
|
|
186
186
|
const [valueBeforeEdit, setValueBeforeEdit] = useState(computedValue);
|
|
187
187
|
const [openedPartlyFilled, setOpenedPartlyFilled] = useState(false);
|
|
188
188
|
const fieldRef = useRef(null);
|
|
189
|
+
const locale = useTapestryLocale();
|
|
189
190
|
const dateFieldLocale = useDateFieldLocale();
|
|
190
|
-
return (React.createElement(
|
|
191
|
-
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
return (React.createElement(I18nProvider, { locale: locale },
|
|
192
|
+
React.createElement(DatePicker$1, { ...restProps, "aria-label": hideLabel ? label : undefined, className: combinedClassName, isDateUnavailable: isDateUnavailable, isDisabled: disabled, isReadOnly: readOnly, isRequired: required, maxValue: convertedMax, minValue: convertedMin, onBlur: (event) => {
|
|
193
|
+
if (isPartlyFilled(fieldRef.current)) {
|
|
194
|
+
if (computedValue) {
|
|
195
|
+
setHeldValue(computedValue);
|
|
196
|
+
setComputedValue(null);
|
|
197
|
+
}
|
|
195
198
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
setComputedValue(heldValueRef.current);
|
|
201
|
-
}
|
|
202
|
-
else if (formatDateOnBlur && computedValue) {
|
|
203
|
-
const formattedValue = formatDateOnBlur(computedValue);
|
|
204
|
-
if (!$ad063034c8620db8$export$ea39ec197993aef0(formattedValue, computedValue)) {
|
|
205
|
-
setComputedValue(formattedValue);
|
|
199
|
+
else if (heldValueRef.current) {
|
|
200
|
+
// Refilled to the date react-aria still held, so it reported no change
|
|
201
|
+
setHeldValue(null);
|
|
202
|
+
setComputedValue(heldValueRef.current);
|
|
206
203
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
React.createElement(
|
|
249
|
-
React.createElement(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
204
|
+
else if (formatDateOnBlur && computedValue) {
|
|
205
|
+
const formattedValue = formatDateOnBlur(computedValue);
|
|
206
|
+
if (!$ad063034c8620db8$export$ea39ec197993aef0(formattedValue, computedValue)) {
|
|
207
|
+
setComputedValue(formattedValue);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
onBlur?.(event);
|
|
211
|
+
}, onChange: (newValue) => {
|
|
212
|
+
heldValueRef.current = null;
|
|
213
|
+
setHeldValue(null);
|
|
214
|
+
if (newValue === null && computedValue === null)
|
|
215
|
+
return;
|
|
216
|
+
setComputedValue(newValue);
|
|
217
|
+
}, onFocus: (event) => {
|
|
218
|
+
if (!heldValue)
|
|
219
|
+
setValueBeforeEdit(computedValue);
|
|
220
|
+
onFocus?.(event);
|
|
221
|
+
}, onOpenChange: (isOpen) => {
|
|
222
|
+
if (isOpen)
|
|
223
|
+
setOpenedPartlyFilled(isPartlyFilled(fieldRef.current));
|
|
224
|
+
else
|
|
225
|
+
setActiveOverlay(null);
|
|
226
|
+
onOpenChange?.(isOpen);
|
|
227
|
+
}, validate: () => (heldValue && required ? "Enter a full date" : null), value: heldValue ?? computedValue },
|
|
228
|
+
!hideLabel && React.createElement(Label, { className: "tds-field-label" }, label),
|
|
229
|
+
React.createElement(Group, { "aria-invalid": invalid || undefined, className: "tds-field-control tds-date-picker-field", ref: fieldRef },
|
|
230
|
+
React.createElement(I18nProvider, { locale: dateFieldLocale },
|
|
231
|
+
React.createElement(DateInput, { className: "tds-date-picker-input" }, (segment) => (React.createElement(DateSegment, { "aria-invalid": invalid || undefined, className: segment.type === "literal"
|
|
232
|
+
? "tds-field-date-segment-separator"
|
|
233
|
+
: "tds-field-date-segment", segment: segment.type === "year" &&
|
|
234
|
+
!segment.isPlaceholder &&
|
|
235
|
+
segment.value != null &&
|
|
236
|
+
alwaysShowFourDigitYear
|
|
237
|
+
? {
|
|
238
|
+
...segment,
|
|
239
|
+
text: new Intl.NumberFormat(undefined, {
|
|
240
|
+
minimumIntegerDigits: 4,
|
|
241
|
+
useGrouping: false,
|
|
242
|
+
}).format(segment.value),
|
|
243
|
+
}
|
|
244
|
+
: segment })))),
|
|
245
|
+
React.createElement(Button, { className: "tds-btn tds-btn--infield tds-date-picker-button" },
|
|
246
|
+
React.createElement(Icon, { "aria-hidden": true, symbol: "general#calendar" }))),
|
|
247
|
+
React.createElement(Popover, { className: classNames("tds-date-picker-popover", {
|
|
248
|
+
"tds-date-picker-popover--lg": size === "lg",
|
|
249
|
+
}), offset: 2 },
|
|
250
|
+
React.createElement(Dialog, null,
|
|
251
|
+
React.createElement(Calendar, { className: "tds-date-picker-calendar", defaultFocusedValue: openedPartlyFilled ? (valueBeforeEdit ?? undefined) : undefined, firstDayOfWeek: firstDayOfWeek, value: openedPartlyFilled ? null : undefined },
|
|
252
|
+
React.createElement(DatePickerCalendarBody, { activeOverlay: activeOverlay, setActiveOverlay: setActiveOverlay })))),
|
|
253
|
+
description && (React.createElement(Text, { elementType: "p", className: "tds-field-description", slot: "description" },
|
|
254
|
+
React.createElement(Icon, { "aria-hidden": true, className: "tds-field-description-invalid-icon", symbol: "general#exclamation-triangle" }),
|
|
255
|
+
description)),
|
|
256
|
+
name && (
|
|
257
|
+
// Submits the reported value, which react-aria's own input can't while it holds a partly filled date
|
|
258
|
+
React.createElement("input", { disabled: disabled, hidden: true, name: name, onChange: () => { }, type: "text", value: computedValue?.toString() ?? "" })))));
|
|
256
259
|
}
|
|
257
260
|
DatePicker.displayName = "DatePicker";
|
|
258
261
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sources":["../../../src/components/date-picker/DatePicker.tsx"],"sourcesContent":["import \"../button/btn.css\"\nimport \"../field/index.css\"\nimport \"./index.css\"\n\nimport {\n CalendarDate,\n type DateValue,\n getLocalTimeZone,\n isSameDay,\n parseDate,\n today as todayCalendar,\n} from \"@internationalized/date\"\nimport Icon from \"@utilities/Icon\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport { useDateFieldLocale } from \"@utilities/useDateFieldLocale\"\nimport classNames from \"classnames\"\nimport React, {\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { I18nProvider } from \"react-aria/I18nProvider\"\nimport { CalendarStateContext } from \"react-aria-components/Calendar\"\nimport {\n Button,\n Calendar,\n CalendarCell,\n CalendarGrid,\n CalendarGridBody,\n CalendarGridHeader,\n CalendarHeaderCell,\n DateInput,\n DatePicker as AriaDatePicker,\n type DatePickerProps as AriaDatePickerProps,\n DateSegment,\n Group,\n Label,\n Popover,\n Text,\n} from \"react-aria-components/DatePicker\"\nimport { Dialog } from \"react-aria-components/Dialog\"\nimport { ListBox, ListBoxItem } from \"react-aria-components/ListBox\"\n\nconst _today = todayCalendar(getLocalTimeZone())\nconst MONTHS = Array.from({ length: 12 }, (_, i) => i)\nconst YEARS = Array.from({ length: 131 }, (_, i) => _today.year - 100 + i)\nconst shortMonthFormatter = new Intl.DateTimeFormat(undefined, {\n month: \"short\",\n})\nconst longMonthFormatter = new Intl.DateTimeFormat(undefined, { month: \"long\" })\n\nexport type DatePickerSize = \"md\" | \"lg\"\n\nexport type DatePickerDateValue = DateValue | string\n\nfunction toCalendarDate(\n input: DatePickerDateValue | null | undefined\n): DateValue | null | undefined {\n if (input === null) return null\n if (input === undefined) return undefined\n\n if (typeof input === \"object\" && \"calendar\" in input) {\n return input\n }\n\n return parseDate(input)\n}\n\nexport interface DatePickerProps {\n /** If `true`, always shows leading zeros in the year segment for years less than 1000. Defaults to true. */\n alwaysShowFourDigitYear?: boolean\n /** The initial value for uncontrolled usage. Accepts a DateValue or ISO date string. */\n defaultValue?: DatePickerDateValue | null\n /** Helper text displayed below the component. Styled as error text when `invalid` is `true`. */\n description?: ReactNode\n /** Disables the input and calendar button. */\n disabled?: boolean\n /** Sets the first day of the week in the calendar. Defaults to locale-appropriate value. */\n firstDayOfWeek?: \"fri\" | \"mon\" | \"sat\" | \"sun\" | \"thu\" | \"tue\" | \"wed\"\n /**\n * Called on blur with the current complete value, if any, so it can be\n * normalized (e.g. correcting a 2-digit year to 4 digits). If the returned\n * value differs from the current one, the field updates to match.\n */\n formatDateOnBlur?: (date: DateValue) => DateValue\n /** If `true`, the `label` text is rendered as an `aria-label` instead of a visible label element. */\n hideLabel?: boolean\n /** Whether the input is in an invalid state. */\n invalid?: boolean\n /** Callback that returns `true` for dates that should be visible but not selectable. */\n isDateUnavailable?: (date: DateValue) => boolean\n /** Accessible label for the field. */\n label: string\n /** Maximum selectable date. Accepts a DateValue or ISO date string. */\n max?: DatePickerDateValue\n /** Minimum selectable date. Accepts a DateValue or ISO date string. */\n min?: DatePickerDateValue\n /** Called when the selected date changes. */\n onChange?: (value: DateValue | null) => void\n /** If `true`, allows the value to be read but not changed. */\n readOnly?: boolean\n /** If `true`, appends an asterisk at the end of the label text. */\n required?: boolean\n /** The size of the date picker. */\n size?: DatePickerSize\n /**\n * The controlled value. Accepts a DateValue or ISO date string.\n *\n * A partly filled date (e.g. `4/dd/2026`) reports `null` on blur but stays on\n * screen. Setting `null` again won't clear it; remount with a `key` to reset.\n */\n value?: DatePickerDateValue | null\n}\n\ntype AriaDatePickerPropsToOmit =\n | \"children\"\n | \"defaultOpen\"\n | \"granularity\"\n | \"hideTimeZone\"\n | \"hourCycle\"\n | \"pageBehavior\"\n | \"placeholderValue\"\n | \"shouldCloseOnSelect\"\n | \"shouldForceLeadingZeros\"\n | \"slot\"\n\ntype AriaDatePickerPropsToInclude = \"isOpen\" | \"name\" | \"onOpenChange\"\n\nexport type DatePickerElementProps = CombineAriaPropsWithCustomProps<\n AriaDatePickerProps<DateValue>,\n DatePickerProps,\n AriaDatePickerPropsToOmit,\n AriaDatePickerPropsToInclude\n>\n\nfunction DatePickerOverlay({\n children,\n variant,\n}: {\n children: ReactNode\n variant: \"month\" | \"year\"\n}) {\n return (\n <div\n aria-label={`Select ${variant}`}\n aria-modal=\"true\"\n className={`tds-date-picker-overlay tds-date-picker-overlay--${variant}`}\n role=\"dialog\"\n >\n {children}\n </div>\n )\n}\n\nfunction DatePickerCalendarBody({\n activeOverlay,\n setActiveOverlay,\n}: {\n activeOverlay: \"month\" | \"year\" | null\n setActiveOverlay: (overlay: \"month\" | \"year\" | null) => void\n}) {\n // Read and drive Calendar's focused date through its state context. This\n // lets react-aria-components own the \"open to selected month\" behavior:\n // when the popover opens, Calendar mounts and auto-focuses the DatePicker's\n // current value (whether typed into the input segments or set via `value`).\n const state = useContext(CalendarStateContext)!\n const focusedDate = state.focusedDate\n const today = todayCalendar(getLocalTimeZone())\n\n function handleOverlaySelectionChange(\n keys: \"all\" | Set<number | string>,\n onSelect: (key: number) => void\n ) {\n if (keys === \"all\") return\n const [first] = Array.from(keys)\n if (first !== undefined) onSelect(Number(first))\n }\n\n function handleMonthSelect(monthIndex: number) {\n state.setFocusedDate(new CalendarDate(focusedDate.year, monthIndex + 1, 1))\n setActiveOverlay(null)\n }\n\n function handleYearSelect(year: number) {\n state.setFocusedDate(new CalendarDate(year, focusedDate.month, 1))\n setActiveOverlay(null)\n }\n\n return (\n <>\n <header className=\"tds-date-picker-calendar-header\">\n <div className=\"tds-date-picker-calendar-heading\">\n <Button\n aria-expanded={activeOverlay === \"month\"}\n aria-haspopup=\"dialog\"\n className=\"tds-date-picker-calendar-overlay-trigger\"\n onPress={() =>\n setActiveOverlay(activeOverlay === \"month\" ? null : \"month\")\n }\n slot={null}\n >\n {longMonthFormatter.format(\n new Date(2000, focusedDate.month - 1, 1)\n )}\n </Button>\n <Button\n aria-expanded={activeOverlay === \"year\"}\n aria-haspopup=\"dialog\"\n className=\"tds-date-picker-calendar-overlay-trigger\"\n onPress={() =>\n setActiveOverlay(activeOverlay === \"year\" ? null : \"year\")\n }\n slot={null}\n >\n {focusedDate.year}\n </Button>\n </div>\n {activeOverlay ? (\n <Button\n aria-label={`Close ${activeOverlay} picker`}\n className=\"tds-date-picker-calendar-nav\"\n onPress={() => setActiveOverlay(null)}\n slot={null}\n >\n <Icon aria-hidden symbol=\"general#x\" />\n </Button>\n ) : (\n <>\n <Button\n aria-label=\"Go to today\"\n className=\"tds-date-picker-calendar-nav tds-date-picker-calendar-nav--lg\"\n style={{\n visibility:\n focusedDate.month === today.month &&\n focusedDate.year === today.year\n ? \"hidden\"\n : undefined,\n }}\n onPress={() => {\n state.setFocusedDate(today)\n state.setFocused(true)\n }}\n slot={null}\n >\n {/* TODO: Add to icon library and use Icon once icon is decided on */}\n <svg\n aria-hidden\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n className=\"symbol\"\n >\n <path d=\"M13.444 14.222H2.556V5.667h10.888zm0-12.444h-.777V.222h-1.556v1.556H4.889V.222H3.333v1.556h-.777a1.55 1.55 0 0 0-1.548 1.555L1 14.222a1.555 1.555 0 0 0 1.556 1.556h10.888A1.56 1.56 0 0 0 15 14.222V3.333a1.56 1.56 0 0 0-1.556-1.555\" />\n <circle cx=\"8\" cy=\"9.75\" r=\"2.25\" />\n </svg>\n </Button>\n <Button\n aria-label=\"Previous month\"\n className=\"tds-date-picker-calendar-nav\"\n slot=\"previous\"\n >\n <Icon aria-hidden symbol=\"general#left-chevron\" />\n </Button>\n <Button\n aria-label=\"Next month\"\n className=\"tds-date-picker-calendar-nav\"\n slot=\"next\"\n >\n <Icon aria-hidden symbol=\"general#right-chevron\" />\n </Button>\n </>\n )}\n </header>\n <div className=\"tds-date-picker-calendar-body\">\n {activeOverlay === \"month\" && (\n <DatePickerOverlay variant=\"month\">\n <ListBox\n aria-label=\"Months\"\n // eslint-disable-next-line jsx-a11y/no-autofocus -- focusing the active item on dialog open is required per ARIA authoring practices\n autoFocus\n className=\"tds-date-picker-overlay-list\"\n disallowEmptySelection\n escapeKeyBehavior=\"none\"\n layout=\"grid\"\n onSelectionChange={(keys) =>\n handleOverlaySelectionChange(keys, handleMonthSelect)\n }\n selectedKeys={[String(focusedDate.month - 1)]}\n selectionMode=\"single\"\n >\n {MONTHS.map((i) => {\n const date = new Date(2000, i, 1)\n const shortMonth = shortMonthFormatter.format(date)\n const longMonth = longMonthFormatter.format(date)\n\n return (\n <ListBoxItem\n className=\"tds-date-picker-overlay-cell\"\n id={String(i)}\n key={i}\n aria-label={longMonth}\n textValue={longMonth}\n >\n {shortMonth}\n </ListBoxItem>\n )\n })}\n </ListBox>\n </DatePickerOverlay>\n )}\n {activeOverlay === \"year\" && (\n <DatePickerOverlay variant=\"year\">\n <ListBox\n aria-label=\"Years\"\n // eslint-disable-next-line jsx-a11y/no-autofocus -- focusing the active item on dialog open is required per ARIA authoring practices\n autoFocus\n className=\"tds-date-picker-overlay-list\"\n disallowEmptySelection\n escapeKeyBehavior=\"none\"\n layout=\"grid\"\n onSelectionChange={(keys) =>\n handleOverlaySelectionChange(keys, handleYearSelect)\n }\n selectedKeys={[String(focusedDate.year)]}\n selectionMode=\"single\"\n >\n {YEARS.map((year) => (\n <ListBoxItem\n className=\"tds-date-picker-overlay-cell\"\n id={String(year)}\n key={year}\n textValue={String(year)}\n >\n {year}\n </ListBoxItem>\n ))}\n </ListBox>\n </DatePickerOverlay>\n )}\n <CalendarGrid className=\"tds-date-picker-calendar-grid\">\n <CalendarGridHeader className=\"tds-date-picker-calendar-grid-header\">\n {(day) => (\n <CalendarHeaderCell className=\"tds-date-picker-calendar-header-cell\">\n {day}\n </CalendarHeaderCell>\n )}\n </CalendarGridHeader>\n <CalendarGridBody className=\"tds-date-picker-calendar-grid-body\">\n {(date) => (\n <CalendarCell\n className=\"tds-date-picker-calendar-cell-button\"\n date={date}\n />\n )}\n </CalendarGridBody>\n </CalendarGrid>\n </div>\n </>\n )\n}\n\nfunction useValue({\n defaultValue,\n onChange,\n value,\n}: Pick<DatePickerProps, \"defaultValue\" | \"onChange\" | \"value\">): [\n DateValue | null,\n (value: DateValue | null) => void,\n] {\n const [uncontrolledValue, setUncontrolledValue] = useState(\n () => toCalendarDate(defaultValue) ?? null\n )\n // react-aria rebuilds the segments whenever the value's reference changes,\n // so a new object for the same date would wipe a partly typed one\n const valueKey = value == null ? value : value.toString()\n const controlledValue = useMemo(\n () => toCalendarDate(value) ?? null,\n // eslint-disable-next-line react-hooks/exhaustive-deps -- convert again only when the date changes, not the object\n [valueKey]\n )\n if (value !== undefined) {\n return [controlledValue, (...args) => onChange?.(...args)]\n }\n return [\n uncontrolledValue,\n (value) => {\n onChange?.(value)\n setUncontrolledValue(value)\n },\n ]\n}\n\n// Expands 2-digit years to 4 digits using the POSIX windowing rule: last 80 years and next 19 years.\nfunction expandTwoDigitYearsViaPOSIX(date: DateValue): DateValue {\n if (date.year >= 100) return date\n\n const currentYear = todayCalendar(getLocalTimeZone()).year\n const currentCentury = Math.floor(currentYear / 100) * 100\n const windowStart = currentYear - 80\n\n let fullYear = currentCentury + date.year\n if (fullYear < windowStart) fullYear += 100\n else if (fullYear > windowStart + 99) fullYear -= 100\n\n return date.set({ year: fullYear })\n}\n\nfunction isPartlyFilled(field: HTMLElement | null) {\n const segments = Array.from(\n field?.querySelectorAll('[data-type]:not([data-type=\"literal\"])') ?? []\n )\n const blankCount = segments.filter((segment) =>\n segment.hasAttribute(\"data-placeholder\")\n ).length\n return blankCount > 0 && blankCount < segments.length\n}\n\n/**\n * A date picker allows a user to select a particular date.\n * The input supports keyboard entry of individual day, month, and year segments;\n * the calendar offers month and year quick-pick overlays plus a \"go to today\" shortcut.\n *\n * The date picker automatically displays the value and calendar from the user's locale,\n * and does not require a specific date format.\n *\n * Values are exchanged as `DateValue` from `@internationalized/date`, but\n * `value`, `defaultValue`, `min`, and `max` also accept ISO date strings\n * (`\"YYYY-MM-DD\"`) for convenience. Restrict the selectable range with\n * `min`/`max`, or mark individual dates as unavailable via `isDateUnavailable`.\n *\n * Renders uncontrolled when `value` is omitted: pass `defaultValue` to set\n * the initial date without managing state.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-datepicker--docs | Storybook Documentation}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport function DatePicker({\n className,\n defaultValue,\n description,\n disabled,\n firstDayOfWeek,\n formatDateOnBlur = expandTwoDigitYearsViaPOSIX,\n hideLabel,\n invalid,\n isDateUnavailable,\n label,\n max,\n min,\n name,\n onBlur,\n onChange,\n onFocus,\n readOnly,\n required,\n size = \"md\",\n value,\n alwaysShowFourDigitYear = false,\n ...restProps\n}: DatePickerElementProps) {\n const convertedMin = toCalendarDate(min) ?? undefined\n const convertedMax = toCalendarDate(max) ?? undefined\n\n const combinedClassName = classNames(\n \"tds-field tds-date-picker\",\n {\n \"tds-date-picker--lg\": size === \"lg\",\n \"tds-field--lg\": size === \"lg\",\n },\n className\n )\n\n const [activeOverlay, setActiveOverlay] = useState<\"month\" | \"year\" | null>(\n null\n )\n\n const [computedValue, setComputedValue] = useValue({\n defaultValue,\n onChange,\n value,\n })\n\n // react-aria only reports complete dates, and rebuilds the segments whenever\n // its value changes. So once a partly filled date reports null, react-aria\n // keeps the last complete date it held, or it would wipe the partial text.\n // See adobe/react-spectrum#9624 and #9801.\n const [heldValue, setHeldValue] = useState<DateValue | null>(null)\n const valueKey = computedValue?.toString() ?? null\n const [lastValueKey, setLastValueKey] = useState(valueKey)\n if (valueKey !== lastValueKey) {\n setLastValueKey(valueKey)\n if (computedValue) setHeldValue(null)\n }\n // onBlur reads this; react-aria can report a change earlier in the same blur event\n const heldValueRef = useRef(heldValue)\n useEffect(() => {\n heldValueRef.current = heldValue\n }, [heldValue])\n\n const [valueBeforeEdit, setValueBeforeEdit] = useState(computedValue)\n const [openedPartlyFilled, setOpenedPartlyFilled] = useState(false)\n const fieldRef = useRef<HTMLDivElement>(null)\n\n const dateFieldLocale = useDateFieldLocale()\n\n return (\n <AriaDatePicker\n {...restProps}\n aria-label={hideLabel ? label : undefined}\n className={combinedClassName}\n isDateUnavailable={isDateUnavailable}\n isDisabled={disabled}\n isReadOnly={readOnly}\n isRequired={required}\n maxValue={convertedMax}\n minValue={convertedMin}\n onBlur={(event) => {\n if (isPartlyFilled(fieldRef.current)) {\n if (computedValue) {\n setHeldValue(computedValue)\n setComputedValue(null)\n }\n } else if (heldValueRef.current) {\n // Refilled to the date react-aria still held, so it reported no change\n setHeldValue(null)\n setComputedValue(heldValueRef.current)\n } else if (formatDateOnBlur && computedValue) {\n const formattedValue = formatDateOnBlur(computedValue)\n if (!isSameDay(formattedValue, computedValue)) {\n setComputedValue(formattedValue)\n }\n }\n onBlur?.(event)\n }}\n onChange={(newValue) => {\n heldValueRef.current = null\n setHeldValue(null)\n if (newValue === null && computedValue === null) return\n setComputedValue(newValue)\n }}\n onFocus={(event) => {\n if (!heldValue) setValueBeforeEdit(computedValue)\n onFocus?.(event)\n }}\n onOpenChange={(isOpen) => {\n if (isOpen) setOpenedPartlyFilled(isPartlyFilled(fieldRef.current))\n else setActiveOverlay(null)\n }}\n validate={() => (heldValue && required ? \"Enter a full date\" : null)}\n value={heldValue ?? computedValue}\n >\n {!hideLabel && <Label className=\"tds-field-label\">{label}</Label>}\n <Group\n aria-invalid={invalid || undefined}\n className=\"tds-field-control tds-date-picker-field\"\n ref={fieldRef}\n >\n <I18nProvider locale={dateFieldLocale}>\n <DateInput className=\"tds-date-picker-input\">\n {(segment) => (\n <DateSegment\n aria-invalid={invalid || undefined}\n className={\n segment.type === \"literal\"\n ? \"tds-field-date-segment-separator\"\n : \"tds-field-date-segment\"\n }\n segment={\n segment.type === \"year\" &&\n !segment.isPlaceholder &&\n segment.value != null &&\n alwaysShowFourDigitYear\n ? {\n ...segment,\n text: new Intl.NumberFormat(undefined, {\n minimumIntegerDigits: 4,\n useGrouping: false,\n }).format(segment.value),\n }\n : segment\n }\n />\n )}\n </DateInput>\n </I18nProvider>\n <Button className=\"tds-btn tds-btn--infield tds-date-picker-button\">\n <Icon aria-hidden symbol=\"general#calendar\" />\n </Button>\n </Group>\n <Popover\n className={classNames(\"tds-date-picker-popover\", {\n \"tds-date-picker-popover--lg\": size === \"lg\",\n })}\n offset={2}\n >\n <Dialog>\n <Calendar\n className=\"tds-date-picker-calendar\"\n defaultFocusedValue={\n openedPartlyFilled ? (valueBeforeEdit ?? undefined) : undefined\n }\n firstDayOfWeek={firstDayOfWeek}\n value={openedPartlyFilled ? null : undefined}\n >\n <DatePickerCalendarBody\n activeOverlay={activeOverlay}\n setActiveOverlay={setActiveOverlay}\n />\n </Calendar>\n </Dialog>\n </Popover>\n {description && (\n <Text\n elementType=\"p\"\n className=\"tds-field-description\"\n slot=\"description\"\n >\n <Icon\n aria-hidden\n className=\"tds-field-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n />\n {description}\n </Text>\n )}\n {name && (\n // Submits the reported value, which react-aria's own input can't while it holds a partly filled date\n <input\n disabled={disabled}\n hidden\n name={name}\n onChange={() => {}}\n type=\"text\"\n value={computedValue?.toString() ?? \"\"}\n />\n )}\n </AriaDatePicker>\n )\n}\n\nDatePicker.displayName = \"DatePicker\"\n"],"names":["todayC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EAAC,oCAAoC,EAC9C,MAAM,EAAC,8BAA8B,EAAA,CACrC;AACD,YAAA,WAAW,CACP,CACR;AACA,QAAA,IAAI;;AAEH,QAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EACE,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAA,IAAA,EACN,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAK,EAAE,CAAC,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAA,CACtC,CACH,CACc;AAErB;AAEA,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sources":["../../../src/components/date-picker/DatePicker.tsx"],"sourcesContent":["import \"../button/btn.css\"\nimport \"../field/index.css\"\nimport \"./index.css\"\n\nimport {\n CalendarDate,\n type DateValue,\n getLocalTimeZone,\n isSameDay,\n parseDate,\n today as todayCalendar,\n} from \"@internationalized/date\"\nimport Icon from \"@utilities/Icon\"\nimport { useTapestryLocale } from \"@utilities/locale\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport { useDateFieldLocale } from \"@utilities/useDateFieldLocale\"\nimport classNames from \"classnames\"\nimport React, {\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { I18nProvider } from \"react-aria/I18nProvider\"\nimport { CalendarStateContext } from \"react-aria-components/Calendar\"\nimport {\n Button,\n Calendar,\n CalendarCell,\n CalendarGrid,\n CalendarGridBody,\n CalendarGridHeader,\n CalendarHeaderCell,\n DateInput,\n DatePicker as AriaDatePicker,\n type DatePickerProps as AriaDatePickerProps,\n DateSegment,\n Group,\n Label,\n Popover,\n Text,\n} from \"react-aria-components/DatePicker\"\nimport { Dialog } from \"react-aria-components/Dialog\"\nimport { ListBox, ListBoxItem } from \"react-aria-components/ListBox\"\n\nconst _today = todayCalendar(getLocalTimeZone())\nconst MONTHS = Array.from({ length: 12 }, (_, i) => i)\nconst YEARS = Array.from({ length: 131 }, (_, i) => _today.year - 100 + i)\n\nexport type DatePickerSize = \"md\" | \"lg\"\n\nexport type DatePickerDateValue = DateValue | string\n\nfunction toCalendarDate(\n input: DatePickerDateValue | null | undefined\n): DateValue | null | undefined {\n if (input === null) return null\n if (input === undefined) return undefined\n\n if (typeof input === \"object\" && \"calendar\" in input) {\n return input\n }\n\n return parseDate(input)\n}\n\nexport interface DatePickerProps {\n /** If `true`, always shows leading zeros in the year segment for years less than 1000. Defaults to true. */\n alwaysShowFourDigitYear?: boolean\n /** The initial value for uncontrolled usage. Accepts a DateValue or ISO date string. */\n defaultValue?: DatePickerDateValue | null\n /** Helper text displayed below the component. Styled as error text when `invalid` is `true`. */\n description?: ReactNode\n /** Disables the input and calendar button. */\n disabled?: boolean\n /** Sets the first day of the week in the calendar. Defaults to locale-appropriate value. */\n firstDayOfWeek?: \"fri\" | \"mon\" | \"sat\" | \"sun\" | \"thu\" | \"tue\" | \"wed\"\n /**\n * Called on blur with the current complete value, if any, so it can be\n * normalized (e.g. correcting a 2-digit year to 4 digits). If the returned\n * value differs from the current one, the field updates to match.\n */\n formatDateOnBlur?: (date: DateValue) => DateValue\n /** If `true`, the `label` text is rendered as an `aria-label` instead of a visible label element. */\n hideLabel?: boolean\n /** Whether the input is in an invalid state. */\n invalid?: boolean\n /** Callback that returns `true` for dates that should be visible but not selectable. */\n isDateUnavailable?: (date: DateValue) => boolean\n /** Accessible label for the field. */\n label: string\n /** Maximum selectable date. Accepts a DateValue or ISO date string. */\n max?: DatePickerDateValue\n /** Minimum selectable date. Accepts a DateValue or ISO date string. */\n min?: DatePickerDateValue\n /** Called when the selected date changes. */\n onChange?: (value: DateValue | null) => void\n /** If `true`, allows the value to be read but not changed. */\n readOnly?: boolean\n /** If `true`, appends an asterisk at the end of the label text. */\n required?: boolean\n /** The size of the date picker. */\n size?: DatePickerSize\n /**\n * The controlled value. Accepts a DateValue or ISO date string.\n *\n * A partly filled date (e.g. `4/dd/2026`) reports `null` on blur but stays on\n * screen. Setting `null` again won't clear it; remount with a `key` to reset.\n */\n value?: DatePickerDateValue | null\n}\n\ntype AriaDatePickerPropsToOmit =\n | \"children\"\n | \"defaultOpen\"\n | \"granularity\"\n | \"hideTimeZone\"\n | \"hourCycle\"\n | \"pageBehavior\"\n | \"placeholderValue\"\n | \"shouldCloseOnSelect\"\n | \"shouldForceLeadingZeros\"\n | \"slot\"\n\ntype AriaDatePickerPropsToInclude = \"isOpen\" | \"name\" | \"onOpenChange\"\n\nexport type DatePickerElementProps = CombineAriaPropsWithCustomProps<\n AriaDatePickerProps<DateValue>,\n DatePickerProps,\n AriaDatePickerPropsToOmit,\n AriaDatePickerPropsToInclude\n>\n\nfunction DatePickerOverlay({\n children,\n variant,\n}: {\n children: ReactNode\n variant: \"month\" | \"year\"\n}) {\n return (\n <div\n aria-label={`Select ${variant}`}\n aria-modal=\"true\"\n className={`tds-date-picker-overlay tds-date-picker-overlay--${variant}`}\n role=\"dialog\"\n >\n {children}\n </div>\n )\n}\n\nfunction DatePickerCalendarBody({\n activeOverlay,\n setActiveOverlay,\n}: {\n activeOverlay: \"month\" | \"year\" | null\n setActiveOverlay: (overlay: \"month\" | \"year\" | null) => void\n}) {\n // Read and drive Calendar's focused date through its state context. This\n // lets react-aria-components own the \"open to selected month\" behavior:\n // when the popover opens, Calendar mounts and auto-focuses the DatePicker's\n // current value (whether typed into the input segments or set via `value`).\n const state = useContext(CalendarStateContext)!\n const focusedDate = state.focusedDate\n const today = todayCalendar(getLocalTimeZone())\n const locale = useTapestryLocale()\n const shortMonthFormatter = useMemo(\n () => new Intl.DateTimeFormat(locale, { month: \"short\" }),\n [locale]\n )\n const longMonthFormatter = useMemo(\n () => new Intl.DateTimeFormat(locale, { month: \"long\" }),\n [locale]\n )\n\n function handleOverlaySelectionChange(\n keys: \"all\" | Set<number | string>,\n onSelect: (key: number) => void\n ) {\n if (keys === \"all\") return\n const [first] = Array.from(keys)\n if (first !== undefined) onSelect(Number(first))\n }\n\n function handleMonthSelect(monthIndex: number) {\n state.setFocusedDate(new CalendarDate(focusedDate.year, monthIndex + 1, 1))\n setActiveOverlay(null)\n }\n\n function handleYearSelect(year: number) {\n state.setFocusedDate(new CalendarDate(year, focusedDate.month, 1))\n setActiveOverlay(null)\n }\n\n return (\n <>\n <header className=\"tds-date-picker-calendar-header\">\n <div className=\"tds-date-picker-calendar-heading\">\n <Button\n aria-expanded={activeOverlay === \"month\"}\n aria-haspopup=\"dialog\"\n className=\"tds-date-picker-calendar-overlay-trigger\"\n onPress={() =>\n setActiveOverlay(activeOverlay === \"month\" ? null : \"month\")\n }\n slot={null}\n >\n {longMonthFormatter.format(\n new Date(2000, focusedDate.month - 1, 1)\n )}\n </Button>\n <Button\n aria-expanded={activeOverlay === \"year\"}\n aria-haspopup=\"dialog\"\n className=\"tds-date-picker-calendar-overlay-trigger\"\n onPress={() =>\n setActiveOverlay(activeOverlay === \"year\" ? null : \"year\")\n }\n slot={null}\n >\n {focusedDate.year}\n </Button>\n </div>\n {activeOverlay ? (\n <Button\n aria-label={`Close ${activeOverlay} picker`}\n className=\"tds-date-picker-calendar-nav\"\n onPress={() => setActiveOverlay(null)}\n slot={null}\n >\n <Icon aria-hidden symbol=\"general#x\" />\n </Button>\n ) : (\n <>\n <Button\n aria-label=\"Go to today\"\n className=\"tds-date-picker-calendar-nav tds-date-picker-calendar-nav--lg\"\n style={{\n visibility:\n focusedDate.month === today.month &&\n focusedDate.year === today.year\n ? \"hidden\"\n : undefined,\n }}\n onPress={() => {\n state.setFocusedDate(today)\n state.setFocused(true)\n }}\n slot={null}\n >\n {/* TODO: Add to icon library and use Icon once icon is decided on */}\n <svg\n aria-hidden\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n className=\"symbol\"\n >\n <path d=\"M13.444 14.222H2.556V5.667h10.888zm0-12.444h-.777V.222h-1.556v1.556H4.889V.222H3.333v1.556h-.777a1.55 1.55 0 0 0-1.548 1.555L1 14.222a1.555 1.555 0 0 0 1.556 1.556h10.888A1.56 1.56 0 0 0 15 14.222V3.333a1.56 1.56 0 0 0-1.556-1.555\" />\n <circle cx=\"8\" cy=\"9.75\" r=\"2.25\" />\n </svg>\n </Button>\n <Button\n aria-label=\"Previous month\"\n className=\"tds-date-picker-calendar-nav\"\n slot=\"previous\"\n >\n <Icon aria-hidden symbol=\"general#left-chevron\" />\n </Button>\n <Button\n aria-label=\"Next month\"\n className=\"tds-date-picker-calendar-nav\"\n slot=\"next\"\n >\n <Icon aria-hidden symbol=\"general#right-chevron\" />\n </Button>\n </>\n )}\n </header>\n <div className=\"tds-date-picker-calendar-body\">\n {activeOverlay === \"month\" && (\n <DatePickerOverlay variant=\"month\">\n <ListBox\n aria-label=\"Months\"\n // eslint-disable-next-line jsx-a11y/no-autofocus -- focusing the active item on dialog open is required per ARIA authoring practices\n autoFocus\n className=\"tds-date-picker-overlay-list\"\n disallowEmptySelection\n escapeKeyBehavior=\"none\"\n layout=\"grid\"\n onSelectionChange={(keys) =>\n handleOverlaySelectionChange(keys, handleMonthSelect)\n }\n selectedKeys={[String(focusedDate.month - 1)]}\n selectionMode=\"single\"\n >\n {MONTHS.map((i) => {\n const date = new Date(2000, i, 1)\n const shortMonth = shortMonthFormatter.format(date)\n const longMonth = longMonthFormatter.format(date)\n\n return (\n <ListBoxItem\n className=\"tds-date-picker-overlay-cell\"\n id={String(i)}\n key={i}\n aria-label={longMonth}\n textValue={longMonth}\n >\n {shortMonth}\n </ListBoxItem>\n )\n })}\n </ListBox>\n </DatePickerOverlay>\n )}\n {activeOverlay === \"year\" && (\n <DatePickerOverlay variant=\"year\">\n <ListBox\n aria-label=\"Years\"\n // eslint-disable-next-line jsx-a11y/no-autofocus -- focusing the active item on dialog open is required per ARIA authoring practices\n autoFocus\n className=\"tds-date-picker-overlay-list\"\n disallowEmptySelection\n escapeKeyBehavior=\"none\"\n layout=\"grid\"\n onSelectionChange={(keys) =>\n handleOverlaySelectionChange(keys, handleYearSelect)\n }\n selectedKeys={[String(focusedDate.year)]}\n selectionMode=\"single\"\n >\n {YEARS.map((year) => (\n <ListBoxItem\n className=\"tds-date-picker-overlay-cell\"\n id={String(year)}\n key={year}\n textValue={String(year)}\n >\n {year}\n </ListBoxItem>\n ))}\n </ListBox>\n </DatePickerOverlay>\n )}\n <CalendarGrid className=\"tds-date-picker-calendar-grid\">\n <CalendarGridHeader className=\"tds-date-picker-calendar-grid-header\">\n {(day) => (\n <CalendarHeaderCell className=\"tds-date-picker-calendar-header-cell\">\n {day}\n </CalendarHeaderCell>\n )}\n </CalendarGridHeader>\n <CalendarGridBody className=\"tds-date-picker-calendar-grid-body\">\n {(date) => (\n <CalendarCell\n className=\"tds-date-picker-calendar-cell-button\"\n date={date}\n />\n )}\n </CalendarGridBody>\n </CalendarGrid>\n </div>\n </>\n )\n}\n\nfunction useValue({\n defaultValue,\n onChange,\n value,\n}: Pick<DatePickerProps, \"defaultValue\" | \"onChange\" | \"value\">): [\n DateValue | null,\n (value: DateValue | null) => void,\n] {\n const [uncontrolledValue, setUncontrolledValue] = useState(\n () => toCalendarDate(defaultValue) ?? null\n )\n // react-aria rebuilds the segments whenever the value's reference changes,\n // so a new object for the same date would wipe a partly typed one\n const valueKey = value == null ? value : value.toString()\n const controlledValue = useMemo(\n () => toCalendarDate(value) ?? null,\n // eslint-disable-next-line react-hooks/exhaustive-deps -- convert again only when the date changes, not the object\n [valueKey]\n )\n if (value !== undefined) {\n return [controlledValue, (...args) => onChange?.(...args)]\n }\n return [\n uncontrolledValue,\n (value) => {\n onChange?.(value)\n setUncontrolledValue(value)\n },\n ]\n}\n\n// Expands 2-digit years to 4 digits using the POSIX windowing rule: last 80 years and next 19 years.\nfunction expandTwoDigitYearsViaPOSIX(date: DateValue): DateValue {\n if (date.year >= 100) return date\n\n const currentYear = todayCalendar(getLocalTimeZone()).year\n const currentCentury = Math.floor(currentYear / 100) * 100\n const windowStart = currentYear - 80\n\n let fullYear = currentCentury + date.year\n if (fullYear < windowStart) fullYear += 100\n else if (fullYear > windowStart + 99) fullYear -= 100\n\n return date.set({ year: fullYear })\n}\n\nfunction isPartlyFilled(field: HTMLElement | null) {\n const segments = Array.from(\n field?.querySelectorAll('[data-type]:not([data-type=\"literal\"])') ?? []\n )\n const blankCount = segments.filter((segment) =>\n segment.hasAttribute(\"data-placeholder\")\n ).length\n return blankCount > 0 && blankCount < segments.length\n}\n\n/**\n * A date picker allows a user to select a particular date.\n * The input supports keyboard entry of individual day, month, and year segments;\n * the calendar offers month and year quick-pick overlays plus a \"go to today\" shortcut.\n *\n * The date picker automatically displays the value and calendar from the user's locale,\n * and does not require a specific date format.\n *\n * Values are exchanged as `DateValue` from `@internationalized/date`, but\n * `value`, `defaultValue`, `min`, and `max` also accept ISO date strings\n * (`\"YYYY-MM-DD\"`) for convenience. Restrict the selectable range with\n * `min`/`max`, or mark individual dates as unavailable via `isDateUnavailable`.\n *\n * Renders uncontrolled when `value` is omitted: pass `defaultValue` to set\n * the initial date without managing state.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-datepicker--docs | Storybook Documentation}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport function DatePicker({\n className,\n defaultValue,\n description,\n disabled,\n firstDayOfWeek,\n formatDateOnBlur = expandTwoDigitYearsViaPOSIX,\n hideLabel,\n invalid,\n isDateUnavailable,\n label,\n max,\n min,\n name,\n onBlur,\n onChange,\n onFocus,\n onOpenChange,\n readOnly,\n required,\n size = \"md\",\n value,\n alwaysShowFourDigitYear = false,\n ...restProps\n}: DatePickerElementProps) {\n const convertedMin = toCalendarDate(min) ?? undefined\n const convertedMax = toCalendarDate(max) ?? undefined\n\n const combinedClassName = classNames(\n \"tds-field tds-date-picker\",\n {\n \"tds-date-picker--lg\": size === \"lg\",\n \"tds-field--lg\": size === \"lg\",\n },\n className\n )\n\n const [activeOverlay, setActiveOverlay] = useState<\"month\" | \"year\" | null>(\n null\n )\n\n const [computedValue, setComputedValue] = useValue({\n defaultValue,\n onChange,\n value,\n })\n\n // react-aria only reports complete dates, and rebuilds the segments whenever\n // its value changes. So once a partly filled date reports null, react-aria\n // keeps the last complete date it held, or it would wipe the partial text.\n // See adobe/react-spectrum#9624 and #9801.\n const [heldValue, setHeldValue] = useState<DateValue | null>(null)\n const valueKey = computedValue?.toString() ?? null\n const [lastValueKey, setLastValueKey] = useState(valueKey)\n if (valueKey !== lastValueKey) {\n setLastValueKey(valueKey)\n if (computedValue) setHeldValue(null)\n }\n // onBlur reads this; react-aria can report a change earlier in the same blur event\n const heldValueRef = useRef(heldValue)\n useEffect(() => {\n heldValueRef.current = heldValue\n }, [heldValue])\n\n const [valueBeforeEdit, setValueBeforeEdit] = useState(computedValue)\n const [openedPartlyFilled, setOpenedPartlyFilled] = useState(false)\n const fieldRef = useRef<HTMLDivElement>(null)\n\n const locale = useTapestryLocale()\n const dateFieldLocale = useDateFieldLocale()\n\n return (\n <I18nProvider locale={locale}>\n <AriaDatePicker\n {...restProps}\n aria-label={hideLabel ? label : undefined}\n className={combinedClassName}\n isDateUnavailable={isDateUnavailable}\n isDisabled={disabled}\n isReadOnly={readOnly}\n isRequired={required}\n maxValue={convertedMax}\n minValue={convertedMin}\n onBlur={(event) => {\n if (isPartlyFilled(fieldRef.current)) {\n if (computedValue) {\n setHeldValue(computedValue)\n setComputedValue(null)\n }\n } else if (heldValueRef.current) {\n // Refilled to the date react-aria still held, so it reported no change\n setHeldValue(null)\n setComputedValue(heldValueRef.current)\n } else if (formatDateOnBlur && computedValue) {\n const formattedValue = formatDateOnBlur(computedValue)\n if (!isSameDay(formattedValue, computedValue)) {\n setComputedValue(formattedValue)\n }\n }\n onBlur?.(event)\n }}\n onChange={(newValue) => {\n heldValueRef.current = null\n setHeldValue(null)\n if (newValue === null && computedValue === null) return\n setComputedValue(newValue)\n }}\n onFocus={(event) => {\n if (!heldValue) setValueBeforeEdit(computedValue)\n onFocus?.(event)\n }}\n onOpenChange={(isOpen) => {\n if (isOpen) setOpenedPartlyFilled(isPartlyFilled(fieldRef.current))\n else setActiveOverlay(null)\n onOpenChange?.(isOpen)\n }}\n validate={() => (heldValue && required ? \"Enter a full date\" : null)}\n value={heldValue ?? computedValue}\n >\n {!hideLabel && <Label className=\"tds-field-label\">{label}</Label>}\n <Group\n aria-invalid={invalid || undefined}\n className=\"tds-field-control tds-date-picker-field\"\n ref={fieldRef}\n >\n <I18nProvider locale={dateFieldLocale}>\n <DateInput className=\"tds-date-picker-input\">\n {(segment) => (\n <DateSegment\n aria-invalid={invalid || undefined}\n className={\n segment.type === \"literal\"\n ? \"tds-field-date-segment-separator\"\n : \"tds-field-date-segment\"\n }\n segment={\n segment.type === \"year\" &&\n !segment.isPlaceholder &&\n segment.value != null &&\n alwaysShowFourDigitYear\n ? {\n ...segment,\n text: new Intl.NumberFormat(undefined, {\n minimumIntegerDigits: 4,\n useGrouping: false,\n }).format(segment.value),\n }\n : segment\n }\n />\n )}\n </DateInput>\n </I18nProvider>\n <Button className=\"tds-btn tds-btn--infield tds-date-picker-button\">\n <Icon aria-hidden symbol=\"general#calendar\" />\n </Button>\n </Group>\n <Popover\n className={classNames(\"tds-date-picker-popover\", {\n \"tds-date-picker-popover--lg\": size === \"lg\",\n })}\n offset={2}\n >\n <Dialog>\n <Calendar\n className=\"tds-date-picker-calendar\"\n defaultFocusedValue={\n openedPartlyFilled ? (valueBeforeEdit ?? undefined) : undefined\n }\n firstDayOfWeek={firstDayOfWeek}\n value={openedPartlyFilled ? null : undefined}\n >\n <DatePickerCalendarBody\n activeOverlay={activeOverlay}\n setActiveOverlay={setActiveOverlay}\n />\n </Calendar>\n </Dialog>\n </Popover>\n {description && (\n <Text\n elementType=\"p\"\n className=\"tds-field-description\"\n slot=\"description\"\n >\n <Icon\n aria-hidden\n className=\"tds-field-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n />\n {description}\n </Text>\n )}\n {name && (\n // Submits the reported value, which react-aria's own input can't while it holds a partly filled date\n <input\n disabled={disabled}\n hidden\n name={name}\n onChange={() => {}}\n type=\"text\"\n value={computedValue?.toString() ?? \"\"}\n />\n )}\n </AriaDatePicker>\n </I18nProvider>\n )\n}\n\nDatePicker.displayName = \"DatePicker\"\n"],"names":["todayCalendar","getLocalTimeZone","parseDate","CalendarDate","AriaDatePicker","isSameDay"],"mappings":";;;;;;;;;;;;;;AA+CA,MAAM,MAAM,GAAGA,yCAAa,CAACC,yCAAgB,EAAE,CAAC;AAChD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACtD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;AAM1E,SAAS,cAAc,CACrB,KAA6C,EAAA;IAE7C,IAAI,KAAK,KAAK,IAAI;AAAE,QAAA,OAAO,IAAI;IAC/B,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IAEzC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,IAAI,KAAK,EAAE;AACpD,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,OAAOC,wCAAS,CAAC,KAAK,CAAC;AACzB;AAqEA,SAAS,iBAAiB,CAAC,EACzB,QAAQ,EACR,OAAO,GAIR,EAAA;IACC,QACE,2CACc,CAAA,OAAA,EAAU,OAAO,EAAE,EAAA,YAAA,EACpB,MAAM,EACjB,SAAS,EAAE,oDAAoD,OAAO,CAAA,CAAE,EACxE,IAAI,EAAC,QAAQ,EAAA,EAEZ,QAAQ,CACL;AAEV;AAEA,SAAS,sBAAsB,CAAC,EAC9B,aAAa,EACb,gBAAgB,GAIjB,EAAA;;;;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BAAA,KAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,EACP,SAAS,EAAC,0BAA0B,EACpC,mBAAmB,EACjB,kBAAkB,IAAI,eAAe,IAAI,SAAS,IAAI,SAAS,EAEjE,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,EAAA;AAE5C,wBAAA,KAAA,CAAA,aAAA,CAAC,sBAAsB,EAAA,EACrB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAAA,CAClC,CACO,CACJ,CACD;AACT,YAAA,WAAW,KACV,KAAA,CAAA,aAAA,CAAC,IAAI,IACH,WAAW,EAAC,GAAG,EACf,SAAS,EAAC,uBAAuB,EACjC,IAAI,EAAC,aAAa,EAAA;gBAElB,KAAA,CAAA,aAAA,CAAC,IAAI,yBAEH,SAAS,EAAC,oCAAoC,EAC9C,MAAM,EAAC,8BAA8B,EAAA,CACrC;AACD,gBAAA,WAAW,CACP,CACR;AACA,YAAA,IAAI;;AAEH,YAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EACE,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAA,IAAA,EACN,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAO,CAAC,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAA,CACtC,CACH,CACc,CACJ;AAEnB;AAEA,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
@@ -13,7 +13,7 @@ import { BaseLink } from './BaseLink.js';
|
|
|
13
13
|
*/
|
|
14
14
|
const IconLink = forwardRef(({ className, href, icon, tooltip, tooltipPlacement = "bottom", ...restProps }, ref) => {
|
|
15
15
|
const iconOnlyClassName = classNames("tds-btn--icononly", className);
|
|
16
|
-
if (tooltip) {
|
|
16
|
+
if (tooltip?.trim()) {
|
|
17
17
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...linkProps } = restProps;
|
|
18
18
|
return (React.createElement(Tooltip, { content: tooltip, placement: tooltipPlacement, visualOnly: true },
|
|
19
19
|
React.createElement(BaseLink, { href: href, label: icon, className: iconOnlyClassName, ref: ref, ...linkProps, "aria-label": ariaLabel || tooltip })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconLink.js","sources":["../../../src/components/link/IconLink.tsx"],"sourcesContent":["import \"../button/btn.css\"\n\nimport { Tooltip, type TooltipPlacement } from \"@components/internal/tooltip\"\nimport classNames from \"classnames\"\nimport React, { forwardRef } from \"react\"\n\nimport { BaseLink, BaseLinkElementProps } from \"./BaseLink\"\n\ntype IconLinkSharedProps = Omit<\n Extract<BaseLinkElementProps, { asChild?: false }>,\n \"label\" | \"children\"\n> & {\n /** The icon element to display. */\n icon: React.ReactNode\n}\n\ntype IconLinkTooltipProps = {\n /** Accessible label. Required for icon-only links to provide context about the link's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\"?: string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Download\"`, aria-label `\"Download, report.pdf\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip: string\n}\n\ntype IconLinkAriaLabelProps = {\n /** Accessible label. Required for icon-only links to provide context about the link's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\": string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Download\"`, aria-label `\"Download, report.pdf\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip?: string\n}\n\n/**\n * An icon-only link needs a name: `aria-label`, `tooltip`, or both.\n * `IconLinkAriaLabelProps` is declared last so that a missing name\n * reports \"aria-label is missing\", not \"tooltip is missing\".\n */\ntype IconLinkNameProps = IconLinkAriaLabelProps | IconLinkTooltipProps\n\nexport type IconLinkProps = IconLinkSharedProps &\n IconLinkNameProps & {\n /** Where the tooltip renders relative to the link. Default `\"bottom\"`. Has no effect without `tooltip`. */\n tooltipPlacement?: TooltipPlacement\n }\n\n/**\n * An icon-only link component that renders as an HTML `<a>` element with\n * button-like styling. Requires an `icon`, and an `aria-label` or `tooltip`\n * for accessibility.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/links-icon-link--docs | Storybook Documentation}\n */\nexport const IconLink = forwardRef<HTMLAnchorElement, IconLinkProps>(\n (\n {\n className,\n href,\n icon,\n tooltip,\n tooltipPlacement = \"bottom\",\n ...restProps\n }: IconLinkProps,\n ref\n ) => {\n const iconOnlyClassName = classNames(\"tds-btn--icononly\", className)\n\n if (tooltip) {\n const {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...linkProps\n } = restProps\n\n return (\n <Tooltip content={tooltip} placement={tooltipPlacement} visualOnly>\n <BaseLink\n href={href}\n label={icon}\n className={iconOnlyClassName}\n ref={ref}\n {...linkProps}\n aria-label={ariaLabel || tooltip}\n />\n </Tooltip>\n )\n }\n\n return (\n <BaseLink\n href={href}\n label={icon}\n className={iconOnlyClassName}\n ref={ref}\n {...restProps}\n />\n )\n }\n)\n\nIconLink.displayName = \"IconLink\"\n"],"names":[],"mappings":";;;;;AA2CA;;;;;;;AAOG;AACI,MAAM,QAAQ,GAAG,UAAU,CAChC,CACE,EACE,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,gBAAgB,GAAG,QAAQ,EAC3B,GAAG,SAAS,EACE,EAChB,GAAG,KACD;IACF,MAAM,iBAAiB,GAAG,UAAU,CAAC,mBAAmB,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"IconLink.js","sources":["../../../src/components/link/IconLink.tsx"],"sourcesContent":["import \"../button/btn.css\"\n\nimport { Tooltip, type TooltipPlacement } from \"@components/internal/tooltip\"\nimport classNames from \"classnames\"\nimport React, { forwardRef } from \"react\"\n\nimport { BaseLink, BaseLinkElementProps } from \"./BaseLink\"\n\ntype IconLinkSharedProps = Omit<\n Extract<BaseLinkElementProps, { asChild?: false }>,\n \"label\" | \"children\"\n> & {\n /** The icon element to display. */\n icon: React.ReactNode\n}\n\ntype IconLinkTooltipProps = {\n /** Accessible label. Required for icon-only links to provide context about the link's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\"?: string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Download\"`, aria-label `\"Download, report.pdf\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip: string\n}\n\ntype IconLinkAriaLabelProps = {\n /** Accessible label. Required for icon-only links to provide context about the link's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\": string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Download\"`, aria-label `\"Download, report.pdf\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip?: string\n}\n\n/**\n * An icon-only link needs a name: `aria-label`, `tooltip`, or both.\n * `IconLinkAriaLabelProps` is declared last so that a missing name\n * reports \"aria-label is missing\", not \"tooltip is missing\".\n */\ntype IconLinkNameProps = IconLinkAriaLabelProps | IconLinkTooltipProps\n\nexport type IconLinkProps = IconLinkSharedProps &\n IconLinkNameProps & {\n /** Where the tooltip renders relative to the link. Default `\"bottom\"`. Has no effect without `tooltip`. */\n tooltipPlacement?: TooltipPlacement\n }\n\n/**\n * An icon-only link component that renders as an HTML `<a>` element with\n * button-like styling. Requires an `icon`, and an `aria-label` or `tooltip`\n * for accessibility.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/links-icon-link--docs | Storybook Documentation}\n */\nexport const IconLink = forwardRef<HTMLAnchorElement, IconLinkProps>(\n (\n {\n className,\n href,\n icon,\n tooltip,\n tooltipPlacement = \"bottom\",\n ...restProps\n }: IconLinkProps,\n ref\n ) => {\n const iconOnlyClassName = classNames(\"tds-btn--icononly\", className)\n\n if (tooltip?.trim()) {\n const {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...linkProps\n } = restProps\n\n return (\n <Tooltip content={tooltip} placement={tooltipPlacement} visualOnly>\n <BaseLink\n href={href}\n label={icon}\n className={iconOnlyClassName}\n ref={ref}\n {...linkProps}\n aria-label={ariaLabel || tooltip}\n />\n </Tooltip>\n )\n }\n\n return (\n <BaseLink\n href={href}\n label={icon}\n className={iconOnlyClassName}\n ref={ref}\n {...restProps}\n />\n )\n }\n)\n\nIconLink.displayName = \"IconLink\"\n"],"names":[],"mappings":";;;;;AA2CA;;;;;;;AAOG;AACI,MAAM,QAAQ,GAAG,UAAU,CAChC,CACE,EACE,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,gBAAgB,GAAG,QAAQ,EAC3B,GAAG,SAAS,EACE,EAChB,GAAG,KACD;IACF,MAAM,iBAAiB,GAAG,UAAU,CAAC,mBAAmB,EAAE,SAAS,CAAC;AAEpE,IAAA,IAAI,OAAO,EAAE,IAAI,EAAE,EAAE;AACnB,QAAA,MAAM,EACJ,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,GAAG,SAAS,EACb,GAAG,SAAS;AAEb,QAAA,QACE,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAA,IAAA,EAAA;YAChE,KAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,EACP,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAAG,EAAA,GACJ,SAAS,EAAA,YAAA,EACD,SAAS,IAAI,OAAO,EAAA,CAChC,CACM;IAEd;IAEA,QACE,oBAAC,QAAQ,EAAA,EACP,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAAG,EAAA,GACJ,SAAS,EAAA,CACb;AAEN,CAAC;AAGH,QAAQ,CAAC,WAAW,GAAG,UAAU;;;;"}
|
|
@@ -12,7 +12,7 @@ import { SegmentBase } from './SegmentBase.js';
|
|
|
12
12
|
* @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-segmentedcontrol--docs | Storybook Documentation}
|
|
13
13
|
*/
|
|
14
14
|
const IconSegment = forwardRef(function IconSegment({ icon, tooltip, tooltipPlacement = "bottom", ...restProps }, ref) {
|
|
15
|
-
if (tooltip) {
|
|
15
|
+
if (tooltip?.trim()) {
|
|
16
16
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...segmentProps } = restProps;
|
|
17
17
|
return (React__default.createElement(Tooltip, { content: tooltip, placement: tooltipPlacement, visualOnly: true },
|
|
18
18
|
React__default.createElement(SegmentBase, { ...segmentProps, "aria-label": ariaLabel || tooltip, content: icon, iconOnly: true, ref: ref })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconSegment.js","sources":["../../../src/components/segmented-control/IconSegment.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport { Tooltip, type TooltipPlacement } from \"@components/internal/tooltip\"\nimport React, { type ButtonHTMLAttributes, forwardRef } from \"react\"\n\nimport { SegmentBase, type SegmentKind } from \"./SegmentBase\"\n\ntype IconSegmentSharedProps = {\n /** Disables this item only. */\n disabled?: boolean\n /** The icon to display. */\n icon: React.ReactNode\n /**\n * This segment's color when selected. Default `'interaction-subtle'`.\n */\n kind?: SegmentKind\n /** Where the tooltip renders relative to the segment. Default `\"bottom\"`. Has no effect without `tooltip`. */\n tooltipPlacement?: TooltipPlacement\n /** Unique identifier for this item. */\n value: string\n}\n\ntype IconSegmentTooltipProps = {\n /** Accessible label. Required for icon-only segments to provide context about the segment's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\"?: string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Grid\"`, aria-label `\"Grid view\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip: string\n}\n\ntype IconSegmentAriaLabelProps = {\n /** Accessible label. Required for icon-only segments to provide context about the segment's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\": string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Grid\"`, aria-label `\"Grid view\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip?: string\n}\n\n/**\n * An icon-only segment needs a name: `aria-label`, `tooltip`, or both.\n * `IconSegmentAriaLabelProps` is declared last so that a missing name\n * reports \"aria-label is missing\", not \"tooltip is missing\".\n */\ntype IconSegmentNameProps = IconSegmentAriaLabelProps | IconSegmentTooltipProps\n\nexport type IconSegmentProps = IconSegmentSharedProps & IconSegmentNameProps\n\nexport type IconSegmentElementProps = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n | keyof IconSegmentSharedProps\n | \"aria-checked\"\n | \"aria-label\"\n | \"children\"\n | \"onClick\"\n | \"onKeyDown\"\n | \"role\"\n | \"tabIndex\"\n | \"tooltip\"\n | \"type\"\n> &\n IconSegmentProps\n\n/**\n * An icon-only item within a `SegmentedControl`, mirroring `IconButton`'s\n * shape. Requires an `aria-label` or `tooltip` for accessibility. Must be\n * rendered as a direct child of `SegmentedControl` — it reads selection\n * state, group `disabled`, and roving tabindex from that context.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-segmentedcontrol--docs | Storybook Documentation}\n */\nexport const IconSegment = forwardRef<\n HTMLButtonElement,\n IconSegmentElementProps\n>(function IconSegment(\n {\n icon,\n tooltip,\n tooltipPlacement = \"bottom\",\n ...restProps\n }: IconSegmentElementProps,\n ref\n) {\n if (tooltip) {\n const {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...segmentProps\n } = restProps\n\n return (\n <Tooltip content={tooltip} placement={tooltipPlacement} visualOnly>\n <SegmentBase\n {...segmentProps}\n aria-label={ariaLabel || tooltip}\n content={icon}\n iconOnly\n ref={ref}\n />\n </Tooltip>\n )\n }\n\n return <SegmentBase {...restProps} content={icon} iconOnly ref={ref} />\n})\n\nIconSegment.displayName = \"IconSegment\"\n"],"names":["React"],"mappings":";;;;AA4DA;;;;;;;;AAQG;MACU,WAAW,GAAG,UAAU,CAGnC,SAAS,WAAW,CACpB,EACE,IAAI,EACJ,OAAO,EACP,gBAAgB,GAAG,QAAQ,EAC3B,GAAG,SAAS,EACY,EAC1B,GAAG,EAAA;
|
|
1
|
+
{"version":3,"file":"IconSegment.js","sources":["../../../src/components/segmented-control/IconSegment.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport { Tooltip, type TooltipPlacement } from \"@components/internal/tooltip\"\nimport React, { type ButtonHTMLAttributes, forwardRef } from \"react\"\n\nimport { SegmentBase, type SegmentKind } from \"./SegmentBase\"\n\ntype IconSegmentSharedProps = {\n /** Disables this item only. */\n disabled?: boolean\n /** The icon to display. */\n icon: React.ReactNode\n /**\n * This segment's color when selected. Default `'interaction-subtle'`.\n */\n kind?: SegmentKind\n /** Where the tooltip renders relative to the segment. Default `\"bottom\"`. Has no effect without `tooltip`. */\n tooltipPlacement?: TooltipPlacement\n /** Unique identifier for this item. */\n value: string\n}\n\ntype IconSegmentTooltipProps = {\n /** Accessible label. Required for icon-only segments to provide context about the segment's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\"?: string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Grid\"`, aria-label `\"Grid view\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip: string\n}\n\ntype IconSegmentAriaLabelProps = {\n /** Accessible label. Required for icon-only segments to provide context about the segment's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\": string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Grid\"`, aria-label `\"Grid view\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip?: string\n}\n\n/**\n * An icon-only segment needs a name: `aria-label`, `tooltip`, or both.\n * `IconSegmentAriaLabelProps` is declared last so that a missing name\n * reports \"aria-label is missing\", not \"tooltip is missing\".\n */\ntype IconSegmentNameProps = IconSegmentAriaLabelProps | IconSegmentTooltipProps\n\nexport type IconSegmentProps = IconSegmentSharedProps & IconSegmentNameProps\n\nexport type IconSegmentElementProps = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n | keyof IconSegmentSharedProps\n | \"aria-checked\"\n | \"aria-label\"\n | \"children\"\n | \"onClick\"\n | \"onKeyDown\"\n | \"role\"\n | \"tabIndex\"\n | \"tooltip\"\n | \"type\"\n> &\n IconSegmentProps\n\n/**\n * An icon-only item within a `SegmentedControl`, mirroring `IconButton`'s\n * shape. Requires an `aria-label` or `tooltip` for accessibility. Must be\n * rendered as a direct child of `SegmentedControl` — it reads selection\n * state, group `disabled`, and roving tabindex from that context.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-segmentedcontrol--docs | Storybook Documentation}\n */\nexport const IconSegment = forwardRef<\n HTMLButtonElement,\n IconSegmentElementProps\n>(function IconSegment(\n {\n icon,\n tooltip,\n tooltipPlacement = \"bottom\",\n ...restProps\n }: IconSegmentElementProps,\n ref\n) {\n if (tooltip?.trim()) {\n const {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...segmentProps\n } = restProps\n\n return (\n <Tooltip content={tooltip} placement={tooltipPlacement} visualOnly>\n <SegmentBase\n {...segmentProps}\n aria-label={ariaLabel || tooltip}\n content={icon}\n iconOnly\n ref={ref}\n />\n </Tooltip>\n )\n }\n\n return <SegmentBase {...restProps} content={icon} iconOnly ref={ref} />\n})\n\nIconSegment.displayName = \"IconSegment\"\n"],"names":["React"],"mappings":";;;;AA4DA;;;;;;;;AAQG;MACU,WAAW,GAAG,UAAU,CAGnC,SAAS,WAAW,CACpB,EACE,IAAI,EACJ,OAAO,EACP,gBAAgB,GAAG,QAAQ,EAC3B,GAAG,SAAS,EACY,EAC1B,GAAG,EAAA;AAEH,IAAA,IAAI,OAAO,EAAE,IAAI,EAAE,EAAE;AACnB,QAAA,MAAM,EACJ,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,GAAG,YAAY,EAChB,GAAG,SAAS;AAEb,QAAA,QACEA,cAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAA,IAAA,EAAA;YAChEA,cAAA,CAAA,aAAA,CAAC,WAAW,OACN,YAAY,EAAA,YAAA,EACJ,SAAS,IAAI,OAAO,EAChC,OAAO,EAAE,IAAI,EACb,QAAQ,QACR,GAAG,EAAE,GAAG,EAAA,CACR,CACM;IAEd;AAEA,IAAA,OAAOA,cAAA,CAAA,aAAA,CAAC,WAAW,EAAA,EAAA,GAAK,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAA,IAAA,EAAC,GAAG,EAAE,GAAG,GAAI;AACzE,CAAC;AAED,WAAW,CAAC,WAAW,GAAG,aAAa;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.d.ts","sourceRoot":"","sources":["../../../src/components/time-field/TimeField.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,aAAa,CAAA;AAEpB,OAAO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,EAAE,OAAO,CAAA;IAClB,kCAAkC;IAClC,IAAI,CAAC,EAAE,aAAa,CAAA;CACrB;AAED,KAAK,wBAAwB,GACzB,UAAU,GACV,aAAa,GACb,kBAAkB,GAClB,yBAAyB,GACzB,MAAM,CAAA;AAEV,KAAK,2BAA2B,GAC5B,cAAc,GACd,WAAW,GACX,MAAM,GACN,UAAU,GACV,OAAO,CAAA;AAEX,MAAM,MAAM,qBAAqB,GAAG,+BAA+B,CACjE,kBAAkB,CAAC,cAAc,CAAC,EAClC,cAAc,EACd,wBAAwB,EACxB,2BAA2B,CAC5B,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,EACxB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,KAAK,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,IAAW,EACX,GAAG,SAAS,EACb,EAAE,qBAAqB,qBAgEvB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseTime as $58246871e4652552$export$c9698ec7f05a07e1 } from './../../ext/@internationalized/date/dist/private/string.js';
|
|
2
2
|
import Icon from '../../utilities/Icon.js';
|
|
3
|
+
import { useTapestryLocale } from '../../utilities/locale.js';
|
|
3
4
|
import { useDateFieldLocale } from '../../utilities/useDateFieldLocale.js';
|
|
4
5
|
import classNames from 'classnames';
|
|
5
6
|
import React from 'react';
|
|
@@ -24,16 +25,18 @@ function TimeField({ className, defaultValue, description, disabled, forceLeadin
|
|
|
24
25
|
"tds-field--lg": size === "lg",
|
|
25
26
|
"tds-time-field--lg": size === "lg",
|
|
26
27
|
}, className);
|
|
28
|
+
const locale = useTapestryLocale();
|
|
27
29
|
const dateFieldLocale = useDateFieldLocale();
|
|
28
|
-
return (React.createElement(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
React.createElement(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
React.createElement(
|
|
36
|
-
|
|
30
|
+
return (React.createElement(I18nProvider, { locale: locale },
|
|
31
|
+
React.createElement(TimeField$1, { ...restProps, "aria-label": hideLabel ? label : undefined, className: combinedClassName, defaultValue: asTimeFieldValue(defaultValue), granularity: "minute", isDisabled: disabled, isReadOnly: readOnly, isRequired: required, maxValue: asTimeFieldValue(max), minValue: asTimeFieldValue(min), shouldForceLeadingZeros: forceLeadingZeros },
|
|
32
|
+
!hideLabel && React.createElement(Label, { className: "tds-field-label" }, label),
|
|
33
|
+
React.createElement(I18nProvider, { locale: dateFieldLocale },
|
|
34
|
+
React.createElement(DateInput, { "aria-invalid": invalid || undefined, className: "tds-field-control tds-time-field-input" }, (segment) => (React.createElement(DateSegment, { "aria-invalid": invalid || undefined, className: segment.type === "literal"
|
|
35
|
+
? "tds-field-date-segment-separator"
|
|
36
|
+
: "tds-field-date-segment", segment: segment })))),
|
|
37
|
+
description && (React.createElement(Text, { elementType: "p", className: "tds-field-description", slot: "description" },
|
|
38
|
+
React.createElement(Icon, { "aria-hidden": true, className: "tds-field-description-invalid-icon", symbol: "general#exclamation-triangle" }),
|
|
39
|
+
description)))));
|
|
37
40
|
}
|
|
38
41
|
function asTimeFieldValue(value) {
|
|
39
42
|
if (typeof value === "string") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.js","sources":["../../../src/components/time-field/TimeField.tsx"],"sourcesContent":["import \"../field/index.css\"\nimport \"./index.css\"\n\nimport {\n type CalendarDateTime,\n parseTime,\n type Time,\n type ZonedDateTime,\n} from \"@internationalized/date\"\nimport Icon from \"@utilities/Icon\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport { useDateFieldLocale } from \"@utilities/useDateFieldLocale\"\nimport classNames from \"classnames\"\nimport React from \"react\"\nimport { I18nProvider } from \"react-aria/I18nProvider\"\nimport {\n DateInput,\n DateSegment,\n Label,\n Text,\n TimeField as AriaTimeField,\n type TimeFieldProps as AriaTimeFieldProps,\n} from \"react-aria-components/TimeField\"\n\nexport type TimeFieldSize = \"md\" | \"lg\"\n\nexport type TimeFieldValue = CalendarDateTime | Time | ZonedDateTime\n\nexport interface TimeFieldProps {\n /** The default value for the field, as a `TimeFieldValue` or an ISO 8601 time string (e.g. `\"12:00\"`). */\n defaultValue?: TimeFieldValue | string\n /** Helper text displayed below the component. Styled as error text when `invalid` is `true`. */\n description?: React.ReactNode\n /** Disables the field. */\n disabled?: boolean\n /** If `true`, always shows leading zeros in the hour field. */\n forceLeadingZeros?: boolean\n /** If `true`, renders the label visually hidden. */\n hideLabel?: boolean\n /** If `true`, applies error styling to the field and description. */\n invalid?: boolean\n /** Accessible label for the field. */\n label: string\n /** The maximum allowed time, as a `TimeFieldValue` or an ISO 8601 time string (e.g. `\"17:00\"`). */\n max?: TimeFieldValue | string\n /** The minimum allowed time, as a `TimeFieldValue` or an ISO 8601 time string (e.g. `\"09:00\"`). */\n min?: TimeFieldValue | string\n /** Allows the value to be read but not changed. */\n readOnly?: boolean\n /** If `true`, appends an asterisk after the label text. */\n required?: boolean\n /** The size of the time field. */\n size?: TimeFieldSize\n}\n\ntype AriaTimeFieldPropsToOmit =\n | \"children\"\n | \"granularity\"\n | \"placeholderValue\"\n | \"shouldForceLeadingZeros\"\n | \"slot\"\n\ntype AriaTimeFieldPropsToInclude =\n | \"hideTimeZone\"\n | \"hourCycle\"\n | \"name\"\n | \"onChange\"\n | \"value\"\n\nexport type TimeFieldElementProps = CombineAriaPropsWithCustomProps<\n AriaTimeFieldProps<TimeFieldValue>,\n TimeFieldProps,\n AriaTimeFieldPropsToOmit,\n AriaTimeFieldPropsToInclude\n>\n\n/**\n * A time field component allows users to enter and edit time values as individual\n * segments. Each segment supports keyboard entry, increment/decrement\n * with arrow keys, and respects the user's locale (12- vs 24-hour clock),\n * which can be overridden with `hourCycle`.\n *\n * Values are `Time`, `CalendarDateTime`, or `ZonedDateTime` from\n * `@internationalized/date`. Restrict the allowed range with `min`/`max`.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-timefield--docs | Storybook Documentation}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport function TimeField({\n className,\n defaultValue,\n description,\n disabled,\n forceLeadingZeros,\n hideLabel,\n invalid,\n label,\n max,\n min,\n readOnly,\n required,\n size = \"md\",\n ...restProps\n}: TimeFieldElementProps) {\n const combinedClassName = classNames(\n \"tds-field tds-time-field\",\n {\n \"tds-field--lg\": size === \"lg\",\n \"tds-time-field--lg\": size === \"lg\",\n },\n className\n )\n\n const dateFieldLocale = useDateFieldLocale()\n\n return (\n <AriaTimeField\n
|
|
1
|
+
{"version":3,"file":"TimeField.js","sources":["../../../src/components/time-field/TimeField.tsx"],"sourcesContent":["import \"../field/index.css\"\nimport \"./index.css\"\n\nimport {\n type CalendarDateTime,\n parseTime,\n type Time,\n type ZonedDateTime,\n} from \"@internationalized/date\"\nimport Icon from \"@utilities/Icon\"\nimport { useTapestryLocale } from \"@utilities/locale\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport { useDateFieldLocale } from \"@utilities/useDateFieldLocale\"\nimport classNames from \"classnames\"\nimport React from \"react\"\nimport { I18nProvider } from \"react-aria/I18nProvider\"\nimport {\n DateInput,\n DateSegment,\n Label,\n Text,\n TimeField as AriaTimeField,\n type TimeFieldProps as AriaTimeFieldProps,\n} from \"react-aria-components/TimeField\"\n\nexport type TimeFieldSize = \"md\" | \"lg\"\n\nexport type TimeFieldValue = CalendarDateTime | Time | ZonedDateTime\n\nexport interface TimeFieldProps {\n /** The default value for the field, as a `TimeFieldValue` or an ISO 8601 time string (e.g. `\"12:00\"`). */\n defaultValue?: TimeFieldValue | string\n /** Helper text displayed below the component. Styled as error text when `invalid` is `true`. */\n description?: React.ReactNode\n /** Disables the field. */\n disabled?: boolean\n /** If `true`, always shows leading zeros in the hour field. */\n forceLeadingZeros?: boolean\n /** If `true`, renders the label visually hidden. */\n hideLabel?: boolean\n /** If `true`, applies error styling to the field and description. */\n invalid?: boolean\n /** Accessible label for the field. */\n label: string\n /** The maximum allowed time, as a `TimeFieldValue` or an ISO 8601 time string (e.g. `\"17:00\"`). */\n max?: TimeFieldValue | string\n /** The minimum allowed time, as a `TimeFieldValue` or an ISO 8601 time string (e.g. `\"09:00\"`). */\n min?: TimeFieldValue | string\n /** Allows the value to be read but not changed. */\n readOnly?: boolean\n /** If `true`, appends an asterisk after the label text. */\n required?: boolean\n /** The size of the time field. */\n size?: TimeFieldSize\n}\n\ntype AriaTimeFieldPropsToOmit =\n | \"children\"\n | \"granularity\"\n | \"placeholderValue\"\n | \"shouldForceLeadingZeros\"\n | \"slot\"\n\ntype AriaTimeFieldPropsToInclude =\n | \"hideTimeZone\"\n | \"hourCycle\"\n | \"name\"\n | \"onChange\"\n | \"value\"\n\nexport type TimeFieldElementProps = CombineAriaPropsWithCustomProps<\n AriaTimeFieldProps<TimeFieldValue>,\n TimeFieldProps,\n AriaTimeFieldPropsToOmit,\n AriaTimeFieldPropsToInclude\n>\n\n/**\n * A time field component allows users to enter and edit time values as individual\n * segments. Each segment supports keyboard entry, increment/decrement\n * with arrow keys, and respects the user's locale (12- vs 24-hour clock),\n * which can be overridden with `hourCycle`.\n *\n * Values are `Time`, `CalendarDateTime`, or `ZonedDateTime` from\n * `@internationalized/date`. Restrict the allowed range with `min`/`max`.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-timefield--docs | Storybook Documentation}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport function TimeField({\n className,\n defaultValue,\n description,\n disabled,\n forceLeadingZeros,\n hideLabel,\n invalid,\n label,\n max,\n min,\n readOnly,\n required,\n size = \"md\",\n ...restProps\n}: TimeFieldElementProps) {\n const combinedClassName = classNames(\n \"tds-field tds-time-field\",\n {\n \"tds-field--lg\": size === \"lg\",\n \"tds-time-field--lg\": size === \"lg\",\n },\n className\n )\n\n const locale = useTapestryLocale()\n const dateFieldLocale = useDateFieldLocale()\n\n return (\n <I18nProvider locale={locale}>\n <AriaTimeField\n {...restProps}\n aria-label={hideLabel ? label : undefined}\n className={combinedClassName}\n defaultValue={asTimeFieldValue(defaultValue)}\n granularity=\"minute\"\n isDisabled={disabled}\n isReadOnly={readOnly}\n isRequired={required}\n maxValue={asTimeFieldValue(max)}\n minValue={asTimeFieldValue(min)}\n shouldForceLeadingZeros={forceLeadingZeros}\n >\n {!hideLabel && <Label className=\"tds-field-label\">{label}</Label>}\n <I18nProvider locale={dateFieldLocale}>\n <DateInput\n aria-invalid={invalid || undefined}\n className=\"tds-field-control tds-time-field-input\"\n >\n {(segment) => (\n <DateSegment\n aria-invalid={invalid || undefined}\n className={\n segment.type === \"literal\"\n ? \"tds-field-date-segment-separator\"\n : \"tds-field-date-segment\"\n }\n segment={segment}\n />\n )}\n </DateInput>\n </I18nProvider>\n {description && (\n <Text\n elementType=\"p\"\n className=\"tds-field-description\"\n slot=\"description\"\n >\n <Icon\n aria-hidden\n className=\"tds-field-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n />\n {description}\n </Text>\n )}\n </AriaTimeField>\n </I18nProvider>\n )\n}\n\nfunction asTimeFieldValue(\n value: TimeFieldValue | string | undefined\n): TimeFieldValue | undefined {\n if (typeof value === \"string\") {\n return parseTime(value)\n }\n return value ?? undefined\n}\n"],"names":["AriaTimeField","parseTime"],"mappings":";;;;;;;;;AA6EA;;;;;;;;;;;;AAYG;AACG,SAAU,SAAS,CAAC,EACxB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,KAAK,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,IAAI,GAAG,IAAI,EACX,GAAG,SAAS,EACU,EAAA;AACtB,IAAA,MAAM,iBAAiB,GAAG,UAAU,CAClC,0BAA0B,EAC1B;Q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