vunor 0.4.2 → 0.4.4
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 +112 -0
- package/README.md +36 -6
- package/dist/theme.d.mts +15 -2
- package/dist/theme.mjs +29 -7
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.4.4
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `replaceShortcut` from `vunor/theme`: replaces a built-in shortcut instead of merging into it. A shortcut of yours with the same name as a built-in one is merged with it (its classes are appended); mark your entry to drop vunor's definition and keep only your classes: `vunorShortcuts(defineShortcuts({ press: replaceShortcut({ 'active:': 'scale-95' }) }))`. It takes any form a normal entry takes (a string, an array or a shortcut object) and goes on the shortcut name, not on a variant key. In `mergeVunorShortcuts([a, b, c])` a marked entry drops the definitions of its name from the earlier lists, later lists merge on top of it as usual, and the mark survives the merge, so a map composed with `mergeVunorShortcuts` and passed to `vunorShortcuts()` still replaces the built-in shortcut.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- `vunorShortcuts()` no longer changes the exported `mergedVunorShortcuts` object (it turned its shortcut objects into strings in place), and an array entry (`'my-row': ['p-2', 'm-1']`) now becomes `p-2 m-1` (it became `0p-2 1m-1`).
|
|
12
|
+
- In a shortcut object, an array item holding several classes gets the variant prefix on each class: `{ 'hover:': ['p-2 m-1'] }` becomes `hover:p-2 hover:m-1` (it became `hover:p-2 m-1`).
|
|
13
|
+
- The `press` notes for 0.4.2 advised `transition-[scale]` to ease the press, but that class generates no CSS. Use `[transition-property:scale] duration-150`.
|
|
14
|
+
|
|
15
|
+
## 0.4.3
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- The npm package now ships this `CHANGELOG.md`, so the notes for a release are in `node_modules/vunor/` next to the code. No code changes.
|
|
20
|
+
|
|
21
|
+
## 0.4.2
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- `press` shortcut: press feedback for any clickable. An enabled element shrinks to `scale: var(--press-scale, 0.97)` while it is `:active`, on touch and mouse. It ignores `data-active`, which Reka UI and vunor use for "current" (selected tab, pressed toggle, open popover trigger). It uses the `scale` property, so it stacks with translate/rotate utilities, sets no transition (add `[transition-property:scale] duration-150` to ease it) and clears the iOS tap highlight. An app that passes its own `press` shortcut to `vunorShortcuts()` gets vunor's rule merged into it; mark the app's one with `replaceShortcut` (0.4.4) or rename it.
|
|
26
|
+
- `whenHover`, `whenHoverIdle` and `whenCanHover` from `vunor/theme`: variant-prefix keys for your own shortcuts that apply hover only on devices whose primary input can hover. Use `whenHoverIdle` when the shortcut also paints `active:`.
|
|
27
|
+
- `whenEnabled` and `whenDisabled` from `vunor/theme`: the variant-prefix keys for vunor's shared disabled definition, needed to override c8 states (see below).
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Hover paint is applied only on devices whose primary input can hover (`@media (hover: hover)`): the `c8-*` families, `i8-bare`, `i8-icon-clickable`, `calendar-cell`, `slider-thumb`, `combobox-c8-icon` and `dialog-close`. A tap on a touch screen no longer leaves a hover wash stuck on. Press (`:active`), `:focus-visible` and `[data-highlighted]` are not gated. While the mouse presses, the press paint still wins. Other differences on a device that can hover:
|
|
32
|
+
- **Overrides of a c8 hover must move.** An override written as `'c8-x': { [whenEnabled]: { 'hover:': '…' } }` now compiles to a separate, less specific rule and loses. Write `'c8-x': { [whenEnabled]: { [whenHoverIdle]: '…' } }`; it merges into vunor's rule and wins.
|
|
33
|
+
- In dark mode, pressing a `calendar-cell` shows the 15% press tint; it used to keep the solid 700 hover fill.
|
|
34
|
+
- `c8-filled` now rests on `scope-color-600` and goes to 700 on hover and 800 on press, in light and dark mode. On 500 its white text measured 3.4–4.1:1 against the default palette, below WCAG AA, and the lighter dark-mode hover and press fills (400, 300) measured 2.1–3.0:1. White text now reaches at least 4.5:1 on every fill for every default palette colour (lowest: `good-600`, 4.62:1). Filled buttons are one shade darker, and in dark mode hover and press darken instead of lightening. In dark mode the button also gets a 1px inset rim in `scope-color-500` (a `ring-inset` box-shadow that composes with `shadow-*`): 600–800 sit at 1.7–3.6:1 against the dark layers, the rim at 3.05:1 or more against every one. The selected `VuCalendar` day (which uses `c8-filled`) changes the same way. With a tuned palette, check your 600 shades: `mainPalette.preserveInputColor: true` with `good: '#22c55e'` gives `good-600` only 4.18:1.
|
|
35
|
+
- Not changed: the checkbox and radio fills, the slider thumb and range and the tab indicator stay on `scope-color-500`. They carry no text; their marks (the white check and radio dot) and fills reach the 3:1 non-text contrast at 500 (3.4:1 or more against white, 3.05:1 or more against the dark layers).
|
|
36
|
+
|
|
37
|
+
## 0.4.1
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
|
|
41
|
+
- `presetVunor({ baseStyles })`, default `true`. Set it to `false` when the app styles its own page: the page-level element rules go (the body, figcaption and h1–h6 typography, including a level's `font` and `css` from `typography`, and the scrollbar styling). The theme variables on `:root` and the body `--font-*` variables stay, as do all shortcuts and classes.
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- `VuSelect`'s `v-model` type now follows `multiple`: an array with `multiple`, a single value without it. Before, the type did not follow `multiple`.
|
|
46
|
+
|
|
47
|
+
## 0.4.0
|
|
48
|
+
|
|
49
|
+
### Breaking
|
|
50
|
+
|
|
51
|
+
- `vue` (`^3.5.0`), `unocss` (`^66.2.1`) and `reka-ui` (`^2.8.0`) are now **peer dependencies** (they were dependencies). The app provides them, so it has a single copy of each. npm and pnpm install missing peers automatically; list them in your app to pin versions: `pnpm add vunor vue unocss reka-ui`. The floors are measured: the dist checks pass with reka-ui 2.8.0 (older 2.x releases do not render popups with Vue 3.4), reka-ui 2.8 needs `@vueuse/core` 14, which needs Vue 3.5, and the theme generates identical CSS from unocss 66.2.1 on (66.2.0 and older miss arbitrary custom-property utilities).
|
|
52
|
+
- `@unocss/preset-mini` is no longer a dependency: types come from `unocss/preset-mini` (no second `@unocss` copy).
|
|
53
|
+
- `@nuxt/kit` and `@nuxt/schema` are optional peer dependencies, used only by `vunor/nuxt`.
|
|
54
|
+
|
|
55
|
+
### Intended changes of default behaviour
|
|
56
|
+
|
|
57
|
+
The dist test compares what each component passes to its Reka/vunor parts by default with
|
|
58
|
+
0.3.2; these are the only differences:
|
|
59
|
+
|
|
60
|
+
- `VuCheckbox` is no longer `required` by default (it always set `required` on the checkbox, which would block form submission now that `name` is forwarded). Pass `required` to require it.
|
|
61
|
+
- `VuButton` renders `aria-pressed` only when `pressed` is passed, and `aria-selected` only when `selected` is passed **and** the button has a role that allows it (`option`, `tab`, `gridcell`, `row`, `columnheader`, `rowheader`, `treeitem`, e.g. inside a listbox). Before, every button rendered `aria-pressed="false" aria-selected="false"`. `selected` now also sets `data-selected`, which `c8-*` styles like `aria-selected`.
|
|
62
|
+
- `VuButton` with `to`: the active router link gets `data-selected="true"` and, when exactly active, `aria-current="page"`, instead of the invalid `aria-selected` on a link. The `c8-flat` look is the same.
|
|
63
|
+
- `id`: on `VuCheckbox` it goes to the checkbox control (for `<label for>`), not the wrapper div. On `VuPopover` (and a `multiple` + `groupItem` `VuCombobox`) the trigger keeps Reka's id, which links it to the popup; an `id` you pass is not applied there.
|
|
64
|
+
- Button-only props (`active`, `pressed`, `selected`, `asLink`, `to`) no longer appear as DOM attributes.
|
|
65
|
+
- Wrappers no longer pass `false` for boolean props you did not set, so Reka's own defaults apply (for example the hidden date input of `VuDatePicker` is no longer `required="false"`).
|
|
66
|
+
- `VuPopover` no longer passes its own props to the popup as attributes (`as-link`, `model-value`, … appeared on the popup element).
|
|
67
|
+
- Removed invalid `as-child` attributes from `VuCombobox`'s popup portal and `VuPopover`'s root (they did nothing and warned in development).
|
|
68
|
+
- `VuButton` no longer renders an empty `style=""` attribute.
|
|
69
|
+
- `default-open` works on `VuPopover`, `VuSelect`, `VuSelectBase`, `VuCombobox`, `VuDatePicker` and `VuDatePickerBase`: when you do not bind `open` (`v-model:open`), the `open` model is now `undefined` (Reka's "uncontrolled") instead of `false`, which kept the popup closed and ignored `default-open`. Likewise `VuCheckbox` `default-value` works: its model is `undefined` until you bind it.
|
|
70
|
+
- What a component exposes about that state now always matches the Reka root, also when it is uncontrolled: slot props (`VuPopover` `isOpen`, `VuSelectBase` `open` / `value` / `displayItem`), the open-state styling (`data-active` / `data-group-active` on the Select, Combobox and date picker shells, the Popover trigger), `openPopup()` (one call toggles once), the Checkbox mark, the Slider value label and the Select / Combobox shown label with `default-value`. `VuDialog` uses the same rule: `default-open` opens it without emitting `update:open`.
|
|
71
|
+
- Like Reka, components read `default-open` / `default-value` once, when they mount: changing it later has no effect, and what the component exposes stays in step with the Reka root. When you clear a bound model (`v-model` back to `undefined`), the exposed state falls back exactly like the root (for example `VuSlider`'s label shows Reka's default `0`, not nothing), and the component does not emit.
|
|
72
|
+
- Behaviour change: with `multiple`, `VuCombobox`'s `open` (`v-model:open`, `default-open`) is the popover the user opens with the field. In 0.3.2 it described the option list inside the popover, which is always open: mounting emitted `update:open(true)` with the popover closed, the first open emitted nothing, and a bound `:open` did not open the popover. Now mounting emits nothing, each open and close emits one `update:open`, a bound `:open` / `default-open` opens the popover, and the field's open-state styling (`data-expanded`, `data-active`) follows the popover.
|
|
73
|
+
- Clearing a `multiple` `VuCombobox` (its clear icon) now emits `[]` (0.3.2 emitted `undefined`), so the selection is empty rather than handed back to the uncontrolled default.
|
|
74
|
+
- One click toggles a popup once. A click on a field's append icon (the chevron) also reached the field around it, and both toggled: the `VuCombobox` chevron (single and `groupItem`) could not open its popup, and in `multiple` mode a second chevron click did not close it. Every wrapper now routes a gesture to exactly one toggle (`VuCombobox`, `VuSelect`, `VuSelectBase`, `VuDatePicker`, `VuDatePickerBase`, `VuPopover`); the Reka triggers they render are marked `data-vu-trigger` and toggle by themselves.
|
|
75
|
+
- The `VuDatePicker` / `VuDatePickerBase` calendar icon is keyboard-operable: it is a `role="button"` with an `aria-label`, and Enter / Space open and close the calendar (it reacted to clicks only).
|
|
76
|
+
- A popup whose `v-model:open` went back to `undefined` after being set no longer passes `undefined` to Reka (`Invalid prop "present"` warning in development): once set, the open state handed to Reka stays a boolean.
|
|
77
|
+
- `VuCombobox`: the field shows its open state (`data-group-active`, like `VuSelect`), and `popupPosition` / `sticky` apply.
|
|
78
|
+
- `VuCombobox` with `groupItem`: moving the pointer off the input clears the keyboard highlight, and the reading direction applies, as in non-`groupItem` mode. Reka's listbox wiring (`dir`, pointer-leave and focus-out handlers) now reaches the input, and the wrapper classes `relative w-full h-full` are no longer passed down (in 0.3.2 both were merged into a hidden template node and never reached the DOM).
|
|
79
|
+
- `VuMenu` highlights its first item when it opens (Reka's default). In 0.3.2 the item buttons rendered a Fragment root, so Reka could not register the items.
|
|
80
|
+
- `VuDatePicker` / `VuDatePickerBase` render their input shell (see Fixes), so the date field, its trigger and the popup's `aria-labelledby` now exist by default.
|
|
81
|
+
|
|
82
|
+
Defaults kept on purpose: `VuCombobox` keeps the typed text on blur (`resetSearchTermOnBlur` defaults to `false`; Reka's default is `true`), and `VuPopover` keeps collision handling off (`avoidCollisions`, `sideFlip`, `alignFlip`, `hideShiftedArrow` default to `false`; pass them to opt in).
|
|
83
|
+
|
|
84
|
+
### Fixes
|
|
85
|
+
|
|
86
|
+
- Components are compiled in production mode. Before, template comments next to a root element turned it into a Fragment, and production apps silently lost `class`, `@click` and `aria-*` on `VuButton`, `VuButtonBase`, `VuCheckbox` and `VuMenuItem`.
|
|
87
|
+
- Every component forwards fallthrough attributes (`class`, `style`, `id`, `data-*`, `aria-*`, listeners) to its rendered root, including components whose Reka root renders no element (`VuDialog`, `VuPopover`, `VuSelect`, `VuSelectBase`, `VuDatePickerBase`, `VuAppToasts`, `VuCombobox`).
|
|
88
|
+
- Props and events of the wrapped Reka component pass through, for example `VuSelect`/`VuSelectBase` `name`, `multiple`, `by`, `dir`, `autocomplete`, `v-model:open`; `VuPopover` `v-model:open`, `modal`, `default-open` and the content events; `VuCombobox` `name`, `by`, `open-on-focus`, `@highlight` and more; `@update:placeholder` on `VuCalendar` and `VuDatePicker`. `name` now submits the value with the enclosing form.
|
|
89
|
+
- `vunor/nuxt` no longer throws `ReferenceError: __vue_files__ is not defined` on import.
|
|
90
|
+
- `VuDatePickerBase` renders `VuInputBase` (it rendered an unknown `<vuinputbase>` element).
|
|
91
|
+
- `VuCombobox` no longer imports `@vueuse/core` (it was not a dependency), and no longer warns about a readonly computed on every mount.
|
|
92
|
+
- A disabled or loading `VuButton` rendered as a link (`to`, `as-link`) no longer navigates or fires `@click`: it drops `href` (so middle-click and "open in new tab" have nothing to follow) and stays a focusable link (`role="link"`, `aria-disabled="true"`, `tabindex="0"`). `VuButtonBase` no longer renders the invalid `disabled` attribute on `<a>`.
|
|
93
|
+
- `VuButton`: `to` uses the app's `RouterLink` (no `vue-router` import; its type is structural) and navigates client-side; without a router, a string `to` renders `<a href>` and warns in dev.
|
|
94
|
+
- `@click` on `VuSelect` and `VuCombobox` fires in `groupItem` mode too.
|
|
95
|
+
- `VuSelect` / `VuSelectBase` types: the model is `string`, or `string[]` with `multiple`.
|
|
96
|
+
- `VuSlider` no longer calls `@update:model-value` twice per change.
|
|
97
|
+
- `VuAppToasts` forwards `hotkey` to the toast viewport.
|
|
98
|
+
- The published `dist/` is rebuilt from scratch, so no stale chunks are shipped.
|
|
99
|
+
- `VuCheckbox` forwards `name`, `value`, `true-value`, `false-value` and `default-value` to the checkbox control.
|
|
100
|
+
- `VuRadioGroup` forwards `name`, `required`, `orientation`, `dir` and `loop`.
|
|
101
|
+
- `VuDialog` supports `default-open` and `disable-outside-pointer-events`, and no longer points `aria-describedby` at a missing description.
|
|
102
|
+
- `VuOverflowContainer` no longer hangs when it has no width (hidden or not laid out).
|
|
103
|
+
- `VuInputBase` used outside `VuInput` no longer warns about a missing injection.
|
|
104
|
+
- `VuCheckbox` shows its checkmark from Reka's own state: with custom `true-value` / `false-value`, and inside a Reka `CheckboxGroupRoot` (the group's model decides), the mark now matches the checkbox.
|
|
105
|
+
- `VuCombobox` with `open-on-click` / `open-on-focus`: a click on the input opens the popup once (one `update:open`) instead of opening and immediately closing it; the chevron still toggles.
|
|
106
|
+
- A disabled or loading `VuButton` link also ignores `@click.once`, `@click.capture` and `@click.passive` listeners.
|
|
107
|
+
- `VuSelectBase` with `multiple`: its slot `value` is `[]` when nothing is selected, as in Reka (it was `undefined`).
|
|
108
|
+
- `VuDialog` footer buttons no longer warn in development (`Component emitted event "footer-click-ok" but it is neither declared …`) and no longer put the `@footer-click-<label>` listeners on the dialog card element. The event names are unchanged: `footer-click` (with the label) and `footer-click-<label>` (lower-cased, spaces removed). `.once`, kebab-case and `v-on` object listeners work for `footer-click-<label>` as for any Vue event.
|
|
109
|
+
|
|
110
|
+
### Known trade-off
|
|
111
|
+
|
|
112
|
+
- Because components are compiled in production mode, their props carry no runtime type information (only what boolean casting needs). Apps no longer get Vue's "Invalid prop type" warnings for vunor components in development; TypeScript types are unchanged.
|
package/README.md
CHANGED
|
@@ -201,13 +201,15 @@ defineShortcuts({
|
|
|
201
201
|
})
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
+
`whenCanHover` is the bare `@media (hover: hover)` prefix, for a hover selector of your own: ``[`${whenCanHover}[&>.icon:hover]:`]: 'text-current-hl'``.
|
|
205
|
+
|
|
204
206
|
### Compound Variants
|
|
205
207
|
|
|
206
208
|
Nesting can go deeper for compound variants:
|
|
207
209
|
|
|
208
210
|
```ts
|
|
209
211
|
defineShortcuts({
|
|
210
|
-
'
|
|
212
|
+
'my-btn': {
|
|
211
213
|
'': 'current-bg-scope-color-500 text-white rounded-base',
|
|
212
214
|
'hover:': 'current-bg-scope-color-400',
|
|
213
215
|
'dark:': {
|
|
@@ -221,7 +223,7 @@ defineShortcuts({
|
|
|
221
223
|
|
|
222
224
|
### Why Objects Instead of Strings?
|
|
223
225
|
|
|
224
|
-
**Because they merge.** When two shortcut objects define the same key, `mergeVunorShortcuts()`
|
|
226
|
+
**Because they merge.** When two shortcut objects define the same key, `mergeVunorShortcuts()` merges them, appending the later entry's classes. This is the key to Vunor's customization model: you can surgically override a single variant of a built-in style without rewriting the whole shortcut.
|
|
225
227
|
|
|
226
228
|
For example, to make all filled buttons pill-shaped while keeping every other variant (hover, active, dark mode, disabled) intact:
|
|
227
229
|
|
|
@@ -230,10 +232,10 @@ import { vunorShortcuts, defineShortcuts } from 'vunor/theme'
|
|
|
230
232
|
|
|
231
233
|
const myOverrides = defineShortcuts({
|
|
232
234
|
'c8-filled': {
|
|
233
|
-
'': 'rounded-full', //
|
|
235
|
+
'': 'rounded-full', // added to the base classes
|
|
234
236
|
},
|
|
235
237
|
'i8-flat': {
|
|
236
|
-
'': 'border-b-2', //
|
|
238
|
+
'': 'border-b-2', // added to the base classes
|
|
237
239
|
},
|
|
238
240
|
})
|
|
239
241
|
|
|
@@ -243,10 +245,36 @@ export default defineConfig({
|
|
|
243
245
|
})
|
|
244
246
|
```
|
|
245
247
|
|
|
246
|
-
Your `'c8-filled'.'':`
|
|
248
|
+
Your `'c8-filled'.'':` classes are added to the base classes of `c8-filled`, while all its `hover:`, `dark:`, `active:` variants remain intact from the defaults. Everything flows through a single merge pipeline, producing consistent CSS passed to UnoCSS.
|
|
247
249
|
|
|
248
250
|
`vunorShortcuts()` returns the merged default shortcuts for all built-in styles (c8, i8, card, dialog, etc.). Pass your overrides as the first argument -- they take priority.
|
|
249
251
|
|
|
252
|
+
### Replacing a Built-in Shortcut
|
|
253
|
+
|
|
254
|
+
To drop a built-in shortcut and use only your own classes under its name, mark your entry with `replaceShortcut`:
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
import { defineShortcuts, replaceShortcut, vunorShortcuts } from 'vunor/theme'
|
|
258
|
+
|
|
259
|
+
const mine = defineShortcuts({
|
|
260
|
+
// vunor's own `press` is dropped; only these classes remain
|
|
261
|
+
'press': replaceShortcut({ 'active:': 'scale-95' }),
|
|
262
|
+
// a normal entry still merges into vunor's c8-filled
|
|
263
|
+
'c8-filled': { '': 'rounded-full' },
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
export default defineConfig({
|
|
267
|
+
presets: [presetVunor()],
|
|
268
|
+
shortcuts: [vunorShortcuts(mine)],
|
|
269
|
+
})
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`replaceShortcut` takes any form a normal entry takes (a string, an array or a shortcut object). Put it on the shortcut name, not on a variant key inside a shortcut (there it has no effect). In `mergeVunorShortcuts([a, b, c])` a marked entry drops the definitions of its name from the earlier lists, and entries in later lists merge on top of it as usual. The mark survives the merge, so `vunorShortcuts(mergeVunorShortcuts([x, y]))` still replaces the built-in shortcut when `y` marks it.
|
|
273
|
+
|
|
274
|
+
Without vunor's merge, plain UnoCSS does the same: a shortcut in a later map of the `shortcuts` array replaces an earlier one of the same name, so `shortcuts: [vunorShortcuts(), { press: 'active:scale-95' }]` also drops vunor's `press`.
|
|
275
|
+
|
|
276
|
+
An app shortcut with the same name as a built-in one is merged with it unless it is marked: when a vunor release adds a shortcut whose name your app already uses, mark your app's one with `replaceShortcut` (or rename it).
|
|
277
|
+
|
|
250
278
|
---
|
|
251
279
|
|
|
252
280
|
## Semantic CSS Classes
|
|
@@ -325,7 +353,9 @@ vunorShortcuts(
|
|
|
325
353
|
)
|
|
326
354
|
```
|
|
327
355
|
|
|
328
|
-
|
|
356
|
+
`whenEnabled` and `whenDisabled` are the variant-prefix keys for the shared disabled definition above. Use them in your own shortcuts so a state matches the same elements vunor treats as disabled: `{ [whenEnabled]: { 'active:': 'bg-current/20' }, [whenDisabled]: 'cursor-not-allowed' }`.
|
|
357
|
+
|
|
358
|
+
For press feedback on any clickable, add `press`: it shrinks an enabled element slightly while it is `:active` (`[--press-scale:0.9]` changes the amount; add `[transition-property:scale] duration-150` to ease it). It ignores `data-active`, which Reka UI and vunor use for "current" (selected tab, pressed toggle, open popover trigger).
|
|
329
359
|
|
|
330
360
|
The `btn` layout primitive fades a disabled element to opacity 0.8. That is a default: `disabled-soft` (0.4) or a `disabled:opacity-*` utility replaces it, whether written on the element or composed with `btn` in your own shortcut (`'my-btn': 'btn disabled-soft'`).
|
|
331
361
|
|
package/dist/theme.d.mts
CHANGED
|
@@ -370,9 +370,22 @@ declare const rawVunorShortcuts: TVunorShortcut[];
|
|
|
370
370
|
* @returns string
|
|
371
371
|
*/
|
|
372
372
|
declare function toUnoShortcut(obj: TVunorShortcut): string;
|
|
373
|
+
/**
|
|
374
|
+
* Marks a top-level shortcut entry as a replacement: when shortcuts are merged
|
|
375
|
+
* (`mergeVunorShortcuts`, `vunorShortcuts`), it drops every earlier definition of
|
|
376
|
+
* the same name instead of merging into it. Later entries still merge on top of it.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* vunorShortcuts(defineShortcuts({ press: replaceShortcut({ 'active:': 'scale-95' }) }))
|
|
380
|
+
*
|
|
381
|
+
* @param value the shortcut, in any form a normal entry accepts
|
|
382
|
+
* @returns the shortcut's class string in a marked array
|
|
383
|
+
*/
|
|
384
|
+
declare const replaceShortcut: (value: string | string[] | TVunorShortcut) => string[];
|
|
373
385
|
/**
|
|
374
386
|
* Merges an array of vunor shortcuts
|
|
375
|
-
* Items from the beginning have less priority
|
|
387
|
+
* Items from the beginning have less priority. An entry marked with
|
|
388
|
+
* `replaceShortcut` drops the earlier entries of its name.
|
|
376
389
|
*
|
|
377
390
|
* @param shortcuts TVunorShortcut[]
|
|
378
391
|
* @returns TVunorShortcut
|
|
@@ -397,4 +410,4 @@ declare const mergedVunorShortcuts: TVunorShortcut;
|
|
|
397
410
|
*/
|
|
398
411
|
declare function vunorShortcuts(customShortcuts?: TVunorShortcut, baseShortcuts?: TVunorShortcut): Record<string, string>;
|
|
399
412
|
//#endregion
|
|
400
|
-
export { type TVunorLayerPaletteAdvanced, type TVunorMainPaletteAdvanced, type TVunorPaletteColor, type TVunorPaletteOptions, type TVunorShortcut, type TVunorSurfaceConfig, type TVunorTheme, componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|
|
413
|
+
export { type TVunorLayerPaletteAdvanced, type TVunorMainPaletteAdvanced, type TVunorPaletteColor, type TVunorPaletteOptions, type TVunorShortcut, type TVunorSurfaceConfig, type TVunorTheme, componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, replaceShortcut, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|
package/dist/theme.mjs
CHANGED
|
@@ -527,11 +527,28 @@ function toUnoShortcut(obj) {
|
|
|
527
527
|
}
|
|
528
528
|
function prepareScArray(input) {
|
|
529
529
|
if (typeof input === "string") return input.split(" ");
|
|
530
|
-
if (Array.isArray(input)) return input;
|
|
530
|
+
if (Array.isArray(input)) return input.flatMap((item) => item.split(" "));
|
|
531
531
|
const a = [];
|
|
532
532
|
for (const [key, val] of Object.entries(input)) a.push(...prepareScArray(val).map((v) => `${key}${v}`));
|
|
533
533
|
return a;
|
|
534
534
|
}
|
|
535
|
+
const REPLACE = Symbol.for("vunor.replaceShortcut");
|
|
536
|
+
/** A shortcut value as one UnoCSS class string */
|
|
537
|
+
const toClassString = (value = "") => typeof value === "string" ? value : Array.isArray(value) ? value.join(" ") : toUnoShortcut(value);
|
|
538
|
+
const markReplacement = (classes) => Object.defineProperty(classes, REPLACE, { value: true });
|
|
539
|
+
const isReplacement = (value) => Array.isArray(value) && REPLACE in value;
|
|
540
|
+
/**
|
|
541
|
+
* Marks a top-level shortcut entry as a replacement: when shortcuts are merged
|
|
542
|
+
* (`mergeVunorShortcuts`, `vunorShortcuts`), it drops every earlier definition of
|
|
543
|
+
* the same name instead of merging into it. Later entries still merge on top of it.
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* vunorShortcuts(defineShortcuts({ press: replaceShortcut({ 'active:': 'scale-95' }) }))
|
|
547
|
+
*
|
|
548
|
+
* @param value the shortcut, in any form a normal entry accepts
|
|
549
|
+
* @returns the shortcut's class string in a marked array
|
|
550
|
+
*/
|
|
551
|
+
const replaceShortcut = (value) => markReplacement([toClassString(value)]);
|
|
535
552
|
/**
|
|
536
553
|
* Merges source vunor shortcut with target vunor shortcut
|
|
537
554
|
* The target vunor shortcut has more power
|
|
@@ -546,9 +563,12 @@ const mergeTwoVunorShortcuts = (target, source) => {
|
|
|
546
563
|
for (const key of Array.from(keys)) {
|
|
547
564
|
const inSource = Object.prototype.hasOwnProperty.call(source, key);
|
|
548
565
|
const inTarget = Object.prototype.hasOwnProperty.call(target, key);
|
|
549
|
-
|
|
566
|
+
const targetEntry = target[key];
|
|
567
|
+
if (inSource && isReplacement(source[key])) result[key] = source[key];
|
|
568
|
+
else if (inSource && inTarget && isReplacement(targetEntry)) result[key] = markReplacement([...targetEntry, toClassString(source[key])]);
|
|
569
|
+
else if (inSource && inTarget) {
|
|
550
570
|
let sourceValue = source[key];
|
|
551
|
-
let targetValue =
|
|
571
|
+
let targetValue = targetEntry;
|
|
552
572
|
if (Array.isArray(sourceValue)) sourceValue = sourceValue.join(" ");
|
|
553
573
|
if (Array.isArray(targetValue)) targetValue = targetValue.join(" ");
|
|
554
574
|
if (typeof sourceValue === "string" && typeof targetValue === "string") result[key] = `${targetValue} ${sourceValue}`;
|
|
@@ -562,7 +582,8 @@ const mergeTwoVunorShortcuts = (target, source) => {
|
|
|
562
582
|
};
|
|
563
583
|
/**
|
|
564
584
|
* Merges an array of vunor shortcuts
|
|
565
|
-
* Items from the beginning have less priority
|
|
585
|
+
* Items from the beginning have less priority. An entry marked with
|
|
586
|
+
* `replaceShortcut` drops the earlier entries of its name.
|
|
566
587
|
*
|
|
567
588
|
* @param shortcuts TVunorShortcut[]
|
|
568
589
|
* @returns TVunorShortcut
|
|
@@ -2569,8 +2590,9 @@ const mergedVunorShortcuts = mergeVunorShortcuts(rawVunorShortcuts);
|
|
|
2569
2590
|
*/
|
|
2570
2591
|
function vunorShortcuts(customShortcuts, baseShortcuts = mergedVunorShortcuts) {
|
|
2571
2592
|
const merged = customShortcuts ? mergeVunorShortcuts([baseShortcuts, customShortcuts]) : baseShortcuts;
|
|
2572
|
-
|
|
2573
|
-
|
|
2593
|
+
const result = {};
|
|
2594
|
+
for (const [key, val] of Object.entries(merged)) result[key] = toClassString(val);
|
|
2595
|
+
return result;
|
|
2574
2596
|
}
|
|
2575
2597
|
//#endregion
|
|
2576
|
-
export { componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|
|
2598
|
+
export { componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, replaceShortcut, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|