@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.
Files changed (43) hide show
  1. package/CATALOG.md +24 -22
  2. package/README.md +14 -3
  3. package/dist/components/core/index.d.ts +2 -1
  4. package/dist/components/core/index.mjs +9 -1
  5. package/dist/components/core/palette.d.ts +6 -2
  6. package/dist/components/core/palette.mjs +120 -1
  7. package/dist/components/core/types.d.ts +3 -1
  8. package/dist/components/data/Badge.vue +3 -2
  9. package/dist/components/data/FilterPill.vue +3 -2
  10. package/dist/components/data/Tag.vue +3 -2
  11. package/dist/components/data/types.d.ts +2 -2
  12. package/dist/components/forms/Combobox.vue +17 -2
  13. package/dist/components/forms/PaletteSelect.vue +60 -16
  14. package/dist/components/forms/PaletteSelect.vue.d.ts +32 -25
  15. package/dist/components/forms/types.d.ts +2 -2
  16. package/dist/components/overlays/ConfirmDialog.vue.d.ts +2 -2
  17. package/dist/components/overlays/ConfirmHost.vue.d.ts +2 -2
  18. package/dist/components/overlays/types.d.ts +2 -2
  19. package/dist/components/templates/SettingsModal.vue +9 -15
  20. package/dist/components/templates/SettingsModal.vue.d.ts +2 -2
  21. package/dist/grid/cells/BadgeCell.vue +18 -7
  22. package/dist/grid/types.d.ts +2 -2
  23. package/dist/internal/layout/CollapsedTrail.vue +120 -0
  24. package/dist/internal/layout/CollapsedTrail.vue.d.ts +404 -0
  25. package/dist/internal/overlays/DialogTrail.vue +9 -10
  26. package/dist/internal/overlays/DialogTrail.vue.d.ts +407 -8
  27. package/dist/internal/overlays/MenuList.vue +2 -1
  28. package/dist/internal/overlays/OverlayView.vue.d.ts +2 -2
  29. package/dist/locale/de.mjs +4 -1
  30. package/dist/locale/en.mjs +4 -1
  31. package/dist/locale/it.mjs +4 -1
  32. package/dist/locale/types.d.ts +3 -0
  33. package/dist/palette.d.ts +3 -2
  34. package/dist/palette.mjs +3 -0
  35. package/dist/styles/data/record-list.css +1 -3
  36. package/dist/styles/data/tree.css +1 -3
  37. package/dist/styles/forms/palette-select.css +5 -0
  38. package/dist/styles/forms.css +1 -0
  39. package/dist/styles/layout/trail.css +67 -0
  40. package/dist/styles/layout.css +1 -0
  41. package/dist/styles/overlays/modal.css +11 -4
  42. package/dist/styles/templates/settings-modal.css +2 -5
  43. package/package.json +1 -1
@@ -1,33 +1,77 @@
1
1
  <template>
2
- <Combobox
3
- v-model="model"
4
- :options="options"
5
- :clearable="clearable"
6
- :placeholder="placeholder ?? (clearable ? t('palette.auto') : void 0)"
7
- :size="size"
8
- :disabled="disabled"
9
- :readonly="readonly"
10
- :invalid="invalid"
11
- />
2
+ <div class="k-palette-select" :class="[props.class]" :style="props.style">
3
+ <Combobox
4
+ v-bind="$attrs"
5
+ v-model="selected"
6
+ :options="options"
7
+ :clearable="clearable"
8
+ :placeholder="placeholder ?? (clearable ? t('palette.auto') : void 0)"
9
+ :size="size"
10
+ :disabled="disabled"
11
+ :readonly="readonly"
12
+ :invalid="invalid"
13
+ />
14
+ <FieldBoundary v-if="custom && isHexColor(model)" auxiliary>
15
+ <ColorInput
16
+ v-model="hex"
17
+ :aria-label="customText"
18
+ :size="size"
19
+ :disabled="disabled"
20
+ :readonly="readonly"
21
+ />
22
+ </FieldBoundary>
23
+ </div>
12
24
  </template>
13
25
 
14
26
  <script setup>
15
- import { computed } from "vue";
27
+ import { computed, ref, watch } from "vue";
16
28
  import { useLocale } from "../../composables/useLocale";
17
- import { PALETTE_COLORS } from "../core/palette";
29
+ import FieldBoundary from "../core/FieldBoundary.vue";
30
+ import { PALETTE_COLORS, isHexColor } from "../core/palette";
31
+ import ColorInput from "./ColorInput.vue";
18
32
  import Combobox from "./Combobox.vue";
33
+ const CUSTOM = "custom";
34
+ defineOptions({ inheritAttrs: false });
19
35
  const props = defineProps({
20
36
  colors: { type: Array, required: false, default: () => PALETTE_COLORS },
37
+ custom: { type: Boolean, required: false },
21
38
  clearable: { type: Boolean, required: false },
22
39
  placeholder: { type: String, required: false },
40
+ customLabel: { type: String, required: false },
23
41
  size: { type: String, required: false, default: "md" },
24
42
  disabled: { type: Boolean, required: false },
25
43
  readonly: { type: Boolean, required: false },
26
- invalid: { type: Boolean, required: false, default: void 0 }
44
+ invalid: { type: Boolean, required: false, default: void 0 },
45
+ class: { type: null, required: false },
46
+ style: { type: null, required: false }
27
47
  });
28
48
  const model = defineModel({ type: null });
29
49
  const { t } = useLocale();
30
- const options = computed(
31
- () => props.colors.map((color) => ({ value: color, label: t(`palette.${color}`), color }))
32
- );
50
+ const customText = computed(() => props.customLabel ?? t("palette.customColor"));
51
+ const lastCustom = ref(isHexColor(model.value) ? model.value : "#3b82f6");
52
+ watch(model, (value) => {
53
+ if (isHexColor(value)) lastCustom.value = value;
54
+ });
55
+ const selected = computed({
56
+ get: () => isHexColor(model.value) ? CUSTOM : model.value,
57
+ set: (value) => {
58
+ model.value = value === CUSTOM ? lastCustom.value : value;
59
+ }
60
+ });
61
+ const hex = computed({
62
+ get: () => isHexColor(model.value) ? model.value : void 0,
63
+ set: (value) => {
64
+ if (isHexColor(value)) model.value = value.toLowerCase();
65
+ }
66
+ });
67
+ const options = computed(() => {
68
+ const list = props.colors.map((color) => ({
69
+ value: color,
70
+ label: t(`palette.${color}`),
71
+ color
72
+ }));
73
+ if (props.custom || isHexColor(model.value))
74
+ list.push({ value: CUSTOM, label: t("palette.custom"), color: lastCustom.value });
75
+ return list;
76
+ });
33
77
  </script>
@@ -1,21 +1,28 @@
1
- import type { FieldSize, PaletteColor } from '../core/types';
1
+ import type { ColorValue, FieldSize, PaletteColor } from '../core/types';
2
+ import type { ComboboxOption } from './types';
3
+ type PaletteOptionValue = PaletteColor | typeof CUSTOM;
4
+ declare const CUSTOM = "custom";
2
5
  declare const __VLS_export: import("vue").DefineComponent<{
3
6
  colors?: readonly PaletteColor[];
7
+ custom?: boolean;
4
8
  clearable?: boolean;
5
9
  placeholder?: string;
10
+ customLabel?: string;
6
11
  size?: FieldSize;
7
12
  disabled?: boolean;
8
13
  readonly?: boolean;
9
14
  invalid?: boolean;
10
- modelValue?: PaletteColor | null | undefined;
15
+ class?: unknown;
16
+ style?: unknown;
17
+ modelValue?: ColorValue | "custom" | null | undefined;
11
18
  key?: PropertyKey | undefined;
12
19
  loading?: boolean | undefined;
13
20
  prefix?: string | undefined | undefined;
14
21
  icon?: import("../../index.ts").IconName | undefined;
15
22
  value?: any;
16
- filter?: ((option: import("./types.ts").ComboboxOption<PaletteColor>, query: string) => boolean) | undefined;
23
+ filter?: ((option: ComboboxOption<PaletteOptionValue>, query: string) => boolean) | undefined;
17
24
  form?: string | undefined | undefined;
18
- search?: import("./types.ts").ComboboxSearch<PaletteColor> | undefined;
25
+ search?: import("./types").ComboboxSearch<PaletteOptionValue> | undefined;
19
26
  required?: boolean | undefined;
20
27
  min?: (string | number) | undefined;
21
28
  max?: (string | number) | undefined;
@@ -23,7 +30,6 @@ declare const __VLS_export: import("vue").DefineComponent<{
23
30
  checked?: any[] | Set<any> | (boolean | "true" | "false") | undefined;
24
31
  indeterminate?: boolean | undefined | undefined;
25
32
  title?: string | undefined | undefined;
26
- style?: import("vue").StyleValue;
27
33
  list?: string | undefined | undefined;
28
34
  results?: (string | number) | undefined;
29
35
  name?: string | undefined;
@@ -31,7 +37,6 @@ declare const __VLS_export: import("vue").DefineComponent<{
31
37
  contextmenu?: string | undefined | undefined;
32
38
  hidden?: "" | "hidden" | (boolean | "true" | "false") | "until-found" | undefined;
33
39
  query?: string | undefined;
34
- class?: import("vue").ClassValue;
35
40
  role?: string | undefined | undefined;
36
41
  'aria-label'?: string | undefined | undefined;
37
42
  'aria-hidden'?: (boolean | "true" | "false") | undefined;
@@ -245,17 +250,17 @@ declare const __VLS_export: import("vue").DefineComponent<{
245
250
  onCancel?: ((payload: Event) => void) | undefined;
246
251
  onClose?: (() => any) | undefined;
247
252
  emptyText?: string | undefined;
248
- options?: import("./types.ts").ComboboxOption<PaletteColor>[] | undefined;
253
+ options?: ComboboxOption<PaletteOptionValue>[] | undefined;
249
254
  removeLabel?: string | undefined;
250
255
  loadingText?: string | undefined;
251
- onCreate?: ((option: import("./types.ts").ComboboxOption<PaletteColor>) => any) | undefined;
256
+ onCreate?: ((option: ComboboxOption<PaletteOptionValue>) => any) | undefined;
252
257
  onOpen?: (() => any) | undefined;
253
258
  "onUpdate:query"?: ((value: string) => any) | undefined;
254
259
  hideTags?: boolean | undefined;
255
- creatable?: boolean | import("./types.ts").ComboboxCreate<PaletteColor> | undefined;
256
- createActions?: import("./types.ts").ComboboxCreateActions<PaletteColor> | undefined;
257
- createValidate?: import("./types.ts").ComboboxCreateValidate | undefined;
258
- createTransform?: import("./types.ts").ComboboxCreateTransform | undefined;
260
+ creatable?: boolean | import("./types").ComboboxCreate<PaletteOptionValue> | undefined;
261
+ createActions?: import("./types").ComboboxCreateActions<PaletteOptionValue> | undefined;
262
+ createValidate?: import("./types").ComboboxCreateValidate | undefined;
263
+ createTransform?: import("./types").ComboboxCreateTransform | undefined;
259
264
  debounce?: number | undefined;
260
265
  minQueryLength?: number | undefined;
261
266
  maxSelected?: number | undefined;
@@ -265,24 +270,28 @@ declare const __VLS_export: import("vue").DefineComponent<{
265
270
  createText?: ((query: string) => string) | undefined;
266
271
  resultsText?: ((count: number) => string) | undefined;
267
272
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
268
- "update:modelValue": (value: PaletteColor | null | undefined) => any;
273
+ "update:modelValue": (value: ColorValue | null | undefined) => any;
269
274
  }, string, import("vue").PublicProps, Readonly<{
270
275
  colors?: readonly PaletteColor[];
276
+ custom?: boolean;
271
277
  clearable?: boolean;
272
278
  placeholder?: string;
279
+ customLabel?: string;
273
280
  size?: FieldSize;
274
281
  disabled?: boolean;
275
282
  readonly?: boolean;
276
283
  invalid?: boolean;
277
- modelValue?: PaletteColor | null | undefined;
284
+ class?: unknown;
285
+ style?: unknown;
286
+ modelValue?: ColorValue | "custom" | null | undefined;
278
287
  key?: PropertyKey | undefined;
279
288
  loading?: boolean | undefined;
280
289
  prefix?: string | undefined | undefined;
281
290
  icon?: import("../../index.ts").IconName | undefined;
282
291
  value?: any;
283
- filter?: ((option: import("./types.ts").ComboboxOption<PaletteColor>, query: string) => boolean) | undefined;
292
+ filter?: ((option: ComboboxOption<PaletteOptionValue>, query: string) => boolean) | undefined;
284
293
  form?: string | undefined | undefined;
285
- search?: import("./types.ts").ComboboxSearch<PaletteColor> | undefined;
294
+ search?: import("./types").ComboboxSearch<PaletteOptionValue> | undefined;
286
295
  required?: boolean | undefined;
287
296
  min?: (string | number) | undefined;
288
297
  max?: (string | number) | undefined;
@@ -290,7 +299,6 @@ declare const __VLS_export: import("vue").DefineComponent<{
290
299
  checked?: any[] | Set<any> | (boolean | "true" | "false") | undefined;
291
300
  indeterminate?: boolean | undefined | undefined;
292
301
  title?: string | undefined | undefined;
293
- style?: import("vue").StyleValue;
294
302
  list?: string | undefined | undefined;
295
303
  results?: (string | number) | undefined;
296
304
  name?: string | undefined;
@@ -298,7 +306,6 @@ declare const __VLS_export: import("vue").DefineComponent<{
298
306
  contextmenu?: string | undefined | undefined;
299
307
  hidden?: "" | "hidden" | (boolean | "true" | "false") | "until-found" | undefined;
300
308
  query?: string | undefined;
301
- class?: import("vue").ClassValue;
302
309
  role?: string | undefined | undefined;
303
310
  'aria-label'?: string | undefined | undefined;
304
311
  'aria-hidden'?: (boolean | "true" | "false") | undefined;
@@ -512,17 +519,17 @@ declare const __VLS_export: import("vue").DefineComponent<{
512
519
  onCancel?: ((payload: Event) => void) | undefined;
513
520
  onClose?: (() => any) | undefined;
514
521
  emptyText?: string | undefined;
515
- options?: import("./types.ts").ComboboxOption<PaletteColor>[] | undefined;
522
+ options?: ComboboxOption<PaletteOptionValue>[] | undefined;
516
523
  removeLabel?: string | undefined;
517
524
  loadingText?: string | undefined;
518
- onCreate?: ((option: import("./types.ts").ComboboxOption<PaletteColor>) => any) | undefined;
525
+ onCreate?: ((option: ComboboxOption<PaletteOptionValue>) => any) | undefined;
519
526
  onOpen?: (() => any) | undefined;
520
527
  "onUpdate:query"?: ((value: string) => any) | undefined;
521
528
  hideTags?: boolean | undefined;
522
- creatable?: boolean | import("./types.ts").ComboboxCreate<PaletteColor> | undefined;
523
- createActions?: import("./types.ts").ComboboxCreateActions<PaletteColor> | undefined;
524
- createValidate?: import("./types.ts").ComboboxCreateValidate | undefined;
525
- createTransform?: import("./types.ts").ComboboxCreateTransform | undefined;
529
+ creatable?: boolean | import("./types").ComboboxCreate<PaletteOptionValue> | undefined;
530
+ createActions?: import("./types").ComboboxCreateActions<PaletteOptionValue> | undefined;
531
+ createValidate?: import("./types").ComboboxCreateValidate | undefined;
532
+ createTransform?: import("./types").ComboboxCreateTransform | undefined;
526
533
  debounce?: number | undefined;
527
534
  minQueryLength?: number | undefined;
528
535
  maxSelected?: number | undefined;
@@ -532,7 +539,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
532
539
  createText?: ((query: string) => string) | undefined;
533
540
  resultsText?: ((count: number) => string) | undefined;
534
541
  }> & Readonly<{
535
- "onUpdate:modelValue"?: ((value: PaletteColor | null | undefined) => any) | undefined;
542
+ "onUpdate:modelValue"?: ((value: ColorValue | null | undefined) => any) | undefined;
536
543
  }>, {
537
544
  size: FieldSize;
538
545
  invalid: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { IconName } from '../../composables/useIcons';
2
- import type { PaletteColor } from '../core/types';
2
+ import type { ColorValue } from '../core/types';
3
3
  export type ChoiceValue = string | number | boolean | null;
4
4
  export type ChoiceOrientation = 'horizontal' | 'vertical';
5
5
  export interface ChoiceOption<T = ChoiceValue> {
@@ -29,7 +29,7 @@ export interface ComboboxOption<T = string | number> {
29
29
  description?: string;
30
30
  disabled?: boolean;
31
31
  icon?: IconName;
32
- color?: PaletteColor;
32
+ color?: ColorValue;
33
33
  group?: string;
34
34
  keywords?: string[];
35
35
  }
@@ -229,8 +229,8 @@ declare const __VLS_base: import("vue").DefineComponent<{
229
229
  onOpen?: (() => any) | undefined;
230
230
  backLabel?: string;
231
231
  closeLabel?: string;
232
- trail?: string[];
233
232
  onNavigate?: ((index: number) => any) | undefined;
233
+ trail?: string[];
234
234
  rootClass?: unknown;
235
235
  hideClose?: boolean;
236
236
  beforeClose?: import("./types.ts").DialogBeforeClose;
@@ -466,8 +466,8 @@ declare const __VLS_base: import("vue").DefineComponent<{
466
466
  onOpen?: (() => any) | undefined;
467
467
  backLabel?: string;
468
468
  closeLabel?: string;
469
- trail?: string[];
470
469
  onNavigate?: ((index: number) => any) | undefined;
470
+ trail?: string[];
471
471
  rootClass?: unknown;
472
472
  hideClose?: boolean;
473
473
  beforeClose?: import("./types.ts").DialogBeforeClose;
@@ -219,8 +219,8 @@ declare const __VLS_export: import("vue").DefineComponent<Partial<NonNullable<{
219
219
  readonly onOpen?: (() => any) | undefined;
220
220
  readonly backLabel?: string | undefined;
221
221
  readonly closeLabel?: string | undefined;
222
- readonly trail?: string[] | undefined;
223
222
  readonly onNavigate?: ((index: number) => any) | undefined;
223
+ readonly trail?: string[] | undefined;
224
224
  readonly rootClass?: unknown;
225
225
  readonly hideClose?: boolean | undefined;
226
226
  readonly beforeClose?: import("./types.ts").DialogBeforeClose | undefined;
@@ -452,8 +452,8 @@ declare const __VLS_export: import("vue").DefineComponent<Partial<NonNullable<{
452
452
  readonly onOpen?: (() => any) | undefined;
453
453
  readonly backLabel?: string | undefined;
454
454
  readonly closeLabel?: string | undefined;
455
- readonly trail?: string[] | undefined;
456
455
  readonly onNavigate?: ((index: number) => any) | undefined;
456
+ readonly trail?: string[] | undefined;
457
457
  readonly rootClass?: unknown;
458
458
  readonly hideClose?: boolean | undefined;
459
459
  readonly beforeClose?: import("./types.ts").DialogBeforeClose | undefined;
@@ -1,4 +1,4 @@
1
- import type { DotColor, LinkTarget, PaletteColor, Tone } from '../core/types';
1
+ import type { ColorValue, DotColor, LinkTarget, Tone } from '../core/types';
2
2
  import type { IconName } from '../../composables/useIcons';
3
3
  import type { AnchorTarget, Placement, Side, VirtualAnchor } from '../../internal/floating/position';
4
4
  export type { AnchorTarget as OverlayAnchorTarget, Placement as OverlayPlacement, Side as OverlaySide, VirtualAnchor as OverlayVirtualAnchor, };
@@ -65,7 +65,7 @@ export type MenuItems = MenuEntry[] | MenuEntry[][];
65
65
  export interface CommandItemBadge {
66
66
  label: string;
67
67
  tone?: Tone;
68
- color?: PaletteColor;
68
+ color?: ColorValue;
69
69
  }
70
70
  export interface CommandItem<T = unknown> {
71
71
  id: string;
@@ -99,21 +99,14 @@
99
99
  <header class="k-settings-modal-header">
100
100
  <div class="k-settings-modal-heading">
101
101
  <h2 :id="`${baseId}-title`" class="k-settings-modal-title">
102
- <template v-if="currentPage">
103
- <template v-for="(crumb, index) in trail" :key="index">
104
- <button
105
- type="button"
106
- class="k-settings-modal-crumb"
107
- @click="goTo(index)"
108
- >
109
- {{ crumb }}
110
- </button>
111
- <Icon name="chevron-right" class="k-settings-modal-crumb-separator" />
112
- </template>
113
- <span class="k-settings-modal-crumb is-current">
114
- {{ currentPage.label }}
115
- </span>
116
- </template>
102
+ <CollapsedTrail
103
+ v-if="currentPage"
104
+ :crumbs="trail"
105
+ prefix="k-settings-modal"
106
+ @navigate="goTo"
107
+ >
108
+ {{ currentPage.label }}
109
+ </CollapsedTrail>
117
110
  <template v-else>{{ active.label }}</template>
118
111
  </h2>
119
112
  <p v-if="active.description" class="k-settings-modal-description">
@@ -220,6 +213,7 @@ import { THEME_PRESETS } from "../../composables/usePreset";
220
213
  import { useLocale } from "../../composables/useLocale";
221
214
  import { useLinkResolver } from "../../internal/core/link";
222
215
  import { useScrollEdges } from "../../internal/core/scroll-edges";
216
+ import CollapsedTrail from "../../internal/layout/CollapsedTrail.vue";
223
217
  import {
224
218
  useDefaultRouteLocation,
225
219
  useRouteValue,
@@ -255,8 +255,8 @@ declare const __VLS_base: import("vue").DefineComponent<{
255
255
  sheet?: boolean;
256
256
  tab?: import("../layout/types.ts").TabItem["value"];
257
257
  onCancel?: ((payload: Event) => void) | undefined;
258
- trail?: string[];
259
258
  onNavigate?: ((index: number) => any) | undefined;
259
+ trail?: string[];
260
260
  rootClass?: unknown;
261
261
  hideClose?: boolean;
262
262
  "onUpdate:tab"?: ((value: string | number | undefined) => any) | undefined;
@@ -507,8 +507,8 @@ declare const __VLS_base: import("vue").DefineComponent<{
507
507
  sheet?: boolean;
508
508
  tab?: import("../layout/types.ts").TabItem["value"];
509
509
  onCancel?: ((payload: Event) => void) | undefined;
510
- trail?: string[];
511
510
  onNavigate?: ((index: number) => any) | undefined;
511
+ trail?: string[];
512
512
  rootClass?: unknown;
513
513
  hideClose?: boolean;
514
514
  "onUpdate:tab"?: ((value: string | number | undefined) => any) | undefined;
@@ -17,9 +17,14 @@
17
17
  :title="entry.title"
18
18
  >{{ entry.text }}</Badge
19
19
  >
20
- <span v-else class="k-data-grid-badge" :class="entry.classes" :title="entry.title">{{
21
- entry.text
22
- }}</span>
20
+ <span
21
+ v-else
22
+ class="k-data-grid-badge"
23
+ :class="entry.classes"
24
+ :style="entry.style"
25
+ :title="entry.title"
26
+ >{{ entry.text }}</span
27
+ >
23
28
  </template>
24
29
  <template v-if="hiddenCount > 0">
25
30
  <Badge
@@ -51,9 +56,14 @@
51
56
  :title="single.title"
52
57
  >{{ single.text }}</Badge
53
58
  >
54
- <span v-else class="k-data-grid-badge" :class="single.classes" :title="single.title">{{
55
- single.text
56
- }}</span>
59
+ <span
60
+ v-else
61
+ class="k-data-grid-badge"
62
+ :class="single.classes"
63
+ :style="single.style"
64
+ :title="single.title"
65
+ >{{ single.text }}</span
66
+ >
57
67
  </template>
58
68
  <EmptyCell v-else :context="cellContext" />
59
69
  </template>
@@ -62,7 +72,7 @@
62
72
  import { computed, nextTick, ref, watch } from "vue";
63
73
  import { useResizeObserver } from "../../internal/core/resize";
64
74
  import Badge from "../../components/data/Badge.vue";
65
- import { paletteClass } from "../../components/core/palette";
75
+ import { colorStyle, paletteClass } from "../../components/core/palette";
66
76
  import { formatLocaleMessage } from "../../locale";
67
77
  import EmptyCell from "./EmptyCell.vue";
68
78
  const props = defineProps({
@@ -92,6 +102,7 @@ function entryFor(raw, index) {
92
102
  tone,
93
103
  color,
94
104
  badgeClass,
105
+ style: colorStyle(color),
95
106
  classes: [
96
107
  color ? ["k-data-grid-badge-palette", paletteClass(color)] : `k-data-grid-badge-${tone}`,
97
108
  badgeClass
@@ -1,5 +1,5 @@
1
1
  import type { ColDef, GridApi, ICellRendererParams } from 'ag-grid-community';
2
- import type { PaletteColor, Tone } from '../components/core/types';
2
+ import type { ColorValue, Tone } from '../components/core/types';
3
3
  import type { BadgeSize, BadgeVariant, PageSize } from '../components/data/types';
4
4
  import type { KMessages } from '../locale/types';
5
5
  export type GridDensity = 'compact' | 'normal' | 'comfortable';
@@ -56,7 +56,7 @@ export interface DateCellParams {
56
56
  export type BadgeCellMap<V, T> = Record<string, V> | ((value: unknown, data: T | undefined) => V | undefined);
57
57
  export interface BadgeCellParams<T = unknown> {
58
58
  tones?: Record<string, Tone>;
59
- colors?: BadgeCellMap<PaletteColor, T>;
59
+ colors?: BadgeCellMap<ColorValue, T>;
60
60
  labels?: BadgeCellMap<string, T>;
61
61
  titles?: BadgeCellMap<string, T>;
62
62
  defaultTone?: Tone;
@@ -0,0 +1,120 @@
1
+ <template>
2
+ <span ref="rootRef" class="k-trail">
3
+ <span class="k-trail-list">
4
+ <template v-for="part in parts" :key="part.key">
5
+ <DropdownMenu v-if="part.index === null" :items="hiddenItems" class="k-trail-menu">
6
+ <button
7
+ type="button"
8
+ class="k-trail-more"
9
+ :class="crumbClass"
10
+ :aria-label="moreText"
11
+ :title="moreText"
12
+ >
13
+ <Icon name="ellipsis-horizontal" />
14
+ </button>
15
+ </DropdownMenu>
16
+ <button
17
+ v-else
18
+ type="button"
19
+ class="k-trail-crumb"
20
+ :class="crumbClass"
21
+ :title="part.label"
22
+ @click="emit('navigate', part.index)"
23
+ >
24
+ {{ part.label }}
25
+ </button>
26
+ <Icon name="chevron-right" class="k-trail-separator" :class="separatorClass" />
27
+ </template>
28
+ <span class="k-trail-current is-current" :class="crumbClass"><slot /></span>
29
+ </span>
30
+ <span class="k-trail-measure" aria-hidden="true">
31
+ <span ref="measureRef" class="k-trail-measure-content">
32
+ <span v-for="(crumb, index) in crumbs" :key="index" :class="crumbClass">
33
+ {{ crumb }}
34
+ </span>
35
+ <span class="k-trail-more" :class="crumbClass"
36
+ ><Icon name="ellipsis-horizontal"
37
+ /></span>
38
+ <Icon name="chevron-right" class="k-trail-separator" :class="separatorClass" />
39
+ <span class="is-current" :class="crumbClass"><slot /></span>
40
+ </span>
41
+ </span>
42
+ </span>
43
+ </template>
44
+
45
+ <script setup>
46
+ import { computed, nextTick, ref, useTemplateRef, watch } from "vue";
47
+ import Icon from "../../components/core/Icon.vue";
48
+ import DropdownMenu from "../../components/overlays/DropdownMenu.vue";
49
+ import { useLocale } from "../../composables/useLocale";
50
+ import { useResizeObserver } from "../core/resize";
51
+ const props = defineProps({
52
+ crumbs: { type: Array, required: true },
53
+ prefix: { type: String, required: true }
54
+ });
55
+ const emit = defineEmits(["navigate"]);
56
+ defineSlots();
57
+ const { t } = useLocale();
58
+ const moreText = computed(() => t("breadcrumbs.collapsed"));
59
+ const crumbClass = computed(() => `${props.prefix}-crumb`);
60
+ const separatorClass = computed(() => `${props.prefix}-crumb-separator`);
61
+ const rootRef = useTemplateRef("rootRef");
62
+ const measureRef = useTemplateRef("measureRef");
63
+ const kept = ref(null);
64
+ const visibleTail = computed(() => {
65
+ const count = props.crumbs.length;
66
+ if (kept.value === null || count < 2) return null;
67
+ return Math.min(kept.value, count - 2);
68
+ });
69
+ const parts = computed(() => {
70
+ const crumbs = props.crumbs.map((label, index) => ({ key: `${index}`, label, index }));
71
+ const tail = visibleTail.value;
72
+ if (tail === null) return crumbs;
73
+ return [
74
+ crumbs[0],
75
+ { key: "more", label: "", index: null },
76
+ ...crumbs.slice(crumbs.length - tail)
77
+ ];
78
+ });
79
+ const hiddenItems = computed(() => {
80
+ const tail = visibleTail.value;
81
+ if (tail === null) return [];
82
+ return props.crumbs.slice(1, props.crumbs.length - tail).map((label, offset) => ({
83
+ label,
84
+ onSelect: () => emit("navigate", offset + 1)
85
+ }));
86
+ });
87
+ function widthOf(element) {
88
+ return element ? element.getBoundingClientRect().width : 0;
89
+ }
90
+ function measure() {
91
+ const root = rootRef.value;
92
+ const content = measureRef.value;
93
+ if (!root || !content) return;
94
+ const count = props.crumbs.length;
95
+ const items = Array.from(content.children);
96
+ const gap = Number.parseFloat(getComputedStyle(content).columnGap) || 0;
97
+ const step = widthOf(items[count + 1]) + gap * 2;
98
+ const crumbs = items.slice(0, count).map((item) => widthOf(item) + step);
99
+ const more = widthOf(items[count]) + step;
100
+ const current = widthOf(items[count + 2]);
101
+ const available = widthOf(root) + 0.5;
102
+ const full = crumbs.reduce((sum, width) => sum + width, current);
103
+ if (count < 2 || full <= available) {
104
+ kept.value = null;
105
+ return;
106
+ }
107
+ let used = crumbs[0] + more + current;
108
+ let keep = 0;
109
+ while (keep < count - 2 && used + crumbs[count - 1 - keep] <= available) {
110
+ used += crumbs[count - 1 - keep];
111
+ keep += 1;
112
+ }
113
+ kept.value = keep;
114
+ }
115
+ useResizeObserver(() => [rootRef.value, measureRef.value], measure);
116
+ watch(
117
+ () => props.crumbs.join("\0"),
118
+ () => nextTick(measure)
119
+ );
120
+ </script>