@astryxdesign/core 0.7.8-canary.f10bc91 → 0.7.8-canary.f5a3152

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 (81) hide show
  1. package/dist/CheckboxList/CheckboxList.d.ts +13 -2
  2. package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
  3. package/dist/CheckboxList/CheckboxList.js +10 -4
  4. package/dist/CheckboxList/CheckboxListContext.d.ts +7 -0
  5. package/dist/CheckboxList/CheckboxListContext.d.ts.map +1 -1
  6. package/dist/CheckboxList/CheckboxListContext.js +2 -1
  7. package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
  8. package/dist/CheckboxList/CheckboxListItem.js +14 -2
  9. package/dist/CheckboxList/requiredGroup.d.ts +22 -0
  10. package/dist/CheckboxList/requiredGroup.d.ts.map +1 -0
  11. package/dist/CheckboxList/requiredGroup.js +52 -0
  12. package/dist/DateInput/PickerWheel.d.ts +1 -1
  13. package/dist/DateInput/PickerWheel.d.ts.map +1 -1
  14. package/dist/DateInput/PickerWheel.js +28 -4
  15. package/dist/DateInput/Wheel.d.ts +2 -2
  16. package/dist/DateInput/Wheel.d.ts.map +1 -1
  17. package/dist/DateInput/Wheel.js +20 -4
  18. package/dist/DateInput/datePickerTouch.d.ts +13 -0
  19. package/dist/DateInput/datePickerTouch.d.ts.map +1 -0
  20. package/dist/DateInput/datePickerTouch.js +14 -0
  21. package/dist/DateInput/wheelOptions.d.ts +22 -2
  22. package/dist/DateInput/wheelOptions.d.ts.map +1 -1
  23. package/dist/DateInput/wheelOptions.js +14 -2
  24. package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
  25. package/dist/DateTimeInput/TouchDateTimeField.js +62 -119
  26. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +4 -3
  27. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -1
  28. package/dist/PowerSearch/PowerSearchBottomSheet.js +4 -3
  29. package/dist/TimeInput/TimeWheels.d.ts +32 -0
  30. package/dist/TimeInput/TimeWheels.d.ts.map +1 -0
  31. package/dist/TimeInput/TimeWheels.js +144 -0
  32. package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
  33. package/dist/TimeInput/TouchTimeField.js +63 -118
  34. package/dist/TimeInput/timeWheelRules.d.ts +124 -0
  35. package/dist/TimeInput/timeWheelRules.d.ts.map +1 -0
  36. package/dist/TimeInput/timeWheelRules.js +277 -0
  37. package/dist/gestures/GestureHost.d.ts.map +1 -1
  38. package/dist/gestures/GestureHost.js +3 -0
  39. package/dist/i18n/generated-english/TimeInput/TimeWheels.generated.d.ts +8 -0
  40. package/dist/i18n/generated-english/TimeInput/TimeWheels.generated.d.ts.map +1 -0
  41. package/dist/i18n/generated-english/TimeInput/TimeWheels.generated.js +17 -0
  42. package/dist/utils/interactionOverlay.stylex.d.ts +3 -2
  43. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  44. package/dist/utils/interactionOverlay.stylex.js +3 -2
  45. package/dist/utils/pressFeedback.d.ts.map +1 -1
  46. package/dist/utils/pressFeedback.js +74 -9
  47. package/dist/utils/pressGesture.d.ts +4 -2
  48. package/dist/utils/pressGesture.d.ts.map +1 -1
  49. package/dist/utils/pressGesture.js +3 -1
  50. package/dist/utils/selectionLock.d.ts +10 -1
  51. package/dist/utils/selectionLock.d.ts.map +1 -1
  52. package/dist/utils/selectionLock.js +31 -5
  53. package/dist/utils/sharedMutationObserver.d.ts +2 -1
  54. package/dist/utils/sharedMutationObserver.d.ts.map +1 -1
  55. package/dist/utils/sharedMutationObserver.js +2 -1
  56. package/dist/utils/timeParser.d.ts +2 -1
  57. package/dist/utils/timeParser.d.ts.map +1 -1
  58. package/dist/utils/timeParser.js +29 -3
  59. package/package.json +4 -4
  60. package/src/CheckboxList/CheckboxList.doc.mjs +7 -0
  61. package/src/CheckboxList/CheckboxList.tsx +34 -2
  62. package/src/CheckboxList/CheckboxListContext.tsx +9 -1
  63. package/src/CheckboxList/CheckboxListItem.tsx +23 -2
  64. package/src/CheckboxList/requiredGroup.ts +77 -0
  65. package/src/DateInput/PickerWheel.tsx +37 -2
  66. package/src/DateInput/Wheel.tsx +30 -2
  67. package/src/DateInput/datePickerTouch.ts +15 -0
  68. package/src/DateInput/wheelOptions.ts +31 -2
  69. package/src/DateTimeInput/TouchDateTimeField.tsx +94 -178
  70. package/src/PowerSearch/PowerSearchBottomSheet.tsx +7 -5
  71. package/src/TimeInput/TimeWheels.tsx +218 -0
  72. package/src/TimeInput/TouchTimeField.tsx +93 -157
  73. package/src/TimeInput/timeWheelRules.ts +352 -0
  74. package/src/gestures/GestureHost.ts +5 -4
  75. package/src/i18n/generated-english/TimeInput/TimeWheels.generated.ts +18 -0
  76. package/src/utils/interactionOverlay.stylex.ts +3 -2
  77. package/src/utils/pressFeedback.ts +99 -21
  78. package/src/utils/pressGesture.ts +4 -2
  79. package/src/utils/selectionLock.ts +40 -6
  80. package/src/utils/sharedMutationObserver.ts +2 -1
  81. package/src/utils/timeParser.ts +40 -3
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file CheckboxList.tsx
3
- * @input Uses React, useId, useOptimistic, useTransition, Field, List, CheckboxListContext
3
+ * @input Uses React, useId, useOptimistic, useTransition, Field, List, CheckboxListContext, requiredGroup
4
4
  * @output Exports CheckboxList component, CheckboxListProps
5
5
  * @position Core implementation; consumed by index.ts, tested by CheckboxList.test.tsx
6
6
  *
@@ -39,6 +39,17 @@ export interface CheckboxListProps extends Omit<FieldInputBaseProps<HTMLDivEleme
39
39
  * @default false
40
40
  */
41
41
  isOptional?: boolean;
42
+ /**
43
+ * Whether the group needs at least one checked box. Shows the required
44
+ * indicator after the group label by the same rules as every input field.
45
+ * While no box is checked, the browser blocks submit and moves focus to
46
+ * the first box that is neither disabled nor read-only. A disabled or
47
+ * read-only group requires nothing. Show your own error text through
48
+ * `status`.
49
+ * Mutually exclusive with isOptional.
50
+ * @default false
51
+ */
52
+ isRequired?: boolean;
42
53
  /**
43
54
  * Status indicator for the checkbox group.
44
55
  * When set with a message, displays a colored message box below the group.
@@ -122,7 +133,7 @@ export interface CheckboxListProps extends Omit<FieldInputBaseProps<HTMLDivEleme
122
133
  * </CheckboxList>
123
134
  * ```
124
135
  */
125
- export declare function CheckboxList({ label, isLabelHidden, description, isOptional, status, value, onChange, changeAction, density, hasDividers, isDisabled, disabledMessage, isReadOnly, children, ref, width, containerXstyle, containerClassName, containerStyle, controlXstyle, controlClassName, controlStyle, 'aria-labelledby': ariaLabelledByProp, 'aria-describedby': ariaDescribedByProp, ...restProps }: CheckboxListProps): import("react").JSX.Element;
136
+ export declare function CheckboxList({ label, isLabelHidden, description, isOptional, isRequired, status, value, onChange, changeAction, density, hasDividers, isDisabled, disabledMessage, isReadOnly, children, ref, width, containerXstyle, containerClassName, containerStyle, controlXstyle, controlClassName, controlStyle, 'aria-labelledby': ariaLabelledByProp, 'aria-describedby': ariaDescribedByProp, ...restProps }: CheckboxListProps): import("react").JSX.Element;
126
137
  export declare namespace CheckboxList {
127
138
  var displayName: string;
128
139
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxList.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/CheckboxList.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAE9C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAarD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAC7C,mBAAmB,CAAC,cAAc,CAAC,EACnC,UAAU,CACX;IACC,mDAAmD;IACnD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cA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C,EAAE,WAAW,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,MAAM,EACN,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,OAAoB,EACpB,WAAmB,EACnB,UAAkB,EAClB,eAAe,EACf,UAAkB,EAClB,QAAQ,EACR,GAAG,EACH,KAAK,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EAAE,kBAAkB,EACrC,kBAAkB,EAAE,mBAAmB,EACvC,GAAG,SAAS,EACb,EAAE,iBAAiB,+BA2KnB;yBAtMe,YAAY"}
@@ -4,7 +4,7 @@
4
4
 
5
5
  /**
6
6
  * @file CheckboxList.tsx
7
- * @input Uses React, useId, useOptimistic, useTransition, Field, List, CheckboxListContext
7
+ * @input Uses React, useId, useOptimistic, useTransition, Field, List, CheckboxListContext, requiredGroup
8
8
  * @output Exports CheckboxList component, CheckboxListProps
9
9
  * @position Core implementation; consumed by index.ts, tested by CheckboxList.test.tsx
10
10
  *
@@ -26,6 +26,7 @@ import { mergeProps } from "../utils/index.js";
26
26
  import { themeProps } from "../utils/themeProps.js";
27
27
  import { joinAriaIDs } from "../utils/inputAria.js";
28
28
  import { CheckboxListContext } from "./CheckboxListContext.js";
29
+ import { createRequiredGroup } from "./requiredGroup.js";
29
30
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
30
31
  const EMPTY_ARRAY = [];
31
32
  /**
@@ -51,6 +52,7 @@ export function CheckboxList({
51
52
  isLabelHidden = false,
52
53
  description,
53
54
  isOptional = false,
55
+ isRequired = false,
54
56
  status,
55
57
  value,
56
58
  onChange,
@@ -85,6 +87,8 @@ export function CheckboxList({
85
87
  const labelID = useId();
86
88
  const descriptionID = useId();
87
89
  const statusMessageID = useId();
90
+ const requiredGroup = useMemo(() => isRequired ? createRequiredGroup() : undefined, [isRequired]);
91
+ const observeRequiredGroup = useCallback(container => container != null && requiredGroup != null ? requiredGroup.observe(container) : undefined, [requiredGroup]);
88
92
  const [, startTransition] = useTransition();
89
93
  const isCollectionMode = value !== undefined;
90
94
  const effectiveValue = value ?? EMPTY_ARRAY;
@@ -128,8 +132,9 @@ export function CheckboxList({
128
132
  disabledMessageID: showsDisabledMessage ? disabledMessageTooltip.describedBy : undefined,
129
133
  isReadOnly,
130
134
  isInvalid: status?.type === 'error',
131
- loadingValues
132
- }), [isCollectionMode, optimisticValue, handleChange, isDisabled, showsDisabledMessage, disabledMessageTooltip.describedBy, isReadOnly, status?.type, loadingValues]);
135
+ loadingValues,
136
+ requiredGroup
137
+ }), [isCollectionMode, optimisticValue, handleChange, isDisabled, showsDisabledMessage, disabledMessageTooltip.describedBy, isReadOnly, status?.type, loadingValues, requiredGroup]);
133
138
  return /*#__PURE__*/_jsxs(Field, {
134
139
  label: label,
135
140
  isLabelHidden: isLabelHidden,
@@ -138,6 +143,7 @@ export function CheckboxList({
138
143
  labelID: labelID,
139
144
  isGroupLabel: true,
140
145
  isOptional: isOptional,
146
+ isRequired: isRequired,
141
147
  descriptionID: description ? descriptionID : undefined,
142
148
  isDisabled: isDisabled,
143
149
  status: status ? {
@@ -158,7 +164,7 @@ export function CheckboxList({
158
164
  ...rest,
159
165
  // The disabled-message tooltip anchors here; its handlers are gated
160
166
  // internally by isEnabled, so attaching unconditionally is safe.
161
- ref: useMergedRefs(ref, disabledMessageTooltip.ref),
167
+ ref: useMergedRefs(ref, disabledMessageTooltip.ref, observeRequiredGroup),
162
168
  ...mergeProps(stylex.props(controlXstyle), controlClassName, controlStyle),
163
169
  role: "group"
164
170
  // Screen readers announce the whole group as unavailable. Its dimmed
@@ -1,3 +1,4 @@
1
+ import type { RequiredGroup } from './requiredGroup.js';
1
2
  export interface CheckboxListContextValue {
2
3
  value?: string[];
3
4
  /**
@@ -36,6 +37,12 @@ export interface CheckboxListContextValue {
36
37
  * when idle.
37
38
  */
38
39
  loadingValues?: ReadonlyArray<string>;
40
+ /**
41
+ * Present when the list is `isRequired`. Each item registers its checkbox,
42
+ * so that while no box is checked the first enabled box carries native
43
+ * `required`.
44
+ */
45
+ requiredGroup?: RequiredGroup;
39
46
  }
40
47
  export declare const CheckboxListContext: import("react").Context<CheckboxListContextValue | null>;
41
48
  //# sourceMappingURL=CheckboxListContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxListContext.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/CheckboxListContext.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7D,UAAU,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,mBAAmB,0DACiC,CAAC"}
1
+ {"version":3,"file":"CheckboxListContext.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/CheckboxListContext.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7D,UAAU,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,eAAO,MAAM,mBAAmB,0DACiC,CAAC"}
@@ -4,7 +4,8 @@
4
4
 
5
5
  /**
6
6
  * @file CheckboxListContext.tsx
7
- * @input Uses the private layer-scoped context factory
7
+ * @input Uses the private layer-scoped context factory and the RequiredGroup
8
+ * type
8
9
  * @output Exports CheckboxListContext for parent-child communication
9
10
  * @position Internal context; consumed by CheckboxList.tsx and CheckboxListItem.tsx
10
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxListItem.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/CheckboxListItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAqB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAIzD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAS5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAuBvC,MAAM,WAAW,qBAAsB,SAAQ,SAAS,CAAC,aAAa,CAAC;IACrE;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;;;;;;;;;OAaG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IACtC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;CAChC;AAyCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,KAAK,EACL,WAAW,EACX,UAAU,EACV,UAAU,EAAE,cAAsB,EAClC,SAAS,EAAE,aAAqB,EAChC,SAAS,EACT,OAAO,EACP,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,EACL,OAAO,EAAE,WAAW,EACpB,KAAK,EACL,GAAG,SAAS,EACb,EAAE,qBAAqB,+BA6IvB;yBA9Je,gBAAgB"}
1
+ {"version":3,"file":"CheckboxListItem.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/CheckboxListItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAkC,KAAK,SAAS,EAAC,MAAM,OAAO,C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xList.stories.tsx
17
17
  * - /packages/cli/assets/templates/blocks/components/CheckboxList/ (showcase blocks)
18
18
  */
19
- import { use, useId, useRef } from 'react';
19
+ import { use, useCallback, useId, useRef } from 'react';
20
20
  import * as stylex from '@stylexjs/stylex';
21
21
  import "../theme/tokens.stylex.js";
22
22
  import { colorVars } from "../theme/tokens.stylex.js";
@@ -26,6 +26,7 @@ import { ListContext } from "../List/ListContext.js";
26
26
  import { CheckboxListContext } from "./CheckboxListContext.js";
27
27
  import { ItemDescriptionContext } from "../Item/ItemDescriptionContext.js";
28
28
  import { joinAriaIDs } from "../utils/inputAria.js";
29
+ import { useMergedRefs } from "../hooks/useMergedRefs.js";
29
30
  import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
30
31
  import english from "../i18n/generated-english/CheckboxList/CheckboxListItem.generated.js";
31
32
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -172,6 +173,17 @@ export function CheckboxListItem({
172
173
  const checkboxRef = useRef(null);
173
174
  const hasRowInteraction = isInteractive || onClickProp != null;
174
175
 
176
+ // A required group decides which box carries native `required` from the
177
+ // state of every box. A change to this box's state registers it again.
178
+ const requiredGroup = ctx?.requiredGroup;
179
+ const isBoxChecked = resolvedChecked === true;
180
+ const isBoxEnabled = !effectiveDisabled && !effectiveReadOnly;
181
+ const registerWithRequiredGroup = useCallback(input => input != null && requiredGroup != null ? requiredGroup.register(input, {
182
+ isChecked: isBoxChecked,
183
+ isEnabled: isBoxEnabled
184
+ }) : undefined, [requiredGroup, isBoxChecked, isBoxEnabled]);
185
+ const checkboxInputRef = useMergedRefs(checkboxRef, registerWithRequiredGroup);
186
+
175
187
  // A read-only checkbox carries aria-readonly, which the row's clickable
176
188
  // container treats as a non-interactive target, so a click on it would be
177
189
  // delegated straight back to the checkbox without end. Stop that click at
@@ -222,7 +234,7 @@ export function CheckboxListItem({
222
234
  className: className,
223
235
  style: style,
224
236
  startContent: /*#__PURE__*/_jsx(DescribedCheckboxInput, {
225
- ref: checkboxRef,
237
+ ref: checkboxInputRef,
226
238
  label: checkboxLabel,
227
239
  "aria-labelledby": namesFromVisibleLabel ? labelID : undefined,
228
240
  isLabelHidden: true,
@@ -0,0 +1,22 @@
1
+ /** The state of one box that decides which box carries `required`. */
2
+ export interface RequiredGroupBox {
3
+ isChecked: boolean;
4
+ /** False for a disabled or read-only box, which the user cannot check. */
5
+ isEnabled: boolean;
6
+ }
7
+ export interface RequiredGroup {
8
+ /**
9
+ * Adds a checkbox with its state and updates `required` on every box.
10
+ * Returns a function that removes the checkbox, clears its `required`, and
11
+ * updates the rest. An item registers again when its state changes.
12
+ */
13
+ register: (input: HTMLInputElement, box: RequiredGroupBox) => () => void;
14
+ /**
15
+ * Updates `required` when the group's options move, for example after a
16
+ * keyed reorder, which registers no box again. Returns a function that
17
+ * stops it.
18
+ */
19
+ observe: (container: HTMLElement) => () => void;
20
+ }
21
+ export declare function createRequiredGroup(): RequiredGroup;
22
+ //# sourceMappingURL=requiredGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requiredGroup.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/requiredGroup.ts"],"names":[],"mappings":"AAkBA,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,KAAK,MAAM,IAAI,CAAC;IACzE;;;;OAIG;IACH,OAAO,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,MAAM,IAAI,CAAC;CACjD;AAUD,wBAAgB,mBAAmB,IAAI,aAAa,CA4BnD"}
@@ -0,0 +1,52 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file requiredGroup.ts
5
+ * @input The checkbox inputs of a required CheckboxList and each box's state;
6
+ * Core's shared mutation observer
7
+ * @output Exports createRequiredGroup, RequiredGroup, and RequiredGroupBox
8
+ * @position Internal to CheckboxList; CheckboxList creates one for an
9
+ * `isRequired` group and CheckboxListItem registers its checkbox with it
10
+ *
11
+ * The browser has no required state for a group of checkboxes. While no box
12
+ * is checked, the first enabled box carries native `required`. The browser
13
+ * then blocks submit and moves focus to that box with its own message. Once
14
+ * any box is checked, no box carries `required`.
15
+ */
16
+
17
+ import { observeMutations } from "../utils/sharedMutationObserver.js";
18
+
19
+ /** The state of one box that decides which box carries `required`. */
20
+
21
+ const MOVE_OPTIONS = {
22
+ childList: true,
23
+ subtree: true
24
+ };
25
+ function byDocumentOrder(a, b) {
26
+ return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
27
+ }
28
+ export function createRequiredGroup() {
29
+ const boxes = new Map();
30
+ function update() {
31
+ const ordered = [...boxes.keys()].sort(byDocumentOrder);
32
+ const isEmpty = ![...boxes.values()].some(box => box.isChecked);
33
+ const target = isEmpty ? ordered.find(input => boxes.get(input)?.isEnabled === true) : undefined;
34
+ for (const input of ordered) {
35
+ input.required = input === target;
36
+ }
37
+ }
38
+ return {
39
+ register(input, box) {
40
+ boxes.set(input, box);
41
+ update();
42
+ return () => {
43
+ boxes.delete(input);
44
+ input.required = false;
45
+ update();
46
+ };
47
+ },
48
+ observe(container) {
49
+ return observeMutations(container, MOVE_OPTIONS, update);
50
+ }
51
+ };
52
+ }
@@ -12,7 +12,7 @@ import { type WheelProps } from './wheelOptions.js';
12
12
  * <PickerWheel label="Month" options={monthOptions} value={month} onChange={setMonth} />
13
13
  * ```
14
14
  */
15
- export declare function PickerWheel({ label, options, value, onChange, isActive, }: WheelProps): import("react").JSX.Element;
15
+ export declare function PickerWheel({ label, options, value, onChange, isActive, ref, }: WheelProps): import("react").JSX.Element;
16
16
  export declare namespace PickerWheel {
17
17
  var displayName: string;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PickerWheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/PickerWheel.tsx"],"names":[],"mappings":"AAmDA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AA2HxB;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAe,GAChB,EAAE,UAAU,+BA8gBZ;yBAphBe,WAAW"}
1
+ {"version":3,"file":"PickerWheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/PickerWheel.tsx"],"names":[],"mappings":"AA2DA,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AA2HxB;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAe,EACf,GAAG,GACJ,EAAE,UAAU,+BAuiBZ;yBA9iBe,WAAW"}
@@ -4,7 +4,8 @@
4
4
 
5
5
  /**
6
6
  * @file PickerWheel.tsx
7
- * @input Wheel's props (wheelOptions.ts): options, value and change callback
7
+ * @input Wheel's props (wheelOptions.ts): options, value and change callback;
8
+ * optionally a ref for programmatic turns
8
9
  * @output PickerWheel: one picker column that moves like UIPickerView
9
10
  * @position Internal component; the Wheel under a finger (Wheel.tsx picks it)
10
11
  *
@@ -14,7 +15,7 @@
14
15
  * SYNC: When modified, update PickerWheel.test.tsx, Wheel.tsx,
15
16
  * DateInputTouch.test.tsx, DateInput.doc.mjs and TimeInput.doc.mjs.
16
17
  */
17
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
18
+ import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
18
19
  import * as stylex from '@stylexjs/stylex';
19
20
  import { scrollTypeOf } from "../gestures/GestureHost.js";
20
21
  import { PanGestureRecognizer } from "../gestures/PanGestureRecognizer.js";
@@ -36,7 +37,7 @@ import { useOwnScrollGesture } from "./useOwnScrollGesture.js";
36
37
  import { useWheelListbox } from "./useWheelListbox.js";
37
38
  import { createWheelStrip } from "./wheelStrip.js";
38
39
  import { dragOffset, nearestIndex, offsetBounds, planRelease, spinCurve } from "./wheelPhysics.js";
39
- import { endIndex, nearestEnabledIndex, steppedIndex, WHEEL_ROW_HEIGHT } from "./wheelOptions.js";
40
+ import { canSpinTo, endIndex, nearestEnabledIndex, steppedIndex, WHEEL_ROW_HEIGHT } from "./wheelOptions.js";
40
41
 
41
42
  /** Row pitch, px: the touch column keeps the scrolling column's pitch. */
42
43
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -130,7 +131,8 @@ export function PickerWheel({
130
131
  options,
131
132
  value,
132
133
  onChange,
133
- isActive = true
134
+ isActive = true,
135
+ ref
134
136
  }) {
135
137
  const columnRef = useRef(null);
136
138
  const rowsRef = useRef(null);
@@ -468,6 +470,28 @@ export function PickerWheel({
468
470
  isEnabled: isActive,
469
471
  isPointerKept: true
470
472
  });
473
+
474
+ // A spin turns only onto an enabled row (canSpinTo). So its arrival commits
475
+ // that row, and nothing turns on past it. It reports the row it was asked
476
+ // for, as the scrolling column does.
477
+ const spinTo = useCallback(async index => new Promise(resolve => {
478
+ if (!canSpinTo(latestRef.current.options, index)) {
479
+ resolve(false);
480
+ return;
481
+ }
482
+ const offset = motion.offset();
483
+ move(turnCurve(columnRef.current, offset, index * ROW_HEIGHT), {
484
+ onEnd: (outcome, end) => {
485
+ if (outcome === 'arrived') {
486
+ arrive(end);
487
+ }
488
+ resolve(outcome === 'arrived');
489
+ }
490
+ });
491
+ }), [motion, move, arrive]);
492
+ useImperativeHandle(ref, () => ({
493
+ spinTo
494
+ }), [spinTo]);
471
495
  const turnToPosition = useCallback((position, offset) => {
472
496
  const current = latestRef.current;
473
497
  const option = current.options[position];
@@ -1,5 +1,5 @@
1
1
  import { type WheelProps } from './wheelOptions.js';
2
- export { nearestEnabledIndex, type WheelOption, type WheelProps, } from './wheelOptions.js';
2
+ export { nearestEnabledIndex, type WheelHandle, type WheelOption, type WheelProps, } from './wheelOptions.js';
3
3
  /**
4
4
  * One picker column: UIPickerView's motion with flat rows under a finger, the
5
5
  * snap-scrolling column under a fine pointer.
@@ -31,7 +31,7 @@ export declare namespace Wheel {
31
31
  * />
32
32
  * ```
33
33
  */
34
- export declare function ScrollWheel({ label, options, value, onChange, isActive, }: WheelProps): import("react").JSX.Element;
34
+ export declare function ScrollWheel({ label, options, value, onChange, isActive, ref, }: WheelProps): import("react").JSX.Element;
35
35
  export declare namespace ScrollWheel {
36
36
  var displayName: string;
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Wheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/Wheel.tsx"],"names":[],"mappings":"AAoDA,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC;AAoMxB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BAKtC;yBALe,KAAK;;;AASrB;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAe,GAChB,EAAE,UAAU,+BAmUZ;yBAzUe,WAAW"}
1
+ {"version":3,"file":"Wheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/Wheel.tsx"],"names":[],"mappings":"AA2DA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC;AAoMxB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BAKtC;yBALe,KAAK;;;AASrB;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAe,EACf,GAAG,GACJ,EAAE,UAAU,+BAqVZ;yBA5Ve,WAAW"}
@@ -4,7 +4,8 @@
4
4
 
5
5
  /**
6
6
  * @file Wheel.tsx
7
- * @input Option list, selected value and change callback
7
+ * @input Option list, selected value and change callback; a ref for
8
+ * programmatic turns
8
9
  * @output Exports Wheel (one picker column), ScrollWheel (the scrolling
9
10
  * column) and the shared types of wheelOptions.ts
10
11
  * @position Internal component; consumed by MonthYearWheels.tsx,
@@ -26,7 +27,7 @@
26
27
  * - /packages/core/src/DateInput/DateInput.doc.mjs
27
28
  * - /packages/core/src/DateInput/DateInputTouch.test.tsx
28
29
  */
29
- import { useCallback, useEffect, useRef, useState } from 'react';
30
+ import { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
30
31
  import * as stylex from '@stylexjs/stylex';
31
32
  import "../theme/tokens.stylex.js";
32
33
  import { colorVars, radiusVars, fontWeightVars, typeScaleVars, spacingVars, durationVars } from "../theme/tokens.stylex.js";
@@ -40,7 +41,7 @@ import { useOwnScrollGesture } from "./useOwnScrollGesture.js";
40
41
  import { usePointerDragScroll } from "./usePointerDragScroll.js";
41
42
  import { useScrollSettle } from "./useScrollSettle.js";
42
43
  import { useWheelListbox } from "./useWheelListbox.js";
43
- import { endIndex, nearestEnabledIndex, steppedIndex } from "./wheelOptions.js";
44
+ import { canSpinTo, endIndex, nearestEnabledIndex, steppedIndex } from "./wheelOptions.js";
44
45
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
45
46
  export { nearestEnabledIndex } from "./wheelOptions.js";
46
47
  const ITEM_BLOCK_SIZE = dateInputTouchSizes.wheelItemSize;
@@ -130,8 +131,23 @@ export function ScrollWheel({
130
131
  options,
131
132
  value,
132
133
  onChange,
133
- isActive = true
134
+ isActive = true,
135
+ ref
134
136
  }) {
137
+ // A spin commits the row at once. The new value then scrolls the column
138
+ // there, as any new value does.
139
+ useImperativeHandle(ref, () => ({
140
+ spinTo: async index => {
141
+ if (!canSpinTo(options, index)) {
142
+ return false;
143
+ }
144
+ const option = options[index];
145
+ if (option.value !== value) {
146
+ onChange(option.value);
147
+ }
148
+ return true;
149
+ }
150
+ }), [options, value, onChange]);
135
151
  const scrollerRef = useRef(null);
136
152
  const selectedIndex = Math.max(0, options.findIndex(option => option.value === value));
137
153
  // Which row is under the band right now. Tracks the finger during a scroll;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @file datePickerTouch.ts
3
+ * @input The date and time pickers' touch-only pieces
4
+ * @output Re-exports what the date and time sheets use only under a finger:
5
+ * TimeWheels
6
+ * @position The pickers' touch layer. The sheets import touch behaviour from
7
+ * here only, so a desktop build can replace this one module.
8
+ *
9
+ * SYNC: When modified, update TouchTimeField.tsx and TouchDateTimeField.tsx.
10
+ */
11
+ export { TimeWheels } from '../TimeInput/TimeWheels.js';
12
+ export type { TimeWheelsProps } from '../TimeInput/TimeWheels.js';
13
+ //# sourceMappingURL=datePickerTouch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datePickerTouch.d.ts","sourceRoot":"","sources":["../../src/DateInput/datePickerTouch.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAC;AACnD,YAAY,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file datePickerTouch.ts
5
+ * @input The date and time pickers' touch-only pieces
6
+ * @output Re-exports what the date and time sheets use only under a finger:
7
+ * TimeWheels
8
+ * @position The pickers' touch layer. The sheets import touch behaviour from
9
+ * here only, so a desktop build can replace this one module.
10
+ *
11
+ * SYNC: When modified, update TouchTimeField.tsx and TouchDateTimeField.tsx.
12
+ */
13
+
14
+ export { TimeWheels } from "../TimeInput/TimeWheels.js";
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @file wheelOptions.ts
3
3
  * @input Nothing; types, the row height and pure functions
4
- * @output WheelOption, WheelProps, WHEEL_ROW_HEIGHT, nearestEnabledIndex,
5
- * steppedIndex and endIndex: what both wheels share
4
+ * @output WheelOption, WheelProps, WheelHandle, WHEEL_ROW_HEIGHT, canSpinTo,
5
+ * nearestEnabledIndex, steppedIndex and endIndex: what both wheels share
6
6
  * @position Internal; read by Wheel.tsx (which re-exports all of it) and
7
7
  * PickerWheel.tsx
8
8
  *
@@ -10,6 +10,7 @@
10
10
  * - /packages/core/src/DateInput/Wheel.tsx
11
11
  * - /packages/core/src/DateInput/PickerWheel.tsx
12
12
  */
13
+ import type { Ref } from 'react';
13
14
  /**
14
15
  * The row height, px (`dateInputTouchSizes.wheelItemSize`): the pitch of both
15
16
  * columns' rows, and the unit of the touch wheel's offset.
@@ -32,6 +33,18 @@ export interface WheelOption {
32
33
  */
33
34
  order?: number;
34
35
  }
36
+ /** What a Wheel's `ref` exposes. */
37
+ export interface WheelHandle {
38
+ /**
39
+ * Turn the wheel onto `index` (an index into `options`) on the tap spin, then
40
+ * commit it as a rest would. Resolves true once that row is the committed
41
+ * one, false if a finger or another turn interrupted it or the wheel went
42
+ * away first. An index outside `options` or a disabled row resolves false at
43
+ * once, and nothing turns. Under a fine pointer the row commits at once. The
44
+ * column then scrolls to it as for any new value, on the same rule.
45
+ */
46
+ spinTo(index: number): Promise<boolean>;
47
+ }
35
48
  export interface WheelProps {
36
49
  /** Accessible name for the column, e.g. "Month". */
37
50
  label: string;
@@ -48,7 +61,14 @@ export interface WheelProps {
48
61
  * motion.
49
62
  */
50
63
  isActive?: boolean;
64
+ /** Programmatic turns: `spinTo(index)`. */
65
+ ref?: Ref<WheelHandle>;
51
66
  }
67
+ /**
68
+ * Whether `spinTo(index)` may turn onto `index`: an enabled row of `options`.
69
+ * The touch wheel and the scrolling column answer a spin by the same rule.
70
+ */
71
+ export declare function canSpinTo(options: ReadonlyArray<WheelOption>, index: number): boolean;
52
72
  /**
53
73
  * The enabled row nearest `index`: `index` itself when it is enabled,
54
74
  * otherwise the closest enabled row on either side. A tie goes to the side of
@@ -1 +1 @@
1
- {"version":3,"file":"wheelOptions.d.ts","sourceRoot":"","sources":["../../src/DateInput/wheelOptions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACpC,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,MAAM,CAsBR;AAaD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,MAAM,GAAG,IAAI,CAyBf;AAED,uFAAuF;AACvF,wBAAgB,QAAQ,CACtB,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,GAAG,EAAE,OAAO,GAAG,MAAM,GACpB,MAAM,GA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R;AAaD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,MAAM,GAAG,IAAI,CAyBf;AAED,uFAAuF;AACvF,wBAAgB,QAAQ,CACtB,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,GAAG,EAAE,OAAO,GAAG,MAAM,GACpB,MAAM,GAAG,IAAI,CAKf"}
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @file wheelOptions.ts
5
5
  * @input Nothing; types, the row height and pure functions
6
- * @output WheelOption, WheelProps, WHEEL_ROW_HEIGHT, nearestEnabledIndex,
7
- * steppedIndex and endIndex: what both wheels share
6
+ * @output WheelOption, WheelProps, WheelHandle, WHEEL_ROW_HEIGHT, canSpinTo,
7
+ * nearestEnabledIndex, steppedIndex and endIndex: what both wheels share
8
8
  * @position Internal; read by Wheel.tsx (which re-exports all of it) and
9
9
  * PickerWheel.tsx
10
10
  *
@@ -18,6 +18,18 @@
18
18
  * columns' rows, and the unit of the touch wheel's offset.
19
19
  */
20
20
  export const WHEEL_ROW_HEIGHT = 28;
21
+
22
+ /** What a Wheel's `ref` exposes. */
23
+
24
+ /**
25
+ * Whether `spinTo(index)` may turn onto `index`: an enabled row of `options`.
26
+ * The touch wheel and the scrolling column answer a spin by the same rule.
27
+ */
28
+ export function canSpinTo(options, index) {
29
+ const option = options[index];
30
+ return option != null && !option.isDisabled;
31
+ }
32
+
21
33
  /**
22
34
  * The enabled row nearest `index`: `index` itself when it is enabled,
23
35
  * otherwise the closest enabled row on either side. A tie goes to the side of
@@ -1 +1 @@
1
- {"version":3,"file":"TouchDateTimeField.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/TouchDateTimeField.tsx"],"names":[],"mappings":"AA6GA,OAAO,KAAK,EAAC,kBAAkB,EAAoB,MAAM,iBAAiB,CAAC;AAoV3E,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAe,EACf,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,SAAiB,EACjB,GAAG,EACH,GAAG,EACH,eAAe,EACf,UAAkB,EAClB,UAAkB,EAElB,aAAa,EAAE,cAAc,EAC7B,kBAAkB,EAAE,mBAAmB,EACvC,QAAgB,EAChB,WAAW,EAAE,oBAAoB,EACjC,eAAe,EAAE,wBAAwB,EACzC,SAAS,EACT,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,YAAY,EAEZ,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,gBAAoB,EAClC,KAAK,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,GAAG,EACH,GAAG,SAAS,EACb,EAAE,kBAAkB,+BAy/BpB;yBAhiCe,kBAAkB"}
1
+ {"version":3,"file":"TouchDateTimeField.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/TouchDateTimeField.tsx"],"names":[],"mappings":"AAuHA,OAAO,KAAK,EAAC,kBAAkB,EAAoB,MAAM,iBAAiB,CAAC;AA6S3E,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAe,EACf,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,SAAiB,EACjB,GAAG,EACH,GAAG,EACH,eAAe,EACf,UAAkB,EAClB,UAAkB,EAElB,aAAa,EAAE,cAAc,EAC7B,kBAAkB,EAAE,mBAAmB,EACvC,QAAgB,EAChB,WAAW,EAAE,oBAAoB,EACjC,eAAe,EAAE,wBAAwB,EACzC,SAAS,EACT,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,YAAY,EAEZ,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,gBAAoB,EAClC,KAAK,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,GAAG,EACH,GAAG,SAAS,EACb,EAAE,kBAAkB,+BAk8BpB;yBAz+Be,kBAAkB"}