@eightshift/ui-components 5.5.0 → 5.6.1

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 (51) hide show
  1. package/dist/assets/style-admin.css +2 -8286
  2. package/dist/assets/style-editor.css +2 -8286
  3. package/dist/assets/style.css +2 -8292
  4. package/dist/assets/wp-font-enhancements.css +2 -8
  5. package/dist/assets/wp-ui-enhancements.css +2 -387
  6. package/dist/components/button/button.js +1 -1
  7. package/dist/components/color-pickers/color-picker.js +1 -1
  8. package/dist/components/color-pickers/color-swatch.js +1 -1
  9. package/dist/components/color-pickers/gradient-editor.js +1 -1
  10. package/dist/components/color-pickers/solid-color-picker.js +1 -1
  11. package/dist/components/component-toggle/component-toggle.js +1 -1
  12. package/dist/components/draggable/draggable-handle.js +1 -1
  13. package/dist/components/draggable/draggable.js +1 -1
  14. package/dist/components/draggable-list/draggable-list-item.js +1 -1
  15. package/dist/components/draggable-list/draggable-list.js +1 -1
  16. package/dist/components/expandable/expandable.js +1 -1
  17. package/dist/components/item-collection/item-collection.js +1 -1
  18. package/dist/components/link-input/link-input.js +1 -1
  19. package/dist/components/matrix-align/matrix-align.js +1 -1
  20. package/dist/components/menu/menu.js +1 -1
  21. package/dist/components/modal/modal.js +1 -1
  22. package/dist/components/number-picker/number-picker.js +1 -1
  23. package/dist/components/option-select/option-select.js +1 -1
  24. package/dist/components/placeholders/file-picker-shell.js +12 -8
  25. package/dist/components/placeholders/file-placeholder.js +1 -1
  26. package/dist/components/popover/popover.js +1 -1
  27. package/dist/components/repeater/repeater-item.js +1 -1
  28. package/dist/components/repeater/repeater.js +1 -1
  29. package/dist/components/responsive/mini-responsive.js +1 -1
  30. package/dist/components/responsive/responsive-legacy.js +1 -1
  31. package/dist/components/responsive/responsive.js +1 -1
  32. package/dist/components/responsive-preview/responsive-preview.js +1 -1
  33. package/dist/components/select/v2/async-multi-select.js +1 -1
  34. package/dist/components/select/v2/async-select.js +1 -1
  35. package/dist/components/select/v2/multi-select.js +1 -1
  36. package/dist/components/select/v2/single-select.js +1 -1
  37. package/dist/components/slider/column-config-slider.js +1 -1
  38. package/dist/components/slider/utils.js +1 -1
  39. package/dist/components/smart-image/smart-image.js +49 -7
  40. package/dist/components/smart-image/worker-inline.js +4 -0
  41. package/dist/components/tabs/tabs.js +1 -1
  42. package/dist/{default-i18n-CN_q3KUs.js → default-i18n-DBm-GqWM.js} +167 -50
  43. package/dist/general-Ck8IV7xJ.js +4371 -0
  44. package/dist/icons/index.js +2 -0
  45. package/dist/icons/spinner.js +18 -0
  46. package/dist/utilities/general.js +8 -4140
  47. package/dist/utilities/hash.js +30 -0
  48. package/dist/utilities/index.js +12 -7
  49. package/dist/utilities/web-workers.js +50 -0
  50. package/dist/workers/image-analysis.worker.js +52 -0
  51. package/package.json +16 -14
@@ -0,0 +1,30 @@
1
+ const simpleHash = (str) => {
2
+ let hash = 0;
3
+ for (let i = 0; i < str.length; i++) {
4
+ const char = str.charCodeAt(i);
5
+ hash = (hash << 5) - hash + char;
6
+ }
7
+ return (hash >>> 0).toString(36).padStart(7, "0");
8
+ };
9
+ const cyrb64 = (str, seed = 0) => {
10
+ let h1 = 3735928559 ^ seed;
11
+ let h2 = 1103547991 ^ seed;
12
+ for (let i = 0, ch; i < str.length; i++) {
13
+ ch = str.charCodeAt(i);
14
+ h1 = Math.imul(h1 ^ ch, 2654435761);
15
+ h2 = Math.imul(h2 ^ ch, 1597334677);
16
+ }
17
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
18
+ h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
19
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
20
+ h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
21
+ return [h2 >>> 0, h1 >>> 0];
22
+ };
23
+ const cyrb64Hash = (str, seed = 0) => {
24
+ const [h2, h1] = cyrb64(str, seed);
25
+ return h2.toString(36).padStart(7, "0") + h1.toString(36).padStart(7, "0");
26
+ };
27
+ export {
28
+ cyrb64Hash,
29
+ simpleHash
30
+ };
@@ -2,19 +2,23 @@ import { arrayMoveMultiple, fixIds } from "./array-helpers.js";
2
2
  import { camelCase, has, isEmpty, isEqual, isObject, isPlainObject, isString, kebabCase, lowerFirst, pascalCase, snakeCase, upperFirst } from "./es-dash.js";
3
3
  import { truncate, truncateEnd, truncateMiddle, unescapeHTML } from "./text-helpers.js";
4
4
  import { debounce, throttle } from "./debounce-throttle.js";
5
- import { analyzeImage, checkTransparency, getFileExtension, isColorDark } from "./general.js";
6
- import { c } from "../lite-DVmmD_-j.js";
5
+ import { a, b, d, c, g, i } from "../general-Ck8IV7xJ.js";
6
+ import { c as c2 } from "../lite-DVmmD_-j.js";
7
+ import { cyrb64Hash, simpleHash } from "./hash.js";
7
8
  export {
8
- analyzeImage,
9
+ a as analyzeImage,
10
+ b as analyzeImageAsync,
11
+ d as analyzeImageData,
9
12
  arrayMoveMultiple,
10
13
  camelCase,
11
- checkTransparency,
12
- c as clsx,
14
+ c as checkTransparency,
15
+ c2 as clsx,
16
+ cyrb64Hash,
13
17
  debounce,
14
18
  fixIds,
15
- getFileExtension,
19
+ g as getFileExtension,
16
20
  has,
17
- isColorDark,
21
+ i as isColorDark,
18
22
  isEmpty,
19
23
  isEqual,
20
24
  isObject,
@@ -23,6 +27,7 @@ export {
23
27
  kebabCase,
24
28
  lowerFirst,
25
29
  pascalCase,
30
+ simpleHash,
26
31
  snakeCase,
27
32
  throttle,
28
33
  truncate,
@@ -0,0 +1,50 @@
1
+ function useImageAnalysisWorker(workerRef, workerInline) {
2
+ const getOrCreateWorker = () => {
3
+ if (!workerRef.current) {
4
+ workerRef.current = createImageAnalysisWorker(workerInline);
5
+ workerRef.current.addEventListener("error", (e) => {
6
+ console.error("Worker error event:", e);
7
+ });
8
+ }
9
+ return workerRef.current;
10
+ };
11
+ const analyzeWithWorkerCb = async (imageBitmap, settings) => {
12
+ const worker = getOrCreateWorker();
13
+ return analyzeWithWorker(worker, imageBitmap, settings);
14
+ };
15
+ return { getOrCreateWorker, analyzeWithWorkerCb };
16
+ }
17
+ function createImageAnalysisWorker(workerInline) {
18
+ if (!workerInline || typeof workerInline !== "string" || workerInline.length < 100) {
19
+ throw new Error("Worker could not be created: inline worker code not available. Make sure the worker is properly bundled.");
20
+ }
21
+ const blob = new Blob([workerInline], { type: "application/javascript" });
22
+ return new Worker(URL.createObjectURL(blob), { type: "module" });
23
+ }
24
+ function analyzeWithWorker(worker, imageBitmap, settings) {
25
+ return new Promise((resolve, reject) => {
26
+ const handleMessage = (event) => {
27
+ const { success, data, error } = event.data;
28
+ if (success) {
29
+ resolve(data);
30
+ } else {
31
+ reject(new Error(error));
32
+ }
33
+ worker.removeEventListener("message", handleMessage);
34
+ worker.removeEventListener("error", handleError);
35
+ };
36
+ const handleError = (error) => {
37
+ reject(error);
38
+ worker.removeEventListener("message", handleMessage);
39
+ worker.removeEventListener("error", handleError);
40
+ };
41
+ worker.addEventListener("message", handleMessage);
42
+ worker.addEventListener("error", handleError);
43
+ worker.postMessage({ imageBitmap, settings }, [imageBitmap]);
44
+ });
45
+ }
46
+ export {
47
+ analyzeWithWorker,
48
+ createImageAnalysisWorker,
49
+ useImageAnalysisWorker
50
+ };
@@ -0,0 +1,52 @@
1
+ import { f as floatBufferFromCanvas, d as analyzeImageData, F as FLOAT_RGBA } from "../general-Ck8IV7xJ.js";
2
+ self.onmessage = async (event) => {
3
+ const { imageBitmap, settings } = event.data;
4
+ try {
5
+ const result = await analyzeImageInWorker(imageBitmap, settings);
6
+ self.postMessage({ success: true, data: result });
7
+ } catch (error) {
8
+ self.postMessage({ success: false, error: error.message, stack: error.stack });
9
+ }
10
+ };
11
+ async function analyzeImageInWorker(imageBitmap, rawSettings) {
12
+ const defaults = {
13
+ numColors: 3,
14
+ lightnessThreshold: 0.5,
15
+ yFrom: 0,
16
+ yTo: 1,
17
+ maxSize: 320,
18
+ alphaThreshold: 30
19
+ };
20
+ const settings = { ...defaults, ...rawSettings };
21
+ const { yFrom, yTo, maxSize } = settings;
22
+ const imageWidth = imageBitmap.width;
23
+ const imageHeight = imageBitmap.height;
24
+ if (!imageWidth || !imageHeight) return false;
25
+ let imageScale = 1;
26
+ if (imageWidth > maxSize || imageHeight > maxSize) {
27
+ imageScale = Math.min(maxSize / imageWidth, maxSize / imageHeight);
28
+ }
29
+ const imageWidthScaled = Math.floor(imageWidth * imageScale);
30
+ const imageHeightScaled = Math.floor(imageHeight * imageScale);
31
+ const srcX = 0;
32
+ const srcY = Math.floor(yFrom * imageHeight);
33
+ const srcW = Math.max(1, imageWidth);
34
+ const srcH = Math.max(1, Math.ceil((yTo - yFrom) * imageHeight));
35
+ const destW = Math.max(1, imageWidthScaled);
36
+ const destH = Math.max(1, Math.ceil((yTo - yFrom) * imageHeightScaled));
37
+ const colorCanvas = new OffscreenCanvas(destW, destH);
38
+ const colorContext = colorCanvas.getContext("2d");
39
+ colorContext.drawImage(imageBitmap, srcX, srcY, srcW, srcH, 0, 0, destW, destH);
40
+ const buffer = floatBufferFromCanvas(colorCanvas, FLOAT_RGBA);
41
+ const transparencyCanvas = new OffscreenCanvas(imageWidthScaled, imageHeightScaled);
42
+ const transparencyContext = transparencyCanvas.getContext("2d");
43
+ transparencyContext.drawImage(imageBitmap, 0, 0, imageWidth, imageHeight, 0, 0, imageWidthScaled, imageHeightScaled);
44
+ const imageData = transparencyContext.getImageData(0, 0, imageWidthScaled, imageHeightScaled).data;
45
+ return analyzeImageData({
46
+ buffer,
47
+ imageData,
48
+ width: imageWidthScaled,
49
+ height: imageHeightScaled,
50
+ settings
51
+ });
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eightshift/ui-components",
3
- "version": "5.5.0",
3
+ "version": "5.6.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -34,7 +34,8 @@
34
34
  "scripts": {
35
35
  "dev": "vite",
36
36
  "start": "vite",
37
- "build": "vite build",
37
+ "build": "bun run update-scripts && vite build",
38
+ "update-scripts": "vite build --config vite.worker.config.js && node scripts/inline-worker.js",
38
39
  "lint": "bun x eslint",
39
40
  "preview": "vite preview"
40
41
  },
@@ -44,6 +45,7 @@
44
45
  },
45
46
  "devDependencies": {
46
47
  "@adobe/react-spectrum": "^3.45.0",
48
+ "@atom-universe/use-web-worker": "^2.2.1",
47
49
  "@dnd-kit/abstract": "^0.1.21",
48
50
  "@dnd-kit/core": "^6.3.1",
49
51
  "@dnd-kit/dom": "^0.1.21",
@@ -55,18 +57,22 @@
55
57
  "@eslint/compat": "^1.4.0",
56
58
  "@react-stately/collections": "^3.12.8",
57
59
  "@stylistic/eslint-plugin-js": "^4.4.1",
58
- "@tailwindcss/vite": "^4.1.14",
60
+ "@tailwindcss/vite": "^4.1.15",
61
+ "@thi.ng/color": "^5.7.62",
62
+ "@thi.ng/pixel": "^7.5.10",
63
+ "@thi.ng/pixel-analysis": "^2.0.9",
64
+ "@thi.ng/pixel-dominant-colors": "^2.0.14",
59
65
  "@types/react": "^18.3.26",
60
66
  "@types/react-dom": "^18.3.7",
61
67
  "@vitejs/plugin-react-swc": "^4.1.0",
62
- "@wordpress/i18n": "^6.5.0",
68
+ "@wordpress/i18n": "^6.6.0",
63
69
  "autoprefixer": "^10.4.21",
64
70
  "class-variance-authority": "^0.7.1",
65
71
  "clsx": "^2.1.1",
66
72
  "css-gradient-parser": "^0.0.18",
67
- "eslint": "^9.37.0",
73
+ "eslint": "^9.38.0",
68
74
  "eslint-config-prettier": "^10.1.8",
69
- "eslint-plugin-jsdoc": "^61.1.0",
75
+ "eslint-plugin-jsdoc": "^61.1.5",
70
76
  "eslint-plugin-prettier": "^5.5.4",
71
77
  "glob": "^11.0.3",
72
78
  "globals": "^16.4.0",
@@ -79,7 +85,7 @@
79
85
  "lightningcss": "^1.30.2",
80
86
  "postcss": "^8.5.6",
81
87
  "prettier": "^3.6.2",
82
- "prettier-plugin-tailwindcss": "^0.6.14",
88
+ "prettier-plugin-tailwindcss": "^0.7.1",
83
89
  "react": "^18.3.1",
84
90
  "react-aria": "^3.44.0",
85
91
  "react-aria-components": "^1.13.0",
@@ -89,18 +95,14 @@
89
95
  "react-select": "^5.10.2",
90
96
  "react-stately": "^3.42.0",
91
97
  "svg-to-jsx-string": "^0.1.1",
92
- "tailwindcss": "^4.1.14",
98
+ "tailwindcss": "^4.1.15",
93
99
  "tailwindcss-motion": "^1.1.1",
94
100
  "tailwindcss-react-aria-components": "^2.0.1",
95
- "vite": "^7.1.9",
101
+ "vite": "^7.1.11",
96
102
  "vite-plugin-lib-inject-css": "^2.2.2"
97
103
  },
98
104
  "dependencies": {
99
105
  "@fontsource-variable/geist": "^5.2.8",
100
- "@fontsource-variable/geist-mono": "^5.2.7",
101
- "@thi.ng/color": "^5.7.62",
102
- "@thi.ng/pixel": "^7.5.10",
103
- "@thi.ng/pixel-analysis": "^2.0.9",
104
- "@thi.ng/pixel-dominant-colors": "^2.0.14"
106
+ "@fontsource-variable/geist-mono": "^5.2.7"
105
107
  }
106
108
  }