@latty-ds/web 0.2.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.
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/custom-elements.json +8785 -0
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.js +35 -0
- package/dist/base/themeable-element.d.ts +20 -0
- package/dist/components/accordion/accordion.d.ts +82 -0
- package/dist/components/accordion/accordion.styles.d.ts +1 -0
- package/dist/components/accordion/accordion.types.d.ts +10 -0
- package/dist/components/accordion/index.d.ts +8 -0
- package/dist/components/accordion/index.js +468 -0
- package/dist/components/alert/alert.d.ts +51 -0
- package/dist/components/alert/alert.styles.d.ts +1 -0
- package/dist/components/alert/alert.types.d.ts +2 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +746 -0
- package/dist/components/avatar/avatar.d.ts +27 -0
- package/dist/components/avatar/avatar.styles.d.ts +1 -0
- package/dist/components/avatar/avatar.types.d.ts +3 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +222 -0
- package/dist/components/badge/badge.d.ts +29 -0
- package/dist/components/badge/badge.styles.d.ts +1 -0
- package/dist/components/badge/badge.types.d.ts +3 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +277 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +53 -0
- package/dist/components/breadcrumb/breadcrumb.styles.d.ts +2 -0
- package/dist/components/breadcrumb/breadcrumb.types.d.ts +1 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +166 -0
- package/dist/components/button/button.d.ts +111 -0
- package/dist/components/button/button.styles.d.ts +1 -0
- package/dist/components/button/button.types.d.ts +38 -0
- package/dist/components/button/index.d.ts +8 -0
- package/dist/components/button/index.js +466 -0
- package/dist/components/calendar/calendar.d.ts +84 -0
- package/dist/components/calendar/calendar.styles.d.ts +1 -0
- package/dist/components/calendar/calendar.types.d.ts +15 -0
- package/dist/components/calendar/index.d.ts +1 -0
- package/dist/components/calendar/index.js +958 -0
- package/dist/components/checkbox/checkbox.d.ts +113 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.types.d.ts +21 -0
- package/dist/components/checkbox/index.d.ts +8 -0
- package/dist/components/checkbox/index.js +320 -0
- package/dist/components/chip/chip.d.ts +35 -0
- package/dist/components/chip/chip.styles.d.ts +1 -0
- package/dist/components/chip/chip.types.d.ts +3 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/chip/index.js +282 -0
- package/dist/components/color-input/color-input.d.ts +55 -0
- package/dist/components/color-input/color-input.styles.d.ts +1 -0
- package/dist/components/color-input/color-input.types.d.ts +2 -0
- package/dist/components/color-input/index.d.ts +1 -0
- package/dist/components/color-input/index.js +489 -0
- package/dist/components/combobox/combobox.d.ts +59 -0
- package/dist/components/combobox/combobox.styles.d.ts +1 -0
- package/dist/components/combobox/combobox.types.d.ts +7 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1988 -0
- package/dist/components/date-input/date-input.d.ts +66 -0
- package/dist/components/date-input/date-input.styles.d.ts +1 -0
- package/dist/components/date-input/date-input.types.d.ts +3 -0
- package/dist/components/date-input/index.d.ts +2 -0
- package/dist/components/date-input/index.js +2863 -0
- package/dist/components/datepicker/datepicker.d.ts +52 -0
- package/dist/components/datepicker/datepicker.styles.d.ts +1 -0
- package/dist/components/datepicker/datepicker.types.d.ts +3 -0
- package/dist/components/datepicker/index.d.ts +2 -0
- package/dist/components/datepicker/index.js +416 -0
- package/dist/components/dialog/dialog.d.ts +114 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.types.d.ts +11 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +920 -0
- package/dist/components/divider/divider.d.ts +35 -0
- package/dist/components/divider/divider.styles.d.ts +1 -0
- package/dist/components/divider/divider.types.d.ts +2 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +149 -0
- package/dist/components/dropdown/dropdown-item.d.ts +24 -0
- package/dist/components/dropdown/dropdown-item.styles.d.ts +1 -0
- package/dist/components/dropdown/dropdown.d.ts +30 -0
- package/dist/components/dropdown/dropdown.styles.d.ts +1 -0
- package/dist/components/dropdown/dropdown.types.d.ts +1 -0
- package/dist/components/dropdown/index.d.ts +3 -0
- package/dist/components/dropdown/index.js +1791 -0
- package/dist/components/header/header.d.ts +19 -0
- package/dist/components/header/header.styles.d.ts +1 -0
- package/dist/components/header/header.types.d.ts +1 -0
- package/dist/components/header/index.d.ts +2 -0
- package/dist/components/header/index.js +104 -0
- package/dist/components/icon-button/icon-button.d.ts +52 -0
- package/dist/components/icon-button/icon-button.styles.d.ts +1 -0
- package/dist/components/icon-button/icon-button.types.d.ts +8 -0
- package/dist/components/icon-button/index.d.ts +1 -0
- package/dist/components/icon-button/index.js +342 -0
- package/dist/components/image/image.d.ts +26 -0
- package/dist/components/image/image.styles.d.ts +1 -0
- package/dist/components/image/image.types.d.ts +0 -0
- package/dist/components/image/index.d.ts +1 -0
- package/dist/components/image/index.js +105 -0
- package/dist/components/link/index.d.ts +1 -0
- package/dist/components/link/index.js +108 -0
- package/dist/components/link/link.d.ts +22 -0
- package/dist/components/link/link.styles.d.ts +1 -0
- package/dist/components/link/link.types.d.ts +1 -0
- package/dist/components/list/index.d.ts +9 -0
- package/dist/components/list/index.js +254 -0
- package/dist/components/list/list-item.d.ts +41 -0
- package/dist/components/list/list-item.styles.d.ts +1 -0
- package/dist/components/list/list.d.ts +85 -0
- package/dist/components/list/list.styles.d.ts +1 -0
- package/dist/components/list/list.types.d.ts +16 -0
- package/dist/components/nav/index.d.ts +3 -0
- package/dist/components/nav/index.js +345 -0
- package/dist/components/nav/nav-item.d.ts +73 -0
- package/dist/components/nav/nav.d.ts +49 -0
- package/dist/components/nav/nav.styles.d.ts +2 -0
- package/dist/components/nav/nav.types.d.ts +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +210 -0
- package/dist/components/pagination/pagination.d.ts +34 -0
- package/dist/components/pagination/pagination.styles.d.ts +1 -0
- package/dist/components/pagination/pagination.types.d.ts +1 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +167 -0
- package/dist/components/progress/progress.d.ts +44 -0
- package/dist/components/progress/progress.styles.d.ts +1 -0
- package/dist/components/progress/progress.types.d.ts +2 -0
- package/dist/components/radio/index.d.ts +8 -0
- package/dist/components/radio/index.js +294 -0
- package/dist/components/radio/radio.d.ts +96 -0
- package/dist/components/radio/radio.styles.d.ts +1 -0
- package/dist/components/radio/radio.types.d.ts +21 -0
- package/dist/components/radio-group/index.d.ts +8 -0
- package/dist/components/radio-group/index.js +384 -0
- package/dist/components/radio-group/radio-group.d.ts +100 -0
- package/dist/components/radio-group/radio-group.styles.d.ts +1 -0
- package/dist/components/radio-group/radio-group.types.d.ts +8 -0
- package/dist/components/select/index.d.ts +8 -0
- package/dist/components/select/index.js +2123 -0
- package/dist/components/select/select.d.ts +129 -0
- package/dist/components/select/select.styles.d.ts +1 -0
- package/dist/components/select/select.types.d.ts +37 -0
- package/dist/components/shared/backdrop.styles.d.ts +1 -0
- package/dist/components/shared/floating.d.ts +10 -0
- package/dist/components/sidepanel/index.d.ts +1 -0
- package/dist/components/sidepanel/index.js +768 -0
- package/dist/components/sidepanel/sidepanel.d.ts +48 -0
- package/dist/components/sidepanel/sidepanel.styles.d.ts +1 -0
- package/dist/components/sidepanel/sidepanel.types.d.ts +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +129 -0
- package/dist/components/skeleton/skeleton.d.ts +39 -0
- package/dist/components/skeleton/skeleton.styles.d.ts +1 -0
- package/dist/components/skeleton/skeleton.types.d.ts +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +635 -0
- package/dist/components/slider/slider.d.ts +33 -0
- package/dist/components/slider/slider.styles.d.ts +1 -0
- package/dist/components/slider/slider.types.d.ts +1 -0
- package/dist/components/snackbar/index.d.ts +2 -0
- package/dist/components/snackbar/index.js +358 -0
- package/dist/components/snackbar/snackbar.d.ts +63 -0
- package/dist/components/snackbar/snackbar.styles.d.ts +1 -0
- package/dist/components/snackbar/snackbar.types.d.ts +1 -0
- package/dist/components/spinner/index.d.ts +8 -0
- package/dist/components/spinner/index.js +131 -0
- package/dist/components/spinner/spineer.styles.d.ts +1 -0
- package/dist/components/spinner/spinner.d.ts +52 -0
- package/dist/components/spinner/spinner.types.d.ts +18 -0
- package/dist/components/surface/index.d.ts +8 -0
- package/dist/components/surface/index.js +128 -0
- package/dist/components/surface/surface.d.ts +48 -0
- package/dist/components/surface/surface.styles.d.ts +1 -0
- package/dist/components/surface/surface.types.d.ts +20 -0
- package/dist/components/switch/index.d.ts +8 -0
- package/dist/components/switch/index.js +293 -0
- package/dist/components/switch/switch.d.ts +90 -0
- package/dist/components/switch/switch.styles.d.ts +1 -0
- package/dist/components/switch/switch.types.d.ts +21 -0
- package/dist/components/tab/index.d.ts +9 -0
- package/dist/components/tab/index.js +252 -0
- package/dist/components/tab/tab-panel.d.ts +28 -0
- package/dist/components/tab/tab-panel.styles.d.ts +1 -0
- package/dist/components/tab/tab.d.ts +59 -0
- package/dist/components/tab/tab.styles.d.ts +1 -0
- package/dist/components/tab/tab.types.d.ts +7 -0
- package/dist/components/tab-group/index.d.ts +8 -0
- package/dist/components/tab-group/index.js +441 -0
- package/dist/components/tab-group/tab-group.d.ts +99 -0
- package/dist/components/tab-group/tab-group.styles.d.ts +1 -0
- package/dist/components/tab-group/tab-group.types.d.ts +11 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +582 -0
- package/dist/components/table/table.d.ts +160 -0
- package/dist/components/table/table.styles.d.ts +1 -0
- package/dist/components/table/table.types.d.ts +106 -0
- package/dist/components/text/index.d.ts +1 -0
- package/dist/components/text/index.js +207 -0
- package/dist/components/text/text.d.ts +32 -0
- package/dist/components/text/text.styles.d.ts +1 -0
- package/dist/components/text/text.types.d.ts +2 -0
- package/dist/components/textfield/index.d.ts +8 -0
- package/dist/components/textfield/index.js +718 -0
- package/dist/components/textfield/textfield.d.ts +168 -0
- package/dist/components/textfield/textfield.styles.d.ts +1 -0
- package/dist/components/textfield/textfield.types.d.ts +40 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +379 -0
- package/dist/components/tooltip/tooltip.d.ts +42 -0
- package/dist/components/tooltip/tooltip.styles.d.ts +1 -0
- package/dist/components/tooltip/tooltip.types.d.ts +1 -0
- package/dist/css/font-face.css +22 -0
- package/dist/css/latty.css +57 -0
- package/dist/fonts/HankenGrotesk-Variable.woff2 +0 -0
- package/dist/fonts/HankenGrotesk-VariableItalic.woff2 +0 -0
- package/dist/index.cjs +12739 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +11406 -0
- package/dist/manifest.json +2396 -0
- package/dist/utils/click-outside.d.ts +22 -0
- package/dist/utils/color.d.ts +14 -0
- package/dist/utils/dispatch.d.ts +18 -0
- package/dist/utils/index.d.ts +3 -0
- package/package.json +231 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { ThemeableElement } from '../../base';
|
|
3
|
+
import { HelperText, TextfieldSize, TextfieldType, TextfieldVariant } from './textfield.types';
|
|
4
|
+
import '@latty-ds/icons';
|
|
5
|
+
import '../text/text';
|
|
6
|
+
/**
|
|
7
|
+
* A customizable text input component with support for multiple variants, sizes, and input types.
|
|
8
|
+
* Supports both single-line inputs and multi-line textareas.
|
|
9
|
+
*
|
|
10
|
+
* @element lt-textfield
|
|
11
|
+
*
|
|
12
|
+
* @fires {CustomEvent<{value: string}>} input - Dispatched when the input value changes
|
|
13
|
+
* @fires {CustomEvent<{value: string}>} change - Dispatched when the input loses focus after a value change
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```html
|
|
17
|
+
* <lt-textfield
|
|
18
|
+
* label="Email"
|
|
19
|
+
* type="email"
|
|
20
|
+
* placeholder="Enter your email"
|
|
21
|
+
* required
|
|
22
|
+
* ></lt-textfield>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```html
|
|
27
|
+
* <lt-textfield
|
|
28
|
+
* variant="error"
|
|
29
|
+
* label="Password"
|
|
30
|
+
* type="password"
|
|
31
|
+
* helper-text="Password must be at least 8 characters"
|
|
32
|
+
* ></lt-textfield>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```html
|
|
37
|
+
* <lt-textfield
|
|
38
|
+
* type="multiline"
|
|
39
|
+
* label="Description"
|
|
40
|
+
* placeholder="Enter description..."
|
|
41
|
+
* rows="5"
|
|
42
|
+
* ></lt-textfield>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class Textfield extends ThemeableElement {
|
|
46
|
+
static styles: import("lit").CSSResult;
|
|
47
|
+
/**
|
|
48
|
+
* Visual variant that determines styling and automatic end icon.
|
|
49
|
+
* @default 'default'
|
|
50
|
+
*/
|
|
51
|
+
variant: TextfieldVariant;
|
|
52
|
+
/**
|
|
53
|
+
* Size of the textfield (affects height, font size, and padding).
|
|
54
|
+
* @default 'md'
|
|
55
|
+
*/
|
|
56
|
+
size: TextfieldSize;
|
|
57
|
+
/**
|
|
58
|
+
* HTML input type. Password type includes automatic visibility toggle.
|
|
59
|
+
* @default 'text'
|
|
60
|
+
*/
|
|
61
|
+
type: TextfieldType;
|
|
62
|
+
/**
|
|
63
|
+
* Current value of the input.
|
|
64
|
+
* @default ''
|
|
65
|
+
*/
|
|
66
|
+
value: string;
|
|
67
|
+
/**
|
|
68
|
+
* Placeholder text shown when input is empty.
|
|
69
|
+
* @default ''
|
|
70
|
+
*/
|
|
71
|
+
placeholder: string;
|
|
72
|
+
/**
|
|
73
|
+
* Label text displayed above the input.
|
|
74
|
+
* @default ''
|
|
75
|
+
*/
|
|
76
|
+
label: string;
|
|
77
|
+
/**
|
|
78
|
+
* Helper text displayed below the input. Can be a static string or a function
|
|
79
|
+
* that receives the current error state and returns the string to display.
|
|
80
|
+
* Color changes based on variant or auto-error state.
|
|
81
|
+
* @default ''
|
|
82
|
+
*/
|
|
83
|
+
helperText: HelperText;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the input is disabled.
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
88
|
+
disabled: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the input is required. Shows asterisk in label when true.
|
|
91
|
+
* @default false
|
|
92
|
+
*/
|
|
93
|
+
required: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the input is readonly.
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
readonly: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Icon name to display at the start of the input.
|
|
101
|
+
* @default ''
|
|
102
|
+
*/
|
|
103
|
+
iconStart: string;
|
|
104
|
+
/**
|
|
105
|
+
* Number of visible text lines for multiline type (textarea).
|
|
106
|
+
* Only applies when type="multiline".
|
|
107
|
+
* @default 3
|
|
108
|
+
*/
|
|
109
|
+
rows: number;
|
|
110
|
+
/**
|
|
111
|
+
* For type="number": minimum allowed value.
|
|
112
|
+
* For all other types: minimum character length.
|
|
113
|
+
* @default null
|
|
114
|
+
*/
|
|
115
|
+
min: number | null;
|
|
116
|
+
/**
|
|
117
|
+
* For type="number": maximum allowed value.
|
|
118
|
+
* For all other types: maximum character length.
|
|
119
|
+
* @default null
|
|
120
|
+
*/
|
|
121
|
+
max: number | null;
|
|
122
|
+
/**
|
|
123
|
+
* Renders the label in small caps with wider letter spacing.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
uppercase: boolean;
|
|
127
|
+
private isPasswordVisible;
|
|
128
|
+
private _touched;
|
|
129
|
+
private _autoError;
|
|
130
|
+
private _onBlur;
|
|
131
|
+
/**
|
|
132
|
+
* Handles input events from the native input or textarea element.
|
|
133
|
+
* Updates the component's value property and dispatches a custom input event.
|
|
134
|
+
*
|
|
135
|
+
* @param e - The native input event
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
private _validate;
|
|
139
|
+
private handleInput;
|
|
140
|
+
/**
|
|
141
|
+
* Handles change events from the native input or textarea element.
|
|
142
|
+
* Updates the component's value property and dispatches a custom change event.
|
|
143
|
+
*
|
|
144
|
+
* @param e - The native change event
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
private handleChange;
|
|
148
|
+
/**
|
|
149
|
+
* Toggles password visibility for password-type inputs.
|
|
150
|
+
* Switches between showing plain text and masked password.
|
|
151
|
+
*
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
private togglePasswordVisibility;
|
|
155
|
+
/**
|
|
156
|
+
* Determines the appropriate end icon based on input type and variant.
|
|
157
|
+
*
|
|
158
|
+
* Password inputs show eye/eye-off toggle icon.
|
|
159
|
+
* Non-default variants show their respective state icons.
|
|
160
|
+
* Default variant shows no end icon.
|
|
161
|
+
*
|
|
162
|
+
* @returns The icon name to display, or empty string if no icon should be shown
|
|
163
|
+
* @private
|
|
164
|
+
*/
|
|
165
|
+
private getEndIconName;
|
|
166
|
+
updated(changed: PropertyValues): void;
|
|
167
|
+
render(): import("lit").TemplateResult<1>;
|
|
168
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const textfieldStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual variant of the textfield component.
|
|
3
|
+
* Determines the border color, focus state, and automatic end icon.
|
|
4
|
+
*
|
|
5
|
+
* - `default`: Standard neutral state with no end icon
|
|
6
|
+
* - `success`: Green styling with check-circle icon
|
|
7
|
+
* - `warning`: Yellow/orange styling with warning-triangle icon
|
|
8
|
+
* - `error`: Red styling with xmark-circle icon
|
|
9
|
+
*/
|
|
10
|
+
export type TextfieldVariant = 'default' | 'success' | 'warning' | 'error';
|
|
11
|
+
/**
|
|
12
|
+
* Size variant of the textfield component.
|
|
13
|
+
* Affects height, font size, and padding.
|
|
14
|
+
*
|
|
15
|
+
* - `sm`: 32px height, 0.875rem font size
|
|
16
|
+
* - `md`: 40px height, 1rem font size
|
|
17
|
+
* - `lg`: 48px height, 1.0625rem font size
|
|
18
|
+
*/
|
|
19
|
+
export type TextfieldSize = 'sm' | 'md' | 'lg';
|
|
20
|
+
/**
|
|
21
|
+
* HTML input type for the textfield.
|
|
22
|
+
* Password type includes automatic visibility toggle with eye icon.
|
|
23
|
+
* Multiline type renders a textarea element instead of input.
|
|
24
|
+
*
|
|
25
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types
|
|
26
|
+
*/
|
|
27
|
+
export type TextfieldType = 'text' | 'email' | 'password' | 'tel' | 'url' | 'number' | 'multiline';
|
|
28
|
+
/**
|
|
29
|
+
* Helper text value — either a static string or a function that receives the
|
|
30
|
+
* current error state and returns the string to display.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Static
|
|
34
|
+
* helperText="Minimum 8 characters"
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Dynamic — different message when invalid
|
|
38
|
+
* helperText={(error) => error ? 'Enter a valid email' : 'We\'ll never share your email'}
|
|
39
|
+
*/
|
|
40
|
+
export type HelperText = string | ((error: boolean) => string);
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/components/tooltip/tooltip.ts
|
|
13
|
+
import { html as html2 } from "lit";
|
|
14
|
+
|
|
15
|
+
// src/base/themeable-element.ts
|
|
16
|
+
import { LitElement } from "lit";
|
|
17
|
+
import { property } from "lit/decorators.js";
|
|
18
|
+
var ThemeableElement = class extends LitElement {
|
|
19
|
+
willUpdate(changed) {
|
|
20
|
+
super.willUpdate(changed);
|
|
21
|
+
if (changed.has("theme")) {
|
|
22
|
+
this._syncThemeAttribute();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
_syncThemeAttribute() {
|
|
26
|
+
if (this.theme === "dark" || this.theme === "light") {
|
|
27
|
+
this.setAttribute("data-theme", this.theme);
|
|
28
|
+
} else {
|
|
29
|
+
this.removeAttribute("data-theme");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__decorateClass([
|
|
34
|
+
property({ reflect: true })
|
|
35
|
+
], ThemeableElement.prototype, "theme", 2);
|
|
36
|
+
|
|
37
|
+
// src/components/tooltip/tooltip.ts
|
|
38
|
+
import { customElement as customElement2, property as property3, query } from "lit/decorators.js";
|
|
39
|
+
import { styleMap } from "lit/directives/style-map.js";
|
|
40
|
+
|
|
41
|
+
// src/components/tooltip/tooltip.styles.ts
|
|
42
|
+
import { css } from "lit";
|
|
43
|
+
var tooltipStyles = css`
|
|
44
|
+
:host {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
position: relative;
|
|
47
|
+
--lt-tooltip-offset: 8px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.tooltip {
|
|
51
|
+
background: var(--lt-tooltip-bg, var(--lt-bg-inverse));
|
|
52
|
+
border-radius: 4px;
|
|
53
|
+
color: var(--lt-tooltip-color, var(--lt-text-inverse));
|
|
54
|
+
opacity: 0;
|
|
55
|
+
padding: var(--lt-spacing-1) var(--lt-spacing-2);
|
|
56
|
+
pointer-events: none;
|
|
57
|
+
position: absolute;
|
|
58
|
+
transition:
|
|
59
|
+
opacity 150ms ease,
|
|
60
|
+
visibility 150ms ease;
|
|
61
|
+
visibility: hidden;
|
|
62
|
+
white-space: nowrap;
|
|
63
|
+
z-index: 1000;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.arrow {
|
|
67
|
+
border: 5px solid transparent;
|
|
68
|
+
height: 0;
|
|
69
|
+
position: absolute;
|
|
70
|
+
width: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:host(:hover) .tooltip,
|
|
74
|
+
:host(:focus-within) .tooltip {
|
|
75
|
+
opacity: 1;
|
|
76
|
+
visibility: visible;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
:host([disabled]) .tooltip,
|
|
80
|
+
:host(:not([content])) .tooltip,
|
|
81
|
+
:host([content='']) .tooltip {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ── Top (default) ──────────────────────────── */
|
|
86
|
+
|
|
87
|
+
:host(:not([placement])) .tooltip,
|
|
88
|
+
:host([placement='top']) .tooltip {
|
|
89
|
+
bottom: calc(100% + var(--lt-tooltip-offset));
|
|
90
|
+
left: 50%;
|
|
91
|
+
transform: translateX(-50%);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:host(:not([placement])) .arrow,
|
|
95
|
+
:host([placement='top']) .arrow {
|
|
96
|
+
border-top-color: var(--lt-tooltip-bg, var(--lt-color-neutral-900));
|
|
97
|
+
left: 50%;
|
|
98
|
+
top: 100%;
|
|
99
|
+
transform: translateX(-50%);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* ── Bottom ─────────────────────────────────── */
|
|
103
|
+
|
|
104
|
+
:host([placement='bottom']) .tooltip {
|
|
105
|
+
left: 50%;
|
|
106
|
+
top: calc(100% + var(--lt-tooltip-offset));
|
|
107
|
+
transform: translateX(-50%);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:host([placement='bottom']) .arrow {
|
|
111
|
+
border-bottom-color: var(--lt-tooltip-bg, var(--lt-color-neutral-900));
|
|
112
|
+
bottom: 100%;
|
|
113
|
+
left: 50%;
|
|
114
|
+
transform: translateX(-50%);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* ── Left ───────────────────────────────────── */
|
|
118
|
+
|
|
119
|
+
:host([placement='left']) .tooltip {
|
|
120
|
+
right: calc(100% + var(--lt-tooltip-offset));
|
|
121
|
+
top: 50%;
|
|
122
|
+
transform: translateY(-50%);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:host([placement='left']) .arrow {
|
|
126
|
+
border-left-color: var(--lt-tooltip-bg, var(--lt-color-neutral-900));
|
|
127
|
+
left: 100%;
|
|
128
|
+
top: 50%;
|
|
129
|
+
transform: translateY(-50%);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* ── Right ──────────────────────────────────── */
|
|
133
|
+
|
|
134
|
+
:host([placement='right']) .tooltip {
|
|
135
|
+
left: calc(100% + var(--lt-tooltip-offset));
|
|
136
|
+
top: 50%;
|
|
137
|
+
transform: translateY(-50%);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
:host([placement='right']) .arrow {
|
|
141
|
+
border-right-color: var(--lt-tooltip-bg, var(--lt-color-neutral-900));
|
|
142
|
+
right: 100%;
|
|
143
|
+
top: 50%;
|
|
144
|
+
transform: translateY(-50%);
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
// src/utils/color.ts
|
|
149
|
+
var resolveColorValue = (value) => value.startsWith("--") ? `var(${value})` : value;
|
|
150
|
+
|
|
151
|
+
// src/components/text/text.ts
|
|
152
|
+
import { customElement, property as property2 } from "lit/decorators.js";
|
|
153
|
+
import { html, unsafeStatic } from "lit/static-html.js";
|
|
154
|
+
|
|
155
|
+
// src/components/text/text.styles.ts
|
|
156
|
+
import { css as css2 } from "lit";
|
|
157
|
+
var textStyles = css2`
|
|
158
|
+
:host {
|
|
159
|
+
display: block;
|
|
160
|
+
color: inherit;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Inline variants sit in text flow */
|
|
164
|
+
:host([variant='caption']),
|
|
165
|
+
:host([variant='overline']),
|
|
166
|
+
:host([variant='label']) {
|
|
167
|
+
display: inline;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
[part='base'] {
|
|
171
|
+
margin: 0;
|
|
172
|
+
color: inherit;
|
|
173
|
+
font-family: var(--lt-typography-fontfamily);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* ── Display ─────────────────────────────────────────────────────────── */
|
|
177
|
+
|
|
178
|
+
:host([variant='display-2xl']) [part='base'] {
|
|
179
|
+
font-size: clamp(2.5rem, 6vw, 4.5rem);
|
|
180
|
+
font-weight: var(--lt-text-weight, 200);
|
|
181
|
+
line-height: 1.1;
|
|
182
|
+
letter-spacing: -0.02em;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
:host([variant='display-xl']) [part='base'] {
|
|
186
|
+
font-size: clamp(2rem, 5vw, 3.75rem);
|
|
187
|
+
font-weight: var(--lt-text-weight, 200);
|
|
188
|
+
line-height: 1.1;
|
|
189
|
+
letter-spacing: -0.02em;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
:host([variant='display-lg']) [part='base'] {
|
|
193
|
+
font-size: clamp(2rem, 4vw, 3rem);
|
|
194
|
+
font-weight: var(--lt-text-weight, 200);
|
|
195
|
+
line-height: 1.15;
|
|
196
|
+
letter-spacing: -0.01em;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* ── Headings ─────────────────────────────────────────────────────────── */
|
|
200
|
+
|
|
201
|
+
:host([variant='h1']) [part='base'] {
|
|
202
|
+
font-size: clamp(1.75rem, 2.5vw + 0.75rem, 2.5rem);
|
|
203
|
+
font-weight: var(--lt-text-weight, 600);
|
|
204
|
+
line-height: 1.2;
|
|
205
|
+
letter-spacing: -0.02em;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
:host([variant='h2']) [part='base'] {
|
|
209
|
+
font-size: clamp(1.5rem, 2vw + 0.5rem, 2rem);
|
|
210
|
+
font-weight: var(--lt-text-weight, 600);
|
|
211
|
+
line-height: 1.25;
|
|
212
|
+
letter-spacing: -0.01em;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
:host([variant='h3']) [part='base'] {
|
|
216
|
+
font-size: clamp(1.25rem, 1.5vw + 0.5rem, 1.5rem);
|
|
217
|
+
font-weight: var(--lt-text-weight, 600);
|
|
218
|
+
line-height: 1.3;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
:host([variant='h4']) [part='base'] {
|
|
222
|
+
font-size: 1.25rem;
|
|
223
|
+
font-weight: var(--lt-text-weight, 600);
|
|
224
|
+
line-height: 1.35;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
:host([variant='h5']) [part='base'] {
|
|
228
|
+
font-size: 1.125rem;
|
|
229
|
+
font-weight: var(--lt-text-weight, 600);
|
|
230
|
+
line-height: 1.4;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
:host([variant='h6']) [part='base'] {
|
|
234
|
+
font-size: 1rem;
|
|
235
|
+
font-weight: var(--lt-text-weight, 600);
|
|
236
|
+
line-height: 1.4;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* ── Body ─────────────────────────────────────────────────────────────── */
|
|
240
|
+
|
|
241
|
+
:host([variant='lead']) [part='base'] {
|
|
242
|
+
font-size: 1.25rem;
|
|
243
|
+
font-weight: var(--lt-text-weight, 400);
|
|
244
|
+
line-height: 1.6;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
:host([variant='body']) [part='base'],
|
|
248
|
+
:host(:not([variant])) [part='base'] {
|
|
249
|
+
font-size: 1rem;
|
|
250
|
+
font-weight: var(--lt-text-weight, 400);
|
|
251
|
+
line-height: 1.6;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
:host([variant='body-sm']) [part='base'] {
|
|
255
|
+
font-size: 0.875rem;
|
|
256
|
+
font-weight: var(--lt-text-weight, 400);
|
|
257
|
+
line-height: 1.6;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* ── Inline ───────────────────────────────────────────────────────────── */
|
|
261
|
+
|
|
262
|
+
:host([variant='caption']) [part='base'] {
|
|
263
|
+
font-size: 0.75rem;
|
|
264
|
+
font-weight: var(--lt-text-weight, 400);
|
|
265
|
+
line-height: 1.5;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
:host([variant='overline']) [part='base'] {
|
|
269
|
+
font-size: 0.6875rem;
|
|
270
|
+
font-weight: var(--lt-text-weight, 600);
|
|
271
|
+
line-height: 1.2;
|
|
272
|
+
letter-spacing: 0.08em;
|
|
273
|
+
text-transform: uppercase;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
:host([variant='label']) [part='base'] {
|
|
277
|
+
font-size: 0.875rem;
|
|
278
|
+
font-weight: var(--lt-text-weight, 600);
|
|
279
|
+
line-height: 1.4;
|
|
280
|
+
}
|
|
281
|
+
`;
|
|
282
|
+
|
|
283
|
+
// src/components/text/text.ts
|
|
284
|
+
var VARIANT_TAG = {
|
|
285
|
+
"display-2xl": "p",
|
|
286
|
+
"display-xl": "p",
|
|
287
|
+
"display-lg": "p",
|
|
288
|
+
h1: "h1",
|
|
289
|
+
h2: "h2",
|
|
290
|
+
h3: "h3",
|
|
291
|
+
h4: "h4",
|
|
292
|
+
h5: "h5",
|
|
293
|
+
h6: "h6",
|
|
294
|
+
lead: "p",
|
|
295
|
+
body: "p",
|
|
296
|
+
"body-sm": "p",
|
|
297
|
+
caption: "span",
|
|
298
|
+
overline: "span",
|
|
299
|
+
label: "span"
|
|
300
|
+
};
|
|
301
|
+
var Text = class extends ThemeableElement {
|
|
302
|
+
constructor() {
|
|
303
|
+
super(...arguments);
|
|
304
|
+
this.variant = "body";
|
|
305
|
+
this.as = "";
|
|
306
|
+
}
|
|
307
|
+
render() {
|
|
308
|
+
const tag = unsafeStatic(this.as || VARIANT_TAG[this.variant] || "p");
|
|
309
|
+
return html`<${tag} part="base"><slot></slot></${tag}>`;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
Text.styles = textStyles;
|
|
313
|
+
__decorateClass([
|
|
314
|
+
property2({ reflect: true })
|
|
315
|
+
], Text.prototype, "variant", 2);
|
|
316
|
+
__decorateClass([
|
|
317
|
+
property2({ reflect: true })
|
|
318
|
+
], Text.prototype, "as", 2);
|
|
319
|
+
Text = __decorateClass([
|
|
320
|
+
customElement("lt-text")
|
|
321
|
+
], Text);
|
|
322
|
+
|
|
323
|
+
// src/components/tooltip/tooltip.ts
|
|
324
|
+
var _tooltipIdCounter = 0;
|
|
325
|
+
var Tooltip = class extends ThemeableElement {
|
|
326
|
+
constructor() {
|
|
327
|
+
super(...arguments);
|
|
328
|
+
this._tooltipId = `lt-tooltip-${++_tooltipIdCounter}`;
|
|
329
|
+
this.content = "";
|
|
330
|
+
this.placement = "top";
|
|
331
|
+
this.disabled = false;
|
|
332
|
+
this.background = "";
|
|
333
|
+
this.color = "";
|
|
334
|
+
}
|
|
335
|
+
firstUpdated() {
|
|
336
|
+
const trigger = this._slot?.assignedElements()[0];
|
|
337
|
+
if (trigger) {
|
|
338
|
+
trigger.setAttribute("aria-describedby", this._tooltipId);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
render() {
|
|
342
|
+
const tooltipStyle = styleMap({
|
|
343
|
+
...this.background ? { "--_tooltip-bg": resolveColorValue(this.background) } : {},
|
|
344
|
+
...this.color ? { "--_tooltip-color": resolveColorValue(this.color) } : {}
|
|
345
|
+
});
|
|
346
|
+
return html2`
|
|
347
|
+
<slot></slot>
|
|
348
|
+
<div class="tooltip" id=${this._tooltipId} role="tooltip" part="tooltip" aria-hidden="true" style=${tooltipStyle}>
|
|
349
|
+
<lt-text variant="caption" as="span">${this.content}</lt-text>
|
|
350
|
+
<span class="arrow" part="arrow"></span>
|
|
351
|
+
</div>
|
|
352
|
+
`;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
Tooltip.styles = tooltipStyles;
|
|
356
|
+
__decorateClass([
|
|
357
|
+
query("slot")
|
|
358
|
+
], Tooltip.prototype, "_slot", 2);
|
|
359
|
+
__decorateClass([
|
|
360
|
+
property3({ reflect: true })
|
|
361
|
+
], Tooltip.prototype, "content", 2);
|
|
362
|
+
__decorateClass([
|
|
363
|
+
property3({ reflect: true })
|
|
364
|
+
], Tooltip.prototype, "placement", 2);
|
|
365
|
+
__decorateClass([
|
|
366
|
+
property3({ type: Boolean, reflect: true })
|
|
367
|
+
], Tooltip.prototype, "disabled", 2);
|
|
368
|
+
__decorateClass([
|
|
369
|
+
property3({ reflect: true })
|
|
370
|
+
], Tooltip.prototype, "background", 2);
|
|
371
|
+
__decorateClass([
|
|
372
|
+
property3({ reflect: true })
|
|
373
|
+
], Tooltip.prototype, "color", 2);
|
|
374
|
+
Tooltip = __decorateClass([
|
|
375
|
+
customElement2("lt-tooltip")
|
|
376
|
+
], Tooltip);
|
|
377
|
+
export {
|
|
378
|
+
Tooltip
|
|
379
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ThemeableElement } from '../../base';
|
|
2
|
+
import type { TooltipPlacement } from './tooltip.types';
|
|
3
|
+
import '../text/text';
|
|
4
|
+
/**
|
|
5
|
+
* Floating label that appears on hover or focus of its trigger element.
|
|
6
|
+
*
|
|
7
|
+
* @element lt-tooltip
|
|
8
|
+
*
|
|
9
|
+
* @slot - The trigger element the tooltip is anchored to.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```html
|
|
13
|
+
* <lt-tooltip content="Save document">
|
|
14
|
+
* <lt-button>Save</lt-button>
|
|
15
|
+
* </lt-tooltip>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```html
|
|
20
|
+
* <lt-tooltip content="Opens in a new tab" placement="bottom"
|
|
21
|
+
* background="--lt-color-primary-600" color="#fff">
|
|
22
|
+
* <a href="#">Learn more</a>
|
|
23
|
+
* </lt-tooltip>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class Tooltip extends ThemeableElement {
|
|
27
|
+
static styles: import("lit").CSSResult;
|
|
28
|
+
private _tooltipId;
|
|
29
|
+
private _slot;
|
|
30
|
+
/** Tooltip label text. */
|
|
31
|
+
content: string;
|
|
32
|
+
/** Placement of the tooltip relative to the trigger: top, bottom, left, or right. */
|
|
33
|
+
placement: TooltipPlacement;
|
|
34
|
+
/** Prevent the tooltip from showing. */
|
|
35
|
+
disabled: boolean;
|
|
36
|
+
/** Background color override. Accepts a hex value (#1a1a2e) or a CSS token name (--lt-color-primary-600). */
|
|
37
|
+
background: string;
|
|
38
|
+
/** Text color override. Accepts a hex value (#ffffff) or a CSS token name (--lt-color-neutral-50). */
|
|
39
|
+
color: string;
|
|
40
|
+
protected firstUpdated(): void;
|
|
41
|
+
render(): import("lit").TemplateResult<1>;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tooltipStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* Hanken Grotesk - Latin */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: 'Hanken Grotesk';
|
|
4
|
+
font-style: normal;
|
|
5
|
+
font-weight: 100 900;
|
|
6
|
+
font-display: swap;
|
|
7
|
+
src: url('/HankenGrotesk-Variable.woff2') format('woff2');
|
|
8
|
+
unicode-range:
|
|
9
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
|
|
10
|
+
U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@font-face {
|
|
14
|
+
font-family: 'Hanken Grotesk';
|
|
15
|
+
font-style: italic;
|
|
16
|
+
font-weight: 100 900;
|
|
17
|
+
font-display: swap;
|
|
18
|
+
src: url('/HankenGrotesk-VariableItalic.woff2') format('woff2');
|
|
19
|
+
unicode-range:
|
|
20
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
|
|
21
|
+
U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
22
|
+
}
|