1 | /*
|
2 | * Copyright 2020 Adobe. All rights reserved.
|
3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
4 | * you may not use this file except in compliance with the License. You may obtain a copy
|
5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6 | *
|
7 | * Unless required by applicable law or agreed to in writing, software distributed under
|
8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
9 | * OF ANY KIND, either express or implied. See the License for the specific language
|
10 | * governing permissions and limitations under the License.
|
11 | */
|
12 |
|
13 | import {ReactNode} from 'react';
|
14 |
|
15 | export type LabelPosition = 'top' | 'side';
|
16 | export type Alignment = 'start' | 'end';
|
17 | export type NecessityIndicator = 'icon' | 'label';
|
18 |
|
19 | export interface LabelableProps {
|
20 | /** The content to display as the label. */
|
21 | label?: ReactNode
|
22 | }
|
23 |
|
24 | export interface SpectrumLabelableProps extends LabelableProps {
|
25 | /**
|
26 | * The label's overall position relative to the element it is labeling.
|
27 | * @default 'top'
|
28 | */
|
29 | labelPosition?: LabelPosition,
|
30 | /**
|
31 | * The label's horizontal alignment relative to the element it is labeling.
|
32 | * @default 'start'
|
33 | */
|
34 | labelAlign?: Alignment,
|
35 | /**
|
36 | * Whether the required state should be shown as an icon or text.
|
37 | * @default 'icon'
|
38 | */
|
39 | necessityIndicator?: NecessityIndicator,
|
40 | /**
|
41 | * Whether the label is labeling a required field or group.
|
42 | */
|
43 | isRequired?: boolean,
|
44 | /**
|
45 | * A ContextualHelp element to place next to the label.
|
46 | */
|
47 | contextualHelp?: ReactNode
|
48 | }
|