@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,199 +1,192 @@
1
- <script setup lang="ts">
2
- /**
3
- * The one search box: an inline magnifier, the text, an optional match count
4
- * or shortcut, and a ✕ that clears it.
5
- *
6
- * It replaced three look-alikes (ListFilter's own box, the import/export
7
- * PickerSearch, Input with a boxed search addon) and a dozen hand-built ones.
8
- * Lives in `components/shared/` and reads only SHARED_TOKENS, so the canvas
9
- * pickers and the manager draw the same box in their own colours. Canvas
10
- * callers pass `size="sm"`.
11
- *
12
- * - Attributes (`data-test`, `@keydown`, `@focus`…) land on the `<input>`;
13
- * `class`, `style` and `data-ai-*` stay on the box so a parent can size it.
14
- * - `visible` + `total` show "3 of 12" while there is a query; add `noun` to
15
- * also show "12 rules" when it's empty.
16
- * - Escape with text clears it and stops there; an empty box lets Escape
17
- * through so a dialog around it still closes.
18
- * - The count and ✕ get `<testPrefix>-count` / `<testPrefix>-clear`, where
19
- * `testPrefix` defaults to the input's own `data-test`.
20
- * - `focus()` and `select()` are exposed for pickers that focus on open.
21
- */
22
- import Kbd from "./Kbd.vue";
23
- import { computed, ref, useAttrs } from "vue";
24
-
25
- defineOptions({ inheritAttrs: false });
26
-
27
- const props = withDefaults(
28
- defineProps<{
29
- placeholder?: string | undefined;
30
- ariaLabel?: string | undefined;
31
- size?: "sm" | "md" | "lg" | undefined;
32
- /** Rows after filtering. With `total`, shows "visible of total". */
33
- visible?: number | undefined;
34
- total?: number | undefined;
35
- /** Plural noun for the idle count ("12 rules"). */
36
- noun?: string | undefined;
37
- /** A key hint shown while the box is empty, e.g. "/" or "Ctrl K". */
38
- shortcut?: string | undefined;
39
- clearLabel?: string | undefined;
40
- disabled?: boolean | undefined;
41
- testPrefix?: string | undefined;
42
- }>(),
43
- { placeholder: "Search…", size: "md", clearLabel: "Clear search" },
44
- );
45
-
46
- const query = defineModel<string>({ required: true });
47
-
48
- const attrs = useAttrs();
49
- /** The box keeps `class`, `style` and the AI pointer's `data-ai-*` marks (so
50
- * the pointer rings the whole box); everything else goes to the input. */
51
- const onRoot = (k: string): boolean => k === "class" || k === "style" || k.startsWith("data-ai-");
52
- const rootAttrs = computed(() => Object.fromEntries(Object.entries(attrs).filter(([k]) => onRoot(k))));
53
- const inputAttrs = computed(() => Object.fromEntries(Object.entries(attrs).filter(([k]) => !onRoot(k))));
54
- const prefix = computed(() => props.testPrefix ?? (attrs["data-test"] as string | undefined));
55
- const tid = (suffix: string): string | undefined => (prefix.value ? `${prefix.value}-${suffix}` : undefined);
56
-
57
- const hasQuery = computed(() => query.value.trim().length > 0);
58
- const counted = computed(() => props.total !== undefined && props.visible !== undefined);
59
-
60
- const field = ref<HTMLInputElement | null>(null);
61
-
62
- function clear(): void {
63
- query.value = "";
64
- field.value?.focus();
65
- }
66
-
67
- function onKeydown(ev: KeyboardEvent): void {
68
- if (ev.key === "Escape" && query.value) {
69
- ev.preventDefault();
70
- ev.stopPropagation();
71
- query.value = "";
72
- }
73
- }
74
-
75
- defineExpose({
76
- focus: () => field.value?.focus(),
77
- select: () => field.value?.select(),
78
- el: field,
79
- });
80
- </script>
81
-
82
- <template>
83
- <label
84
- class="wp-search"
85
- :class="[`wp-search--${size}`, { 'wp-search--on': hasQuery, 'is-disabled': disabled }]"
86
- v-bind="rootAttrs"
87
- >
88
- <i class="pi pi-search wp-search__icon" aria-hidden="true" />
89
- <input
90
- ref="field"
91
- v-model="query"
92
- class="wp-search__field"
93
- type="text"
94
- role="searchbox"
95
- :placeholder="placeholder"
96
- :aria-label="ariaLabel ?? placeholder"
97
- :disabled="disabled"
98
- spellcheck="false"
99
- autocomplete="off"
100
- v-bind="inputAttrs"
101
- @keydown="onKeydown"
102
- />
103
- <span
104
- v-if="counted && (hasQuery || noun)"
105
- class="wp-search__count"
106
- :data-zero="hasQuery && visible === 0 ? '' : null"
107
- :data-test="tid('count')"
108
- aria-live="polite"
109
- >
110
- <template v-if="hasQuery">{{ visible }} of {{ total }}</template>
111
- <template v-else>{{ total }} {{ noun }}</template>
112
- </span>
113
- <Kbd v-if="shortcut && !query" class="wp-search__kbd" :keys="shortcut" size="sm" aria-hidden="true" />
114
- <button
115
- v-if="query"
116
- type="button"
117
- class="wp-search__clear"
118
- :aria-label="clearLabel"
119
- :data-test="tid('clear')"
120
- :disabled="disabled"
121
- @click.prevent="clear"
122
- >
123
- <i class="pi pi-times" aria-hidden="true" />
124
- </button>
125
- </label>
126
- </template>
127
-
128
- <style scoped>
129
- .wp-search {
130
- display: flex;
131
- align-items: center;
132
- gap: var(--wp-space-2);
133
- min-width: 0;
134
- height: var(--wp-control-h-md);
135
- padding: 0 var(--wp-space-2) 0 var(--wp-space-3);
136
- background: var(--wp-bg-2);
137
- border: 1px solid var(--wp-border);
138
- border-radius: var(--wp-radius-sm);
139
- color: var(--wp-text);
140
- font-family: var(--wp-font-sans);
141
- font-size: var(--wp-text-sm);
142
- cursor: text;
143
- transition: border-color var(--wp-motion-quick), box-shadow var(--wp-motion-quick);
144
- }
145
- .wp-search--sm { height: var(--wp-control-h-sm); font-size: var(--wp-text-xs); gap: var(--wp-space-1); padding-left: var(--wp-space-2); }
146
- .wp-search--lg { height: var(--wp-control-h-lg); font-size: var(--wp-text-base); padding-left: var(--wp-space-4); }
147
- .wp-search:hover { border-color: var(--wp-border-strong); }
148
- .wp-search:focus-within { border-color: var(--wp-border-focus); box-shadow: var(--wp-focus-ring); }
149
- .wp-search--on { border-color: var(--wp-accent-500); }
150
- .wp-search.is-disabled { opacity: 0.45; cursor: not-allowed; }
151
-
152
- .wp-search__icon { flex-shrink: 0; font-size: 12px; line-height: 1; color: var(--wp-text-dim); }
153
- .wp-search--sm .wp-search__icon { font-size: 10px; }
154
- .wp-search--on .wp-search__icon,
155
- .wp-search:focus-within .wp-search__icon { color: var(--wp-text-muted); }
156
-
157
- .wp-search__field {
158
- flex: 1 1 8ch;
159
- min-width: 0;
160
- height: 100%;
161
- padding: 0;
162
- border: 0;
163
- background: none;
164
- color: inherit;
165
- font: inherit;
166
- outline: none;
167
- }
168
- .wp-search__field::placeholder { color: var(--wp-text-dim); }
169
- .wp-search__field:disabled { cursor: not-allowed; }
170
-
171
- .wp-search__count {
172
- flex-shrink: 0;
173
- color: var(--wp-text-dim);
174
- font-size: var(--wp-text-xs);
175
- font-variant-numeric: tabular-nums;
176
- white-space: nowrap;
177
- }
178
- .wp-search__count[data-zero] { color: var(--wp-danger); }
179
-
180
- .wp-search__kbd { flex-shrink: 0; }
181
-
182
- /* 20 px hit area even in the 24 px box; the mark draws at 9 px. */
183
- .wp-search__clear {
184
- display: grid;
185
- place-items: center;
186
- flex-shrink: 0;
187
- width: 20px;
188
- height: 20px;
189
- padding: 0;
190
- border: 0;
191
- border-radius: var(--wp-radius-sm);
192
- background: none;
193
- color: var(--wp-text-dim);
194
- cursor: pointer;
195
- }
196
- .wp-search__clear .pi { font-size: 9px; line-height: 1; }
197
- .wp-search__clear:hover { color: var(--wp-text); background: var(--wp-bg-3); }
198
- .wp-search__clear:focus-visible { outline: none; box-shadow: var(--wp-focus-ring); }
199
- </style>
1
+ <script setup lang="ts">
2
+ /**
3
+ * The one search box: an inline magnifier, the text, an optional match count
4
+ * or shortcut, and a ✕ that clears it.
5
+ *
6
+ * It replaced three look-alikes (ListFilter's own box, the import/export
7
+ * PickerSearch, Input with a boxed search addon) and a dozen hand-built ones.
8
+ * Lives in `components/shared/` and reads only SHARED_TOKENS, so the canvas
9
+ * pickers and the manager draw the same box in their own colours. Canvas
10
+ * callers pass `size="sm"`.
11
+ *
12
+ * - Attributes (`data-test`, `@keydown`, `@focus`…) land on the `<input>`;
13
+ * `class`, `style` and `data-ai-*` stay on the box so a parent can size it.
14
+ * - `visible` + `total` show "3 of 12" while there is a query; add `noun` to
15
+ * also show "12 rules" when it's empty.
16
+ * - Escape with text clears it and stops there; an empty box lets Escape
17
+ * through so a dialog around it still closes.
18
+ * - The count and ✕ get `<testPrefix>-count` / `<testPrefix>-clear`, where
19
+ * `testPrefix` defaults to the input's own `data-test`.
20
+ * - `focus()` and `select()` are exposed for pickers that focus on open.
21
+ */
22
+ import Kbd from "./Kbd.vue";
23
+ import { computed, ref, useAttrs } from "vue";
24
+
25
+ defineOptions({ inheritAttrs: false });
26
+
27
+ const props = withDefaults(
28
+ defineProps<{
29
+ placeholder?: string | undefined;
30
+ ariaLabel?: string | undefined;
31
+ size?: "sm" | "md" | "lg" | undefined;
32
+ /** Rows after filtering. With `total`, shows "visible of total". */
33
+ visible?: number | undefined;
34
+ total?: number | undefined;
35
+ /** Plural noun for the idle count ("12 rules"). */
36
+ noun?: string | undefined;
37
+ /** A key hint shown while the box is empty, e.g. "/" or "Ctrl K". */
38
+ shortcut?: string | undefined;
39
+ clearLabel?: string | undefined;
40
+ disabled?: boolean | undefined;
41
+ testPrefix?: string | undefined;
42
+ }>(),
43
+ { placeholder: "Search…", size: "md", clearLabel: "Clear search" },
44
+ );
45
+
46
+ const query = defineModel<string>({ required: true });
47
+
48
+ const attrs = useAttrs();
49
+ /** The box keeps `class`, `style` and the AI pointer's `data-ai-*` marks (so
50
+ * the pointer rings the whole box); everything else goes to the input. */
51
+ const onRoot = (k: string): boolean => k === "class" || k === "style" || k.startsWith("data-ai-");
52
+ const rootAttrs = computed(() => Object.fromEntries(Object.entries(attrs).filter(([k]) => onRoot(k))));
53
+ const inputAttrs = computed(() => Object.fromEntries(Object.entries(attrs).filter(([k]) => !onRoot(k))));
54
+ const prefix = computed(() => props.testPrefix ?? (attrs["data-test"] as string | undefined));
55
+ const tid = (suffix: string): string | undefined => (prefix.value ? `${prefix.value}-${suffix}` : undefined);
56
+
57
+ const hasQuery = computed(() => query.value.trim().length > 0);
58
+ const counted = computed(() => props.total !== undefined && props.visible !== undefined);
59
+
60
+ const field = ref<HTMLInputElement | null>(null);
61
+
62
+ function clear(): void {
63
+ query.value = "";
64
+ field.value?.focus();
65
+ }
66
+
67
+ function onKeydown(ev: KeyboardEvent): void {
68
+ if (ev.key === "Escape" && query.value) {
69
+ ev.preventDefault();
70
+ ev.stopPropagation();
71
+ query.value = "";
72
+ }
73
+ }
74
+
75
+ defineExpose({
76
+ focus: () => field.value?.focus(),
77
+ select: () => field.value?.select(),
78
+ el: field,
79
+ });
80
+ </script>
81
+
82
+ <template>
83
+ <label
84
+ class="wp-search wp-field-box"
85
+ :class="[`wp-search--${size}`, `wp-field-box--${size}`, { 'wp-search--on': hasQuery, 'is-disabled': disabled }]"
86
+ v-bind="rootAttrs"
87
+ >
88
+ <i class="pi pi-search wp-search__icon" aria-hidden="true" />
89
+ <input
90
+ ref="field"
91
+ v-model="query"
92
+ class="wp-search__field"
93
+ type="text"
94
+ role="searchbox"
95
+ :placeholder="placeholder"
96
+ :aria-label="ariaLabel ?? placeholder"
97
+ :disabled="disabled"
98
+ spellcheck="false"
99
+ autocomplete="off"
100
+ v-bind="inputAttrs"
101
+ @keydown="onKeydown"
102
+ />
103
+ <span
104
+ v-if="counted && (hasQuery || noun)"
105
+ class="wp-search__count"
106
+ :data-zero="hasQuery && visible === 0 ? '' : null"
107
+ :data-test="tid('count')"
108
+ aria-live="polite"
109
+ >
110
+ <template v-if="hasQuery">{{ visible }} of {{ total }}</template>
111
+ <template v-else>{{ total }} {{ noun }}</template>
112
+ </span>
113
+ <Kbd v-if="shortcut && !query" class="wp-search__kbd" :keys="shortcut" size="sm" aria-hidden="true" />
114
+ <button
115
+ v-if="query"
116
+ type="button"
117
+ class="wp-search__clear"
118
+ :aria-label="clearLabel"
119
+ :data-test="tid('clear')"
120
+ :disabled="disabled"
121
+ @click.prevent="clear"
122
+ >
123
+ <i class="pi pi-times" aria-hidden="true" />
124
+ </button>
125
+ </label>
126
+ </template>
127
+
128
+ <style scoped src="./field.css"></style>
129
+
130
+ <style scoped>
131
+ .wp-search {
132
+ display: flex;
133
+ align-items: center;
134
+ gap: var(--wp-space-2);
135
+ min-width: 0;
136
+ height: var(--wp-field-h);
137
+ padding: 0 var(--wp-space-2) 0 var(--wp-space-3);
138
+ font-family: var(--wp-font-sans);
139
+ cursor: text;
140
+ }
141
+ .wp-search--sm { gap: var(--wp-space-1); padding-left: var(--wp-space-2); }
142
+ .wp-search--lg { padding-left: var(--wp-space-4); }
143
+ .wp-search--on { border-color: var(--wp-accent-500); }
144
+
145
+ .wp-search__icon { flex-shrink: 0; font-size: 12px; line-height: 1; color: var(--wp-text-dim); }
146
+ .wp-search--sm .wp-search__icon { font-size: 10px; }
147
+ .wp-search--on .wp-search__icon,
148
+ .wp-search:focus-within .wp-search__icon { color: var(--wp-text-muted); }
149
+
150
+ .wp-search__field {
151
+ flex: 1 1 8ch;
152
+ min-width: 0;
153
+ height: 100%;
154
+ padding: 0;
155
+ border: 0;
156
+ background: none;
157
+ color: inherit;
158
+ font: inherit;
159
+ outline: none;
160
+ }
161
+ .wp-search__field::placeholder { color: var(--wp-text-dim); }
162
+ .wp-search__field:disabled { cursor: not-allowed; }
163
+
164
+ .wp-search__count {
165
+ flex-shrink: 0;
166
+ color: var(--wp-text-dim);
167
+ font-size: var(--wp-text-xs);
168
+ font-variant-numeric: tabular-nums;
169
+ white-space: nowrap;
170
+ }
171
+ .wp-search__count[data-zero] { color: var(--wp-danger); }
172
+
173
+ .wp-search__kbd { flex-shrink: 0; }
174
+
175
+ /* 20 px hit area even in the 24 px box; the mark draws at 9 px. */
176
+ .wp-search__clear {
177
+ display: grid;
178
+ place-items: center;
179
+ flex-shrink: 0;
180
+ width: 20px;
181
+ height: 20px;
182
+ padding: 0;
183
+ border: 0;
184
+ border-radius: var(--wp-radius-sm);
185
+ background: none;
186
+ color: var(--wp-text-dim);
187
+ cursor: pointer;
188
+ }
189
+ .wp-search__clear .pi { font-size: 9px; line-height: 1; }
190
+ .wp-search__clear:hover { color: var(--wp-text); background: var(--wp-bg-3); }
191
+ .wp-search__clear:focus-visible { outline: none; box-shadow: var(--wp-focus-ring); }
192
+ </style>