@dumiflex/wp-kit 0.7.0 → 0.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.0](https://github.com/DumiFlex/wp-kit/compare/v0.7.1...v0.8.0) (2026-11-03)
4
+
5
+
6
+ ### Features
7
+
8
+ * Chip stat tiles and DataTable rows that unfold ([8c1cade](https://github.com/DumiFlex/wp-kit/commit/8c1cade94cb5bd1900ca8fca948a4b18fa6ba4f5))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Lightbox closes on a click anywhere dark, the bar and around the picture included ([#79](https://github.com/DumiFlex/wp-kit/issues/79)) ([a6eb440](https://github.com/DumiFlex/wp-kit/commit/a6eb44053641342a96f795b2c75af82d5417c334))
14
+
15
+ ## [0.7.1](https://github.com/DumiFlex/wp-kit/compare/v0.7.0...v0.7.1) (2026-11-03)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * payload previews load their sheet once; SelectionBar says "1 report selected" ([#75](https://github.com/DumiFlex/wp-kit/issues/75)) ([d2774da](https://github.com/DumiFlex/wp-kit/commit/d2774dae3970f3b093778b0d84c5480a43961f9d))
21
+
3
22
  ## [0.7.0](https://github.com/DumiFlex/wp-kit/compare/v0.6.0...v0.7.0) (2026-11-03)
4
23
 
5
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dumiflex/wp-kit",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Vue 3 component kit shared by the Wildcard Pipeline manager, canvas and community site.",
5
5
  "keywords": [
6
6
  "vue",
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ // The shared preview sheet (wp-pv-* classes), loaded once for every preview.
3
+ import "./preview.css";
2
4
  /**
3
5
  * Bundle: what the bundle needs from outside vs what it sets (folded from
4
6
  * its children), then a child list beside the selected child's own full
@@ -195,7 +197,6 @@ const counts = computed(() => {
195
197
  </div>
196
198
  </template>
197
199
 
198
- <style scoped src="./preview.css"></style>
199
200
  <style scoped>
200
201
  .wp-bd-flow {
201
202
  display: grid;
package/src/Chip.vue CHANGED
@@ -18,6 +18,12 @@
18
18
  * filters reads at a glance. `count` puts a small number after the label.
19
19
  * `size`: `xs` (default, a label in a line of text), `sm` (24px, a filter
20
20
  * row) or `md` (32px, next to a md control).
21
+ *
22
+ * `variant="stat"` is the same chip as a tile: the `count` big on top, the
23
+ * label under it and a top edge in `color` (a summary row whose tiles also
24
+ * filter the list below):
25
+ *
26
+ * <Chip variant="stat" :color="roleColour(r)" :count="n" :pressed="on.has(r)" @click="flip(r)">{{ label }}</Chip>
21
27
  */
22
28
  import { computed, type Component } from "vue";
23
29
  import Icon from "./Icon.vue";
@@ -45,9 +51,11 @@ interface Props {
45
51
  /** A status dot before the label, in the chip's colour. */
46
52
  dot?: boolean | undefined;
47
53
  size?: "xs" | "sm" | "md" | undefined;
54
+ /** `pill` (default) or `stat`: a tile with the count big on top. */
55
+ variant?: "pill" | "stat" | undefined;
48
56
  disabled?: boolean | undefined;
49
57
  }
50
- const props = withDefaults(defineProps<Props>(), { tone: "default", as: "span", size: "xs", pressed: undefined });
58
+ const props = withDefaults(defineProps<Props>(), { tone: "default", as: "span", size: "xs", variant: "pill", pressed: undefined });
51
59
 
52
60
  const emit = defineEmits<{
53
61
  (e: "remove"): void;
@@ -56,19 +64,21 @@ const emit = defineEmits<{
56
64
  const toggle = computed(() => props.pressed !== undefined);
57
65
  const tag = computed(() => (toggle.value ? "button" : props.as));
58
66
  const pressable = computed(() => tag.value !== "span");
67
+ const stat = computed(() => props.variant === "stat");
59
68
  const classes = computed(() => [
60
69
  "wp-chip",
61
70
  `wp-chip--${props.size}`,
71
+ stat.value && "wp-chip--stat",
62
72
  pressable.value && "wp-chip--action",
63
73
  toggle.value && "wp-chip--toggle",
64
74
  toggle.value && props.color && "wp-chip--tinted",
65
- !toggle.value && (props.color ? "wp-chip--color" : props.tone !== "default" && `wp-chip--${props.tone}`),
75
+ !toggle.value && !stat.value && (props.color ? "wp-chip--color" : props.tone !== "default" && `wp-chip--${props.tone}`),
66
76
  ]);
67
77
 
68
78
  const colorStyle = computed(() => {
69
79
  if (!props.color) return undefined;
70
80
  const c = props.color;
71
- if (toggle.value) return { "--wp-chip-c": c };
81
+ if (toggle.value || stat.value) return { "--wp-chip-c": c };
72
82
  return {
73
83
  color: `color-mix(in oklab, ${c} 65%, var(--wp-text))`,
74
84
  background: `color-mix(in oklab, ${c} 18%, transparent)`,
@@ -94,9 +104,15 @@ function onRemove(e: MouseEvent) {
94
104
  <span v-if="dot" class="wp-chip__dot" aria-hidden="true" />
95
105
  <!-- 10px sub-ICON_SM: the chip font is 10.5px and a 12px icon read
96
106
  oversized next to it. Larger chips get a larger icon. -->
97
- <Icon v-if="icon" class="wp-chip__icon" :name="icon" :size="size === 'xs' ? 10 : 12" />
98
- <slot />
99
- <span v-if="count !== undefined" class="wp-chip__count">{{ count }}</span>
107
+ <Icon v-if="icon && !stat" class="wp-chip__icon" :name="icon" :size="size === 'xs' ? 10 : 12" />
108
+ <template v-if="stat">
109
+ <span v-if="count !== undefined" class="wp-chip__stat-n">{{ count }}</span>
110
+ <span class="wp-chip__stat-label"><slot /></span>
111
+ </template>
112
+ <template v-else>
113
+ <slot />
114
+ <span v-if="count !== undefined" class="wp-chip__count">{{ count }}</span>
115
+ </template>
100
116
  <button
101
117
  v-if="removable && !pressable"
102
118
  type="button"
@@ -163,4 +179,37 @@ function onRemove(e: MouseEvent) {
163
179
  background: color-mix(in oklab, var(--wp-chip-c) 22%, transparent);
164
180
  color: inherit;
165
181
  }
182
+
183
+ /* A stat tile: the count big on top, the label under it, a top edge in its
184
+ colour. Pressed, it fills with a little of that colour. */
185
+ .wp-chip--stat {
186
+ --wp-chip-c: var(--wp-border-strong);
187
+ box-sizing: border-box;
188
+ height: auto;
189
+ flex-direction: column;
190
+ align-items: flex-start;
191
+ gap: var(--wp-space-1);
192
+ padding: var(--wp-space-4) var(--wp-space-5);
193
+ border: 1px solid var(--wp-border);
194
+ border-top: 3px solid var(--wp-chip-c);
195
+ border-radius: min(8px, var(--wp-radius-cap, 999px));
196
+ background: var(--wp-bg-2);
197
+ color: var(--wp-text);
198
+ font-size: var(--wp-text-xs);
199
+ line-height: 1.3;
200
+ text-align: left;
201
+ white-space: normal;
202
+ }
203
+ .wp-chip--stat.wp-chip--toggle[aria-pressed="true"] {
204
+ border-color: var(--wp-chip-c);
205
+ background: color-mix(in oklab, var(--wp-chip-c) 12%, var(--wp-bg-2));
206
+ color: var(--wp-text);
207
+ }
208
+ .wp-chip__stat-n {
209
+ font-size: var(--wp-text-xl);
210
+ font-weight: var(--wp-weight-semibold);
211
+ font-variant-numeric: tabular-nums;
212
+ line-height: 1.2;
213
+ }
214
+ .wp-chip__stat-label { color: var(--wp-text-muted); }
166
215
  </style>
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ // The shared preview sheet (wp-pv-* classes), loaded once for every preview.
3
+ import "./preview.css";
2
4
  /** Combine: the template in its own block, its negative under it, and a
3
5
  * list of the variables it reads with where each one is used. */
4
6
  import { computed, ref } from "vue";
@@ -130,7 +132,6 @@ const shown = computed(() => (showAll.value ? inputs.value : inputs.value.slice(
130
132
  </div>
131
133
  </template>
132
134
 
133
- <style scoped src="./preview.css"></style>
134
135
  <style scoped>
135
136
  .wp-cb__out {
136
137
  font-family: var(--wp-font-mono);
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ // The shared preview sheet (wp-pv-* classes), loaded once for every preview.
3
+ import "./preview.css";
2
4
  /**
3
5
  * Constraint: counts up top, then the grouped matrix (ConstraintMatrixPreview)
4
6
  * or, for a big matrix, a searchable list of only the cells that do
@@ -226,7 +228,6 @@ function fmtFactor(f: number): string {
226
228
  </div>
227
229
  </template>
228
230
 
229
- <style scoped src="./preview.css"></style>
230
231
  <style scoped>
231
232
  .wp-cn-wrap {
232
233
  padding: 14px 16px 16px;
package/src/DataTable.vue CHANGED
@@ -20,9 +20,11 @@
20
20
  *
21
21
  * `row-clickable` makes each row open something (a trace, a detail panel):
22
22
  * rows take focus, and a click or Enter emits `row-click`. `active-key`
23
- * marks the row that is open.
23
+ * marks the row that is open. With a `#detail` slot the open row unfolds:
24
+ * the slot is drawn full width under it and each row says `aria-expanded`
25
+ * (toggle `active-key` in `row-click` to open and close it).
24
26
  */
25
- import { computed } from "vue";
27
+ import { computed, useSlots } from "vue";
26
28
  import Checkbox from "./Checkbox.vue";
27
29
  import Skeleton from "./Skeleton.vue";
28
30
 
@@ -146,6 +148,10 @@ function toggleRow(row: T, on: boolean): void {
146
148
  emit("update:selected", on ? [...props.selected.filter((x) => x !== k), k] : props.selected.filter((x) => x !== k));
147
149
  }
148
150
 
151
+ const slots = useSlots();
152
+ const hasDetail = computed(() => Boolean(slots.detail));
153
+ const isActive = (row: T): boolean => props.activeKey !== null && keyOf(row) === props.activeKey;
154
+
149
155
  const span = computed(() => props.columns.length + (props.selectable ? 1 : 0));
150
156
  </script>
151
157
 
@@ -212,13 +218,13 @@ const span = computed(() => props.columns.length + (props.selectable ? 1 : 0));
212
218
  </td>
213
219
  </tr>
214
220
  <template v-else>
221
+ <template v-for="(row, index) in shown" :key="keyOf(row)">
215
222
  <tr
216
- v-for="(row, index) in shown"
217
- :key="keyOf(row)"
218
223
  v-bind="rowAttrs ? rowAttrs(row) : {}"
219
224
  :aria-selected="selectable ? picked.has(keyOf(row)) : undefined"
220
225
  :data-selected="selectable && picked.has(keyOf(row)) ? 'true' : undefined"
221
- :data-active="activeKey !== null && keyOf(row) === activeKey ? 'true' : undefined"
226
+ :data-active="isActive(row) ? 'true' : undefined"
227
+ :aria-expanded="rowClickable && hasDetail ? isActive(row) : undefined"
222
228
  :data-clickable="rowClickable || undefined"
223
229
  :tabindex="rowClickable ? 0 : undefined"
224
230
  @click="rowClickable && emit('row-click', row)"
@@ -240,6 +246,10 @@ const span = computed(() => props.columns.length + (props.selectable ? 1 : 0));
240
246
  <slot :name="`cell-${c.key}`" :row="row" :value="cell(row, c.key)" :index="index">{{ cell(row, c.key) ?? "" }}</slot>
241
247
  </td>
242
248
  </tr>
249
+ <tr v-if="hasDetail && isActive(row)" class="wp-data-table__detail">
250
+ <td :colspan="span"><slot name="detail" :row="row" :index="index" /></td>
251
+ </tr>
252
+ </template>
243
253
  </template>
244
254
  </tbody>
245
255
  </table>
@@ -248,6 +258,7 @@ const span = computed(() => props.columns.length + (props.selectable ? 1 : 0));
248
258
 
249
259
  <style scoped>
250
260
  .wp-data-table { overflow: auto; }
261
+ .wp-data-table__detail > td { background: var(--wp-bg-2); }
251
262
  .wp-data-table th[data-align="right"], .wp-data-table td[data-align="right"] { text-align: right; }
252
263
  .wp-data-table th[data-align="center"], .wp-data-table td[data-align="center"] { text-align: center; }
253
264
  .wp-data-table th[data-align="right"] .wp-data-table__sort { flex-direction: row-reverse; }
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ // The shared preview sheet (wp-pv-* classes), loaded once for every preview.
3
+ import "./preview.css";
2
4
  /**
3
5
  * Derivation as rule cards: what it reads / writes / sends to negatives,
4
6
  * then per rule IF / ELSE IF / ELSE with nested AND / OR groups and every
@@ -191,7 +193,6 @@ function toggle(i: number): void {
191
193
  </div>
192
194
  </template>
193
195
 
194
- <style scoped src="./preview.css"></style>
195
196
  <style scoped>
196
197
  .wp-dv-io {
197
198
  display: flex;
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ // The shared preview sheet (wp-pv-* classes), loaded once for every preview.
3
+ import "./preview.css";
2
4
  /** Fixed values as a searchable variable → value → negative table, paged so
3
5
  * a long list stays short until asked. */
4
6
  import { computed, ref } from "vue";
@@ -181,4 +183,3 @@ function toggle(i: number): void {
181
183
  </div>
182
184
  </template>
183
185
 
184
- <style scoped src="./preview.css"></style>
package/src/Lightbox.vue CHANGED
@@ -102,11 +102,15 @@ watch(() => props.open, async (v, was) => {
102
102
  :aria-label="image ? `${image.alt}, ${at + 1} of ${count}` : 'Image viewer'"
103
103
  @click.self="close"
104
104
  >
105
- <div class="wp-lightbox__bar">
105
+ <!-- The bar spans the width: its empty part is dark area too, so it closes. -->
106
+ <!-- eslint-disable-next-line vuejs-accessibility/click-events-have-key-events, vuejs-accessibility/no-static-element-interactions -->
107
+ <div class="wp-lightbox__bar" @click.self="close">
106
108
  <span v-if="count > 1" class="wp-lightbox__count" aria-hidden="true">{{ at + 1 }} / {{ count }}</span>
107
109
  <Button variant="ghost" icon="times" aria-label="Close" class="wp-lightbox__close" kbd="Esc" @click="close" />
108
110
  </div>
109
- <figure v-if="image" class="wp-lightbox__figure" :data-zoom="zoom || undefined">
111
+ <!-- Space around a small picture is dark area too; the picture and its zoom keep their clicks. -->
112
+ <!-- eslint-disable-next-line vuejs-accessibility/click-events-have-key-events, vuejs-accessibility/no-static-element-interactions -->
113
+ <figure v-if="image" class="wp-lightbox__figure" :data-zoom="zoom || undefined" @click.self="close">
110
114
  <!-- An image with no src yet (still rendering): its shape, not an empty frame. -->
111
115
  <Skeleton v-if="!image.src" class="wp-lightbox__loading" shape="block" width="min(70vw, 640px)" height="min(60vh, 480px)" label="Still loading" />
112
116
  <WpImageZoom v-else-if="zoom" v-model:zoom="level" class="wp-lightbox__zoom" :src="image.src" :alt="image.alt" size="md" minimap />
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ // The shared preview sheet (wp-pv-* classes), loaded once for every preview.
3
+ import "./preview.css";
2
4
  /**
3
5
  * Rich, read-only preview of a published module or bundle payload: the
4
6
  * community post page and its embed draw it, and the manager can too.
@@ -146,7 +148,6 @@ const KNOWN = new Set(["wildcard", "fixed_values", "combine", "derivation", "con
146
148
  </p>
147
149
  </template>
148
150
 
149
- <style scoped src="./preview.css"></style>
150
151
  <style scoped>
151
152
  .wp-payload-raw {
152
153
  padding: 18px 24px 22px;
@@ -11,16 +11,20 @@
11
11
  * `#start` sits right after the count (a filter, an option), the default slot
12
12
  * on the right before Clear. `sticky` keeps it at the top of its scroll area
13
13
  * while the list scrolls under it (`--wp-selection-bar-top` moves it below a
14
- * fixed header). `noun` says what is selected ("3 options selected"). Escape
14
+ * fixed header). `noun` says what is selected ("3 options selected");
15
+ * `noun-one` is its singular for a count of 1 ("1 option selected"), by
16
+ * default the noun without its last "s". Escape
15
17
  * inside the bar clears, like Clear; the count is read out as it changes.
16
18
  */
17
- import { onBeforeUnmount, onMounted, ref } from "vue";
19
+ import { computed, onBeforeUnmount, onMounted, ref } from "vue";
18
20
  import Button from "./Button.vue";
19
21
 
20
22
  const props = withDefaults(defineProps<{
21
23
  count: number;
22
24
  /** What a row is, plural ("options"); left out it says "3 selected". */
23
25
  noun?: string | undefined;
26
+ /** The noun for one row ("option"); defaults to `noun` without its last "s". */
27
+ nounOne?: string | undefined;
24
28
  /** Stick to the top of the scroll area. */
25
29
  sticky?: boolean | undefined;
26
30
  /** Hide the Clear button (the host clears another way). */
@@ -28,10 +32,17 @@ const props = withDefaults(defineProps<{
28
32
  clearLabel?: string | undefined;
29
33
  /** The toolbar's accessible name. */
30
34
  label?: string | undefined;
31
- }>(), { noun: undefined, clearLabel: "Clear", label: "Bulk actions" });
35
+ }>(), { noun: undefined, nounOne: undefined, clearLabel: "Clear", label: "Bulk actions" });
32
36
 
33
37
  const emit = defineEmits<{ clear: [] }>();
34
38
 
39
+ /** "3 options selected", "1 option selected", or "3 selected" with no noun. */
40
+ const countText = computed(() => {
41
+ if (!props.noun) return `${props.count} selected`;
42
+ const one = props.nounOne ?? props.noun.replace(/s$/, "");
43
+ return `${props.count} ${props.count === 1 ? one : props.noun} selected`;
44
+ });
45
+
35
46
  function onKeydown(ev: KeyboardEvent): void {
36
47
  if (ev.key !== "Escape" || props.hideClear) return;
37
48
  ev.stopPropagation();
@@ -55,7 +66,7 @@ onBeforeUnmount(() => root.value?.removeEventListener("keydown", onKeydown));
55
66
  :data-sticky="sticky || undefined"
56
67
  data-test="selection-bar"
57
68
  >
58
- <span class="wp-selbar__count" aria-live="polite" data-test="selection-count">{{ count }}{{ noun ? ` ${noun}` : "" }} selected</span>
69
+ <span class="wp-selbar__count" aria-live="polite" data-test="selection-count">{{ countText }}</span>
59
70
  <slot name="start" />
60
71
  <span class="wp-selbar__spacer" />
61
72
  <slot />
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ // The shared preview sheet (wp-pv-* classes), loaded once for every preview.
3
+ import "./preview.css";
2
4
  /**
3
5
  * Wildcard preview built for big pools: a stats strip, search + filters,
4
6
  * tag facets with counts, and options as table rows (chance, tags,
@@ -504,7 +506,6 @@ function isLong(o: WildcardOption): boolean {
504
506
  </div>
505
507
  </template>
506
508
 
507
- <style scoped src="./preview.css"></style>
508
509
  <style scoped>
509
510
  .wp-wc__split[data-facets] {
510
511
  display: grid;
package/src/preview.css CHANGED
@@ -1,7 +1,10 @@
1
1
  /* Shared chrome for the per-type payload previews (stats strip, toolbar,
2
- row tables, section labels). Each preview pulls it in scoped
3
- (`<style scoped src="./preview.css">`), so it styles only that piece's own
4
- markup. Every selector is `.wp-pv-*`. */
2
+ row tables, section labels). Every preview imports it from its script
3
+ (`import "./preview.css"`), so a page carries ONE copy however many
4
+ previews it shows; pulled in scoped, each piece got its own copy (seven in
5
+ the community embed). Every selector is `.wp-pv-*`, so it is safe global.
6
+ Unlayered like button.css and menu.css: in @layer wp-extension a host's
7
+ unlayered reset (Tailwind's preflight) would strip its borders. */
5
8
 
6
9
  .wp-pv {
7
10
  container-type: inline-size;