@reliability-design/web 1.4.0 → 1.4.2

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,6 +1,6 @@
1
1
  import * as lit_html from 'lit-html';
2
2
  import * as lit from 'lit';
3
- import { LitElement, PropertyValues } from 'lit';
3
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
4
4
  export * from '@reliability-design/icons';
5
5
 
6
6
  declare class RelAccordion extends LitElement {
@@ -31,6 +31,172 @@ declare class RelAlert extends LitElement {
31
31
  render(): lit_html.TemplateResult<1>;
32
32
  }
33
33
 
34
+ type TextFieldState = "default" | "error" | "disabled";
35
+ type TextFieldSize = "small" | "medium" | "large";
36
+ type TextFieldVariant = "default" | "underline" | "legend";
37
+ declare class RelTextfield extends LitElement {
38
+ label?: string;
39
+ placeholder: string;
40
+ type: string;
41
+ value: string;
42
+ leftIcon?: string;
43
+ rightIcon?: string;
44
+ /** Makes the trailing icon interactive (pointer + focusable) and emits
45
+ * `rel-right-icon-click` — e.g. a password show/hide toggle or clear button. */
46
+ clickableRightIcon: boolean;
47
+ /** Accessible label for the trailing icon when it is clickable. */
48
+ rightIconAriaLabel?: string;
49
+ supportingText?: string;
50
+ state: TextFieldState;
51
+ size: TextFieldSize;
52
+ floatingLabel: boolean;
53
+ variant: TextFieldVariant;
54
+ disabled: boolean;
55
+ required: boolean;
56
+ multiline: boolean;
57
+ rows: number;
58
+ prefixIcon?: string;
59
+ prefixIconAriaLabel?: string;
60
+ error: boolean;
61
+ errorMessage?: string;
62
+ helperText?: string;
63
+ readonly: boolean;
64
+ maxLength?: number;
65
+ name?: string;
66
+ fullWidth: boolean;
67
+ private internalState;
68
+ private _wasError;
69
+ private uniqueId;
70
+ private get isDisabled();
71
+ private get isError();
72
+ private get leadingIcon();
73
+ private get helper();
74
+ static styles: lit.CSSResult;
75
+ connectedCallback(): void;
76
+ /** Focuses the inner input/textarea (the host itself is not focusable). */
77
+ focus(options?: FocusOptions): void;
78
+ private handleFocus;
79
+ private handleBlur;
80
+ private handleRightIconClick;
81
+ private handleRightIconKeydown;
82
+ private handleInput;
83
+ render(): lit_html.TemplateResult<1>;
84
+ }
85
+
86
+ /** An item is a plain string or any object read through displayField/valueField. */
87
+ type AutocompleteItem = string | Record<string, unknown>;
88
+ type AutocompleteFilter = "contains" | "starts-with" | "none";
89
+ type AutocompleteSearchFn = (query: string) => Promise<AutocompleteItem[]>;
90
+ /**
91
+ * `<rel-autocomplete>` — searchable single-select type-ahead field.
92
+ *
93
+ * Composes `<rel-textfield>` for all field chrome (label, sizes, variants,
94
+ * states, icons) and adds a suggestion panel on top. Two data modes:
95
+ * - local: set `items`; typing filters them (`filter` mode)
96
+ * - remote: set `searchFn`; input is debounced (`debounceMs`), queries are
97
+ * latest-wins (stale responses discarded), and `items` is ignored
98
+ *
99
+ * The committed `value` is always the selected item's value string (its
100
+ * `valueField`) — typing alone emits `rel-change` with the raw text but does
101
+ * not change `value` until an item is picked (or the text exactly matches an
102
+ * item's label/value on Enter/blur).
103
+ */
104
+ declare class RelAutocomplete extends LitElement {
105
+ /** Local (or fallback initial) suggestion list. Ignored while searchFn drives results. */
106
+ items: AutocompleteItem[];
107
+ /** Committed value — the selected item's valueField string ("" = none). */
108
+ value: string;
109
+ /** Object key read for the row label when items are objects. */
110
+ displayField: string;
111
+ /** Object key read for the committed value when items are objects. */
112
+ valueField: string;
113
+ /** Local filtering mode. Ignored when searchFn is set (results arrive pre-filtered). */
114
+ filter: AutocompleteFilter;
115
+ /** Async data source. When set, local filtering is bypassed entirely. */
116
+ searchFn?: AutocompleteSearchFn;
117
+ /** Debounce for searchFn calls, in ms. */
118
+ debounceMs: number;
119
+ /** Minimum typed characters before the panel opens / searchFn fires. 0 = open on focus. */
120
+ minSearchLength: number;
121
+ /** Optional cap on rendered suggestions (panel scrolls regardless). */
122
+ maxSuggestions: number;
123
+ /** Shows a trailing ✕ that clears the text and the committed value. */
124
+ clearable: boolean;
125
+ /** Externally-controlled loading state (internal searchFn loading is automatic). */
126
+ loading: boolean;
127
+ /** Row shown when a query yields nothing. */
128
+ noResultsText: string;
129
+ loadingText: string;
130
+ label?: string;
131
+ placeholder: string;
132
+ size: TextFieldSize;
133
+ variant: TextFieldVariant;
134
+ floatingLabel: boolean;
135
+ prefixIcon?: string;
136
+ disabled: boolean;
137
+ readonly: boolean;
138
+ required: boolean;
139
+ error: boolean;
140
+ errorMessage?: string;
141
+ helperText?: string;
142
+ name?: string;
143
+ fullWidth: boolean;
144
+ private open;
145
+ private inputText;
146
+ private highlightedIndex;
147
+ private panelStyle;
148
+ private searching;
149
+ /** searchFn results; null = idle/local mode (use items). */
150
+ private remoteItems;
151
+ private fieldEl;
152
+ private panelEl;
153
+ private uniqueId;
154
+ private debounceTimer?;
155
+ private searchSeq;
156
+ /** Set while a selection/clear updates `value` internally, so willUpdate
157
+ * doesn't overwrite the input text the way it does for external writes. */
158
+ private internalValueWrite;
159
+ static styles: lit.CSSResult;
160
+ disconnectedCallback(): void;
161
+ protected willUpdate(changed: PropertyValues<this>): void;
162
+ /** Full normalized source list (remote results while searchFn drives, else items). */
163
+ private get allItems();
164
+ private normalizeItem;
165
+ /** Suggestions for the current query — local filter only applies without searchFn. */
166
+ private get filteredItems();
167
+ private get isLoading();
168
+ private get queryLongEnough();
169
+ private addGlobalListeners;
170
+ private removeGlobalListeners;
171
+ private onOutsidePointerDown;
172
+ private onPageScroll;
173
+ private openPanel;
174
+ private closePanel;
175
+ private updatePosition;
176
+ /** Re-evaluates whether the panel should be showing for the current state. */
177
+ private syncPanel;
178
+ private onFieldInput;
179
+ private runSearch;
180
+ private selectItem;
181
+ /** Silent commit when typed text exactly matches an item (label or value, case-insensitive). */
182
+ private commitExactMatch;
183
+ private emitChanged;
184
+ private clear;
185
+ private onKeyDown;
186
+ private onFocusIn;
187
+ private onFocusOut;
188
+ /** Delegates focus to the inner textfield. */
189
+ focus(): void;
190
+ /** Bolds the first occurrence of the query inside a suggestion label. */
191
+ private renderLabel;
192
+ render(): TemplateResult<1>;
193
+ }
194
+ declare global {
195
+ interface HTMLElementTagNameMap {
196
+ "rel-autocomplete": RelAutocomplete;
197
+ }
198
+ }
199
+
34
200
  declare class RelAvatar extends LitElement {
35
201
  size: "lg" | "md" | "sm" | "xs";
36
202
  type: "image" | "text" | "icon";
@@ -238,6 +404,8 @@ type CheckboxState = "default" | "error" | "disabled";
238
404
  type CheckboxStatus = "unchecked" | "checked" | "indeterminate";
239
405
  declare class RelCheckbox extends LitElement {
240
406
  label: string;
407
+ /** rel-icon name rendered between the checkbox and the label (label prefix icon). */
408
+ icon: string;
241
409
  supportingtext: string;
242
410
  state: CheckboxState;
243
411
  status: CheckboxStatus;
@@ -472,6 +640,7 @@ declare class RelDrawer extends LitElement {
472
640
  description: string;
473
641
  private isDragging;
474
642
  private dragOffset;
643
+ private settled;
475
644
  private panelElement;
476
645
  private overlayElement;
477
646
  private previousFocus;
@@ -1000,6 +1169,8 @@ declare class RelPopover extends LitElement {
1000
1169
  private onHostPointerDown;
1001
1170
  private onOpen;
1002
1171
  private onClose;
1172
+ private showNativePopover;
1173
+ private hideNativePopover;
1003
1174
  private addGlobalListeners;
1004
1175
  private removeGlobalListeners;
1005
1176
  private onOutsidePointerDown;
@@ -1135,6 +1306,8 @@ interface SelectOptionObject {
1135
1306
  value: string;
1136
1307
  label?: string;
1137
1308
  supportingText?: string;
1309
+ /** rel-icon name rendered as a prefix (leading icon) on the menu item. */
1310
+ icon?: string;
1138
1311
  }
1139
1312
  type SelectOption = string | SelectOptionObject;
1140
1313
  declare class RelSelect extends LitElement {
@@ -1156,7 +1329,11 @@ declare class RelSelect extends LitElement {
1156
1329
  placeholder: string;
1157
1330
  searchPlaceholder: string;
1158
1331
  selectAllLabel: string;
1159
- /** Max selected chips shown before collapsing the rest into a "+N" badge. */
1332
+ /**
1333
+ * Optional hard cap on visible chips. By default (no cap) the visible
1334
+ * count adapts to the trigger's width: chips collapse into the "+N" badge
1335
+ * one by one instead of wrapping to a second line.
1336
+ */
1160
1337
  maxVisibleChips: number;
1161
1338
  /** Hides the in-panel search field. Figma's "Single Option" dropdown has no search bar at all — use this for short, non-searchable lists. */
1162
1339
  noSearch: boolean;
@@ -1165,13 +1342,30 @@ declare class RelSelect extends LitElement {
1165
1342
  private panelStyle;
1166
1343
  private searchValue;
1167
1344
  private internalState;
1345
+ /** How many chips currently fit in the trigger width (width-adaptive). */
1346
+ private visibleChipCount;
1168
1347
  private triggerEl;
1169
1348
  private searchInputEl;
1170
1349
  private listboxEl;
1350
+ private valueEl;
1351
+ private chipsMeasureEl;
1352
+ /** Must match the `gap` of .select-chips / .select-chips-measure. */
1353
+ private static readonly CHIP_GAP;
1354
+ private chipResizeObserver?;
1171
1355
  private uniqueId;
1172
1356
  static styles: lit.CSSResult;
1357
+ connectedCallback(): void;
1173
1358
  disconnectedCallback(): void;
1359
+ protected firstUpdated(): void;
1174
1360
  protected willUpdate(changed: PropertyValues<this>): void;
1361
+ protected updated(changed: PropertyValues<this>): void;
1362
+ /**
1363
+ * Width-adaptive chip collapsing: measures every selected chip in the
1364
+ * hidden .select-chips-measure row and works out how many fit in the value
1365
+ * area, always reserving room for the trailing "+N" chip when not all fit.
1366
+ * At least one chip stays visible no matter how narrow the field gets.
1367
+ */
1368
+ private computeVisibleChips;
1175
1369
  private get normalizedOptions();
1176
1370
  /** Options matching the current search text (substring match, case-insensitive). */
1177
1371
  private get filteredOptions();
@@ -1199,6 +1393,13 @@ declare class RelSelect extends LitElement {
1199
1393
  private onSearchKeyDown;
1200
1394
  private handleListNavigation;
1201
1395
  private renderChips;
1396
+ /**
1397
+ * Hidden, unconstrained copy of every selected chip used purely for width
1398
+ * measurement (see computeVisibleChips). Chips mirror the visible ones'
1399
+ * width-affecting props (removable adds the ✕ icon). The trailing chip is
1400
+ * the widest "+N" badge that could ever be needed.
1401
+ */
1402
+ private renderChipsMeasure;
1202
1403
  render(): lit_html.TemplateResult<1>;
1203
1404
  }
1204
1405
  declare global {
@@ -1246,6 +1447,7 @@ declare class RelModal extends LitElement {
1246
1447
  static styles: lit.CSSResult;
1247
1448
  connectedCallback(): void;
1248
1449
  disconnectedCallback(): void;
1450
+ protected willUpdate(): void;
1249
1451
  updated(changed: Map<string, unknown>): void;
1250
1452
  private handleOpen;
1251
1453
  private handleClose;
@@ -1425,49 +1627,6 @@ declare class RelTab extends LitElement {
1425
1627
  render(): lit_html.TemplateResult<1>;
1426
1628
  }
1427
1629
 
1428
- type TextFieldState = "default" | "error" | "disabled";
1429
- type TextFieldSize = "small" | "medium" | "large";
1430
- type TextFieldVariant = "default" | "underline" | "legend";
1431
- declare class RelTextfield extends LitElement {
1432
- label?: string;
1433
- placeholder: string;
1434
- type: string;
1435
- value: string;
1436
- leftIcon?: string;
1437
- rightIcon?: string;
1438
- supportingText?: string;
1439
- state: TextFieldState;
1440
- size: TextFieldSize;
1441
- floatingLabel: boolean;
1442
- variant: TextFieldVariant;
1443
- disabled: boolean;
1444
- required: boolean;
1445
- multiline: boolean;
1446
- rows: number;
1447
- prefixIcon?: string;
1448
- prefixIconAriaLabel?: string;
1449
- error: boolean;
1450
- errorMessage?: string;
1451
- helperText?: string;
1452
- readonly: boolean;
1453
- maxLength?: number;
1454
- name?: string;
1455
- fullWidth: boolean;
1456
- private internalState;
1457
- private _wasError;
1458
- private uniqueId;
1459
- private get isDisabled();
1460
- private get isError();
1461
- private get leadingIcon();
1462
- private get helper();
1463
- static styles: lit.CSSResult;
1464
- connectedCallback(): void;
1465
- private handleFocus;
1466
- private handleBlur;
1467
- private handleInput;
1468
- render(): lit_html.TemplateResult<1>;
1469
- }
1470
-
1471
1630
  type ToastType = "default" | "error";
1472
1631
  declare class RelToast extends LitElement {
1473
1632
  message: string;
@@ -1501,4 +1660,4 @@ declare class RelTooltip extends LitElement {
1501
1660
  render(): lit_html.TemplateResult<1>;
1502
1661
  }
1503
1662
 
1504
- export { type BreadcrumbItem, type ButtonTone, type ButtonVariant, type ChipBorder, type ChipSize, type ChipTone, type ChipVariant, type DrawerCloseReason, type DrawerSide, type LabelPlacement, type MenuItem, type MenuType, type ModalSide, type Orientation, type OtpType, type ProgressMode, type RadioOption, RelAccordion, RelAlert, RelAvatar, RelBadge, RelBreadcrumbs, RelButton, RelCalendar, RelCard, RelCardMedia, RelCarousel, RelCheckbox, RelChip, RelContainer, RelDatePicker, RelDivider, RelDrawer, RelDrawerFooter, RelKbd, RelKbdGroup, RelLayout, RelMenu, RelMenuItem, RelMenubar, RelMenubarMenu, RelModal, RelNavbar, RelOtp, RelPagination, RelPopover, RelPopoverContent, RelProgress, RelRadio, RelRangePicker, RelResizableGroup, RelResizableHandle, RelResizablePanel, RelSegmentedButton, RelSelect, RelSkeleton, RelSlider, RelSnackbar, RelStepper, RelSwitch, RelTab, RelTabItem, RelTextfield, RelToast, RelTooltip, RelTopbar, RelTopbarActions, RelTopbarBrand, RelTopbarDropdown, RelTopbarDropdownItem, RelTopbarItem, RelTopbarMobilePanel, RelTopbarProfile, RelTopbarUtilities, type SegmentAlign, type SegmentOption, type SegmentSize, type SelectBorder, type SelectLabelStyle, type SelectOption, type SelectOptionObject, type SelectSize, type SelectState, type SkeletonAnimation, type SkeletonShape, type SliderType, type SnackbarLines, type SnackbarType, type Step, type StepStatus, type StepperSize, type StepperType, type TabItem, type TextAlign, type TextFieldSize, type TextFieldState, type TextFieldVariant, type ToastType, type TooltipPosition, type TooltipType, type TopbarForceLayout, type TopbarProfileType, type TopbarRewardTier, type TopbarVariant, type TrackStyle };
1663
+ export { type AutocompleteFilter, type AutocompleteItem, type AutocompleteSearchFn, type BreadcrumbItem, type ButtonTone, type ButtonVariant, type ChipBorder, type ChipSize, type ChipTone, type ChipVariant, type DrawerCloseReason, type DrawerSide, type LabelPlacement, type MenuItem, type MenuType, type ModalSide, type Orientation, type OtpType, type ProgressMode, type RadioOption, RelAccordion, RelAlert, RelAutocomplete, RelAvatar, RelBadge, RelBreadcrumbs, RelButton, RelCalendar, RelCard, RelCardMedia, RelCarousel, RelCheckbox, RelChip, RelContainer, RelDatePicker, RelDivider, RelDrawer, RelDrawerFooter, RelKbd, RelKbdGroup, RelLayout, RelMenu, RelMenuItem, RelMenubar, RelMenubarMenu, RelModal, RelNavbar, RelOtp, RelPagination, RelPopover, RelPopoverContent, RelProgress, RelRadio, RelRangePicker, RelResizableGroup, RelResizableHandle, RelResizablePanel, RelSegmentedButton, RelSelect, RelSkeleton, RelSlider, RelSnackbar, RelStepper, RelSwitch, RelTab, RelTabItem, RelTextfield, RelToast, RelTooltip, RelTopbar, RelTopbarActions, RelTopbarBrand, RelTopbarDropdown, RelTopbarDropdownItem, RelTopbarItem, RelTopbarMobilePanel, RelTopbarProfile, RelTopbarUtilities, type SegmentAlign, type SegmentOption, type SegmentSize, type SelectBorder, type SelectLabelStyle, type SelectOption, type SelectOptionObject, type SelectSize, type SelectState, type SkeletonAnimation, type SkeletonShape, type SliderType, type SnackbarLines, type SnackbarType, type Step, type StepStatus, type StepperSize, type StepperType, type TabItem, type TextAlign, type TextFieldSize, type TextFieldState, type TextFieldVariant, type ToastType, type TooltipPosition, type TooltipType, type TopbarForceLayout, type TopbarProfileType, type TopbarRewardTier, type TopbarVariant, type TrackStyle };