@q1travel/design-system 0.3.2 → 0.4.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.
@@ -262,7 +262,7 @@ declare type CardOwnProps = {
262
262
 
263
263
  export declare type CardProps = CardAsLink | CardAsContainer;
264
264
 
265
- export declare function Checkbox(props: ControlOptionOwnProps & CheckboxOnlyProps & NativeInputProps): JSX.Element;
265
+ export declare function Checkbox({ ...props }: ControlOptionOwnProps & (FieldShellProps | FieldBareProps) & CheckboxOnlyProps & NativeInputProps): JSX.Element;
266
266
 
267
267
  declare type CheckboxOnlyProps = {
268
268
  /** 半选:视觉态而非第三个值,由父级逻辑驱动(如"部分子项已选")。AT 读作 mixed。 */
@@ -365,10 +365,16 @@ export declare function CollapsibleBreadcrumb({ items, label }: {
365
365
  label: string;
366
366
  }): JSX.Element;
367
367
 
368
- export declare function Combobox({ options, placeholder, emptyLabel, size, disabled, error, clearable, inputId, }: ComboboxProps): JSX.Element;
368
+ export declare function Combobox({ options, value, onChange, placeholder, size, disabled, readOnly, invalid, errorId, error, emptyText, clearable, id, className, name, inputMode, spellCheck, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, ref, ...rest }: ComboboxProps): JSX.Element;
369
369
 
370
370
  export declare type ComboboxOption = {
371
+ /** 禁止空字符串(与「未选」的受控空值歧义,adapter 层保证)。 */
371
372
  value: string;
373
+ /** 显示与过滤的唯一来源。 */
374
+ label: string;
375
+ disabled?: boolean;
376
+ /** 组件透而不读,仅随 onChange 第二参原样带回。 */
377
+ meta?: unknown;
372
378
  /** 选项文本前的图标/装饰(如区域旗帜、状态点)。 */
373
379
  prefix?: ReactNode;
374
380
  /** 选项文本后的图标/装饰(如快捷键、外链标记)。 */
@@ -376,16 +382,41 @@ export declare type ComboboxOption = {
376
382
  };
377
383
 
378
384
  declare type ComboboxProps = {
385
+ /** 唯一 shape,后端字段在 adapter 层转换。 */
379
386
  options: ComboboxOption[];
380
- placeholder: string;
381
- /** 空状态模板的名词(「没有匹配『查询』的{emptyLabel}」)。 */
382
- emptyLabel?: string;
387
+ /** 受控选中值;'' = 未选。 */
388
+ value: string;
389
+ /** 选中传 (option.value, option);clearable 清除传 ('', undefined)。 */
390
+ onChange?: (value: string, option?: ComboboxOption) => void;
391
+ /** 同时作 listbox 的 aria-label。 */
392
+ placeholder?: string;
393
+ /** 家族刻度 sm32/md40/lg48(与 Input/Select/Button 同一体系)。 */
383
394
  size?: ComboboxSize;
384
395
  disabled?: boolean;
396
+ /** 值只读:不可输入、不展开列表。 */
397
+ readOnly?: boolean;
398
+ /** 业务错误模型(主):置 aria-invalid 与错误描边,文案由外部渲染(配 errorId)。 */
399
+ invalid?: boolean;
400
+ /** 外部错误文案元素的 id → aria-describedby;组件不渲染任何文案(外部拥有)。 */
401
+ errorId?: string;
402
+ /** 家族便捷(辅):组件自渲染错误文案并隐含 invalid;与 invalid/errorId 可共存。 */
385
403
  error?: string;
404
+ /** 空态条目;默认业务中立平文案,可传 ReactNode(如带链接的引导)。 */
405
+ emptyText?: ReactNode;
406
+ /** 清除按钮 + Esc 二段清除。 */
386
407
  clearable?: boolean;
387
- /** 供外部 <label htmlFor> 关联;组件自身无 label 属性。 */
388
- inputId?: string;
408
+ /** 施于内部 input,供外部 <label htmlFor> 关联。 */
409
+ id?: string;
410
+ className?: string;
411
+ name?: string;
412
+ inputMode?: InputHTMLAttributes<HTMLInputElement>['inputMode'];
413
+ spellCheck?: boolean;
414
+ 'aria-label'?: string;
415
+ 'aria-labelledby'?: string;
416
+ /** 指向内部 role=combobox 的真实 input(非 wrapper),与内部回焦 ref 合并。 */
417
+ ref?: Ref<HTMLInputElement>;
418
+ } & {
419
+ [dataAttr: `data-${string}`]: string | number | boolean | undefined;
389
420
  };
390
421
 
391
422
  export declare type ComboboxSize = 'sm' | 'md' | 'lg';
@@ -452,15 +483,15 @@ export declare type ContextMenuEntry = {
452
483
  type: 'separator';
453
484
  };
454
485
 
455
- export declare function ControlOption({ id, label, description, error, indeterminate, type, ...rest }: ControlOptionOwnProps & CheckboxOnlyProps & {
486
+ export declare function ControlOption({ id, label, description, error, indeterminate, ref, type, ...rest }: ControlOptionOwnProps & (FieldShellProps | FieldBareProps) & CheckboxOnlyProps & {
456
487
  type: 'checkbox' | 'radio';
457
488
  } & NativeInputProps): JSX.Element;
458
489
 
459
490
  declare type ControlOptionOwnProps = {
460
- id: string;
461
- label: string;
462
- description?: string;
463
- error?: string;
491
+ /** 缺省走 useId;显式传入时行为同现状(specimen/测试可寻址)。 */
492
+ id?: string;
493
+ /** 指向原生 input(ref-as-prop,React 19),供表头全选聚焦等场景使用;与内部 indeterminate ref 合并。 */
494
+ ref?: Ref<HTMLInputElement>;
464
495
  };
465
496
 
466
497
  export declare function CopyButton({ value, label, successMessage, size, className, }: {
@@ -516,13 +547,14 @@ export declare function Drawer({ open, onClose, title, children, footer, height,
516
547
  height?: number;
517
548
  }): JSX.Element | null;
518
549
 
519
- export declare function EmptyState({ icon, title, description, actions, live, }: {
520
- icon: ReactNode;
550
+ export declare function EmptyState({ icon, title, description, actions, headingLevel, }: {
551
+ icon?: ReactNode;
521
552
  title: string;
522
- description: string;
553
+ description?: string;
523
554
  /** CTA 区:传家族 <Button> 与次要链接;最多一个主 CTA。 */
524
555
  actions?: ReactNode;
525
- live?: boolean;
556
+ /** 标题层级:缺省渲染 p(不进标题树);作为页面区块时传 2-6 渲染对应 h 标签。 */
557
+ headingLevel?: 2 | 3 | 4 | 5 | 6;
526
558
  }): JSX.Element;
527
559
 
528
560
  export declare function Entity({ leading, title, subtitle, trailing, }: {
@@ -558,6 +590,12 @@ export declare function Feedback({ label, prompt, placeholder, inline, topics, }
558
590
  topics?: string[];
559
591
  }): JSX.Element;
560
592
 
593
+ declare type FieldBareProps = {
594
+ label?: never;
595
+ description?: never;
596
+ error?: never;
597
+ };
598
+
561
599
  export declare function Fieldset({ title, subtitle, tone, footerStatus, footerAction, disabled, children, }: {
562
600
  title?: string;
563
601
  subtitle: string;
@@ -570,6 +608,12 @@ export declare function Fieldset({ title, subtitle, tone, footerStatus, footerAc
570
608
 
571
609
  export declare type FieldsetTone = 'danger' | 'warning';
572
610
 
611
+ declare type FieldShellProps = {
612
+ label: string;
613
+ description?: string;
614
+ error?: string;
615
+ };
616
+
573
617
  export declare type FieldSize = 'xs' | 'sm' | 'md' | 'lg';
574
618
 
575
619
  export declare function FileTree({ nodes, label, defaultExpanded, }: {
@@ -607,11 +651,15 @@ declare type GaugeSize = 'xs' | 'sm' | 'md' | 'lg';
607
651
 
608
652
  declare type GaugeToneDirection = 'quota' | 'health';
609
653
 
610
- export declare function Input({ id, label, description, error, prefix, suffix, prefixStyling, suffixStyling, rounded, wide, size, className, ...rest }: {
611
- id: string;
612
- label: string;
613
- description?: string;
614
- error?: string;
654
+ export declare function Input({ id, label, description, error, invalid, errorId, ref, prefix, suffix, prefixStyling, suffixStyling, rounded, wide, size, className, ...rest }: {
655
+ /** 可选:未传时内部 useId 兜底(对齐 Combobox);显式传入时行为同 0.3.0。 */
656
+ id?: string;
657
+ /** 置 aria-invalid 的业务校验态,不渲染文案;与壳模式 error 并轨(invalid || Boolean(error))。 */
658
+ invalid?: boolean;
659
+ /** 业务侧错误文案元素的 id,拼入 aria-describedby;文案由业务层渲染。 */
660
+ errorId?: string;
661
+ /** 指向原生 input(ref-as-prop),供校验失败聚焦、测量等场景。 */
662
+ ref?: Ref<HTMLInputElement>;
615
663
  prefix?: ReactNode;
616
664
  suffix?: ReactNode;
617
665
  /** 置 false 去掉前缀的灰块底色与分隔线,变成纯文本/裸图标。 */
@@ -622,7 +670,7 @@ export declare function Input({ id, label, description, error, prefix, suffix, p
622
670
  rounded?: boolean;
623
671
  wide?: boolean;
624
672
  size?: FieldSize;
625
- } & Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size' | 'prefix'>): JSX.Element;
673
+ } & (FieldShellProps | FieldBareProps) & Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size' | 'prefix'>): JSX.Element;
626
674
 
627
675
  export declare function Kbd({ meta, shift, alt, ctrl, small, children, }: {
628
676
  meta?: boolean;
@@ -784,7 +832,7 @@ export declare function ProjectBanner({ variant, message, cta }: {
784
832
  cta: string;
785
833
  }): JSX.Element;
786
834
 
787
- export declare function Radio(props: ControlOptionOwnProps & NativeInputProps): JSX.Element;
835
+ export declare function Radio({ ...props }: ControlOptionOwnProps & (FieldShellProps | FieldBareProps) & NativeInputProps): JSX.Element;
788
836
 
789
837
  export declare function RangeField({ layout, trigger, size, minValue, maxValue, pinnedTimezone, today, value, onChange, }: {
790
838
  layout?: PopoverLayout;
@@ -999,14 +1047,18 @@ export declare function Tabs({ tabs, ariaLabel, variant, }: {
999
1047
  variant?: 'default' | 'secondary';
1000
1048
  }): JSX.Element | null;
1001
1049
 
1002
- export declare function Textarea({ id, label, description, error, wide, size, className, ...rest }: {
1003
- id: string;
1004
- label: string;
1005
- description?: string;
1006
- error?: string;
1050
+ export declare function Textarea({ id, label, description, error, invalid, errorId, ref, wide, size, className, maxLength, onInput, ...rest }: {
1051
+ /** 缺省走 useId;显式传入时行为同现状(specimen/测试可寻址)。 */
1052
+ id?: string;
1053
+ /** 业务校验模型(主):置 aria-invalid;文案由业务层经 errorId 关联,组件不渲染。 */
1054
+ invalid?: boolean;
1055
+ /** 外部错误文案元素的 id,拼入 aria-describedby;文案由业务层渲染。 */
1056
+ errorId?: string;
1057
+ /** 指向原生 textarea(ref-as-prop,React 19),供校验失败聚焦、测量等场景使用。 */
1058
+ ref?: Ref<HTMLTextAreaElement>;
1007
1059
  wide?: boolean;
1008
1060
  size?: FieldSize;
1009
- } & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'>): JSX.Element;
1061
+ } & (FieldShellProps | FieldBareProps) & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'>): JSX.Element;
1010
1062
 
1011
1063
  export declare function TextWithCopyButton({ text, copyValue, successMessage, size, }: {
1012
1064
  text: string;
@@ -1043,8 +1095,13 @@ export declare function ToastProvider({ children }: {
1043
1095
 
1044
1096
  export declare type ToastTone = 'default' | 'success' | 'warning' | 'error';
1045
1097
 
1046
- export declare function Toggle({ defaultOn, disabled, size, onColor, label, description, labelSide, ariaLabel, }: {
1098
+ export declare function Toggle({ checked, defaultOn, onChange, disabled, size, onColor, label, description, labelSide, ariaLabel, }: {
1099
+ /** 受控值;提供后内部状态失效,显示值以外部回写的 checked 为准。 */
1100
+ checked?: boolean;
1101
+ /** 非受控模式的初始值;与 checked 同传时以 checked 为准。 */
1047
1102
  defaultOn?: boolean;
1103
+ /** 切换回调,参数为目标布尔值;受控与非受控模式都会触发。 */
1104
+ onChange?: (checked: boolean) => void;
1048
1105
  disabled?: boolean;
1049
1106
  size?: ToggleSize;
1050
1107
  onColor?: string;