|
| 1 | +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. |
| 2 | +// SPDX-License-Identifier: BSD-3-Clause-Clear |
| 3 | + |
| 4 | +import type {BooleanDataAttr} from "@qualcomm-ui/utils/attributes" |
| 5 | + |
| 6 | +import type {badgeClasses} from "./badge.classes" |
| 7 | + |
| 8 | +export type QdsBadgeType = "count" | "icon" | "text" | "status" |
| 9 | + |
| 10 | +export type QdsBadgeBasicSize = "sm" | "md" | "lg" |
| 11 | +export type QdsBadgeExtendedSize = "xs" | QdsBadgeBasicSize | "xl" |
| 12 | +export type QdsBadgeIconSize = "xxs" | QdsBadgeExtendedSize |
| 13 | + |
| 14 | +export type QdsBadgeSize = |
| 15 | + | QdsBadgeBasicSize |
| 16 | + | QdsBadgeExtendedSize |
| 17 | + | QdsBadgeIconSize |
| 18 | + |
| 19 | +export type QdsBadgeSemanticEmphasis = |
| 20 | + | "neutral" |
| 21 | + | "brand" |
| 22 | + | "info" |
| 23 | + | "success" |
| 24 | + | "warning" |
| 25 | + | "danger" |
| 26 | + |
| 27 | +export type QdsBadgeCategoryEmphasis = |
| 28 | + | "cat-1" |
| 29 | + | "cat-2" |
| 30 | + | "cat-3" |
| 31 | + | "cat-4" |
| 32 | + | "cat-5" |
| 33 | + | "cat-6" |
| 34 | + | "cat-7" |
| 35 | + | "cat-8" |
| 36 | + | "cat-9" |
| 37 | + | "cat-10" |
| 38 | + |
| 39 | +export type QdsBadgeCountVariant = |
| 40 | + | "neutral" |
| 41 | + | "neutral-outline" |
| 42 | + | "brand" |
| 43 | + | "brand-outline" |
| 44 | + | "info" |
| 45 | + | "success" |
| 46 | + | "warning" |
| 47 | + | "danger" |
| 48 | + | "persistent-black" |
| 49 | + | "persistent-white" |
| 50 | + |
| 51 | +export type QdsBadgeStatusEmphasis = QdsBadgeSemanticEmphasis |
| 52 | +export type QdsBadgeStatusVariant = "filled" | "outlined" |
| 53 | + |
| 54 | +export type QdsBadgeIconTextEmphasis = |
| 55 | + | QdsBadgeSemanticEmphasis |
| 56 | + | QdsBadgeCategoryEmphasis |
| 57 | +export type QdsBadgeIconTextVariant = "default" | "subtle" |
| 58 | + |
| 59 | +interface QdsBadgeBaseProps { |
| 60 | + /** |
| 61 | + * The badge disabled state. |
| 62 | + */ |
| 63 | + disabled?: boolean |
| 64 | +} |
| 65 | + |
| 66 | +export interface QdsBadgeCountProps extends QdsBadgeBaseProps { |
| 67 | + /** |
| 68 | + * The numeric count to display. |
| 69 | + */ |
| 70 | + count?: number |
| 71 | + |
| 72 | + /** |
| 73 | + * Maximum count to display. |
| 74 | + * @default 99 |
| 75 | + */ |
| 76 | + max?: number |
| 77 | + |
| 78 | + /** |
| 79 | + * Governs the size of the badge. |
| 80 | + * @default 'md' |
| 81 | + */ |
| 82 | + size?: QdsBadgeBasicSize |
| 83 | + |
| 84 | + /** |
| 85 | + * The badge type. |
| 86 | + */ |
| 87 | + type: "count" |
| 88 | + |
| 89 | + /** |
| 90 | + * Governs the color and style of the count badge. |
| 91 | + * @default 'neutral' |
| 92 | + */ |
| 93 | + variant?: QdsBadgeCountVariant |
| 94 | +} |
| 95 | + |
| 96 | +export interface QdsBadgeStatusProps extends QdsBadgeBaseProps { |
| 97 | + /** |
| 98 | + * Governs the color of the status badge. |
| 99 | + * @default 'neutral' |
| 100 | + */ |
| 101 | + emphasis?: QdsBadgeStatusEmphasis |
| 102 | + |
| 103 | + /** |
| 104 | + * Governs the size of the badge. |
| 105 | + * @default 'md' |
| 106 | + */ |
| 107 | + size?: QdsBadgeExtendedSize |
| 108 | + |
| 109 | + /** |
| 110 | + * The badge type. |
| 111 | + */ |
| 112 | + type: "status" |
| 113 | + |
| 114 | + /** |
| 115 | + * Governs the style of the status badge. |
| 116 | + * @default 'filled' |
| 117 | + */ |
| 118 | + variant?: QdsBadgeStatusVariant |
| 119 | +} |
| 120 | + |
| 121 | +export interface QdsBadgeIconProps extends QdsBadgeBaseProps { |
| 122 | + /** |
| 123 | + * Governs the color of the icon badge. |
| 124 | + * @default 'neutral' |
| 125 | + */ |
| 126 | + emphasis?: QdsBadgeIconTextEmphasis |
| 127 | + |
| 128 | + /** |
| 129 | + * Governs the size of the badge. |
| 130 | + * @default 'md' |
| 131 | + */ |
| 132 | + size?: QdsBadgeIconSize |
| 133 | + |
| 134 | + /** |
| 135 | + * The badge type. |
| 136 | + */ |
| 137 | + type: "icon" |
| 138 | + |
| 139 | + /** |
| 140 | + * Governs the style of the icon badge. |
| 141 | + * @default 'default' |
| 142 | + */ |
| 143 | + variant?: QdsBadgeIconTextVariant |
| 144 | +} |
| 145 | + |
| 146 | +export interface QdsBadgeTextProps extends QdsBadgeBaseProps { |
| 147 | + /** |
| 148 | + * Governs the color of the text badge. |
| 149 | + * @default 'neutral' |
| 150 | + */ |
| 151 | + emphasis?: QdsBadgeIconTextEmphasis |
| 152 | + |
| 153 | + /** |
| 154 | + * Governs the size of the badge. |
| 155 | + * @default 'md' |
| 156 | + */ |
| 157 | + size?: QdsBadgeBasicSize |
| 158 | + |
| 159 | + /** |
| 160 | + * The badge type. |
| 161 | + */ |
| 162 | + type?: "text" |
| 163 | + |
| 164 | + /** |
| 165 | + * Governs the style of the text badge. |
| 166 | + * @default 'default' |
| 167 | + */ |
| 168 | + variant?: QdsBadgeIconTextVariant |
| 169 | +} |
| 170 | + |
| 171 | +export type QdsBadgeApiProps = |
| 172 | + | QdsBadgeCountProps |
| 173 | + | QdsBadgeStatusProps |
| 174 | + | QdsBadgeIconProps |
| 175 | + | QdsBadgeTextProps |
| 176 | + |
| 177 | +type BadgeClasses = typeof badgeClasses |
| 178 | + |
| 179 | +export interface QdsBadgeRootBindings { |
| 180 | + className: BadgeClasses["root"] |
| 181 | + "data-disabled": BooleanDataAttr |
| 182 | + "data-emphasis"?: string |
| 183 | + "data-overflow": BooleanDataAttr |
| 184 | + "data-part": "root" |
| 185 | + "data-scope": "badge" |
| 186 | + "data-size": QdsBadgeSize |
| 187 | + "data-type": QdsBadgeType |
| 188 | + "data-variant"?: string |
| 189 | +} |
| 190 | + |
| 191 | +export interface QdsBadgeIconBindings { |
| 192 | + className: BadgeClasses["icon"] |
| 193 | + "data-part": "icon" |
| 194 | + "data-scope": "badge" |
| 195 | + "data-size": QdsBadgeSize |
| 196 | +} |
| 197 | + |
| 198 | +export interface QdsBadgeApi { |
| 199 | + getDisplayCount(): number | string | null |
| 200 | + getIconBindings(): QdsBadgeIconBindings |
| 201 | + getRootBindings(): QdsBadgeRootBindings |
| 202 | + type: QdsBadgeType |
| 203 | +} |
0 commit comments