@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,143 +1,143 @@
1
- <script setup lang="ts">
2
- /**
3
- * Resize handle: the grip on a panel's edge that drags it wider or taller
4
- * (a drawer's width, a column, a box's height). It owns the size in pixels
5
- * through v-model; the parent puts that size on the panel. Works on the
6
- * canvas and in the manager. Two panels side by side use SplitPane, which
7
- * is built on this.
8
- *
9
- * <aside :style="{ width: `${w}px` }">…<ResizeHandle v-model="w" axis="x" reverse :min="280" :max="720" label="Chat width" /></aside>
10
- *
11
- * APG window splitter: `role="separator"` that takes focus; the arrows move
12
- * it 16 px (Shift: 64), Home / End jump to min / max, Enter or a double
13
- * click puts back `default-size`. `reverse` is for a handle on a panel's
14
- * left or top edge, where dragging toward the start makes it bigger.
15
- */
16
- import { computed, ref } from "vue";
17
-
18
- const props = withDefaults(defineProps<{
19
- /** The panel's size in px. */
20
- modelValue: number;
21
- /** x: the handle changes width (an upright bar). y: height (a flat bar). */
22
- axis?: "x" | "y" | undefined;
23
- min?: number | undefined;
24
- max?: number | undefined;
25
- /** Dragging toward the start (left / up) makes the panel bigger. */
26
- reverse?: boolean | undefined;
27
- /** Where Enter and a double click put it back. */
28
- defaultSize?: number | undefined;
29
- /** Keyboard step in px. */
30
- step?: number | undefined;
31
- /** What it resizes, for screen readers ("Chat width"). */
32
- label: string;
33
- /** The id of the panel it resizes. */
34
- controls?: string | undefined;
35
- disabled?: boolean | undefined;
36
- }>(), { axis: "x", min: 0, max: Number.POSITIVE_INFINITY, defaultSize: undefined, step: 16, controls: undefined });
37
-
38
- const emit = defineEmits<{ (e: "update:modelValue", v: number): void; (e: "end", v: number): void }>();
39
-
40
- const dragging = ref(false);
41
- let start = 0;
42
- let startSize = 0;
43
-
44
- const clamp = (v: number): number => Math.round(Math.min(props.max, Math.max(props.min, v)));
45
- const finiteMax = computed(() => (Number.isFinite(props.max) ? props.max : undefined));
46
-
47
- function set(v: number): void {
48
- const next = clamp(v);
49
- if (next !== props.modelValue) emit("update:modelValue", next);
50
- }
51
-
52
- function onPointerDown(ev: PointerEvent): void {
53
- if (props.disabled || ev.button !== 0) return;
54
- ev.preventDefault();
55
- dragging.value = true;
56
- start = props.axis === "x" ? ev.clientX : ev.clientY;
57
- startSize = props.modelValue;
58
- (ev.currentTarget as HTMLElement).setPointerCapture?.(ev.pointerId);
59
- }
60
-
61
- function onPointerMove(ev: PointerEvent): void {
62
- if (!dragging.value) return;
63
- const d = (props.axis === "x" ? ev.clientX : ev.clientY) - start;
64
- set(startSize + (props.reverse ? -d : d));
65
- }
66
-
67
- function onPointerUp(ev: PointerEvent): void {
68
- if (!dragging.value) return;
69
- dragging.value = false;
70
- (ev.currentTarget as HTMLElement).releasePointerCapture?.(ev.pointerId);
71
- emit("end", props.modelValue);
72
- }
73
-
74
- function reset(): void {
75
- if (props.defaultSize === undefined || props.disabled) return;
76
- set(props.defaultSize);
77
- emit("end", clamp(props.defaultSize));
78
- }
79
-
80
- function onKeydown(ev: KeyboardEvent): void {
81
- if (props.disabled) return;
82
- const s = ev.shiftKey ? props.step * 4 : props.step;
83
- const grow = props.reverse ? -1 : 1;
84
- const fwd = props.axis === "x" ? "ArrowRight" : "ArrowDown";
85
- const back = props.axis === "x" ? "ArrowLeft" : "ArrowUp";
86
- let next: number;
87
- if (ev.key === fwd) next = props.modelValue + s * grow;
88
- else if (ev.key === back) next = props.modelValue - s * grow;
89
- else if (ev.key === "Home") next = props.min;
90
- else if (ev.key === "End" && finiteMax.value !== undefined) next = finiteMax.value;
91
- else if (ev.key === "Enter") { ev.preventDefault(); reset(); return; }
92
- else return;
93
- ev.preventDefault();
94
- set(next);
95
- emit("end", clamp(next));
96
- }
97
- </script>
98
-
99
- <!-- APG window splitter: a focusable separator is interactive. -->
100
- <!-- eslint-disable vuejs-accessibility/no-static-element-interactions -->
101
- <template>
102
- <div
103
- class="wp-resize"
104
- role="separator"
105
- :tabindex="disabled ? -1 : 0"
106
- :aria-label="label"
107
- :aria-orientation="axis === 'x' ? 'vertical' : 'horizontal'"
108
- :aria-valuenow="modelValue"
109
- :aria-valuemin="min"
110
- :aria-valuemax="finiteMax"
111
- :aria-controls="controls"
112
- :aria-disabled="disabled || undefined"
113
- :data-axis="axis"
114
- :data-dragging="dragging || undefined"
115
- @pointerdown="onPointerDown"
116
- @pointermove="onPointerMove"
117
- @pointerup="onPointerUp"
118
- @pointercancel="onPointerUp"
119
- @dblclick="reset"
120
- @keydown="onKeydown"
121
- />
122
- </template>
123
-
124
- <style scoped>
125
- .wp-resize {
126
- position: relative; flex: none; z-index: 1; outline: none; touch-action: none;
127
- }
128
- .wp-resize[data-axis="x"] { width: 8px; margin: 0 -4px; cursor: col-resize; align-self: stretch; }
129
- .wp-resize[data-axis="y"] { height: 8px; margin: -4px 0; cursor: row-resize; width: 100%; }
130
- .wp-resize::after {
131
- content: ""; position: absolute; border-radius: min(1px, var(--wp-radius-cap, 999px)); background: transparent;
132
- transition: background var(--wp-motion-hover);
133
- }
134
- .wp-resize[data-axis="x"]::after { top: 0; bottom: 0; left: 3px; width: 2px; }
135
- .wp-resize[data-axis="y"]::after { left: 0; right: 0; top: 3px; height: 2px; }
136
- .wp-resize:hover::after, .wp-resize[data-dragging]::after { background: var(--wp-accent); }
137
- .wp-resize:focus-visible::after { background: var(--wp-border-focus); box-shadow: 0 0 0 1px var(--wp-border-focus); }
138
- .wp-resize[aria-disabled="true"] { cursor: default; }
139
- .wp-resize[aria-disabled="true"]::after { background: transparent; }
140
- @media (prefers-reduced-motion: reduce) {
141
- .wp-resize::after { transition: none; }
142
- }
143
- </style>
1
+ <script setup lang="ts">
2
+ /**
3
+ * Resize handle: the grip on a panel's edge that drags it wider or taller
4
+ * (a drawer's width, a column, a box's height). It owns the size in pixels
5
+ * through v-model; the parent puts that size on the panel. Works on the
6
+ * canvas and in the manager. Two panels side by side use SplitPane, which
7
+ * is built on this.
8
+ *
9
+ * <aside :style="{ width: `${w}px` }">…<ResizeHandle v-model="w" axis="x" reverse :min="280" :max="720" label="Chat width" /></aside>
10
+ *
11
+ * APG window splitter: `role="separator"` that takes focus; the arrows move
12
+ * it 16 px (Shift: 64), Home / End jump to min / max, Enter or a double
13
+ * click puts back `default-size`. `reverse` is for a handle on a panel's
14
+ * left or top edge, where dragging toward the start makes it bigger.
15
+ */
16
+ import { computed, ref } from "vue";
17
+
18
+ const props = withDefaults(defineProps<{
19
+ /** The panel's size in px. */
20
+ modelValue: number;
21
+ /** x: the handle changes width (an upright bar). y: height (a flat bar). */
22
+ axis?: "x" | "y" | undefined;
23
+ min?: number | undefined;
24
+ max?: number | undefined;
25
+ /** Dragging toward the start (left / up) makes the panel bigger. */
26
+ reverse?: boolean | undefined;
27
+ /** Where Enter and a double click put it back. */
28
+ defaultSize?: number | undefined;
29
+ /** Keyboard step in px. */
30
+ step?: number | undefined;
31
+ /** What it resizes, for screen readers ("Chat width"). */
32
+ label: string;
33
+ /** The id of the panel it resizes. */
34
+ controls?: string | undefined;
35
+ disabled?: boolean | undefined;
36
+ }>(), { axis: "x", min: 0, max: Number.POSITIVE_INFINITY, defaultSize: undefined, step: 16, controls: undefined });
37
+
38
+ const emit = defineEmits<{ (e: "update:modelValue", v: number): void; (e: "end", v: number): void }>();
39
+
40
+ const dragging = ref(false);
41
+ let start = 0;
42
+ let startSize = 0;
43
+
44
+ const clamp = (v: number): number => Math.round(Math.min(props.max, Math.max(props.min, v)));
45
+ const finiteMax = computed(() => (Number.isFinite(props.max) ? props.max : undefined));
46
+
47
+ function set(v: number): void {
48
+ const next = clamp(v);
49
+ if (next !== props.modelValue) emit("update:modelValue", next);
50
+ }
51
+
52
+ function onPointerDown(ev: PointerEvent): void {
53
+ if (props.disabled || ev.button !== 0) return;
54
+ ev.preventDefault();
55
+ dragging.value = true;
56
+ start = props.axis === "x" ? ev.clientX : ev.clientY;
57
+ startSize = props.modelValue;
58
+ (ev.currentTarget as HTMLElement).setPointerCapture?.(ev.pointerId);
59
+ }
60
+
61
+ function onPointerMove(ev: PointerEvent): void {
62
+ if (!dragging.value) return;
63
+ const d = (props.axis === "x" ? ev.clientX : ev.clientY) - start;
64
+ set(startSize + (props.reverse ? -d : d));
65
+ }
66
+
67
+ function onPointerUp(ev: PointerEvent): void {
68
+ if (!dragging.value) return;
69
+ dragging.value = false;
70
+ (ev.currentTarget as HTMLElement).releasePointerCapture?.(ev.pointerId);
71
+ emit("end", props.modelValue);
72
+ }
73
+
74
+ function reset(): void {
75
+ if (props.defaultSize === undefined || props.disabled) return;
76
+ set(props.defaultSize);
77
+ emit("end", clamp(props.defaultSize));
78
+ }
79
+
80
+ function onKeydown(ev: KeyboardEvent): void {
81
+ if (props.disabled) return;
82
+ const s = ev.shiftKey ? props.step * 4 : props.step;
83
+ const grow = props.reverse ? -1 : 1;
84
+ const fwd = props.axis === "x" ? "ArrowRight" : "ArrowDown";
85
+ const back = props.axis === "x" ? "ArrowLeft" : "ArrowUp";
86
+ let next: number;
87
+ if (ev.key === fwd) next = props.modelValue + s * grow;
88
+ else if (ev.key === back) next = props.modelValue - s * grow;
89
+ else if (ev.key === "Home") next = props.min;
90
+ else if (ev.key === "End" && finiteMax.value !== undefined) next = finiteMax.value;
91
+ else if (ev.key === "Enter") { ev.preventDefault(); reset(); return; }
92
+ else return;
93
+ ev.preventDefault();
94
+ set(next);
95
+ emit("end", clamp(next));
96
+ }
97
+ </script>
98
+
99
+ <!-- APG window splitter: a focusable separator is interactive. -->
100
+ <!-- eslint-disable vuejs-accessibility/no-static-element-interactions -->
101
+ <template>
102
+ <div
103
+ class="wp-resize"
104
+ role="separator"
105
+ :tabindex="disabled ? -1 : 0"
106
+ :aria-label="label"
107
+ :aria-orientation="axis === 'x' ? 'vertical' : 'horizontal'"
108
+ :aria-valuenow="modelValue"
109
+ :aria-valuemin="min"
110
+ :aria-valuemax="finiteMax"
111
+ :aria-controls="controls"
112
+ :aria-disabled="disabled || undefined"
113
+ :data-axis="axis"
114
+ :data-dragging="dragging || undefined"
115
+ @pointerdown="onPointerDown"
116
+ @pointermove="onPointerMove"
117
+ @pointerup="onPointerUp"
118
+ @pointercancel="onPointerUp"
119
+ @dblclick="reset"
120
+ @keydown="onKeydown"
121
+ />
122
+ </template>
123
+
124
+ <style scoped>
125
+ .wp-resize {
126
+ position: relative; flex: none; z-index: 1; outline: none; touch-action: none;
127
+ }
128
+ .wp-resize[data-axis="x"] { width: 8px; margin: 0 -4px; cursor: col-resize; align-self: stretch; }
129
+ .wp-resize[data-axis="y"] { height: 8px; margin: -4px 0; cursor: row-resize; width: 100%; }
130
+ .wp-resize::after {
131
+ content: ""; position: absolute; border-radius: min(1px, var(--wp-radius-cap, 999px)); background: transparent;
132
+ transition: background var(--wp-motion-hover);
133
+ }
134
+ .wp-resize[data-axis="x"]::after { top: 0; bottom: 0; left: 3px; width: 2px; }
135
+ .wp-resize[data-axis="y"]::after { left: 0; right: 0; top: 3px; height: 2px; }
136
+ .wp-resize:hover::after, .wp-resize[data-dragging]::after { background: var(--wp-accent); }
137
+ .wp-resize:focus-visible::after { background: var(--wp-border-focus); box-shadow: 0 0 0 1px var(--wp-border-focus); }
138
+ .wp-resize[aria-disabled="true"] { cursor: default; }
139
+ .wp-resize[aria-disabled="true"]::after { background: transparent; }
140
+ @media (prefers-reduced-motion: reduce) {
141
+ .wp-resize::after { transition: none; }
142
+ }
143
+ </style>