@xleddyl/443-components-vue 0.16.57 → 0.16.59
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/CATALOG.md +24 -22
- package/README.md +14 -3
- package/dist/components/core/index.d.ts +2 -1
- package/dist/components/core/index.mjs +9 -1
- package/dist/components/core/palette.d.ts +6 -2
- package/dist/components/core/palette.mjs +120 -1
- package/dist/components/core/types.d.ts +3 -1
- package/dist/components/data/Badge.vue +3 -2
- package/dist/components/data/FilterPill.vue +3 -2
- package/dist/components/data/Tag.vue +3 -2
- package/dist/components/data/types.d.ts +2 -2
- package/dist/components/forms/Combobox.vue +17 -2
- package/dist/components/forms/PaletteSelect.vue +60 -16
- package/dist/components/forms/PaletteSelect.vue.d.ts +32 -25
- package/dist/components/forms/types.d.ts +2 -2
- package/dist/components/overlays/ConfirmDialog.vue.d.ts +2 -2
- package/dist/components/overlays/ConfirmHost.vue.d.ts +2 -2
- package/dist/components/overlays/types.d.ts +2 -2
- package/dist/components/templates/SettingsModal.vue +9 -15
- package/dist/components/templates/SettingsModal.vue.d.ts +2 -2
- package/dist/grid/cells/BadgeCell.vue +18 -7
- package/dist/grid/types.d.ts +2 -2
- package/dist/internal/layout/CollapsedTrail.vue +120 -0
- package/dist/internal/layout/CollapsedTrail.vue.d.ts +404 -0
- package/dist/internal/overlays/DialogTrail.vue +9 -10
- package/dist/internal/overlays/DialogTrail.vue.d.ts +407 -8
- package/dist/internal/overlays/MenuList.vue +2 -1
- package/dist/internal/overlays/OverlayView.vue.d.ts +2 -2
- package/dist/locale/de.mjs +4 -1
- package/dist/locale/en.mjs +4 -1
- package/dist/locale/it.mjs +4 -1
- package/dist/locale/types.d.ts +3 -0
- package/dist/palette.d.ts +3 -2
- package/dist/palette.mjs +3 -0
- package/dist/styles/data/record-list.css +1 -3
- package/dist/styles/data/tree.css +1 -3
- package/dist/styles/forms/palette-select.css +5 -0
- package/dist/styles/forms.css +1 -0
- package/dist/styles/layout/trail.css +67 -0
- package/dist/styles/layout.css +1 -0
- package/dist/styles/overlays/modal.css +11 -4
- package/dist/styles/templates/settings-modal.css +2 -5
- package/package.json +1 -1
package/CATALOG.md
CHANGED
|
@@ -90,8 +90,8 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
|
|
|
90
90
|
| Bulk actions bar for selected rows | `SelectionBar` |
|
|
91
91
|
| Filter chips, active filters | `FilterPills` |
|
|
92
92
|
| Tags, chips, removable labels | `Tag` |
|
|
93
|
-
| Color per group or category (tags, labels, series) | `color` on `Tag`, `Badge`, `FilterPill`, `Combobox` options, `BadgeCell` `colors`; `
|
|
94
|
-
| Choose a palette color (a group, a division) | `PaletteSelect` (`v-model`
|
|
93
|
+
| Color per group or category (tags, labels, series) | `color` (palette name or hex) on `Tag`, `Badge`, `FilterPill`, `Combobox` options, `BadgeCell` `colors`; `paletteColor(key)` |
|
|
94
|
+
| Choose a palette color (a group, a division) | `PaletteSelect` (`v-model` color or null, `clearable` for "Automatic", `custom` for any hex color) |
|
|
95
95
|
| Reorder chips by drag and keyboard, drop items from another panel | `TagList` (`sortable`, `removable`, `accept` + `@item-drop`) |
|
|
96
96
|
| Reorder any list by drag and keyboard | `useSortable` |
|
|
97
97
|
| Status label, counter, dot | `Badge` |
|
|
@@ -183,7 +183,7 @@ All field components work inside `FormField` and take `invalid`, `disabled`, `re
|
|
|
183
183
|
| `Calendar` | Inline calendar. Use it for availability views, or as a building block. | Models: `v-model` (date or range), `v-model:month`. Props: `range`, `min`, `max`, `isDateDisabled`, `locale`, `weekStartsOn`, `dayText(iso)`. Slots: `day`, `footer`. Event: `select`. | `forms/calendar.vue` |
|
|
184
184
|
| `TimeInput` | Time of day (HH:MM, optional seconds). | Model: string or null. Props: `min`, `max`, `step`, `seconds`, `clearable`. | `forms/time-input.vue` |
|
|
185
185
|
| `ColorInput` | Color text field with picker and swatches. | Model: hex string or null. Props: `swatches` (strings or `{ value, label }`), `placeholder`, `invalidText`. | `forms/color-input.vue` |
|
|
186
|
-
| `PaletteSelect` | Select of a palette color, with the dot and the localized color name. | Model: palette
|
|
186
|
+
| `PaletteSelect` | Select of a palette color, with the dot and the localized color name. | Model: `ColorValue` (palette name or `#rrggbb`) or null. Props: `colors` (subset of `PALETTE_COLORS`), `clearable` (placeholder "Automatic"), `custom` (adds "Custom": choosing it shows a `ColorInput` under the select and the model becomes the hex), `customLabel` (name of the color input), `placeholder`, `size`, `disabled`, `readonly`, `invalid`. | `forms/palette-select.vue` |
|
|
187
187
|
| `Slider` | Number in a range with drag handle. | Model: number. Props: `min`, `max`, `step`, `bubble` (true, always), `marks`, `format(value)`, `label`. Event: `change` (on release). | `forms/slider.vue` |
|
|
188
188
|
| `FileInput` | Drop zone and file picker. Validates type, size and count. Supports folders and previews. | Model: `File`, `File[]` or null. Props: `accept`, `acceptMode`, `maxSize`, `maxFiles`, `multiple`, `directory`, `directoryAction`, `previews`, `list`, `loading`, `capture`, `title`, `dropText`, `hint`. Slots: `title`, `hint`, `actions`. Events: `add`, `remove`, `invalid`, `reject`. | `forms/file-input.vue` |
|
|
189
189
|
|
|
@@ -191,21 +191,21 @@ All field components work inside `FormField` and take `invalid`, `disabled`, `re
|
|
|
191
191
|
|
|
192
192
|
Mount `OverlayHost` once for the imperative hooks (see [Composables](#composables)).
|
|
193
193
|
|
|
194
|
-
| Component | Purpose and when to use it | Main props, models, slots, events
|
|
195
|
-
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
196
|
-
| `Modal` | Centered dialog for forms and content. Use `Drawer` for a side panel, `useConfirm` for a yes or no question. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `size` (sm to xl, full, fit, fullscreen), `width`, `minHeight`, `dismissible`, `hideClose`, `sheet`, `flush`, `fill`, `loading`, `beforeClose(reason)`, `tabs` (tabs in the header), `trail` (breadcrumb title and back button), `backLabel`. Slots: default (`{ tab }`), `header`, `actions` (header, before the close button), `footer`, `title-trailing`. Events: `open`, `close`, `afterLeave`, `navigate(index)`. | `overlays/modal.vue` |
|
|
197
|
-
| `Drawer` | Panel from the side or bottom for details and edit forms. Use `Modal` for short focused dialogs. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `side` (left, right, bottom), `size` (sm to xl, full), `dismissible`, `hideClose`, `flush`, `fill` (the body content takes the full height, for a table or a grid), `loading`, `beforeClose(reason)`, `tabs`, `trail`, `backLabel`. Slots like `Modal`. Events: `open`, `close`, `afterLeave`, `navigate(index)`.
|
|
198
|
-
| `ConfirmDialog` | Declarative confirm dialog. Prefer `useConfirm()`. Use this one only when the dialog state lives in the template. | Model: `v-model:open`. Props: `title`, `description`, `confirmLabel`, `cancelLabel`, `tone`, `icon`, `hideCancel`, `onConfirm`. Events: `resolve(confirmed)`, `cancel`, `afterLeave`.
|
|
199
|
-
| `ConfirmHost` | Renders the dialogs of `useConfirm`, `useAlert`, `usePrompt`. `OverlayHost` includes it. Do not mount it alone. | None.
|
|
200
|
-
| `OverlayHost` | One mount point for toasts, confirm dialogs, programmatic modals and loading indicators. | Props: `toaster` (true or options), `confirm`, `modals`, `loading` (true or `{ bar, delay, label }`).
|
|
201
|
-
| `Toaster` | Renders toasts. `OverlayHost` includes it. Use it directly only for custom options. The stack moves out of the way of an open side Drawer (beside it, or above its footer). | Props: `position`, `max`, `duration`, `gap`, `expand`, `progress`, `hotkey`.
|
|
202
|
-
| `DropdownMenu` | Menu opened by its trigger. Items can have icons, shortcuts, checkboxes, radios, sub menus and links. | Model: `v-model:open`. Props: `items` (`label`, `icon`, `color` (palette dot, or `muted` for a grey dot of an empty state), `to`, `href`, `tone: danger`, `shortcut`, `disabled`, `children`, `onSelect`; also `type`: checkbox, radio, label, separator), `placement`, `offset`, `matchTriggerWidth`, `minWidth`. Slot: default (the trigger). Event: `select`.
|
|
203
|
-
| `ContextMenu` | Menu on right click of the wrapped area. | Model: `v-model:open`. Props: `items` (same as `DropdownMenu`), `disabled`. Slot: default (the area). Event: `select`.
|
|
204
|
-
| `Popover` | Floating panel with any content (a form, filters) opened by its trigger. Use `DropdownMenu` for a list of actions. | Model: `v-model:open`. Props: `placement`, `offset`, `arrow`, `label`, `initialFocus`. Slots: default (the trigger), `content`.
|
|
205
|
-
| `HoverCard` | Rich preview on hover or focus (user card, link preview). Use `Tooltip` for plain text. | Model: `v-model:open`. Props: `placement`, `openDelay`, `closeDelay`, `arrow`, `disabled`. Slots: default (trigger), `content`.
|
|
206
|
-
| `Tooltip` | Short text on hover or focus. Optional shortcut. | Props: `text`, `placement`, `openDelay`, `closeDelay`, `arrow`, `shortcut`, `disabled`. Slots: default (trigger), `content`.
|
|
207
|
-
| `CommandPalette` | Search and command dialog (Cmd+K) with groups, recent items, async search and typed item data. Groups take `icon` (default item icon) and `more` (a last "show all" item). Matching (`matchesSearch`, exported) finds every word in any order, without case or accents. | Models: `v-model:open`, `v-model:query`. Props: `groups` (items with `id`, `label`, `description`, `icon`, `badge`, `shortcut`, `keywords`, `to`, `data`, `onSelect`), `search(query, signal)`, `shortcut`, `trigger`, `recentKey`, `emptyText`, `notice`. Slots: `item`, `empty`, `group-label`, `after-results`. Events: `select`, `open`, `close`.
|
|
208
|
-
| `CommandButton` | A `Button` made from a `CommandItem`: label, icon, `to`, `href`, `disabled` and `onSelect` come from the command. | Props: `command`, `label`, `icon`, and every `Button` prop (size, variant, tone).
|
|
194
|
+
| Component | Purpose and when to use it | Main props, models, slots, events | Playground |
|
|
195
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
|
|
196
|
+
| `Modal` | Centered dialog for forms and content. Use `Drawer` for a side panel, `useConfirm` for a yes or no question. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `size` (sm to xl, full, fit, fullscreen), `width`, `minHeight`, `dismissible`, `hideClose`, `sheet`, `flush`, `fill`, `loading`, `beforeClose(reason)`, `tabs` (tabs in the header), `trail` (breadcrumb title and back button; a long trail stays on one line, the middle crumbs collapse into a "..." menu and the current title truncates), `backLabel`. Slots: default (`{ tab }`), `header`, `actions` (header, before the close button), `footer`, `title-trailing`. Events: `open`, `close`, `afterLeave`, `navigate(index)`. | `overlays/modal.vue` |
|
|
197
|
+
| `Drawer` | Panel from the side or bottom for details and edit forms. Use `Modal` for short focused dialogs. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `side` (left, right, bottom), `size` (sm to xl, full), `dismissible`, `hideClose`, `flush`, `fill` (the body content takes the full height, for a table or a grid), `loading`, `beforeClose(reason)`, `tabs`, `trail`, `backLabel`. Slots like `Modal`. Events: `open`, `close`, `afterLeave`, `navigate(index)`. | `overlays/drawer.vue` |
|
|
198
|
+
| `ConfirmDialog` | Declarative confirm dialog. Prefer `useConfirm()`. Use this one only when the dialog state lives in the template. | Model: `v-model:open`. Props: `title`, `description`, `confirmLabel`, `cancelLabel`, `tone`, `icon`, `hideCancel`, `onConfirm`. Events: `resolve(confirmed)`, `cancel`, `afterLeave`. | `overlays/confirm-dialog.vue` |
|
|
199
|
+
| `ConfirmHost` | Renders the dialogs of `useConfirm`, `useAlert`, `usePrompt`. `OverlayHost` includes it. Do not mount it alone. | None. | - |
|
|
200
|
+
| `OverlayHost` | One mount point for toasts, confirm dialogs, programmatic modals and loading indicators. | Props: `toaster` (true or options), `confirm`, `modals`, `loading` (true or `{ bar, delay, label }`). | `overlays/hooks.vue` |
|
|
201
|
+
| `Toaster` | Renders toasts. `OverlayHost` includes it. Use it directly only for custom options. The stack moves out of the way of an open side Drawer (beside it, or above its footer). | Props: `position`, `max`, `duration`, `gap`, `expand`, `progress`, `hotkey`. | `overlays/toast.vue` |
|
|
202
|
+
| `DropdownMenu` | Menu opened by its trigger. Items can have icons, shortcuts, checkboxes, radios, sub menus and links. | Model: `v-model:open`. Props: `items` (`label`, `icon`, `color` (palette name or hex dot, or `muted` for a grey dot of an empty state), `to`, `href`, `tone: danger`, `shortcut`, `disabled`, `children`, `onSelect`; also `type`: checkbox, radio, label, separator), `placement`, `offset`, `matchTriggerWidth`, `minWidth`. Slot: default (the trigger). Event: `select`. | `overlays/dropdown-menu.vue` |
|
|
203
|
+
| `ContextMenu` | Menu on right click of the wrapped area. | Model: `v-model:open`. Props: `items` (same as `DropdownMenu`), `disabled`. Slot: default (the area). Event: `select`. | `overlays/context-menu.vue` |
|
|
204
|
+
| `Popover` | Floating panel with any content (a form, filters) opened by its trigger. Use `DropdownMenu` for a list of actions. | Model: `v-model:open`. Props: `placement`, `offset`, `arrow`, `label`, `initialFocus`. Slots: default (the trigger), `content`. | `overlays/popover.vue` |
|
|
205
|
+
| `HoverCard` | Rich preview on hover or focus (user card, link preview). Use `Tooltip` for plain text. | Model: `v-model:open`. Props: `placement`, `openDelay`, `closeDelay`, `arrow`, `disabled`. Slots: default (trigger), `content`. | `overlays/hover-card.vue` |
|
|
206
|
+
| `Tooltip` | Short text on hover or focus. Optional shortcut. | Props: `text`, `placement`, `openDelay`, `closeDelay`, `arrow`, `shortcut`, `disabled`. Slots: default (trigger), `content`. | `overlays/tooltip.vue` |
|
|
207
|
+
| `CommandPalette` | Search and command dialog (Cmd+K) with groups, recent items, async search and typed item data. Groups take `icon` (default item icon) and `more` (a last "show all" item). Matching (`matchesSearch`, exported) finds every word in any order, without case or accents. | Models: `v-model:open`, `v-model:query`. Props: `groups` (items with `id`, `label`, `description`, `icon`, `badge`, `shortcut`, `keywords`, `to`, `data`, `onSelect`), `search(query, signal)`, `shortcut`, `trigger`, `recentKey`, `emptyText`, `notice`. Slots: `item`, `empty`, `group-label`, `after-results`. Events: `select`, `open`, `close`. | `overlays/command-palette.vue` |
|
|
208
|
+
| `CommandButton` | A `Button` made from a `CommandItem`: label, icon, `to`, `href`, `disabled` and `onSelect` come from the command. | Props: `command`, `label`, `icon`, and every `Button` prop (size, variant, tone). | `overlays/command-palette.vue` |
|
|
209
209
|
|
|
210
210
|
## Data
|
|
211
211
|
|
|
@@ -216,9 +216,9 @@ Mount `OverlayHost` once for the imperative hooks (see [Composables](#composable
|
|
|
216
216
|
| `SelectionBar` | Shows the selected count and bulk actions for a list or table. | Props: `count`, `total`, `placement` (inline, sticky, floating), `onSelectAll`, `onClear`. Slots: `actions`, `count`. With `count` 0 it renders nothing visible. | `data/selection-bar.vue` |
|
|
217
217
|
| `FilterPills` | Quick filters as pills: single, multiple, menu or panel pills, removable active filters. | Model: value, array (`multiple`) or null. Props: `options` (`value`, `label`, `valueLabel`, `count`, `icon`, `color`, `menu`, `panel`, `removable`), `multiple`, `required`, `clearable`, `size`. Slots: `pill`, `panel-<value>`. Events: `select`, `remove`. | `data/filter-pills.vue` |
|
|
218
218
|
| `FilterPill` | One pill button. Use it alone for a custom filter trigger. `FilterPills` uses it. | Props: `label`, `valueLabel`, `icon`, `count`, `active`, `pressed`, `caret`, `size`, `disabled`. Slot: default. | `data/filter-pills.vue` |
|
|
219
|
-
| `Tag` | Chip or label, optionally removable. Use `Badge` for a status. | Props: `label`, `tone`, `color` (palette
|
|
219
|
+
| `Tag` | Chip or label, optionally removable. Use `Badge` for a status. | Props: `label`, `tone`, `color` (palette name or hex), `size`, `icon`, `removable`, `removeLabel`, `removeTabindex`, `disabled`. Slot: default. Event: `remove`. | `data/tag.vue` |
|
|
220
220
|
| `TagList` | A list of `Tag` chips, reorderable by drag, by keyboard (Alt with an arrow key) or move buttons, removable, and a drop target for items dragged from another panel (columns of an export). | Model: `v-model` (`TagListItem[]`: `value`, `label`, `tone`, `icon`, `removable`, `disabled`). Props: `label`, `sortable`, `removable`, `moveButtons`, `accept` (MIME types or a function), `dropEffect`, `tone`, `size`, `disabled`, `emptyText`, `removeLabel`. Slots: `item`, `empty`. Events: `remove`, `move`, `itemDrop` (`{ index, dataTransfer, event }`). | `data/tag-list.vue` |
|
|
221
|
-
| `Badge` | Status label, counter or dot. Not interactive. | Props: `label` (string or number), `tone`, `color` (palette
|
|
221
|
+
| `Badge` | Status label, counter or dot. Not interactive. | Props: `label` (string or number), `tone`, `color` (palette name or hex), `variant` (soft, solid, outline), `size`, `dot`, `pulse`, `icon`. Slot: default. | `data/badge.vue` |
|
|
222
222
|
| `Avatar` | User picture with initials fallback and status dot. | Props: `src`, `name`, `alt`, `size` (xs to xl), `shape` (circle, square), `status` (online, away, busy, offline), `decorative`. Slot: `fallback`. | `data/avatar.vue` |
|
|
223
223
|
| `AvatarGroup` | Overlapping stack of avatars with "+N". | Props: `items` (`src`, `name`, `alt`), `max`, `size`, `shape`, `moreLabel`. | `data/avatar.vue` |
|
|
224
224
|
| `Stat` | Key figure (KPI) with unit, delta, trend, hint and optional sparkline. Can be a link. | Props: `label`, `value`, `unit`, `delta`, `trend` (up, down, flat), `invert` (down is good), `hint`, `icon`, `loading`, `to`, `href`, `plain`. Slots: `label`, `value`, `icon`, `sparkline`, `footer`. | `data/stat.vue` |
|
|
@@ -281,7 +281,7 @@ Templates combine core parts into whole pages and layouts. Start from them for n
|
|
|
281
281
|
| `SettingsPage` | Settings as a page: section nav, panels, floating save bar when `dirty`. | Model: `v-model:section`. Props: `title`, `sections` (`value`, `label`, `icon`, `to`), `dirty`, `saving`, `saveBar`, `form`. Slots: `section-<value>`, `actions`, `nav-footer`. Events: `save`, `discard`. | `templates/settings-page.vue` |
|
|
282
282
|
| `SettingsSection` | Card of one settings section with a save footer. | Props: `title`, `description`, `icon`, `hint`, `saveable`, `saving`, `saveDisabled`, `saveLabel`, `form`. Slots: default, `actions`, `footer`, `hint`. Event: `save`. | `templates/settings-page.vue` |
|
|
283
283
|
| `SettingsGroup` | Block with label, description and actions inside a settings section. | Props: `label`, `description`, `level`, `row`. Slots: default, `label`, `description`, `actions`. | `templates/settings-modal.vue` |
|
|
284
|
-
| `SettingsModal` | Settings dialog with nav, built-in account and appearance sections, your own sections and subpages.
|
|
284
|
+
| `SettingsModal` | Settings dialog with nav, built-in account and appearance sections, your own sections and subpages. A subpage title is a one line trail. | Models: `v-model:open`, `v-model:section`, `v-model:pages`. Props: `sections` (`id`, `label`, `icon`, `group`, `badge`, `to`), `account`, `presets`, `title`, `onSignOut`, `hideSession`, `beforeClose`, `route` (sync with `?settings=<section>/<page>`), `routeLocation` (`'hash'`: `#settings/<section>/<page>`), `accountSection` (id with the built-in account content, default `account`), `resolvePage(section, id, parents)`. Slots: `section-<id>`, `actions-<id>` (right of the header row, also on a subpage), `tabs-<id>` (tabs at the bottom of the header, like a drawer; the strip shows only when the slot renders content), `account-start` (above the profile card), `account-fields`. | `templates/settings-modal.vue` |
|
|
285
285
|
| `AppearanceSettings` | Theme (light, dark, system) and preset cards. Used by `SettingsModal`. Use alone in a settings page. | Props: `presets` (list or false), `themes`, `level`. | `presets.vue` (pages root) |
|
|
286
286
|
| `SaveBar` | Floating bar with save and discard for unsaved changes. | Props: `visible`, `saving`, `message`, `saveLabel`, `discardLabel`, `form`. Slots: default, `actions`. Events: `save`, `discard`. | `templates/settings-page.vue` |
|
|
287
287
|
| `EmptyPage` | First run screen with illustration, actions and onboarding steps. | Props: `title`, `description`, `icon`, `actionLabel`, `actionTo`, `onAction`, `secondaryLabel`, `steps` (`title`, `description`, `done`, `to`), `fill`. Slots: default, `illustration`, `title`, `description`, `actions`. | `templates/empty-page.vue` |
|
|
@@ -327,7 +327,9 @@ Chart helpers: `useChartColors`, `readChartColors`, `withAlpha`, `registerChartM
|
|
|
327
327
|
|
|
328
328
|
## Palette
|
|
329
329
|
|
|
330
|
-
`@xleddyl/443-components-vue/palette` exports the palette without components (`PALETTE_COLORS`, `isPaletteColor`, `paletteColor`, `paletteClass`, types), safe for shared and server code. `PALETTE_COLORS` is a categorical palette of 12 colors, `isPaletteColor(value)` checks a value, `PaletteSelect` chooses one (`--k-palette-<name>` tokens, light and dark). `paletteColor(key)` gives a stable color for a string, `paletteClass(color)` the class that sets `--k-palette` and `--k-palette-text` on your own elements. `paletteClass('muted')` (class `k-palette-muted`) is a grey for an empty or missing state, outside the palette. `k-palette-dot` with that class draws a small dot of the color.
|
|
330
|
+
`@xleddyl/443-components-vue/palette` exports the palette without components (`PALETTE_COLORS`, `isPaletteColor`, `isHexColor`, `isColorValue`, `paletteColor`, `paletteClass`, `colorStyle`, types `PaletteColor`, `HexColor`, `ColorValue`, `DotColor`, `ColorStyle`), safe for shared and server code. `PALETTE_COLORS` is a categorical palette of 12 colors, `isPaletteColor(value)` checks a value, `PaletteSelect` chooses one (`--k-palette-<name>` tokens, light and dark). `paletteColor(key)` gives a stable color for a string, `paletteClass(color)` the class that sets `--k-palette` and `--k-palette-text` on your own elements. `paletteClass('muted')` (class `k-palette-muted`) is a grey for an empty or missing state, outside the palette. `k-palette-dot` with that class draws a small dot of the color.
|
|
331
|
+
|
|
332
|
+
A color value (`ColorValue`) is a palette name or a custom hex color `#rrggbb` (`isHexColor`, `isColorValue`). Every `color` prop takes a `ColorValue` and draws a hex color with the look of a palette color. On your own elements, bind both helpers: `:class="paletteClass(color)"` (undefined for a hex) and `:style="colorStyle(color)"` (undefined for a palette name; for a hex the `--k-palette` and `--k-palette-text` custom properties, light and dark). `colorStyle` keeps the hue of the hex and moves its lightness only as much as needed: the color reaches 3:1 on light surfaces and 4.5:1 on dark ones, the text 4.5:1 on the soft tint, like the palette tokens. `PaletteSelect` with `custom` adds a "Custom" option and a `ColorInput` to pick any hex.
|
|
331
333
|
|
|
332
334
|
## Composables
|
|
333
335
|
|
package/README.md
CHANGED
|
@@ -427,7 +427,7 @@ Several controls in one `FormField`. Only the primary control takes the field id
|
|
|
427
427
|
| Group | Components |
|
|
428
428
|
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
429
429
|
| core | Root, Icon, Button, Spinner, Input, Textarea, FormField, FieldMessage, FieldBoundary, Form, FormAlerts, Kbd, VisuallyHidden |
|
|
430
|
-
| forms | Calendar, Checkbox, CheckboxGroup, ColorInput, Combobox, DateInput, DatePicker, FileInput, InputAddon, InputGroup, NumberInput, PasswordInput, PinInput, Radio, RadioGroup, SegmentedControl, Select, Slider, Switch, TimeInput
|
|
430
|
+
| forms | Calendar, Checkbox, CheckboxGroup, ColorInput, Combobox, DateInput, DatePicker, FileInput, InputAddon, InputGroup, NumberInput, PaletteSelect, PasswordInput, PinInput, Radio, RadioGroup, SegmentedControl, Select, Slider, Switch, TimeInput |
|
|
431
431
|
| overlays | CommandPalette, ConfirmDialog, ConfirmHost, ContextMenu, Drawer, DropdownMenu, HoverCard, Modal, OverlayHost, Popover, Toaster, Tooltip |
|
|
432
432
|
| data | Avatar, AvatarGroup, Badge, DescriptionList, FilterPill, FilterPills, Pagination, SelectionBar, Stat, Table, Tag, TagList, Timeline, Tree |
|
|
433
433
|
| layout | Accordion, AppShell, Breadcrumbs, Card, CopyButton, Grid, NavLink, PageHeader, Separator, Sidebar, SidebarNav, SidebarSection, Stack, Stepper, Tabs, ThemeSwitch, Toolbar |
|
|
@@ -439,6 +439,17 @@ Several controls in one `FormField`. Only the primary control takes the field id
|
|
|
439
439
|
|
|
440
440
|
Composables: `useTheme`, `usePreset`, `useForm`, `useField`, `useFieldControl`, `useToast` (and `toast`), `useConfirm`, `useAlert`, `usePrompt`, `useModal`, `useDrawer`, `useOverlay`, `useModalContext`, `useLoading` (and `withLoading`), `useLoadingState`, `useHotkey`, `useCopy`, `useFileDrop` (with `readDroppedFiles`), `useSortable`, `usePasswordStrength`, `useTableSort`, `useAppShell`, `useRouteState`, `useScrollLock`, `useDirtyGuard`, `useIcons` helpers and `useLinkComponent`, `provideFieldBoundary`, `provideAuxiliaryControls`, `provideForm`, `useLocale`. With the Nuxt module also `useDashboard()` (runtime account, breadcrumbs and badges for the `k-dashboard` layout).
|
|
441
441
|
|
|
442
|
+
### Colors
|
|
443
|
+
|
|
444
|
+
A `color` prop (`Badge`, `Tag`, `FilterPill`, `Combobox` and `DropdownMenu` items, `BadgeCell` `colors`, `CommandPalette` badges) takes a `ColorValue`: one of the 12 palette names (`PALETTE_COLORS`) or a custom hex color `#rrggbb`. A hex color gets the same look as a palette color in both themes. `PaletteSelect` chooses one; `custom` adds a "Custom" option with a `ColorInput`, and the model becomes the hex.
|
|
445
|
+
|
|
446
|
+
```vue
|
|
447
|
+
<KPaletteSelect v-model="color" clearable custom />
|
|
448
|
+
<KBadge :color="color ?? paletteColor(name)" :label="name" />
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
On your own elements, `paletteClass(color)` gives the class of a palette name and `colorStyle(color)` the custom properties of a hex (`--k-palette`, `--k-palette-text`); bind both: `<span class="k-palette-dot" :class="paletteClass(color)" :style="colorStyle(color)" />`. The helpers and `isColorValue`, `isHexColor`, `isPaletteColor` also come from `@xleddyl/443-components-vue/palette`, without components, for shared and server code.
|
|
452
|
+
|
|
442
453
|
### Lists, trees and uploads
|
|
443
454
|
|
|
444
455
|
- `Tree` takes `size="sm"` for dense rows, `checkmark`, `descriptionVariant` (`mono`, the default for paths and slugs, or `text`; a node can override it with its own `descriptionVariant`), `emptyText` (or `#empty`) and works inside a `FormField` (labelled and described by the field). With `reorderable` rows get a drag handle and Alt with the up and down arrows moves them; `nestable` also lets rows change level (drop in the middle of a row, Alt with left and right). Each row also shows move buttons; `moveButtons: false` hides them and keeps drag and the keyboard. The `move` event carries `{ node, target, position, from: { parent, index }, to: { parent, index } }`, `to.index` being the final index, and `applyTreeMove(nodes, move)` returns the updated tree. `canDrop(move)` vetoes a move. Moves are announced to screen readers.
|
|
@@ -558,7 +569,7 @@ const confirmDiscard = () => !dirty.value || confirm({ title: 'Discard changes?'
|
|
|
558
569
|
- `#title-trailing` puts badges or a status next to the title without replacing `#header`.
|
|
559
570
|
- `#actions` (`{ close }`) puts buttons in the header, on the right before the close button (an edit or a more menu), without replacing `#header`.
|
|
560
571
|
- `tabs` (`TabItem[]`) with `v-model:tab` puts an underline tab list at the bottom of the header. The body becomes the tab panel and the default slot gets `{ tab }` (the active value), so the content shows one part at a time (`v-show` keeps the form fields mounted). The body scrolls to the top when the tab changes.
|
|
561
|
-
- `trail` (the labels of the previous levels) turns the title into a breadcrumb that ends with `title`, and adds a back button (`backLabel`, default "Back") before `#actions`. A click on a crumb emits `navigate(index)`, the back button emits `navigate(trail.length - 1)`. Use it for a subpage inside the same panel (an item of the record in the drawer), as in `SettingsModal`.
|
|
572
|
+
- `trail` (the labels of the previous levels) turns the title into a breadcrumb that ends with `title`, and adds a back button (`backLabel`, default "Back") before `#actions`. A click on a crumb emits `navigate(index)`, the back button emits `navigate(trail.length - 1)`. Use it for a subpage inside the same panel (an item of the record in the drawer), as in `SettingsModal`. The trail stays on one line: when it does not fit, the crumbs after the first one collapse into a "..." button (as many of the last ones as fit stay visible) that opens a menu of the hidden crumbs, and when the first crumb and the title still do not fit, the title truncates with an ellipsis. It measures again when the header resizes or the trail changes.
|
|
562
573
|
|
|
563
574
|
```vue
|
|
564
575
|
<KDrawer
|
|
@@ -704,7 +715,7 @@ A large dialog (60rem) with a section nav on the left and the content on the rig
|
|
|
704
715
|
- `@sign-out` adds a Sign out item at the bottom of the nav and in the account section.
|
|
705
716
|
- Labels: `title` (accessible name of the dialog, default `Settings`), `closeLabel`, `navLabel`, `signOutLabel`, `accountLabel`, `accountText`, `appearanceLabel`, `appearanceText`, `sessionLabel`, `sessionText`, `themeLabel`, `themeText`, `presetLabel`, `presetText`.
|
|
706
717
|
- Header actions: `#actions-<id>` renders buttons on the right of the section header row (an "Add user" button), next to the title instead of on a row of its own in the body. It stays there when a subpage is open, so render different actions per page from its `page` prop. When the content is too narrow, the actions wrap under the title. On `DashboardLayout` the slot is `#settings-actions-<id>`.
|
|
707
|
-
- Subpages: `#section-<id>` and `#actions-<id>` get `page`, `pages`, `openPage({ id, label })` and `back()`. With a page open, the header title becomes the path (`Members > Grace Hopper`, same size, only the last part in the text color, earlier parts are buttons that go back to them), the section description stays, and a Back button (`backLabel`, default `common.back`) shows on the right before `#actions-<id>`. `v-model:pages` binds the stack (it also works unbound). Changing section clears it. Render the detail when `page` is set, the list otherwise.
|
|
718
|
+
- Subpages: `#section-<id>` and `#actions-<id>` get `page`, `pages`, `openPage({ id, label })` and `back()`. With a page open, the header title becomes the path (`Members > Grace Hopper`, same size, only the last part in the text color, earlier parts are buttons that go back to them; a long path stays on one line, collapses the middle pages into a "..." menu and truncates the current page), the section description stays, and a Back button (`backLabel`, default `common.back`) shows on the right before `#actions-<id>`. `v-model:pages` binds the stack (it also works unbound). Changing section clears it. Render the detail when `page` is set, the list otherwise.
|
|
708
719
|
- Account section: `accountSection` (default `'account'`) is the id of the section that shows the built-in account content (profile card, `#account-fields`, session group), so a section `{ id: 'general' }` can hold it.
|
|
709
720
|
- Deep links: `route` (`true` for the key `settings`, or your own query key, default `false`) syncs the open state, the section and the subpage stack with the URL: `?settings=users` for a section, `?settings=users/usr_123` for a subpage, deeper pages add segments. Opening, switching section, opening a subpage, Back and the crumbs push history entries, so the browser back button steps back through them and finally closes the dialog; closing removes the parameter. Loading a URL with the parameter opens the dialog at that section and subpage after mount. A section id that is not selectable falls back to the first section and the URL is corrected with `replace`. The URL holds only page ids, so `resolvePage(section, id, parents)` returns the label of a page restored from the URL: a string, `undefined` (the page and the ones after it are dropped, the URL is corrected) or a promise of either (the page opens at once with an empty label, then the label fills in). Without `resolvePage` the label is the id. Pages opened with `openPage` keep their own label. Link sections (`to`) do not close the dialog themselves when the route is synced: the navigation drops the parameter and closes it. `routeLocation: 'hash'` (default from `k.routeState.location`) keeps the same value in the hash: `#settings/users/usr_123`. On `DashboardLayout` the props are `settingsRoute`, `settingsRouteLocation` and `settingsResolvePage`; in the `k-dashboard` layout `settings.route` in `app.config`.
|
|
710
721
|
- `hide-session` hides the Session group (sign out) in the account section; the Sign out item in the nav stays. `beforeClose` works as on Modal.
|
|
@@ -11,5 +11,6 @@ export { default as Root } from './Root.vue';
|
|
|
11
11
|
export { default as Spinner } from './Spinner.vue';
|
|
12
12
|
export { default as Textarea } from './Textarea.vue';
|
|
13
13
|
export { default as VisuallyHidden } from './VisuallyHidden.vue';
|
|
14
|
-
export { PALETTE_COLORS, isPaletteColor, paletteClass, paletteColor } from './palette';
|
|
14
|
+
export { PALETTE_COLORS, colorStyle, isColorValue, isHexColor, isPaletteColor, paletteClass, paletteColor, } from './palette';
|
|
15
|
+
export type { ColorStyle } from './palette';
|
|
15
16
|
export type * from './types';
|
|
@@ -11,4 +11,12 @@ export { default as Root } from "./Root.vue";
|
|
|
11
11
|
export { default as Spinner } from "./Spinner.vue";
|
|
12
12
|
export { default as Textarea } from "./Textarea.vue";
|
|
13
13
|
export { default as VisuallyHidden } from "./VisuallyHidden.vue";
|
|
14
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
PALETTE_COLORS,
|
|
16
|
+
colorStyle,
|
|
17
|
+
isColorValue,
|
|
18
|
+
isHexColor,
|
|
19
|
+
isPaletteColor,
|
|
20
|
+
paletteClass,
|
|
21
|
+
paletteColor
|
|
22
|
+
} from "./palette.mjs";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { DotColor, PaletteColor } from './types';
|
|
1
|
+
import type { ColorValue, DotColor, HexColor, PaletteColor } from './types';
|
|
2
2
|
export declare const PALETTE_COLORS: readonly ["blue", "green", "amber", "violet", "pink", "teal", "orange", "cyan", "indigo", "lime", "red", "slate"];
|
|
3
|
+
export type ColorStyle = Record<'--k-palette' | '--k-palette-text', string>;
|
|
3
4
|
export declare function isPaletteColor(value: unknown): value is PaletteColor;
|
|
5
|
+
export declare function isHexColor(value: unknown): value is HexColor;
|
|
6
|
+
export declare function isColorValue(value: unknown): value is ColorValue;
|
|
4
7
|
export declare function paletteColor(key: string): PaletteColor;
|
|
5
|
-
export declare function paletteClass(color: DotColor | undefined): string | undefined;
|
|
8
|
+
export declare function paletteClass(color: DotColor | null | undefined): string | undefined;
|
|
9
|
+
export declare function colorStyle(color: DotColor | null | undefined): ColorStyle | undefined;
|
|
@@ -12,14 +12,133 @@ export const PALETTE_COLORS = [
|
|
|
12
12
|
"red",
|
|
13
13
|
"slate"
|
|
14
14
|
];
|
|
15
|
+
const HEX_PATTERN = /^#[0-9a-f]{6}$/i;
|
|
16
|
+
const BLACK = [0, 0, 0];
|
|
17
|
+
const WHITE = [1, 1, 1];
|
|
18
|
+
const LIGHT_SURFACE = [247 / 255, 247 / 255, 248 / 255];
|
|
19
|
+
const DARK_SURFACE = [28 / 255, 28 / 255, 32 / 255];
|
|
20
|
+
const SOFT_TINT = 0.12;
|
|
21
|
+
const styleCache = /* @__PURE__ */ new Map();
|
|
15
22
|
export function isPaletteColor(value) {
|
|
16
23
|
return typeof value === "string" && PALETTE_COLORS.includes(value);
|
|
17
24
|
}
|
|
25
|
+
export function isHexColor(value) {
|
|
26
|
+
return typeof value === "string" && HEX_PATTERN.test(value);
|
|
27
|
+
}
|
|
28
|
+
export function isColorValue(value) {
|
|
29
|
+
return isPaletteColor(value) || isHexColor(value);
|
|
30
|
+
}
|
|
18
31
|
export function paletteColor(key) {
|
|
19
32
|
let hash = 0;
|
|
20
33
|
for (const char of key) hash = hash * 31 + char.codePointAt(0) >>> 0;
|
|
21
34
|
return PALETTE_COLORS[hash % PALETTE_COLORS.length];
|
|
22
35
|
}
|
|
23
36
|
export function paletteClass(color) {
|
|
24
|
-
return color ? `k-palette-${color}` : void 0;
|
|
37
|
+
return color && !isHexColor(color) ? `k-palette-${color}` : void 0;
|
|
38
|
+
}
|
|
39
|
+
export function colorStyle(color) {
|
|
40
|
+
if (!isHexColor(color)) return void 0;
|
|
41
|
+
const key = color.toLowerCase();
|
|
42
|
+
const cached = styleCache.get(key);
|
|
43
|
+
if (cached) return cached;
|
|
44
|
+
const style = buildColorStyle(parseHex(key));
|
|
45
|
+
styleCache.set(key, style);
|
|
46
|
+
return style;
|
|
47
|
+
}
|
|
48
|
+
function buildColorStyle(rgb) {
|
|
49
|
+
const light = adjust(rgb, 0, (value) => contrast(value, LIGHT_SURFACE) >= 3);
|
|
50
|
+
const dark = adjust(rgb, 1, (value) => contrast(value, DARK_SURFACE) >= 4.5);
|
|
51
|
+
const lightSoft = mix(LIGHT_SURFACE, light, SOFT_TINT);
|
|
52
|
+
const darkSoft = mix(DARK_SURFACE, dark, SOFT_TINT);
|
|
53
|
+
const lightText = adjust(
|
|
54
|
+
mix(light, BLACK, 0.22),
|
|
55
|
+
0,
|
|
56
|
+
(value) => contrast(value, lightSoft) >= 4.5
|
|
57
|
+
);
|
|
58
|
+
const darkText = adjust(mix(dark, WHITE, 0.12), 1, (value) => contrast(value, darkSoft) >= 4.5);
|
|
59
|
+
return {
|
|
60
|
+
"--k-palette": `light-dark(${toHex(light)}, ${toHex(dark)})`,
|
|
61
|
+
"--k-palette-text": `light-dark(${toHex(lightText)}, ${toHex(darkText)})`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function adjust(rgb, toward, accept) {
|
|
65
|
+
if (accept(rgb)) return rgb;
|
|
66
|
+
const lab = toOklab(rgb);
|
|
67
|
+
const at = (amount) => withLightness(lab, lab[0] + (toward - lab[0]) * amount);
|
|
68
|
+
let low = 0;
|
|
69
|
+
let high = 1;
|
|
70
|
+
for (let step = 0; step < 24; step += 1) {
|
|
71
|
+
const middle = (low + high) / 2;
|
|
72
|
+
if (accept(at(middle))) high = middle;
|
|
73
|
+
else low = middle;
|
|
74
|
+
}
|
|
75
|
+
return at(high);
|
|
76
|
+
}
|
|
77
|
+
function withLightness([, a, b], lightness) {
|
|
78
|
+
if (inGamut(toLinearRgb([lightness, a, b]))) return fromOklab([lightness, a, b]);
|
|
79
|
+
let low = 0;
|
|
80
|
+
let high = 1;
|
|
81
|
+
for (let step = 0; step < 16; step += 1) {
|
|
82
|
+
const middle = (low + high) / 2;
|
|
83
|
+
if (inGamut(toLinearRgb([lightness, a * middle, b * middle]))) low = middle;
|
|
84
|
+
else high = middle;
|
|
85
|
+
}
|
|
86
|
+
return fromOklab([lightness, a * low, b * low]);
|
|
87
|
+
}
|
|
88
|
+
function inGamut(linear) {
|
|
89
|
+
return linear.every((channel) => channel >= -1e-4 && channel <= 1.0001);
|
|
90
|
+
}
|
|
91
|
+
function parseHex(hex) {
|
|
92
|
+
return [1, 3, 5].map((start) => Number.parseInt(hex.slice(start, start + 2), 16) / 255);
|
|
93
|
+
}
|
|
94
|
+
function toHex(rgb) {
|
|
95
|
+
return `#${rgb.map(
|
|
96
|
+
(channel) => Math.round(Math.min(1, Math.max(0, channel)) * 255).toString(16).padStart(2, "0")
|
|
97
|
+
).join("")}`;
|
|
98
|
+
}
|
|
99
|
+
function toLinear(channel) {
|
|
100
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
101
|
+
}
|
|
102
|
+
function fromLinear(channel) {
|
|
103
|
+
const value = Math.min(1, Math.max(0, channel));
|
|
104
|
+
return value <= 31308e-7 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055;
|
|
105
|
+
}
|
|
106
|
+
function toOklab(rgb) {
|
|
107
|
+
const [r, g, b] = rgb.map(toLinear);
|
|
108
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
109
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
110
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
111
|
+
return [
|
|
112
|
+
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
113
|
+
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
114
|
+
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
function toLinearRgb([lightness, a, b]) {
|
|
118
|
+
const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
119
|
+
const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
120
|
+
const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
121
|
+
return [
|
|
122
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
123
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
124
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
function fromOklab(lab) {
|
|
128
|
+
return toLinearRgb(lab).map(fromLinear);
|
|
129
|
+
}
|
|
130
|
+
function mix(from, to, amount) {
|
|
131
|
+
if (amount <= 0) return from;
|
|
132
|
+
const start = toOklab(from);
|
|
133
|
+
const end = toOklab(to);
|
|
134
|
+
return fromOklab(start.map((value, index) => value + (end[index] - value) * amount));
|
|
135
|
+
}
|
|
136
|
+
function luminance(rgb) {
|
|
137
|
+
const [r, g, b] = rgb.map(toLinear);
|
|
138
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
139
|
+
}
|
|
140
|
+
function contrast(first, second) {
|
|
141
|
+
const a = luminance(first);
|
|
142
|
+
const b = luminance(second);
|
|
143
|
+
return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
|
|
25
144
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
2
2
|
export type Tone = 'neutral' | 'accent' | 'info' | 'success' | 'warning' | 'danger';
|
|
3
3
|
export type PaletteColor = 'blue' | 'green' | 'amber' | 'violet' | 'pink' | 'teal' | 'orange' | 'cyan' | 'indigo' | 'lime' | 'red' | 'slate';
|
|
4
|
-
export type
|
|
4
|
+
export type HexColor = `#${string}`;
|
|
5
|
+
export type ColorValue = PaletteColor | HexColor;
|
|
6
|
+
export type DotColor = ColorValue | 'muted';
|
|
5
7
|
export type ButtonVariant = 'solid' | 'soft' | 'subtle' | 'outline' | 'ghost' | 'link';
|
|
6
8
|
export type FieldSize = 'sm' | 'md' | 'lg';
|
|
7
9
|
export type LinkTarget = string | Record<string, unknown>;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
`k-badge-${size}`,
|
|
8
8
|
{ 'has-dot': dot }
|
|
9
9
|
]"
|
|
10
|
+
:style="colorStyle(color)"
|
|
10
11
|
>
|
|
11
12
|
<span v-if="dot" class="k-badge-dot" :class="{ 'is-pulse': pulse }" aria-hidden="true" />
|
|
12
13
|
<Icon v-else-if="icon" :name="icon" />
|
|
@@ -16,11 +17,11 @@
|
|
|
16
17
|
|
|
17
18
|
<script setup>
|
|
18
19
|
import Icon from "../core/Icon.vue";
|
|
19
|
-
import { paletteClass } from "../core/palette";
|
|
20
|
+
import { colorStyle, paletteClass } from "../core/palette";
|
|
20
21
|
defineProps({
|
|
21
22
|
label: { type: [String, Number], required: false },
|
|
22
23
|
tone: { type: String, required: false, default: "neutral" },
|
|
23
|
-
color: { type:
|
|
24
|
+
color: { type: null, required: false },
|
|
24
25
|
variant: { type: String, required: false, default: "soft" },
|
|
25
26
|
size: { type: String, required: false, default: "md" },
|
|
26
27
|
dot: { type: Boolean, required: false },
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
v-else-if="color"
|
|
15
15
|
class="k-filter-pill-dot"
|
|
16
16
|
:class="paletteClass(color)"
|
|
17
|
+
:style="colorStyle(color)"
|
|
17
18
|
aria-hidden="true"
|
|
18
19
|
/>
|
|
19
20
|
<span class="k-filter-pill-label"
|
|
@@ -27,12 +28,12 @@
|
|
|
27
28
|
|
|
28
29
|
<script setup>
|
|
29
30
|
import Icon from "../core/Icon.vue";
|
|
30
|
-
import { paletteClass } from "../core/palette";
|
|
31
|
+
import { colorStyle, paletteClass } from "../core/palette";
|
|
31
32
|
defineProps({
|
|
32
33
|
label: { type: String, required: false },
|
|
33
34
|
valueLabel: { type: String, required: false },
|
|
34
35
|
icon: { type: null, required: false },
|
|
35
|
-
color: { type:
|
|
36
|
+
color: { type: null, required: false },
|
|
36
37
|
count: { type: Number, required: false },
|
|
37
38
|
active: { type: Boolean, required: false },
|
|
38
39
|
pressed: { type: Boolean, required: false, default: void 0 },
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
`k-tag-${size}`,
|
|
8
8
|
{ 'is-removable': removable, 'is-disabled': disabled }
|
|
9
9
|
]"
|
|
10
|
+
:style="colorStyle(color)"
|
|
10
11
|
>
|
|
11
12
|
<Icon v-if="icon" :name="icon" class="k-tag-icon" />
|
|
12
13
|
<span class="k-tag-label"
|
|
@@ -34,11 +35,11 @@ import { hasFocusWithin, neighborFocusTarget } from "../../internal/core/focus";
|
|
|
34
35
|
import { useLocale } from "../../composables/useLocale";
|
|
35
36
|
import { formatLocaleMessage } from "../../locale";
|
|
36
37
|
import Icon from "../core/Icon.vue";
|
|
37
|
-
import { paletteClass } from "../core/palette";
|
|
38
|
+
import { colorStyle, paletteClass } from "../core/palette";
|
|
38
39
|
const props = defineProps({
|
|
39
40
|
label: { type: String, required: false },
|
|
40
41
|
tone: { type: String, required: false, default: "neutral" },
|
|
41
|
-
color: { type:
|
|
42
|
+
color: { type: null, required: false },
|
|
42
43
|
size: { type: String, required: false, default: "md" },
|
|
43
44
|
icon: { type: null, required: false },
|
|
44
45
|
removable: { type: Boolean, required: false },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ColorValue, Tone } from '../core/types';
|
|
2
2
|
import type { IconName } from '../../composables/useIcons';
|
|
3
3
|
import type { MenuItems } from '../overlays/types';
|
|
4
4
|
export type BadgeVariant = 'soft' | 'solid' | 'outline';
|
|
@@ -87,7 +87,7 @@ export interface FilterPillOption<T extends FilterPillValue = FilterPillValue> {
|
|
|
87
87
|
valueLabel?: string;
|
|
88
88
|
count?: number;
|
|
89
89
|
icon?: string;
|
|
90
|
-
color?:
|
|
90
|
+
color?: ColorValue;
|
|
91
91
|
disabled?: boolean;
|
|
92
92
|
menu?: MenuItems;
|
|
93
93
|
menuLabel?: string;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
'is-open': layer.isOpen.value,
|
|
9
9
|
'is-multiple': multiple,
|
|
10
10
|
'is-disabled': control.disabled.value,
|
|
11
|
-
'has-lead': Boolean(icon)
|
|
11
|
+
'has-lead': Boolean(icon || leadColor)
|
|
12
12
|
},
|
|
13
13
|
props.class
|
|
14
14
|
]"
|
|
@@ -28,12 +28,20 @@
|
|
|
28
28
|
@mousedown="onControlMousedown"
|
|
29
29
|
>
|
|
30
30
|
<span v-if="icon" class="k-combobox-lead" aria-hidden="true"><Icon :name="icon" /></span>
|
|
31
|
+
<span v-else-if="leadColor" class="k-combobox-lead" aria-hidden="true">
|
|
32
|
+
<span
|
|
33
|
+
class="k-combobox-option-dot"
|
|
34
|
+
:class="paletteClass(leadColor)"
|
|
35
|
+
:style="colorStyle(leadColor)"
|
|
36
|
+
/>
|
|
37
|
+
</span>
|
|
31
38
|
<template v-if="multiple && !hideTags">
|
|
32
39
|
<span
|
|
33
40
|
v-for="value in selectedValues"
|
|
34
41
|
:key="keyOf(value)"
|
|
35
42
|
class="k-combobox-tag"
|
|
36
43
|
:class="tagClass(value)"
|
|
44
|
+
:style="colorStyle(optionFor(value)?.color)"
|
|
37
45
|
:title="optionFor(value)?.group ?? optionFor(value)?.description"
|
|
38
46
|
>
|
|
39
47
|
<span class="k-combobox-tag-label">{{ labelFor(value) }}</span>
|
|
@@ -131,6 +139,7 @@
|
|
|
131
139
|
v-if="item.option.color"
|
|
132
140
|
class="k-combobox-option-dot"
|
|
133
141
|
:class="paletteClass(item.option.color)"
|
|
142
|
+
:style="colorStyle(item.option.color)"
|
|
134
143
|
aria-hidden="true"
|
|
135
144
|
/>
|
|
136
145
|
{{ item.option.group }}
|
|
@@ -161,6 +170,7 @@
|
|
|
161
170
|
v-else-if="item.option.color && !item.option.icon && !item.option.group"
|
|
162
171
|
class="k-combobox-option-dot"
|
|
163
172
|
:class="paletteClass(item.option.color)"
|
|
173
|
+
:style="colorStyle(item.option.color)"
|
|
164
174
|
aria-hidden="true"
|
|
165
175
|
/>
|
|
166
176
|
<Icon
|
|
@@ -235,7 +245,7 @@ import { normalizeSearch } from "../../internal/core/text";
|
|
|
235
245
|
import { translateOr } from "../../locale";
|
|
236
246
|
import { joinIds } from "../../internal/forms/control";
|
|
237
247
|
import Icon from "../core/Icon.vue";
|
|
238
|
-
import { paletteClass } from "../core/palette";
|
|
248
|
+
import { colorStyle, paletteClass } from "../core/palette";
|
|
239
249
|
import FieldMessage from "../core/FieldMessage.vue";
|
|
240
250
|
import Spinner from "../core/Spinner.vue";
|
|
241
251
|
defineOptions({ inheritAttrs: false });
|
|
@@ -363,6 +373,11 @@ const selectedLabel = computed(() => {
|
|
|
363
373
|
const value = selectedValues.value[0];
|
|
364
374
|
return value === void 0 ? "" : labelFor(value);
|
|
365
375
|
});
|
|
376
|
+
const leadColor = computed(() => {
|
|
377
|
+
if (props.multiple || editing.value) return void 0;
|
|
378
|
+
const value = selectedValues.value[0];
|
|
379
|
+
return value === void 0 ? void 0 : optionFor(value)?.color;
|
|
380
|
+
});
|
|
366
381
|
const inputValue = computed(() => {
|
|
367
382
|
if (props.multiple || editing.value) return query.value;
|
|
368
383
|
return selectedLabel.value;
|