@reliability-design/web 1.4.5 → 1.4.7

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +211 -49
  2. package/dist/components/rel-accordion/README.md +132 -132
  3. package/dist/components/rel-alert/README.md +145 -141
  4. package/dist/components/rel-autocomplete/README.md +156 -61
  5. package/dist/components/rel-avatar/README.md +116 -130
  6. package/dist/components/rel-badge/README.md +98 -93
  7. package/dist/components/rel-breadcrumb/README.md +96 -102
  8. package/dist/components/rel-button/README.md +160 -130
  9. package/dist/components/rel-calendar/README.md +109 -109
  10. package/dist/components/rel-card/README.md +75 -94
  11. package/dist/components/rel-cardmedia/README.md +100 -127
  12. package/dist/components/rel-carousel/README.md +184 -166
  13. package/dist/components/rel-checkbox/README.md +93 -75
  14. package/dist/components/rel-chip/README.md +132 -121
  15. package/dist/components/rel-container/README.md +107 -99
  16. package/dist/components/rel-date-picker/README.md +200 -289
  17. package/dist/components/rel-divider/README.md +78 -100
  18. package/dist/components/rel-drawer/README.md +187 -200
  19. package/dist/components/rel-kbd/README.md +141 -151
  20. package/dist/components/rel-menu/README.md +178 -151
  21. package/dist/components/rel-menubar/README.md +218 -329
  22. package/dist/components/rel-otp/README.md +170 -440
  23. package/dist/components/rel-pagination/README.md +100 -424
  24. package/dist/components/rel-popover/README.md +203 -568
  25. package/dist/components/rel-progress/README.md +88 -110
  26. package/dist/components/rel-radio/README.md +131 -135
  27. package/dist/components/rel-range-picker/README.md +162 -0
  28. package/dist/components/rel-resizable/README.md +199 -140
  29. package/dist/components/rel-segmented-button/README.md +155 -141
  30. package/dist/components/rel-select/README.md +154 -93
  31. package/dist/components/rel-sheet/README.md +168 -224
  32. package/dist/components/rel-skeleton/README.md +103 -0
  33. package/dist/components/rel-slider/README.md +130 -135
  34. package/dist/components/rel-snackbar/README.md +162 -134
  35. package/dist/components/rel-stepper/README.md +158 -160
  36. package/dist/components/rel-switch/README.md +108 -102
  37. package/dist/components/rel-tab/README.md +171 -163
  38. package/dist/components/rel-textfield/README.md +159 -69
  39. package/dist/components/rel-time-picker/README.md +122 -157
  40. package/dist/components/rel-toast/README.md +157 -148
  41. package/dist/components/rel-tooltip/README.md +108 -103
  42. package/dist/components/rel-upload/README.md +220 -0
  43. package/dist/index.d.mts +1387 -350
  44. package/dist/index.d.ts +1387 -350
  45. package/dist/index.js +5863 -3600
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +5864 -3592
  48. package/dist/index.mjs.map +1 -1
  49. package/dist/styles/vars.css +877 -866
  50. package/dist/{vars-XNMTSRVN.css → vars-JHTUGNRG.css} +877 -866
  51. package/package.json +4 -3
  52. package/dist/components/rel-accordion/rel-accordion.ts +0 -336
  53. package/dist/components/rel-alert/rel-alert.ts +0 -305
  54. package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -689
  55. package/dist/components/rel-avatar/rel-avatar.ts +0 -142
  56. package/dist/components/rel-badge/rel-badge.ts +0 -170
  57. package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
  58. package/dist/components/rel-button/rel-button.ts +0 -560
  59. package/dist/components/rel-calendar/index.ts +0 -1
  60. package/dist/components/rel-calendar/rel-calendar.ts +0 -519
  61. package/dist/components/rel-card/rel-card.ts +0 -88
  62. package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
  63. package/dist/components/rel-carousel/index.ts +0 -1
  64. package/dist/components/rel-carousel/rel-carousel.ts +0 -700
  65. package/dist/components/rel-chart/README.md +0 -286
  66. package/dist/components/rel-chart/index.ts +0 -1
  67. package/dist/components/rel-chart/rel-chart.ts +0 -754
  68. package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
  69. package/dist/components/rel-chip/rel-chip.ts +0 -472
  70. package/dist/components/rel-container/rel-container.ts +0 -95
  71. package/dist/components/rel-date-picker/date-format.test.ts +0 -43
  72. package/dist/components/rel-date-picker/date-format.ts +0 -47
  73. package/dist/components/rel-date-picker/index.ts +0 -1
  74. package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1237
  75. package/dist/components/rel-divider/rel-divider.ts +0 -54
  76. package/dist/components/rel-drawer/index.ts +0 -1
  77. package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
  78. package/dist/components/rel-drawer/rel-drawer.ts +0 -604
  79. package/dist/components/rel-kbd/rel-kbd.ts +0 -188
  80. package/dist/components/rel-layout/rel-layout.ts +0 -49
  81. package/dist/components/rel-menu/rel-menu.ts +0 -535
  82. package/dist/components/rel-menubar/index.ts +0 -2
  83. package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
  84. package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
  85. package/dist/components/rel-menubar/rel-menubar.ts +0 -777
  86. package/dist/components/rel-nav-menu/README.md +0 -289
  87. package/dist/components/rel-nav-menu/index.ts +0 -3
  88. package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
  89. package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
  90. package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
  91. package/dist/components/rel-navbar/README.md +0 -126
  92. package/dist/components/rel-navbar/rel-navbar.ts +0 -105
  93. package/dist/components/rel-otp/index.ts +0 -1
  94. package/dist/components/rel-otp/rel-otp.ts +0 -517
  95. package/dist/components/rel-pagination/index.ts +0 -1
  96. package/dist/components/rel-pagination/rel-pagination.ts +0 -509
  97. package/dist/components/rel-popover/index.ts +0 -2
  98. package/dist/components/rel-popover/rel-popover-content.ts +0 -81
  99. package/dist/components/rel-popover/rel-popover.ts +0 -444
  100. package/dist/components/rel-progress/rel-progress.ts +0 -225
  101. package/dist/components/rel-radio/rel-radio.ts +0 -305
  102. package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1331
  103. package/dist/components/rel-resizable/index.ts +0 -3
  104. package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
  105. package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
  106. package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
  107. package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -213
  108. package/dist/components/rel-select/rel-select.ts +0 -1385
  109. package/dist/components/rel-sheet/rel-sheet.ts +0 -465
  110. package/dist/components/rel-sidebar/README.md +0 -209
  111. package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1185
  112. package/dist/components/rel-skeleton/rel-skeleton.ts +0 -134
  113. package/dist/components/rel-slider/rel-slider.ts +0 -670
  114. package/dist/components/rel-snackbar/rel-snackbar.ts +0 -325
  115. package/dist/components/rel-stepper/rel-stepper.ts +0 -565
  116. package/dist/components/rel-switch/rel-switch.ts +0 -197
  117. package/dist/components/rel-tab/rel-tab.ts +0 -264
  118. package/dist/components/rel-table/README.md +0 -178
  119. package/dist/components/rel-table/rel-table-body.ts +0 -22
  120. package/dist/components/rel-table/rel-table-caption.ts +0 -30
  121. package/dist/components/rel-table/rel-table-cell.ts +0 -43
  122. package/dist/components/rel-table/rel-table-footer.ts +0 -24
  123. package/dist/components/rel-table/rel-table-head.ts +0 -47
  124. package/dist/components/rel-table/rel-table-header.ts +0 -22
  125. package/dist/components/rel-table/rel-table-row.ts +0 -37
  126. package/dist/components/rel-table/rel-table.ts +0 -62
  127. package/dist/components/rel-textfield/rel-textfield.ts +0 -866
  128. package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1126
  129. package/dist/components/rel-toast/rel-toast.ts +0 -204
  130. package/dist/components/rel-tooltip/rel-tooltip.ts +0 -190
  131. package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
  132. package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
  133. package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
  134. package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
  135. package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
  136. package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
  137. package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
  138. package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
  139. package/dist/components/rel-topbar/rel-topbar.ts +0 -446
  140. package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
  141. package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
  142. package/dist/components/rel-upload/rel-upload.ts +0 -943
@@ -1,472 +0,0 @@
1
- import { LitElement, html, css } from "lit";
2
- import { customElement, property, state } from "lit/decorators.js";
3
- import "../rel-avatar/rel-avatar.js";
4
- import "@reliability-design/icons/rel-icon";
5
-
6
- export type ChipTone = "neutral" | "danger" | "warning" | "success" | "info";
7
- export type ChipVariant = "fill" | "subtle";
8
- export type ChipSize = "sm" | "md" | "lg";
9
- export type ChipBorder = "default" | "rounded";
10
-
11
- @customElement("rel-chip")
12
- export class RelChip extends LitElement {
13
- // The actually-focusable element is the inner <span tabindex="0">, not the
14
- // host. Without delegatesFocus, calling host.focus() (e.g. from a parent
15
- // component, or a "focus this" demo button) is a no-op since the host
16
- // itself carries no tabindex — only real Tab-key traversal would still
17
- // reach the inner span, because that walks the flattened DOM regardless.
18
- static override shadowRootOptions: ShadowRootInit = {
19
- ...LitElement.shadowRootOptions,
20
- delegatesFocus: true,
21
- };
22
-
23
- @property({ type: String }) label = "Label";
24
-
25
- @property({ type: String, reflect: true }) tone: ChipTone = "neutral";
26
-
27
- @property({ type: String, reflect: true }) variant: ChipVariant = "fill";
28
-
29
- @property({ type: String, reflect: true }) size: ChipSize = "md";
30
-
31
- @property({ type: String, reflect: true }) border: ChipBorder = "default";
32
-
33
- /** Icon name from the generated icon dictionary (e.g. "settings") — rendered via <rel-icon>. */
34
- @property({ type: String, attribute: "leading-icon" }) leadingIcon?: string;
35
- @property({ type: String, attribute: "trailing-icon" }) trailingIcon?: string;
36
- /** Initials text for the avatar (e.g. "JD"). Mutually exclusive with leadingIcon. */
37
- @property({ type: String }) avatar?: string;
38
-
39
- @property({ type: Boolean }) removable = false;
40
-
41
- /** IMPORTANT: reflected so CSS + Angular can see it */
42
- @property({ type: Boolean, reflect: true }) removed = false;
43
-
44
- /** Opt-in native drag-and-drop — reflects the Figma "Dragged" state automatically during a real drag gesture. */
45
- // Explicit attribute mapping — Lit's default attribute name for a camelCase
46
- // property is the name fully lowercased (no hyphens), so without this it'd
47
- // only respond to draggablechip="", not draggable-chip.
48
- @property({ type: Boolean, attribute: "draggable-chip" }) draggableChip = false;
49
-
50
- /** Reflected so CSS can target the Figma "Dragged" visual state. Driven automatically by dragstart/dragend when draggableChip is set. */
51
- @state() private dragging = false;
52
-
53
- static styles = css`
54
- :host {
55
- color: var(--rel-text-default);
56
- display: inline-flex;
57
- width: auto;
58
- flex: 0 0 auto;
59
- }
60
-
61
- :host([removed]) {
62
- display: none;
63
- }
64
-
65
- .chip {
66
- display: inline-flex;
67
- align-items: center;
68
- box-sizing: border-box;
69
- border: 1px solid transparent;
70
- gap: var(--rel-spacing-xs);
71
- cursor: pointer;
72
- user-select: none;
73
- white-space: nowrap;
74
- outline: none;
75
- background: transparent;
76
- transition: background-color 0.15s ease;
77
- }
78
-
79
- /* ── Size ── */
80
- :host([size="lg"]) .chip {
81
- height: 32px;
82
- padding: var(--rel-spacing-2xs) var(--rel-spacing-xs);
83
- font-family: var(--rel-body-lg-regular-font-family);
84
- font-weight: var(--rel-body-lg-medium-font-weight);
85
- font-size: var(--rel-body-lg-regular-font-size);
86
- line-height: var(--rel-body-lg-regular-line-height);
87
- letter-spacing: var(--rel-body-lg-regular-letter-spacing);
88
- }
89
-
90
- :host([size="md"]) .chip {
91
- height: 28px;
92
- padding: var(--rel-spacing-2xs) var(--rel-spacing-xs);
93
- font-family: var(--rel-body-md-regular-font-family);
94
- font-weight: var(--rel-body-md-medium-font-weight);
95
- font-size: var(--rel-body-md-regular-font-size);
96
- line-height: var(--rel-body-md-regular-line-height);
97
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
98
- }
99
-
100
- :host([size="sm"]) .chip {
101
- height: 24px;
102
- padding: var(--rel-spacing-2xs) var(--rel-spacing-xs);
103
- font-family: var(--rel-body-sm-regular-font-family);
104
- font-weight: var(--rel-body-xs-medium-font-weight);
105
- font-size: var(--rel-body-sm-medium-font-size);
106
- line-height: var(--rel-body-sm-medium-line-height);
107
- letter-spacing: var(--rel-body-sm-medium-letter-spacing);
108
- }
109
-
110
- /* ── Border / shape — "Rounded" also widens horizontal padding to 12px,
111
- consistent across all three sizes per the Figma spec. ── */
112
- :host([border="default"]) .chip {
113
- border-radius: var(--rel-border-radius-xs);
114
- }
115
-
116
- :host([border="rounded"]) .chip {
117
- border-radius: var(--rel-border-radius-full-rounded);
118
- padding-left: var(--rel-spacing-sm);
119
- padding-right: var(--rel-spacing-sm);
120
- }
121
-
122
- /* ── Tone x Variant — V2 action tokens (auto light/dark) ── */
123
- :host([tone="neutral"][variant="fill"]) .chip {
124
- background: var(--rel-action-neutral-fill);
125
- color: var(--rel-text-inverse);
126
- }
127
- :host([tone="neutral"][variant="subtle"]) .chip {
128
- background: var(--rel-action-neutral-subtle);
129
- color: var(--rel-action-neutral-label-icons-subtle);
130
- }
131
- :host([tone="danger"][variant="fill"]) .chip {
132
- background: var(--rel-action-danger-fill);
133
- color: var(--rel-text-static-light);
134
- }
135
- :host([tone="danger"][variant="subtle"]) .chip {
136
- background: var(--rel-action-danger-subtle);
137
- color: var(--rel-action-danger-label-icons-subtle);
138
- }
139
- :host([tone="warning"][variant="fill"]) .chip {
140
- background: var(--rel-action-warning-fill);
141
- color: var(--rel-action-warning-label-icons-fill);
142
- }
143
- :host([tone="warning"][variant="subtle"]) .chip {
144
- background: var(--rel-action-warning-subtle);
145
- color: var(--rel-action-warning-label-icons-subtle);
146
- }
147
- :host([tone="success"][variant="fill"]) .chip {
148
- background: var(--rel-action-success-fill);
149
- color: var(--rel-action-success-label-icons-fill);
150
- }
151
- :host([tone="success"][variant="subtle"]) .chip {
152
- background: var(--rel-action-success-subtle);
153
- color: var(--rel-action-success-label-icons-subtle);
154
- }
155
- :host([tone="info"][variant="fill"]) .chip {
156
- background: var(--rel-action-info-fill);
157
- color: var(--rel-action-info-label-icons-fill);
158
- }
159
- :host([tone="info"][variant="subtle"]) .chip {
160
- background: var(--rel-action-info-subtle);
161
- color: var(--rel-action-info-label-icons-subtle);
162
- }
163
-
164
- /* ── Hover / Dragged — per-tone V2 action state tokens ── */
165
- :host([tone="neutral"][variant="fill"]) .chip:hover {
166
- background: var(--rel-action-neutral-fill-hover);
167
- }
168
- :host([tone="neutral"][variant="fill"]) .chip:active,
169
- :host([tone="neutral"][variant="fill"][dragging]) .chip {
170
- background: var(--rel-action-neutral-fill-dragged);
171
- }
172
- :host([tone="neutral"][variant="subtle"]) .chip:hover {
173
- border-color: var(--rel-action-neutral-border-subtle-hover);
174
- background: var(--rel-action-neutral-subtle-hover);
175
- }
176
- :host([tone="neutral"][variant="subtle"]) .chip:active,
177
- :host([tone="neutral"][variant="subtle"][dragging]) .chip {
178
- border-color: var(--rel-action-neutral-border-subtle-dragged);
179
- background: var(--rel-action-neutral-subtle-dragged);
180
- }
181
- :host([tone="danger"][variant="fill"]) .chip:hover {
182
- background: var(--rel-action-danger-fill-hover);
183
- }
184
- :host([tone="danger"][variant="fill"]) .chip:active,
185
- :host([tone="danger"][variant="fill"][dragging]) .chip {
186
- background: var(--rel-action-danger-fill-dragged);
187
- }
188
- :host([tone="danger"][variant="subtle"]) .chip:hover {
189
- border-color: var(--rel-action-danger-border-subtle-hover);
190
- background: var(--rel-action-danger-subtle-hover);
191
- color: var(--rel-action-danger-label-icons-subtle-hover);
192
- }
193
- :host([tone="danger"][variant="subtle"]) .chip:active,
194
- :host([tone="danger"][variant="subtle"][dragging]) .chip {
195
- border-color: var(--rel-action-danger-border-subtle-dragged);
196
- background: var(--rel-action-danger-subtle-dragged);
197
- color: var(--rel-action-danger-label-icons-subtle-dragged);
198
- }
199
- :host([tone="warning"][variant="fill"]) .chip:hover {
200
- background: var(--rel-action-warning-fill-hover);
201
- }
202
- :host([tone="warning"][variant="fill"]) .chip:active,
203
- :host([tone="warning"][variant="fill"][dragging]) .chip {
204
- background: var(--rel-action-warning-fill-dragged);
205
- }
206
- :host([tone="warning"][variant="subtle"]) .chip:hover {
207
- border-color: var(--rel-action-warning-border-subtle-hover);
208
- background: var(--rel-action-warning-subtle-hover);
209
- color: var(--rel-action-warning-label-icons-subtle-hover);
210
- }
211
- :host([tone="warning"][variant="subtle"]) .chip:active,
212
- :host([tone="warning"][variant="subtle"][dragging]) .chip {
213
- border-color: var(--rel-action-warning-border-subtle-dragged);
214
- background: var(--rel-action-warning-subtle-dragged);
215
- color: var(--rel-action-warning-label-icons-subtle-dragged);
216
- }
217
- :host([tone="success"][variant="fill"]) .chip:hover {
218
- background: var(--rel-action-success-fill-hover);
219
- }
220
- :host([tone="success"][variant="fill"]) .chip:active,
221
- :host([tone="success"][variant="fill"][dragging]) .chip {
222
- background: var(--rel-action-success-fill-dragged);
223
- }
224
- :host([tone="success"][variant="subtle"]) .chip:hover {
225
- border-color: var(--rel-action-success-border-subtle-hover);
226
- background: var(--rel-action-success-subtle-hover);
227
- color: var(--rel-action-success-label-icons-subtle-hover);
228
- }
229
- :host([tone="success"][variant="subtle"]) .chip:active,
230
- :host([tone="success"][variant="subtle"][dragging]) .chip {
231
- border-color: var(--rel-action-success-border-subtle-dragged);
232
- background: var(--rel-action-success-subtle-dragged);
233
- color: var(--rel-action-success-label-icons-subtle-dragged);
234
- }
235
- :host([tone="info"][variant="fill"]) .chip:hover {
236
- background: var(--rel-action-info-fill-hover);
237
- }
238
- :host([tone="info"][variant="fill"]) .chip:active,
239
- :host([tone="info"][variant="fill"][dragging]) .chip {
240
- background: var(--rel-action-info-fill-dragged);
241
- }
242
- :host([tone="info"][variant="subtle"]) .chip:hover {
243
- border-color: var(--rel-action-info-border-subtle-hover);
244
- background: var(--rel-action-info-subtle-hover);
245
- color: var(--rel-action-info-label-icons-subtle-hover);
246
- }
247
- :host([tone="info"][variant="subtle"]) .chip:active,
248
- :host([tone="info"][variant="subtle"][dragging]) .chip {
249
- border-color: var(--rel-action-info-border-subtle-dragged);
250
- background: var(--rel-action-info-subtle-dragged);
251
- color: var(--rel-action-info-label-icons-subtle-dragged);
252
- }
253
-
254
- :host([dragging]) .chip {
255
- cursor: grabbing;
256
- }
257
-
258
- /* ── Focused — 1.5px outline, drawn outside (matches Figma's
259
- strokeAlign:OUTSIDE) so it never affects layout. Same color
260
- regardless of tone, per spec. OUTSIDE alignment means the stroke
261
- sits flush against the shape's edge with zero gap, extending
262
- outward by strokeWeight — outline-offset must be 0, not a positive
263
- gap (a positive offset was the bug: it drew a visible gap that
264
- doesn't exist in Figma). ── */
265
- .chip:focus-visible {
266
- outline: 1.5px solid var(--rel-chip-focus-ring, var(--rel-border-focus));
267
- outline-offset: 1.5px;
268
- box-shadow: 0 0 0 1.5px var(--rel-border-focus-inner);
269
- }
270
-
271
- /* ── Icons ── */
272
- /* rel-icon renders its SVG inside its own shadow root, so sizing has to
273
- go through --rel-icon-size (a custom property — pierces shadow
274
- boundaries) rather than a ".chip-icon svg" selector, which can never
275
- reach across shadow DOM. */
276
- .chip-icon {
277
- flex-shrink: 0;
278
- }
279
-
280
- :host([size="lg"]) .chip-icon {
281
- --rel-icon-size: 20px;
282
- }
283
-
284
- :host([size="md"]) .chip-icon {
285
- --rel-icon-size: 18px;
286
- }
287
-
288
- :host([size="sm"]) .chip-icon {
289
- --rel-icon-size: 16px;
290
- }
291
-
292
- /* ── Avatar — not shown in the Figma sample. rel-avatar sizes its inner
293
- .avatar div directly from its own "size" prop (fixed presets only —
294
- no --rel-avatar-size custom property escape hatch like rel-icon has),
295
- so a host-level width/height override here would only resize the
296
- empty outer wrapper, not the actual painted circle. "xs" (20px) is
297
- rel-avatar's smallest preset; used uniformly across all three chip
298
- sizes since there's nothing smaller to ask for. ── */
299
- .chip rel-avatar {
300
- display: inline-flex;
301
- flex-shrink: 0;
302
- }
303
-
304
- :host([variant="fill"]) .chip rel-avatar {
305
- --rel-avatar-bg-fill: var(--rel-action-overlay-hover-inverse);
306
- --rel-avatar-color-fill: var(--rel-action-neutral-label-icons-fill-inverse);
307
- }
308
-
309
- :host([variant="subtle"]) .chip rel-avatar {
310
- --rel-avatar-bg-fill: var(--rel-action-overlay-hover-strong);
311
- --rel-avatar-color-fill: currentColor;
312
- }
313
-
314
- /* ── Remove (close) button ── */
315
- .chip-remove {
316
- display: inline-flex;
317
- align-items: center;
318
- justify-content: center;
319
- flex-shrink: 0;
320
- cursor: pointer;
321
- opacity: 0.7;
322
- background: none;
323
- border: none;
324
- color: inherit;
325
- font: inherit;
326
- padding: 0;
327
- line-height: 1;
328
- }
329
-
330
- .chip-remove:hover {
331
- opacity: 1;
332
- }
333
-
334
- .chip-remove:focus-visible {
335
- outline: 1.5px solid currentColor;
336
- outline-offset: 1px;
337
- border-radius: var(--rel-border-radius-xs);
338
- }
339
-
340
- :host([size="lg"]) .chip-remove {
341
- --rel-icon-size: 20px;
342
- }
343
- :host([size="md"]) .chip-remove {
344
- --rel-icon-size: 18px;
345
- }
346
- :host([size="sm"]) .chip-remove {
347
- --rel-icon-size: 16px;
348
- }
349
-
350
- `;
351
-
352
- private get classes() {
353
- return "chip";
354
- }
355
-
356
- private handleRemove(event: Event) {
357
- event.stopPropagation();
358
- this.removed = true;
359
-
360
- this.dispatchEvent(
361
- new CustomEvent("removed", {
362
- bubbles: true,
363
- composed: true,
364
- })
365
- );
366
- }
367
-
368
- /** The chip body is announced as a button, so it must also act on keys:
369
- * Enter/Space re-dispatch as a host click (consumers' @click handlers
370
- * fire), Delete/Backspace remove when removable, and arrow keys ask the
371
- * container to reorder a draggable chip (`chip-move`) — the keyboard
372
- * alternative to pointer drag-and-drop. */
373
- private handleKeydown = (e: KeyboardEvent) => {
374
- if (e.key === "Enter" || e.key === " ") {
375
- e.preventDefault();
376
- this.click();
377
- return;
378
- }
379
- if ((e.key === "Delete" || e.key === "Backspace") && this.removable) {
380
- e.preventDefault();
381
- this.handleRemove(e);
382
- return;
383
- }
384
- if (this.draggableChip && (e.key === "ArrowLeft" || e.key === "ArrowRight")) {
385
- e.preventDefault();
386
- this.dispatchEvent(
387
- new CustomEvent("chip-move", {
388
- detail: { direction: e.key === "ArrowLeft" ? -1 : 1 },
389
- bubbles: true,
390
- composed: true,
391
- })
392
- );
393
- }
394
- };
395
-
396
- private onDragStart = (e: DragEvent) => {
397
- if (!this.draggableChip) return;
398
- this.dragging = true;
399
- e.dataTransfer?.setData("text/plain", this.label);
400
- };
401
-
402
- private onDragEnd = () => {
403
- this.dragging = false;
404
- };
405
-
406
- protected updated(changed: Map<string, unknown>) {
407
- if (changed.has("draggableChip")) {
408
- if (this.draggableChip) {
409
- this.setAttribute("draggable", "true");
410
- this.addEventListener("dragstart", this.onDragStart);
411
- this.addEventListener("dragend", this.onDragEnd);
412
- } else {
413
- this.removeAttribute("draggable");
414
- this.removeEventListener("dragstart", this.onDragStart);
415
- this.removeEventListener("dragend", this.onDragEnd);
416
- this.dragging = false;
417
- }
418
- }
419
- if (changed.has("dragging")) {
420
- this.toggleAttribute("dragging", this.dragging);
421
- }
422
- }
423
-
424
- render() {
425
- const showAvatar = !!this.avatar;
426
- const showLeadingIcon = !showAvatar && !!this.leadingIcon;
427
-
428
- if (this.avatar && this.leadingIcon) {
429
- console.warn(
430
- "[rel-chip] leadingIcon and avatar are mutually exclusive. avatar takes precedence."
431
- );
432
- }
433
-
434
- return html`
435
- <span
436
- part="base" class="${this.classes}"
437
- role="button"
438
- tabindex="0"
439
- aria-label="${this.label}"
440
- @keydown=${this.handleKeydown}
441
- >
442
- ${showAvatar
443
- ? html`<rel-avatar type="text" text=${this.avatar} size="xs"></rel-avatar>`
444
- : null}
445
- ${showLeadingIcon
446
- ? html`<rel-icon part="icon" class="chip-icon" name="${this.leadingIcon}"></rel-icon>`
447
- : null}
448
-
449
- <span part="label" class="chip-label">${this.label}</span>
450
-
451
- ${this.trailingIcon
452
- ? html`<rel-icon class="chip-icon" name="${this.trailingIcon}"></rel-icon>`
453
- : null}
454
- ${this.removable
455
- ? html`<button
456
- class="chip-remove"
457
- aria-label="Remove ${this.label}"
458
- @click=${this.handleRemove}
459
- >
460
- <rel-icon name="close"></rel-icon>
461
- </button>`
462
- : null}
463
- </span>
464
- `;
465
- }
466
- }
467
-
468
- declare global {
469
- interface HTMLElementTagNameMap {
470
- "rel-chip": RelChip;
471
- }
472
- }
@@ -1,95 +0,0 @@
1
- import { LitElement, html, css } from "lit";
2
- import { customElement, property } from "lit/decorators.js";
3
-
4
- @customElement("rel-container")
5
- export class RelContainer extends LitElement {
6
- @property({ type: String, reflect: true }) padding: "sm" | "md" | "lg" | "xl" = "md";
7
- @property({ type: Boolean }) shadow = false;
8
- @property({ type: String, reflect: true }) background: "light" | "white" | "none" = "white";
9
-
10
- static styles = css`
11
- :host {
12
- color: var(--rel-text-default);
13
- display: block;
14
- width: 100%;
15
- box-sizing: border-box;
16
- }
17
-
18
- .reliability-container {
19
- border-radius: var(--rel-border-radius-sm);
20
- display: block;
21
- width: 100%;
22
- box-sizing: border-box;
23
- }
24
-
25
- .bg-white {
26
- background-color: var(--rel-bg-surface);
27
- }
28
-
29
- .bg-light {
30
- background-color: var(--rel-bg-surface-elevated);
31
- }
32
-
33
- .bg-none {
34
- background: transparent;
35
- }
36
-
37
- /* Default typography for slotted container content (Figma roles) */
38
- ::slotted(h1), ::slotted(h2), ::slotted(h3), ::slotted(h4) {
39
- font-family: var(--rel-headings-sm-font-family);
40
- font-weight: var(--rel-headings-sm-font-weight);
41
- font-size: var(--rel-headings-sm-font-size);
42
- line-height: var(--rel-headings-sm-line-height);
43
- letter-spacing: var(--rel-headings-sm-letter-spacing);
44
- color: var(--rel-text-default);
45
- margin: 0 0 var(--rel-spacing-lg) 0;
46
- }
47
-
48
- ::slotted(p) {
49
- font-family: var(--rel-body-md-regular-font-family);
50
- font-weight: var(--rel-body-md-regular-font-weight);
51
- font-size: var(--rel-body-md-regular-font-size);
52
- line-height: var(--rel-body-md-regular-line-height);
53
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
54
- color: var(--rel-text-body);
55
- margin: 0;
56
- }
57
-
58
- .padding-sm {
59
- padding: var(--rel-spacing-xs);
60
- }
61
-
62
- .padding-md {
63
- padding: var(--rel-spacing-md);
64
- }
65
-
66
- .padding-lg {
67
- padding: var(--rel-spacing-xl);
68
- }
69
-
70
- .padding-xl {
71
- padding: var(--rel-spacing-2xl);
72
- }
73
-
74
- .shadow {
75
- box-shadow: var(--rel-shadows-shadow-300);
76
- }
77
- `;
78
-
79
- private get classes() {
80
- return [
81
- "reliability-container",
82
- `bg-${this.background}`,
83
- `padding-${this.padding}`,
84
- this.shadow ? "shadow" : "",
85
- ].join(" ");
86
- }
87
-
88
- render() {
89
- return html`
90
- <div part="base container" class="${this.classes}">
91
- <slot></slot>
92
- </div>
93
- `;
94
- }
95
- }
@@ -1,43 +0,0 @@
1
- import { test } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { formatDatePattern } from "./date-format";
4
-
5
- // Local, DOM-free date (noon avoids any TZ edge on the calendar day).
6
- const d = new Date(2026, 6, 21, 12, 0, 0); // 2026-07-21 (month is 0-based)
7
- const single = new Date(2026, 2, 5, 12, 0, 0); // 2026-03-05 → single-digit M/D
8
-
9
- test("YYYY-MM-DD (ISO, the primary ask)", () => {
10
- assert.equal(formatDatePattern(d, "YYYY-MM-DD"), "2026-07-21");
11
- });
12
-
13
- test("MM/DD/YYYY (US)", () => {
14
- assert.equal(formatDatePattern(d, "MM/DD/YYYY"), "07/21/2026");
15
- });
16
-
17
- test("DD/MM/YYYY (EU)", () => {
18
- assert.equal(formatDatePattern(d, "DD/MM/YYYY"), "21/07/2026");
19
- });
20
-
21
- test("zero-padding vs single-digit tokens", () => {
22
- assert.equal(formatDatePattern(single, "YYYY-MM-DD"), "2026-03-05");
23
- assert.equal(formatDatePattern(single, "D/M/YYYY"), "5/3/2026");
24
- assert.equal(formatDatePattern(single, "YY"), "26");
25
- });
26
-
27
- test("named-month tokens are locale-aware", () => {
28
- assert.equal(formatDatePattern(d, "MMMM D, YYYY", "en-US"), "July 21, 2026");
29
- assert.equal(formatDatePattern(d, "MMM DD", "en-US"), "Jul 21");
30
- // German locale month name
31
- assert.equal(formatDatePattern(d, "MMMM", "de-DE"), "Juli");
32
- });
33
-
34
- test("bracketed literals pass through without token substitution", () => {
35
- assert.equal(formatDatePattern(d, "[Week of] YYYY-MM-DD"), "Week of 2026-07-21");
36
- // 'M' and 'D' inside a bracketed literal are NOT substituted
37
- assert.equal(formatDatePattern(d, "[Manifest Due:] DD/MM"), "Manifest Due: 21/07");
38
- });
39
-
40
- test("arbitrary separators pass through", () => {
41
- assert.equal(formatDatePattern(d, "YYYY.MM.DD"), "2026.07.21");
42
- assert.equal(formatDatePattern(d, "DD MMM YYYY", "en-US"), "21 Jul 2026");
43
- });
@@ -1,47 +0,0 @@
1
- /**
2
- * Token-based date formatting for rel-date-picker's selected-value display.
3
- *
4
- * Pure (Date + Intl only, no DOM) so it is unit-testable in Node. Tokens are
5
- * matched longest-first; anything else (separators like `-` `/` `.` and spaces)
6
- * passes through literally. Wrap literal text that contains token letters in
7
- * square brackets, e.g. `[Week of] YYYY-MM-DD`.
8
- *
9
- * | Token | Meaning | Example (2026-07-21) |
10
- * |-------|------------------------|----------------------|
11
- * | YYYY | 4-digit year | 2026 |
12
- * | YY | 2-digit year | 26 |
13
- * | MMMM | full month (locale) | July |
14
- * | MMM | short month (locale) | Jul |
15
- * | MM | 2-digit month | 07 |
16
- * | M | month number | 7 |
17
- * | DD | 2-digit day | 21 |
18
- * | D | day number | 21 |
19
- */
20
- export function formatDatePattern(
21
- date: Date,
22
- pattern: string,
23
- locale = "en-US"
24
- ): string {
25
- const pad = (n: number) => String(n).padStart(2, "0");
26
- const year = date.getFullYear();
27
- const month = date.getMonth() + 1;
28
- const day = date.getDate();
29
-
30
- const tokens: Record<string, string> = {
31
- YYYY: String(year),
32
- YY: String(year).slice(-2),
33
- MMMM: new Intl.DateTimeFormat(locale, { month: "long" }).format(date),
34
- MMM: new Intl.DateTimeFormat(locale, { month: "short" }).format(date),
35
- MM: pad(month),
36
- M: String(month),
37
- DD: pad(day),
38
- D: String(day),
39
- };
40
-
41
- // `\[([^\]]*)\]` captures a bracketed literal (emitted without the brackets);
42
- // otherwise the matched token is substituted from the map.
43
- return pattern.replace(
44
- /\[([^\]]*)\]|YYYY|YY|MMMM|MMM|MM|M|DD|D/g,
45
- (match, literal) => (literal !== undefined ? literal : tokens[match])
46
- );
47
- }
@@ -1 +0,0 @@
1
- export * from "./rel-date-picker";