asma-ui-core 3.132.0 → 3.133.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.
@@ -8,5 +8,7 @@ export declare const TimePickerInput: React.FC<StyledTimePickerProps & {
8
8
  isValidTime: boolean;
9
9
  isValidEndTime: boolean;
10
10
  isMissingTime?: boolean;
11
+ /** Set only while the current entry is one `isTimeDisabled` refuses; carries its reason. */
12
+ disabledTimeError?: React.ReactNode;
11
13
  localValue: string;
12
14
  }>;
@@ -1,7 +1,11 @@
1
+ import { TimePredicate } from '../helpers/disabledTime';
2
+ import { ReactNode } from 'react';
1
3
  export interface TimePickerPanelProps {
2
4
  dataTest: string;
3
5
  value?: Date;
4
6
  minTime?: Date;
7
+ isTimeDisabled?: TimePredicate;
8
+ disabledTimeReason?: ReactNode;
5
9
  onSelect: (date: Date | undefined) => void;
6
10
  handleClear: () => void;
7
11
  onConfirm: () => void;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Marking individual clock times unavailable, from a predicate the consumer owns.
3
+ *
4
+ * ## Why a predicate rather than a second bound
5
+ *
6
+ * `minTime` answers one shape of question — "nothing before this" — with a single `<` on day
7
+ * minutes. The question that needed answering here is a **band**, and the band that motivated it
8
+ * wraps midnight: a customer's quiet hours for patient SMS are typically `22:00–06:00`, where
9
+ * `start < end` is false and no pair of bounds expresses it. Mirroring `minTime` with a `maxTime`
10
+ * would have left the wrap rule implicit (`start > end` secretly meaning "inverted") and still only
11
+ * ever described one contiguous band.
12
+ *
13
+ * A predicate states the rule at the call site, where the domain lives, and this file stays a
14
+ * question of which *cells* that rule rejects.
15
+ *
16
+ * ## Only the clock time counts
17
+ *
18
+ * Same contract as {@link isBeforeMinTime}: the calendar day of the date handed to the predicate is
19
+ * the consumer's concern, never this picker's. Cells are probed on the day of the current value so
20
+ * a predicate that happens to read the date still sees a coherent instant.
21
+ */
22
+ export type TimePredicate = (time: Date) => boolean;
23
+ /**
24
+ * An hour cell is unavailable only when **every** minute cell inside it is.
25
+ *
26
+ * This deliberately mirrors `isHourDisabled`'s rule for `minTime` rather than probing the hour on
27
+ * its own: an hour that is half available is still reachable, and greying it would strand the
28
+ * minutes the consumer does allow. Only the steps the minutes column actually offers are probed —
29
+ * checking all 60 would disable an hour the user can never select into anyway.
30
+ */
31
+ export declare const isHourRejected: (hour: number, reference: Date, isTimeDisabled?: TimePredicate) => boolean;
32
+ /** A single minute cell, gated by the hour the minutes column is currently showing. */
33
+ export declare const isMinuteRejected: (hour: number, minute: number, reference: Date, isTimeDisabled?: TimePredicate) => boolean;
34
+ /** A complete time — what a typed entry or a stale panel pick has to be checked against. */
35
+ export declare const isTimeRejected: (time: Date | undefined, isTimeDisabled?: TimePredicate) => boolean;
@@ -1,5 +1,6 @@
1
1
  import { AriaAttributes, ReactNode } from 'react';
2
2
  import { FieldWidth } from '../../../components/inputs/field-styles';
3
+ import { TimePredicate } from './helpers/disabledTime';
3
4
  /**
4
5
  * @param notBeforeTime - Start time of the range. Selected time must be after this value.
5
6
  */
@@ -31,6 +32,25 @@ export interface StyledTimePickerProps {
31
32
  * Unlike `notBeforeTime`, it never shows an error.
32
33
  */
33
34
  minTime?: Date;
35
+ /**
36
+ * @figmaProp none — behavioral; drives the Time item `State=Disabled` cells (node 15086-19871).
37
+ * Marks arbitrary clock times unavailable, including a band that wraps midnight, which no pair
38
+ * of bounds can express. An hour cell greys only when every minute cell inside it is rejected,
39
+ * matching `minTime`'s rule.
40
+ *
41
+ * Unlike `minTime`, a rejected time typed by hand **raises the error state** rather than
42
+ * silently reverting: the consumer asked for these times to be refused, so swallowing the entry
43
+ * would leave the author believing it was accepted.
44
+ *
45
+ * Pair it with {@link disabledTimeReason}; a disabled cell with no reason is a dead end.
46
+ */
47
+ isTimeDisabled?: TimePredicate;
48
+ /**
49
+ * Why {@link isTimeDisabled} rejects what it rejects. Serves twice, so one string cannot drift
50
+ * from the other: the tooltip on a rejected cell, and the field error when a rejected time is
51
+ * typed. Copy stays with the consumer — this picker knows nothing about anyone's domain.
52
+ */
53
+ disabledTimeReason?: ReactNode;
34
54
  /**
35
55
  * Extra ARIA attributes for the text input (e.g. `aria-label`, `aria-required`) — for a visible
36
56
  * label rendered outside the picker. Without them the input is named by `title` or `label`.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.132.0",
6
+ "version": "3.133.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",