@milaboratories/uikit 1.2.21 → 1.2.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/uikit",
3
- "version": "1.2.21",
3
+ "version": "1.2.22",
4
4
  "type": "module",
5
5
  "main": "dist/pl-uikit.umd.js",
6
6
  "module": "dist/pl-uikit.js",
@@ -31,8 +31,8 @@
31
31
  "vue-tsc": "^2.1.6",
32
32
  "yarpm": "^1.2.0",
33
33
  "svgo": "^3.3.2",
34
- "@platforma-sdk/model": "^1.7.0",
35
- "@milaboratories/helpers": "^1.6.5"
34
+ "@milaboratories/helpers": "^1.6.5",
35
+ "@platforma-sdk/model": "^1.7.0"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "vite",
@@ -9,7 +9,7 @@ export default {
9
9
 
10
10
  <script lang="ts" setup generic="M = unknown">
11
11
  import './pl-btn-group.scss';
12
- import { useSlots } from 'vue';
12
+ import { computed, useSlots } from 'vue';
13
13
  import { PlTooltip } from '@/components/PlTooltip';
14
14
  import InnerBorder from '@/utils/InnerBorder.vue';
15
15
  import type { SimpleOption } from '@/types';
@@ -25,7 +25,7 @@ const emit = defineEmits<{
25
25
 
26
26
  const emitModel = (v: M) => emit('update:modelValue', v);
27
27
 
28
- defineProps<{
28
+ const props = defineProps<{
29
29
  /**
30
30
  * The current selected value.
31
31
  */
@@ -51,6 +51,13 @@ defineProps<{
51
51
  */
52
52
  error?: string;
53
53
  }>();
54
+
55
+ const normalizedOptions = computed(() =>
56
+ props.options.map((it) => ({
57
+ label: 'label' in it ? it.label : it.text,
58
+ value: it.value,
59
+ })),
60
+ );
54
61
  </script>
55
62
 
56
63
  <template>
@@ -65,7 +72,7 @@ defineProps<{
65
72
  </label>
66
73
  <InnerBorder class="ui-btn-group__container">
67
74
  <div
68
- v-for="(opt, i) in options"
75
+ v-for="(opt, i) in normalizedOptions"
69
76
  :key="i"
70
77
  class="ui-btn-group__option"
71
78
  :tabindex="modelValue === opt.value || disabled ? undefined : 0"
@@ -73,7 +80,7 @@ defineProps<{
73
80
  @keydown.enter="emitModel(opt.value)"
74
81
  @click="emitModel(opt.value)"
75
82
  >
76
- {{ opt.text }}
83
+ {{ opt.label }}
77
84
  </div>
78
85
  </InnerBorder>
79
86
  <div v-if="helper" class="ui-btn-group__helper">{{ helper }}</div>
@@ -28,7 +28,7 @@ const props = defineProps<{
28
28
  /**
29
29
  * List of available options for the component
30
30
  */
31
- options: SimpleOption<M>[];
31
+ options: Readonly<SimpleOption<M>[]>;
32
32
  /**
33
33
  * If `true`, the component is disabled and cannot be interacted with.
34
34
  */
@@ -48,9 +48,9 @@ const updateModel = (value: M) => {
48
48
  <template>
49
49
  <div class="ui-checkbox-group" :class="{ disabled }">
50
50
  <label v-if="label">{{ label }}</label>
51
- <div v-for="(opt, i) in options" :key="i">
52
- <PlCheckboxBase :disabled="disabled" :label="opt.text" :model-value="hasValue(opt.value)" @update:model-value="() => updateModel(opt.value)" />
53
- <label @click.stop="() => updateModel(opt.value)">{{ opt.text }}</label>
51
+ <div v-for="(opt, i) in options.map((it) => ({ label: 'label' in it ? it.label : it.text, value: it.value }))" :key="i">
52
+ <PlCheckboxBase :disabled="disabled" :label="opt.label" :model-value="hasValue(opt.value)" @update:model-value="() => updateModel(opt.value)" />
53
+ <label @click.stop="() => updateModel(opt.value)">{{ opt.label }}</label>
54
54
  </div>
55
55
  </div>
56
56
  </template>
@@ -145,5 +145,6 @@ export function normalizeListOptions<V = unknown>(options: Readonly<ListOption<V
145
145
  return options.map((it) => ({
146
146
  label: 'label' in it ? it.label : it.text,
147
147
  value: it.value,
148
+ description: it.description,
148
149
  }));
149
150
  }
package/src/types.ts CHANGED
@@ -20,8 +20,19 @@ export type ElementPosition = Omit<DOMRect, 'toJSON'> & {
20
20
  offsetX: number;
21
21
  };
22
22
 
23
- export type SimpleOption<T = unknown> = {
24
- text: string;
23
+ export type SimpleOption<T = unknown> =
24
+ | {
25
+ text: string;
26
+ value: T;
27
+ }
28
+ | {
29
+ label: string;
30
+ value: T;
31
+ };
32
+
33
+ export type SimpleOptionNormalized<T = unknown> = {
34
+ label: string;
35
+ description?: string;
25
36
  value: T;
26
37
  };
27
38
 
@@ -37,6 +48,12 @@ export type ListOption<T = unknown> =
37
48
  value: T;
38
49
  };
39
50
 
51
+ export type ListOptionNormalized<T = unknown> = {
52
+ label: string;
53
+ description?: string;
54
+ value: T;
55
+ };
56
+
40
57
  export type { ModelRef };
41
58
 
42
59
  export type RefOption = {
@@ -44,12 +61,6 @@ export type RefOption = {
44
61
  readonly ref: ModelRef;
45
62
  };
46
63
 
47
- export type ListOptionNormalized<T = unknown> = {
48
- label: string;
49
- description?: string;
50
- value: T;
51
- };
52
-
53
64
  export type ListOptionType<Type> = Type extends ListOption<infer X>[] ? X : never;
54
65
 
55
66
  export const maskIcons16 = [