@milaboratories/uikit 2.2.46 → 2.2.48

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": "2.2.46",
3
+ "version": "2.2.48",
4
4
  "type": "module",
5
5
  "main": "dist/pl-uikit.umd.js",
6
6
  "module": "dist/pl-uikit.js",
@@ -35,8 +35,8 @@
35
35
  "svgo": "^3.3.2",
36
36
  "@types/d3": "^7.4.3",
37
37
  "@milaboratories/eslint-config": "^1.0.1",
38
- "@platforma-sdk/model": "^1.21.20",
39
- "@milaboratories/helpers": "^1.6.11"
38
+ "@milaboratories/helpers": "^1.6.11",
39
+ "@platforma-sdk/model": "^1.21.20"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "vite",
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref } from 'vue';
3
- import { debounce, notEmpty } from '../helpers/utils';
3
+ import { debounce, notEmpty } from '@milaboratories/helpers';
4
4
 
5
5
  const hasElementEllipsis = ref(false);
6
6
 
@@ -7,8 +7,9 @@ export default {
7
7
  <script lang="ts" setup>
8
8
  import { useEventListener } from '@/composition/useEventListener';
9
9
  import './pl-dialog-modal.scss';
10
- import { ref, useAttrs, useSlots } from 'vue';
10
+ import { computed, ref, useSlots } from 'vue';
11
11
  import PlCloseModalBtn from '@/utils/PlCloseModalBtn.vue';
12
+ import type { Size } from '@/types';
12
13
 
13
14
  const slots = useSlots();
14
15
 
@@ -56,6 +57,10 @@ const props = withDefaults(
56
57
  * If `true`, the modal window closes when clicking outside the modal area (default: `true`)
57
58
  */
58
59
  closeOnOutsideClick?: boolean;
60
+ /**
61
+ * Predefined size (standard small | medium | large). Takes precedence over (min|max)(width|height) properties. Not defined by default.
62
+ */
63
+ size?: Size | undefined;
59
64
  }>(),
60
65
  {
61
66
  width: '448px',
@@ -65,12 +70,44 @@ const props = withDefaults(
65
70
  closable: true,
66
71
  noContentGutters: false,
67
72
  actionsHasTopBorder: true,
73
+ size: undefined,
68
74
  },
69
75
  );
70
76
 
71
77
  const modal = ref<HTMLElement>();
72
78
 
73
- const $attrs = useAttrs();
79
+ const style = computed(() => {
80
+ const { width, height, minHeight, maxHeight, size } = props;
81
+
82
+ if (size === 'small') {
83
+ return {
84
+ width: '448px',
85
+ height: '440px',
86
+ minHeight: 'auto',
87
+ maxHeight: 'auto',
88
+ };
89
+ }
90
+
91
+ if (size === 'medium') {
92
+ return {
93
+ width: '720px',
94
+ height: '720px',
95
+ minHeight: 'auto',
96
+ maxHeight: 'auto',
97
+ };
98
+ }
99
+
100
+ if (size === 'large') {
101
+ return {
102
+ width: '1080px',
103
+ height: '880px',
104
+ minHeight: 'auto',
105
+ maxHeight: 'auto',
106
+ };
107
+ }
108
+
109
+ return { width, height, minHeight, maxHeight };
110
+ });
74
111
 
75
112
  function onClickShadow(ev: Event) {
76
113
  if (modal.value && props.closeOnOutsideClick && document.contains(ev.target as Node) && !modal.value.contains(ev.target as Node)) {
@@ -94,7 +131,7 @@ useEventListener(document.body, 'keyup', (ev) => {
94
131
  ref="modal"
95
132
  class="pl-dialog-modal"
96
133
  :class="{ 'has-title': slots.title, 'has-content': slots.default }"
97
- :style="{ width, height, minHeight, maxHeight }"
134
+ :style="style"
98
135
  >
99
136
  <PlCloseModalBtn v-if="closable" class="close-modal-btn" @click.stop="emit('update:modelValue', false)" />
100
137
  <div v-if="slots.title" class="pl-dialog-modal__title">
@@ -73,6 +73,7 @@ const props = withDefaults(
73
73
  placeholder: '...',
74
74
  required: false,
75
75
  disabled: false,
76
+ options: undefined,
76
77
  },
77
78
  );
78
79
 
@@ -53,6 +53,7 @@ const props = withDefaults(
53
53
  placeholder: '...',
54
54
  required: false,
55
55
  disabled: false,
56
+ options: undefined,
56
57
  },
57
58
  );
58
59
 
@@ -1,6 +1,6 @@
1
1
  import type { Ref } from 'vue';
2
2
  import { ref, watch } from 'vue';
3
- import { notEmpty } from '@/helpers/utils';
3
+ import { notEmpty } from '@milaboratories/helpers';
4
4
 
5
5
  const $store = new Map<string, Ref<string | null>>();
6
6
 
@@ -4,14 +4,6 @@ export function call<R>(f: () => R): R {
4
4
  return f();
5
5
  }
6
6
 
7
- export function notEmpty<T>(v: T | null | undefined, message: string): T {
8
- if (v === null || v === undefined) {
9
- throw Error(message);
10
- }
11
-
12
- return v;
13
- }
14
-
15
7
  export function requestTick<P>(cb: (...args: P[]) => void) {
16
8
  let tick = false;
17
9
 
@@ -108,17 +100,6 @@ export function animateInfinite(options: { getFraction: (dt: number) => number;
108
100
  /* eslint-disable @typescript-eslint/no-explicit-any */
109
101
  type AnyFunction = (...args: any[]) => any;
110
102
 
111
- export function debounce<F extends AnyFunction>(func: F, delay: number) {
112
- let timerId = -1;
113
- return (...args: Parameters<F>) => {
114
- if (timerId !== -1) {
115
- clearTimeout(timerId);
116
- timerId = -1;
117
- }
118
- timerId = window.setTimeout(() => func(...args), delay);
119
- };
120
- }
121
-
122
103
  export function throttle<F extends AnyFunction>(callback: F, ms: number, trailing = true): (...args: Parameters<F>) => void {
123
104
  let t = 0,
124
105
  call: AnyFunction | null;
@@ -142,6 +123,10 @@ export function listToOptions<T>(list: T[] | readonly T[]): ListOption<T>[] {
142
123
  }
143
124
 
144
125
  export function normalizeListOptions<V = unknown>(options: Readonly<ListOption<V>[]>) {
126
+ if (!Array.isArray(options)) {
127
+ throw Error('Invalid component options: ' + String(options));
128
+ }
129
+
145
130
  return options.map((it) => ({
146
131
  label: 'label' in it ? it.label : it.text,
147
132
  value: it.value,
package/vite.config.ts CHANGED
@@ -40,8 +40,8 @@ export default defineConfig({
40
40
  },
41
41
  },
42
42
  build: {
43
- sourcemap: process.env.DEV_SOURCE_MAP === '1',
44
- emptyOutDir: false,
43
+ sourcemap: true,
44
+ emptyOutDir: true,
45
45
  lib: {
46
46
  // Could also be a dictionary or array of multiple entry points
47
47
  entry: [resolve(__dirname, 'src/index.ts')],