primer_view_components 0.0.38 → 0.0.43
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +283 -27
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/components/primer/auto_complete.rb +4 -2
- data/app/components/primer/auto_complete/item.rb +1 -1
- data/app/components/primer/avatar_component.rb +22 -3
- data/app/components/primer/avatar_stack_component.rb +8 -5
- data/app/components/primer/base_button.rb +1 -1
- data/app/components/primer/base_component.rb +24 -13
- data/app/components/primer/blankslate_component.html.erb +1 -0
- data/app/components/primer/blankslate_component.rb +68 -47
- data/app/components/primer/border_box_component.rb +1 -1
- data/app/components/primer/box_component.rb +1 -1
- data/app/components/primer/breadcrumb_component.rb +1 -1
- data/app/components/primer/button_component.html.erb +9 -0
- data/app/components/primer/button_component.rb +39 -5
- data/app/components/primer/button_group.rb +3 -3
- data/app/components/primer/button_marketing_component.rb +1 -1
- data/app/components/primer/clipboard_copy.rb +1 -1
- data/app/components/primer/clipboard_copy_component.js +17 -8
- data/app/components/primer/clipboard_copy_component.ts +19 -8
- data/app/components/primer/close_button.rb +4 -2
- data/app/components/primer/component.rb +22 -3
- data/app/components/primer/counter_component.rb +6 -1
- data/app/components/primer/details_component.rb +1 -1
- data/app/components/primer/dropdown/menu_component.rb +1 -1
- data/app/components/primer/dropdown_component.rb +1 -1
- data/app/components/primer/flash_component.rb +3 -3
- data/app/components/primer/flex_component.rb +28 -1
- data/app/components/primer/flex_item_component.rb +20 -1
- data/app/components/primer/heading_component.rb +12 -19
- data/app/components/primer/hidden_text_expander.rb +4 -4
- data/app/components/primer/icon_button.rb +65 -0
- data/app/components/primer/image.rb +46 -0
- data/app/components/primer/image_crop.d.ts +1 -0
- data/app/components/primer/image_crop.html.erb +12 -0
- data/app/components/primer/image_crop.js +1 -0
- data/app/components/primer/image_crop.rb +36 -0
- data/app/components/primer/image_crop.ts +1 -0
- data/app/components/primer/label_component.rb +7 -3
- data/app/components/primer/layout_component.rb +1 -1
- data/app/components/primer/link_component.rb +1 -1
- data/app/components/primer/local_time.d.ts +1 -0
- data/app/components/primer/local_time.js +1 -0
- data/app/components/primer/local_time.rb +59 -0
- data/app/components/primer/local_time.ts +1 -0
- data/app/components/primer/{markdown_component.rb → markdown.rb} +12 -7
- data/app/components/primer/menu_component.rb +1 -1
- data/app/components/primer/navigation/tab_component.rb +8 -1
- data/app/components/primer/octicon_component.html.erb +7 -0
- data/app/components/primer/octicon_component.rb +53 -19
- data/app/components/primer/octicon_symbols_component.html.erb +3 -0
- data/app/components/primer/octicon_symbols_component.rb +61 -0
- data/app/components/primer/popover_component.rb +1 -1
- data/app/components/primer/primer.d.ts +2 -0
- data/app/components/primer/primer.js +2 -0
- data/app/components/primer/primer.ts +2 -0
- data/app/components/primer/progress_bar_component.rb +1 -1
- data/app/components/primer/spinner_component.rb +3 -3
- data/app/components/primer/state_component.rb +1 -1
- data/app/components/primer/subhead_component.rb +34 -4
- data/app/components/primer/tab_container_component.rb +1 -1
- data/app/components/primer/tab_nav_component.html.erb +5 -1
- data/app/components/primer/tab_nav_component.rb +63 -10
- data/app/components/primer/text_component.rb +6 -3
- data/app/components/primer/time_ago_component.rb +1 -1
- data/app/components/primer/timeline_item_component.rb +1 -1
- data/app/components/primer/{tooltip_component.rb → tooltip.rb} +11 -9
- data/app/components/primer/truncate.rb +7 -3
- data/app/components/primer/underline_nav_component.html.erb +1 -1
- data/app/components/primer/underline_nav_component.rb +18 -2
- data/app/lib/primer/classify.rb +27 -39
- data/app/lib/primer/classify/cache.rb +35 -15
- data/app/lib/primer/classify/flex.rb +111 -0
- data/app/lib/primer/classify/functional_border_colors.rb +1 -2
- data/app/lib/primer/classify/grid.rb +45 -0
- data/app/lib/primer/fetch_or_fallback_helper.rb +2 -2
- data/app/lib/primer/octicon/cache.rb +42 -0
- data/app/lib/primer/tabbed_component_helper.rb +2 -2
- data/app/lib/primer/view_helper.rb +2 -1
- data/lib/primer/view_components.rb +1 -1
- data/lib/primer/view_components/engine.rb +2 -0
- data/lib/primer/view_components/linters.rb +3 -0
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +16 -0
- data/lib/primer/view_components/linters/flash_component_migration_counter.rb +16 -0
- data/lib/primer/view_components/linters/helpers.rb +89 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/coverage.rake +14 -0
- data/lib/tasks/docs.rake +372 -0
- data/lib/tasks/statuses.rake +12 -0
- data/lib/yard/docs_helper.rb +57 -0
- data/static/statuses.json +54 -1
- metadata +62 -11
- data/app/components/primer/button_component.rb.orig +0 -138
- data/app/components/primer/foo_bar.d.ts +0 -1
- data/app/components/primer/foo_bar.js +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78f4fe987616d5ab746cbd6d6a0bc79ff62ecf33eb2365af3ade87a43461d35b
|
|
4
|
+
data.tar.gz: 2813cf307508ab9a413d98edbba54e1d7735dc86e853a42587487c7293d42571
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b13c5c05eb27d2a635396d736daa1039024bef7ddb456d20ec037f2cf270e8cb157ebd40619ca8eed4523e9cde5af2d990b428dc2ff663a42faaf01070a48ef
|
|
7
|
+
data.tar.gz: c5e126fcf17bf04914a2ea054ca181991a8cb0fda5659753c4e03241e6dfcfe8a5e876b915033cfc69b11c10b3b7946403fdb86f1fca3161eb1278eae29d99ed
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,258 @@
|
|
|
2
2
|
|
|
3
3
|
## main
|
|
4
4
|
|
|
5
|
+
## 0.0.43
|
|
6
|
+
|
|
7
|
+
* Upgrade primer/css to 17.2.1
|
|
8
|
+
|
|
9
|
+
*Jon Rohan*
|
|
10
|
+
|
|
11
|
+
### New
|
|
12
|
+
|
|
13
|
+
* Add `clearfix` and `container` system arguments.
|
|
14
|
+
|
|
15
|
+
*Manuel Puyol*
|
|
16
|
+
|
|
17
|
+
### Updates
|
|
18
|
+
|
|
19
|
+
* Promote `TabNav` component to beta.
|
|
20
|
+
|
|
21
|
+
*Manuel Puyol*
|
|
22
|
+
|
|
23
|
+
* Allow customizing `TabContainer` when using `TabNav` and `UnderlineNav` components.
|
|
24
|
+
|
|
25
|
+
*Manuel Puyol*
|
|
26
|
+
|
|
27
|
+
### Breaking changes
|
|
28
|
+
|
|
29
|
+
* Restrict `col` system arguments to only accept values between 1 and 12.
|
|
30
|
+
|
|
31
|
+
*Manuel Puyol*
|
|
32
|
+
|
|
33
|
+
### Misc
|
|
34
|
+
|
|
35
|
+
* Raise an error if `class` is used as a system argument.
|
|
36
|
+
|
|
37
|
+
*Manuel Puyol*
|
|
38
|
+
|
|
39
|
+
* Don't commit auto-generated component previews.
|
|
40
|
+
|
|
41
|
+
*Kate Higa*
|
|
42
|
+
|
|
43
|
+
* Provide linters for component migrations.
|
|
44
|
+
|
|
45
|
+
*Manuel Puyol*
|
|
46
|
+
|
|
47
|
+
* Update docs to accept multiline descriptions.
|
|
48
|
+
|
|
49
|
+
*Manuel Puyol*
|
|
50
|
+
|
|
51
|
+
## 0.0.42
|
|
52
|
+
|
|
53
|
+
### New
|
|
54
|
+
|
|
55
|
+
* Add `font_family`, `font_style` and `text_transform` system arguments.
|
|
56
|
+
|
|
57
|
+
*Manuel Puyol*
|
|
58
|
+
|
|
59
|
+
* Add more options for `font_size` and `font_weight`.
|
|
60
|
+
|
|
61
|
+
*Manuel Puyol*
|
|
62
|
+
|
|
63
|
+
### Updates
|
|
64
|
+
|
|
65
|
+
* Add `align` option to the `TabNav` extra slot to allow HTML ordering.
|
|
66
|
+
|
|
67
|
+
*Manuel Puyol*
|
|
68
|
+
|
|
69
|
+
### Misc
|
|
70
|
+
|
|
71
|
+
* Auto-generate component previews from doc examples and run integration test checks.
|
|
72
|
+
|
|
73
|
+
*Kate Higa, Joel Hawksley*
|
|
74
|
+
|
|
75
|
+
* Configure previews controller to allow view helper usage in preview template.
|
|
76
|
+
|
|
77
|
+
*Kate Higa*
|
|
78
|
+
|
|
79
|
+
* Only include `ViewComponent::SlotableV2` if `ViewComponent::Base` does not already include it.
|
|
80
|
+
|
|
81
|
+
*Manuel Puyol*
|
|
82
|
+
|
|
83
|
+
* Add `force_system_arguments` option to raise an error if a class is used instead of using System Arguments.
|
|
84
|
+
|
|
85
|
+
*Manuel Puyol*
|
|
86
|
+
|
|
87
|
+
### Breaking changes
|
|
88
|
+
|
|
89
|
+
* Restrict allowed tags for `Truncate`, `Markdown`, and `HiddenTextExpander`.
|
|
90
|
+
|
|
91
|
+
*Kate Higa*
|
|
92
|
+
|
|
93
|
+
## 0.0.41
|
|
94
|
+
|
|
95
|
+
### New
|
|
96
|
+
|
|
97
|
+
* Create `LocalTime` component.
|
|
98
|
+
|
|
99
|
+
*Kristján Oddsson*
|
|
100
|
+
|
|
101
|
+
* Create `Image` component.
|
|
102
|
+
|
|
103
|
+
*Manuel Puyol*
|
|
104
|
+
|
|
105
|
+
* Add `extra` slot to `TabNav`.
|
|
106
|
+
|
|
107
|
+
*Manuel Puyol*
|
|
108
|
+
|
|
109
|
+
* Do not raise error if Primer CSS class name is passed to component if `PRIMER_WARNINGS_DISABLED` is set.
|
|
110
|
+
|
|
111
|
+
*Joel Hawksley*
|
|
112
|
+
|
|
113
|
+
### Accessibility
|
|
114
|
+
|
|
115
|
+
* Accept `aria-current="true"` in tabbed components.
|
|
116
|
+
|
|
117
|
+
*Manuel Puyol*
|
|
118
|
+
|
|
119
|
+
### Changes
|
|
120
|
+
|
|
121
|
+
* Promote `Tooltip` component to beta.
|
|
122
|
+
|
|
123
|
+
*Manuel Puyol*
|
|
124
|
+
|
|
125
|
+
### Bug fixes
|
|
126
|
+
|
|
127
|
+
* Ensure that `ClipboardCopy` behaviors only target ViewComponents.
|
|
128
|
+
|
|
129
|
+
*Manuel Puyol*
|
|
130
|
+
|
|
131
|
+
* Ensure that the `rounded` attribute for `<image-crop>` is represented as a boolean attribute.
|
|
132
|
+
|
|
133
|
+
*Kristján Oddsson*
|
|
134
|
+
|
|
135
|
+
### Breaking changes
|
|
136
|
+
|
|
137
|
+
* Rename `TooltipComponent` to `Tooltip`.
|
|
138
|
+
|
|
139
|
+
*Manuel Puyol*
|
|
140
|
+
|
|
141
|
+
* Don't allow `OcticonComponent` height/width values under 16px
|
|
142
|
+
|
|
143
|
+
*Jon Rohan*
|
|
144
|
+
|
|
145
|
+
* Remove `:large` size option from `OcticonComponent` and change `:medium` to 24px
|
|
146
|
+
|
|
147
|
+
*Jon Rohan*
|
|
148
|
+
|
|
149
|
+
* Restrict `Label` tag to `span`, `div`, `a`, `summary`.
|
|
150
|
+
|
|
151
|
+
*Kate Higa*
|
|
152
|
+
|
|
153
|
+
### Misc
|
|
154
|
+
|
|
155
|
+
* Add a CI check for changes to the CHANGELOG file.
|
|
156
|
+
|
|
157
|
+
*Kristján Oddsson*
|
|
158
|
+
|
|
159
|
+
## 0.0.40
|
|
160
|
+
|
|
161
|
+
### New
|
|
162
|
+
|
|
163
|
+
* Create `ImageCrop` component.
|
|
164
|
+
|
|
165
|
+
*Kristján Oddsson*
|
|
166
|
+
|
|
167
|
+
### Changes
|
|
168
|
+
|
|
169
|
+
* Promote `IconButton` to beta.
|
|
170
|
+
|
|
171
|
+
*Manuel Puyol*
|
|
172
|
+
|
|
173
|
+
* Add `box` argument to `IconButton`.
|
|
174
|
+
|
|
175
|
+
*Manuel Puyol*
|
|
176
|
+
|
|
177
|
+
* Promote `Markdown` to beta.
|
|
178
|
+
|
|
179
|
+
*Manuel Puyol*
|
|
180
|
+
|
|
181
|
+
### Bug fixes
|
|
182
|
+
|
|
183
|
+
* Fix `IconButton` raising when `aria-label` was provided using an object.
|
|
184
|
+
|
|
185
|
+
*Manuel Puyol*
|
|
186
|
+
|
|
187
|
+
* Fix disabling of default styles for `SpinnerComponent` via `nil` style parameter.
|
|
188
|
+
|
|
189
|
+
*Chris Wilson*
|
|
190
|
+
|
|
191
|
+
### Deprecations
|
|
192
|
+
|
|
193
|
+
* Deprecate `Flex` in favor of `BoxComponent`.
|
|
194
|
+
|
|
195
|
+
*Manuel Puyol*
|
|
196
|
+
|
|
197
|
+
### Breaking Changes
|
|
198
|
+
|
|
199
|
+
* Restrict `ButtonGroup` tag to `:div` and update docs for `Text` tag.
|
|
200
|
+
|
|
201
|
+
*Kate Higa*
|
|
202
|
+
|
|
203
|
+
* Remove non-functional `width` and `height` `:fill` option.
|
|
204
|
+
|
|
205
|
+
*Jon Rohan*, *Joel Hawksley*
|
|
206
|
+
|
|
207
|
+
* Restrict `Subhead` `heading` slot tag to `div` and `h1`-`h6`.
|
|
208
|
+
|
|
209
|
+
*Kate Higa*
|
|
210
|
+
|
|
211
|
+
* Restrict `Blankslate` tag to `div`.
|
|
212
|
+
|
|
213
|
+
*Kate Higa*
|
|
214
|
+
|
|
215
|
+
* Explicitly limit tag for `AvatarStack` to `:div` and `:span`.
|
|
216
|
+
|
|
217
|
+
*Kate Higa*
|
|
218
|
+
|
|
219
|
+
* Rename `MarkdownComponent` to `Markdown`.
|
|
220
|
+
|
|
221
|
+
*Manuel Puyol*
|
|
222
|
+
|
|
223
|
+
## 0.0.39
|
|
224
|
+
|
|
225
|
+
* Promote `CloseButton` to beta.
|
|
226
|
+
|
|
227
|
+
*Manuel Puyol*
|
|
228
|
+
|
|
229
|
+
* Update `ClipboardCopy` to not toggle icons unless they both exist.
|
|
230
|
+
|
|
231
|
+
*Kristján Oddsson*
|
|
232
|
+
|
|
233
|
+
* Add `icon` and `counter` slots to `ButtonComponent`.
|
|
234
|
+
|
|
235
|
+
*Manuel Puyol*
|
|
236
|
+
|
|
237
|
+
* Create `IconButton` component.
|
|
238
|
+
|
|
239
|
+
*Manuel Puyol*
|
|
240
|
+
|
|
241
|
+
* Removing trailing whitespace from output of `class=""` Classify generation.
|
|
242
|
+
|
|
243
|
+
*Jon Rohan*
|
|
244
|
+
|
|
245
|
+
* Deprecate `FlexItem` in favor of `BoxComponent`.
|
|
246
|
+
|
|
247
|
+
*Manuel Puyol*
|
|
248
|
+
|
|
249
|
+
* Dropping requirement of `octicons_helper` and updating `OcticonComponent` to use `octicon` gem directly.
|
|
250
|
+
|
|
251
|
+
*Jon Rohan*
|
|
252
|
+
|
|
253
|
+
* **Breaking change:** Remove `:overlay` option from `border_color`.
|
|
254
|
+
|
|
255
|
+
*Simon Luthi*
|
|
256
|
+
|
|
5
257
|
## 0.0.38
|
|
6
258
|
|
|
7
259
|
* Extract `BaseButton` component.
|
|
@@ -16,15 +268,19 @@
|
|
|
16
268
|
|
|
17
269
|
*Manuel Puyol*
|
|
18
270
|
|
|
19
|
-
*
|
|
271
|
+
* Create `ClipboardCopy` component.
|
|
272
|
+
|
|
273
|
+
*Kristján Oddsson*
|
|
274
|
+
|
|
275
|
+
* **Breaking change:** Rename `ButtonGroupComponent` to `ButtonGroup` and promote it to beta.
|
|
20
276
|
|
|
21
277
|
*Manuel Puyol*
|
|
22
278
|
|
|
23
|
-
* **Breaking change
|
|
279
|
+
* **Breaking change:** Do not provide default for `Heading` and improve documentation.
|
|
24
280
|
|
|
25
281
|
*Kate Higa*
|
|
26
282
|
|
|
27
|
-
* **Breaking change
|
|
283
|
+
* **Breaking change:** Don't allow `StateComponent` to be a link.
|
|
28
284
|
|
|
29
285
|
*Kate Higa*
|
|
30
286
|
|
|
@@ -48,11 +304,11 @@
|
|
|
48
304
|
|
|
49
305
|
*Manuel Puyol*
|
|
50
306
|
|
|
51
|
-
* **Breaking change
|
|
307
|
+
* **Breaking change:** Rename `AutoCompleteComponent` to `AutoComplete` and `AutoCompleteItemComponent` to `AutoComplete::Item`.
|
|
52
308
|
|
|
53
309
|
*Manuel Puyol*
|
|
54
310
|
|
|
55
|
-
* **Breaking change
|
|
311
|
+
* **Breaking change:** Rename `TruncateComponent` to `Truncate` and promote it to beta.
|
|
56
312
|
|
|
57
313
|
*Manuel Puyol*
|
|
58
314
|
|
|
@@ -70,7 +326,7 @@
|
|
|
70
326
|
|
|
71
327
|
*Manuel Puyol*
|
|
72
328
|
|
|
73
|
-
* **Breaking change
|
|
329
|
+
* **Breaking change:** Make `label` required for `UnderlineNav` and `TabNav`.
|
|
74
330
|
|
|
75
331
|
*Manuel Puyol*
|
|
76
332
|
|
|
@@ -84,23 +340,23 @@
|
|
|
84
340
|
|
|
85
341
|
*Manuel Puyol*
|
|
86
342
|
|
|
87
|
-
* **Breaking change
|
|
343
|
+
* **Breaking change:** Rename `FlashComponent` `variant` argument to `scheme`.
|
|
88
344
|
|
|
89
345
|
*Manuel Puyol*
|
|
90
346
|
|
|
91
|
-
* **Breaking change
|
|
347
|
+
* **Breaking change:** Rename `LinkComponent` `variant` argument to `scheme`.
|
|
92
348
|
|
|
93
349
|
*Manuel Puyol*
|
|
94
350
|
|
|
95
|
-
* **Breaking change
|
|
351
|
+
* **Breaking change:** Rename `ButtonComponent` `button_type` argument to `scheme`.
|
|
96
352
|
|
|
97
353
|
*Manuel Puyol*
|
|
98
354
|
|
|
99
|
-
* **Breaking change
|
|
355
|
+
* **Breaking change:** Rename `ButtonMarketingComponent` `button_type` argument to `scheme`.
|
|
100
356
|
|
|
101
357
|
*Manuel Puyol*
|
|
102
358
|
|
|
103
|
-
* **Breaking change
|
|
359
|
+
* **Breaking change:** Rename `StateComponent` `color` argument to `scheme`.
|
|
104
360
|
|
|
105
361
|
*Manuel Puyol*
|
|
106
362
|
|
|
@@ -120,11 +376,11 @@
|
|
|
120
376
|
|
|
121
377
|
*Manuel Puyol*
|
|
122
378
|
|
|
123
|
-
* **Breaking change
|
|
379
|
+
* **Breaking change:** Update `TabNav#tab` API to accept the tab content as a block and panel content as a slot.
|
|
124
380
|
|
|
125
381
|
*Manuel Puyol*
|
|
126
382
|
|
|
127
|
-
* **Breaking change
|
|
383
|
+
* **Breaking change:** Update `UnderlineNavComponent` API be more strict and support `TabContainer`.
|
|
128
384
|
|
|
129
385
|
*Manuel Puyol*
|
|
130
386
|
|
|
@@ -188,7 +444,7 @@
|
|
|
188
444
|
|
|
189
445
|
*Steve Richert*
|
|
190
446
|
|
|
191
|
-
* **Breaking change
|
|
447
|
+
* **Breaking change:** Updates `PopoverComponent` to use Slots V2.
|
|
192
448
|
|
|
193
449
|
*Manuel Puyol*
|
|
194
450
|
|
|
@@ -206,11 +462,11 @@
|
|
|
206
462
|
|
|
207
463
|
*Keith Cirkel*
|
|
208
464
|
|
|
209
|
-
* **Breaking change
|
|
465
|
+
* **Breaking change:** Updates `UnderlineNavComponent` to use Slots V2.
|
|
210
466
|
|
|
211
467
|
*Simon Taranto*
|
|
212
468
|
|
|
213
|
-
* **Breaking change
|
|
469
|
+
* **Breaking change:** Upgrade `LayoutComponent` to use Slots V2.
|
|
214
470
|
|
|
215
471
|
*Simon Taranto*
|
|
216
472
|
|
|
@@ -240,11 +496,11 @@
|
|
|
240
496
|
|
|
241
497
|
*Manuel Puyol*
|
|
242
498
|
|
|
243
|
-
* **Breaking change
|
|
499
|
+
* **Breaking change:** Upgrade `ProgressBarComponent` to use Slots V2.
|
|
244
500
|
|
|
245
501
|
*Simon Taranto*
|
|
246
502
|
|
|
247
|
-
* **Breaking change
|
|
503
|
+
* **Breaking change:** Upgrade `BreadcrumbComponent` to use Slots V2.
|
|
248
504
|
|
|
249
505
|
*Manuel Puyol*
|
|
250
506
|
|
|
@@ -254,11 +510,11 @@
|
|
|
254
510
|
|
|
255
511
|
*Manuel Puyol*
|
|
256
512
|
|
|
257
|
-
* **Breaking change
|
|
513
|
+
* **Breaking change:** Upgrade `SubheadComponent` to use Slots V2.
|
|
258
514
|
|
|
259
515
|
*Simon Taranto*
|
|
260
516
|
|
|
261
|
-
* **Breaking change
|
|
517
|
+
* **Breaking change:** Update `LabelComponent` to use only functional color
|
|
262
518
|
supportive scheme keys. The component no longer accepts colors (`:gray`, for
|
|
263
519
|
example) but only functional schemes (`primary`, for example).
|
|
264
520
|
`LabelComponent` is promoted to beta status.
|
|
@@ -279,29 +535,29 @@
|
|
|
279
535
|
|
|
280
536
|
*Simon Taranto*
|
|
281
537
|
|
|
282
|
-
* **Breaking change
|
|
538
|
+
* **Breaking change:** Upgrade `BorderBoxComponent` to use Slots V2.
|
|
283
539
|
|
|
284
540
|
*Manuel Puyol*
|
|
285
541
|
|
|
286
|
-
* **Breaking change
|
|
542
|
+
* **Breaking change:** Upgrade `StateComponent` to support functional colors. This change requires using [@primer/css-next](https://www.npmjs.com/package/@primer/css-next). The required changes will be upstreamed to @primer/css at a later date.
|
|
287
543
|
|
|
288
544
|
*Simon Taranto*
|
|
289
545
|
|
|
290
|
-
* **Breaking change
|
|
546
|
+
* **Breaking change:** Upgrade `DetailsComponent` to use Slots V2.
|
|
291
547
|
|
|
292
548
|
*Simon Taranto*
|
|
293
549
|
|
|
294
550
|
## 0.0.21
|
|
295
551
|
|
|
296
|
-
* **Breaking change
|
|
552
|
+
* **Breaking change:** Upgrade `FlashComponent` to use Slots V2.
|
|
297
553
|
|
|
298
554
|
*Joel Hawksley, Simon Taranto*
|
|
299
555
|
|
|
300
|
-
* **Breaking change
|
|
556
|
+
* **Breaking change:** Upgrade `BlankslateComponent` to use Slots V2.
|
|
301
557
|
|
|
302
558
|
*Manuel Puyol*
|
|
303
559
|
|
|
304
|
-
* **Breaking change
|
|
560
|
+
* **Breaking change:** Upgrade `TimelineItemComponent` to use Slots V2.
|
|
305
561
|
|
|
306
562
|
*Manuel Puyol*
|
|
307
563
|
|
|
@@ -345,7 +601,7 @@
|
|
|
345
601
|
|
|
346
602
|
*Simon Taranto*
|
|
347
603
|
|
|
348
|
-
* **Breaking change
|
|
604
|
+
* **Breaking change:** Drop support for Ruby 2.4.
|
|
349
605
|
|
|
350
606
|
*Simon Taranto*
|
|
351
607
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t=!!navigator.userAgent.match(/Macintosh/);class e{constructor(e,n){this.input=e,this.list=n,this.isComposing=!1,n.id||(n.id=`combobox-${Math.random().toString().slice(2,6)}`),this.keyboardEventHandler=e=>function(e,n){if(e.shiftKey||e.metaKey||e.altKey)return;if(!t&&e.ctrlKey)return;if(n.isComposing)return;switch(e.key){case"Enter":case"Tab":(function(t,e){const n=e.querySelector('[aria-selected="true"]');return!!n&&("true"===n.getAttribute("aria-disabled")||n.click(),!0)})(n.input,n.list)&&e.preventDefault();break;case"Escape":n.clearSelection();break;case"ArrowDown":n.navigate(1),e.preventDefault();break;case"ArrowUp":n.navigate(-1),e.preventDefault();break;case"n":t&&e.ctrlKey&&(n.navigate(1),e.preventDefault());break;case"p":t&&e.ctrlKey&&(n.navigate(-1),e.preventDefault());break;default:if(e.ctrlKey)break;n.clearSelection()}}(e,this),this.compositionEventHandler=t=>function(t,e){e.isComposing="compositionstart"===t.type;if(!document.getElementById(e.input.getAttribute("aria-controls")||""))return;e.clearSelection()}(t,this),this.inputHandler=this.clearSelection.bind(this),e.setAttribute("role","combobox"),e.setAttribute("aria-controls",n.id),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("aria-haspopup","listbox")}destroy(){this.clearSelection(),this.stop(),this.input.removeAttribute("role"),this.input.removeAttribute("aria-controls"),this.input.removeAttribute("aria-expanded"),this.input.removeAttribute("aria-autocomplete"),this.input.removeAttribute("aria-haspopup")}start(){this.input.setAttribute("aria-expanded","true"),this.input.addEventListener("compositionstart",this.compositionEventHandler),this.input.addEventListener("compositionend",this.compositionEventHandler),this.input.addEventListener("input",this.inputHandler),this.input.addEventListener("keydown",this.keyboardEventHandler),this.list.addEventListener("click",n)}stop(){this.clearSelection(),this.input.setAttribute("aria-expanded","false"),this.input.removeEventListener("compositionstart",this.compositionEventHandler),this.input.removeEventListener("compositionend",this.compositionEventHandler),this.input.removeEventListener("input",this.inputHandler),this.input.removeEventListener("keydown",this.keyboardEventHandler),this.list.removeEventListener("click",n)}navigate(t=1){const e=Array.from(this.list.querySelectorAll('[aria-selected="true"]')).filter(i)[0],n=Array.from(this.list.querySelectorAll('[role="option"]')).filter(i),o=n.indexOf(e);if(o===n.length-1&&1===t||0===o&&-1===t)return this.clearSelection(),void this.input.focus();let s=1===t?0:n.length-1;if(e&&o>=0){const e=o+t;e>=0&&e<n.length&&(s=e)}const a=n[s];if(a)for(const t of n)a===t?(this.input.setAttribute("aria-activedescendant",a.id),a.setAttribute("aria-selected","true"),r(this.list,a)):t.setAttribute("aria-selected","false")}clearSelection(){this.input.removeAttribute("aria-activedescendant");for(const t of this.list.querySelectorAll('[aria-selected="true"]'))t.setAttribute("aria-selected","false")}}function n(t){if(!(t.target instanceof Element))return;const e=t.target.closest('[role="option"]');e&&"true"!==e.getAttribute("aria-disabled")&&function(t){t.dispatchEvent(new CustomEvent("combobox-commit",{bubbles:!0}))}(e)}function i(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(t.offsetWidth>0||t.offsetHeight>0)}function r(t,e){(function(t,e){const n=t.scrollTop,i=n+t.clientHeight,r=e.offsetTop,o=r+e.clientHeight;return r>=n&&o<=i})(t,e)||(t.scrollTop=e.offsetTop)}class o extends CustomEvent{constructor(t,e){super(t,e),this.relatedTarget=e.relatedTarget}}const s=new WeakMap;function a(t,e){const n=new XMLHttpRequest;return n.open("GET",e,!0),n.setRequestHeader("Accept","text/fragment+html"),function(t,e){const n=s.get(t);n&&n.abort();s.set(t,e);const i=()=>s.delete(t),r=function(t){return new Promise(((e,n)=>{t.onload=function(){t.status>=200&&t.status<300?e(t.responseText):n(new Error(t.responseText))},t.onerror=n,t.send()}))}(e);return r.then(i,i),r}(t,n)}class c{constructor(t,n,i){this.container=t,this.input=n,this.results=i,this.combobox=new e(n,i),this.results.hidden=!0,this.input.setAttribute("autocomplete","off"),this.input.setAttribute("spellcheck","false"),this.interactingWithList=!1,this.onInputChange=function(t,e=0){let n;return function(...i){clearTimeout(n),n=window.setTimeout((()=>{clearTimeout(n),t(...i)}),e)}}(this.onInputChange.bind(this),300),this.onResultsMouseDown=this.onResultsMouseDown.bind(this),this.onInputBlur=this.onInputBlur.bind(this),this.onInputFocus=this.onInputFocus.bind(this),this.onKeydown=this.onKeydown.bind(this),this.onCommit=this.onCommit.bind(this),this.input.addEventListener("keydown",this.onKeydown),this.input.addEventListener("focus",this.onInputFocus),this.input.addEventListener("blur",this.onInputBlur),this.input.addEventListener("input",this.onInputChange),this.results.addEventListener("mousedown",this.onResultsMouseDown),this.results.addEventListener("combobox-commit",this.onCommit)}destroy(){this.input.removeEventListener("keydown",this.onKeydown),this.input.removeEventListener("focus",this.onInputFocus),this.input.removeEventListener("blur",this.onInputBlur),this.input.removeEventListener("input",this.onInputChange),this.results.removeEventListener("mousedown",this.onResultsMouseDown),this.results.removeEventListener("combobox-commit",this.onCommit)}onKeydown(t){if("Escape"===t.key&&this.container.open)this.container.open=!1,t.stopPropagation(),t.preventDefault();else if(t.altKey&&"ArrowUp"===t.key&&this.container.open)this.container.open=!1,t.stopPropagation(),t.preventDefault();else if(t.altKey&&"ArrowDown"===t.key&&!this.container.open){if(!this.input.value.trim())return;this.container.open=!0,t.stopPropagation(),t.preventDefault()}}onInputFocus(){this.fetchResults()}onInputBlur(){this.interactingWithList?this.interactingWithList=!1:this.container.open=!1}onCommit({target:t}){const e=t;if(!(e instanceof HTMLElement))return;if(this.container.open=!1,e instanceof HTMLAnchorElement)return;const n=e.getAttribute("data-autocomplete-value")||e.textContent;this.container.value=n}onResultsMouseDown(){this.interactingWithList=!0}onInputChange(){this.container.removeAttribute("value"),this.fetchResults()}identifyOptions(){let t=0;for(const e of this.results.querySelectorAll('[role="option"]:not([id])'))e.id=`${this.results.id}-option-${t++}`}fetchResults(){const t=this.input.value.trim();if(!t)return void(this.container.open=!1);const e=this.container.src;if(!e)return;const n=new URL(e,window.location.href),i=new URLSearchParams(n.search.slice(1));i.append("q",t),n.search=i.toString(),this.container.dispatchEvent(new CustomEvent("loadstart")),a(this.input,n.toString()).then((t=>{this.results.innerHTML=t,this.identifyOptions();const e=!!this.results.querySelector('[role="option"]');this.container.open=e,this.container.dispatchEvent(new CustomEvent("load")),this.container.dispatchEvent(new CustomEvent("loadend"))})).catch((()=>{this.container.dispatchEvent(new CustomEvent("error")),this.container.dispatchEvent(new CustomEvent("loadend"))}))}open(){this.results.hidden&&(this.combobox.start(),this.results.hidden=!1)}close(){this.results.hidden||(this.combobox.stop(),this.results.hidden=!0)}}const u=new WeakMap;class l extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("for");if(!t)return;const e=this.querySelector("input"),n=document.getElementById(t);e instanceof HTMLInputElement&&n&&(u.set(this,new c(this,e,n)),n.setAttribute("role","listbox"))}disconnectedCallback(){const t=u.get(this);t&&(t.destroy(),u.delete(this))}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}static get observedAttributes(){return["open","value"]}attributeChangedCallback(t,e,n){if(e===n)return;const i=u.get(this);if(i)switch(t){case"open":null===n?i.close():i.open();break;case"value":null!==n&&(i.input.value=n),this.dispatchEvent(new o("auto-complete-change",{bubbles:!0,relatedTarget:i.input}))}}}function d(t){if("clipboard"in navigator)return navigator.clipboard.writeText(t.textContent);const e=getSelection();if(null==e)return Promise.reject(new Error);e.removeAllRanges();const n=document.createRange();return n.selectNodeContents(t),e.addRange(n),document.execCommand("copy"),e.removeAllRanges(),Promise.resolve()}function h(t){if("clipboard"in navigator)return navigator.clipboard.writeText(t);const e=document.body;if(!e)return Promise.reject(new Error);const n=function(t){const e=document.createElement("pre");return e.style.width="1px",e.style.height="1px",e.style.position="fixed",e.style.top="5px",e.textContent=t,e}(t);return e.appendChild(n),d(n),e.removeChild(n),Promise.resolve()}function m(t){const e=t.getAttribute("for"),n=t.getAttribute("value");function i(){t.dispatchEvent(new CustomEvent("clipboard-copy",{bubbles:!0}))}if(n)h(n).then(i);else if(e){const n="getRootNode"in Element.prototype?t.getRootNode():t.ownerDocument;if(!(n instanceof Document||"ShadowRoot"in window&&n instanceof ShadowRoot))return;const o=n.getElementById(e);o&&(r=o,r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement?h(r.value):r instanceof HTMLAnchorElement&&r.hasAttribute("href")?h(r.href):d(r)).then(i)}var r}function p(t){const e=t.currentTarget;e instanceof HTMLElement&&m(e)}function f(t){if(" "===t.key||"Enter"===t.key){const e=t.currentTarget;e instanceof HTMLElement&&(t.preventDefault(),m(e))}}function b(t){t.currentTarget.addEventListener("keydown",f)}function g(t){t.currentTarget.removeEventListener("keydown",f)}window.customElements.get("auto-complete")||(window.AutocompleteElement=l,window.customElements.define("auto-complete",l));class w extends HTMLElement{constructor(){super(),this.addEventListener("click",p),this.addEventListener("focus",b),this.addEventListener("blur",g)}connectedCallback(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","button")}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}}function v(t){""===t.style.display||"block"===t.style.display?t.style.display="none":t.style.display="block"}function y(t){const[e,n]=t.querySelectorAll(".octicon");e&&v(e),n&&v(n)}window.customElements.get("clipboard-copy")||(window.ClipboardCopyElement=w,window.customElements.define("clipboard-copy",w)),document.addEventListener("clipboard-copy",(function({target:t}){t instanceof HTMLElement&&(y(t),setTimeout(y,2e3,t))}));class E extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(t=>{const e=t.target;if(!(e instanceof HTMLElement))return;if("tab"!==e.getAttribute("role")&&!e.closest('[role="tablist"]'))return;const n=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]')),i=n.indexOf(n.find((t=>t.matches('[aria-selected="true"]'))));if("ArrowRight"===t.code){let t=i+1;t>=n.length&&(t=0),A(this,t)}else if("ArrowLeft"===t.code){let t=i-1;t<0&&(t=n.length-1),A(this,t)}else"Home"===t.code?(A(this,0),t.preventDefault()):"End"===t.code&&(A(this,n.length-1),t.preventDefault())})),this.addEventListener("click",(t=>{const e=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]'));if(!(t.target instanceof Element))return;const n=t.target.closest('[role="tab"]');if(!n||!n.closest('[role="tablist"]'))return;A(this,e.indexOf(n))}))}connectedCallback(){for(const t of this.querySelectorAll('[role="tablist"] [role="tab"]'))t.hasAttribute("aria-selected")||t.setAttribute("aria-selected","false"),t.hasAttribute("tabindex")||("true"===t.getAttribute("aria-selected")?t.setAttribute("tabindex","0"):t.setAttribute("tabindex","-1"))}}function A(t,e){const n=t.querySelectorAll('[role="tablist"] [role="tab"]'),i=t.querySelectorAll('[role="tabpanel"]'),r=n[e],o=i[e];if(!!t.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:o}}))){for(const t of n)t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");for(const t of i)t.hidden=!0,t.hasAttribute("tabindex")||t.hasAttribute("data-tab-container-no-tabstop")||t.setAttribute("tabindex","0");r.setAttribute("aria-selected","true"),r.setAttribute("tabindex","0"),r.focus(),o.hidden=!1,t.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:o}}))}}window.customElements.get("tab-container")||(window.TabContainerElement=E,window.customElements.define("tab-container",E));const M=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],T=["January","February","March","April","May","June","July","August","September","October","November","December"];function k(t){return"0".concat(t).slice(-2)}function L(t,e){const n=t.getDay(),i=t.getDate(),r=t.getMonth(),o=t.getFullYear(),s=t.getHours(),a=t.getMinutes(),c=t.getSeconds();return e.replace(/%([%aAbBcdeHIlmMpPSwyYZz])/g,(function(e){let u;switch(e[1]){case"%":return"%";case"a":return M[n].slice(0,3);case"A":return M[n];case"b":return T[r].slice(0,3);case"B":return T[r];case"c":return t.toString();case"d":return k(i);case"e":return String(i);case"H":return k(s);case"I":return k(L(t,"%l"));case"l":return String(0===s||12===s?12:(s+12)%12);case"m":return k(r+1);case"M":return k(a);case"p":return s>11?"PM":"AM";case"P":return s>11?"pm":"am";case"S":return k(c);case"w":return String(n);case"y":return k(o%100);case"Y":return String(o);case"Z":return u=t.toString().match(/\((\w+)\)$/),u?u[1]:"";case"z":return u=t.toString().match(/\w([+-]\d\d\d\d) /),u?u[1]:""}return""}))}function x(t){let e;return function(){if(e)return e;if("Intl"in window)try{return e=new Intl.DateTimeFormat(void 0,t),e}catch(t){if(!(t instanceof RangeError))throw t}}}let C=null;const S=x({day:"numeric",month:"short"});function D(){if(null!==C)return C;const t=S();if(t){const e=t.format(new Date(0));return C=!!e.match(/^\d/),C}return!1}let H=null;const I=x({day:"numeric",month:"short",year:"numeric"});function F(t){const e=t.closest("[lang]");return e instanceof HTMLElement&&e.lang?e.lang:"default"}const R=new WeakMap;class q extends HTMLElement{static get observedAttributes(){return["datetime","day","format","lang","hour","minute","month","second","title","weekday","year"]}connectedCallback(){const t=this.getFormattedTitle();t&&!this.hasAttribute("title")&&this.setAttribute("title",t);const e=this.getFormattedDate();e&&(this.textContent=e)}attributeChangedCallback(t,e,n){const i=this.getFormattedTitle();if("datetime"===t){const t=Date.parse(n);isNaN(t)?R.delete(this):R.set(this,new Date(t))}const r=this.getFormattedTitle(),o=this.getAttribute("title");"title"===t||!r||o&&o!==i||this.setAttribute("title",r);const s=this.getFormattedDate();s&&(this.textContent=s)}get date(){return R.get(this)}getFormattedTitle(){const t=this.date;if(!t)return;const e=K();if(e)return e.format(t);try{return t.toLocaleString()}catch(e){if(e instanceof RangeError)return t.toString();throw e}}getFormattedDate(){}}const K=x({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),U=new WeakMap;class P extends q{attributeChangedCallback(t,e,n){"hour"!==t&&"minute"!==t&&"second"!==t&&"time-zone-name"!==t||U.delete(this),super.attributeChangedCallback(t,e,n)}getFormattedDate(){const t=this.date;if(!t)return;const e=function(t,e){const n={weekday:{short:"%a",long:"%A"},day:{numeric:"%e","2-digit":"%d"},month:{short:"%b",long:"%B"},year:{numeric:"%Y","2-digit":"%y"}};let i=D()?"weekday day month year":"weekday month day, year";for(const e in n){const r=n[e][t.getAttribute(e)];i=i.replace(e,r||"")}return i=i.replace(/(\s,)|(,\s$)/,""),L(e,i).replace(/\s+/," ").trim()}(this,t)||"",n=function(t,e){const n={},i=t.getAttribute("hour");"numeric"!==i&&"2-digit"!==i||(n.hour=i);const r=t.getAttribute("minute");"numeric"!==r&&"2-digit"!==r||(n.minute=r);const o=t.getAttribute("second");"numeric"!==o&&"2-digit"!==o||(n.second=o);const s=t.getAttribute("time-zone-name");"short"!==s&&"long"!==s||(n.timeZoneName=s);if(0===Object.keys(n).length)return;let a=U.get(t);a||(a=x(n),U.set(t,a));const c=a();if(c)return c.format(e);return L(e,n.second?"%H:%M:%S":"%H:%M")}(this,t)||"";return"".concat(e," ").concat(n).trim()}}window.customElements.get("local-time")||(window.LocalTimeElement=P,window.customElements.define("local-time",P));class B{constructor(t,e){this.date=t,this.locale=e}toString(){const t=this.timeElapsed();if(t)return t;{const t=this.timeAhead();return t||"on ".concat(this.formatDate())}}timeElapsed(){const t=(new Date).getTime()-this.date.getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),r=Math.round(i/24);return t>=0&&r<30?this.timeAgoFromMs(t):null}timeAhead(){const t=this.date.getTime()-(new Date).getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),r=Math.round(i/24);return t>=0&&r<30?this.timeUntil():null}timeAgo(){const t=(new Date).getTime()-this.date.getTime();return this.timeAgoFromMs(t)}timeAgoFromMs(t){const e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),r=Math.round(i/24),o=Math.round(r/30),s=Math.round(o/12);return t<0||e<10?W(this.locale,0,"second"):e<45?W(this.locale,-e,"second"):e<90||n<45?W(this.locale,-n,"minute"):n<90||i<24?W(this.locale,-i,"hour"):i<36||r<30?W(this.locale,-r,"day"):o<18?W(this.locale,-o,"month"):W(this.locale,-s,"year")}microTimeAgo(){const t=(new Date).getTime()-this.date.getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),r=Math.round(i/24),o=Math.round(r/30),s=Math.round(o/12);return n<1?"1m":n<60?"".concat(n,"m"):i<24?"".concat(i,"h"):r<365?"".concat(r,"d"):"".concat(s,"y")}timeUntil(){const t=this.date.getTime()-(new Date).getTime();return this.timeUntilFromMs(t)}timeUntilFromMs(t){const e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),r=Math.round(i/24),o=Math.round(r/30),s=Math.round(o/12);return o>=18||o>=12?W(this.locale,s,"year"):r>=45||r>=30?W(this.locale,o,"month"):i>=36||i>=24?W(this.locale,r,"day"):n>=90||n>=45?W(this.locale,i,"hour"):e>=90||e>=45?W(this.locale,n,"minute"):W(this.locale,e>=10?e:0,"second")}microTimeUntil(){const t=this.date.getTime()-(new Date).getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),r=Math.round(i/24),o=Math.round(r/30),s=Math.round(o/12);return r>=365?"".concat(s,"y"):i>=24?"".concat(r,"d"):n>=60?"".concat(i,"h"):n>1?"".concat(n,"m"):"1m"}formatDate(){let t=D()?"%e %b":"%b %e";var e;return e=this.date,(new Date).getUTCFullYear()!==e.getUTCFullYear()&&(t+=function(){if(null!==H)return H;const t=I();if(t){const e=t.format(new Date(0));return H=!!e.match(/\d,/),H}return!0}()?", %Y":" %Y"),L(this.date,t)}formatTime(){const t=N();return t?t.format(this.date):L(this.date,"%l:%M%P")}}function W(t,e,n){const i=function(t,e){if("Intl"in window&&"RelativeTimeFormat"in window.Intl)try{return new Intl.RelativeTimeFormat(t,e)}catch(t){if(!(t instanceof RangeError))throw t}}(t,{numeric:"auto"});return i?i.format(e,n):function(t,e){if(0===t)switch(e){case"year":case"quarter":case"month":case"week":return"this ".concat(e);case"day":return"today";case"hour":case"minute":return"in 0 ".concat(e,"s");case"second":return"now"}else if(1===t)switch(e){case"year":case"quarter":case"month":case"week":return"next ".concat(e);case"day":return"tomorrow";case"hour":case"minute":case"second":return"in 1 ".concat(e)}else if(-1===t)switch(e){case"year":case"quarter":case"month":case"week":return"last ".concat(e);case"day":return"yesterday";case"hour":case"minute":case"second":return"1 ".concat(e," ago")}else if(t>1)switch(e){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return"in ".concat(t," ").concat(e,"s")}else if(t<-1)switch(e){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return"".concat(-t," ").concat(e,"s ago")}throw new RangeError("Invalid unit argument for format() '".concat(e,"'"))}(e,n)}const N=x({hour:"numeric",minute:"2-digit"});class O extends q{getFormattedDate(){const t=this.date;if(t)return new B(t,F(this)).toString()}connectedCallback(){Y.push(this),$||(z(),$=setInterval(z,6e4)),super.connectedCallback()}disconnectedCallback(){const t=Y.indexOf(this);-1!==t&&Y.splice(t,1),Y.length||$&&(clearInterval($),$=null)}}const Y=[];let $;function z(){let t,e,n;for(e=0,n=Y.length;e<n;e++)t=Y[e],t.textContent=t.getFormattedDate()||""}window.customElements.get("relative-time")||(window.RelativeTimeElement=O,window.customElements.define("relative-time",O));class Z extends O{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new B(e,F(this)).microTimeAgo():new B(e,F(this)).timeAgo()}}window.customElements.get("time-ago")||(window.TimeAgoElement=Z,window.customElements.define("time-ago",Z));class j extends O{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new B(e,F(this)).microTimeUntil():new B(e,F(this)).timeUntil()}}window.customElements.get("time-until")||(window.TimeUntilElement=j,window.customElements.define("time-until",j));
|
|
1
|
+
const t=!!navigator.userAgent.match(/Macintosh/);class e{constructor(e,n){this.input=e,this.list=n,this.isComposing=!1,n.id||(n.id=`combobox-${Math.random().toString().slice(2,6)}`),this.keyboardEventHandler=e=>function(e,n){if(e.shiftKey||e.metaKey||e.altKey)return;if(!t&&e.ctrlKey)return;if(n.isComposing)return;switch(e.key){case"Enter":case"Tab":(function(t,e){const n=e.querySelector('[aria-selected="true"]');return!!n&&("true"===n.getAttribute("aria-disabled")||n.click(),!0)})(n.input,n.list)&&e.preventDefault();break;case"Escape":n.clearSelection();break;case"ArrowDown":n.navigate(1),e.preventDefault();break;case"ArrowUp":n.navigate(-1),e.preventDefault();break;case"n":t&&e.ctrlKey&&(n.navigate(1),e.preventDefault());break;case"p":t&&e.ctrlKey&&(n.navigate(-1),e.preventDefault());break;default:if(e.ctrlKey)break;n.clearSelection()}}(e,this),this.compositionEventHandler=t=>function(t,e){e.isComposing="compositionstart"===t.type;if(!document.getElementById(e.input.getAttribute("aria-controls")||""))return;e.clearSelection()}(t,this),this.inputHandler=this.clearSelection.bind(this),e.setAttribute("role","combobox"),e.setAttribute("aria-controls",n.id),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("aria-haspopup","listbox")}destroy(){this.clearSelection(),this.stop(),this.input.removeAttribute("role"),this.input.removeAttribute("aria-controls"),this.input.removeAttribute("aria-expanded"),this.input.removeAttribute("aria-autocomplete"),this.input.removeAttribute("aria-haspopup")}start(){this.input.setAttribute("aria-expanded","true"),this.input.addEventListener("compositionstart",this.compositionEventHandler),this.input.addEventListener("compositionend",this.compositionEventHandler),this.input.addEventListener("input",this.inputHandler),this.input.addEventListener("keydown",this.keyboardEventHandler),this.list.addEventListener("click",n)}stop(){this.clearSelection(),this.input.setAttribute("aria-expanded","false"),this.input.removeEventListener("compositionstart",this.compositionEventHandler),this.input.removeEventListener("compositionend",this.compositionEventHandler),this.input.removeEventListener("input",this.inputHandler),this.input.removeEventListener("keydown",this.keyboardEventHandler),this.list.removeEventListener("click",n)}navigate(t=1){const e=Array.from(this.list.querySelectorAll('[aria-selected="true"]')).filter(i)[0],n=Array.from(this.list.querySelectorAll('[role="option"]')).filter(i),o=n.indexOf(e);if(o===n.length-1&&1===t||0===o&&-1===t)return this.clearSelection(),void this.input.focus();let r=1===t?0:n.length-1;if(e&&o>=0){const e=o+t;e>=0&&e<n.length&&(r=e)}const a=n[r];if(a)for(const t of n)a===t?(this.input.setAttribute("aria-activedescendant",a.id),a.setAttribute("aria-selected","true"),s(this.list,a)):t.setAttribute("aria-selected","false")}clearSelection(){this.input.removeAttribute("aria-activedescendant");for(const t of this.list.querySelectorAll('[aria-selected="true"]'))t.setAttribute("aria-selected","false")}}function n(t){if(!(t.target instanceof Element))return;const e=t.target.closest('[role="option"]');e&&"true"!==e.getAttribute("aria-disabled")&&function(t){t.dispatchEvent(new CustomEvent("combobox-commit",{bubbles:!0}))}(e)}function i(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(t.offsetWidth>0||t.offsetHeight>0)}function s(t,e){(function(t,e){const n=t.scrollTop,i=n+t.clientHeight,s=e.offsetTop,o=s+e.clientHeight;return s>=n&&o<=i})(t,e)||(t.scrollTop=e.offsetTop)}class o extends CustomEvent{constructor(t,e){super(t,e),this.relatedTarget=e.relatedTarget}}const r=new WeakMap;function a(t,e){const n=new XMLHttpRequest;return n.open("GET",e,!0),n.setRequestHeader("Accept","text/fragment+html"),function(t,e){const n=r.get(t);n&&n.abort();r.set(t,e);const i=()=>r.delete(t),s=function(t){return new Promise(((e,n)=>{t.onload=function(){t.status>=200&&t.status<300?e(t.responseText):n(new Error(t.responseText))},t.onerror=n,t.send()}))}(e);return s.then(i,i),s}(t,n)}class c{constructor(t,n,i){this.container=t,this.input=n,this.results=i,this.combobox=new e(n,i),this.results.hidden=!0,this.input.setAttribute("autocomplete","off"),this.input.setAttribute("spellcheck","false"),this.interactingWithList=!1,this.onInputChange=function(t,e=0){let n;return function(...i){clearTimeout(n),n=window.setTimeout((()=>{clearTimeout(n),t(...i)}),e)}}(this.onInputChange.bind(this),300),this.onResultsMouseDown=this.onResultsMouseDown.bind(this),this.onInputBlur=this.onInputBlur.bind(this),this.onInputFocus=this.onInputFocus.bind(this),this.onKeydown=this.onKeydown.bind(this),this.onCommit=this.onCommit.bind(this),this.input.addEventListener("keydown",this.onKeydown),this.input.addEventListener("focus",this.onInputFocus),this.input.addEventListener("blur",this.onInputBlur),this.input.addEventListener("input",this.onInputChange),this.results.addEventListener("mousedown",this.onResultsMouseDown),this.results.addEventListener("combobox-commit",this.onCommit)}destroy(){this.input.removeEventListener("keydown",this.onKeydown),this.input.removeEventListener("focus",this.onInputFocus),this.input.removeEventListener("blur",this.onInputBlur),this.input.removeEventListener("input",this.onInputChange),this.results.removeEventListener("mousedown",this.onResultsMouseDown),this.results.removeEventListener("combobox-commit",this.onCommit)}onKeydown(t){if("Escape"===t.key&&this.container.open)this.container.open=!1,t.stopPropagation(),t.preventDefault();else if(t.altKey&&"ArrowUp"===t.key&&this.container.open)this.container.open=!1,t.stopPropagation(),t.preventDefault();else if(t.altKey&&"ArrowDown"===t.key&&!this.container.open){if(!this.input.value.trim())return;this.container.open=!0,t.stopPropagation(),t.preventDefault()}}onInputFocus(){this.fetchResults()}onInputBlur(){this.interactingWithList?this.interactingWithList=!1:this.container.open=!1}onCommit({target:t}){const e=t;if(!(e instanceof HTMLElement))return;if(this.container.open=!1,e instanceof HTMLAnchorElement)return;const n=e.getAttribute("data-autocomplete-value")||e.textContent;this.container.value=n}onResultsMouseDown(){this.interactingWithList=!0}onInputChange(){this.container.removeAttribute("value"),this.fetchResults()}identifyOptions(){let t=0;for(const e of this.results.querySelectorAll('[role="option"]:not([id])'))e.id=`${this.results.id}-option-${t++}`}fetchResults(){const t=this.input.value.trim();if(!t)return void(this.container.open=!1);const e=this.container.src;if(!e)return;const n=new URL(e,window.location.href),i=new URLSearchParams(n.search.slice(1));i.append("q",t),n.search=i.toString(),this.container.dispatchEvent(new CustomEvent("loadstart")),a(this.input,n.toString()).then((t=>{this.results.innerHTML=t,this.identifyOptions();const e=!!this.results.querySelector('[role="option"]');this.container.open=e,this.container.dispatchEvent(new CustomEvent("load")),this.container.dispatchEvent(new CustomEvent("loadend"))})).catch((()=>{this.container.dispatchEvent(new CustomEvent("error")),this.container.dispatchEvent(new CustomEvent("loadend"))}))}open(){this.results.hidden&&(this.combobox.start(),this.results.hidden=!1)}close(){this.results.hidden||(this.combobox.stop(),this.results.hidden=!0)}}const u=new WeakMap;class l extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("for");if(!t)return;const e=this.querySelector("input"),n=document.getElementById(t);e instanceof HTMLInputElement&&n&&(u.set(this,new c(this,e,n)),n.setAttribute("role","listbox"))}disconnectedCallback(){const t=u.get(this);t&&(t.destroy(),u.delete(this))}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}static get observedAttributes(){return["open","value"]}attributeChangedCallback(t,e,n){if(e===n)return;const i=u.get(this);if(i)switch(t){case"open":null===n?i.close():i.open();break;case"value":null!==n&&(i.input.value=n),this.dispatchEvent(new o("auto-complete-change",{bubbles:!0,relatedTarget:i.input}))}}}function d(t){if("clipboard"in navigator)return navigator.clipboard.writeText(t.textContent);const e=getSelection();if(null==e)return Promise.reject(new Error);e.removeAllRanges();const n=document.createRange();return n.selectNodeContents(t),e.addRange(n),document.execCommand("copy"),e.removeAllRanges(),Promise.resolve()}function h(t){if("clipboard"in navigator)return navigator.clipboard.writeText(t);const e=document.body;if(!e)return Promise.reject(new Error);const n=function(t){const e=document.createElement("pre");return e.style.width="1px",e.style.height="1px",e.style.position="fixed",e.style.top="5px",e.textContent=t,e}(t);return e.appendChild(n),d(n),e.removeChild(n),Promise.resolve()}function m(t){const e=t.getAttribute("for"),n=t.getAttribute("value");function i(){t.dispatchEvent(new CustomEvent("clipboard-copy",{bubbles:!0}))}if(n)h(n).then(i);else if(e){const n="getRootNode"in Element.prototype?t.getRootNode():t.ownerDocument;if(!(n instanceof Document||"ShadowRoot"in window&&n instanceof ShadowRoot))return;const o=n.getElementById(e);o&&(s=o,s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement?h(s.value):s instanceof HTMLAnchorElement&&s.hasAttribute("href")?h(s.href):d(s)).then(i)}var s}function f(t){const e=t.currentTarget;e instanceof HTMLElement&&m(e)}function p(t){if(" "===t.key||"Enter"===t.key){const e=t.currentTarget;e instanceof HTMLElement&&(t.preventDefault(),m(e))}}function g(t){t.currentTarget.addEventListener("keydown",p)}function b(t){t.currentTarget.removeEventListener("keydown",p)}window.customElements.get("auto-complete")||(window.AutocompleteElement=l,window.customElements.define("auto-complete",l));class w extends HTMLElement{constructor(){super(),this.addEventListener("click",f),this.addEventListener("focus",g),this.addEventListener("blur",b)}connectedCallback(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","button")}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}}window.customElements.get("clipboard-copy")||(window.ClipboardCopyElement=w,window.customElements.define("clipboard-copy",w));function v(t){""===t.style.display||"block"===t.style.display?t.style.display="none":t.style.display="block"}function y(t){const[e,n]=t.querySelectorAll(".octicon");e&&n&&(v(e),v(n))}const E=new WeakMap;document.addEventListener("clipboard-copy",(function({target:t}){if(!(t instanceof HTMLElement))return;if(!t.hasAttribute("data-view-component"))return;const e=E.get(t);e?(clearTimeout(e),E.delete(t)):y(t),E.set(t,setTimeout(y,2e3,t))}));class A extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(t=>{const e=t.target;if(!(e instanceof HTMLElement))return;if("tab"!==e.getAttribute("role")&&!e.closest('[role="tablist"]'))return;const n=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]')),i=n.indexOf(n.find((t=>t.matches('[aria-selected="true"]'))));if("ArrowRight"===t.code){let t=i+1;t>=n.length&&(t=0),M(this,t)}else if("ArrowLeft"===t.code){let t=i-1;t<0&&(t=n.length-1),M(this,t)}else"Home"===t.code?(M(this,0),t.preventDefault()):"End"===t.code&&(M(this,n.length-1),t.preventDefault())})),this.addEventListener("click",(t=>{const e=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]'));if(!(t.target instanceof Element))return;const n=t.target.closest('[role="tab"]');if(!n||!n.closest('[role="tablist"]'))return;M(this,e.indexOf(n))}))}connectedCallback(){for(const t of this.querySelectorAll('[role="tablist"] [role="tab"]'))t.hasAttribute("aria-selected")||t.setAttribute("aria-selected","false"),t.hasAttribute("tabindex")||("true"===t.getAttribute("aria-selected")?t.setAttribute("tabindex","0"):t.setAttribute("tabindex","-1"))}}function M(t,e){const n=t.querySelectorAll('[role="tablist"] [role="tab"]'),i=t.querySelectorAll('[role="tabpanel"]'),s=n[e],o=i[e];if(!!t.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:o}}))){for(const t of n)t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");for(const t of i)t.hidden=!0,t.hasAttribute("tabindex")||t.hasAttribute("data-tab-container-no-tabstop")||t.setAttribute("tabindex","0");s.setAttribute("aria-selected","true"),s.setAttribute("tabindex","0"),s.focus(),o.hidden=!1,t.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:o}}))}}window.customElements.get("tab-container")||(window.TabContainerElement=A,window.customElements.define("tab-container",A));const T=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["January","February","March","April","May","June","July","August","September","October","November","December"];function L(t){return`0${t}`.slice(-2)}function k(t,e){const n=t.getDay(),i=t.getDate(),s=t.getMonth(),o=t.getFullYear(),r=t.getHours(),a=t.getMinutes(),c=t.getSeconds();return e.replace(/%([%aAbBcdeHIlmMpPSwyYZz])/g,(function(e){let u;switch(e[1]){case"%":return"%";case"a":return T[n].slice(0,3);case"A":return T[n];case"b":return x[s].slice(0,3);case"B":return x[s];case"c":return t.toString();case"d":return L(i);case"e":return String(i);case"H":return L(r);case"I":return L(k(t,"%l"));case"l":return String(0===r||12===r?12:(r+12)%12);case"m":return L(s+1);case"M":return L(a);case"p":return r>11?"PM":"AM";case"P":return r>11?"pm":"am";case"S":return L(c);case"w":return String(n);case"y":return L(o%100);case"Y":return String(o);case"Z":return u=t.toString().match(/\((\w+)\)$/),u?u[1]:"";case"z":return u=t.toString().match(/\w([+-]\d\d\d\d) /),u?u[1]:""}return""}))}function C(t){let e;return function(){if(e)return e;if("Intl"in window)try{return e=new Intl.DateTimeFormat(void 0,t),e}catch(t){if(!(t instanceof RangeError))throw t}}}let S=null;const H=C({day:"numeric",month:"short"});function D(){if(null!==S)return S;const t=H();if(t){const e=t.format(new Date(0));return S=!!e.match(/^\d/),S}return!1}let $=null;const I=C({day:"numeric",month:"short",year:"numeric"});function R(t){const e=t.closest("[lang]");return e instanceof HTMLElement&&e.lang?e.lang:"default"}const F=new WeakMap;class Y extends HTMLElement{static get observedAttributes(){return["datetime","day","format","lang","hour","minute","month","second","title","weekday","year","time-zone-name"]}connectedCallback(){const t=this.getFormattedTitle();t&&!this.hasAttribute("title")&&this.setAttribute("title",t);const e=this.getFormattedDate();e&&(this.textContent=e)}attributeChangedCallback(t,e,n){const i=this.getFormattedTitle();if("datetime"===t){const t=Date.parse(n);isNaN(t)?F.delete(this):F.set(this,new Date(t))}const s=this.getFormattedTitle(),o=this.getAttribute("title");"title"===t||!s||o&&o!==i||this.setAttribute("title",s);const r=this.getFormattedDate();r&&(this.textContent=r)}get date(){return F.get(this)}getFormattedTitle(){const t=this.date;if(!t)return;const e=q();if(e)return e.format(t);try{return t.toLocaleString()}catch(e){if(e instanceof RangeError)return t.toString();throw e}}getFormattedDate(){}}const q=C({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),W=new WeakMap;class X extends Y{attributeChangedCallback(t,e,n){"hour"!==t&&"minute"!==t&&"second"!==t&&"time-zone-name"!==t||W.delete(this),super.attributeChangedCallback(t,e,n)}getFormattedDate(){const t=this.date;if(!t)return;return`${function(t,e){const n={weekday:{short:"%a",long:"%A"},day:{numeric:"%e","2-digit":"%d"},month:{short:"%b",long:"%B"},year:{numeric:"%Y","2-digit":"%y"}};let i=D()?"weekday day month year":"weekday month day, year";for(const e in n){const s=n[e][t.getAttribute(e)||""];i=i.replace(e,s||"")}return i=i.replace(/(\s,)|(,\s$)/,""),k(e,i).replace(/\s+/," ").trim()}(this,t)||""} ${function(t,e){const n={},i=t.getAttribute("hour");"numeric"!==i&&"2-digit"!==i||(n.hour=i);const s=t.getAttribute("minute");"numeric"!==s&&"2-digit"!==s||(n.minute=s);const o=t.getAttribute("second");"numeric"!==o&&"2-digit"!==o||(n.second=o);const r=t.getAttribute("time-zone-name");"short"!==r&&"long"!==r||(n.timeZoneName=r);if(0===Object.keys(n).length)return;let a=W.get(t);a||(a=C(n),W.set(t,a));const c=a();if(c)return c.format(e);return k(e,n.second?"%H:%M:%S":"%H:%M")}(this,t)||""}`.trim()}}window.customElements.get("local-time")||(window.LocalTimeElement=X,window.customElements.define("local-time",X));class K{constructor(t,e){this.date=t,this.locale=e}toString(){const t=this.timeElapsed();if(t)return t;{const t=this.timeAhead();return t||`on ${this.formatDate()}`}}timeElapsed(){const t=(new Date).getTime()-this.date.getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),s=Math.round(i/24);return t>=0&&s<30?this.timeAgoFromMs(t):null}timeAhead(){const t=this.date.getTime()-(new Date).getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),s=Math.round(i/24);return t>=0&&s<30?this.timeUntil():null}timeAgo(){const t=(new Date).getTime()-this.date.getTime();return this.timeAgoFromMs(t)}timeAgoFromMs(t){const e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return t<0||e<10?O(this.locale,0,"second"):e<45?O(this.locale,-e,"second"):e<90||n<45?O(this.locale,-n,"minute"):n<90||i<24?O(this.locale,-i,"hour"):i<36||s<30?O(this.locale,-s,"day"):o<18?O(this.locale,-o,"month"):O(this.locale,-r,"year")}microTimeAgo(){const t=(new Date).getTime()-this.date.getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return n<1?"1m":n<60?`${n}m`:i<24?`${i}h`:s<365?`${s}d`:`${r}y`}timeUntil(){const t=this.date.getTime()-(new Date).getTime();return this.timeUntilFromMs(t)}timeUntilFromMs(t){const e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return o>=18||o>=12?O(this.locale,r,"year"):s>=45||s>=30?O(this.locale,o,"month"):i>=36||i>=24?O(this.locale,s,"day"):n>=90||n>=45?O(this.locale,i,"hour"):e>=90||e>=45?O(this.locale,n,"minute"):O(this.locale,e>=10?e:0,"second")}microTimeUntil(){const t=this.date.getTime()-(new Date).getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return s>=365?`${r}y`:i>=24?`${s}d`:n>=60?`${i}h`:n>1?`${n}m`:"1m"}formatDate(){let t=D()?"%e %b":"%b %e";var e;return e=this.date,(new Date).getUTCFullYear()!==e.getUTCFullYear()&&(t+=function(){if(null!==$)return $;const t=I();if(t){const e=t.format(new Date(0));return $=!!e.match(/\d,/),$}return!0}()?", %Y":" %Y"),k(this.date,t)}formatTime(){const t=z();return t?t.format(this.date):k(this.date,"%l:%M%P")}}function O(t,e,n){const i=function(t,e){if("Intl"in window&&"RelativeTimeFormat"in window.Intl)try{return new Intl.RelativeTimeFormat(t,e)}catch(t){if(!(t instanceof RangeError))throw t}}(t,{numeric:"auto"});return i?i.format(e,n):function(t,e){if(0===t)switch(e){case"year":case"quarter":case"month":case"week":return`this ${e}`;case"day":return"today";case"hour":case"minute":return`in 0 ${e}s`;case"second":return"now"}else if(1===t)switch(e){case"year":case"quarter":case"month":case"week":return`next ${e}`;case"day":return"tomorrow";case"hour":case"minute":case"second":return`in 1 ${e}`}else if(-1===t)switch(e){case"year":case"quarter":case"month":case"week":return`last ${e}`;case"day":return"yesterday";case"hour":case"minute":case"second":return`1 ${e} ago`}else if(t>1)switch(e){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return`in ${t} ${e}s`}else if(t<-1)switch(e){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return`${-t} ${e}s ago`}throw new RangeError(`Invalid unit argument for format() '${e}'`)}(e,n)}const z=C({hour:"numeric",minute:"2-digit"});class U extends Y{getFormattedDate(){const t=this.date;if(t)return new K(t,R(this)).toString()}connectedCallback(){P.push(this),B||(N(),B=window.setInterval(N,6e4)),super.connectedCallback()}disconnectedCallback(){const t=P.indexOf(this);-1!==t&&P.splice(t,1),P.length||B&&(clearInterval(B),B=null)}}const P=[];let B;function N(){let t,e,n;for(e=0,n=P.length;e<n;e++)t=P[e],t.textContent=t.getFormattedDate()||""}window.customElements.get("relative-time")||(window.RelativeTimeElement=U,window.customElements.define("relative-time",U));class Z extends U{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new K(e,R(this)).microTimeAgo():new K(e,R(this)).timeAgo()}}window.customElements.get("time-ago")||(window.TimeAgoElement=Z,window.customElements.define("time-ago",Z));class j extends U{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new K(e,R(this)).microTimeUntil():new K(e,R(this)).timeUntil()}}window.customElements.get("time-until")||(window.TimeUntilElement=j,window.customElements.define("time-until",j));const J=new WeakMap,G=new WeakMap,Q=new WeakMap;function V(t){const e=t.currentTarget;if(!(e instanceof rt))return;const{box:n,image:i}=Q.get(e)||{};if(!n||!i)return;let s=0,o=0;if(t instanceof KeyboardEvent)"ArrowUp"===t.key?o=-1:"ArrowDown"===t.key?o=1:"ArrowLeft"===t.key?s=-1:"ArrowRight"===t.key&&(s=1);else if(G.has(e)&&t instanceof MouseEvent){const n=G.get(e);s=t.pageX-n.dragStartX,o=t.pageY-n.dragStartY}else if(G.has(e)&&t instanceof TouchEvent){const{pageX:n,pageY:i}=t.changedTouches[0],{dragStartX:r,dragStartY:a}=G.get(e);s=n-r,o=i-a}if(0!==s||0!==o){const t=Math.min(Math.max(0,n.offsetLeft+s),i.width-n.offsetWidth),r=Math.min(Math.max(0,n.offsetTop+o),i.height-n.offsetHeight);n.style.left=`${t}px`,n.style.top=`${r}px`,ot(e,{x:t,y:r,width:n.offsetWidth,height:n.offsetHeight})}if(t instanceof MouseEvent)G.set(e,{dragStartX:t.pageX,dragStartY:t.pageY});else if(t instanceof TouchEvent){const{pageX:n,pageY:i}=t.changedTouches[0];G.set(e,{dragStartX:n,dragStartY:i})}}function _(t){const e=t.target;if(!(e instanceof HTMLElement))return;const n=tt(e);if(!(n instanceof rt))return;const{box:i}=Q.get(n)||{};if(!i)return;const s=n.getBoundingClientRect();let o,r,a;if(t instanceof KeyboardEvent){if("Escape"===t.key)return it(n);if("-"===t.key&&(a=-10),"="===t.key&&(a=10),!a)return;o=i.offsetWidth+a,r=i.offsetHeight+a,J.set(n,{startX:i.offsetLeft,startY:i.offsetTop})}else if(t instanceof MouseEvent){const e=J.get(n);if(!e)return;o=t.pageX-e.startX-s.left-window.pageXOffset,r=t.pageY-e.startY-s.top-window.pageYOffset}else if(t instanceof TouchEvent){const e=J.get(n);if(!e)return;o=t.changedTouches[0].pageX-e.startX-s.left-window.pageXOffset,r=t.changedTouches[0].pageY-e.startY-s.top-window.pageYOffset}o&&r&&nt(n,o,r,!(t instanceof KeyboardEvent))}function tt(t){const e=t.getRootNode();return e instanceof ShadowRoot?e.host:t}function et(t){const e=t.currentTarget;if(!(e instanceof HTMLElement))return;const n=tt(e);if(!(n instanceof rt))return;const{box:i}=Q.get(n)||{};if(!i)return;const s=t.target;if(s instanceof HTMLElement)if(s.hasAttribute("data-direction")){const e=s.getAttribute("data-direction")||"";n.addEventListener("mousemove",_),n.addEventListener("touchmove",_,{passive:!0}),["nw","se"].indexOf(e)>=0&&n.classList.add("nwse"),["ne","sw"].indexOf(e)>=0&&n.classList.add("nesw"),J.set(n,{startX:i.offsetLeft+(["se","ne"].indexOf(e)>=0?0:i.offsetWidth),startY:i.offsetTop+(["se","sw"].indexOf(e)>=0?0:i.offsetHeight)}),_(t)}else n.addEventListener("mousemove",V),n.addEventListener("touchmove",V,{passive:!0})}function nt(t,e,n,i=!0){let s=Math.max(Math.abs(e),Math.abs(n),10);const o=J.get(t);if(!o)return;const{box:r,image:a}=Q.get(t)||{};if(!r||!a)return;s=Math.min(s,n>0?a.height-o.startY:o.startY,e>0?a.width-o.startX:o.startX);const c=i?Math.round(Math.max(0,e>0?o.startX:o.startX-s)):r.offsetLeft,u=i?Math.round(Math.max(0,n>0?o.startY:o.startY-s)):r.offsetTop;r.style.left=`${c}px`,r.style.top=`${u}px`,r.style.width=`${s}px`,r.style.height=`${s}px`,ot(t,{x:c,y:u,width:s,height:s})}function it(t){const{image:e}=Q.get(t)||{};if(!e)return;const n=Math.round(e.clientWidth>e.clientHeight?e.clientHeight:e.clientWidth);J.set(t,{startX:(e.clientWidth-n)/2,startY:(e.clientHeight-n)/2}),nt(t,n,n)}function st(t){const e=t.currentTarget;e instanceof rt&&(G.delete(e),e.classList.remove("nwse","nesw"),e.removeEventListener("mousemove",_),e.removeEventListener("mousemove",V),e.removeEventListener("touchmove",_),e.removeEventListener("touchmove",V))}function ot(t,e){const{image:n}=Q.get(t)||{};if(!n)return;const i=n.naturalWidth/n.width;for(const n in e){const s=Math.round(e[n]*i);e[n]=s;const o=t.querySelector(`[data-image-crop-input='${n}']`);o instanceof HTMLInputElement&&(o.value=s.toString())}t.dispatchEvent(new CustomEvent("image-crop-change",{bubbles:!0,detail:e}))}class rt extends HTMLElement{connectedCallback(){if(Q.has(this))return;const t=this.attachShadow({mode:"open"});t.innerHTML='\n<style>\n :host { touch-action: none; display: block; }\n :host(.nesw) { cursor: nesw-resize; }\n :host(.nwse) { cursor: nwse-resize; }\n :host(.nesw) .crop-box, :host(.nwse) .crop-box { cursor: inherit; }\n :host([loaded]) .crop-image { display: block; }\n :host([loaded]) ::slotted([data-loading-slot]), .crop-image { display: none; }\n\n .crop-wrapper {\n position: relative;\n font-size: 0;\n }\n .crop-container {\n user-select: none;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n overflow: hidden;\n z-index: 1;\n top: 0;\n width: 100%;\n height: 100%;\n }\n\n :host([rounded]) .crop-box {\n border-radius: 50%;\n box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.3);\n }\n .crop-box {\n position: absolute;\n border: 1px dashed #fff;\n box-sizing: border-box;\n cursor: move;\n }\n\n :host([rounded]) .crop-outline {\n outline: none;\n }\n .crop-outline {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n outline: 4000px solid rgba(0, 0, 0, .3);\n }\n\n .handle { position: absolute; }\n :host([rounded]) .handle::before { border-radius: 50%; }\n .handle:before {\n position: absolute;\n display: block;\n padding: 4px;\n transform: translate(-50%, -50%);\n content: \' \';\n background: #fff;\n border: 1px solid #767676;\n }\n .ne { top: 0; right: 0; cursor: nesw-resize; }\n .nw { top: 0; left: 0; cursor: nwse-resize; }\n .se { bottom: 0; right: 0; cursor: nwse-resize; }\n .sw { bottom: 0; left: 0; cursor: nesw-resize; }\n</style>\n<slot></slot>\n<div class="crop-wrapper">\n <img width="100%" class="crop-image" alt="">\n <div class="crop-container">\n <div data-crop-box class="crop-box">\n <div class="crop-outline"></div>\n <div data-direction="nw" class="handle nw"></div>\n <div data-direction="ne" class="handle ne"></div>\n <div data-direction="sw" class="handle sw"></div>\n <div data-direction="se" class="handle se"></div>\n </div>\n </div>\n</div>\n';const e=t.querySelector("[data-crop-box]");if(!(e instanceof HTMLElement))return;const n=t.querySelector("img");n instanceof HTMLImageElement&&(Q.set(this,{box:e,image:n}),n.addEventListener("load",(()=>{this.loaded=!0,it(this)})),this.addEventListener("mouseleave",st),this.addEventListener("touchend",st),this.addEventListener("mouseup",st),e.addEventListener("mousedown",et),e.addEventListener("touchstart",et,{passive:!0}),this.addEventListener("keydown",V),this.addEventListener("keydown",_),this.src&&(n.src=this.src))}static get observedAttributes(){return["src"]}get src(){return this.getAttribute("src")}set src(t){t?this.setAttribute("src",t):this.removeAttribute("src")}get loaded(){return this.hasAttribute("loaded")}set loaded(t){t?this.setAttribute("loaded",""):this.removeAttribute("loaded")}attributeChangedCallback(t,e,n){const{image:i}=Q.get(this)||{};"src"===t&&(this.loaded=!1,i&&(i.src=n))}}window.customElements.get("image-crop")||(window.ImageCropElement=rt,window.customElements.define("image-crop",rt));
|
|
2
2
|
//# sourceMappingURL=primer_view_components.js.map
|