@astryxdesign/core 0.4.5-canary.ee6d68d → 0.4.5-canary.fba7b40
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/Blockquote/Blockquote.d.ts +4 -3
- package/dist/Blockquote/Blockquote.d.ts.map +1 -1
- package/dist/Blockquote/Blockquote.js +9 -10
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +12 -3
- package/dist/DateInput/DateInput.d.ts +31 -2
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +75 -10
- package/dist/DateInput/MonthScroller.d.ts +35 -0
- package/dist/DateInput/MonthScroller.d.ts.map +1 -0
- package/dist/DateInput/MonthScroller.js +573 -0
- package/dist/DateInput/MonthYearWheels.d.ts +24 -0
- package/dist/DateInput/MonthYearWheels.d.ts.map +1 -0
- package/dist/DateInput/MonthYearWheels.js +114 -0
- package/dist/DateInput/TouchDateField.d.ts +10 -0
- package/dist/DateInput/TouchDateField.d.ts.map +1 -0
- package/dist/DateInput/TouchDateField.js +810 -0
- package/dist/DateInput/Wheel.d.ts +41 -0
- package/dist/DateInput/Wheel.d.ts.map +1 -0
- package/dist/DateInput/Wheel.js +315 -0
- package/dist/DateInput/monthGeometry.d.ts +65 -0
- package/dist/DateInput/monthGeometry.d.ts.map +1 -0
- package/dist/DateInput/monthGeometry.js +98 -0
- package/dist/DateInput/tokens.stylex.d.ts +63 -0
- package/dist/DateInput/tokens.stylex.d.ts.map +1 -0
- package/dist/DateInput/tokens.stylex.js +74 -0
- package/dist/DateInput/useOwnScrollGesture.d.ts +41 -0
- package/dist/DateInput/useOwnScrollGesture.d.ts.map +1 -0
- package/dist/DateInput/useOwnScrollGesture.js +202 -0
- package/dist/DateInput/usePointerDragScroll.d.ts +15 -0
- package/dist/DateInput/usePointerDragScroll.d.ts.map +1 -0
- package/dist/DateInput/usePointerDragScroll.js +216 -0
- package/dist/DateInput/useScrollSettle.d.ts +26 -0
- package/dist/DateInput/useScrollSettle.d.ts.map +1 -0
- package/dist/DateInput/useScrollSettle.js +149 -0
- package/dist/Toast/Toast.d.ts +4 -3
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +10 -7
- package/dist/astryx.css +38 -0
- package/dist/hooks/useAutoMediaMode.d.ts +31 -0
- package/dist/hooks/useAutoMediaMode.d.ts.map +1 -0
- package/dist/hooks/useAutoMediaMode.js +201 -0
- package/dist/theme/MediaTheme.d.ts +25 -5
- package/dist/theme/MediaTheme.d.ts.map +1 -1
- package/dist/theme/MediaTheme.js +31 -6
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/syntax/index.d.ts +6 -0
- package/dist/theme/syntax/index.d.ts.map +1 -1
- package/dist/theme/syntax/index.js +7 -2
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/plainDate.d.ts +2 -0
- package/dist/utils/plainDate.d.ts.map +1 -1
- package/dist/utils/plainDate.js +16 -0
- package/locales/en.json +24 -0
- package/locales/pseudo.json +18 -0
- package/package.json +2 -2
- package/src/Banner/Banner.doc.mjs +2 -0
- package/src/Blockquote/Blockquote.doc.mjs +30 -7
- package/src/Blockquote/Blockquote.test.tsx +34 -3
- package/src/Blockquote/Blockquote.tsx +11 -9
- package/src/BottomSheet/BottomSheet.doc.mjs +3 -3
- package/src/BottomSheet/BottomSheetPanel.test.tsx +50 -0
- package/src/BottomSheet/BottomSheetPanel.tsx +26 -0
- package/src/ComplexSelector/ComplexSelector.doc.mjs +10 -0
- package/src/DateInput/DateInput.tsx +77 -10
- package/src/DateInput/DateInputTouch.test.tsx +2393 -0
- package/src/DateInput/MonthScroller.tsx +784 -0
- package/src/DateInput/MonthYearWheels.tsx +147 -0
- package/src/DateInput/TouchDateField.tsx +1214 -0
- package/src/DateInput/Wheel.tsx +470 -0
- package/src/DateInput/monthGeometry.ts +118 -0
- package/src/DateInput/tokens.stylex.ts +99 -0
- package/src/DateInput/useOwnScrollGesture.ts +227 -0
- package/src/DateInput/usePointerDragScroll.ts +220 -0
- package/src/DateInput/useScrollSettle.ts +164 -0
- package/src/DateRangeInput/DateRangeInput.doc.mjs +1 -1
- package/src/FormLayout/FormLayout.doc.mjs +1 -1
- package/src/TextArea/TextArea.doc.mjs +1 -1
- package/src/Toast/Toast.tsx +9 -7
- package/src/Tooltip/Tooltip.doc.mjs +1 -1
- package/src/hooks/useAutoMediaMode.test.ts +109 -0
- package/src/hooks/useAutoMediaMode.ts +233 -0
- package/src/hooks/useScrollLock.doc.mjs +3 -3
- package/src/theme/MediaTheme.doc.mjs +23 -4
- package/src/theme/MediaTheme.dom.test.tsx +97 -0
- package/src/theme/MediaTheme.tsx +42 -7
- package/src/theme/index.ts +1 -1
- package/src/theme/syntax/index.ts +6 -2
- package/src/theme/syntax/serverSafeSyntax.test.ts +68 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/plainDate.ts +16 -0
|
@@ -18,15 +18,16 @@ export interface BlockquoteProps extends BaseProps<HTMLQuoteElement> {
|
|
|
18
18
|
/** Content of the blockquote */
|
|
19
19
|
children: ReactNode;
|
|
20
20
|
/**
|
|
21
|
-
* Optional attribution for the quote. Rendered in a
|
|
21
|
+
* Optional attribution for the quote. Rendered in a `<cite>` element after
|
|
22
|
+
* the quoted content.
|
|
22
23
|
*/
|
|
23
24
|
cite?: ReactNode;
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Blockquote component for displaying quoted content.
|
|
27
28
|
*
|
|
28
|
-
* Renders a semantic `<blockquote>` with an
|
|
29
|
-
*
|
|
29
|
+
* Renders a semantic `<blockquote>` with an inline-start rule and secondary
|
|
30
|
+
* text color, matching the Astryx visual language.
|
|
30
31
|
*
|
|
31
32
|
* @example
|
|
32
33
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockquote.d.ts","sourceRoot":"","sources":["../../src/Blockquote/Blockquote.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAM5C,MAAM,WAAW,eAAgB,SAAQ,SAAS,CAAC,gBAAgB,CAAC;IAClE,qDAAqD;IACrD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC,gCAAgC;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"Blockquote.d.ts","sourceRoot":"","sources":["../../src/Blockquote/Blockquote.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAM5C,MAAM,WAAW,eAAgB,SAAQ,SAAS,CAAC,gBAAgB,CAAC;IAClE,qDAAqD;IACrD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC,gCAAgC;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAwBD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,eAAe,+BAmBjB;yBA3Be,UAAU"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import * as stylex from '@stylexjs/stylex';
|
|
17
17
|
import "../theme/tokens.stylex.js";
|
|
18
18
|
import { colorVars, spacingVars, typeScaleVars } from "../theme/tokens.stylex.js";
|
|
19
|
-
import { mergeProps } from "../utils/index.js";
|
|
19
|
+
import { isRenderable, mergeProps } from "../utils/index.js";
|
|
20
20
|
import { themeProps } from "../utils/themeProps.js";
|
|
21
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
22
|
const styles = {
|
|
@@ -26,6 +26,7 @@ const styles = {
|
|
|
26
26
|
kGJrpR: "x14ydlgx",
|
|
27
27
|
kZCmMZ: "x1rey3nv",
|
|
28
28
|
kMwMTN: "xv1l7n4",
|
|
29
|
+
kHjlTd: "x1mzt3pk",
|
|
29
30
|
keTefX: "x1lziwak",
|
|
30
31
|
k71WvV: "x14z9mp",
|
|
31
32
|
keoZOQ: "xdj266r",
|
|
@@ -37,8 +38,8 @@ const styles = {
|
|
|
37
38
|
/**
|
|
38
39
|
* Blockquote component for displaying quoted content.
|
|
39
40
|
*
|
|
40
|
-
* Renders a semantic `<blockquote>` with an
|
|
41
|
-
*
|
|
41
|
+
* Renders a semantic `<blockquote>` with an inline-start rule and secondary
|
|
42
|
+
* text color, matching the Astryx visual language.
|
|
42
43
|
*
|
|
43
44
|
* @example
|
|
44
45
|
* ```
|
|
@@ -58,13 +59,11 @@ export function Blockquote({
|
|
|
58
59
|
ref: ref,
|
|
59
60
|
...mergeProps(themeProps('blockquote'), stylex.props(styles.root, xstyle), className, style),
|
|
60
61
|
...props,
|
|
61
|
-
children: [children, cite
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
children: cite
|
|
67
|
-
})
|
|
62
|
+
children: [children, isRenderable(cite) && /*#__PURE__*/_jsx("cite", {
|
|
63
|
+
...{
|
|
64
|
+
className: "x1lliihq xtbrsbv x141an7d x1ltkj2j x1j61x8r"
|
|
65
|
+
},
|
|
66
|
+
children: cite
|
|
68
67
|
})]
|
|
69
68
|
});
|
|
70
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetPanel.d.ts","sourceRoot":"","sources":["../../src/BottomSheet/BottomSheetPanel.tsx"],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AQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IACjD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACzD,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,CAAC;CAC7D;AA+GD,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,EAC/B,GAAG,EACH,KAAK,EACL,MAAM,EACN,QAAQ,EACR,UAAU,EACV,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,EACN,qBAA4B,EAC5B,kBAA0B,EAC1B,SAAS,EACT,cAAc,EACd,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,qBAAqB,+BAyQvB;yBA3Re,gBAAgB"}
|
|
@@ -24,7 +24,7 @@ import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo,
|
|
|
24
24
|
import * as stylex from '@stylexjs/stylex';
|
|
25
25
|
import { useDevWarning } from "../hooks/index.js";
|
|
26
26
|
import "../theme/tokens.stylex.js";
|
|
27
|
-
import { colorVars, durationVars, easeVars, radiusVars, shadowVars, sizeVars, spacingVars } from "../theme/tokens.stylex.js";
|
|
27
|
+
import { borderVars, colorVars, durationVars, easeVars, radiusVars, shadowVars, sizeVars, spacingVars } from "../theme/tokens.stylex.js";
|
|
28
28
|
import { mergeProps, themeProps } from "../utils/index.js";
|
|
29
29
|
import { overlayPaddingReset } from "../Layout/padding.stylex.js";
|
|
30
30
|
import { isValidSnapPoint, resolveSnapPoints } from "./snapOffsets.js";
|
|
@@ -82,6 +82,15 @@ const styles = {
|
|
|
82
82
|
kzqmXN: "xh8yej3",
|
|
83
83
|
ks0D6T: "x11gisft",
|
|
84
84
|
kWkggS: "x10xzikg",
|
|
85
|
+
kEafiO: "x11xkdxz",
|
|
86
|
+
kPef9Z: "x13fuv20",
|
|
87
|
+
kLZC3w: "x1pc3f07",
|
|
88
|
+
k2ei4v: "xgbv0en",
|
|
89
|
+
kVhnKS: "x1t7ytsu",
|
|
90
|
+
kGJrpR: "x1j92z86",
|
|
91
|
+
ke9TFa: "xw8tdv1",
|
|
92
|
+
k8ry5P: "x18b5jzi",
|
|
93
|
+
kBCPoo: "x1gejf6u",
|
|
85
94
|
krdFHd: "x81l70g",
|
|
86
95
|
kfmiAY: "x7hs6f1",
|
|
87
96
|
kGVxlE: "x1kcpxr7",
|
|
@@ -430,10 +439,10 @@ export function BottomSheetPanel({
|
|
|
430
439
|
}), /*#__PURE__*/_jsx("div", {
|
|
431
440
|
...mergeProps({
|
|
432
441
|
0: {
|
|
433
|
-
className: "x1iyjqo2 x2lwn1j x9f619 x1odjw0f x8du1vd xx69xxh x18d9i69"
|
|
442
|
+
className: "x1iyjqo2 x2lwn1j x9f619 x1odjw0f x8du1vd xx69xxh x10xzikg x18d9i69"
|
|
434
443
|
},
|
|
435
444
|
1: {
|
|
436
|
-
className: "x1iyjqo2 x2lwn1j x9f619 x1odjw0f x8du1vd xx69xxh x18d9i69 xrw9175 x1s928wv xhkezso xu6fald x2q1x1w"
|
|
445
|
+
className: "x1iyjqo2 x2lwn1j x9f619 x1odjw0f x8du1vd xx69xxh x10xzikg x18d9i69 xrw9175 x1s928wv xhkezso xu6fald x2q1x1w"
|
|
437
446
|
}
|
|
438
447
|
}[!!(height === 'tall') << 0], scrollPreservationInset > 0 ? {
|
|
439
448
|
style: {
|
|
@@ -204,7 +204,36 @@ export interface DateInputProps extends Omit<BaseProps, 'onChange' | 'defaultVal
|
|
|
204
204
|
format?: DateInputFormat | ((value: ISODateString) => string);
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
207
|
-
* A date picker
|
|
207
|
+
* A date picker that fits the pointer it is being used with.
|
|
208
|
+
*
|
|
209
|
+
* With a mouse or trackpad this is a text input you can type into, with a
|
|
210
|
+
* calendar in a popover — unchanged, and still the surface every existing
|
|
211
|
+
* consumer gets. With a finger it is a picker built for one: a bottom sheet
|
|
212
|
+
* holding one month per screen, swiped sideways, with month and year wheels
|
|
213
|
+
* behind the header title for the far jumps swiping is bad at.
|
|
214
|
+
*
|
|
215
|
+
* The props are identical either way — this is one component with two
|
|
216
|
+
* surfaces, not two components — so nothing at the call site changes, and a
|
|
217
|
+
* date typed on a laptop and a date thumbed on a phone are the same value.
|
|
218
|
+
*
|
|
219
|
+
* ## Why a runtime switch and not CSS
|
|
220
|
+
*
|
|
221
|
+
* The two surfaces are structurally different — a popover anchored to a text
|
|
222
|
+
* field versus a full-width sheet holding a scroller — so "render both, hide
|
|
223
|
+
* one" would double the DOM, double the tab stops, and mount two calendars.
|
|
224
|
+
* The condition is not layout either: it is *which interaction is faster*,
|
|
225
|
+
* and that depends on the pointer, which CSS cannot hand to JS.
|
|
226
|
+
*
|
|
227
|
+
* They are two components rather than one with a branch inside because the
|
|
228
|
+
* hook lists differ; keeping them separate is what lets each own its own.
|
|
229
|
+
*
|
|
230
|
+
* ## Hydration
|
|
231
|
+
*
|
|
232
|
+
* `useMediaQuery` reports false during SSR, so server HTML is always the
|
|
233
|
+
* pointer field and the swap happens after hydration. That is deliberately
|
|
234
|
+
* unobservable: both surfaces render the SAME closed field — a bordered input
|
|
235
|
+
* with a calendar icon and the formatted date — and differ only in what
|
|
236
|
+
* opens. Nothing moves; the field just starts opening a sheet.
|
|
208
237
|
*
|
|
209
238
|
* @example
|
|
210
239
|
* ```
|
|
@@ -215,7 +244,7 @@ export interface DateInputProps extends Omit<BaseProps, 'onChange' | 'defaultVal
|
|
|
215
244
|
* />
|
|
216
245
|
* ```
|
|
217
246
|
*/
|
|
218
|
-
export declare function DateInput(
|
|
247
|
+
export declare function DateInput(props: DateInputProps): import("react").JSX.Element;
|
|
219
248
|
export declare namespace DateInput {
|
|
220
249
|
var displayName: string;
|
|
221
250
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../src/DateInput/DateInput.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAS3C,OAAO,EAGL,KAAK,WAAW,EAKhB,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AAOlB,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../src/DateInput/DateInput.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAS3C,OAAO,EAGL,KAAK,WAAW,EAKhB,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AAOlB,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAcrB,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AA8ClD,QAAA,MAAM,UAAU;;;;;;;;;;;;;EAad,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,UAAU,CAAC;AAEpD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CACnC,eAAe,EACf,MAAM,GAAG,WAAW,GAAG,cAAc,GAAG,aAAa,CACtD,CAAC;AAIF,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,eAAe,IAAI,mBAAmB,GACvC,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;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WAAW,CAAC;IACrB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IAEnC;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,CAAC,CAAC;CAC/D;AAmeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,+BAQ9C;yBARe,SAAS"}
|
|
@@ -29,8 +29,10 @@ import { Spinner } from "../Spinner/index.js";
|
|
|
29
29
|
import { Calendar } from "../Calendar/index.js";
|
|
30
30
|
import { useCalendarConstraints } from "../Calendar/hooks/index.js";
|
|
31
31
|
import { useInputStatusIcon } from "../hooks/useInputStatusIcon.js";
|
|
32
|
+
import { useMediaQuery } from "../hooks/useMediaQuery.js";
|
|
32
33
|
import { useResolvedRequired } from "../hooks/useResolvedRequired.js";
|
|
33
34
|
import { usePopover } from "../Popover/index.js";
|
|
35
|
+
import { TouchDateField } from "./TouchDateField.js";
|
|
34
36
|
import { useTooltip } from "../Tooltip/index.js";
|
|
35
37
|
import { getInputARIA, isImeKeyEvent, parseDateInput } from "../utils/index.js";
|
|
36
38
|
import { plainDateFromISO, plainDateToISO, formatSharedDate } from "../utils/plainDate.js";
|
|
@@ -95,18 +97,30 @@ import { stableClassName } from "../naming.js";
|
|
|
95
97
|
import { useTranslator, InternationalizationContext } from "../i18n/index.js";
|
|
96
98
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
97
99
|
/**
|
|
98
|
-
*
|
|
100
|
+
* The pointer that decides which surface a `DateInput` renders.
|
|
99
101
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
102
|
+
* `pointer: coarse` is the *primary* pointing device, which is what makes it
|
|
103
|
+
* the whole test. A touchscreen laptop reports `fine` (its trackpad) with
|
|
104
|
+
* `any-pointer: coarse` alongside, so it keeps the typable field — right,
|
|
105
|
+
* because its keyboard is there. A tablet reports `coarse` and gets the
|
|
106
|
+
* picker, at any width. There is deliberately no width bound: it would only
|
|
107
|
+
* re-exclude the tablets, since a narrowed desktop window is still a mouse.
|
|
108
|
+
*
|
|
109
|
+
* Deliberately NOT exported. It was, briefly, on the theory that an app might
|
|
110
|
+
* want to ask the same question and lay out to match — but nothing asked, and
|
|
111
|
+
* six other core components (CheckboxInput, ChatComposerInput, ...) just
|
|
112
|
+
* write `@media (pointer: coarse)` inline rather than sharing a constant. An
|
|
113
|
+
* export is additive later and awkward to withdraw, so it waits for a real
|
|
114
|
+
* caller.
|
|
108
115
|
*/
|
|
109
|
-
|
|
116
|
+
const TOUCH_POINTER_QUERY = '(pointer: coarse)';
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The pointer-driven field: a text input you can type into, with a calendar
|
|
120
|
+
* in a popover beside it. `DateInput` renders this whenever the primary
|
|
121
|
+
* pointer is not a finger — see {@link TOUCH_POINTER_QUERY}.
|
|
122
|
+
*/
|
|
123
|
+
function PointerDateField({
|
|
110
124
|
label,
|
|
111
125
|
isLabelHidden = false,
|
|
112
126
|
description,
|
|
@@ -500,4 +514,55 @@ export function DateInput({
|
|
|
500
514
|
children: inputWrapper
|
|
501
515
|
});
|
|
502
516
|
}
|
|
517
|
+
PointerDateField.displayName = 'PointerDateField';
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* A date picker that fits the pointer it is being used with.
|
|
521
|
+
*
|
|
522
|
+
* With a mouse or trackpad this is a text input you can type into, with a
|
|
523
|
+
* calendar in a popover — unchanged, and still the surface every existing
|
|
524
|
+
* consumer gets. With a finger it is a picker built for one: a bottom sheet
|
|
525
|
+
* holding one month per screen, swiped sideways, with month and year wheels
|
|
526
|
+
* behind the header title for the far jumps swiping is bad at.
|
|
527
|
+
*
|
|
528
|
+
* The props are identical either way — this is one component with two
|
|
529
|
+
* surfaces, not two components — so nothing at the call site changes, and a
|
|
530
|
+
* date typed on a laptop and a date thumbed on a phone are the same value.
|
|
531
|
+
*
|
|
532
|
+
* ## Why a runtime switch and not CSS
|
|
533
|
+
*
|
|
534
|
+
* The two surfaces are structurally different — a popover anchored to a text
|
|
535
|
+
* field versus a full-width sheet holding a scroller — so "render both, hide
|
|
536
|
+
* one" would double the DOM, double the tab stops, and mount two calendars.
|
|
537
|
+
* The condition is not layout either: it is *which interaction is faster*,
|
|
538
|
+
* and that depends on the pointer, which CSS cannot hand to JS.
|
|
539
|
+
*
|
|
540
|
+
* They are two components rather than one with a branch inside because the
|
|
541
|
+
* hook lists differ; keeping them separate is what lets each own its own.
|
|
542
|
+
*
|
|
543
|
+
* ## Hydration
|
|
544
|
+
*
|
|
545
|
+
* `useMediaQuery` reports false during SSR, so server HTML is always the
|
|
546
|
+
* pointer field and the swap happens after hydration. That is deliberately
|
|
547
|
+
* unobservable: both surfaces render the SAME closed field — a bordered input
|
|
548
|
+
* with a calendar icon and the formatted date — and differ only in what
|
|
549
|
+
* opens. Nothing moves; the field just starts opening a sheet.
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```
|
|
553
|
+
* <DateInput
|
|
554
|
+
* label="Event date"
|
|
555
|
+
* value={date}
|
|
556
|
+
* onChange={setDate}
|
|
557
|
+
* />
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
export function DateInput(props) {
|
|
561
|
+
const isTouch = useMediaQuery(TOUCH_POINTER_QUERY);
|
|
562
|
+
return isTouch ? /*#__PURE__*/_jsx(TouchDateField, {
|
|
563
|
+
...props
|
|
564
|
+
}) : /*#__PURE__*/_jsx(PointerDateField, {
|
|
565
|
+
...props
|
|
566
|
+
});
|
|
567
|
+
}
|
|
503
568
|
DateInput.displayName = 'DateInput';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type DayOfWeek, type ISODateString, type PlainDate } from '../utils';
|
|
2
|
+
export interface MonthScrollerHandle {
|
|
3
|
+
/** Bring a month to rest at the top of the scrollport. */
|
|
4
|
+
scrollToMonth: (monthIndex: number, behavior?: ScrollBehavior) => void;
|
|
5
|
+
}
|
|
6
|
+
export interface MonthScrollerProps {
|
|
7
|
+
/** Imperative handle for programmatic navigation (Today, the wheels). */
|
|
8
|
+
handleRef?: React.RefObject<MonthScrollerHandle | null>;
|
|
9
|
+
/** First reachable month, as a month index. */
|
|
10
|
+
minMonthIndex: number;
|
|
11
|
+
/** Last reachable month, as a month index. */
|
|
12
|
+
maxMonthIndex: number;
|
|
13
|
+
/** Month to rest on at mount. */
|
|
14
|
+
initialMonthIndex: number;
|
|
15
|
+
/** Fires as the scroller passes each month, settled or not. */
|
|
16
|
+
onVisibleMonthChange: (monthIndex: number) => void;
|
|
17
|
+
/** Currently selected date. */
|
|
18
|
+
selectedDate: PlainDate | null;
|
|
19
|
+
/** Today, for the `aria-current` marker. */
|
|
20
|
+
today: PlainDate;
|
|
21
|
+
/** Whether a date fails min/max or a custom constraint. */
|
|
22
|
+
isDateDisabled: (date: PlainDate) => boolean;
|
|
23
|
+
/** First column of the week. */
|
|
24
|
+
weekStartsOn: DayOfWeek;
|
|
25
|
+
/** Fired when a day is tapped. */
|
|
26
|
+
onSelect: (value: ISODateString) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A vertically continuous, snap-paged run of month grids.
|
|
30
|
+
*/
|
|
31
|
+
export declare function MonthScroller({ handleRef, minMonthIndex, maxMonthIndex, initialMonthIndex, onVisibleMonthChange, selectedDate, today, isDateDisabled, weekStartsOn, onSelect, }: MonthScrollerProps): import("react").JSX.Element;
|
|
32
|
+
export declare namespace MonthScroller {
|
|
33
|
+
var displayName: string;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=MonthScroller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonthScroller.d.ts","sourceRoot":"","sources":["../../src/DateInput/MonthScroller.tsx"],"names":[],"mappings":"AAmDA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,SAAS,EAQf,MAAM,UAAU,CAAC;AAyMlB,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;CACxE;AAED,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACxD,+CAA+C;IAC/C,aAAa,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,oBAAoB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,+BAA+B;IAC/B,YAAY,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,4CAA4C;IAC5C,KAAK,EAAE,SAAS,CAAC;IACjB,2DAA2D;IAC3D,cAAc,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC;IAC7C,gCAAgC;IAChC,YAAY,EAAE,SAAS,CAAC;IACxB,kCAAkC;IAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,KAAK,EACL,cAAc,EACd,YAAY,EACZ,QAAQ,GACT,EAAE,kBAAkB,+BAwUpB;yBAnVe,aAAa"}
|