@planningcenter/tapestry 4.13.0 → 4.14.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/componentRegistrars.d.ts +1 -0
- package/dist/componentRegistrars.d.ts.map +1 -1
- package/dist/componentRegistrars.js +7 -1
- package/dist/componentRegistrars.js.map +1 -1
- package/dist/components/DataTable/ActiveFilters.d.ts +3 -3
- package/dist/components/DataTable/ActiveFilters.d.ts.map +1 -1
- package/dist/components/DataTable/ActiveFilters.js +8 -5
- package/dist/components/DataTable/ActiveFilters.js.map +1 -1
- package/dist/components/DataTable/DataTable.d.ts +22 -21
- package/dist/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.js +47 -37
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/DataTableColumn.d.ts +15 -3
- package/dist/components/DataTable/DataTableColumn.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableColumnTypes.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableColumnTypes.js +9 -0
- package/dist/components/DataTable/DataTableColumnTypes.js.map +1 -1
- package/dist/components/DataTable/DeleteSavedViewAlertDialog.d.ts +1 -1
- package/dist/components/DataTable/DeleteSavedViewAlertDialog.d.ts.map +1 -1
- package/dist/components/DataTable/DeleteSavedViewAlertDialog.js.map +1 -1
- package/dist/components/DataTable/ManageViewsButton.d.ts +9 -0
- package/dist/components/DataTable/ManageViewsButton.d.ts.map +1 -0
- package/dist/components/DataTable/{ManageSavedViewsButton.js → ManageViewsButton.js} +5 -5
- package/dist/components/DataTable/ManageViewsButton.js.map +1 -0
- package/dist/components/DataTable/{ManageSavedViewsModal.d.ts → ManageViewsModal.d.ts} +7 -7
- package/dist/components/DataTable/ManageViewsModal.d.ts.map +1 -0
- package/dist/components/DataTable/{ManageSavedViewsModal.js → ManageViewsModal.js} +10 -10
- package/dist/components/DataTable/ManageViewsModal.js.map +1 -0
- package/dist/components/DataTable/ManageViewsModal.module.css.js +4 -0
- package/dist/components/DataTable/ManageViewsModal.module.css.js.map +1 -0
- package/dist/components/DataTable/NewSavedViewButton.js +1 -1
- package/dist/components/DataTable/NewSavedViewButton.js.map +1 -1
- package/dist/components/DataTable/OperatorSelect.js +4 -1
- package/dist/components/DataTable/OperatorSelect.js.map +1 -1
- package/dist/components/DataTable/RowActions.d.ts +4 -0
- package/dist/components/DataTable/RowActions.d.ts.map +1 -1
- package/dist/components/DataTable/RowActions.js +3 -3
- package/dist/components/DataTable/RowActions.js.map +1 -1
- package/dist/components/DataTable/ViewMenu.d.ts +18 -0
- package/dist/components/DataTable/ViewMenu.d.ts.map +1 -0
- package/dist/components/DataTable/{SavedViewMenu.js → ViewMenu.js} +5 -5
- package/dist/components/DataTable/ViewMenu.js.map +1 -0
- package/dist/components/DataTable/{SavedViewsBar.d.ts → ViewsBar.d.ts} +11 -11
- package/dist/components/DataTable/ViewsBar.d.ts.map +1 -0
- package/dist/components/DataTable/{SavedViewsBar.js → ViewsBar.js} +27 -27
- package/dist/components/DataTable/ViewsBar.js.map +1 -0
- package/dist/components/DataTable/dateFilter.d.ts +17 -3
- package/dist/components/DataTable/dateFilter.d.ts.map +1 -1
- package/dist/components/DataTable/dateFilter.js +19 -3
- package/dist/components/DataTable/dateFilter.js.map +1 -1
- package/dist/components/DataTable/index.d.ts +3 -3
- package/dist/components/DataTable/index.d.ts.map +1 -1
- package/dist/components/DataTable/useActiveView.d.ts +7 -0
- package/dist/components/DataTable/useActiveView.d.ts.map +1 -0
- package/dist/components/DataTable/{useActiveSavedView.js → useActiveView.js} +5 -5
- package/dist/components/DataTable/useActiveView.js.map +1 -0
- package/dist/components/DataTable/useColumnVisibility.d.ts +12 -8
- package/dist/components/DataTable/useColumnVisibility.d.ts.map +1 -1
- package/dist/components/DataTable/useColumnVisibility.js +28 -16
- package/dist/components/DataTable/useColumnVisibility.js.map +1 -1
- package/dist/components/DataTable/useSaveStatus.d.ts +6 -6
- package/dist/components/DataTable/useSaveStatus.d.ts.map +1 -1
- package/dist/components/DataTable/useSaveStatus.js +7 -7
- package/dist/components/DataTable/useSaveStatus.js.map +1 -1
- package/dist/components/DataTable/useSavedViewNameModal.d.ts +2 -2
- package/dist/components/DataTable/useSavedViewNameModal.d.ts.map +1 -1
- package/dist/components/DataTable/useSavedViewNameModal.js +2 -2
- package/dist/components/DataTable/useSavedViewNameModal.js.map +1 -1
- package/dist/components/DataTable/useSavedViewsClient.d.ts +3 -3
- package/dist/components/DataTable/useSavedViewsClient.d.ts.map +1 -1
- package/dist/components/DataTable/useSavedViewsClient.js +1 -1
- package/dist/components/DataTable/useSavedViewsClient.js.map +1 -1
- package/dist/components/DataTable/useSavedViewsState.d.ts +7 -7
- package/dist/components/DataTable/useSavedViewsState.d.ts.map +1 -1
- package/dist/components/DataTable/useSavedViewsState.js +1 -1
- package/dist/components/DataTable/useSavedViewsState.js.map +1 -1
- package/dist/components/DataTable/useUpdateSavedViewName.d.ts +1 -1
- package/dist/components/DataTable/useUpdateSavedViewName.d.ts.map +1 -1
- package/dist/components/DataTable/useUpdateSavedViewName.js.map +1 -1
- package/dist/components/DataTable/{useVisibleSavedViews.d.ts → useVisibleViews.d.ts} +2 -2
- package/dist/components/DataTable/useVisibleViews.d.ts.map +1 -0
- package/dist/components/DataTable/{useVisibleSavedViews.js → useVisibleViews.js} +6 -6
- package/dist/components/DataTable/useVisibleViews.js.map +1 -0
- package/dist/components/DataTable/views.d.ts +56 -0
- package/dist/components/DataTable/views.d.ts.map +1 -0
- package/dist/components/DataTable/{savedViews.js → views.js} +12 -11
- package/dist/components/DataTable/views.js.map +1 -0
- package/dist/components/button/ActionsDropdownIconButton.d.ts +2 -2
- package/dist/components/button/ActionsDropdownIconButton.d.ts.map +1 -1
- package/dist/components/button/ActionsDropdownIconButton.js.map +1 -1
- package/dist/components/button/IconButton.d.ts +2 -2
- package/dist/components/button/IconButton.d.ts.map +1 -1
- package/dist/components/button/IconButton.js.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroup.d.ts +3 -1
- package/dist/components/checkbox-group/CheckboxGroup.d.ts.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroup.js +2 -2
- package/dist/components/checkbox-group/CheckboxGroup.js.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +7 -2
- package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
- package/dist/components/date-picker/DatePicker.js +69 -14
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.js +10 -2
- package/dist/components/dropdown/Dropdown.js.map +1 -1
- package/dist/components/link/BaseLink.js +3 -3
- package/dist/components/link/BaseLink.js.map +1 -1
- package/dist/components/link/IconLink.js +4 -4
- package/dist/components/link/IconLink.js.map +1 -1
- package/dist/components/link/Link.js +2 -2
- package/dist/components/link/Link.js.map +1 -1
- package/dist/components/radio-group/RadioGroup.d.ts +7 -1
- package/dist/components/radio-group/RadioGroup.d.ts.map +1 -1
- package/dist/components/radio-group/RadioGroup.js +2 -2
- package/dist/components/radio-group/RadioGroup.js.map +1 -1
- package/dist/index.css +107 -27
- package/dist/index.css.map +1 -1
- package/dist/packages/tapestry-wc/dist/components/tds-page-header.js +2 -2
- package/dist/packages/tapestry-wc/dist/components/tds-page-header.js.map +1 -1
- package/dist/reactRender.css +1535 -1436
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRender.js +1 -1
- package/dist/reactRenderLegacy.css +1535 -1436
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/reactRenderLegacy.js +1 -1
- package/dist/tapestryMount.css +1535 -1436
- package/dist/tapestryMount.css.map +1 -1
- package/dist/tapestryMount.js +1 -1
- package/dist/tapestryMountLegacy.css +1535 -1436
- package/dist/tapestryMountLegacy.css.map +1 -1
- package/dist/tapestryMountLegacy.js +1 -1
- package/dist/unstable.css +381 -282
- package/dist/unstable.css.map +1 -1
- package/package.json +3 -3
- package/react-types/index.d.ts +5 -0
- package/dist/components/DataTable/ManageSavedViewsButton.d.ts +0 -9
- package/dist/components/DataTable/ManageSavedViewsButton.d.ts.map +0 -1
- package/dist/components/DataTable/ManageSavedViewsButton.js.map +0 -1
- package/dist/components/DataTable/ManageSavedViewsModal.d.ts.map +0 -1
- package/dist/components/DataTable/ManageSavedViewsModal.js.map +0 -1
- package/dist/components/DataTable/ManageSavedViewsModal.module.css.js +0 -4
- package/dist/components/DataTable/ManageSavedViewsModal.module.css.js.map +0 -1
- package/dist/components/DataTable/SavedViewMenu.d.ts +0 -18
- package/dist/components/DataTable/SavedViewMenu.d.ts.map +0 -1
- package/dist/components/DataTable/SavedViewMenu.js.map +0 -1
- package/dist/components/DataTable/SavedViewsBar.d.ts.map +0 -1
- package/dist/components/DataTable/SavedViewsBar.js.map +0 -1
- package/dist/components/DataTable/savedViews.d.ts +0 -45
- package/dist/components/DataTable/savedViews.d.ts.map +0 -1
- package/dist/components/DataTable/savedViews.js.map +0 -1
- package/dist/components/DataTable/useActiveSavedView.d.ts +0 -7
- package/dist/components/DataTable/useActiveSavedView.d.ts.map +0 -1
- package/dist/components/DataTable/useActiveSavedView.js.map +0 -1
- package/dist/components/DataTable/useVisibleSavedViews.d.ts.map +0 -1
- package/dist/components/DataTable/useVisibleSavedViews.js.map +0 -1
|
@@ -10,13 +10,13 @@ import React__default from 'react';
|
|
|
10
10
|
* @component
|
|
11
11
|
* @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-checkbox-group--docs | Storybook Documentation}
|
|
12
12
|
*/
|
|
13
|
-
function CheckboxGroup({ children, className, description, invalid, label, size = "md", ...restProps }) {
|
|
13
|
+
function CheckboxGroup({ children, className, description, hideLabel = false, invalid, label, size = "md", ...restProps }) {
|
|
14
14
|
const combinedClassName = classNames("tds-checkbox-group", size === "sm" && "tds-checkbox-group--sm", className);
|
|
15
15
|
const stableId = useId();
|
|
16
16
|
const displayDescription = description || (invalid ? "One or more checkboxes are invalid." : undefined);
|
|
17
17
|
const descriptionId = `tds-checkbox-group-${stableId}-description`;
|
|
18
18
|
return (React__default.createElement("fieldset", { ...restProps, "aria-describedby": displayDescription ? descriptionId : undefined, "aria-invalid": invalid || undefined, className: combinedClassName },
|
|
19
|
-
React__default.createElement("legend",
|
|
19
|
+
React__default.createElement("legend", { className: hideLabel ? "tds-checkbox-group-legend--hidden" : undefined }, label),
|
|
20
20
|
displayDescription && (React__default.createElement("p", { id: descriptionId, className: "tds-checkbox-group-description" },
|
|
21
21
|
React__default.createElement(Icon, { "aria-hidden": true, className: "tds-checkbox-group-description-invalid-icon", symbol: "general#exclamation-triangle" }),
|
|
22
22
|
displayDescription)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxGroup.js","sources":["../../../src/components/checkbox-group/CheckboxGroup.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport Icon from \"@utilities/Icon\"\nimport { useId } from \"@utilities/useId\"\nimport classNames from \"classnames\"\nimport React, { FieldsetHTMLAttributes } from \"react\"\n\nexport type CheckboxGroupSize = \"md\" | \"sm\"\n\nexport interface CheckboxGroupProps {\n /** Optional description or error message rendered below the legend. */\n description?: React.ReactNode\n /** If true, adds aria-invalid and styles the description as an error. */\n invalid?: boolean\n /** The group label. Renders as <legend>. Required. */\n label: string\n /** Sets font size for the legend and description. */\n size?: CheckboxGroupSize\n}\n\nexport type CheckboxGroupElementProps = Omit<\n FieldsetHTMLAttributes<HTMLFieldSetElement>,\n keyof CheckboxGroupProps\n> &\n CheckboxGroupProps\n\n/**\n * A checkbox group allows a user to select multiple items from a list of options.\n * Use it to group two or more checkboxes that share a common question or label.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-checkbox-group--docs | Storybook Documentation}\n */\nexport function CheckboxGroup({\n children,\n className,\n description,\n invalid,\n label,\n size = \"md\",\n ...restProps\n}: CheckboxGroupElementProps) {\n const combinedClassName = classNames(\n \"tds-checkbox-group\",\n size === \"sm\" && \"tds-checkbox-group--sm\",\n className\n )\n const stableId = useId()\n\n const displayDescription =\n description || (invalid ? \"One or more checkboxes are invalid.\" : undefined)\n const descriptionId = `tds-checkbox-group-${stableId}-description`\n\n return (\n <fieldset\n {...restProps}\n aria-describedby={displayDescription ? descriptionId : undefined}\n aria-invalid={invalid || undefined}\n className={combinedClassName}\n >\n <legend
|
|
1
|
+
{"version":3,"file":"CheckboxGroup.js","sources":["../../../src/components/checkbox-group/CheckboxGroup.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport Icon from \"@utilities/Icon\"\nimport { useId } from \"@utilities/useId\"\nimport classNames from \"classnames\"\nimport React, { FieldsetHTMLAttributes } from \"react\"\n\nexport type CheckboxGroupSize = \"md\" | \"sm\"\n\nexport interface CheckboxGroupProps {\n /** Optional description or error message rendered below the legend. */\n description?: React.ReactNode\n /** If true, visually hides the legend while keeping it available to assistive technology. */\n hideLabel?: boolean\n /** If true, adds aria-invalid and styles the description as an error. */\n invalid?: boolean\n /** The group label. Renders as <legend>. Required. */\n label: string\n /** Sets font size for the legend and description. */\n size?: CheckboxGroupSize\n}\n\nexport type CheckboxGroupElementProps = Omit<\n FieldsetHTMLAttributes<HTMLFieldSetElement>,\n keyof CheckboxGroupProps\n> &\n CheckboxGroupProps\n\n/**\n * A checkbox group allows a user to select multiple items from a list of options.\n * Use it to group two or more checkboxes that share a common question or label.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-checkbox-group--docs | Storybook Documentation}\n */\nexport function CheckboxGroup({\n children,\n className,\n description,\n hideLabel = false,\n invalid,\n label,\n size = \"md\",\n ...restProps\n}: CheckboxGroupElementProps) {\n const combinedClassName = classNames(\n \"tds-checkbox-group\",\n size === \"sm\" && \"tds-checkbox-group--sm\",\n className\n )\n const stableId = useId()\n\n const displayDescription =\n description || (invalid ? \"One or more checkboxes are invalid.\" : undefined)\n const descriptionId = `tds-checkbox-group-${stableId}-description`\n\n return (\n <fieldset\n {...restProps}\n aria-describedby={displayDescription ? descriptionId : undefined}\n aria-invalid={invalid || undefined}\n className={combinedClassName}\n >\n <legend\n className={hideLabel ? \"tds-checkbox-group-legend--hidden\" : undefined}\n >\n {label}\n </legend>\n {displayDescription && (\n <p id={descriptionId} className=\"tds-checkbox-group-description\">\n <Icon\n aria-hidden\n className=\"tds-checkbox-group-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n />\n {displayDescription}\n </p>\n )}\n <div className=\"tds-checkbox-group-fields\">{children}</div>\n </fieldset>\n )\n}\n"],"names":["React"],"mappings":";;;;;AA4BA;;;;;;AAMG;AACG,SAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,GAAG,KAAK,EACjB,OAAO,EACP,KAAK,EACL,IAAI,GAAG,IAAI,EACX,GAAG,SAAS,EACc,EAAA;AAC1B,IAAA,MAAM,iBAAiB,GAAG,UAAU,CAClC,oBAAoB,EACpB,IAAI,KAAK,IAAI,IAAI,wBAAwB,EACzC,SAAS,CACV;AACD,IAAA,MAAM,QAAQ,GAAG,KAAK,EAAE;AAExB,IAAA,MAAM,kBAAkB,GACtB,WAAW,KAAK,OAAO,GAAG,qCAAqC,GAAG,SAAS,CAAC;AAC9E,IAAA,MAAM,aAAa,GAAG,CAAA,mBAAA,EAAsB,QAAQ,cAAc;IAElE,QACEA,8CACM,SAAS,EAAA,kBAAA,EACK,kBAAkB,GAAG,aAAa,GAAG,SAAS,kBAClD,OAAO,IAAI,SAAS,EAClC,SAAS,EAAE,iBAAiB,EAAA;AAE5B,QAAAA,cAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EACE,SAAS,EAAE,SAAS,GAAG,mCAAmC,GAAG,SAAS,EAAA,EAErE,KAAK,CACC;QACR,kBAAkB,KACjBA,cAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAG,EAAE,EAAE,aAAa,EAAE,SAAS,EAAC,gCAAgC,EAAA;YAC9DA,cAAA,CAAA,aAAA,CAAC,IAAI,yBAEH,SAAS,EAAC,6CAA6C,EACvD,MAAM,EAAC,8BAA8B,EAAA,CACrC;AACD,YAAA,kBAAkB,CACjB,CACL;QACDA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,2BAA2B,EAAA,EAAE,QAAQ,CAAO,CAClD;AAEf;;;;"}
|
|
@@ -44,7 +44,12 @@ export interface DatePickerProps {
|
|
|
44
44
|
required?: boolean;
|
|
45
45
|
/** The size of the date picker. */
|
|
46
46
|
size?: DatePickerSize;
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The controlled value. Accepts a DateValue or ISO date string.
|
|
49
|
+
*
|
|
50
|
+
* A partly filled date (e.g. `4/dd/2026`) reports `null` on blur but stays on
|
|
51
|
+
* screen. Setting `null` again won't clear it; remount with a `key` to reset.
|
|
52
|
+
*/
|
|
48
53
|
value?: DatePickerDateValue | null;
|
|
49
54
|
}
|
|
50
55
|
type AriaDatePickerPropsToOmit = "children" | "defaultOpen" | "granularity" | "hideTimeZone" | "hourCycle" | "pageBehavior" | "placeholderValue" | "shouldCloseOnSelect" | "shouldForceLeadingZeros" | "slot";
|
|
@@ -70,7 +75,7 @@ export type DatePickerElementProps = CombineAriaPropsWithCustomProps<AriaDatePic
|
|
|
70
75
|
* @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-datepicker--docs | Storybook Documentation}
|
|
71
76
|
* @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}
|
|
72
77
|
*/
|
|
73
|
-
export declare function DatePicker({ className, defaultValue, description, disabled, firstDayOfWeek, formatDateOnBlur, hideLabel, invalid, isDateUnavailable, label, max, min, onBlur, onChange, readOnly, required, size, value, alwaysShowFourDigitYear, ...restProps }: DatePickerElementProps): React.JSX.Element;
|
|
78
|
+
export declare function DatePicker({ className, defaultValue, description, disabled, firstDayOfWeek, formatDateOnBlur, hideLabel, invalid, isDateUnavailable, label, max, min, name, onBlur, onChange, onFocus, readOnly, required, size, value, alwaysShowFourDigitYear, ...restProps }: DatePickerElementProps): React.JSX.Element;
|
|
74
79
|
export declare namespace DatePicker {
|
|
75
80
|
var displayName: string;
|
|
76
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/date-picker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,OAAO,oBAAoB,CAAA;AAC3B,OAAO,aAAa,CAAA;AAEpB,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAGhF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/date-picker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,OAAO,oBAAoB,CAAA;AAC3B,OAAO,aAAa,CAAA;AAEpB,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAGhF,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;AAGd,OAAO,EAUL,KAAK,eAAe,IAAI,mBAAmB,EAM5C,MAAM,kCAAkC,CAAA;AAYzC,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAA;AAExC,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,MAAM,CAAA;AAepD,MAAM,WAAW,eAAe;IAC9B,4GAA4G;IAC5G,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,wFAAwF;IACxF,YAAY,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACzC,gGAAgG;IAChG,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4F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ACH,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,cAAc,EACd,gBAA8C,EAC9C,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAW,EACX,KAAK,EACL,uBAA+B,EAC/B,GAAG,SAAS,EACb,EAAE,sBAAsB,qBAmLxB;yBA1Me,UAAU"}
|
|
@@ -4,7 +4,7 @@ import { parseDate as $58246871e4652552$export$6b862160d295c8e } from './../../e
|
|
|
4
4
|
import Icon from '../../utilities/Icon.js';
|
|
5
5
|
import { useDateFieldLocale } from '../../utilities/useDateFieldLocale.js';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import React, { useState, useContext } from 'react';
|
|
7
|
+
import React, { useState, useRef, useEffect, useMemo, useContext } from 'react';
|
|
8
8
|
import { I18nProvider } from 'react-aria/I18nProvider';
|
|
9
9
|
import { CalendarStateContext } from 'react-aria-components/Calendar';
|
|
10
10
|
import { DatePicker as DatePicker$1, Label, Group, DateInput, DateSegment, Button, Popover, Calendar, Text, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, CalendarCell } from 'react-aria-components/DatePicker';
|
|
@@ -97,8 +97,14 @@ function DatePickerCalendarBody({ activeOverlay, setActiveOverlay, }) {
|
|
|
97
97
|
}
|
|
98
98
|
function useValue({ defaultValue, onChange, value, }) {
|
|
99
99
|
const [uncontrolledValue, setUncontrolledValue] = useState(() => toCalendarDate(defaultValue) ?? null);
|
|
100
|
+
// react-aria rebuilds the segments whenever the value's reference changes,
|
|
101
|
+
// so a new object for the same date would wipe a partly typed one
|
|
102
|
+
const valueKey = value == null ? value : value.toString();
|
|
103
|
+
const controlledValue = useMemo(() => toCalendarDate(value) ?? null,
|
|
104
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- convert again only when the date changes, not the object
|
|
105
|
+
[valueKey]);
|
|
100
106
|
if (value !== undefined) {
|
|
101
|
-
return [
|
|
107
|
+
return [controlledValue, (...args) => onChange?.(...args)];
|
|
102
108
|
}
|
|
103
109
|
return [
|
|
104
110
|
uncontrolledValue,
|
|
@@ -122,6 +128,11 @@ function expandTwoDigitYearsViaPOSIX(date) {
|
|
|
122
128
|
fullYear -= 100;
|
|
123
129
|
return date.set({ year: fullYear });
|
|
124
130
|
}
|
|
131
|
+
function isPartlyFilled(field) {
|
|
132
|
+
const segments = Array.from(field?.querySelectorAll('[data-type]:not([data-type="literal"])') ?? []);
|
|
133
|
+
const blankCount = segments.filter((segment) => segment.hasAttribute("data-placeholder")).length;
|
|
134
|
+
return blankCount > 0 && blankCount < segments.length;
|
|
135
|
+
}
|
|
125
136
|
/**
|
|
126
137
|
* A date picker allows a user to select a particular date.
|
|
127
138
|
* The input supports keyboard entry of individual day, month, and year segments;
|
|
@@ -142,7 +153,7 @@ function expandTwoDigitYearsViaPOSIX(date) {
|
|
|
142
153
|
* @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-datepicker--docs | Storybook Documentation}
|
|
143
154
|
* @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}
|
|
144
155
|
*/
|
|
145
|
-
function DatePicker({ className, defaultValue, description, disabled, firstDayOfWeek, formatDateOnBlur = expandTwoDigitYearsViaPOSIX, hideLabel, invalid, isDateUnavailable, label, max, min, onBlur, onChange, 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, readOnly, required, size = "md", value, alwaysShowFourDigitYear = false, ...restProps }) {
|
|
146
157
|
const convertedMin = toCalendarDate(min) ?? undefined;
|
|
147
158
|
const convertedMax = toCalendarDate(max) ?? undefined;
|
|
148
159
|
const combinedClassName = classNames("tds-field tds-date-picker", {
|
|
@@ -155,23 +166,64 @@ function DatePicker({ className, defaultValue, description, disabled, firstDayOf
|
|
|
155
166
|
onChange,
|
|
156
167
|
value,
|
|
157
168
|
});
|
|
169
|
+
// react-aria only reports complete dates, and rebuilds the segments whenever
|
|
170
|
+
// its value changes. So once a partly filled date reports null, react-aria
|
|
171
|
+
// keeps the last complete date it held, or it would wipe the partial text.
|
|
172
|
+
// See adobe/react-spectrum#9624 and #9801.
|
|
173
|
+
const [heldValue, setHeldValue] = useState(null);
|
|
174
|
+
const valueKey = computedValue?.toString() ?? null;
|
|
175
|
+
const [lastValueKey, setLastValueKey] = useState(valueKey);
|
|
176
|
+
if (valueKey !== lastValueKey) {
|
|
177
|
+
setLastValueKey(valueKey);
|
|
178
|
+
if (computedValue)
|
|
179
|
+
setHeldValue(null);
|
|
180
|
+
}
|
|
181
|
+
// onBlur reads this; react-aria can report a change earlier in the same blur event
|
|
182
|
+
const heldValueRef = useRef(heldValue);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
heldValueRef.current = heldValue;
|
|
185
|
+
}, [heldValue]);
|
|
186
|
+
const [valueBeforeEdit, setValueBeforeEdit] = useState(computedValue);
|
|
187
|
+
const [openedPartlyFilled, setOpenedPartlyFilled] = useState(false);
|
|
188
|
+
const fieldRef = useRef(null);
|
|
158
189
|
const dateFieldLocale = useDateFieldLocale();
|
|
159
190
|
return (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) => {
|
|
191
|
+
if (isPartlyFilled(fieldRef.current)) {
|
|
192
|
+
if (computedValue) {
|
|
193
|
+
setHeldValue(computedValue);
|
|
194
|
+
setComputedValue(null);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (heldValueRef.current) {
|
|
198
|
+
// Refilled to the date react-aria still held, so it reported no change
|
|
199
|
+
setHeldValue(null);
|
|
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);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
160
208
|
onBlur?.(event);
|
|
161
|
-
if (!formatDateOnBlur || !computedValue)
|
|
162
|
-
return;
|
|
163
|
-
const formattedValue = formatDateOnBlur(computedValue);
|
|
164
|
-
if ($ad063034c8620db8$export$ea39ec197993aef0(formattedValue, computedValue))
|
|
165
|
-
return;
|
|
166
|
-
setComputedValue(formattedValue);
|
|
167
209
|
}, onChange: (newValue) => {
|
|
210
|
+
heldValueRef.current = null;
|
|
211
|
+
setHeldValue(null);
|
|
212
|
+
if (newValue === null && computedValue === null)
|
|
213
|
+
return;
|
|
168
214
|
setComputedValue(newValue);
|
|
215
|
+
}, onFocus: (event) => {
|
|
216
|
+
if (!heldValue)
|
|
217
|
+
setValueBeforeEdit(computedValue);
|
|
218
|
+
onFocus?.(event);
|
|
169
219
|
}, onOpenChange: (isOpen) => {
|
|
170
|
-
if (
|
|
220
|
+
if (isOpen)
|
|
221
|
+
setOpenedPartlyFilled(isPartlyFilled(fieldRef.current));
|
|
222
|
+
else
|
|
171
223
|
setActiveOverlay(null);
|
|
172
|
-
}, value: computedValue },
|
|
224
|
+
}, validate: () => (heldValue && required ? "Enter a full date" : null), value: heldValue ?? computedValue },
|
|
173
225
|
!hideLabel && React.createElement(Label, { className: "tds-field-label" }, label),
|
|
174
|
-
React.createElement(Group, { "aria-invalid": invalid || undefined, className: "tds-field-control tds-date-picker-field" },
|
|
226
|
+
React.createElement(Group, { "aria-invalid": invalid || undefined, className: "tds-field-control tds-date-picker-field", ref: fieldRef },
|
|
175
227
|
React.createElement(I18nProvider, { locale: dateFieldLocale },
|
|
176
228
|
React.createElement(DateInput, { className: "tds-date-picker-input" }, (segment) => (React.createElement(DateSegment, { "aria-invalid": invalid || undefined, className: segment.type === "literal"
|
|
177
229
|
? "tds-field-date-segment-separator"
|
|
@@ -193,11 +245,14 @@ function DatePicker({ className, defaultValue, description, disabled, firstDayOf
|
|
|
193
245
|
"tds-date-picker-popover--lg": size === "lg",
|
|
194
246
|
}), offset: 2 },
|
|
195
247
|
React.createElement(Dialog, null,
|
|
196
|
-
React.createElement(Calendar, { className: "tds-date-picker-calendar", firstDayOfWeek: firstDayOfWeek },
|
|
248
|
+
React.createElement(Calendar, { className: "tds-date-picker-calendar", defaultFocusedValue: openedPartlyFilled ? (valueBeforeEdit ?? undefined) : undefined, firstDayOfWeek: firstDayOfWeek, value: openedPartlyFilled ? null : undefined },
|
|
197
249
|
React.createElement(DatePickerCalendarBody, { activeOverlay: activeOverlay, setActiveOverlay: setActiveOverlay })))),
|
|
198
250
|
description && (React.createElement(Text, { elementType: "p", className: "tds-field-description", slot: "description" },
|
|
199
251
|
React.createElement(Icon, { "aria-hidden": true, className: "tds-field-description-invalid-icon", symbol: "general#exclamation-triangle" }),
|
|
200
|
-
description))
|
|
252
|
+
description)),
|
|
253
|
+
name && (
|
|
254
|
+
// Submits the reported value, which react-aria's own input can't while it holds a partly filled date
|
|
255
|
+
React.createElement("input", { disabled: disabled, hidden: true, name: name, onChange: () => { }, type: "text", value: computedValue?.toString() ?? "" }))));
|
|
201
256
|
}
|
|
202
257
|
DatePicker.displayName = "DatePicker";
|
|
203
258
|
|
|
@@ -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, { type ReactNode, useContext, useState } 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 /** The controlled value. Accepts a DateValue or ISO date string. */\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 if (value !== undefined) {\n return [toCalendarDate(value) ?? null, (...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\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 onBlur,\n onChange,\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 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 onBlur?.(event)\n if (!formatDateOnBlur || !computedValue) return\n\n const formattedValue = formatDateOnBlur(computedValue)\n if (isSameDay(formattedValue, computedValue)) return\n\n setComputedValue(formattedValue)\n }}\n onChange={(newValue) => {\n setComputedValue(newValue)\n }}\n onOpenChange={(isOpen) => {\n if (!isOpen) setActiveOverlay(null)\n }}\n value={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 >\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 firstDayOfWeek={firstDayOfWeek}\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 </AriaDatePicker>\n )\n}\n\nDatePicker.displayName = \"DatePicker\"\n"],"names":["todayCalendar","getLocalTimeZone","parseDate","CalendarDate","AriaDatePicker","isSameDay"],"mappings":";;;;;;;;;;;;;AAuCA,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;AAC1E,MAAM,mBAAmB,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;AAC7D,IAAA,KAAK,EAAE,OAAO;AACf,CAAA,CAAC;AACF,MAAM,kBAAkB,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAMhF,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,C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AAC,yBAAyB,EAAE;gBAC/C,6BAA6B,EAAE,IAAI,KAAK,IAAI;aAC7C,CAAC,EACF,MAAM,EAAE,CAAC,EAAA;AAET,YAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,IAAA;gBACL,KAAA,CAAA,aAAA,CAAC,QAAQ,IACP,SAAS,EAAC,0BAA0B,EACpC,cAAc,EAAE,cAAc,EAAA;AAE9B,oBAAA,KAAA,CAAA,aAAA,CAAC,sBAAsB,EAAA,EACrB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAAA,CAClC,CACO,CACJ,CACD;AACT,QAAA,WAAW,KACV,KAAA,CAAA,aAAA,CAAC,IAAI,IACH,WAAW,EAAC,GAAG,EACf,SAAS,EAAC,uBAAuB,EACjC,IAAI,EAAC,aAAa,EAAA;YAElB,KAAA,CAAA,aAAA,CAAC,IAAI,yBAEH,SAAS,EAAC,oCAAoC,EAC9C,MAAM,EAAC,8BAA8B,EAAA,CACrC;AACD,YAAA,WAAW,CACP,CACR,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 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":["todayCalendar","getLocalTimeZone","parseDate","CalendarDate","AriaDatePicker","isSameDay"],"mappings":";;;;;;;;;;;;;AA8CA,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;AAC1E,MAAM,mBAAmB,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;AAC7D,IAAA,KAAK,EAAE,OAAO;AACf,CAAA,CAAC;AACF,MAAM,kBAAkB,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAMhF,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,I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AI,GAAG,SAAS,EAAA;AAE5C,oBAAA,KAAA,CAAA,aAAA,CAAC,sBAAsB,EAAA,EACrB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAAA,CAClC,CACO,CACJ,CACD;AACT,QAAA,WAAW,KACV,KAAA,CAAA,aAAA,CAAC,IAAI,IACH,WAAW,EAAC,GAAG,EACf,SAAS,EAAC,uBAAuB,EACjC,IAAI,EAAC,aAAa,EAAA;YAElB,KAAA,CAAA,aAAA,CAAC,IAAI,yBAEH,SAAS,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,KAAK,EAAE,EAEZ,KAAK,YAAY,EACjB,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,KAAK,EAAE,EAEZ,KAAK,YAAY,EACjB,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-slot';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import React, { useRef, useContext } from 'react';
|
|
3
|
+
import React, { useRef, useContext, useState, useEffect } from 'react';
|
|
4
4
|
import { useInteractOutside, usePreventScroll, FocusScope } from 'react-aria';
|
|
5
5
|
import { MenuTrigger, MenuItem, RootMenuTriggerStateContext, Popover, Menu, MenuSection, Header, Separator, Pressable } from 'react-aria-components/Menu';
|
|
6
6
|
import { PopoverContext } from 'react-aria-components/Popover';
|
|
@@ -53,6 +53,13 @@ function DropdownMenu({ children, id, placement = "bottom start", ...dataAttribu
|
|
|
53
53
|
const state = useContext(RootMenuTriggerStateContext);
|
|
54
54
|
const menuTriggerRef = useMenuTriggerRef();
|
|
55
55
|
const lastPointerType = useRef(null);
|
|
56
|
+
// Release focus containment once a press starts outside the menu, so focus
|
|
57
|
+
// can land on whatever was pressed instead of being pulled back into the menu.
|
|
58
|
+
const [isPointerDownOutside, setIsPointerDownOutside] = useState(false);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!state?.isOpen)
|
|
61
|
+
setIsPointerDownOutside(false);
|
|
62
|
+
}, [state?.isOpen]);
|
|
56
63
|
useInteractOutside({
|
|
57
64
|
isDisabled: !state?.isOpen,
|
|
58
65
|
onInteractOutside: (event) => {
|
|
@@ -67,12 +74,13 @@ function DropdownMenu({ children, id, placement = "bottom start", ...dataAttribu
|
|
|
67
74
|
},
|
|
68
75
|
onInteractOutsideStart: (event) => {
|
|
69
76
|
lastPointerType.current = event.pointerType;
|
|
77
|
+
setIsPointerDownOutside(true);
|
|
70
78
|
},
|
|
71
79
|
ref: popoverRef,
|
|
72
80
|
});
|
|
73
81
|
usePreventScroll({ isDisabled: !state?.isOpen });
|
|
74
82
|
return (React.createElement(Popover, { className: "tds-dropdown-popover", isNonModal: true, placement: placement, ref: popoverRef, shouldCloseOnInteractOutside: () => false },
|
|
75
|
-
React.createElement(FocusScope, { contain:
|
|
83
|
+
React.createElement(FocusScope, { contain: !isPointerDownOutside },
|
|
76
84
|
React.createElement(Menu, { ...dataAttributes, id: id }, children))));
|
|
77
85
|
}
|
|
78
86
|
function DropdownTrigger({ children, disabled }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport { Slot } from \"@radix-ui/react-slot\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport classNames from \"classnames\"\nimport React, {\n type ComponentProps,\n type ReactElement,\n type ReactNode,\n type RefObject,\n useContext,\n useRef,\n} from \"react\"\nimport { FocusScope, useInteractOutside, usePreventScroll } from \"react-aria\"\nimport type {\n Key,\n MenuItemProps,\n MenuSectionProps,\n PopoverProps,\n} from \"react-aria-components\"\nimport {\n Header,\n Menu,\n MenuItem,\n MenuSection,\n MenuTrigger,\n Popover,\n Pressable,\n RootMenuTriggerStateContext,\n Separator,\n} from \"react-aria-components/Menu\"\nimport { PopoverContext } from \"react-aria-components/Popover\"\n\nimport { DropdownTriggerContext } from \"./DropdownTriggerContext\"\n\nexport type DropdownPlacement = NonNullable<PopoverProps[\"placement\"]>\n\nexport interface DropdownProps {\n /**\n * A `<DropdownTrigger>` followed by a `<DropdownMenu>` containing the items.\n */\n children: ReactNode\n /** Fires when the menu closes. */\n onClose?: () => void\n /** Fires when the menu opens. Useful for analytics or lazy data prep. */\n onOpen?: () => void\n}\n\nexport type DropdownElementProps = DropdownProps\n\n/**\n * An action menu — a button that, when activated, reveals a list of actions or\n * navigation links. Composed of a `<DropdownTrigger>` wrapping a Tapestry\n * dropdown-trigger button (`DropdownButton`, `DropdownIconButton`, or\n * `PageHeaderActionsDropdownButton`) and a `<DropdownMenu>` containing\n * `<DropdownAction>`, `<DropdownLink>`, `<DropdownSection>`, and\n * `<DropdownSeparator>` items.\n *\n * Built on React Aria's `MenuTrigger` primitive; popover positioning and menu\n * identity live on `<DropdownMenu>`.\n *\n * @component\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/menu/ | W3C APG Menu Pattern}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport function Dropdown({ children, onClose, onOpen }: DropdownElementProps) {\n const handleOpenChange = (isOpen: boolean) => {\n if (isOpen) onOpen?.()\n else onClose?.()\n }\n\n return <MenuTrigger onOpenChange={handleOpenChange}>{children}</MenuTrigger>\n}\n\nexport interface DropdownMenuProps {\n /** Arbitrary `data-*` attributes are forwarded to the menu element. */\n [key: `data-${string}`]: boolean | number | string | undefined\n /**\n * `<DropdownAction>` / `<DropdownLink>` / `<DropdownSection>` /\n * `<DropdownSeparator>` elements.\n */\n children: ReactNode\n /** Override for the underlying `<Menu>` element id. */\n id?: string\n /**\n * Popover position relative to the trigger. Uses React Aria's\n * space-separated format (e.g., `\"bottom start\"`, `\"top end\"`,\n * `\"left top\"`). Defaults to `\"bottom start\"`.\n */\n placement?: DropdownPlacement\n}\n\nexport type DropdownMenuElementProps = DropdownMenuProps\n\nfunction useMenuTriggerRef() {\n const popoverContext = useContext(PopoverContext)\n return popoverContext && \"triggerRef\" in popoverContext\n ? popoverContext.triggerRef\n : undefined\n}\n\nfunction isTouchOnTrigger({\n event,\n menuTriggerRef,\n pointerType,\n}: {\n event: PointerEvent\n menuTriggerRef: RefObject<Element | null> | undefined\n pointerType: string | null\n}) {\n const isTouch = pointerType === \"touch\"\n const isOnMenuTrigger =\n event.target instanceof Node &&\n Boolean(menuTriggerRef?.current?.contains(event.target))\n return isTouch && isOnMenuTrigger\n}\n\n/**\n * The popover surface for a `<Dropdown>`. Wraps React Aria's `<Popover>` and\n * `<Menu>` and contains the menu items.\n *\n * @component\n */\nexport function DropdownMenu({\n children,\n id,\n placement = \"bottom start\",\n ...dataAttributes\n}: DropdownMenuElementProps) {\n const popoverRef = useRef<HTMLElement>(null)\n const state = useContext(RootMenuTriggerStateContext)\n const menuTriggerRef = useMenuTriggerRef()\n const lastPointerType = useRef<string | null>(null)\n\n useInteractOutside({\n isDisabled: !state?.isOpen,\n onInteractOutside: (event) => {\n const triggerWillToggleClosed = isTouchOnTrigger({\n event,\n menuTriggerRef,\n pointerType: lastPointerType.current,\n })\n if (triggerWillToggleClosed) return\n\n state?.close()\n },\n onInteractOutsideStart: (event) => {\n lastPointerType.current = event.pointerType\n },\n ref: popoverRef,\n })\n usePreventScroll({ isDisabled: !state?.isOpen })\n\n return (\n <Popover\n className=\"tds-dropdown-popover\"\n isNonModal\n placement={placement}\n ref={popoverRef}\n shouldCloseOnInteractOutside={() => false}\n >\n <FocusScope contain>\n <Menu {...dataAttributes} id={id}>\n {children}\n </Menu>\n </FocusScope>\n </Popover>\n )\n}\n\nexport interface DropdownTriggerProps {\n /**\n * A single Tapestry dropdown-trigger button element (`DropdownButton`,\n * `DropdownIconButton`, or `PageHeaderActionsDropdownButton`).\n */\n children: ReactElement\n /**\n * Whether the trigger is disabled. This is the single source of truth for the\n * trigger's disabled state — a `disabled` set directly on the child button\n * does not win.\n */\n disabled?: boolean\n}\n\n/**\n * Wraps a single Tapestry dropdown-trigger button and bridges it to React\n * Aria's `MenuTrigger` via `<Pressable>`.\n * Uses context to pass `disabled` to the trigger button.\n *\n * @component\n */\ntype PressableChild = ComponentProps<typeof Pressable>[\"children\"]\n\nexport function DropdownTrigger({ children, disabled }: DropdownTriggerProps) {\n return (\n <DropdownTriggerContext.Provider value={{ disabled }}>\n <Pressable isDisabled={disabled}>{children as PressableChild}</Pressable>\n </DropdownTriggerContext.Provider>\n )\n}\n\nexport interface DropdownItemBaseProps {\n /** Applies destructive styling. */\n destructive?: boolean\n /** Applies staff-only visual treatment. */\n staffOnly?: boolean\n}\n\nexport interface DropdownActionProps extends DropdownItemBaseProps {\n /**\n * Disables the item. Renamed to React Aria's `isDisabled` inside the\n * wrapper. Disabled items are skipped by keyboard traversal and won't fire\n * `onAction`.\n */\n disabled?: boolean\n /**\n * Stable identifier — required by React Aria's collection model for keying\n * and focus tracking.\n */\n id: Key\n /**\n * Callback fired when the item is activated.\n *\n * React Aria closes the menu and returns focus to the trigger after this\n * runs, which can override a focus change made here — e.g. focusing a\n * nearby input. If `onAction` needs to move focus elsewhere, wrap that\n * part in `queueMicrotask` to defer it until after React Aria's\n * focus-restore has finished: `queueMicrotask(() => inputRef.current?.focus())`.\n */\n onAction: () => void\n /** Whether activating the item closes the menu. Defaults to `true`. */\n shouldCloseOnSelect?: boolean\n}\n\ntype AriaActionPropsToOmit =\n | \"href\"\n | \"isDisabled\"\n | \"rel\"\n | \"routerOptions\"\n | \"target\"\n | \"value\"\ntype AriaActionPropsToInclude = \"textValue\"\n\nexport type DropdownActionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuItemProps<T>,\n DropdownActionProps,\n AriaActionPropsToOmit,\n AriaActionPropsToInclude\n >\n\n/**\n * A `<Dropdown>` item that fires a callback when activated. Renders an RA\n * `<MenuItem>` (`role=\"menuitem\"`). Children are passed through and can use\n * the slot convention (`slot=\"label\" | \"prefix\" | \"suffix\" | \"description\"`)\n * for structured content.\n *\n * @component\n */\nexport function DropdownAction<T extends object>({\n className,\n destructive,\n disabled,\n staffOnly,\n ...restProps\n}: DropdownActionElementProps<T>) {\n return (\n <MenuItem\n {...restProps}\n className={classNames(\n \"tds-dropdown-item\",\n {\n \"tds-dropdown-item--destructive\": destructive,\n \"tds-dropdown-item--staff-only\": staffOnly,\n },\n className\n )}\n isDisabled={disabled}\n />\n )\n}\n\nexport interface DropdownLinkBaseProps extends DropdownItemBaseProps {\n /** If `true`, sets `target=\"_blank\"` and `rel=\"noreferrer noopener\"`. */\n external?: boolean\n /**\n * Stable identifier — required by React Aria's collection model for keying\n * and focus tracking.\n */\n id: Key\n}\n\nexport interface DropdownLinkAsChildProps extends DropdownLinkBaseProps {\n /**\n * Merge menu item behavior onto a single child element (e.g. a router\n * `Link`) instead of rendering an `<a>`. When true, `href` must not be set.\n * **Not supported in Rails.**\n */\n asChild: true\n href?: never\n}\n\nexport interface DropdownLinkHrefProps extends DropdownLinkBaseProps {\n asChild?: false\n /** Destination URL. */\n href: string\n}\n\nexport type DropdownLinkProps = DropdownLinkAsChildProps | DropdownLinkHrefProps\n\ntype AriaLinkPropsToOmit =\n | \"isDisabled\"\n | \"onAction\"\n | \"rel\"\n | \"render\"\n | \"target\"\n | \"value\"\ntype AriaLinkPropsToInclude = \"routerOptions\" | \"textValue\"\n\nexport type DropdownLinkElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuItemProps<T>,\n DropdownLinkProps,\n AriaLinkPropsToOmit,\n AriaLinkPropsToInclude\n >\n\n/** Strips RAC-injected `undefined` values (e.g. `href`) that would otherwise clobber a child's own prop of the same name via `Slot`. */\nfunction omitUndefinedValues<T extends object>(props: T): Partial<T> {\n return Object.fromEntries(\n Object.entries(props).filter(([, value]) => value !== undefined)\n ) as Partial<T>\n}\n\n/**\n * A `<Dropdown>` item that navigates to a URL. Renders an RA `<MenuItem>` as\n * an anchor (`<a role=\"menuitem\" href=\"…\">`). Pass `external` to open in a\n * new tab with `rel=\"noreferrer noopener\"`.\n *\n * `disabled` is intentionally not accepted — HTML has no native disabled state\n * for anchors, and a \"disabled link\" has no accessible analog. If a link\n * shouldn't be activatable, omit it.\n *\n * @component\n */\nexport function DropdownLink<T extends object>({\n asChild = false,\n children,\n className,\n destructive,\n external,\n staffOnly,\n ...restProps\n}: DropdownLinkElementProps<T>) {\n const externalProps = external\n ? { rel: \"noreferrer noopener\", target: \"_blank\" as const }\n : null\n return (\n <MenuItem\n {...restProps}\n {...externalProps}\n className={classNames(\n \"tds-dropdown-item\",\n {\n \"tds-dropdown-item--destructive\": destructive,\n \"tds-dropdown-item--staff-only\": staffOnly,\n },\n className\n )}\n render={\n asChild\n ? (props) => (\n <Slot {...omitUndefinedValues(props)}>\n {children as ReactElement}\n </Slot>\n )\n : undefined\n }\n >\n {asChild ? undefined : children}\n </MenuItem>\n )\n}\n\nexport interface DropdownSectionProps {\n /** The items rendered within the section. */\n children: ReactNode\n /**\n * Heading rendered above the section's items. Required — RA renders the\n * section as `role=\"group\"` and the heading provides the group's\n * accessible name via `aria-labelledby`.\n */\n title: string\n}\n\nexport type DropdownSectionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuSectionProps<T>,\n DropdownSectionProps,\n \"value\",\n never\n >\n\n/**\n * A grouped section within a `<Dropdown>`. Renders an RA `<MenuSection>`\n * (`role=\"group\"`) with an optional `<Header>` heading when `title` is set.\n *\n * @component\n */\nexport function DropdownSection<T extends object>({\n children,\n className,\n title,\n ...restProps\n}: DropdownSectionElementProps<T>) {\n return (\n <MenuSection\n {...restProps}\n className={classNames(\"tds-dropdown-section\", className)}\n >\n <Header className=\"tds-dropdown-section-label\">{title}</Header>\n {children}\n </MenuSection>\n )\n}\n\nexport type DropdownSeparatorElementProps = Record<string, never>\n\n/**\n * A divider between items in a `<Dropdown>`. Renders an RA `<Separator>`\n * (`role=\"separator\"`).\n *\n * @component\n */\nexport function DropdownSeparator() {\n return <Separator className=\"tds-dropdown-separator\" />\n}\n"],"names":[],"mappings":";;;;;;;;AAkDA;;;;;;;;;;;;;;AAcG;AACG,SAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAwB,EAAA;AAC1E,IAAA,MAAM,gBAAgB,GAAG,CAAC,MAAe,KAAI;AAC3C,QAAA,IAAI,MAAM;YAAE,MAAM,IAAI;;YACjB,OAAO,IAAI;AAClB,IAAA,CAAC;IAED,OAAO,KAAA,CAAA,aAAA,CAAC,WAAW,EAAA,EAAC,YAAY,EAAE,gBAAgB,EAAA,EAAG,QAAQ,CAAe;AAC9E;AAsBA,SAAS,iBAAiB,GAAA;AACxB,IAAA,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;AACjD,IAAA,OAAO,cAAc,IAAI,YAAY,IAAI;UACrC,cAAc,CAAC;UACf,SAAS;AACf;AAEA,SAAS,gBAAgB,CAAC,EACxB,KAAK,EACL,cAAc,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T,GAAG,SAAS,EACgB,EAAA;IAC5B,MAAM,aAAa,GAAG;UAClB,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAiB;UACvD,IAAI;AACR,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,EAAA,GACH,SAAS,EAAA,GACT,aAAa,EACjB,SAAS,EAAE,UAAU,CACnB,mBAAmB,EACnB;AACE,YAAA,gCAAgC,EAAE,WAAW;AAC7C,YAAA,+BAA+B,EAAE,SAAS;AAC3C,SAAA,EACD,SAAS,CACV,EACD,MAAM,EACJ;AACE,cAAE,CAAC,KAAK,MACJ,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAA,GAAK,mBAAmB,CAAC,KAAK,CAAC,EAAA,EACjC,QAAwB,CACpB;AAEX,cAAE,SAAS,EAAA,EAGd,OAAO,GAAG,SAAS,GAAG,QAAQ,CACtB;AAEf;AAqBA;;;;;AAKG;AACG,SAAU,eAAe,CAAmB,EAChD,QAAQ,EACR,SAAS,EACT,KAAK,EACL,GAAG,SAAS,EACmB,EAAA;AAC/B,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,WAAW,EAAA,EAAA,GACN,SAAS,EACb,SAAS,EAAE,UAAU,CAAC,sBAAsB,EAAE,SAAS,CAAC,EAAA;AAExD,QAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,SAAS,EAAC,4BAA4B,EAAA,EAAE,KAAK,CAAU;QAC9D,QAAQ,CACG;AAElB;AAIA;;;;;AAKG;SACa,iBAAiB,GAAA;AAC/B,IAAA,OAAO,oBAAC,SAAS,EAAA,EAAC,SAAS,EAAC,wBAAwB,GAAG;AACzD;;;;"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport { Slot } from \"@radix-ui/react-slot\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport classNames from \"classnames\"\nimport React, {\n type ComponentProps,\n type ReactElement,\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport { FocusScope, useInteractOutside, usePreventScroll } from \"react-aria\"\nimport type {\n Key,\n MenuItemProps,\n MenuSectionProps,\n PopoverProps,\n} from \"react-aria-components\"\nimport {\n Header,\n Menu,\n MenuItem,\n MenuSection,\n MenuTrigger,\n Popover,\n Pressable,\n RootMenuTriggerStateContext,\n Separator,\n} from \"react-aria-components/Menu\"\nimport { PopoverContext } from \"react-aria-components/Popover\"\n\nimport { DropdownTriggerContext } from \"./DropdownTriggerContext\"\n\nexport type DropdownPlacement = NonNullable<PopoverProps[\"placement\"]>\n\nexport interface DropdownProps {\n /**\n * A `<DropdownTrigger>` followed by a `<DropdownMenu>` containing the items.\n */\n children: ReactNode\n /** Fires when the menu closes. */\n onClose?: () => void\n /** Fires when the menu opens. Useful for analytics or lazy data prep. */\n onOpen?: () => void\n}\n\nexport type DropdownElementProps = DropdownProps\n\n/**\n * An action menu — a button that, when activated, reveals a list of actions or\n * navigation links. Composed of a `<DropdownTrigger>` wrapping a Tapestry\n * dropdown-trigger button (`DropdownButton`, `DropdownIconButton`, or\n * `PageHeaderActionsDropdownButton`) and a `<DropdownMenu>` containing\n * `<DropdownAction>`, `<DropdownLink>`, `<DropdownSection>`, and\n * `<DropdownSeparator>` items.\n *\n * Built on React Aria's `MenuTrigger` primitive; popover positioning and menu\n * identity live on `<DropdownMenu>`.\n *\n * @component\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/menu/ | W3C APG Menu Pattern}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport function Dropdown({ children, onClose, onOpen }: DropdownElementProps) {\n const handleOpenChange = (isOpen: boolean) => {\n if (isOpen) onOpen?.()\n else onClose?.()\n }\n\n return <MenuTrigger onOpenChange={handleOpenChange}>{children}</MenuTrigger>\n}\n\nexport interface DropdownMenuProps {\n /** Arbitrary `data-*` attributes are forwarded to the menu element. */\n [key: `data-${string}`]: boolean | number | string | undefined\n /**\n * `<DropdownAction>` / `<DropdownLink>` / `<DropdownSection>` /\n * `<DropdownSeparator>` elements.\n */\n children: ReactNode\n /** Override for the underlying `<Menu>` element id. */\n id?: string\n /**\n * Popover position relative to the trigger. Uses React Aria's\n * space-separated format (e.g., `\"bottom start\"`, `\"top end\"`,\n * `\"left top\"`). Defaults to `\"bottom start\"`.\n */\n placement?: DropdownPlacement\n}\n\nexport type DropdownMenuElementProps = DropdownMenuProps\n\nfunction useMenuTriggerRef() {\n const popoverContext = useContext(PopoverContext)\n return popoverContext && \"triggerRef\" in popoverContext\n ? popoverContext.triggerRef\n : undefined\n}\n\nfunction isTouchOnTrigger({\n event,\n menuTriggerRef,\n pointerType,\n}: {\n event: PointerEvent\n menuTriggerRef: RefObject<Element | null> | undefined\n pointerType: string | null\n}) {\n const isTouch = pointerType === \"touch\"\n const isOnMenuTrigger =\n event.target instanceof Node &&\n Boolean(menuTriggerRef?.current?.contains(event.target))\n return isTouch && isOnMenuTrigger\n}\n\n/**\n * The popover surface for a `<Dropdown>`. Wraps React Aria's `<Popover>` and\n * `<Menu>` and contains the menu items.\n *\n * @component\n */\nexport function DropdownMenu({\n children,\n id,\n placement = \"bottom start\",\n ...dataAttributes\n}: DropdownMenuElementProps) {\n const popoverRef = useRef<HTMLElement>(null)\n const state = useContext(RootMenuTriggerStateContext)\n const menuTriggerRef = useMenuTriggerRef()\n const lastPointerType = useRef<string | null>(null)\n // Release focus containment once a press starts outside the menu, so focus\n // can land on whatever was pressed instead of being pulled back into the menu.\n const [isPointerDownOutside, setIsPointerDownOutside] = useState(false)\n\n useEffect(() => {\n if (!state?.isOpen) setIsPointerDownOutside(false)\n }, [state?.isOpen])\n\n useInteractOutside({\n isDisabled: !state?.isOpen,\n onInteractOutside: (event) => {\n const triggerWillToggleClosed = isTouchOnTrigger({\n event,\n menuTriggerRef,\n pointerType: lastPointerType.current,\n })\n if (triggerWillToggleClosed) return\n\n state?.close()\n },\n onInteractOutsideStart: (event) => {\n lastPointerType.current = event.pointerType\n setIsPointerDownOutside(true)\n },\n ref: popoverRef,\n })\n usePreventScroll({ isDisabled: !state?.isOpen })\n\n return (\n <Popover\n className=\"tds-dropdown-popover\"\n isNonModal\n placement={placement}\n ref={popoverRef}\n shouldCloseOnInteractOutside={() => false}\n >\n <FocusScope contain={!isPointerDownOutside}>\n <Menu {...dataAttributes} id={id}>\n {children}\n </Menu>\n </FocusScope>\n </Popover>\n )\n}\n\nexport interface DropdownTriggerProps {\n /**\n * A single Tapestry dropdown-trigger button element (`DropdownButton`,\n * `DropdownIconButton`, or `PageHeaderActionsDropdownButton`).\n */\n children: ReactElement\n /**\n * Whether the trigger is disabled. This is the single source of truth for the\n * trigger's disabled state — a `disabled` set directly on the child button\n * does not win.\n */\n disabled?: boolean\n}\n\n/**\n * Wraps a single Tapestry dropdown-trigger button and bridges it to React\n * Aria's `MenuTrigger` via `<Pressable>`.\n * Uses context to pass `disabled` to the trigger button.\n *\n * @component\n */\ntype PressableChild = ComponentProps<typeof Pressable>[\"children\"]\n\nexport function DropdownTrigger({ children, disabled }: DropdownTriggerProps) {\n return (\n <DropdownTriggerContext.Provider value={{ disabled }}>\n <Pressable isDisabled={disabled}>{children as PressableChild}</Pressable>\n </DropdownTriggerContext.Provider>\n )\n}\n\nexport interface DropdownItemBaseProps {\n /** Applies destructive styling. */\n destructive?: boolean\n /** Applies staff-only visual treatment. */\n staffOnly?: boolean\n}\n\nexport interface DropdownActionProps extends DropdownItemBaseProps {\n /**\n * Disables the item. Renamed to React Aria's `isDisabled` inside the\n * wrapper. Disabled items are skipped by keyboard traversal and won't fire\n * `onAction`.\n */\n disabled?: boolean\n /**\n * Stable identifier — required by React Aria's collection model for keying\n * and focus tracking.\n */\n id: Key\n /**\n * Callback fired when the item is activated.\n *\n * React Aria closes the menu and returns focus to the trigger after this\n * runs, which can override a focus change made here — e.g. focusing a\n * nearby input. If `onAction` needs to move focus elsewhere, wrap that\n * part in `queueMicrotask` to defer it until after React Aria's\n * focus-restore has finished: `queueMicrotask(() => inputRef.current?.focus())`.\n */\n onAction: () => void\n /** Whether activating the item closes the menu. Defaults to `true`. */\n shouldCloseOnSelect?: boolean\n}\n\ntype AriaActionPropsToOmit =\n | \"href\"\n | \"isDisabled\"\n | \"rel\"\n | \"routerOptions\"\n | \"target\"\n | \"value\"\ntype AriaActionPropsToInclude = \"textValue\"\n\nexport type DropdownActionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuItemProps<T>,\n DropdownActionProps,\n AriaActionPropsToOmit,\n AriaActionPropsToInclude\n >\n\n/**\n * A `<Dropdown>` item that fires a callback when activated. Renders an RA\n * `<MenuItem>` (`role=\"menuitem\"`). Children are passed through and can use\n * the slot convention (`slot=\"label\" | \"prefix\" | \"suffix\" | \"description\"`)\n * for structured content.\n *\n * @component\n */\nexport function DropdownAction<T extends object>({\n className,\n destructive,\n disabled,\n staffOnly,\n ...restProps\n}: DropdownActionElementProps<T>) {\n return (\n <MenuItem\n {...restProps}\n className={classNames(\n \"tds-dropdown-item\",\n {\n \"tds-dropdown-item--destructive\": destructive,\n \"tds-dropdown-item--staff-only\": staffOnly,\n },\n className\n )}\n isDisabled={disabled}\n />\n )\n}\n\nexport interface DropdownLinkBaseProps extends DropdownItemBaseProps {\n /** If `true`, sets `target=\"_blank\"` and `rel=\"noreferrer noopener\"`. */\n external?: boolean\n /**\n * Stable identifier — required by React Aria's collection model for keying\n * and focus tracking.\n */\n id: Key\n}\n\nexport interface DropdownLinkAsChildProps extends DropdownLinkBaseProps {\n /**\n * Merge menu item behavior onto a single child element (e.g. a router\n * `Link`) instead of rendering an `<a>`. When true, `href` must not be set.\n * **Not supported in Rails.**\n */\n asChild: true\n href?: never\n}\n\nexport interface DropdownLinkHrefProps extends DropdownLinkBaseProps {\n asChild?: false\n /** Destination URL. */\n href: string\n}\n\nexport type DropdownLinkProps = DropdownLinkAsChildProps | DropdownLinkHrefProps\n\ntype AriaLinkPropsToOmit =\n | \"isDisabled\"\n | \"onAction\"\n | \"rel\"\n | \"render\"\n | \"target\"\n | \"value\"\ntype AriaLinkPropsToInclude = \"routerOptions\" | \"textValue\"\n\nexport type DropdownLinkElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuItemProps<T>,\n DropdownLinkProps,\n AriaLinkPropsToOmit,\n AriaLinkPropsToInclude\n >\n\n/** Strips RAC-injected `undefined` values (e.g. `href`) that would otherwise clobber a child's own prop of the same name via `Slot`. */\nfunction omitUndefinedValues<T extends object>(props: T): Partial<T> {\n return Object.fromEntries(\n Object.entries(props).filter(([, value]) => value !== undefined)\n ) as Partial<T>\n}\n\n/**\n * A `<Dropdown>` item that navigates to a URL. Renders an RA `<MenuItem>` as\n * an anchor (`<a role=\"menuitem\" href=\"…\">`). Pass `external` to open in a\n * new tab with `rel=\"noreferrer noopener\"`.\n *\n * `disabled` is intentionally not accepted — HTML has no native disabled state\n * for anchors, and a \"disabled link\" has no accessible analog. If a link\n * shouldn't be activatable, omit it.\n *\n * @component\n */\nexport function DropdownLink<T extends object>({\n asChild = false,\n children,\n className,\n destructive,\n external,\n staffOnly,\n ...restProps\n}: DropdownLinkElementProps<T>) {\n const externalProps = external\n ? { rel: \"noreferrer noopener\", target: \"_blank\" as const }\n : null\n return (\n <MenuItem\n {...restProps}\n {...externalProps}\n className={classNames(\n \"tds-dropdown-item\",\n {\n \"tds-dropdown-item--destructive\": destructive,\n \"tds-dropdown-item--staff-only\": staffOnly,\n },\n className\n )}\n render={\n asChild\n ? (props) => (\n <Slot {...omitUndefinedValues(props)}>\n {children as ReactElement}\n </Slot>\n )\n : undefined\n }\n >\n {asChild ? undefined : children}\n </MenuItem>\n )\n}\n\nexport interface DropdownSectionProps {\n /** The items rendered within the section. */\n children: ReactNode\n /**\n * Heading rendered above the section's items. Required — RA renders the\n * section as `role=\"group\"` and the heading provides the group's\n * accessible name via `aria-labelledby`.\n */\n title: string\n}\n\nexport type DropdownSectionElementProps<T extends object = object> =\n CombineAriaPropsWithCustomProps<\n MenuSectionProps<T>,\n DropdownSectionProps,\n \"value\",\n never\n >\n\n/**\n * A grouped section within a `<Dropdown>`. Renders an RA `<MenuSection>`\n * (`role=\"group\"`) with an optional `<Header>` heading when `title` is set.\n *\n * @component\n */\nexport function DropdownSection<T extends object>({\n children,\n className,\n title,\n ...restProps\n}: DropdownSectionElementProps<T>) {\n return (\n <MenuSection\n {...restProps}\n className={classNames(\"tds-dropdown-section\", className)}\n >\n <Header className=\"tds-dropdown-section-label\">{title}</Header>\n {children}\n </MenuSection>\n )\n}\n\nexport type DropdownSeparatorElementProps = Record<string, never>\n\n/**\n * A divider between items in a `<Dropdown>`. Renders an RA `<Separator>`\n * (`role=\"separator\"`).\n *\n * @component\n */\nexport function DropdownSeparator() {\n return <Separator className=\"tds-dropdown-separator\" />\n}\n"],"names":[],"mappings":";;;;;;;;AAoDA;;;;;;;;;;;;;;AAcG;AACG,SAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAwB,EAAA;AAC1E,IAAA,MAAM,gBAAgB,GAAG,CAAC,MAAe,KAAI;AAC3C,QAAA,IAAI,MAAM;YAAE,MAAM,IAAI;;YACjB,OAAO,IAAI;AAClB,IAAA,CAAC;IAED,OAAO,KAAA,CAAA,aAAA,CAAC,WAAW,EAAA,EAAC,YAAY,EAAE,gBAAgB,EAAA,EAAG,QAAQ,CAAe;AAC9E;AAsBA,SAAS,iBAAiB,GAAA;AACxB,IAAA,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;AACjD,IAAA,OAAO,cAAc,IAAI,YAAY,IAAI;UACrC,cAAc,CAAC;UACf,SAAS;AACf;AAEA,SAAS,gBAAgB,CAAC,EACxB,KAAK,EACL,cAAc,EACd,WAAW,GAKZ,EAAA;AACC,IAAA,MAAM,OAAO,GAAG,WAAW,KAAK,OAAO;AACvC,IAAA,MAAM,eAAe,GACn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;;"}
|
|
@@ -2,7 +2,7 @@ import { useTooltipTriggerProps } from '../internal/tooltip/useTooltipTriggerPro
|
|
|
2
2
|
import { Slot, Slottable } from '@radix-ui/react-slot';
|
|
3
3
|
import { COMPONENT_SIZE_CLASS_MAP, COMPONENT_KIND_CLASS_MAP, wrapStringWithSpan } from '../../utilities/buttonLinkShared.js';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
6
|
|
|
7
7
|
const BaseLink = forwardRef(({ asChild = false, "aria-describedby": ariaDescribedBy, children, className, external = false, fullWidth, href, kind, label, prefix, size, suffix, ...restProps }, ref) => {
|
|
8
8
|
const { describedBy, mergedProps, mergedRef } = useTooltipTriggerProps(restProps, ref, ariaDescribedBy);
|
|
@@ -11,9 +11,9 @@ const BaseLink = forwardRef(({ asChild = false, "aria-describedby": ariaDescribe
|
|
|
11
11
|
? { rel: "noopener noreferrer", target: "_blank" }
|
|
12
12
|
: {};
|
|
13
13
|
const Comp = asChild ? Slot : "a";
|
|
14
|
-
return (
|
|
14
|
+
return (React.createElement(Comp, { ...(!asChild && { href }), className: combinedClassName, ref: mergedRef, ...mergedProps, "aria-describedby": describedBy, ...externalProps },
|
|
15
15
|
wrapStringWithSpan(prefix),
|
|
16
|
-
|
|
16
|
+
React.createElement(Slottable, null, label || children),
|
|
17
17
|
wrapStringWithSpan(suffix)));
|
|
18
18
|
});
|
|
19
19
|
BaseLink.displayName = "BaseLink";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLink.js","sources":["../../../src/components/link/BaseLink.tsx"],"sourcesContent":["import \"../button/btn.css\"\n\nimport { useTooltipTriggerProps } from \"@components/internal/tooltip/useTooltipTriggerProps\"\nimport { Slot, Slottable } from \"@radix-ui/react-slot\"\nimport {\n BaseComponentProps,\n COMPONENT_KIND_CLASS_MAP,\n COMPONENT_SIZE_CLASS_MAP,\n ComponentKind,\n wrapStringWithSpan,\n} from \"@utilities/buttonLinkShared\"\nimport { Simplify } from \"@utilities/typeUtils\"\nimport classNames from \"classnames\"\nimport React, { AnchorHTMLAttributes, forwardRef } from \"react\"\n\ntype BaseLinkBaseProps = BaseComponentProps &\n Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof BaseComponentProps | \"children\" | \"href\"\n > & {\n children?: React.ReactNode\n external?: boolean\n kind?: ComponentKind\n label?: React.ReactNode\n }\n\nexport type BaseLinkElementProps =\n | Simplify<\n BaseLinkBaseProps & {\n /**\n * When true, merges the link's styling onto the child element instead\n * of rendering an `<a>`. Use to wrap a router link (e.g. react-router,\n * Next.js) or any link-like component. The `external` prop still\n * applies — it spreads `rel`/`target` onto the child element.\n */\n asChild: true\n href?: never\n }\n >\n | Simplify<BaseLinkBaseProps & { asChild?: false; href: string }>\n\nexport const BaseLink = forwardRef<HTMLAnchorElement, BaseLinkElementProps>(\n (\n {\n asChild = false,\n \"aria-describedby\": ariaDescribedBy,\n children,\n className,\n external = false,\n fullWidth,\n href,\n kind,\n label,\n prefix,\n size,\n suffix,\n ...restProps\n }: BaseLinkElementProps,\n ref\n ) => {\n const { describedBy, mergedProps, mergedRef } = useTooltipTriggerProps(\n restProps,\n ref,\n ariaDescribedBy\n )\n\n const combinedClassName = classNames(\n kind && \"tds-btn\",\n size && size !== \"md\" && kind && COMPONENT_SIZE_CLASS_MAP[size],\n kind && COMPONENT_KIND_CLASS_MAP[kind],\n fullWidth && \"tds-btn--full-width\",\n className,\n { \"tds-btn--prefix\": prefix, \"tds-btn--suffix\": suffix }\n )\n\n const externalProps = external\n ? { rel: \"noopener noreferrer\", target: \"_blank\" }\n : {}\n\n const Comp = asChild ? Slot : \"a\"\n\n return (\n <Comp\n {...(!asChild && { href })}\n className={combinedClassName}\n ref={mergedRef}\n {...mergedProps}\n aria-describedby={describedBy}\n {...externalProps}\n >\n {wrapStringWithSpan(prefix)}\n <Slottable>{label || children}</Slottable>\n {wrapStringWithSpan(suffix)}\n </Comp>\n )\n }\n)\n\nBaseLink.displayName = \"BaseLink\"\n"],"names":[
|
|
1
|
+
{"version":3,"file":"BaseLink.js","sources":["../../../src/components/link/BaseLink.tsx"],"sourcesContent":["import \"../button/btn.css\"\n\nimport { useTooltipTriggerProps } from \"@components/internal/tooltip/useTooltipTriggerProps\"\nimport { Slot, Slottable } from \"@radix-ui/react-slot\"\nimport {\n BaseComponentProps,\n COMPONENT_KIND_CLASS_MAP,\n COMPONENT_SIZE_CLASS_MAP,\n ComponentKind,\n wrapStringWithSpan,\n} from \"@utilities/buttonLinkShared\"\nimport { Simplify } from \"@utilities/typeUtils\"\nimport classNames from \"classnames\"\nimport React, { AnchorHTMLAttributes, forwardRef } from \"react\"\n\ntype BaseLinkBaseProps = BaseComponentProps &\n Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof BaseComponentProps | \"children\" | \"href\"\n > & {\n children?: React.ReactNode\n external?: boolean\n kind?: ComponentKind\n label?: React.ReactNode\n }\n\nexport type BaseLinkElementProps =\n | Simplify<\n BaseLinkBaseProps & {\n /**\n * When true, merges the link's styling onto the child element instead\n * of rendering an `<a>`. Use to wrap a router link (e.g. react-router,\n * Next.js) or any link-like component. The `external` prop still\n * applies — it spreads `rel`/`target` onto the child element.\n */\n asChild: true\n href?: never\n }\n >\n | Simplify<BaseLinkBaseProps & { asChild?: false; href: string }>\n\nexport const BaseLink = forwardRef<HTMLAnchorElement, BaseLinkElementProps>(\n (\n {\n asChild = false,\n \"aria-describedby\": ariaDescribedBy,\n children,\n className,\n external = false,\n fullWidth,\n href,\n kind,\n label,\n prefix,\n size,\n suffix,\n ...restProps\n }: BaseLinkElementProps,\n ref\n ) => {\n const { describedBy, mergedProps, mergedRef } = useTooltipTriggerProps(\n restProps,\n ref,\n ariaDescribedBy\n )\n\n const combinedClassName = classNames(\n kind && \"tds-btn\",\n size && size !== \"md\" && kind && COMPONENT_SIZE_CLASS_MAP[size],\n kind && COMPONENT_KIND_CLASS_MAP[kind],\n fullWidth && \"tds-btn--full-width\",\n className,\n { \"tds-btn--prefix\": prefix, \"tds-btn--suffix\": suffix }\n )\n\n const externalProps = external\n ? { rel: \"noopener noreferrer\", target: \"_blank\" }\n : {}\n\n const Comp = asChild ? Slot : \"a\"\n\n return (\n <Comp\n {...(!asChild && { href })}\n className={combinedClassName}\n ref={mergedRef}\n {...mergedProps}\n aria-describedby={describedBy}\n {...externalProps}\n >\n {wrapStringWithSpan(prefix)}\n <Slottable>{label || children}</Slottable>\n {wrapStringWithSpan(suffix)}\n </Comp>\n )\n }\n)\n\nBaseLink.displayName = \"BaseLink\"\n"],"names":[],"mappings":";;;;;;MAyCa,QAAQ,GAAG,UAAU,CAChC,CACE,EACE,OAAO,GAAG,KAAK,EACf,kBAAkB,EAAE,eAAe,EACnC,QAAQ,EACR,SAAS,EACT,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,GAAG,SAAS,EACS,EACvB,GAAG,KACD;AACF,IAAA,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,sBAAsB,CACpE,SAAS,EACT,GAAG,EACH,eAAe,CAChB;IAED,MAAM,iBAAiB,GAAG,UAAU,CAClC,IAAI,IAAI,SAAS,EACjB,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,wBAAwB,CAAC,IAAI,CAAC,EAC/D,IAAI,IAAI,wBAAwB,CAAC,IAAI,CAAC,EACtC,SAAS,IAAI,qBAAqB,EAClC,SAAS,EACT,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,CACzD;IAED,MAAM,aAAa,GAAG;UAClB,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ;UAC9C,EAAE;IAEN,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,GAAG;IAEjC,QACE,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAA,IACE,CAAC,OAAO,IAAI,EAAE,IAAI,EAAE,CAAC,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,SAAS,EAAA,GACV,WAAW,EAAA,kBAAA,EACG,WAAW,EAAA,GACzB,aAAa,EAAA;QAEhB,kBAAkB,CAAC,MAAM,CAAC;AAC3B,QAAA,KAAA,CAAA,aAAA,CAAC,SAAS,EAAA,IAAA,EAAE,KAAK,IAAI,QAAQ,CAAa;AACzC,QAAA,kBAAkB,CAAC,MAAM,CAAC,CACtB;AAEX,CAAC;AAGH,QAAQ,CAAC,WAAW,GAAG,UAAU;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tooltip } from '../internal/tooltip/Tooltip.js';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
4
|
import { BaseLink } from './BaseLink.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -15,10 +15,10 @@ const IconLink = forwardRef(({ className, href, icon, tooltip, tooltipPlacement
|
|
|
15
15
|
const iconOnlyClassName = classNames("tds-btn--icononly", className);
|
|
16
16
|
if (tooltip) {
|
|
17
17
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...linkProps } = restProps;
|
|
18
|
-
return (
|
|
19
|
-
|
|
18
|
+
return (React.createElement(Tooltip, { content: tooltip, placement: tooltipPlacement, visualOnly: true },
|
|
19
|
+
React.createElement(BaseLink, { href: href, label: icon, className: iconOnlyClassName, ref: ref, ...linkProps, "aria-label": ariaLabel || tooltip })));
|
|
20
20
|
}
|
|
21
|
-
return (
|
|
21
|
+
return (React.createElement(BaseLink, { href: href, label: icon, className: iconOnlyClassName, ref: ref, ...restProps }));
|
|
22
22
|
});
|
|
23
23
|
IconLink.displayName = "IconLink";
|
|
24
24
|
|