@mond-design-system/react 1.0.0-alpha.0 → 1.0.0-alpha.1

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, HTMLAttributes, JSX, ReactElement, ReactNode, ButtonHTMLAttributes, ElementType, Ref, AnchorHTMLAttributes, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, LiHTMLAttributes, MouseEventHandler, RefObject, KeyboardEvent } from 'react';
2
+ import { CSSProperties, HTMLAttributes, JSX, ReactElement, ReactNode, ButtonHTMLAttributes, ElementType, Ref, AnchorHTMLAttributes, MouseEventHandler, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, LiHTMLAttributes, RefObject, KeyboardEvent } from 'react';
3
3
 
4
4
  /**
5
5
  * Join class names, dropping anything falsy.
@@ -234,6 +234,181 @@ interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
234
234
  */
235
235
  declare function Badge({ tone, className, ...rest }: BadgeProps): ReactElement;
236
236
 
237
+ type ChipVariant = "soft" | "outline";
238
+ interface ChipProps extends HTMLAttributes<HTMLElement> {
239
+ children: ReactNode;
240
+ /** Unselected appearance. Default "soft". */
241
+ variant?: ChipVariant;
242
+ /** Toggle state. When given on an interactive chip it also sets aria-pressed;
243
+ * omit for a plain action chip so it does not announce as a toggle. */
244
+ selected?: boolean;
245
+ /** Leading glyph, e.g. `<Icon name="check" size="sm" />`. */
246
+ icon?: ReactNode;
247
+ /** When provided, Chip renders as a `<button>`. */
248
+ onClick?: MouseEventHandler;
249
+ disabled?: boolean;
250
+ }
251
+ /**
252
+ * Compact pill for filters and single/multi choices. Interactive (a button,
253
+ * with aria-pressed when `selected` is given) when `onClick` is set, otherwise
254
+ * a static pill. For a passive content label use Tag instead.
255
+ *
256
+ * ```tsx
257
+ * <Chip selected={filter === "all"} onClick={() => setFilter("all")}>All</Chip>
258
+ * <Chip variant="outline" icon={<Icon name="pin" size="sm" />}>Nearby</Chip>
259
+ * ```
260
+ */
261
+ declare function Chip({ children, variant, selected, icon, onClick, disabled, className, ...rest }: ChipProps): ReactElement;
262
+
263
+ type ChipGroupGap = "hairline" | "tight" | "base";
264
+ interface ChipGroupProps extends HTMLAttributes<HTMLDivElement> {
265
+ /** Chips (or any inline items) laid out in a wrapping group. */
266
+ children: ReactNode;
267
+ /** Space between items, on the gap scale. Default "tight". */
268
+ gap?: ChipGroupGap;
269
+ }
270
+ /**
271
+ * Wrapping row of Chips for multi-select choices inside a form (pick several
272
+ * days, locations, tags…). Items wrap onto new lines so nothing scrolls
273
+ * off-screen; use ChipBar for a single-line scrolling filter strip.
274
+ *
275
+ * ```tsx
276
+ * <ChipGroup>
277
+ * {days.map((day) => (
278
+ * <Chip key={day} selected={picked.has(day)} onClick={() => toggle(day)}>
279
+ * {day}
280
+ * </Chip>
281
+ * ))}
282
+ * </ChipGroup>
283
+ * ```
284
+ */
285
+ declare function ChipGroup({ children, gap, className, ...rest }: ChipGroupProps): ReactElement;
286
+
287
+ type ChipBarGap = "hairline" | "tight" | "base";
288
+ interface ChipBarProps extends HTMLAttributes<HTMLDivElement> {
289
+ /** Chips (or any inline items) laid out in a single scrolling row. */
290
+ children: ReactNode;
291
+ /** Space between items, on the gap scale. Default "tight". */
292
+ gap?: ChipBarGap;
293
+ /** Frame the strip so overflow reads as a scroll area. Default false. */
294
+ bordered?: boolean;
295
+ /** Fade the trailing edge to hint that the row scrolls. Default true. */
296
+ fade?: boolean;
297
+ }
298
+ /**
299
+ * Horizontally scrollable single-line row of Chips — a filter strip. Items
300
+ * never wrap; the row scrolls when they overflow. `fade` dissolves the
301
+ * trailing edge so the last chip hints at more rather than getting chopped
302
+ * mid-word. Use ChipGroup for a wrapping set of choices inside a form.
303
+ *
304
+ * ```tsx
305
+ * <ChipBar>
306
+ * {segments.map((s) => (
307
+ * <Chip key={s} selected={s === segment} onClick={() => setSegment(s)}>
308
+ * {s}
309
+ * </Chip>
310
+ * ))}
311
+ * </ChipBar>
312
+ * ```
313
+ */
314
+ declare function ChipBar({ children, gap, bordered, fade, className, ...rest }: ChipBarProps): ReactElement;
315
+
316
+ type CountButtonTone = "accent" | "danger";
317
+ interface CountButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "aria-label" | "aria-pressed"> {
318
+ /** Glyph shown before the text, e.g. `<Icon name="heart" />` (md). */
319
+ icon: ReactNode;
320
+ /** Accessible label (required) — describes the action for screen readers. */
321
+ label: string;
322
+ /**
323
+ * Toggle state. When defined, sets `aria-pressed` and tints the control
324
+ * with the tone colour. Omit for non-toggle actions (e.g. comment).
325
+ */
326
+ active?: boolean;
327
+ /** Token the active tint reads. Default "accent". */
328
+ tone?: CountButtonTone;
329
+ /**
330
+ * The write behind this action is in flight. Swaps the glyph for a spinner
331
+ * of the same size and locks the control — a second tap in that window
332
+ * would toggle the write straight back off.
333
+ */
334
+ loading?: boolean;
335
+ /** Visible text beside the icon — typically a count or a word. */
336
+ children?: ReactNode;
337
+ }
338
+ /**
339
+ * Inline, chrome-less pressable pairing an icon with a count or word — like,
340
+ * comment, react actions. Owns hover, press, disabled, loading and active
341
+ * (`aria-pressed`) states so consumers never hand-roll button chrome.
342
+ *
343
+ * The app owns the glyph, so it also owns the filled/outline swap:
344
+ *
345
+ * ```tsx
346
+ * <CountButton
347
+ * icon={<Icon name={liked ? "heart-filled" : "heart"} />}
348
+ * label={liked ? "Unlike" : "Like"}
349
+ * active={liked}
350
+ * loading={likeMutation.isPending}
351
+ * onClick={() => likeMutation.mutate()}
352
+ * >
353
+ * {likeCount}
354
+ * </CountButton>
355
+ * ```
356
+ */
357
+ declare function CountButton({ icon, label, active, tone, disabled, loading, className, children, ...rest }: CountButtonProps): ReactElement;
358
+
359
+ interface DateTimePickerLabels {
360
+ /** Accessible name of the picker dialog. */
361
+ dialog: string;
362
+ previousMonth: string;
363
+ nextMonth: string;
364
+ today: string;
365
+ done: string;
366
+ hour: string;
367
+ minute: string;
368
+ dayPeriod: string;
369
+ }
370
+ interface DateTimePickerProps {
371
+ /** Current value as an ISO 8601 string. */
372
+ value?: string | undefined;
373
+ /** Fires with the combined ISO string when the user confirms. */
374
+ onChange: (iso: string) => void;
375
+ /** Shown on the trigger when nothing is selected. */
376
+ placeholder?: string | undefined;
377
+ /** Earliest selectable moment as an ISO string. Default: now. */
378
+ min?: string | undefined;
379
+ /** Minute granularity. Default 5; use 30 for :00/:30 only. */
380
+ minuteStep?: number | undefined;
381
+ disabled?: boolean | undefined;
382
+ /** Applied to the trigger button so a `<label htmlFor>` can point at it. */
383
+ id?: string | undefined;
384
+ /** Field name for the trigger, e.g. "Starts". Announced alongside the value. */
385
+ "aria-label"?: string | undefined;
386
+ /** BCP 47 tag for names, week start and hour cycle. Default: runtime locale. */
387
+ locale?: string | undefined;
388
+ /** Overrides for the picker's own strings (defaults are English). */
389
+ labels?: Partial<DateTimePickerLabels> | undefined;
390
+ }
391
+ /**
392
+ * Mobile-first date + time picker. A trigger styled like Input opens a bottom
393
+ * sheet with a month calendar (roving-focus grid, arrow keys move the day)
394
+ * and native Select time controls. Controlled via `value` (ISO); emits the
395
+ * combined ISO string on confirm. All names, the week start and the 12/24-hour
396
+ * clock come from `Intl` for the given locale.
397
+ *
398
+ * ```tsx
399
+ * <Field label="Starts">
400
+ * <DateTimePicker
401
+ * value={startsAt}
402
+ * onChange={setStartsAt}
403
+ * min={new Date().toISOString()}
404
+ * minuteStep={30}
405
+ * locale={i18n.language}
406
+ * />
407
+ * </Field>
408
+ * ```
409
+ */
410
+ declare function DateTimePicker({ value, onChange, placeholder, min, minuteStep, disabled, id, "aria-label": ariaLabel, locale, labels, }: DateTimePickerProps): ReactElement;
411
+
237
412
  type TagTone = "neutral" | "accent";
238
413
  interface TagProps extends HTMLAttributes<HTMLSpanElement> {
239
414
  children: ReactNode;
@@ -914,6 +1089,45 @@ interface UseOverlayOptions {
914
1089
  */
915
1090
  declare function useOverlay<T extends HTMLElement>(options: UseOverlayOptions): RefObject<T | null>;
916
1091
 
1092
+ interface OverlayHistory {
1093
+ /**
1094
+ * An overlay has opened. The implementation adds a history entry, and calls
1095
+ * `onPop` if the user goes back to it. Returns a dispose for when the
1096
+ * overlay closes some other way — its close button, Escape, the scrim, or
1097
+ * unmounting. The implementation owes the entry back: one left behind is a
1098
+ * back tap that does nothing.
1099
+ */
1100
+ register(onPop: () => void): () => void;
1101
+ }
1102
+ /**
1103
+ * On a phone, back is also the dismiss gesture: an open overlay that ignores
1104
+ * it costs the user the screen underneath instead. The library owns *when* an
1105
+ * overlay opens and closes; the app owns the history mechanism, because a raw
1106
+ * `history.pushState` from a library corrupts a router's own bookkeeping
1107
+ * (React Router keeps its index in `history.state`).
1108
+ *
1109
+ * Null wherever no app has supplied one — Storybook, a unit test, a consumer
1110
+ * that has not opted in. Overlays go on working; they just do not answer back.
1111
+ *
1112
+ * `useOverlay` registers every open overlay, so Modal, Sheet and
1113
+ * ConfirmDialog are covered with no per-call-site wiring:
1114
+ *
1115
+ * ```tsx
1116
+ * // App root — e.g. backed by the app router:
1117
+ * const overlayHistory = useMemo<OverlayHistory>(() => ({
1118
+ * register(onPop) {
1119
+ * pushOverlayEntry(onPop); // app-owned, via the router
1120
+ * return () => popOverlayEntry(); // give the entry back
1121
+ * },
1122
+ * }), []);
1123
+ *
1124
+ * <OverlayHistoryContext.Provider value={overlayHistory}>
1125
+ * <App />
1126
+ * </OverlayHistoryContext.Provider>
1127
+ * ```
1128
+ */
1129
+ declare const OverlayHistoryContext: react.Context<OverlayHistory | null>;
1130
+
917
1131
  interface Presence {
918
1132
  /** Keep the element in the DOM (true during exit animation). */
919
1133
  mounted: boolean;
@@ -939,4 +1153,4 @@ interface RovingGroupOptions {
939
1153
  */
940
1154
  declare function useRovingGroup(ref: RefObject<HTMLElement | null>, { selector, orientation }: RovingGroupOptions): (event: KeyboardEvent<HTMLElement>) => void;
941
1155
 
942
- export { AppBar, type AppBarProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeTone, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CSSVars, Card, CardBody, CardFooter, CardHeader, type CardProps, type CardSectionProps, type CardVariant, Checkbox, type CheckboxProps, ConfirmDialog, type ConfirmDialogProps, Container, type ContainerProps, type ContainerWidth, Divider, type DividerProps, EmptyState, type EmptyStateProps, Field, type FieldContextValue, type FieldProps, Heading, type HeadingLevel, type HeadingProps, type HeadingTone, Icon, type IconProps, IconProvider, type IconProviderProps, type IconRender, type IconRenderProps, type IconSize, Inline, type InlineAlign, type InlineGap, type InlineJustify, type InlineProps, Input, type InputProps, type InputSize, Link, type LinkProps, type LinkVariant, ListGroup, type ListGroupProps, ListItem, type ListItemProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, PasswordInput, type PasswordInputProps, type Presence, ProgressBar, type ProgressBarProps, Radio, type RadioProps, type RovingGroupOptions, Screen, ScreenContent, SearchField, type SearchFieldProps, type SegmentOption, SegmentedControl, type SegmentedControlProps, Select, type SelectProps, type SelectSize, Sheet, SheetBody, SheetFooter, SheetHeader, type SheetProps, Skeleton, type SkeletonProps, type SkeletonVariant, Spinner, type SpinnerProps, Stack, type StackAlign, type StackGap, type StackProps, Switch, type SwitchProps, Tab, TabBar, TabBarItem, type TabBarItemProps, type TabBarProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Tag, type TagProps, type TagTone, Text, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, type UseOverlayOptions, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
1156
+ export { AppBar, type AppBarProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeTone, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CSSVars, Card, CardBody, CardFooter, CardHeader, type CardProps, type CardSectionProps, type CardVariant, Checkbox, type CheckboxProps, Chip, ChipBar, type ChipBarGap, type ChipBarProps, ChipGroup, type ChipGroupGap, type ChipGroupProps, type ChipProps, type ChipVariant, ConfirmDialog, type ConfirmDialogProps, Container, type ContainerProps, type ContainerWidth, CountButton, type CountButtonProps, type CountButtonTone, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Divider, type DividerProps, EmptyState, type EmptyStateProps, Field, type FieldContextValue, type FieldProps, Heading, type HeadingLevel, type HeadingProps, type HeadingTone, Icon, type IconProps, IconProvider, type IconProviderProps, type IconRender, type IconRenderProps, type IconSize, Inline, type InlineAlign, type InlineGap, type InlineJustify, type InlineProps, Input, type InputProps, type InputSize, Link, type LinkProps, type LinkVariant, ListGroup, type ListGroupProps, ListItem, type ListItemProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type OverlayHistory, OverlayHistoryContext, PasswordInput, type PasswordInputProps, type Presence, ProgressBar, type ProgressBarProps, Radio, type RadioProps, type RovingGroupOptions, Screen, ScreenContent, SearchField, type SearchFieldProps, type SegmentOption, SegmentedControl, type SegmentedControlProps, Select, type SelectProps, type SelectSize, Sheet, SheetBody, SheetFooter, SheetHeader, type SheetProps, Skeleton, type SkeletonProps, type SkeletonVariant, Spinner, type SpinnerProps, Stack, type StackAlign, type StackGap, type StackProps, Switch, type SwitchProps, Tab, TabBar, TabBarItem, type TabBarItemProps, type TabBarProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Tag, type TagProps, type TagTone, Text, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, type UseOverlayOptions, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };