@milaboratories/uikit 2.3.10 → 2.3.12

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 (31) hide show
  1. package/.turbo/turbo-build.log +19 -19
  2. package/.turbo/turbo-type-check.log +1 -1
  3. package/CHANGELOG.md +13 -0
  4. package/dist/components/PlAutocomplete/PlAutocomplete.vue.js +1 -1
  5. package/dist/components/PlDropdown/PlDropdown.vue.js +1 -1
  6. package/dist/components/PlDropdownLegacy/PlDropdownLegacy.vue.js +1 -1
  7. package/dist/components/PlDropdownMulti/PlDropdownMulti.vue.js +1 -1
  8. package/dist/components/PlFileInput/PlFileInput.vue.js +1 -1
  9. package/dist/components/PlSvg/registry.d.ts.map +1 -1
  10. package/dist/components/PlSvg/registry.js +26 -28
  11. package/dist/components/PlSvg/registry.js.map +1 -1
  12. package/dist/components/PlTextArea/PlTextArea.vue.js +1 -1
  13. package/dist/components/PlTextField/PlTextField.vue.js +1 -1
  14. package/dist/composition/computedCached.d.ts +4 -5
  15. package/dist/composition/computedCached.d.ts.map +1 -1
  16. package/dist/composition/computedCached.js +13 -14
  17. package/dist/composition/computedCached.js.map +1 -1
  18. package/dist/composition/watchCached.d.ts +1 -1
  19. package/dist/composition/watchCached.d.ts.map +1 -1
  20. package/dist/composition/watchCached.js +12 -12
  21. package/dist/composition/watchCached.js.map +1 -1
  22. package/dist/generated/components/svg/images/{SvgRequired.vue.js → SvgRequired.vue2.js} +1 -1
  23. package/dist/generated/components/svg/images/SvgRequired.vue2.js.map +1 -0
  24. package/dist/lib/model/common/dist/index.js +10 -10
  25. package/dist/sdk/model/dist/index.js +55 -55
  26. package/dist/sdk/model/dist/index.js.map +1 -1
  27. package/package.json +5 -5
  28. package/src/components/PlSvg/registry.ts +10 -12
  29. package/src/composition/computedCached.ts +18 -16
  30. package/src/composition/watchCached.ts +9 -6
  31. package/dist/generated/components/svg/images/SvgRequired.vue.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/uikit",
3
- "version": "2.3.10",
3
+ "version": "2.3.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -23,8 +23,8 @@
23
23
  "@vueuse/core": "^13.3.0",
24
24
  "d3": "^7.9.0",
25
25
  "resize-observer-polyfill": "^1.5.1",
26
- "@milaboratories/helpers": "^1.6.17",
27
- "@platforma-sdk/model": "^1.40.0"
26
+ "@platforma-sdk/model": "^1.40.1",
27
+ "@milaboratories/helpers": "^1.6.17"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@vitejs/plugin-vue": "^5.2.3",
@@ -34,9 +34,9 @@
34
34
  "vue-tsc": "^2.2.10",
35
35
  "yarpm": "^1.2.0",
36
36
  "svgo": "^3.3.2",
37
- "@milaboratories/ts-configs": "1.0.4",
37
+ "@milaboratories/eslint-config": "^1.0.4",
38
38
  "@milaboratories/build-configs": "1.0.4",
39
- "@milaboratories/eslint-config": "^1.0.4"
39
+ "@milaboratories/ts-configs": "1.0.4"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "vite",
@@ -32,9 +32,12 @@ export function registerSvg(raw: string, name?: string): SvgMeta {
32
32
  if (!registeredRaw.has(raw)) {
33
33
  const id = `svg-${name ? `${name}-` : ''}${uniqueId(16)}`;
34
34
 
35
- const widthMatch = raw.match(/width="(\d+)(px)?"/)?.[1];
36
- const heightMatch = raw.match(/height="(\d+)(px)?"/)?.[1];
37
- const viewBoxParts = raw.match(/viewBox="[-+]?\d*\.?\d+(?:e[-+]?\d+)?"/);
35
+ const openSvgTagMatch = raw.match(/^<svg[^>]*>/i)?.[0];
36
+ const fillMatch = openSvgTagMatch?.match(/fill\s*=\s*"(.*?)"/)?.[1];
37
+ const strokeMatch = openSvgTagMatch?.match(/stroke\s*=\s*"(.*?)"/)?.[1];
38
+ const widthMatch = openSvgTagMatch?.match(/width\s*=\s*"(\d+)(px)?"/)?.[1];
39
+ const heightMatch = openSvgTagMatch?.match(/height\s*=\s*"(\d+)(px)?"/)?.[1];
40
+ const viewBoxParts = openSvgTagMatch?.match(/viewBox\s*=\s*"[-+]?\d*\.?\d+(?:e[-+]?\d+)?"/);
38
41
  const viewBoxWidthMatch = viewBoxParts?.[2];
39
42
  const viewBoxHeightMatch = viewBoxParts?.[3];
40
43
  let width = Number(viewBoxWidthMatch ?? widthMatch ?? 16);
@@ -43,18 +46,13 @@ export function registerSvg(raw: string, name?: string): SvgMeta {
43
46
  height = isNaN(height) ? 16 : height;
44
47
  const viewBox = `0 0 ${width} ${height}`;
45
48
 
46
- // Parse the original SVG tag and preserve all its attributes except id and viewBox
47
- const svgTagMatch = raw.match(/^<svg([^>]*)>/i);
48
- let svgAttributes = svgTagMatch ? svgTagMatch[1] : '';
49
- // Remove any existing id or viewBox attributes
50
- svgAttributes = svgAttributes
51
- .replace(/\s*id\s*=\s*(['"])[^'"]*\1/gi, '')
52
- .replace(/\s*viewBox\s*=\s*(['"])[^'"]*\1/gi, '');
53
-
54
49
  let fillIdx = 0;
55
50
  let strokeIdx = 0;
51
+ const fillAttr = fillMatch ? `fill="${fillMatch}"` : '';
52
+ const strokeAttr = strokeMatch ? `stroke="${strokeMatch}"` : '';
53
+
56
54
  const preparedSvg = raw
57
- .replace(/^<svg[^>]*>/i, `<svg id="${id}" viewBox="${viewBox}" ${svgAttributes}>`)
55
+ .replace(/^<svg[^>]*>/i, `<svg id="${id}" viewBox="${viewBox}" ${fillAttr} ${strokeAttr}>`)
58
56
  .replace(/<\/svg>\s*$/, '</svg>')
59
57
  .replace(
60
58
  /\bfill\s*=\s*(['"])(.*?)\1/gi,
@@ -1,4 +1,4 @@
1
- import { isJsonEqual } from '@milaboratories/helpers';
1
+ import { deepClone, isJsonEqual } from '@milaboratories/helpers';
2
2
  import {
3
3
  computed,
4
4
  ref,
@@ -9,37 +9,39 @@ import {
9
9
  type WritableComputedRef,
10
10
  } from 'vue';
11
11
 
12
+ /**
13
+ * Alternative to `computed`, but triggering only on actual data changes.
14
+ * Always `deep` as the plain `computed` is.
15
+ */
12
16
  export function computedCached<T>(options: {
13
17
  get: ComputedGetter<T>;
14
18
  set: ComputedSetter<T>;
15
- deep?: boolean;
16
19
  }): WritableComputedRef<T>;
17
- export function computedCached<T>(options: {
18
- get: ComputedGetter<T>;
19
- deep?: boolean;
20
- }): ComputedRef<T>;
21
20
  export function computedCached<T>(getter: ComputedGetter<T>): ComputedRef<T>;
22
- export function computedCached<T>(options: ComputedGetter<T> | {
21
+ export function computedCached<T>(arg: ComputedGetter<T> | {
23
22
  get: ComputedGetter<T>;
24
- set?: ComputedSetter<T>;
25
- deep?: boolean;
23
+ set: ComputedSetter<T>;
26
24
  }) {
27
- if (typeof options === 'function') {
28
- options = {
29
- get: options,
30
- };
25
+ let getter: ComputedGetter<T>;
26
+ let setter: ComputedSetter<T> | undefined = undefined;
27
+ if (typeof arg === 'function') {
28
+ getter = arg;
29
+ } else {
30
+ getter = arg.get;
31
+ setter = arg.set;
31
32
  }
32
- const { get: getter, set: setter, deep } = options;
33
33
 
34
34
  const cachedValue = ref<T>(getter());
35
35
  watch(
36
36
  getter,
37
37
  (newValue) => {
38
38
  if (!isJsonEqual(newValue, cachedValue.value)) {
39
- cachedValue.value = newValue;
39
+ // `deepClone` is needed because in case some fields are patched the deep would be triggered,
40
+ // but objects would be equal as the saved value was also patched
41
+ cachedValue.value = deepClone(newValue);
40
42
  }
41
43
  },
42
- { deep },
44
+ { deep: true },
43
45
  );
44
46
 
45
47
  if (setter) {
@@ -1,4 +1,4 @@
1
- import { isJsonEqual } from '@milaboratories/helpers';
1
+ import { deepClone, isJsonEqual } from '@milaboratories/helpers';
2
2
  import {
3
3
  ref,
4
4
  watch,
@@ -10,9 +10,10 @@ import {
10
10
  type MaybeUndefined<T, I> = I extends true ? T | undefined : T;
11
11
  export interface WatchCachedOptions<Immediate = boolean> {
12
12
  immediate?: Immediate;
13
- deep?: boolean;
14
- // when `once` is needed, caching is useless, use plain watch instead
13
+ // deep: true; - caching is useless when you are using the source as a `shallowRef`
14
+ // once: false; - caching is useless when you need a single shot, use plain watch instead
15
15
  }
16
+ /** Alternative to `watch`, but triggering only on actual data changes */
16
17
  export function watchCached<T, Immediate extends Readonly<boolean> = false>(
17
18
  source: WatchSource<T>,
18
19
  cb: WatchCallback<T, MaybeUndefined<T, Immediate>>,
@@ -23,11 +24,13 @@ export function watchCached<T, Immediate extends Readonly<boolean> = false>(
23
24
  source,
24
25
  (newValue) => {
25
26
  if (!isJsonEqual(newValue, cachedValue.value)) {
26
- cachedValue.value = newValue;
27
+ // `deepClone` is needed because in case some fields are patched the deep would be triggered,
28
+ // but objects would be equal as the saved value was also patched
29
+ cachedValue.value = deepClone(newValue);
27
30
  }
28
31
  },
29
32
  {
30
- deep: options?.deep,
33
+ deep: true,
31
34
  immediate: true, // always initialize cachedValue
32
35
  },
33
36
  );
@@ -37,7 +40,7 @@ export function watchCached<T, Immediate extends Readonly<boolean> = false>(
37
40
  {
38
41
  // standard vue `WatchOptions` conform to `WatchCachedOptions` interface,
39
42
  // so construct new options to remove unsupported entries
40
- deep: options?.deep,
43
+ deep: true,
41
44
  immediate: options?.immediate,
42
45
  },
43
46
  );
@@ -1 +0,0 @@
1
- {"version":3,"file":"SvgRequired.vue.js","sources":["../../../../../src/generated/components/svg/images/SvgRequired.vue"],"sourcesContent":["<!-- ⚠️ AUTOGENERATED. DO NOT EDIT. -->\n<script lang=\"ts\">\nimport '../svg-styles.css';\nexport default { name: 'SvgRequired' };\n</script>\n\n<template>\n <div class=\"svg-icon SvgRequired\" style=\"width: 5px; height: 12px\" />\n</template>\n\n<style>\n .SvgRequired { background-image: url(\"data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2212%22%20viewBox%3D%220%200%205%2012%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M1.51685%204.8L2.5%203.34159L3.47612%204.8L4.39607%204.12743L3.31461%202.7469L5%202.25133L4.64888%201.16106L3.00562%201.77699L3.06882%200H1.93118L1.99438%201.77699L0.351124%201.16106L0%202.25133L1.68539%202.7469L0.59691%204.12743L1.51685%204.8Z%22%20fill%3D%22%23F1222F%22%2F%3E%3C%2Fsvg%3E\"); }\n</style>\n"],"names":["_hoisted_1"],"mappings":";;;;AAOoC,MAAAA,IAAA;AAAA,EAAA,OAAA;AAAA;;;;;;"}