@dumiflex/wp-kit 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CHANGELOG.md +92 -51
  2. package/LICENSE +674 -674
  3. package/README.md +73 -76
  4. package/package.json +78 -77
  5. package/src/Avatar.vue +83 -83
  6. package/src/Badge.vue +97 -97
  7. package/src/Banner.vue +118 -118
  8. package/src/BookmarkButton.vue +27 -27
  9. package/src/BundleMeta.vue +51 -51
  10. package/src/Button.vue +103 -103
  11. package/src/Card.vue +68 -68
  12. package/src/Checkbox.vue +109 -107
  13. package/src/Chip.vue +163 -97
  14. package/src/ChoiceCards.vue +133 -133
  15. package/src/CloseButton.vue +69 -69
  16. package/src/CodeBlock.vue +146 -119
  17. package/src/ColorField.vue +188 -206
  18. package/src/ColorPicker.vue +201 -201
  19. package/src/Combobox.vue +331 -334
  20. package/src/ConfirmDialog.vue +165 -163
  21. package/src/ConfirmModal.vue +147 -147
  22. package/src/ConstraintMatrixPreview.vue +708 -708
  23. package/src/ContextMenu.vue +386 -379
  24. package/src/CopyButton.vue +156 -156
  25. package/src/DataTable.vue +293 -292
  26. package/src/DatePicker.vue +234 -234
  27. package/src/DescriptionList.vue +73 -73
  28. package/src/DiffView.vue +68 -68
  29. package/src/Disclosure.vue +166 -166
  30. package/src/DragHandle.vue +49 -49
  31. package/src/Drawer.vue +131 -131
  32. package/src/DropZone.vue +196 -196
  33. package/src/DropdownMenu.vue +72 -72
  34. package/src/EmptyState.vue +111 -111
  35. package/src/Field.vue +28 -28
  36. package/src/HsvPicker.vue +208 -208
  37. package/src/Icon.vue +39 -39
  38. package/src/IconPicker.vue +209 -209
  39. package/src/ImageGrid.vue +127 -125
  40. package/src/InlineEdit.vue +183 -183
  41. package/src/Input.vue +99 -99
  42. package/src/Kbd.vue +56 -56
  43. package/src/Lightbox.vue +176 -173
  44. package/src/ListFilter.vue +85 -85
  45. package/src/ListRow.vue +204 -204
  46. package/src/LoadingMark.vue +217 -161
  47. package/src/Logo.vue +60 -60
  48. package/src/Modal.vue +78 -76
  49. package/src/ModalShell.vue +109 -107
  50. package/src/Pagination.vue +106 -106
  51. package/src/Popover.vue +180 -171
  52. package/src/PostCard.vue +210 -211
  53. package/src/ProgressBar.vue +90 -90
  54. package/src/RadioGroup.vue +177 -177
  55. package/src/RangeSlider.vue +183 -183
  56. package/src/RelativeDate.vue +35 -35
  57. package/src/ResizeHandle.vue +143 -143
  58. package/src/SearchInput.vue +192 -199
  59. package/src/Select.vue +644 -641
  60. package/src/Separator.vue +54 -54
  61. package/src/Skeleton.vue +98 -82
  62. package/src/Slider.vue +198 -198
  63. package/src/SortableList.vue +260 -260
  64. package/src/SplitPane.vue +68 -68
  65. package/src/StarButton.vue +40 -40
  66. package/src/Stepper.vue +141 -141
  67. package/src/SupportLinks.vue +93 -93
  68. package/src/TagInput.vue +297 -300
  69. package/src/Textarea.vue +57 -57
  70. package/src/Timeline.vue +92 -92
  71. package/src/ToastCard.vue +119 -119
  72. package/src/ToastHost.vue +40 -40
  73. package/src/Toggle.vue +36 -36
  74. package/src/TokenizedValue.vue +310 -310
  75. package/src/Toolbar.vue +110 -110
  76. package/src/VirtualList.vue +87 -87
  77. package/src/VisuallyHidden.vue +29 -29
  78. package/src/WpButton.vue +75 -75
  79. package/src/WpCheck.vue +104 -102
  80. package/src/WpIconButton.vue +107 -107
  81. package/src/WpImageZoom.vue +544 -544
  82. package/src/WpNumber.vue +178 -183
  83. package/src/WpSegmented.vue +175 -175
  84. package/src/WpSelect.vue +93 -89
  85. package/src/WpSwitch.vue +163 -163
  86. package/src/WpTabs.vue +188 -188
  87. package/src/_modal-motion.css +33 -33
  88. package/src/_skeleton.css +50 -50
  89. package/src/axis-color.ts +42 -42
  90. package/src/button.css +169 -169
  91. package/src/calendar.ts +59 -59
  92. package/src/clipboard.ts +50 -50
  93. package/src/colour-presets.ts +12 -12
  94. package/src/diff.ts +51 -51
  95. package/src/drop-zone.ts +41 -41
  96. package/src/field.css +50 -0
  97. package/src/flip.ts +237 -237
  98. package/src/floating-layer.ts +48 -0
  99. package/src/floating.ts +99 -99
  100. package/src/highlight.ts +199 -0
  101. package/src/hsv.ts +100 -100
  102. package/src/icon-catalog.ts +52 -52
  103. package/src/image-zoom.ts +93 -93
  104. package/src/kind-colour.ts +28 -0
  105. package/src/loading-mark-motion.ts +249 -0
  106. package/src/logo-paths.ts +21 -21
  107. package/src/matrix-axis.ts +91 -91
  108. package/src/pagination.ts +27 -27
  109. package/src/platform-keys.ts +29 -29
  110. package/src/rich-tokenize.ts +357 -357
  111. package/src/select-types.ts +32 -32
  112. package/src/slider-math.ts +45 -45
  113. package/src/sortable.ts +22 -22
  114. package/src/theme/fonts/OFL-Fraunces.txt +93 -93
  115. package/src/theme/fonts/OFL-JetBrainsMono.txt +93 -93
  116. package/src/theme/fonts/OFL-Manrope.txt +93 -93
  117. package/src/theme/looks.css +428 -428
  118. package/src/theme/palettes.css +254 -254
  119. package/src/theme/tokens.css +2896 -2894
  120. package/src/tokens.ts +56 -56
  121. package/src/tooltip.css +43 -43
  122. package/src/tooltip.ts +146 -146
  123. package/src/useDialogFocus.ts +73 -73
  124. package/src/useGrowableField.ts +357 -357
  125. package/src/useModalKeyShield.ts +116 -116
  126. package/src/useToast.ts +48 -48
  127. package/src/wp-logo.svg +14 -14
  128. package/src/ChipToggle.vue +0 -92
  129. package/src/KindChip.vue +0 -53
  130. package/src/RatingBadge.vue +0 -42
@@ -1,234 +1,234 @@
1
- <script setup lang="ts">
2
- /**
3
- * A date field: the button shows the picked day; it opens a month grid in
4
- * a kit Popover. The value is a "YYYY-MM-DD" string (a calendar day, no
5
- * time zone) or null.
6
- *
7
- * <DatePicker v-model="since" aria-label="Changed since" clearable />
8
- * <DatePicker v-model="day" :min="firstRun" :max="today" />
9
- *
10
- * APG date picker dialog: the grid is one Tab stop; arrows move a day or a
11
- * week, PageUp / PageDown a month (Shift: a year), Home / End to the start
12
- * or end of the week, Enter or Space picks, Escape closes and gives focus
13
- * back to the button. Days outside `min` / `max` can't be picked.
14
- */
15
- import { computed, nextTick, ref, useId, watch } from "vue";
16
- import Popover from "./Popover.vue";
17
- import {
18
- addDays, addMonths, compareYmd, fromDate, monthGrid, parseYmd, toYmd, weekdayNames, type Ymd,
19
- } from "./calendar";
20
-
21
- const props = withDefaults(defineProps<{
22
- modelValue: string | null;
23
- min?: string | undefined;
24
- max?: string | undefined;
25
- placeholder?: string | undefined;
26
- size?: "sm" | "md" | "lg" | undefined;
27
- disabled?: boolean | undefined;
28
- invalid?: boolean | undefined;
29
- ariaLabel?: string | undefined;
30
- clearable?: boolean | undefined;
31
- /** 0 = Sunday, 1 = Monday. */
32
- weekStart?: 0 | 1 | undefined;
33
- /** Language for month and day names; the browser's by default. */
34
- locale?: string | undefined;
35
- }>(), {
36
- min: undefined, max: undefined, placeholder: "Pick a date", size: "md",
37
- ariaLabel: "Date", weekStart: 1, locale: undefined,
38
- });
39
-
40
- const emit = defineEmits<{ (e: "update:modelValue", v: string | null): void }>();
41
-
42
- const uid = useId();
43
- const gridId = `wp-date-grid-${uid}`;
44
- const titleId = `wp-date-title-${uid}`;
45
- const open = ref(false);
46
- const gridEl = ref<HTMLElement | null>(null);
47
-
48
- const value = computed(() => parseYmd(props.modelValue));
49
- const lo = computed(() => parseYmd(props.min));
50
- const hi = computed(() => parseYmd(props.max));
51
- const today = fromDate(new Date());
52
-
53
- /** The day with the keyboard focus; the shown month follows it. */
54
- const focus = ref<Ymd>(value.value ?? today);
55
- const days = computed(() => monthGrid(focus.value.y, focus.value.m, props.weekStart));
56
- const weeks = computed(() => Array.from({ length: 6 }, (_, w) => days.value.slice(w * 7, w * 7 + 7)));
57
- const names = computed(() => weekdayNames(props.weekStart, props.locale));
58
- const title = computed(() => new Date(focus.value.y, focus.value.m, 1)
59
- .toLocaleDateString(props.locale, { month: "long", year: "numeric" }));
60
-
61
- const shown = computed(() => (value.value
62
- ? new Date(value.value.y, value.value.m, value.value.d).toLocaleDateString(props.locale, { day: "numeric", month: "short", year: "numeric" })
63
- : ""));
64
-
65
- const same = (a: Ymd | null, b: Ymd): boolean => !!a && compareYmd(a, b) === 0;
66
- const outOfRange = (v: Ymd): boolean => (!!lo.value && compareYmd(v, lo.value) < 0) || (!!hi.value && compareYmd(v, hi.value) > 0);
67
- const clamp = (v: Ymd): Ymd => (lo.value && compareYmd(v, lo.value) < 0 ? lo.value : hi.value && compareYmd(v, hi.value) > 0 ? hi.value : v);
68
- const long = (v: Ymd): string => new Date(v.y, v.m, v.d).toLocaleDateString(props.locale, { weekday: "long", day: "numeric", month: "long", year: "numeric" });
69
-
70
- function focusDay(): void {
71
- void nextTick(() => gridEl.value?.querySelector<HTMLElement>('[tabindex="0"]')?.focus());
72
- }
73
-
74
- watch(open, (v) => {
75
- if (!v) return;
76
- focus.value = clamp(value.value ?? today);
77
- focusDay();
78
- });
79
-
80
- function pick(v: Ymd): void {
81
- if (outOfRange(v)) return;
82
- emit("update:modelValue", toYmd(v));
83
- open.value = false;
84
- }
85
-
86
- function move(v: Ymd): void {
87
- focus.value = clamp(v);
88
- focusDay();
89
- }
90
-
91
- function shiftMonth(n: number): void {
92
- move(addMonths(focus.value, n));
93
- }
94
-
95
- function onGridKey(ev: KeyboardEvent): void {
96
- const f = focus.value;
97
- const dow = (new Date(f.y, f.m, f.d).getDay() - props.weekStart + 7) % 7;
98
- const to: Record<string, () => Ymd> = {
99
- ArrowLeft: () => addDays(f, -1),
100
- ArrowRight: () => addDays(f, 1),
101
- ArrowUp: () => addDays(f, -7),
102
- ArrowDown: () => addDays(f, 7),
103
- Home: () => addDays(f, -dow),
104
- End: () => addDays(f, 6 - dow),
105
- PageUp: () => addMonths(f, ev.shiftKey ? -12 : -1),
106
- PageDown: () => addMonths(f, ev.shiftKey ? 12 : 1),
107
- };
108
- if (to[ev.key]) {
109
- ev.preventDefault();
110
- move(to[ev.key]());
111
- } else if (ev.key === "Enter" || ev.key === " ") {
112
- ev.preventDefault();
113
- pick(f);
114
- }
115
- }
116
-
117
- function clear(): void {
118
- emit("update:modelValue", null);
119
- }
120
- </script>
121
-
122
- <!-- Popover's autofocus prop is off: focus goes to the picked day, not the first button. -->
123
- <!-- eslint-disable vuejs-accessibility/no-autofocus -->
124
- <template>
125
- <span class="wp-date" :data-size="size">
126
- <Popover v-model:open="open" :autofocus="false" :label="ariaLabel">
127
- <template #trigger="{ props: tp }">
128
- <button
129
- type="button"
130
- class="wp-date__field"
131
- :data-invalid="invalid || undefined"
132
- :disabled="disabled"
133
- :aria-label="shown ? `${ariaLabel}: ${shown}` : ariaLabel"
134
- v-bind="tp"
135
- >
136
- <i class="pi pi-calendar wp-date__icon" aria-hidden="true" />
137
- <span :class="shown ? 'wp-date__text' : 'wp-date__placeholder'">{{ shown || placeholder }}</span>
138
- </button>
139
- </template>
140
- <div class="wp-date__panel">
141
- <div class="wp-date__head">
142
- <button type="button" class="wp-date__nav" aria-label="Previous month" @click="shiftMonth(-1)">
143
- <i class="pi pi-chevron-left" aria-hidden="true" />
144
- </button>
145
- <span :id="titleId" class="wp-date__title" aria-live="polite">{{ title }}</span>
146
- <button type="button" class="wp-date__nav" aria-label="Next month" @click="shiftMonth(1)">
147
- <i class="pi pi-chevron-right" aria-hidden="true" />
148
- </button>
149
- </div>
150
- <!-- The grid is reached through its days (roving tabindex); it only listens for their keys. -->
151
- <!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions, vuejs-accessibility/interactive-supports-focus -->
152
- <table :id="gridId" ref="gridEl" class="wp-date__grid" role="grid" :aria-labelledby="titleId" @keydown="onGridKey">
153
- <thead>
154
- <tr>
155
- <th v-for="n in names" :key="n.long" scope="col" :abbr="n.long">{{ n.short }}</th>
156
- </tr>
157
- </thead>
158
- <tbody>
159
- <tr v-for="(week, w) in weeks" :key="w">
160
- <td
161
- v-for="d in week"
162
- :key="toYmd(d)"
163
- class="wp-date__day"
164
- :tabindex="same(focus, d) ? 0 : -1"
165
- :aria-selected="same(value, d)"
166
- :aria-disabled="outOfRange(d) || undefined"
167
- :aria-label="long(d)"
168
- :aria-current="same(today, d) ? 'date' : undefined"
169
- :data-other="d.m !== focus.m || undefined"
170
- :data-today="same(today, d) || undefined"
171
- @click="pick(d)"
172
- >{{ d.d }}</td>
173
- </tr>
174
- </tbody>
175
- </table>
176
- <div class="wp-date__foot">
177
- <button type="button" class="wp-date__link" :disabled="outOfRange(today)" @click="pick(today)">Today</button>
178
- <button v-if="clearable && modelValue" type="button" class="wp-date__link" @click="clear(); open = false">Clear</button>
179
- </div>
180
- </div>
181
- </Popover>
182
- </span>
183
- </template>
184
-
185
- <style scoped>
186
- .wp-date { display: inline-flex; --_h: var(--wp-control-h-md); }
187
- .wp-date[data-size="sm"] { --_h: var(--wp-control-h-sm); }
188
- .wp-date[data-size="lg"] { --_h: var(--wp-control-h-lg); }
189
- .wp-date__field {
190
- display: inline-flex; align-items: center; gap: var(--wp-space-2); box-sizing: border-box;
191
- min-width: 150px; height: var(--_h); padding: 0 var(--wp-space-3);
192
- border: 1px solid var(--wp-border); border-radius: var(--wp-radius);
193
- background: var(--wp-bg-1); color: var(--wp-text); cursor: pointer;
194
- font: 400 var(--wp-text-sm)/1 var(--wp-font-sans); text-align: left;
195
- transition: border-color var(--wp-motion-hover), box-shadow var(--wp-motion-hover);
196
- }
197
- .wp-date[data-size="sm"] .wp-date__field { min-width: 120px; padding: 0 var(--wp-space-2); border-radius: var(--wp-radius-sm); font-size: var(--wp-text-xs); }
198
- .wp-date__field:hover:not(:disabled) { border-color: var(--wp-border-strong); }
199
- .wp-date__field:focus-visible { outline: none; border-color: var(--wp-border-focus); box-shadow: 0 0 0 3px var(--wp-focus-ring); }
200
- .wp-date__field[data-invalid] { border-color: var(--wp-error-border); }
201
- .wp-date__field:disabled { opacity: 0.45; cursor: not-allowed; }
202
- .wp-date__icon { color: var(--wp-text-muted); font-size: 12px; }
203
- .wp-date__placeholder { color: var(--wp-text-dim); }
204
- .wp-date__panel { display: flex; flex-direction: column; gap: var(--wp-space-2); }
205
- .wp-date__head { display: flex; align-items: center; justify-content: space-between; gap: var(--wp-space-2); }
206
- .wp-date__title { font-weight: 600; color: var(--wp-text); }
207
- .wp-date__nav, .wp-date__link {
208
- display: inline-grid; place-items: center; height: var(--wp-control-h-sm); min-width: var(--wp-control-h-sm);
209
- padding: 0 var(--wp-space-2); border: 0; border-radius: var(--wp-radius-sm);
210
- background: transparent; color: var(--wp-text-muted); cursor: pointer; font: inherit;
211
- }
212
- .wp-date__nav .pi { font-size: 11px; }
213
- .wp-date__nav:hover, .wp-date__link:hover:not(:disabled) { background: var(--wp-row-hover); color: var(--wp-text); }
214
- .wp-date__nav:focus-visible, .wp-date__link:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--wp-border-focus); }
215
- .wp-date__link:disabled { opacity: 0.45; cursor: not-allowed; }
216
- .wp-date__grid { border-collapse: collapse; }
217
- .wp-date__grid th {
218
- width: 32px; height: 24px; color: var(--wp-text-muted); font-size: var(--wp-text-xs); font-weight: 500;
219
- }
220
- .wp-date__day {
221
- width: 32px; height: 30px; padding: 0; text-align: center; border-radius: var(--wp-radius-sm);
222
- color: var(--wp-text); font-variant-numeric: tabular-nums; cursor: pointer;
223
- }
224
- .wp-date__day[data-other] { color: var(--wp-text-dim); }
225
- .wp-date__day[data-today] { box-shadow: inset 0 0 0 1px var(--wp-border-strong); }
226
- .wp-date__day:hover { background: var(--wp-row-hover); }
227
- .wp-date__day[aria-selected="true"] { background: var(--wp-accent); color: var(--wp-bg); }
228
- .wp-date__day[aria-disabled="true"] { opacity: 0.35; cursor: not-allowed; background: transparent; text-decoration: line-through; }
229
- .wp-date__day:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--wp-border-focus); }
230
- .wp-date__foot { display: flex; justify-content: space-between; }
231
- @media (prefers-reduced-motion: reduce) {
232
- .wp-date__field { transition: none; }
233
- }
234
- </style>
1
+ <script setup lang="ts">
2
+ /**
3
+ * A date field: the button shows the picked day; it opens a month grid in
4
+ * a kit Popover. The value is a "YYYY-MM-DD" string (a calendar day, no
5
+ * time zone) or null.
6
+ *
7
+ * <DatePicker v-model="since" aria-label="Changed since" clearable />
8
+ * <DatePicker v-model="day" :min="firstRun" :max="today" />
9
+ *
10
+ * APG date picker dialog: the grid is one Tab stop; arrows move a day or a
11
+ * week, PageUp / PageDown a month (Shift: a year), Home / End to the start
12
+ * or end of the week, Enter or Space picks, Escape closes and gives focus
13
+ * back to the button. Days outside `min` / `max` can't be picked.
14
+ */
15
+ import { computed, nextTick, ref, useId, watch } from "vue";
16
+ import Popover from "./Popover.vue";
17
+ import {
18
+ addDays, addMonths, compareYmd, fromDate, monthGrid, parseYmd, toYmd, weekdayNames, type Ymd,
19
+ } from "./calendar";
20
+
21
+ const props = withDefaults(defineProps<{
22
+ modelValue: string | null;
23
+ min?: string | undefined;
24
+ max?: string | undefined;
25
+ placeholder?: string | undefined;
26
+ size?: "sm" | "md" | "lg" | undefined;
27
+ disabled?: boolean | undefined;
28
+ invalid?: boolean | undefined;
29
+ ariaLabel?: string | undefined;
30
+ clearable?: boolean | undefined;
31
+ /** 0 = Sunday, 1 = Monday. */
32
+ weekStart?: 0 | 1 | undefined;
33
+ /** Language for month and day names; the browser's by default. */
34
+ locale?: string | undefined;
35
+ }>(), {
36
+ min: undefined, max: undefined, placeholder: "Pick a date", size: "md",
37
+ ariaLabel: "Date", weekStart: 1, locale: undefined,
38
+ });
39
+
40
+ const emit = defineEmits<{ (e: "update:modelValue", v: string | null): void }>();
41
+
42
+ const uid = useId();
43
+ const gridId = `wp-date-grid-${uid}`;
44
+ const titleId = `wp-date-title-${uid}`;
45
+ const open = ref(false);
46
+ const gridEl = ref<HTMLElement | null>(null);
47
+
48
+ const value = computed(() => parseYmd(props.modelValue));
49
+ const lo = computed(() => parseYmd(props.min));
50
+ const hi = computed(() => parseYmd(props.max));
51
+ const today = fromDate(new Date());
52
+
53
+ /** The day with the keyboard focus; the shown month follows it. */
54
+ const focus = ref<Ymd>(value.value ?? today);
55
+ const days = computed(() => monthGrid(focus.value.y, focus.value.m, props.weekStart));
56
+ const weeks = computed(() => Array.from({ length: 6 }, (_, w) => days.value.slice(w * 7, w * 7 + 7)));
57
+ const names = computed(() => weekdayNames(props.weekStart, props.locale));
58
+ const title = computed(() => new Date(focus.value.y, focus.value.m, 1)
59
+ .toLocaleDateString(props.locale, { month: "long", year: "numeric" }));
60
+
61
+ const shown = computed(() => (value.value
62
+ ? new Date(value.value.y, value.value.m, value.value.d).toLocaleDateString(props.locale, { day: "numeric", month: "short", year: "numeric" })
63
+ : ""));
64
+
65
+ const same = (a: Ymd | null, b: Ymd): boolean => !!a && compareYmd(a, b) === 0;
66
+ const outOfRange = (v: Ymd): boolean => (!!lo.value && compareYmd(v, lo.value) < 0) || (!!hi.value && compareYmd(v, hi.value) > 0);
67
+ const clamp = (v: Ymd): Ymd => (lo.value && compareYmd(v, lo.value) < 0 ? lo.value : hi.value && compareYmd(v, hi.value) > 0 ? hi.value : v);
68
+ const long = (v: Ymd): string => new Date(v.y, v.m, v.d).toLocaleDateString(props.locale, { weekday: "long", day: "numeric", month: "long", year: "numeric" });
69
+
70
+ function focusDay(): void {
71
+ void nextTick(() => gridEl.value?.querySelector<HTMLElement>('[tabindex="0"]')?.focus());
72
+ }
73
+
74
+ watch(open, (v) => {
75
+ if (!v) return;
76
+ focus.value = clamp(value.value ?? today);
77
+ focusDay();
78
+ });
79
+
80
+ function pick(v: Ymd): void {
81
+ if (outOfRange(v)) return;
82
+ emit("update:modelValue", toYmd(v));
83
+ open.value = false;
84
+ }
85
+
86
+ function move(v: Ymd): void {
87
+ focus.value = clamp(v);
88
+ focusDay();
89
+ }
90
+
91
+ function shiftMonth(n: number): void {
92
+ move(addMonths(focus.value, n));
93
+ }
94
+
95
+ function onGridKey(ev: KeyboardEvent): void {
96
+ const f = focus.value;
97
+ const dow = (new Date(f.y, f.m, f.d).getDay() - props.weekStart + 7) % 7;
98
+ const to: Record<string, () => Ymd> = {
99
+ ArrowLeft: () => addDays(f, -1),
100
+ ArrowRight: () => addDays(f, 1),
101
+ ArrowUp: () => addDays(f, -7),
102
+ ArrowDown: () => addDays(f, 7),
103
+ Home: () => addDays(f, -dow),
104
+ End: () => addDays(f, 6 - dow),
105
+ PageUp: () => addMonths(f, ev.shiftKey ? -12 : -1),
106
+ PageDown: () => addMonths(f, ev.shiftKey ? 12 : 1),
107
+ };
108
+ if (to[ev.key]) {
109
+ ev.preventDefault();
110
+ move(to[ev.key]());
111
+ } else if (ev.key === "Enter" || ev.key === " ") {
112
+ ev.preventDefault();
113
+ pick(f);
114
+ }
115
+ }
116
+
117
+ function clear(): void {
118
+ emit("update:modelValue", null);
119
+ }
120
+ </script>
121
+
122
+ <!-- Popover's autofocus prop is off: focus goes to the picked day, not the first button. -->
123
+ <!-- eslint-disable vuejs-accessibility/no-autofocus -->
124
+ <template>
125
+ <span class="wp-date" :data-size="size">
126
+ <Popover v-model:open="open" :autofocus="false" :label="ariaLabel">
127
+ <template #trigger="{ props: tp }">
128
+ <button
129
+ type="button"
130
+ class="wp-date__field"
131
+ :data-invalid="invalid || undefined"
132
+ :disabled="disabled"
133
+ :aria-label="shown ? `${ariaLabel}: ${shown}` : ariaLabel"
134
+ v-bind="tp"
135
+ >
136
+ <i class="pi pi-calendar wp-date__icon" aria-hidden="true" />
137
+ <span :class="shown ? 'wp-date__text' : 'wp-date__placeholder'">{{ shown || placeholder }}</span>
138
+ </button>
139
+ </template>
140
+ <div class="wp-date__panel">
141
+ <div class="wp-date__head">
142
+ <button type="button" class="wp-date__nav" aria-label="Previous month" @click="shiftMonth(-1)">
143
+ <i class="pi pi-chevron-left" aria-hidden="true" />
144
+ </button>
145
+ <span :id="titleId" class="wp-date__title" aria-live="polite">{{ title }}</span>
146
+ <button type="button" class="wp-date__nav" aria-label="Next month" @click="shiftMonth(1)">
147
+ <i class="pi pi-chevron-right" aria-hidden="true" />
148
+ </button>
149
+ </div>
150
+ <!-- The grid is reached through its days (roving tabindex); it only listens for their keys. -->
151
+ <!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions, vuejs-accessibility/interactive-supports-focus -->
152
+ <table :id="gridId" ref="gridEl" class="wp-date__grid" role="grid" :aria-labelledby="titleId" @keydown="onGridKey">
153
+ <thead>
154
+ <tr>
155
+ <th v-for="n in names" :key="n.long" scope="col" :abbr="n.long">{{ n.short }}</th>
156
+ </tr>
157
+ </thead>
158
+ <tbody>
159
+ <tr v-for="(week, w) in weeks" :key="w">
160
+ <td
161
+ v-for="d in week"
162
+ :key="toYmd(d)"
163
+ class="wp-date__day"
164
+ :tabindex="same(focus, d) ? 0 : -1"
165
+ :aria-selected="same(value, d)"
166
+ :aria-disabled="outOfRange(d) || undefined"
167
+ :aria-label="long(d)"
168
+ :aria-current="same(today, d) ? 'date' : undefined"
169
+ :data-other="d.m !== focus.m || undefined"
170
+ :data-today="same(today, d) || undefined"
171
+ @click="pick(d)"
172
+ >{{ d.d }}</td>
173
+ </tr>
174
+ </tbody>
175
+ </table>
176
+ <div class="wp-date__foot">
177
+ <button type="button" class="wp-date__link" :disabled="outOfRange(today)" @click="pick(today)">Today</button>
178
+ <button v-if="clearable && modelValue" type="button" class="wp-date__link" @click="clear(); open = false">Clear</button>
179
+ </div>
180
+ </div>
181
+ </Popover>
182
+ </span>
183
+ </template>
184
+
185
+ <style scoped>
186
+ .wp-date { display: inline-flex; --_h: var(--wp-control-h-md); }
187
+ .wp-date[data-size="sm"] { --_h: var(--wp-control-h-sm); }
188
+ .wp-date[data-size="lg"] { --_h: var(--wp-control-h-lg); }
189
+ .wp-date__field {
190
+ display: inline-flex; align-items: center; gap: var(--wp-space-2); box-sizing: border-box;
191
+ min-width: 150px; height: var(--_h); padding: 0 var(--wp-space-3);
192
+ border: 1px solid var(--wp-border); border-radius: var(--wp-radius);
193
+ background: var(--wp-bg-1); color: var(--wp-text); cursor: pointer;
194
+ font: 400 var(--wp-text-sm)/1 var(--wp-font-sans); text-align: left;
195
+ transition: border-color var(--wp-motion-hover), box-shadow var(--wp-motion-hover);
196
+ }
197
+ .wp-date[data-size="sm"] .wp-date__field { min-width: 120px; padding: 0 var(--wp-space-2); border-radius: var(--wp-radius-sm); font-size: var(--wp-text-xs); }
198
+ .wp-date__field:hover:not(:disabled) { border-color: var(--wp-border-strong); }
199
+ .wp-date__field:focus-visible { outline: none; border-color: var(--wp-border-focus); box-shadow: var(--wp-focus-ring); }
200
+ .wp-date__field[data-invalid] { border-color: var(--wp-error-border); }
201
+ .wp-date__field:disabled { opacity: 0.45; cursor: not-allowed; }
202
+ .wp-date__icon { color: var(--wp-text-muted); font-size: 12px; }
203
+ .wp-date__placeholder { color: var(--wp-text-dim); }
204
+ .wp-date__panel { display: flex; flex-direction: column; gap: var(--wp-space-2); }
205
+ .wp-date__head { display: flex; align-items: center; justify-content: space-between; gap: var(--wp-space-2); }
206
+ .wp-date__title { font-weight: 600; color: var(--wp-text); }
207
+ .wp-date__nav, .wp-date__link {
208
+ display: inline-grid; place-items: center; height: var(--wp-control-h-sm); min-width: var(--wp-control-h-sm);
209
+ padding: 0 var(--wp-space-2); border: 0; border-radius: var(--wp-radius-sm);
210
+ background: transparent; color: var(--wp-text-muted); cursor: pointer; font: inherit;
211
+ }
212
+ .wp-date__nav .pi { font-size: 11px; }
213
+ .wp-date__nav:hover, .wp-date__link:hover:not(:disabled) { background: var(--wp-row-hover); color: var(--wp-text); }
214
+ .wp-date__nav:focus-visible, .wp-date__link:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--wp-border-focus); }
215
+ .wp-date__link:disabled { opacity: 0.45; cursor: not-allowed; }
216
+ .wp-date__grid { border-collapse: collapse; }
217
+ .wp-date__grid th {
218
+ width: 32px; height: 24px; color: var(--wp-text-muted); font-size: var(--wp-text-xs); font-weight: 500;
219
+ }
220
+ .wp-date__day {
221
+ width: 32px; height: 30px; padding: 0; text-align: center; border-radius: var(--wp-radius-sm);
222
+ color: var(--wp-text); font-variant-numeric: tabular-nums; cursor: pointer;
223
+ }
224
+ .wp-date__day[data-other] { color: var(--wp-text-dim); }
225
+ .wp-date__day[data-today] { box-shadow: inset 0 0 0 1px var(--wp-border-strong); }
226
+ .wp-date__day:hover { background: var(--wp-row-hover); }
227
+ .wp-date__day[aria-selected="true"] { background: var(--wp-accent); color: var(--wp-bg); }
228
+ .wp-date__day[aria-disabled="true"] { opacity: 0.35; cursor: not-allowed; background: transparent; text-decoration: line-through; }
229
+ .wp-date__day:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--wp-border-focus); }
230
+ .wp-date__foot { display: flex; justify-content: space-between; }
231
+ @media (prefers-reduced-motion: reduce) {
232
+ .wp-date__field { transition: none; }
233
+ }
234
+ </style>
@@ -1,73 +1,73 @@
1
- <script setup lang="ts">
2
- /**
3
- * Description list: label and value rows (an item's details, a step of the
4
- * trace, model info). Labels line up in one column and values in the next;
5
- * `stacked` puts each label above its value for a narrow panel. Works on the
6
- * canvas and in the manager.
7
- *
8
- * <DescriptionList :items="[{ label: 'Family', value: 'SDXL' }, { label: 'ID', value: id, mono: true, copy: true }]" />
9
- * <DescriptionList :items="rows"><template #value-status="{ item }"><Badge dot tone="success" text="Live" /></template></DescriptionList>
10
- *
11
- * A value that is empty draws a dim dash. A row with `key` can fill its value
12
- * from the `value-<key>` slot.
13
- */
14
- import CopyButton from "./CopyButton.vue";
15
-
16
- export interface DescriptionItem {
17
- label: string;
18
- value?: string | number | null | undefined;
19
- /** Names the `value-<key>` slot for this row. */
20
- key?: string | undefined;
21
- /** Draw the value in the mono font (ids, seeds, paths). */
22
- mono?: boolean | undefined;
23
- /** Add a copy button after the value. */
24
- copy?: boolean | undefined;
25
- }
26
-
27
- withDefaults(defineProps<{
28
- items: DescriptionItem[];
29
- layout?: "columns" | "stacked" | undefined;
30
- size?: "sm" | "md" | undefined;
31
- /** Lines between rows. */
32
- divided?: boolean | undefined;
33
- }>(), { layout: "columns", size: "md" });
34
-
35
- const empty = (v: DescriptionItem["value"]): boolean => v === undefined || v === null || v === "";
36
- </script>
37
-
38
- <template>
39
- <dl class="wp-dl" :data-layout="layout" :data-size="size" :data-divided="divided || undefined">
40
- <div v-for="(it, i) in items" :key="it.key ?? `${i}-${it.label}`" class="wp-dl__row">
41
- <dt class="wp-dl__label">{{ it.label }}</dt>
42
- <dd class="wp-dl__value" :data-mono="it.mono || undefined">
43
- <slot v-if="it.key && $slots[`value-${it.key}`]" :name="`value-${it.key}`" :item="it" />
44
- <template v-else-if="empty(it.value)"><span class="wp-dl__empty" aria-label="None">—</span></template>
45
- <template v-else>
46
- <span class="wp-dl__text">{{ it.value }}</span>
47
- <CopyButton v-if="it.copy" :text="String(it.value)" :label="`Copy ${it.label}`" size="sm" class="wp-dl__copy" />
48
- </template>
49
- </dd>
50
- </div>
51
- </dl>
52
- </template>
53
-
54
- <style scoped>
55
- .wp-dl {
56
- display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: var(--wp-space-6); row-gap: var(--wp-space-3);
57
- margin: 0; min-width: 0; font: 400 var(--wp-text-sm)/1.45 var(--wp-font-sans);
58
- }
59
- .wp-dl[data-size="sm"] { column-gap: var(--wp-space-5); row-gap: var(--wp-space-2); font-size: var(--wp-text-xs); }
60
- .wp-dl__row { display: contents; }
61
- .wp-dl__label { margin: 0; color: var(--wp-text-muted); }
62
- .wp-dl__value { display: flex; align-items: center; gap: var(--wp-space-2); min-width: 0; margin: 0; color: var(--wp-text); }
63
- .wp-dl__text { min-width: 0; overflow-wrap: anywhere; }
64
- .wp-dl__value[data-mono] .wp-dl__text { font-family: var(--wp-font-mono); font-size: 0.95em; }
65
- .wp-dl__empty { color: var(--wp-text-dim); }
66
- .wp-dl__copy { margin: -4px 0; }
67
- .wp-dl[data-divided] { row-gap: 0; }
68
- .wp-dl[data-divided] .wp-dl__label, .wp-dl[data-divided] .wp-dl__value { padding: var(--wp-space-3) 0; border-top: 1px solid var(--wp-border-soft); }
69
- .wp-dl[data-divided] .wp-dl__row:first-child > * { border-top: 0; }
70
- .wp-dl[data-layout="stacked"] { grid-template-columns: minmax(0, 1fr); row-gap: var(--wp-space-4); }
71
- .wp-dl[data-layout="stacked"] .wp-dl__row { display: flex; flex-direction: column; gap: 2px; }
72
- .wp-dl[data-layout="stacked"] .wp-dl__label { font-size: var(--wp-text-xs); font-weight: 600; }
73
- </style>
1
+ <script setup lang="ts">
2
+ /**
3
+ * Description list: label and value rows (an item's details, a step of the
4
+ * trace, model info). Labels line up in one column and values in the next;
5
+ * `stacked` puts each label above its value for a narrow panel. Works on the
6
+ * canvas and in the manager.
7
+ *
8
+ * <DescriptionList :items="[{ label: 'Family', value: 'SDXL' }, { label: 'ID', value: id, mono: true, copy: true }]" />
9
+ * <DescriptionList :items="rows"><template #value-status="{ item }"><Badge dot tone="success" text="Live" /></template></DescriptionList>
10
+ *
11
+ * A value that is empty draws a dim dash. A row with `key` can fill its value
12
+ * from the `value-<key>` slot.
13
+ */
14
+ import CopyButton from "./CopyButton.vue";
15
+
16
+ export interface DescriptionItem {
17
+ label: string;
18
+ value?: string | number | null | undefined;
19
+ /** Names the `value-<key>` slot for this row. */
20
+ key?: string | undefined;
21
+ /** Draw the value in the mono font (ids, seeds, paths). */
22
+ mono?: boolean | undefined;
23
+ /** Add a copy button after the value. */
24
+ copy?: boolean | undefined;
25
+ }
26
+
27
+ withDefaults(defineProps<{
28
+ items: DescriptionItem[];
29
+ layout?: "columns" | "stacked" | undefined;
30
+ size?: "sm" | "md" | undefined;
31
+ /** Lines between rows. */
32
+ divided?: boolean | undefined;
33
+ }>(), { layout: "columns", size: "md" });
34
+
35
+ const empty = (v: DescriptionItem["value"]): boolean => v === undefined || v === null || v === "";
36
+ </script>
37
+
38
+ <template>
39
+ <dl class="wp-dl" :data-layout="layout" :data-size="size" :data-divided="divided || undefined">
40
+ <div v-for="(it, i) in items" :key="it.key ?? `${i}-${it.label}`" class="wp-dl__row">
41
+ <dt class="wp-dl__label">{{ it.label }}</dt>
42
+ <dd class="wp-dl__value" :data-mono="it.mono || undefined">
43
+ <slot v-if="it.key && $slots[`value-${it.key}`]" :name="`value-${it.key}`" :item="it" />
44
+ <template v-else-if="empty(it.value)"><span class="wp-dl__empty" aria-label="None">—</span></template>
45
+ <template v-else>
46
+ <span class="wp-dl__text">{{ it.value }}</span>
47
+ <CopyButton v-if="it.copy" :text="String(it.value)" :label="`Copy ${it.label}`" size="sm" class="wp-dl__copy" />
48
+ </template>
49
+ </dd>
50
+ </div>
51
+ </dl>
52
+ </template>
53
+
54
+ <style scoped>
55
+ .wp-dl {
56
+ display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: var(--wp-space-6); row-gap: var(--wp-space-3);
57
+ margin: 0; min-width: 0; font: 400 var(--wp-text-sm)/1.45 var(--wp-font-sans);
58
+ }
59
+ .wp-dl[data-size="sm"] { column-gap: var(--wp-space-5); row-gap: var(--wp-space-2); font-size: var(--wp-text-xs); }
60
+ .wp-dl__row { display: contents; }
61
+ .wp-dl__label { margin: 0; color: var(--wp-text-muted); }
62
+ .wp-dl__value { display: flex; align-items: center; gap: var(--wp-space-2); min-width: 0; margin: 0; color: var(--wp-text); }
63
+ .wp-dl__text { min-width: 0; overflow-wrap: anywhere; }
64
+ .wp-dl__value[data-mono] .wp-dl__text { font-family: var(--wp-font-mono); font-size: 0.95em; }
65
+ .wp-dl__empty { color: var(--wp-text-dim); }
66
+ .wp-dl__copy { margin: -4px 0; }
67
+ .wp-dl[data-divided] { row-gap: 0; }
68
+ .wp-dl[data-divided] .wp-dl__label, .wp-dl[data-divided] .wp-dl__value { padding: var(--wp-space-3) 0; border-top: 1px solid var(--wp-border-soft); }
69
+ .wp-dl[data-divided] .wp-dl__row:first-child > * { border-top: 0; }
70
+ .wp-dl[data-layout="stacked"] { grid-template-columns: minmax(0, 1fr); row-gap: var(--wp-space-4); }
71
+ .wp-dl[data-layout="stacked"] .wp-dl__row { display: flex; flex-direction: column; gap: 2px; }
72
+ .wp-dl[data-layout="stacked"] .wp-dl__label { font-size: var(--wp-text-xs); font-weight: 600; }
73
+ </style>