@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
package/src/WpSwitch.vue CHANGED
@@ -1,163 +1,163 @@
1
- <script setup lang="ts">
2
- /**
3
- * The on/off switch for canvas widgets and the manager (Toggle.vue wraps it).
4
- *
5
- * <WpSwitch v-model="held" label="Hold across run" /> track
6
- * <WpSwitch v-model="held" variant="chip" icon="pi-link" label="Hold across run" />
7
- *
8
- * `variant="track"` is a sliding knob; `variant="chip"` is a labelled chip
9
- * that lights up when on (the editors' Runtime row). `mixed` draws the
10
- * "some children on" state of a bulk switch; it still reads as off to a
11
- * screen reader (a switch has no mixed state).
12
- *
13
- * The root is a focusable span, not a button, so the switch can sit inside a
14
- * clickable header row (derivation rules) without nesting buttons. Space and
15
- * Enter flip it. A disabled switch stays in the tab order (aria-disabled, as
16
- * the ARIA guide allows) so its tooltip still says why it is off.
17
- *
18
- * One component on both sides means one stylesheet: the scoped block below
19
- * reads only SHARED_TOKENS, so it wears each side's colours. (Scoped and unlayered on purpose: the manager's Tailwind preflight
20
- * is unlayered and would beat a layered border.)
21
- */
22
- const props = withDefaults(
23
- defineProps<{
24
- modelValue?: boolean | undefined;
25
- variant?: "track" | "chip" | undefined;
26
- size?: "sm" | "md" | "lg" | undefined;
27
- label?: string | undefined;
28
- /** PrimeIcons class (e.g. `pi-lock`), drawn before the label. */
29
- icon?: string | undefined;
30
- mixed?: boolean | undefined;
31
- disabled?: boolean | undefined;
32
- invalid?: boolean | undefined;
33
- }>(),
34
- { modelValue: false, variant: "track", size: "sm", label: undefined, icon: undefined },
35
- );
36
-
37
- const emit = defineEmits<{ "update:modelValue": [next: boolean] }>();
38
-
39
- function flip(): void {
40
- if (props.disabled) return;
41
- emit("update:modelValue", !props.modelValue);
42
- }
43
- </script>
44
-
45
- <template>
46
- <span
47
- class="wp-switch"
48
- :class="[`wp-switch--${size}`, { 'wp-switch--chip': variant === 'chip', 'wp-switch--mixed': mixed && !modelValue }]"
49
- role="switch"
50
- :aria-checked="modelValue === true"
51
- :aria-disabled="disabled || undefined"
52
- :aria-invalid="invalid || undefined"
53
- tabindex="0"
54
- @click="flip"
55
- @keydown.space.stop.prevent="flip"
56
- @keydown.enter.prevent.stop="flip"
57
- >
58
- <span v-if="variant === 'track'" class="wp-switch__track" aria-hidden="true"><span class="wp-switch__knob" /></span>
59
- <i v-else-if="icon" class="pi wp-switch__icon" :class="icon" aria-hidden="true" />
60
- <slot><span v-if="label" class="wp-switch__label">{{ label }}</span></slot>
61
- </span>
62
- </template>
63
-
64
- <style scoped>
65
- /* Two looks. track: a sliding knob, for a setting that takes effect at once.
66
- * chip: a labelled chip that lights up when on (Hide from prompt, Lock...).
67
- * Heights follow the control scale (sm 24 / md 32 / lg 40). */
68
- .wp-switch {
69
- display: inline-flex;
70
- align-items: center;
71
- gap: var(--wp-space-3);
72
- min-height: 20px;
73
- flex-shrink: 0;
74
- color: var(--wp-text-muted);
75
- font: var(--wp-text-xs) / 1 var(--wp-font-sans);
76
- cursor: pointer;
77
- user-select: none;
78
- outline: none;
79
- -webkit-tap-highlight-color: transparent;
80
- }
81
- .wp-switch[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
82
- .wp-switch__label { color: var(--wp-text-muted); }
83
- .wp-switch--md, .wp-switch--lg { min-height: 24px; font-size: var(--wp-text-sm); }
84
-
85
- /* Track look */
86
- .wp-switch__track {
87
- --switch-w: 26px;
88
- --switch-h: 14px;
89
- position: relative;
90
- flex-shrink: 0;
91
- width: var(--switch-w);
92
- height: var(--switch-h);
93
- box-sizing: border-box;
94
- border: 1px solid var(--wp-border-strong);
95
- border-radius: var(--wp-radius-cap, 999px);
96
- background: var(--wp-bg-3);
97
- transition: background var(--wp-motion-quick), border-color var(--wp-motion-quick);
98
- }
99
- .wp-switch--md .wp-switch__track { --switch-w: 32px; --switch-h: 18px; }
100
- .wp-switch--lg .wp-switch__track { --switch-w: 40px; --switch-h: 22px; }
101
- .wp-switch__knob {
102
- position: absolute;
103
- top: 1px;
104
- left: 1px;
105
- width: calc(var(--switch-h) - 4px);
106
- height: calc(var(--switch-h) - 4px);
107
- border-radius: min(50%, var(--wp-radius-cap, 999px));
108
- background: var(--wp-text-dim);
109
- transition: transform var(--wp-motion-quick), background var(--wp-motion-quick);
110
- }
111
- .wp-switch:not([aria-disabled="true"]):hover .wp-switch__track { border-color: var(--wp-text-dim); }
112
- .wp-switch[aria-checked="true"] .wp-switch__track { background: var(--wp-accent); border-color: var(--wp-accent); }
113
- .wp-switch[aria-checked="true"] .wp-switch__knob {
114
- background: white; /* the knob on the accent track, both themes */
115
- transform: translateX(calc(var(--switch-w) - var(--switch-h)));
116
- }
117
- .wp-switch--mixed .wp-switch__track { border-style: dashed; border-color: var(--wp-accent); }
118
- .wp-switch--mixed .wp-switch__knob {
119
- background: var(--wp-accent);
120
- transform: translateX(calc((var(--switch-w) - var(--switch-h)) / 2));
121
- }
122
- .wp-switch:focus-visible .wp-switch__track,
123
- .wp-switch--chip:focus-visible { box-shadow: var(--wp-focus-ring); }
124
- .wp-switch[aria-invalid="true"] .wp-switch__track,
125
- .wp-switch--chip[aria-invalid="true"] { border-color: var(--wp-error-border); }
126
-
127
- /* Chip look */
128
- .wp-switch--chip {
129
- height: var(--wp-control-h-sm);
130
- min-height: 0;
131
- gap: var(--wp-space-3);
132
- padding: 0 var(--wp-space-4);
133
- box-sizing: border-box;
134
- border: 1px solid var(--wp-border);
135
- border-radius: var(--wp-radius-sm);
136
- background: var(--wp-bg);
137
- transition: border-color var(--wp-motion-quick), background var(--wp-motion-quick);
138
- }
139
- .wp-switch--chip.wp-switch--md { height: var(--wp-control-h-md); padding: 0 var(--wp-space-5); }
140
- .wp-switch--chip.wp-switch--lg { height: var(--wp-control-h-lg); padding: 0 var(--wp-space-6); }
141
- .wp-switch--chip .wp-switch__icon { font-size: var(--wp-text-xs); color: var(--wp-text-dim); }
142
- .wp-switch--chip:not([aria-disabled="true"]):hover { border-color: var(--wp-border-strong); }
143
- .wp-switch--chip[aria-checked="true"] {
144
- border-color: var(--wp-accent);
145
- color: var(--wp-accent-text);
146
- background: color-mix(in srgb, var(--wp-accent) 10%, transparent);
147
- }
148
- .wp-switch--chip[aria-checked="true"] .wp-switch__label,
149
- .wp-switch--chip[aria-checked="true"] .wp-switch__icon { color: var(--wp-accent-text); }
150
- .wp-switch--chip.wp-switch--mixed {
151
- border-style: dashed;
152
- border-color: var(--wp-accent);
153
- background: color-mix(in srgb, var(--wp-accent) 6%, transparent);
154
- }
155
- /* accent-text, not the raw accent: the raw ramp sits near 3:1 on light
156
- Tide / Ember pages. */
157
- .wp-switch--chip.wp-switch--mixed .wp-switch__label,
158
- .wp-switch--chip.wp-switch--mixed .wp-switch__icon { color: var(--wp-accent-text); }
159
-
160
- @media (prefers-reduced-motion: reduce) {
161
- .wp-switch__track, .wp-switch__knob, .wp-switch--chip { transition: none; }
162
- }
163
- </style>
1
+ <script setup lang="ts">
2
+ /**
3
+ * The on/off switch for canvas widgets and the manager (Toggle.vue wraps it).
4
+ *
5
+ * <WpSwitch v-model="held" label="Hold across run" /> track
6
+ * <WpSwitch v-model="held" variant="chip" icon="pi-link" label="Hold across run" />
7
+ *
8
+ * `variant="track"` is a sliding knob; `variant="chip"` is a labelled chip
9
+ * that lights up when on (the editors' Runtime row). `mixed` draws the
10
+ * "some children on" state of a bulk switch; it still reads as off to a
11
+ * screen reader (a switch has no mixed state).
12
+ *
13
+ * The root is a focusable span, not a button, so the switch can sit inside a
14
+ * clickable header row (derivation rules) without nesting buttons. Space and
15
+ * Enter flip it. A disabled switch stays in the tab order (aria-disabled, as
16
+ * the ARIA guide allows) so its tooltip still says why it is off.
17
+ *
18
+ * One component on both sides means one stylesheet: the scoped block below
19
+ * reads only SHARED_TOKENS, so it wears each side's colours. (Scoped and unlayered on purpose: the manager's Tailwind preflight
20
+ * is unlayered and would beat a layered border.)
21
+ */
22
+ const props = withDefaults(
23
+ defineProps<{
24
+ modelValue?: boolean | undefined;
25
+ variant?: "track" | "chip" | undefined;
26
+ size?: "sm" | "md" | "lg" | undefined;
27
+ label?: string | undefined;
28
+ /** PrimeIcons class (e.g. `pi-lock`), drawn before the label. */
29
+ icon?: string | undefined;
30
+ mixed?: boolean | undefined;
31
+ disabled?: boolean | undefined;
32
+ invalid?: boolean | undefined;
33
+ }>(),
34
+ { modelValue: false, variant: "track", size: "sm", label: undefined, icon: undefined },
35
+ );
36
+
37
+ const emit = defineEmits<{ "update:modelValue": [next: boolean] }>();
38
+
39
+ function flip(): void {
40
+ if (props.disabled) return;
41
+ emit("update:modelValue", !props.modelValue);
42
+ }
43
+ </script>
44
+
45
+ <template>
46
+ <span
47
+ class="wp-switch"
48
+ :class="[`wp-switch--${size}`, { 'wp-switch--chip': variant === 'chip', 'wp-switch--mixed': mixed && !modelValue }]"
49
+ role="switch"
50
+ :aria-checked="modelValue === true"
51
+ :aria-disabled="disabled || undefined"
52
+ :aria-invalid="invalid || undefined"
53
+ tabindex="0"
54
+ @click="flip"
55
+ @keydown.space.stop.prevent="flip"
56
+ @keydown.enter.prevent.stop="flip"
57
+ >
58
+ <span v-if="variant === 'track'" class="wp-switch__track" aria-hidden="true"><span class="wp-switch__knob" /></span>
59
+ <i v-else-if="icon" class="pi wp-switch__icon" :class="icon" aria-hidden="true" />
60
+ <slot><span v-if="label" class="wp-switch__label">{{ label }}</span></slot>
61
+ </span>
62
+ </template>
63
+
64
+ <style scoped>
65
+ /* Two looks. track: a sliding knob, for a setting that takes effect at once.
66
+ * chip: a labelled chip that lights up when on (Hide from prompt, Lock...).
67
+ * Heights follow the control scale (sm 24 / md 32 / lg 40). */
68
+ .wp-switch {
69
+ display: inline-flex;
70
+ align-items: center;
71
+ gap: var(--wp-space-3);
72
+ min-height: 20px;
73
+ flex-shrink: 0;
74
+ color: var(--wp-text-muted);
75
+ font: var(--wp-text-xs) / 1 var(--wp-font-sans);
76
+ cursor: pointer;
77
+ user-select: none;
78
+ outline: none;
79
+ -webkit-tap-highlight-color: transparent;
80
+ }
81
+ .wp-switch[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
82
+ .wp-switch__label { color: var(--wp-text-muted); }
83
+ .wp-switch--md, .wp-switch--lg { min-height: 24px; font-size: var(--wp-text-sm); }
84
+
85
+ /* Track look */
86
+ .wp-switch__track {
87
+ --switch-w: 26px;
88
+ --switch-h: 14px;
89
+ position: relative;
90
+ flex-shrink: 0;
91
+ width: var(--switch-w);
92
+ height: var(--switch-h);
93
+ box-sizing: border-box;
94
+ border: 1px solid var(--wp-border-strong);
95
+ border-radius: var(--wp-radius-cap, 999px);
96
+ background: var(--wp-bg-3);
97
+ transition: background var(--wp-motion-quick), border-color var(--wp-motion-quick);
98
+ }
99
+ .wp-switch--md .wp-switch__track { --switch-w: 32px; --switch-h: 18px; }
100
+ .wp-switch--lg .wp-switch__track { --switch-w: 40px; --switch-h: 22px; }
101
+ .wp-switch__knob {
102
+ position: absolute;
103
+ top: 1px;
104
+ left: 1px;
105
+ width: calc(var(--switch-h) - 4px);
106
+ height: calc(var(--switch-h) - 4px);
107
+ border-radius: min(50%, var(--wp-radius-cap, 999px));
108
+ background: var(--wp-text-dim);
109
+ transition: transform var(--wp-motion-quick), background var(--wp-motion-quick);
110
+ }
111
+ .wp-switch:not([aria-disabled="true"]):hover .wp-switch__track { border-color: var(--wp-text-dim); }
112
+ .wp-switch[aria-checked="true"] .wp-switch__track { background: var(--wp-accent); border-color: var(--wp-accent); }
113
+ .wp-switch[aria-checked="true"] .wp-switch__knob {
114
+ background: white; /* the knob on the accent track, both themes */
115
+ transform: translateX(calc(var(--switch-w) - var(--switch-h)));
116
+ }
117
+ .wp-switch--mixed .wp-switch__track { border-style: dashed; border-color: var(--wp-accent); }
118
+ .wp-switch--mixed .wp-switch__knob {
119
+ background: var(--wp-accent);
120
+ transform: translateX(calc((var(--switch-w) - var(--switch-h)) / 2));
121
+ }
122
+ .wp-switch:focus-visible .wp-switch__track,
123
+ .wp-switch--chip:focus-visible { box-shadow: var(--wp-focus-ring); }
124
+ .wp-switch[aria-invalid="true"] .wp-switch__track,
125
+ .wp-switch--chip[aria-invalid="true"] { border-color: var(--wp-error-border); }
126
+
127
+ /* Chip look */
128
+ .wp-switch--chip {
129
+ height: var(--wp-control-h-sm);
130
+ min-height: 0;
131
+ gap: var(--wp-space-3);
132
+ padding: 0 var(--wp-space-4);
133
+ box-sizing: border-box;
134
+ border: 1px solid var(--wp-border);
135
+ border-radius: var(--wp-radius-sm);
136
+ background: var(--wp-bg);
137
+ transition: border-color var(--wp-motion-quick), background var(--wp-motion-quick);
138
+ }
139
+ .wp-switch--chip.wp-switch--md { height: var(--wp-control-h-md); padding: 0 var(--wp-space-5); }
140
+ .wp-switch--chip.wp-switch--lg { height: var(--wp-control-h-lg); padding: 0 var(--wp-space-6); }
141
+ .wp-switch--chip .wp-switch__icon { font-size: var(--wp-text-xs); color: var(--wp-text-dim); }
142
+ .wp-switch--chip:not([aria-disabled="true"]):hover { border-color: var(--wp-border-strong); }
143
+ .wp-switch--chip[aria-checked="true"] {
144
+ border-color: var(--wp-accent);
145
+ color: var(--wp-accent-text);
146
+ background: color-mix(in srgb, var(--wp-accent) 10%, transparent);
147
+ }
148
+ .wp-switch--chip[aria-checked="true"] .wp-switch__label,
149
+ .wp-switch--chip[aria-checked="true"] .wp-switch__icon { color: var(--wp-accent-text); }
150
+ .wp-switch--chip.wp-switch--mixed {
151
+ border-style: dashed;
152
+ border-color: var(--wp-accent);
153
+ background: color-mix(in srgb, var(--wp-accent) 6%, transparent);
154
+ }
155
+ /* accent-text, not the raw accent: the raw ramp sits near 3:1 on light
156
+ Tide / Ember pages. */
157
+ .wp-switch--chip.wp-switch--mixed .wp-switch__label,
158
+ .wp-switch--chip.wp-switch--mixed .wp-switch__icon { color: var(--wp-accent-text); }
159
+
160
+ @media (prefers-reduced-motion: reduce) {
161
+ .wp-switch__track, .wp-switch__knob, .wp-switch--chip { transition: none; }
162
+ }
163
+ </style>