@wordpress/components 29.12.0 → 29.13.1-next.719a03cbe.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.
Files changed (157) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/box-control/input-control.js +2 -2
  3. package/build/box-control/input-control.js.map +1 -1
  4. package/build/calendar/date-calendar/index.js +60 -0
  5. package/build/calendar/date-calendar/index.js.map +1 -0
  6. package/build/calendar/date-range-calendar/index.js +168 -0
  7. package/build/calendar/date-range-calendar/index.js.map +1 -0
  8. package/build/calendar/index.js +27 -0
  9. package/build/calendar/index.js.map +1 -0
  10. package/build/calendar/types.js +6 -0
  11. package/build/calendar/types.js.map +1 -0
  12. package/build/calendar/utils/constants.js +68 -0
  13. package/build/calendar/utils/constants.js.map +1 -0
  14. package/build/calendar/utils/day-cell.js +137 -0
  15. package/build/calendar/utils/day-cell.js.map +1 -0
  16. package/build/calendar/utils/misc.js +10 -0
  17. package/build/calendar/utils/misc.js.map +1 -0
  18. package/build/calendar/utils/use-controlled-value.js +58 -0
  19. package/build/calendar/utils/use-controlled-value.js.map +1 -0
  20. package/build/calendar/utils/use-localization-props.js +162 -0
  21. package/build/calendar/utils/use-localization-props.js.map +1 -0
  22. package/build/custom-gradient-picker/gradient-bar/control-points.js +1 -1
  23. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  24. package/build/custom-select-control-v2/custom-select.js +3 -3
  25. package/build/custom-select-control-v2/custom-select.js.map +1 -1
  26. package/build/date-time/date/index.js +1 -1
  27. package/build/date-time/date/index.js.map +1 -1
  28. package/build/form-token-field/index.js +11 -1
  29. package/build/form-token-field/index.js.map +1 -1
  30. package/build/form-token-field/token.js +1 -1
  31. package/build/form-token-field/token.js.map +1 -1
  32. package/build/index.js +19 -0
  33. package/build/index.js.map +1 -1
  34. package/build/mobile/bottom-sheet/cell.native.js +2 -2
  35. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  36. package/build/mobile/link-picker/index.native.js +1 -1
  37. package/build/mobile/link-picker/index.native.js.map +1 -1
  38. package/build/navigation/menu/menu-title-search.js +1 -1
  39. package/build/navigation/menu/menu-title-search.js.map +1 -1
  40. package/build/palette-edit/index.js +4 -4
  41. package/build/palette-edit/index.js.map +1 -1
  42. package/build-module/box-control/input-control.js +2 -2
  43. package/build-module/box-control/input-control.js.map +1 -1
  44. package/build-module/calendar/date-calendar/index.js +51 -0
  45. package/build-module/calendar/date-calendar/index.js.map +1 -0
  46. package/build-module/calendar/date-range-calendar/index.js +157 -0
  47. package/build-module/calendar/date-range-calendar/index.js.map +1 -0
  48. package/build-module/calendar/index.js +4 -0
  49. package/build-module/calendar/index.js.map +1 -0
  50. package/build-module/calendar/types.js +2 -0
  51. package/build-module/calendar/types.js.map +1 -0
  52. package/build-module/calendar/utils/constants.js +61 -0
  53. package/build-module/calendar/utils/constants.js.map +1 -0
  54. package/build-module/calendar/utils/day-cell.js +131 -0
  55. package/build-module/calendar/utils/day-cell.js.map +1 -0
  56. package/build-module/calendar/utils/misc.js +4 -0
  57. package/build-module/calendar/utils/misc.js.map +1 -0
  58. package/build-module/calendar/utils/use-controlled-value.js +51 -0
  59. package/build-module/calendar/utils/use-controlled-value.js.map +1 -0
  60. package/build-module/calendar/utils/use-localization-props.js +154 -0
  61. package/build-module/calendar/utils/use-localization-props.js.map +1 -0
  62. package/build-module/custom-gradient-picker/gradient-bar/control-points.js +1 -1
  63. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  64. package/build-module/custom-select-control-v2/custom-select.js +4 -4
  65. package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
  66. package/build-module/date-time/date/index.js +1 -1
  67. package/build-module/date-time/date/index.js.map +1 -1
  68. package/build-module/form-token-field/index.js +11 -1
  69. package/build-module/form-token-field/index.js.map +1 -1
  70. package/build-module/form-token-field/token.js +1 -1
  71. package/build-module/form-token-field/token.js.map +1 -1
  72. package/build-module/index.js +1 -0
  73. package/build-module/index.js.map +1 -1
  74. package/build-module/mobile/bottom-sheet/cell.native.js +2 -2
  75. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  76. package/build-module/mobile/link-picker/index.native.js +1 -1
  77. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  78. package/build-module/navigation/menu/menu-title-search.js +1 -1
  79. package/build-module/navigation/menu/menu-title-search.js.map +1 -1
  80. package/build-module/palette-edit/index.js +4 -4
  81. package/build-module/palette-edit/index.js.map +1 -1
  82. package/build-style/style-rtl.css +358 -5
  83. package/build-style/style.css +358 -5
  84. package/build-types/box-control/input-control.d.ts.map +1 -1
  85. package/build-types/box-control/utils.d.ts +7 -7
  86. package/build-types/calendar/date-calendar/index.d.ts +11 -0
  87. package/build-types/calendar/date-calendar/index.d.ts.map +1 -0
  88. package/build-types/calendar/date-range-calendar/index.d.ts +14 -0
  89. package/build-types/calendar/date-range-calendar/index.d.ts.map +1 -0
  90. package/build-types/calendar/index.d.ts +4 -0
  91. package/build-types/calendar/index.d.ts.map +1 -0
  92. package/build-types/calendar/stories/date-calendar.story.d.ts +16 -0
  93. package/build-types/calendar/stories/date-calendar.story.d.ts.map +1 -0
  94. package/build-types/calendar/stories/date-range-calendar.story.d.ts +16 -0
  95. package/build-types/calendar/stories/date-range-calendar.story.d.ts.map +1 -0
  96. package/build-types/calendar/test/__utils__/index.d.ts +10 -0
  97. package/build-types/calendar/test/__utils__/index.d.ts.map +1 -0
  98. package/build-types/calendar/test/date-calendar.d.ts +2 -0
  99. package/build-types/calendar/test/date-calendar.d.ts.map +1 -0
  100. package/build-types/calendar/test/date-range-calendar.d.ts +2 -0
  101. package/build-types/calendar/test/date-range-calendar.d.ts.map +1 -0
  102. package/build-types/calendar/types.d.ts +317 -0
  103. package/build-types/calendar/types.d.ts.map +1 -0
  104. package/build-types/calendar/utils/constants.d.ts +52 -0
  105. package/build-types/calendar/utils/constants.d.ts.map +1 -0
  106. package/build-types/calendar/utils/day-cell.d.ts +21 -0
  107. package/build-types/calendar/utils/day-cell.d.ts.map +1 -0
  108. package/build-types/calendar/utils/misc.d.ts +2 -0
  109. package/build-types/calendar/utils/misc.d.ts.map +1 -0
  110. package/build-types/calendar/utils/use-controlled-value.d.ts +27 -0
  111. package/build-types/calendar/utils/use-controlled-value.d.ts.map +1 -0
  112. package/build-types/calendar/utils/use-localization-props.d.ts +64 -0
  113. package/build-types/calendar/utils/use-localization-props.d.ts.map +1 -0
  114. package/build-types/custom-gradient-picker/constants.d.ts +6 -3
  115. package/build-types/custom-gradient-picker/constants.d.ts.map +1 -1
  116. package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
  117. package/build-types/dimension-control/sizes.d.ts +15 -3
  118. package/build-types/dimension-control/sizes.d.ts.map +1 -1
  119. package/build-types/font-size-picker/constants.d.ts +2 -2
  120. package/build-types/font-size-picker/constants.d.ts.map +1 -1
  121. package/build-types/form-token-field/index.d.ts.map +1 -1
  122. package/build-types/index.d.ts +1 -0
  123. package/build-types/index.d.ts.map +1 -1
  124. package/build-types/popover/overlay-middlewares.d.ts +6 -1
  125. package/build-types/popover/overlay-middlewares.d.ts.map +1 -1
  126. package/package.json +21 -20
  127. package/src/box-control/input-control.tsx +14 -5
  128. package/src/calendar/date-calendar/README.md +250 -0
  129. package/src/calendar/date-calendar/index.tsx +55 -0
  130. package/src/calendar/date-range-calendar/README.md +287 -0
  131. package/src/calendar/date-range-calendar/index.tsx +203 -0
  132. package/src/calendar/index.tsx +3 -0
  133. package/src/calendar/stories/date-calendar.story.tsx +221 -0
  134. package/src/calendar/stories/date-range-calendar.story.tsx +230 -0
  135. package/src/calendar/style.scss +431 -0
  136. package/src/calendar/test/__utils__/index.ts +56 -0
  137. package/src/calendar/test/date-calendar.tsx +975 -0
  138. package/src/calendar/test/date-range-calendar.tsx +1701 -0
  139. package/src/calendar/types.ts +342 -0
  140. package/src/calendar/utils/constants.ts +62 -0
  141. package/src/calendar/utils/day-cell.tsx +133 -0
  142. package/src/calendar/utils/misc.ts +3 -0
  143. package/src/calendar/utils/use-controlled-value.ts +61 -0
  144. package/src/calendar/utils/use-localization-props.ts +169 -0
  145. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +1 -1
  146. package/src/custom-select-control-v2/custom-select.tsx +6 -3
  147. package/src/date-time/date/index.tsx +1 -1
  148. package/src/form-token-field/index.tsx +12 -1
  149. package/src/form-token-field/token.tsx +1 -1
  150. package/src/index.ts +1 -0
  151. package/src/mobile/bottom-sheet/cell.native.js +2 -2
  152. package/src/mobile/link-picker/index.native.js +1 -1
  153. package/src/navigation/menu/menu-title-search.tsx +1 -1
  154. package/src/palette-edit/index.tsx +4 -4
  155. package/src/select-control/style.scss +0 -6
  156. package/src/style.scss +1 -0
  157. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,51 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { DayPicker } from 'react-day-picker';
5
+ import { enUS } from 'react-day-picker/locale';
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { COMMON_PROPS } from '../utils/constants';
10
+ import { clampNumberOfMonths } from '../utils/misc';
11
+ import { useControlledValue } from '../utils/use-controlled-value';
12
+ import { useLocalizationProps } from '../utils/use-localization-props';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ /**
15
+ * `DateCalendar` is a React component that provides a customizable calendar
16
+ * interface for **single date** selection.
17
+ *
18
+ * The component is built with accessibility in mind and follows ARIA best
19
+ * practices for calendar widgets. It provides keyboard navigation, screen reader
20
+ * support, and customizable labels for internationalization.
21
+ */
22
+ export const DateCalendar = ({
23
+ defaultSelected,
24
+ selected: selectedProp,
25
+ onSelect,
26
+ numberOfMonths = 1,
27
+ locale = enUS,
28
+ timeZone,
29
+ ...props
30
+ }) => {
31
+ const localizationProps = useLocalizationProps({
32
+ locale,
33
+ timeZone,
34
+ mode: 'single'
35
+ });
36
+ const [selected, setSelected] = useControlledValue({
37
+ defaultValue: defaultSelected,
38
+ value: selectedProp,
39
+ onChange: onSelect
40
+ });
41
+ return /*#__PURE__*/_jsx(DayPicker, {
42
+ ...COMMON_PROPS,
43
+ ...localizationProps,
44
+ ...props,
45
+ mode: "single",
46
+ numberOfMonths: clampNumberOfMonths(numberOfMonths),
47
+ selected: selected,
48
+ onSelect: setSelected
49
+ });
50
+ };
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DayPicker","enUS","COMMON_PROPS","clampNumberOfMonths","useControlledValue","useLocalizationProps","jsx","_jsx","DateCalendar","defaultSelected","selected","selectedProp","onSelect","numberOfMonths","locale","timeZone","props","localizationProps","mode","setSelected","defaultValue","value","onChange"],"sources":["@wordpress/components/src/calendar/date-calendar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { DayPicker } from 'react-day-picker';\nimport { enUS } from 'react-day-picker/locale';\n/**\n * Internal dependencies\n */\nimport { COMMON_PROPS } from '../utils/constants';\nimport { clampNumberOfMonths } from '../utils/misc';\nimport { useControlledValue } from '../utils/use-controlled-value';\nimport { useLocalizationProps } from '../utils/use-localization-props';\nimport type { DateCalendarProps } from '../types';\n\n/**\n * `DateCalendar` is a React component that provides a customizable calendar\n * interface for **single date** selection.\n *\n * The component is built with accessibility in mind and follows ARIA best\n * practices for calendar widgets. It provides keyboard navigation, screen reader\n * support, and customizable labels for internationalization.\n */\nexport const DateCalendar = ( {\n\tdefaultSelected,\n\tselected: selectedProp,\n\tonSelect,\n\tnumberOfMonths = 1,\n\tlocale = enUS,\n\ttimeZone,\n\t...props\n}: DateCalendarProps ) => {\n\tconst localizationProps = useLocalizationProps( {\n\t\tlocale,\n\t\ttimeZone,\n\t\tmode: 'single',\n\t} );\n\n\tconst [ selected, setSelected ] = useControlledValue< Date | undefined >( {\n\t\tdefaultValue: defaultSelected,\n\t\tvalue: selectedProp,\n\t\tonChange: onSelect,\n\t} );\n\n\treturn (\n\t\t<DayPicker\n\t\t\t{ ...COMMON_PROPS }\n\t\t\t{ ...localizationProps }\n\t\t\t{ ...props }\n\t\t\tmode=\"single\"\n\t\t\tnumberOfMonths={ clampNumberOfMonths( numberOfMonths ) }\n\t\t\tselected={ selected }\n\t\t\tonSelect={ setSelected }\n\t\t/>\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,IAAI,QAAQ,yBAAyB;AAC9C;AACA;AACA;AACA,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,QAAQ,eAAe;AACnD,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,oBAAoB,QAAQ,iCAAiC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGA,CAAE;EAC7BC,eAAe;EACfC,QAAQ,EAAEC,YAAY;EACtBC,QAAQ;EACRC,cAAc,GAAG,CAAC;EAClBC,MAAM,GAAGb,IAAI;EACbc,QAAQ;EACR,GAAGC;AACe,CAAC,KAAM;EACzB,MAAMC,iBAAiB,GAAGZ,oBAAoB,CAAE;IAC/CS,MAAM;IACNC,QAAQ;IACRG,IAAI,EAAE;EACP,CAAE,CAAC;EAEH,MAAM,CAAER,QAAQ,EAAES,WAAW,CAAE,GAAGf,kBAAkB,CAAsB;IACzEgB,YAAY,EAAEX,eAAe;IAC7BY,KAAK,EAAEV,YAAY;IACnBW,QAAQ,EAAEV;EACX,CAAE,CAAC;EAEH,oBACCL,IAAA,CAACP,SAAS;IAAA,GACJE,YAAY;IAAA,GACZe,iBAAiB;IAAA,GACjBD,KAAK;IACVE,IAAI,EAAC,QAAQ;IACbL,cAAc,EAAGV,mBAAmB,CAAEU,cAAe,CAAG;IACxDH,QAAQ,EAAGA,QAAU;IACrBE,QAAQ,EAAGO;EAAa,CACxB,CAAC;AAEJ,CAAC","ignoreList":[]}
@@ -0,0 +1,157 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { differenceInCalendarDays } from 'date-fns';
5
+ import { DayPicker, rangeContainsModifiers } from 'react-day-picker';
6
+ import { enUS } from 'react-day-picker/locale';
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { useMemo, useState } from '@wordpress/element';
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { COMMON_PROPS, MODIFIER_CLASSNAMES } from '../utils/constants';
15
+ import { clampNumberOfMonths } from '../utils/misc';
16
+ import { useControlledValue } from '../utils/use-controlled-value';
17
+ import { useLocalizationProps } from '../utils/use-localization-props';
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ export function usePreviewRange({
20
+ selected,
21
+ hoveredDate,
22
+ excludeDisabled,
23
+ min,
24
+ max,
25
+ disabled
26
+ }) {
27
+ return useMemo(() => {
28
+ if (!hoveredDate || !selected?.from) {
29
+ return;
30
+ }
31
+ let previewHighlight;
32
+ let potentialNewRange;
33
+
34
+ // Hovering on a date before the start of the selected range
35
+ if (hoveredDate < selected.from) {
36
+ var _selected$to;
37
+ previewHighlight = {
38
+ from: hoveredDate,
39
+ to: selected.from
40
+ };
41
+ potentialNewRange = {
42
+ from: hoveredDate,
43
+ to: (_selected$to = selected.to) !== null && _selected$to !== void 0 ? _selected$to : selected.from
44
+ };
45
+ } else if (selected.to && hoveredDate > selected.from && hoveredDate < selected.to) {
46
+ // Hovering on a date between the start and end of the selected range
47
+ previewHighlight = {
48
+ from: selected.from,
49
+ to: hoveredDate
50
+ };
51
+ potentialNewRange = {
52
+ from: selected.from,
53
+ to: hoveredDate
54
+ };
55
+ } else if (hoveredDate > selected.from) {
56
+ var _selected$to2;
57
+ // Hovering on a date after the end of the selected range (either
58
+ // because it's greater than selected.to, or because it's not defined)
59
+ previewHighlight = {
60
+ from: (_selected$to2 = selected.to) !== null && _selected$to2 !== void 0 ? _selected$to2 : selected.from,
61
+ to: hoveredDate
62
+ };
63
+ potentialNewRange = {
64
+ from: selected.from,
65
+ to: hoveredDate
66
+ };
67
+ }
68
+ if (min !== undefined && min > 0 && potentialNewRange && differenceInCalendarDays(potentialNewRange.to, potentialNewRange.from) < min) {
69
+ previewHighlight = {
70
+ from: hoveredDate,
71
+ to: hoveredDate
72
+ };
73
+ }
74
+ if (max !== undefined && max > 0 && potentialNewRange && differenceInCalendarDays(potentialNewRange.to, potentialNewRange.from) > max) {
75
+ previewHighlight = {
76
+ from: hoveredDate,
77
+ to: hoveredDate
78
+ };
79
+ }
80
+ if (excludeDisabled && disabled && potentialNewRange && rangeContainsModifiers(potentialNewRange, disabled)) {
81
+ previewHighlight = {
82
+ from: hoveredDate,
83
+ to: hoveredDate
84
+ };
85
+ }
86
+ return previewHighlight;
87
+ }, [selected, hoveredDate, excludeDisabled, min, max, disabled]);
88
+ }
89
+
90
+ /**
91
+ * `DateRangeCalendar` is a React component that provides a customizable calendar
92
+ * interface for **date range** selection.
93
+ *
94
+ * The component is built with accessibility in mind and follows ARIA best
95
+ * practices for calendar widgets. It provides keyboard navigation, screen reader
96
+ * support, and customizable labels for internationalization.
97
+ */
98
+ export const DateRangeCalendar = ({
99
+ defaultSelected,
100
+ selected: selectedProp,
101
+ onSelect,
102
+ numberOfMonths = 1,
103
+ excludeDisabled,
104
+ min,
105
+ max,
106
+ disabled,
107
+ locale = enUS,
108
+ timeZone,
109
+ ...props
110
+ }) => {
111
+ const localizationProps = useLocalizationProps({
112
+ locale,
113
+ timeZone,
114
+ mode: 'range'
115
+ });
116
+ const [selected, setSelected] = useControlledValue({
117
+ defaultValue: defaultSelected,
118
+ value: selectedProp,
119
+ onChange: onSelect
120
+ });
121
+ const [hoveredDate, setHoveredDate] = useState(undefined);
122
+
123
+ // Compute the preview range for hover effect
124
+ const previewRange = usePreviewRange({
125
+ selected,
126
+ hoveredDate,
127
+ excludeDisabled,
128
+ min,
129
+ max,
130
+ disabled
131
+ });
132
+ const modifiers = useMemo(() => {
133
+ return {
134
+ preview: previewRange,
135
+ preview_start: previewRange?.from,
136
+ preview_end: previewRange?.to
137
+ };
138
+ }, [previewRange]);
139
+ return /*#__PURE__*/_jsx(DayPicker, {
140
+ ...COMMON_PROPS,
141
+ ...localizationProps,
142
+ ...props,
143
+ mode: "range",
144
+ numberOfMonths: clampNumberOfMonths(numberOfMonths),
145
+ disabled: disabled,
146
+ excludeDisabled: excludeDisabled,
147
+ min: min,
148
+ max: max,
149
+ selected: selected,
150
+ onSelect: setSelected,
151
+ onDayMouseEnter: date => setHoveredDate(date),
152
+ onDayMouseLeave: () => setHoveredDate(undefined),
153
+ modifiers: modifiers,
154
+ modifiersClassNames: MODIFIER_CLASSNAMES
155
+ });
156
+ };
157
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["differenceInCalendarDays","DayPicker","rangeContainsModifiers","enUS","useMemo","useState","COMMON_PROPS","MODIFIER_CLASSNAMES","clampNumberOfMonths","useControlledValue","useLocalizationProps","jsx","_jsx","usePreviewRange","selected","hoveredDate","excludeDisabled","min","max","disabled","from","previewHighlight","potentialNewRange","_selected$to","to","_selected$to2","undefined","DateRangeCalendar","defaultSelected","selectedProp","onSelect","numberOfMonths","locale","timeZone","props","localizationProps","mode","setSelected","defaultValue","value","onChange","setHoveredDate","previewRange","modifiers","preview","preview_start","preview_end","onDayMouseEnter","date","onDayMouseLeave","modifiersClassNames"],"sources":["@wordpress/components/src/calendar/date-range-calendar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { differenceInCalendarDays } from 'date-fns';\nimport { DayPicker, rangeContainsModifiers } from 'react-day-picker';\nimport { enUS } from 'react-day-picker/locale';\n/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport { COMMON_PROPS, MODIFIER_CLASSNAMES } from '../utils/constants';\nimport { clampNumberOfMonths } from '../utils/misc';\nimport { useControlledValue } from '../utils/use-controlled-value';\nimport { useLocalizationProps } from '../utils/use-localization-props';\nimport type { DateRangeCalendarProps, DateRange } from '../types';\n\nexport function usePreviewRange( {\n\tselected,\n\thoveredDate,\n\texcludeDisabled,\n\tmin,\n\tmax,\n\tdisabled,\n}: Pick<\n\tDateRangeCalendarProps,\n\t'selected' | 'excludeDisabled' | 'min' | 'max' | 'disabled'\n> & {\n\thoveredDate: Date | undefined;\n} ) {\n\treturn useMemo( () => {\n\t\tif ( ! hoveredDate || ! selected?.from ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet previewHighlight: DateRange | undefined;\n\t\tlet potentialNewRange: { from: Date; to: Date } | undefined;\n\n\t\t// Hovering on a date before the start of the selected range\n\t\tif ( hoveredDate < selected.from ) {\n\t\t\tpreviewHighlight = {\n\t\t\t\tfrom: hoveredDate,\n\t\t\t\tto: selected.from,\n\t\t\t};\n\n\t\t\tpotentialNewRange = {\n\t\t\t\tfrom: hoveredDate,\n\t\t\t\tto: selected.to ?? selected.from,\n\t\t\t};\n\t\t} else if (\n\t\t\tselected.to &&\n\t\t\thoveredDate > selected.from &&\n\t\t\thoveredDate < selected.to\n\t\t) {\n\t\t\t// Hovering on a date between the start and end of the selected range\n\t\t\tpreviewHighlight = {\n\t\t\t\tfrom: selected.from,\n\t\t\t\tto: hoveredDate,\n\t\t\t};\n\n\t\t\tpotentialNewRange = {\n\t\t\t\tfrom: selected.from,\n\t\t\t\tto: hoveredDate,\n\t\t\t};\n\t\t} else if ( hoveredDate > selected.from ) {\n\t\t\t// Hovering on a date after the end of the selected range (either\n\t\t\t// because it's greater than selected.to, or because it's not defined)\n\t\t\tpreviewHighlight = {\n\t\t\t\tfrom: selected.to ?? selected.from,\n\t\t\t\tto: hoveredDate,\n\t\t\t};\n\n\t\t\tpotentialNewRange = {\n\t\t\t\tfrom: selected.from,\n\t\t\t\tto: hoveredDate,\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tmin !== undefined &&\n\t\t\tmin > 0 &&\n\t\t\tpotentialNewRange &&\n\t\t\tdifferenceInCalendarDays(\n\t\t\t\tpotentialNewRange.to,\n\t\t\t\tpotentialNewRange.from\n\t\t\t) < min\n\t\t) {\n\t\t\tpreviewHighlight = {\n\t\t\t\tfrom: hoveredDate,\n\t\t\t\tto: hoveredDate,\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tmax !== undefined &&\n\t\t\tmax > 0 &&\n\t\t\tpotentialNewRange &&\n\t\t\tdifferenceInCalendarDays(\n\t\t\t\tpotentialNewRange.to,\n\t\t\t\tpotentialNewRange.from\n\t\t\t) > max\n\t\t) {\n\t\t\tpreviewHighlight = {\n\t\t\t\tfrom: hoveredDate,\n\t\t\t\tto: hoveredDate,\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\texcludeDisabled &&\n\t\t\tdisabled &&\n\t\t\tpotentialNewRange &&\n\t\t\trangeContainsModifiers( potentialNewRange, disabled )\n\t\t) {\n\t\t\tpreviewHighlight = {\n\t\t\t\tfrom: hoveredDate,\n\t\t\t\tto: hoveredDate,\n\t\t\t};\n\t\t}\n\n\t\treturn previewHighlight;\n\t}, [ selected, hoveredDate, excludeDisabled, min, max, disabled ] );\n}\n\n/**\n * `DateRangeCalendar` is a React component that provides a customizable calendar\n * interface for **date range** selection.\n *\n * The component is built with accessibility in mind and follows ARIA best\n * practices for calendar widgets. It provides keyboard navigation, screen reader\n * support, and customizable labels for internationalization.\n */\nexport const DateRangeCalendar = ( {\n\tdefaultSelected,\n\tselected: selectedProp,\n\tonSelect,\n\tnumberOfMonths = 1,\n\texcludeDisabled,\n\tmin,\n\tmax,\n\tdisabled,\n\tlocale = enUS,\n\ttimeZone,\n\t...props\n}: DateRangeCalendarProps ) => {\n\tconst localizationProps = useLocalizationProps( {\n\t\tlocale,\n\t\ttimeZone,\n\t\tmode: 'range',\n\t} );\n\n\tconst [ selected, setSelected ] = useControlledValue<\n\t\tDateRange | undefined\n\t>( {\n\t\tdefaultValue: defaultSelected,\n\t\tvalue: selectedProp,\n\t\tonChange: onSelect,\n\t} );\n\n\tconst [ hoveredDate, setHoveredDate ] = useState< Date | undefined >(\n\t\tundefined\n\t);\n\n\t// Compute the preview range for hover effect\n\tconst previewRange = usePreviewRange( {\n\t\tselected,\n\t\thoveredDate,\n\t\texcludeDisabled,\n\t\tmin,\n\t\tmax,\n\t\tdisabled,\n\t} );\n\n\tconst modifiers = useMemo( () => {\n\t\treturn {\n\t\t\tpreview: previewRange,\n\t\t\tpreview_start: previewRange?.from,\n\t\t\tpreview_end: previewRange?.to,\n\t\t};\n\t}, [ previewRange ] );\n\n\treturn (\n\t\t<DayPicker\n\t\t\t{ ...COMMON_PROPS }\n\t\t\t{ ...localizationProps }\n\t\t\t{ ...props }\n\t\t\tmode=\"range\"\n\t\t\tnumberOfMonths={ clampNumberOfMonths( numberOfMonths ) }\n\t\t\tdisabled={ disabled }\n\t\t\texcludeDisabled={ excludeDisabled }\n\t\t\tmin={ min }\n\t\t\tmax={ max }\n\t\t\tselected={ selected }\n\t\t\tonSelect={ setSelected }\n\t\t\tonDayMouseEnter={ ( date ) => setHoveredDate( date ) }\n\t\t\tonDayMouseLeave={ () => setHoveredDate( undefined ) }\n\t\t\tmodifiers={ modifiers }\n\t\t\tmodifiersClassNames={ MODIFIER_CLASSNAMES }\n\t\t/>\n\t);\n};\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export { TZDate } from 'react-day-picker';
2
+ export { DateCalendar } from './date-calendar';
3
+ export { DateRangeCalendar } from './date-range-calendar';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TZDate","DateCalendar","DateRangeCalendar"],"sources":["@wordpress/components/src/calendar/index.tsx"],"sourcesContent":["export { TZDate } from 'react-day-picker';\nexport { DateCalendar } from './date-calendar';\nexport { DateRangeCalendar } from './date-range-calendar';\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,kBAAkB;AACzC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,iBAAiB,QAAQ,uBAAuB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/calendar/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { Locale } from 'date-fns';\nimport type * as React from 'react';\n\n/**\n * Represents the modifiers that match a specific day in the calendar.\n * @example\n * const modifiers: Modifiers = {\n * today: false, // the day is not today\n * selected: true, // the day is selected\n * disabled: false, // the day is not disabled\n * outside: false, // the day is not outside the month\n * focused: false, // the day is not focused\n *\n * weekend: false // custom modifier example for matching a weekend\n * booked: true // custom modifier example for matching a booked day\n * available: false // custom modifier example for matching an available day\n * };\n */\nexport type Modifiers = Record< string, boolean >;\n\n/**\n * A value or a function that matches a specific day.\n * @example\n * // will always match the day\n * const booleanMatcher: Matcher = true;\n *\n * // will match the today's date\n * const dateMatcher: Matcher = new Date();\n *\n * // will match the days in the array\n * const arrayMatcher: Matcher = [\n * new Date(2019, 1, 2),\n * new Date(2019, 1, 4)\n * ];\n *\n * // will match days after the 2nd of February 2019\n * const afterMatcher: DateAfter = { after: new Date(2019, 1, 2) };\n *\n * // will match days before the 2nd of February 2019 }\n * const beforeMatcher: DateBefore = { before: new Date(2019, 1, 2) };\n *\n * // will match Sundays\n * const dayOfWeekMatcher: DayOfWeek = {\n * dayOfWeek: 0\n * };\n *\n * // will match the included days, except the two dates\n * const intervalMatcher: DateInterval = {\n * after: new Date(2019, 1, 2),\n * before: new Date(2019, 1, 5)\n * };\n *\n * // will match the included days, including the two dates\n * const rangeMatcher: DateRange = {\n * from: new Date(2019, 1, 2),\n * to: new Date(2019, 1, 5)\n * };\n *\n * // will match when the function return true\n * const functionMatcher: Matcher = (day: Date) => {\n * return day.getMonth() === 2; // match when month is March\n * };\n */\ntype Matcher =\n\t| boolean\n\t| ( ( date: Date ) => boolean )\n\t| Date\n\t| Date[]\n\t| DateRange\n\t| DateBefore\n\t| DateAfter\n\t| DateInterval\n\t| DayOfWeek;\n/**\n * Match a day falling after the specified date, with the date not included.\n * @example\n * // Match days after the 2nd of February 2019\n * const matcher: DateAfter = { after: new Date(2019, 1, 2) };\n */\ntype DateAfter = {\n\tafter: Date;\n};\n/**\n * Match a day falling before the specified date, with the date not included.\n * @example\n * // Match days before the 2nd of February 2019\n * const matcher: DateBefore = { before: new Date(2019, 1, 2) };\n */\ntype DateBefore = {\n\tbefore: Date;\n};\n/**\n * An interval of dates. Differently from `DateRange`, the range ends here\n * are not included.\n * @example\n * // Match the days between the 2nd and the 5th of February 2019\n * const matcher: DateInterval = {\n * after: new Date(2019, 1, 2),\n * before: new Date(2019, 1, 5)\n * };\n */\ntype DateInterval = {\n\tbefore: Date;\n\tafter: Date;\n};\n/**\n * A range of dates. The range can be open. Differently from\n * `DateInterval`, the range ends here are included.\n * @example\n * // Match the days between the 2nd and the 5th of February 2019\n * const matcher: DateRange = {\n * from: new Date(2019, 1, 2),\n * to: new Date(2019, 1, 5)\n * };\n */\nexport type DateRange = {\n\tfrom: Date | undefined;\n\tto?: Date | undefined;\n};\n/**\n * Match dates being one of the specified days of the week (`0-6`, where `0` is\n * Sunday).\n * @example\n * // Match Sundays\n * const matcher: DayOfWeek = { dayOfWeek: 0 };\n * // Match weekends\n * const matcher: DayOfWeek = { dayOfWeek: [0, 6] };\n */\ntype DayOfWeek = {\n\tdayOfWeek: number | number[];\n};\n\n/**\n * Shared handler type for `onSelect` callback when a selection mode is set.\n * @example\n * const handleSelect: OnSelectHandler<Date> = (\n * selected,\n * triggerDate,\n * modifiers,\n * e\n * ) => {\n * console.log( \"Selected:\", selected );\n * console.log( \"Triggered by:\", triggerDate );\n * };\n * @template T - The type of the selected item.\n * @callback OnSelectHandler\n * @param {T} selected - The selected item after the event.\n * @param {Date} triggerDate - The date when the event was triggered. This is\n * typically the day clicked or interacted with.\n * @param {Modifiers} modifiers - The modifiers associated with the event.\n * @param {React.MouseEvent | React.KeyboardEvent} e - The event object.\n */\ntype OnSelectHandler< T > = (\n\tselected: T,\n\ttriggerDate: Date,\n\tmodifiers: Modifiers,\n\te: React.MouseEvent | React.KeyboardEvent\n) => void;\n\nexport interface BaseProps\n\textends Omit<\n\t\tReact.HTMLAttributes< HTMLDivElement >,\n\t\t'onSelect' | 'defaultValue'\n\t> {\n\t/**\n\t * Whether the selection is required.\n\t * When `true`, there always needs to be a date selected.\n\t * @default false\n\t */\n\trequired?: boolean;\n\n\t/**\n\t * The initial month to show in the calendar view (uncontrolled).\n\t * @default The current month\n\t */\n\tdefaultMonth?: Date;\n\t/**\n\t * The month displayed in the calendar view (controlled). Use together with\n\t * `onMonthChange` to change the month programmatically.\n\t */\n\tmonth?: Date;\n\t/**\n\t * The number of months displayed at once.\n\t * @default 1\n\t */\n\tnumberOfMonths?: number;\n\t/**\n\t * The earliest month to start the month navigation.\n\t */\n\tstartMonth?: Date;\n\t/**\n\t * The latest month to end the month navigation.\n\t */\n\tendMonth?: Date;\n\t/**\n\t * Focus the first selected day (if set) or today's date (if not disabled).\n\t *\n\t * Use this prop when you need to focus the calendar after a user action\n\t * (e.g. opening the dialog with the calendar).\n\t */\n\tautoFocus?: boolean;\n\t/**\n\t * Specify which days are disabled. Using `true` will disable all dates.\n\t */\n\tdisabled?: Matcher | Matcher[] | undefined;\n\t/**\n\t * Disable the navigation buttons.\n\t */\n\tdisableNavigation?: boolean;\n\t/**\n\t * Use custom labels, useful for translating the component.\n\t *\n\t * For a correct localized experience, consumers should make sure the locale\n\t * used for the translated labels and `locale` prop are consistent.\n\t */\n\tlabels?: {\n\t\t/**\n\t\t * The label for the navigation toolbar.\n\t\t * @default \"\"\n\t\t */\n\t\tlabelNav?: () => string;\n\t\t/**\n\t\t * The label for the month grid.\n\t\t * @default \"LLLL y\" (e.g. \"November 2022\")\n\t\t */\n\t\tlabelGrid?: ( date: Date ) => string;\n\t\t/**\n\t\t * The label for the gridcell, when the calendar is not interactive.\n\t\t * @default The formatted date.\n\t\t */\n\t\tlabelGridcell?: ( date: Date, modifiers?: Modifiers ) => string;\n\t\t/**\n\t\t * The label for the \"next month\" button.\n\t\t * @default \"Go to the Next Month\"\n\t\t */\n\t\tlabelNext?: ( month: Date | undefined ) => string;\n\t\t/**\n\t\t * The label for the \"previous month\" button.\n\t\t * @default \"Go to the Previous Month\"\n\t\t */\n\t\tlabelPrevious?: ( month: Date | undefined ) => string;\n\t\t/**\n\t\t * The label for the day button.\n\t\t * @default The formatted date.\n\t\t */\n\t\tlabelDayButton?: ( date: Date, modifiers?: Modifiers ) => string;\n\t\t/**\n\t\t * The label for the weekday.\n\t\t * @default ( date: Date ) => \"Monday\" | \"Tuesday\" | \"Wednesday\" | \"Thursday\" | \"Friday\" | \"Saturday\" | \"Sunday\"\n\t\t */\n\t\tlabelWeekday?: ( date: Date ) => string;\n\t};\n\n\t/**\n\t * The locale object used to localize dates. Pass a locale from\n\t * `@date-fns/locale` to localize the calendar.\n\t *\n\t * For a correct localized experience, consumers should make sure the locale\n\t * used for the translated labels and `locale` prop are consistent.\n\t * @see https://github.com/date-fns/date-fns/tree/main/src/locale for a list of the supported locales\n\t * @default The `enUS` locale from `@date-fns/locale`\n\t */\n\tlocale?: Locale;\n\t/**\n\t * The index of the first day of the week (0 - Sunday). Overrides the locale's\n\t * one.\n\t * @default Based on the `locale` prop\n\t */\n\tweekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;\n\t/**\n\t * Event fired when the user navigates between months.\n\t */\n\tonMonthChange?: ( month: Date ) => void;\n\t/**\n\t * The time zone (IANA or UTC offset) to use in the calendar.\n\t *\n\t * See\n\t * [Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)\n\t * for the possible values.\n\t *\n\t * When working with time zones, use the `TZDate` object exported by this\n\t * package instead of the native `Date` object.\n\t * @example\n\t * import { DateCalendar, TZDate } from \"@automattic/components\";\n\t *\n\t * export function WithTimeZone() {\n\t * const timeZone = \"America/New_York\";\n\t * const [ selected, setSelected ] = useState< Date | undefined >(\n\t * new TZDate( 2024, 12, 10, timeZone ) // Use `TZDate` instead of `Date`\n\t * );\n\t * return (\n\t * <DateCalendar\n\t * timeZone={ timeZone }\n\t * selected={ selected }\n\t * onSelect={ setSelected }\n\t * />\n\t * );\n\t * }\n\t */\n\ttimeZone?: string;\n\t/**\n\t * The role attribute to add to the container element.\n\t * @default 'application'\n\t */\n\trole?: 'application' | 'dialog' | undefined;\n}\n\ninterface SingleProps {\n\t/** The selected date. */\n\tselected?: Date | undefined | null;\n\t/** Event handler when a day is selected. */\n\tonSelect?: OnSelectHandler< Date | undefined >;\n\t/** The default selected date (for uncontrolled usage). */\n\tdefaultSelected?: Date;\n}\n\ninterface RangeProps {\n\t/**\n\t * When `true`, the range will reset when including a disabled day.\n\t */\n\texcludeDisabled?: boolean;\n\t/**\n\t * The minimum number of nights to include in the range.\n\t */\n\tmin?: number;\n\t/**\n\t * The maximum number of nights to include in the range.\n\t */\n\tmax?: number;\n\t/** The selected range. */\n\tselected?: DateRange | undefined | null;\n\t/** Event handler when the selection changes. */\n\tonSelect?: OnSelectHandler< DateRange | undefined >;\n\t/** The default selected range (for uncontrolled usage). */\n\tdefaultSelected?: DateRange;\n}\n\nexport type DateCalendarProps = BaseProps & SingleProps;\nexport type DateRangeCalendarProps = BaseProps & RangeProps;\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { Day } from './day-cell';
5
+ const CLASSNAMES = {
6
+ root: 'components-calendar',
7
+ day: 'components-calendar__day',
8
+ day_button: 'components-calendar__day-button',
9
+ caption_label: 'components-calendar__caption-label',
10
+ button_next: 'components-calendar__button-next',
11
+ button_previous: 'components-calendar__button-previous',
12
+ chevron: 'components-calendar__chevron',
13
+ nav: 'components-calendar__nav',
14
+ month_caption: 'components-calendar__month-caption',
15
+ months: 'components-calendar__months',
16
+ month_grid: 'components-calendar__month-grid',
17
+ weekday: 'components-calendar__weekday',
18
+ today: 'components-calendar__day--today',
19
+ selected: 'components-calendar__day--selected',
20
+ disabled: 'components-calendar__day--disabled',
21
+ hidden: 'components-calendar__day--hidden',
22
+ range_start: 'components-calendar__range-start',
23
+ range_end: 'components-calendar__range-end',
24
+ range_middle: 'components-calendar__range-middle',
25
+ weeks_before_enter: 'components-calendar__weeks-before-enter',
26
+ weeks_before_exit: 'components-calendar__weeks-before-exit',
27
+ weeks_after_enter: 'components-calendar__weeks-after-enter',
28
+ weeks_after_exit: 'components-calendar__weeks-after-exit',
29
+ caption_after_enter: 'components-calendar__caption-after-enter',
30
+ caption_after_exit: 'components-calendar__caption-after-exit',
31
+ caption_before_enter: 'components-calendar__caption-before-enter',
32
+ caption_before_exit: 'components-calendar__caption-before-exit'
33
+ };
34
+ export const MODIFIER_CLASSNAMES = {
35
+ preview: 'components-calendar__day--preview',
36
+ preview_start: 'components-calendar__day--preview-start',
37
+ preview_end: 'components-calendar__day--preview-end'
38
+ };
39
+ export const COMMON_PROPS = {
40
+ animate: true,
41
+ // Only show days in the current month
42
+ showOutsideDays: false,
43
+ // Hide week number column
44
+ showWeekNumber: false,
45
+ // Show weekdays row
46
+ hideWeekdays: false,
47
+ // Month and year caption are not interactive
48
+ captionLayout: 'label',
49
+ // Show a variable number of weeks depending on the month
50
+ fixedWeeks: false,
51
+ // Show navigation buttons
52
+ hideNavigation: false,
53
+ // Class names
54
+ classNames: CLASSNAMES,
55
+ // Default role
56
+ role: 'application',
57
+ components: {
58
+ Day
59
+ }
60
+ };
61
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Day","CLASSNAMES","root","day","day_button","caption_label","button_next","button_previous","chevron","nav","month_caption","months","month_grid","weekday","today","selected","disabled","hidden","range_start","range_end","range_middle","weeks_before_enter","weeks_before_exit","weeks_after_enter","weeks_after_exit","caption_after_enter","caption_after_exit","caption_before_enter","caption_before_exit","MODIFIER_CLASSNAMES","preview","preview_start","preview_end","COMMON_PROPS","animate","showOutsideDays","showWeekNumber","hideWeekdays","captionLayout","fixedWeeks","hideNavigation","classNames","role","components"],"sources":["@wordpress/components/src/calendar/utils/constants.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { Day } from './day-cell';\n\nconst CLASSNAMES = {\n\troot: 'components-calendar',\n\tday: 'components-calendar__day',\n\tday_button: 'components-calendar__day-button',\n\tcaption_label: 'components-calendar__caption-label',\n\tbutton_next: 'components-calendar__button-next',\n\tbutton_previous: 'components-calendar__button-previous',\n\tchevron: 'components-calendar__chevron',\n\tnav: 'components-calendar__nav',\n\tmonth_caption: 'components-calendar__month-caption',\n\tmonths: 'components-calendar__months',\n\tmonth_grid: 'components-calendar__month-grid',\n\tweekday: 'components-calendar__weekday',\n\ttoday: 'components-calendar__day--today',\n\tselected: 'components-calendar__day--selected',\n\tdisabled: 'components-calendar__day--disabled',\n\thidden: 'components-calendar__day--hidden',\n\trange_start: 'components-calendar__range-start',\n\trange_end: 'components-calendar__range-end',\n\trange_middle: 'components-calendar__range-middle',\n\tweeks_before_enter: 'components-calendar__weeks-before-enter',\n\tweeks_before_exit: 'components-calendar__weeks-before-exit',\n\tweeks_after_enter: 'components-calendar__weeks-after-enter',\n\tweeks_after_exit: 'components-calendar__weeks-after-exit',\n\tcaption_after_enter: 'components-calendar__caption-after-enter',\n\tcaption_after_exit: 'components-calendar__caption-after-exit',\n\tcaption_before_enter: 'components-calendar__caption-before-enter',\n\tcaption_before_exit: 'components-calendar__caption-before-exit',\n};\nexport const MODIFIER_CLASSNAMES = {\n\tpreview: 'components-calendar__day--preview',\n\tpreview_start: 'components-calendar__day--preview-start',\n\tpreview_end: 'components-calendar__day--preview-end',\n};\n\nexport const COMMON_PROPS = {\n\tanimate: true,\n\t// Only show days in the current month\n\tshowOutsideDays: false,\n\t// Hide week number column\n\tshowWeekNumber: false,\n\t// Show weekdays row\n\thideWeekdays: false,\n\t// Month and year caption are not interactive\n\tcaptionLayout: 'label',\n\t// Show a variable number of weeks depending on the month\n\tfixedWeeks: false,\n\t// Show navigation buttons\n\thideNavigation: false,\n\t// Class names\n\tclassNames: CLASSNAMES,\n\t// Default role\n\trole: 'application',\n\tcomponents: {\n\t\tDay,\n\t},\n} as const;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAG,QAAQ,YAAY;AAEhC,MAAMC,UAAU,GAAG;EAClBC,IAAI,EAAE,qBAAqB;EAC3BC,GAAG,EAAE,0BAA0B;EAC/BC,UAAU,EAAE,iCAAiC;EAC7CC,aAAa,EAAE,oCAAoC;EACnDC,WAAW,EAAE,kCAAkC;EAC/CC,eAAe,EAAE,sCAAsC;EACvDC,OAAO,EAAE,8BAA8B;EACvCC,GAAG,EAAE,0BAA0B;EAC/BC,aAAa,EAAE,oCAAoC;EACnDC,MAAM,EAAE,6BAA6B;EACrCC,UAAU,EAAE,iCAAiC;EAC7CC,OAAO,EAAE,8BAA8B;EACvCC,KAAK,EAAE,iCAAiC;EACxCC,QAAQ,EAAE,oCAAoC;EAC9CC,QAAQ,EAAE,oCAAoC;EAC9CC,MAAM,EAAE,kCAAkC;EAC1CC,WAAW,EAAE,kCAAkC;EAC/CC,SAAS,EAAE,gCAAgC;EAC3CC,YAAY,EAAE,mCAAmC;EACjDC,kBAAkB,EAAE,yCAAyC;EAC7DC,iBAAiB,EAAE,wCAAwC;EAC3DC,iBAAiB,EAAE,wCAAwC;EAC3DC,gBAAgB,EAAE,uCAAuC;EACzDC,mBAAmB,EAAE,0CAA0C;EAC/DC,kBAAkB,EAAE,yCAAyC;EAC7DC,oBAAoB,EAAE,2CAA2C;EACjEC,mBAAmB,EAAE;AACtB,CAAC;AACD,OAAO,MAAMC,mBAAmB,GAAG;EAClCC,OAAO,EAAE,mCAAmC;EAC5CC,aAAa,EAAE,yCAAyC;EACxDC,WAAW,EAAE;AACd,CAAC;AAED,OAAO,MAAMC,YAAY,GAAG;EAC3BC,OAAO,EAAE,IAAI;EACb;EACAC,eAAe,EAAE,KAAK;EACtB;EACAC,cAAc,EAAE,KAAK;EACrB;EACAC,YAAY,EAAE,KAAK;EACnB;EACAC,aAAa,EAAE,OAAO;EACtB;EACAC,UAAU,EAAE,KAAK;EACjB;EACAC,cAAc,EAAE,KAAK;EACrB;EACAC,UAAU,EAAExC,UAAU;EACtB;EACAyC,IAAI,EAAE,aAAa;EACnBC,UAAU,EAAE;IACX3C;EACD;AACD,CAAU","ignoreList":[]}
@@ -0,0 +1,131 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * External dependencies
4
+ */
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+
10
+ /**
11
+ * The dash array and offset are calculated by:
12
+ * - measuring the path length (eg 92,28384)
13
+ * - establishing how many segments should the path be split into (eg. 24)
14
+ * - dividing the path length by the number of segments (eg. 92,28384 / 24 = 3,84516)
15
+ * - playing with the dash offset to make sure the dashes look good on rounded corners
16
+ */
17
+
18
+ /**
19
+ * Dashed rectangle. The dash array and offset are chosen to make sure dashes
20
+ * look good on rounded corners and have similar metrics to the other dash
21
+ * preview shapes.
22
+ */
23
+ const PreviewDashStartAndEnd = () => {
24
+ return /*#__PURE__*/_jsx("svg", {
25
+ viewBox: "0 0 32 32",
26
+ xmlns: "http://www.w3.org/2000/svg",
27
+ fill: "none",
28
+ stroke: "currentColor",
29
+ strokeDasharray: "3.7677",
30
+ strokeDashoffset: "3.2",
31
+ strokeWidth: "1",
32
+ children: /*#__PURE__*/_jsx("path", {
33
+ d: "M29.5,0.5 h-27 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h27 a2,2 0 0 0 2,-2 v-27 a2,2 0 0 0 -2,-2"
34
+ })
35
+ });
36
+ };
37
+
38
+ /**
39
+ * Dashed top, left, and bottom sides, with rounded corners. The dash array and
40
+ * offset are chosen to make sure that multiple days in a row show a seamless
41
+ * dashed border, and the dashes look good on rounded corners.
42
+ */
43
+ const PreviewDashStart = () => {
44
+ return /*#__PURE__*/_jsx("svg", {
45
+ viewBox: "0 0 32 32",
46
+ xmlns: "http://www.w3.org/2000/svg",
47
+ fill: "none",
48
+ stroke: "currentColor",
49
+ strokeDasharray: "3.84516",
50
+ strokeDashoffset: "1.9226",
51
+ strokeWidth: "1",
52
+ children: /*#__PURE__*/_jsx("path", {
53
+ d: "M32,0.5 h-29.5 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h30"
54
+ })
55
+ });
56
+ };
57
+ /**
58
+ * Dashed top and bottom sides. The dash array and offset are chosen
59
+ * to make sure that multiple days in a row show a seamless dashed border.
60
+ */
61
+ const PreviewDashMiddle = () => {
62
+ return /*#__PURE__*/_jsxs("svg", {
63
+ viewBox: "0 0 32 32",
64
+ xmlns: "http://www.w3.org/2000/svg",
65
+ fill: "none",
66
+ stroke: "currentColor",
67
+ strokeDasharray: "3.9 4",
68
+ strokeDashoffset: "2",
69
+ strokeWidth: "1",
70
+ children: [/*#__PURE__*/_jsx("line", {
71
+ x1: "0",
72
+ y1: "0.5",
73
+ x2: "100",
74
+ y2: "0.5"
75
+ }), /*#__PURE__*/_jsx("line", {
76
+ x1: "0",
77
+ y1: "31.5",
78
+ x2: "100",
79
+ y2: "31.5"
80
+ })]
81
+ });
82
+ };
83
+ /**
84
+ * Dashed top, right, and bottom sides, with rounded corners. The dash array and
85
+ * offset are chosen to make sure that multiple days in a row show a seamless
86
+ * dashed border, and the dashes look good on rounded corners.
87
+ */
88
+ const PreviewDashEnd = () => {
89
+ return /*#__PURE__*/_jsx("svg", {
90
+ viewBox: "0 0 32 32",
91
+ xmlns: "http://www.w3.org/2000/svg",
92
+ fill: "none",
93
+ stroke: "currentColor",
94
+ strokeDasharray: "3.84516",
95
+ strokeDashoffset: "1.9226",
96
+ strokeWidth: "1",
97
+ children: /*#__PURE__*/_jsx("path", {
98
+ d: "M0,0.5 h29.5 a2,2 0 0 1 2,2 v27 a2,2 0 0 1 -2,2 h-29.5"
99
+ })
100
+ });
101
+ };
102
+
103
+ /**
104
+ * Render a grid cell for a specific day in the calendar.
105
+ *
106
+ * Handles interaction and focus for the day.
107
+ * @see https://daypicker.dev/guides/custom-components
108
+ */
109
+ export function Day(props) {
110
+ const {
111
+ day,
112
+ modifiers,
113
+ children,
114
+ ...tdProps
115
+ } = props;
116
+ let PreviewDash;
117
+ if (modifiers.preview_start && modifiers.preview_end) {
118
+ PreviewDash = PreviewDashStartAndEnd;
119
+ } else if (modifiers.preview_start) {
120
+ PreviewDash = PreviewDashStart;
121
+ } else if (modifiers.preview_end) {
122
+ PreviewDash = PreviewDashEnd;
123
+ } else if (modifiers.preview) {
124
+ PreviewDash = PreviewDashMiddle;
125
+ }
126
+ return /*#__PURE__*/_jsxs("td", {
127
+ ...tdProps,
128
+ children: [PreviewDash && /*#__PURE__*/_jsx(PreviewDash, {}), children]
129
+ });
130
+ }
131
+ //# sourceMappingURL=day-cell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PreviewDashStartAndEnd","_jsx","viewBox","xmlns","fill","stroke","strokeDasharray","strokeDashoffset","strokeWidth","children","d","PreviewDashStart","PreviewDashMiddle","_jsxs","x1","y1","x2","y2","PreviewDashEnd","Day","props","day","modifiers","tdProps","PreviewDash","preview_start","preview_end","preview"],"sources":["@wordpress/components/src/calendar/utils/day-cell.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CalendarDay } from 'react-day-picker';\n/**\n * Internal dependencies\n */\nimport type { Modifiers } from '../types';\n\n/**\n * The dash array and offset are calculated by:\n * - measuring the path length (eg 92,28384)\n * - establishing how many segments should the path be split into (eg. 24)\n * - dividing the path length by the number of segments (eg. 92,28384 / 24 = 3,84516)\n * - playing with the dash offset to make sure the dashes look good on rounded corners\n */\n\n/**\n * Dashed rectangle. The dash array and offset are chosen to make sure dashes\n * look good on rounded corners and have similar metrics to the other dash\n * preview shapes.\n */\nconst PreviewDashStartAndEnd = () => {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 32 32\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeDasharray=\"3.7677\"\n\t\t\tstrokeDashoffset=\"3.2\"\n\t\t\tstrokeWidth=\"1\"\n\t\t>\n\t\t\t<path d=\"M29.5,0.5 h-27 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h27 a2,2 0 0 0 2,-2 v-27 a2,2 0 0 0 -2,-2\" />\n\t\t</svg>\n\t);\n};\n\n/**\n * Dashed top, left, and bottom sides, with rounded corners. The dash array and\n * offset are chosen to make sure that multiple days in a row show a seamless\n * dashed border, and the dashes look good on rounded corners.\n */\nconst PreviewDashStart = () => {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 32 32\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeDasharray=\"3.84516\"\n\t\t\tstrokeDashoffset=\"1.9226\"\n\t\t\tstrokeWidth=\"1\"\n\t\t>\n\t\t\t<path d=\"M32,0.5 h-29.5 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h30\" />\n\t\t</svg>\n\t);\n};\n/**\n * Dashed top and bottom sides. The dash array and offset are chosen\n * to make sure that multiple days in a row show a seamless dashed border.\n */\nconst PreviewDashMiddle = () => {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 32 32\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeDasharray=\"3.9 4\"\n\t\t\tstrokeDashoffset=\"2\"\n\t\t\tstrokeWidth=\"1\"\n\t\t>\n\t\t\t<line x1=\"0\" y1=\"0.5\" x2=\"100\" y2=\"0.5\" />\n\t\t\t<line x1=\"0\" y1=\"31.5\" x2=\"100\" y2=\"31.5\" />\n\t\t</svg>\n\t);\n};\n/**\n * Dashed top, right, and bottom sides, with rounded corners. The dash array and\n * offset are chosen to make sure that multiple days in a row show a seamless\n * dashed border, and the dashes look good on rounded corners.\n */\nconst PreviewDashEnd = () => {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 32 32\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeDasharray=\"3.84516\"\n\t\t\tstrokeDashoffset=\"1.9226\"\n\t\t\tstrokeWidth=\"1\"\n\t\t>\n\t\t\t<path d=\"M0,0.5 h29.5 a2,2 0 0 1 2,2 v27 a2,2 0 0 1 -2,2 h-29.5\" />\n\t\t</svg>\n\t);\n};\n\n/**\n * Render a grid cell for a specific day in the calendar.\n *\n * Handles interaction and focus for the day.\n * @see https://daypicker.dev/guides/custom-components\n */\nexport function Day(\n\tprops: {\n\t\t/** The day to render. */\n\t\tday: CalendarDay;\n\t\t/** The modifiers to apply to the day. */\n\t\tmodifiers: Modifiers;\n\t} & React.HTMLAttributes< HTMLDivElement >\n) {\n\tconst { day, modifiers, children, ...tdProps } = props;\n\n\tlet PreviewDash;\n\tif ( modifiers.preview_start && modifiers.preview_end ) {\n\t\tPreviewDash = PreviewDashStartAndEnd;\n\t} else if ( modifiers.preview_start ) {\n\t\tPreviewDash = PreviewDashStart;\n\t} else if ( modifiers.preview_end ) {\n\t\tPreviewDash = PreviewDashEnd;\n\t} else if ( modifiers.preview ) {\n\t\tPreviewDash = PreviewDashMiddle;\n\t}\n\n\treturn (\n\t\t<td { ...tdProps }>\n\t\t\t{ PreviewDash && <PreviewDash /> }\n\t\t\t{ children }\n\t\t</td>\n\t);\n}\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export function clampNumberOfMonths(numberOfMonths) {
2
+ return Math.min(3, Math.max(1, numberOfMonths));
3
+ }
4
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["clampNumberOfMonths","numberOfMonths","Math","min","max"],"sources":["@wordpress/components/src/calendar/utils/misc.ts"],"sourcesContent":["export function clampNumberOfMonths( numberOfMonths: number ) {\n\treturn Math.min( 3, Math.max( 1, numberOfMonths ) );\n}\n"],"mappings":"AAAA,OAAO,SAASA,mBAAmBA,CAAEC,cAAsB,EAAG;EAC7D,OAAOC,IAAI,CAACC,GAAG,CAAE,CAAC,EAAED,IAAI,CAACE,GAAG,CAAE,CAAC,EAAEH,cAAe,CAAE,CAAC;AACpD","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useState, useCallback } from '@wordpress/element';
5
+ /**
6
+ * Handles controlled and uncontrolled state for the selected calendar value.
7
+ * It is assumed that the `value` prop is controlled when it's not undefined:
8
+ * - initial date selected, uncontrolled: use a non-undefined`defaultValue`
9
+ * - initial date selected, controlled: use a non-undefined `value`
10
+ * - no date selected, controlled: set `value` to `null`
11
+ *
12
+ * The `onChange` prop will return `undefined` when no date is selected,
13
+ * regardless of controlled / uncontrolled. It is expected that the consumer
14
+ * of the component will handle setting the value to `null` to indicate no date
15
+ * selected in controlled mode.
16
+ *
17
+ * @param props - The props object.
18
+ * @param props.defaultValue - The default value.
19
+ * @param props.onChange - The onChange callback.
20
+ * @param props.value - The value.
21
+ *
22
+ * @return The value and the setValue function.
23
+ */
24
+ export function useControlledValue({
25
+ defaultValue,
26
+ onChange,
27
+ value: valueProp
28
+ }) {
29
+ var _ref;
30
+ const hasValue = typeof valueProp !== 'undefined';
31
+ const initialValue = hasValue ? valueProp : defaultValue;
32
+ const [state, setState] = useState(initialValue);
33
+ const value = (_ref = hasValue ? valueProp : state) !== null && _ref !== void 0 ? _ref : undefined;
34
+ let setValue;
35
+ const uncontrolledSetValue = useCallback((nextValue, ...args) => {
36
+ setState(nextValue);
37
+ onChange?.(nextValue, ...args);
38
+ }, [setState, onChange]);
39
+ if (hasValue && typeof onChange === 'function') {
40
+ // Controlled mode.
41
+ setValue = onChange;
42
+ } else if (!hasValue && typeof onChange === 'function') {
43
+ // Uncontrolled mode, plus forwarding to the onChange prop.
44
+ setValue = uncontrolledSetValue;
45
+ } else {
46
+ // Uncontrolled mode, only update internal state.
47
+ setValue = setState;
48
+ }
49
+ return [value, setValue];
50
+ }
51
+ //# sourceMappingURL=use-controlled-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useState","useCallback","useControlledValue","defaultValue","onChange","value","valueProp","_ref","hasValue","initialValue","state","setState","undefined","setValue","uncontrolledSetValue","nextValue","args"],"sources":["@wordpress/components/src/calendar/utils/use-controlled-value.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useCallback } from '@wordpress/element';\n\ntype Props< T > = {\n\tdefaultValue?: T;\n\tvalue?: T | null | undefined;\n\tonChange?: ( newValue: T, ...args: any[] ) => void;\n};\n\n/**\n * Handles controlled and uncontrolled state for the selected calendar value.\n * It is assumed that the `value` prop is controlled when it's not undefined:\n * - initial date selected, uncontrolled: use a non-undefined`defaultValue`\n * - initial date selected, controlled: use a non-undefined `value`\n * - no date selected, controlled: set `value` to `null`\n *\n * The `onChange` prop will return `undefined` when no date is selected,\n * regardless of controlled / uncontrolled. It is expected that the consumer\n * of the component will handle setting the value to `null` to indicate no date\n * selected in controlled mode.\n *\n * @param props - The props object.\n * @param props.defaultValue - The default value.\n * @param props.onChange - The onChange callback.\n * @param props.value - The value.\n *\n * @return The value and the setValue function.\n */\nexport function useControlledValue< T >( {\n\tdefaultValue,\n\tonChange,\n\tvalue: valueProp,\n}: Props< T > ) {\n\tconst hasValue = typeof valueProp !== 'undefined';\n\tconst initialValue = hasValue ? valueProp : defaultValue;\n\tconst [ state, setState ] = useState( initialValue );\n\tconst value = ( hasValue ? valueProp : state ) ?? undefined;\n\n\tlet setValue: typeof onChange;\n\tconst uncontrolledSetValue: NonNullable< typeof onChange > = useCallback(\n\t\t( nextValue, ...args ) => {\n\t\t\tsetState( nextValue );\n\t\t\tonChange?.( nextValue, ...args );\n\t\t},\n\t\t[ setState, onChange ]\n\t);\n\tif ( hasValue && typeof onChange === 'function' ) {\n\t\t// Controlled mode.\n\t\tsetValue = onChange;\n\t} else if ( ! hasValue && typeof onChange === 'function' ) {\n\t\t// Uncontrolled mode, plus forwarding to the onChange prop.\n\t\tsetValue = uncontrolledSetValue;\n\t} else {\n\t\t// Uncontrolled mode, only update internal state.\n\t\tsetValue = setState;\n\t}\n\n\treturn [ value, setValue ] as const;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;AAQ1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAO;EACxCC,YAAY;EACZC,QAAQ;EACRC,KAAK,EAAEC;AACI,CAAC,EAAG;EAAA,IAAAC,IAAA;EACf,MAAMC,QAAQ,GAAG,OAAOF,SAAS,KAAK,WAAW;EACjD,MAAMG,YAAY,GAAGD,QAAQ,GAAGF,SAAS,GAAGH,YAAY;EACxD,MAAM,CAAEO,KAAK,EAAEC,QAAQ,CAAE,GAAGX,QAAQ,CAAES,YAAa,CAAC;EACpD,MAAMJ,KAAK,IAAAE,IAAA,GAAKC,QAAQ,GAAGF,SAAS,GAAGI,KAAK,cAAAH,IAAA,cAAAA,IAAA,GAAMK,SAAS;EAE3D,IAAIC,QAAyB;EAC7B,MAAMC,oBAAoD,GAAGb,WAAW,CACvE,CAAEc,SAAS,EAAE,GAAGC,IAAI,KAAM;IACzBL,QAAQ,CAAEI,SAAU,CAAC;IACrBX,QAAQ,GAAIW,SAAS,EAAE,GAAGC,IAAK,CAAC;EACjC,CAAC,EACD,CAAEL,QAAQ,EAAEP,QAAQ,CACrB,CAAC;EACD,IAAKI,QAAQ,IAAI,OAAOJ,QAAQ,KAAK,UAAU,EAAG;IACjD;IACAS,QAAQ,GAAGT,QAAQ;EACpB,CAAC,MAAM,IAAK,CAAEI,QAAQ,IAAI,OAAOJ,QAAQ,KAAK,UAAU,EAAG;IAC1D;IACAS,QAAQ,GAAGC,oBAAoB;EAChC,CAAC,MAAM;IACN;IACAD,QAAQ,GAAGF,QAAQ;EACpB;EAEA,OAAO,CAAEN,KAAK,EAAEQ,QAAQ,CAAE;AAC3B","ignoreList":[]}