@dumiflex/wp-kit 0.3.0 → 0.4.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 (128) hide show
  1. package/CHANGELOG.md +77 -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 +119 -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 +292 -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 +125 -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 +173 -173
  44. package/src/ListFilter.vue +85 -85
  45. package/src/ListRow.vue +204 -204
  46. package/src/LoadingMark.vue +175 -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 +82 -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/hsv.ts +100 -100
  101. package/src/icon-catalog.ts +52 -52
  102. package/src/image-zoom.ts +93 -93
  103. package/src/kind-colour.ts +28 -0
  104. package/src/logo-paths.ts +21 -21
  105. package/src/matrix-axis.ts +91 -91
  106. package/src/pagination.ts +27 -27
  107. package/src/platform-keys.ts +29 -29
  108. package/src/rich-tokenize.ts +357 -357
  109. package/src/select-types.ts +32 -32
  110. package/src/slider-math.ts +45 -45
  111. package/src/sortable.ts +22 -22
  112. package/src/theme/fonts/OFL-Fraunces.txt +93 -93
  113. package/src/theme/fonts/OFL-JetBrainsMono.txt +93 -93
  114. package/src/theme/fonts/OFL-Manrope.txt +93 -93
  115. package/src/theme/looks.css +428 -428
  116. package/src/theme/palettes.css +254 -254
  117. package/src/theme/tokens.css +2896 -2894
  118. package/src/tokens.ts +56 -56
  119. package/src/tooltip.css +43 -43
  120. package/src/tooltip.ts +146 -146
  121. package/src/useDialogFocus.ts +73 -73
  122. package/src/useGrowableField.ts +357 -357
  123. package/src/useModalKeyShield.ts +116 -116
  124. package/src/useToast.ts +48 -48
  125. package/src/wp-logo.svg +14 -14
  126. package/src/ChipToggle.vue +0 -92
  127. package/src/KindChip.vue +0 -53
  128. package/src/RatingBadge.vue +0 -42
@@ -1,183 +1,183 @@
1
- <script setup lang="ts">
2
- /**
3
- * Range slider: a low and a high number on one track (a weight range, a
4
- * token budget, a sweep's from–to). Two thumbs that can't cross, kept at
5
- * least `min-gap` apart; `with-input` adds a WpNumber for each end. Works on
6
- * the canvas (`size="sm"`) and in the manager (`md`).
7
- *
8
- * <RangeSlider v-model="range" :min="0" :max="2" :step="0.1" aria-label="Weight" with-input />
9
- *
10
- * Each thumb is an APG slider ("Weight, low end" / "high end") whose
11
- * min and max are the other thumb, so screen readers hear the real limits.
12
- * A click on the track moves the nearer thumb.
13
- */
14
- import { computed, ref } from "vue";
15
- import { keyStep, percentOf, snap, valueAt } from "./slider-math";
16
- import WpNumber from "./WpNumber.vue";
17
-
18
- const props = withDefaults(defineProps<{
19
- modelValue: [number, number];
20
- min?: number | undefined;
21
- max?: number | undefined;
22
- step?: number | undefined;
23
- /** The smallest distance between the two ends. */
24
- minGap?: number | undefined;
25
- size?: "sm" | "md" | "lg" | undefined;
26
- disabled?: boolean | undefined;
27
- ariaLabel?: string | undefined;
28
- format?: ((v: number) => string) | undefined;
29
- withInput?: boolean | undefined;
30
- }>(), { min: 0, max: 100, step: 1, minGap: 0, size: "md", ariaLabel: "Range" });
31
-
32
- const emit = defineEmits<{ (e: "update:modelValue", v: [number, number]): void; (e: "change", v: [number, number]): void }>();
33
-
34
- const trackEl = ref<HTMLElement | null>(null);
35
- const active = ref<0 | 1 | null>(null);
36
-
37
- const lo = computed(() => snap(Math.min(props.modelValue[0], props.modelValue[1]), props.min, props.max, props.step));
38
- const hi = computed(() => snap(Math.max(props.modelValue[0], props.modelValue[1]), props.min, props.max, props.step));
39
- const loPct = computed(() => percentOf(lo.value, props.min, props.max));
40
- const hiPct = computed(() => percentOf(hi.value, props.min, props.max));
41
- const text = (v: number): string => (props.format ? props.format(v) : String(v));
42
-
43
- /** Put one end at `v`, kept inside the other end minus the gap. */
44
- function setEnd(end: 0 | 1, v: number): [number, number] {
45
- const next: [number, number] = end === 0
46
- ? [Math.min(v, snap(hi.value - props.minGap, props.min, props.max, props.step)), hi.value]
47
- : [lo.value, Math.max(v, snap(lo.value + props.minGap, props.min, props.max, props.step))];
48
- if (next[0] !== props.modelValue[0] || next[1] !== props.modelValue[1]) emit("update:modelValue", next);
49
- return next;
50
- }
51
-
52
- function fromPointer(ev: PointerEvent): number {
53
- const r = trackEl.value?.getBoundingClientRect();
54
- return r ? valueAt(ev.clientX, r.left, r.width, props.min, props.max, props.step) : lo.value;
55
- }
56
-
57
- function onPointerDown(ev: PointerEvent): void {
58
- if (props.disabled || ev.button !== 0) return;
59
- ev.preventDefault();
60
- const v = fromPointer(ev);
61
- active.value = Math.abs(v - lo.value) <= Math.abs(v - hi.value) && !(v > hi.value) ? 0 : 1;
62
- (ev.currentTarget as HTMLElement).setPointerCapture?.(ev.pointerId);
63
- setEnd(active.value, v);
64
- trackEl.value?.querySelectorAll<HTMLElement>("[role=slider]")[active.value]?.focus();
65
- }
66
-
67
- function onPointerMove(ev: PointerEvent): void {
68
- if (active.value !== null) setEnd(active.value, fromPointer(ev));
69
- }
70
-
71
- function onPointerUp(ev: PointerEvent): void {
72
- if (active.value === null) return;
73
- active.value = null;
74
- (ev.currentTarget as HTMLElement).releasePointerCapture?.(ev.pointerId);
75
- emit("change", [lo.value, hi.value]);
76
- }
77
-
78
- function onKeydown(ev: KeyboardEvent, end: 0 | 1): void {
79
- if (props.disabled) return;
80
- const lowLimit = end === 0 ? props.min : lo.value + props.minGap;
81
- const highLimit = end === 0 ? hi.value - props.minGap : props.max;
82
- const cur = end === 0 ? lo.value : hi.value;
83
- const next = keyStep(ev.key, cur, props.min, props.max, props.step);
84
- if (next === null) return;
85
- ev.preventDefault();
86
- const v = ev.key === "Home" ? lowLimit : ev.key === "End" ? highLimit : next;
87
- emit("change", setEnd(end, v));
88
- }
89
-
90
- function onTyped(end: 0 | 1, v: number | null): void {
91
- if (v === null) return;
92
- emit("change", setEnd(end, snap(v, props.min, props.max, props.step)));
93
- }
94
- </script>
95
-
96
- <template>
97
- <div class="wp-range-slider" :data-size="size" :data-disabled="disabled || undefined">
98
- <WpNumber
99
- v-if="withInput"
100
- class="wp-range-slider__input"
101
- :model-value="lo"
102
- :min="min"
103
- :max="hi - props.minGap"
104
- :step="step"
105
- :size="size"
106
- :disabled="disabled"
107
- :aria-label="`${ariaLabel}, low end`"
108
- @update:model-value="onTyped(0, $event)"
109
- />
110
- <div
111
- ref="trackEl"
112
- class="wp-range-slider__track"
113
- @pointerdown="onPointerDown"
114
- @pointermove="onPointerMove"
115
- @pointerup="onPointerUp"
116
- @pointercancel="onPointerUp"
117
- >
118
- <div class="wp-range-slider__rail" />
119
- <div class="wp-range-slider__fill" :style="{ left: `${loPct}%`, width: `${hiPct - loPct}%` }" />
120
- <!-- Focusable unless disabled (tabindex is bound). -->
121
- <!-- eslint-disable-next-line vuejs-accessibility/interactive-supports-focus -->
122
- <div
123
- v-for="end in ([0, 1] as const)"
124
- :key="end"
125
- class="wp-range-slider__thumb"
126
- role="slider"
127
- :tabindex="disabled ? -1 : 0"
128
- :aria-label="`${ariaLabel}, ${end === 0 ? 'low' : 'high'} end`"
129
- :aria-valuemin="end === 0 ? min : lo + props.minGap"
130
- :aria-valuemax="end === 0 ? hi - props.minGap : max"
131
- :aria-valuenow="end === 0 ? lo : hi"
132
- :aria-valuetext="format ? text(end === 0 ? lo : hi) : undefined"
133
- :aria-disabled="disabled || undefined"
134
- :data-active="active === end || undefined"
135
- :style="{ left: `${end === 0 ? loPct : hiPct}%` }"
136
- @keydown="onKeydown($event, end)"
137
- />
138
- </div>
139
- <WpNumber
140
- v-if="withInput"
141
- class="wp-range-slider__input"
142
- :model-value="hi"
143
- :min="lo + props.minGap"
144
- :max="max"
145
- :step="step"
146
- :size="size"
147
- :disabled="disabled"
148
- :aria-label="`${ariaLabel}, high end`"
149
- @update:model-value="onTyped(1, $event)"
150
- />
151
- <span v-else class="wp-range-slider__value" aria-hidden="true">{{ text(lo) }} – {{ text(hi) }}</span>
152
- </div>
153
- </template>
154
-
155
- <style scoped>
156
- .wp-range-slider {
157
- --_h: var(--wp-control-h-md); --_thumb: 16px;
158
- display: flex; align-items: center; gap: var(--wp-space-4); min-width: 0; width: 100%; min-height: var(--_h);
159
- font-family: var(--wp-font-sans);
160
- }
161
- .wp-range-slider[data-size="sm"] { --_h: var(--wp-control-h-sm); --_thumb: 12px; gap: var(--wp-space-3); }
162
- .wp-range-slider[data-size="lg"] { --_h: var(--wp-control-h-lg); --_thumb: 18px; }
163
- .wp-range-slider__track { position: relative; flex: 1; min-width: 80px; height: var(--_h); margin: 0 calc(var(--_thumb) / 2); cursor: pointer; touch-action: none; }
164
- .wp-range-slider__rail, .wp-range-slider__fill { position: absolute; top: 50%; height: 4px; margin-top: -2px; border-radius: var(--wp-radius-cap, 999px); }
165
- .wp-range-slider__rail { left: calc(var(--_thumb) / -2); right: calc(var(--_thumb) / -2); background: var(--wp-bg-3); box-shadow: inset 0 0 0 1px var(--wp-border-soft); }
166
- .wp-range-slider__fill { background: var(--wp-accent); }
167
- .wp-range-slider[data-size="sm"] .wp-range-slider__rail, .wp-range-slider[data-size="sm"] .wp-range-slider__fill { height: 3px; margin-top: -1.5px; }
168
- .wp-range-slider__thumb {
169
- position: absolute; top: 50%; box-sizing: border-box; width: var(--_thumb); height: var(--_thumb);
170
- margin: calc(var(--_thumb) / -2) 0 0 calc(var(--_thumb) / -2);
171
- border: 2px solid var(--wp-accent); border-radius: min(50%, var(--wp-radius-cap, 999px)); background: var(--wp-bg); box-shadow: var(--wp-shadow-sm); outline: none;
172
- transition: transform var(--wp-motion-quick), box-shadow var(--wp-motion-quick);
173
- }
174
- .wp-range-slider__thumb[data-active], .wp-range-slider__thumb:hover { transform: scale(1.12); }
175
- .wp-range-slider__thumb:focus-visible { box-shadow: 0 0 0 3px var(--wp-focus-ring); z-index: 1; }
176
- .wp-range-slider__value { flex: none; color: var(--wp-text); font: 500 var(--wp-text-sm)/1 var(--wp-font-sans); font-variant-numeric: tabular-nums; white-space: nowrap; }
177
- .wp-range-slider[data-size="sm"] .wp-range-slider__value { font-size: var(--wp-text-xs); }
178
- .wp-range-slider__input { flex: none; width: 76px; }
179
- .wp-range-slider[data-size="sm"] .wp-range-slider__input { width: 60px; }
180
- .wp-range-slider[data-disabled] { opacity: 0.45; }
181
- .wp-range-slider[data-disabled] .wp-range-slider__track { cursor: not-allowed; }
182
- @media (prefers-reduced-motion: reduce) { .wp-range-slider__thumb { transition: none; } }
183
- </style>
1
+ <script setup lang="ts">
2
+ /**
3
+ * Range slider: a low and a high number on one track (a weight range, a
4
+ * token budget, a sweep's from–to). Two thumbs that can't cross, kept at
5
+ * least `min-gap` apart; `with-input` adds a WpNumber for each end. Works on
6
+ * the canvas (`size="sm"`) and in the manager (`md`).
7
+ *
8
+ * <RangeSlider v-model="range" :min="0" :max="2" :step="0.1" aria-label="Weight" with-input />
9
+ *
10
+ * Each thumb is an APG slider ("Weight, low end" / "high end") whose
11
+ * min and max are the other thumb, so screen readers hear the real limits.
12
+ * A click on the track moves the nearer thumb.
13
+ */
14
+ import { computed, ref } from "vue";
15
+ import { keyStep, percentOf, snap, valueAt } from "./slider-math";
16
+ import WpNumber from "./WpNumber.vue";
17
+
18
+ const props = withDefaults(defineProps<{
19
+ modelValue: [number, number];
20
+ min?: number | undefined;
21
+ max?: number | undefined;
22
+ step?: number | undefined;
23
+ /** The smallest distance between the two ends. */
24
+ minGap?: number | undefined;
25
+ size?: "sm" | "md" | "lg" | undefined;
26
+ disabled?: boolean | undefined;
27
+ ariaLabel?: string | undefined;
28
+ format?: ((v: number) => string) | undefined;
29
+ withInput?: boolean | undefined;
30
+ }>(), { min: 0, max: 100, step: 1, minGap: 0, size: "md", ariaLabel: "Range" });
31
+
32
+ const emit = defineEmits<{ (e: "update:modelValue", v: [number, number]): void; (e: "change", v: [number, number]): void }>();
33
+
34
+ const trackEl = ref<HTMLElement | null>(null);
35
+ const active = ref<0 | 1 | null>(null);
36
+
37
+ const lo = computed(() => snap(Math.min(props.modelValue[0], props.modelValue[1]), props.min, props.max, props.step));
38
+ const hi = computed(() => snap(Math.max(props.modelValue[0], props.modelValue[1]), props.min, props.max, props.step));
39
+ const loPct = computed(() => percentOf(lo.value, props.min, props.max));
40
+ const hiPct = computed(() => percentOf(hi.value, props.min, props.max));
41
+ const text = (v: number): string => (props.format ? props.format(v) : String(v));
42
+
43
+ /** Put one end at `v`, kept inside the other end minus the gap. */
44
+ function setEnd(end: 0 | 1, v: number): [number, number] {
45
+ const next: [number, number] = end === 0
46
+ ? [Math.min(v, snap(hi.value - props.minGap, props.min, props.max, props.step)), hi.value]
47
+ : [lo.value, Math.max(v, snap(lo.value + props.minGap, props.min, props.max, props.step))];
48
+ if (next[0] !== props.modelValue[0] || next[1] !== props.modelValue[1]) emit("update:modelValue", next);
49
+ return next;
50
+ }
51
+
52
+ function fromPointer(ev: PointerEvent): number {
53
+ const r = trackEl.value?.getBoundingClientRect();
54
+ return r ? valueAt(ev.clientX, r.left, r.width, props.min, props.max, props.step) : lo.value;
55
+ }
56
+
57
+ function onPointerDown(ev: PointerEvent): void {
58
+ if (props.disabled || ev.button !== 0) return;
59
+ ev.preventDefault();
60
+ const v = fromPointer(ev);
61
+ active.value = Math.abs(v - lo.value) <= Math.abs(v - hi.value) && !(v > hi.value) ? 0 : 1;
62
+ (ev.currentTarget as HTMLElement).setPointerCapture?.(ev.pointerId);
63
+ setEnd(active.value, v);
64
+ trackEl.value?.querySelectorAll<HTMLElement>("[role=slider]")[active.value]?.focus();
65
+ }
66
+
67
+ function onPointerMove(ev: PointerEvent): void {
68
+ if (active.value !== null) setEnd(active.value, fromPointer(ev));
69
+ }
70
+
71
+ function onPointerUp(ev: PointerEvent): void {
72
+ if (active.value === null) return;
73
+ active.value = null;
74
+ (ev.currentTarget as HTMLElement).releasePointerCapture?.(ev.pointerId);
75
+ emit("change", [lo.value, hi.value]);
76
+ }
77
+
78
+ function onKeydown(ev: KeyboardEvent, end: 0 | 1): void {
79
+ if (props.disabled) return;
80
+ const lowLimit = end === 0 ? props.min : lo.value + props.minGap;
81
+ const highLimit = end === 0 ? hi.value - props.minGap : props.max;
82
+ const cur = end === 0 ? lo.value : hi.value;
83
+ const next = keyStep(ev.key, cur, props.min, props.max, props.step);
84
+ if (next === null) return;
85
+ ev.preventDefault();
86
+ const v = ev.key === "Home" ? lowLimit : ev.key === "End" ? highLimit : next;
87
+ emit("change", setEnd(end, v));
88
+ }
89
+
90
+ function onTyped(end: 0 | 1, v: number | null): void {
91
+ if (v === null) return;
92
+ emit("change", setEnd(end, snap(v, props.min, props.max, props.step)));
93
+ }
94
+ </script>
95
+
96
+ <template>
97
+ <div class="wp-range-slider" :data-size="size" :data-disabled="disabled || undefined">
98
+ <WpNumber
99
+ v-if="withInput"
100
+ class="wp-range-slider__input"
101
+ :model-value="lo"
102
+ :min="min"
103
+ :max="hi - props.minGap"
104
+ :step="step"
105
+ :size="size"
106
+ :disabled="disabled"
107
+ :aria-label="`${ariaLabel}, low end`"
108
+ @update:model-value="onTyped(0, $event)"
109
+ />
110
+ <div
111
+ ref="trackEl"
112
+ class="wp-range-slider__track"
113
+ @pointerdown="onPointerDown"
114
+ @pointermove="onPointerMove"
115
+ @pointerup="onPointerUp"
116
+ @pointercancel="onPointerUp"
117
+ >
118
+ <div class="wp-range-slider__rail" />
119
+ <div class="wp-range-slider__fill" :style="{ left: `${loPct}%`, width: `${hiPct - loPct}%` }" />
120
+ <!-- Focusable unless disabled (tabindex is bound). -->
121
+ <!-- eslint-disable-next-line vuejs-accessibility/interactive-supports-focus -->
122
+ <div
123
+ v-for="end in ([0, 1] as const)"
124
+ :key="end"
125
+ class="wp-range-slider__thumb"
126
+ role="slider"
127
+ :tabindex="disabled ? -1 : 0"
128
+ :aria-label="`${ariaLabel}, ${end === 0 ? 'low' : 'high'} end`"
129
+ :aria-valuemin="end === 0 ? min : lo + props.minGap"
130
+ :aria-valuemax="end === 0 ? hi - props.minGap : max"
131
+ :aria-valuenow="end === 0 ? lo : hi"
132
+ :aria-valuetext="format ? text(end === 0 ? lo : hi) : undefined"
133
+ :aria-disabled="disabled || undefined"
134
+ :data-active="active === end || undefined"
135
+ :style="{ left: `${end === 0 ? loPct : hiPct}%` }"
136
+ @keydown="onKeydown($event, end)"
137
+ />
138
+ </div>
139
+ <WpNumber
140
+ v-if="withInput"
141
+ class="wp-range-slider__input"
142
+ :model-value="hi"
143
+ :min="lo + props.minGap"
144
+ :max="max"
145
+ :step="step"
146
+ :size="size"
147
+ :disabled="disabled"
148
+ :aria-label="`${ariaLabel}, high end`"
149
+ @update:model-value="onTyped(1, $event)"
150
+ />
151
+ <span v-else class="wp-range-slider__value" aria-hidden="true">{{ text(lo) }} – {{ text(hi) }}</span>
152
+ </div>
153
+ </template>
154
+
155
+ <style scoped>
156
+ .wp-range-slider {
157
+ --_h: var(--wp-control-h-md); --_thumb: 16px;
158
+ display: flex; align-items: center; gap: var(--wp-space-4); min-width: 0; width: 100%; min-height: var(--_h);
159
+ font-family: var(--wp-font-sans);
160
+ }
161
+ .wp-range-slider[data-size="sm"] { --_h: var(--wp-control-h-sm); --_thumb: 12px; gap: var(--wp-space-3); }
162
+ .wp-range-slider[data-size="lg"] { --_h: var(--wp-control-h-lg); --_thumb: 18px; }
163
+ .wp-range-slider__track { position: relative; flex: 1; min-width: 80px; height: var(--_h); margin: 0 calc(var(--_thumb) / 2); cursor: pointer; touch-action: none; }
164
+ .wp-range-slider__rail, .wp-range-slider__fill { position: absolute; top: 50%; height: 4px; margin-top: -2px; border-radius: var(--wp-radius-cap, 999px); }
165
+ .wp-range-slider__rail { left: calc(var(--_thumb) / -2); right: calc(var(--_thumb) / -2); background: var(--wp-bg-3); box-shadow: inset 0 0 0 1px var(--wp-border-soft); }
166
+ .wp-range-slider__fill { background: var(--wp-accent); }
167
+ .wp-range-slider[data-size="sm"] .wp-range-slider__rail, .wp-range-slider[data-size="sm"] .wp-range-slider__fill { height: 3px; margin-top: -1.5px; }
168
+ .wp-range-slider__thumb {
169
+ position: absolute; top: 50%; box-sizing: border-box; width: var(--_thumb); height: var(--_thumb);
170
+ margin: calc(var(--_thumb) / -2) 0 0 calc(var(--_thumb) / -2);
171
+ border: 2px solid var(--wp-accent); border-radius: min(50%, var(--wp-radius-cap, 999px)); background: var(--wp-bg); box-shadow: var(--wp-shadow-sm); outline: none;
172
+ transition: transform var(--wp-motion-quick), box-shadow var(--wp-motion-quick);
173
+ }
174
+ .wp-range-slider__thumb[data-active], .wp-range-slider__thumb:hover { transform: scale(1.12); }
175
+ .wp-range-slider__thumb:focus-visible { box-shadow: var(--wp-focus-ring); z-index: 1; }
176
+ .wp-range-slider__value { flex: none; color: var(--wp-text); font: 500 var(--wp-text-sm)/1 var(--wp-font-sans); font-variant-numeric: tabular-nums; white-space: nowrap; }
177
+ .wp-range-slider[data-size="sm"] .wp-range-slider__value { font-size: var(--wp-text-xs); }
178
+ .wp-range-slider__input { flex: none; width: 76px; }
179
+ .wp-range-slider[data-size="sm"] .wp-range-slider__input { width: 60px; }
180
+ .wp-range-slider[data-disabled] { opacity: 0.45; }
181
+ .wp-range-slider[data-disabled] .wp-range-slider__track { cursor: not-allowed; }
182
+ @media (prefers-reduced-motion: reduce) { .wp-range-slider__thumb { transition: none; } }
183
+ </style>
@@ -1,35 +1,35 @@
1
- <script setup lang="ts">
2
- import { computed } from "vue";
3
-
4
- const props = defineProps<{ value: string | null | undefined }>();
5
-
6
- const display = computed(() => {
7
- if (!props.value) return "—";
8
- const ts = Date.parse(props.value);
9
- if (Number.isNaN(ts)) return "—";
10
- const diff = Date.now() - ts;
11
- const sec = Math.floor(diff / 1000);
12
- if (sec < 60) return "just now";
13
- const min = Math.floor(sec / 60);
14
- if (min < 60) return `${min}m ago`;
15
- const hr = Math.floor(min / 60);
16
- if (hr < 24) return `${hr}h ago`;
17
- const day = Math.floor(hr / 24);
18
- if (day < 7) return `${day}d ago`;
19
- if (day < 30) return `${Math.floor(day / 7)}w ago`;
20
- if (day < 365) return `${Math.floor(day / 30)}mo ago`;
21
- return `${Math.floor(day / 365)}y ago`;
22
- });
23
- </script>
24
-
25
- <template>
26
- <span class="wp-reldate" :title="value || ''">{{ display }}</span>
27
- </template>
28
-
29
- <style scoped>
30
- .wp-reldate {
31
- font-size: 0.75rem;
32
- line-height: 1rem;
33
- color: var(--wp-text2);
34
- }
35
- </style>
1
+ <script setup lang="ts">
2
+ import { computed } from "vue";
3
+
4
+ const props = defineProps<{ value: string | null | undefined }>();
5
+
6
+ const display = computed(() => {
7
+ if (!props.value) return "—";
8
+ const ts = Date.parse(props.value);
9
+ if (Number.isNaN(ts)) return "—";
10
+ const diff = Date.now() - ts;
11
+ const sec = Math.floor(diff / 1000);
12
+ if (sec < 60) return "just now";
13
+ const min = Math.floor(sec / 60);
14
+ if (min < 60) return `${min}m ago`;
15
+ const hr = Math.floor(min / 60);
16
+ if (hr < 24) return `${hr}h ago`;
17
+ const day = Math.floor(hr / 24);
18
+ if (day < 7) return `${day}d ago`;
19
+ if (day < 30) return `${Math.floor(day / 7)}w ago`;
20
+ if (day < 365) return `${Math.floor(day / 30)}mo ago`;
21
+ return `${Math.floor(day / 365)}y ago`;
22
+ });
23
+ </script>
24
+
25
+ <template>
26
+ <span class="wp-reldate" :title="value || ''">{{ display }}</span>
27
+ </template>
28
+
29
+ <style scoped>
30
+ .wp-reldate {
31
+ font-size: 0.75rem;
32
+ line-height: 1rem;
33
+ color: var(--wp-text2);
34
+ }
35
+ </style>