@eightshift/ui-components 5.5.0 → 5.6.0

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 (90) hide show
  1. package/dist/{Button-CQ5ZZJ2w.js → Button-BhEIfWLY.js} +1 -1
  2. package/dist/{Dialog-BMgMUQuN.js → Dialog-B8p4Ymh7.js} +7 -7
  3. package/dist/{List-BiAnh5G5.js → List-Bll1lQEW.js} +1 -1
  4. package/dist/{ListBox-DggfiuO_.js → ListBox-CEpKw7yC.js} +5 -5
  5. package/dist/{OverlayArrow-DraDOoRn.js → OverlayArrow-DDfa8khI.js} +1 -1
  6. package/dist/{SearchField-DWGdCvnn.js → SearchField-D6mPli0i.js} +2 -2
  7. package/dist/{Select-BvggcFOX.js → Select-CHzjZxXy.js} +7 -7
  8. package/dist/{Select-ef7c0426.esm-CmTkSxDx.js → Select-ef7c0426.esm-BJmjGGzK.js} +1 -1
  9. package/dist/{SelectionManager-B6-b5NM2.js → SelectionManager-D77bfEbg.js} +2 -2
  10. package/dist/{Separator-B-xeqOkC.js → Separator-DcqCdD4k.js} +1 -1
  11. package/dist/{SharedElementTransition-fML-zIv6.js → SharedElementTransition-BjRNHsjx.js} +1 -1
  12. package/dist/_commonjsHelpers-BhWcALO8.js +38 -0
  13. package/dist/assets/style-admin.css +2 -8286
  14. package/dist/assets/style-editor.css +2 -8286
  15. package/dist/assets/style.css +2 -8292
  16. package/dist/assets/wp-font-enhancements.css +2 -8
  17. package/dist/assets/wp-ui-enhancements.css +2 -387
  18. package/dist/components/breakpoint-preview/breakpoint-preview.js +1 -0
  19. package/dist/components/button/button.js +2 -2
  20. package/dist/components/checkbox/checkbox.js +2 -2
  21. package/dist/components/color-pickers/color-picker.js +1 -1
  22. package/dist/components/color-pickers/color-swatch.js +1 -1
  23. package/dist/components/color-pickers/gradient-editor.js +1 -1
  24. package/dist/components/color-pickers/solid-color-picker.js +2 -2
  25. package/dist/components/component-toggle/component-toggle.js +1 -1
  26. package/dist/components/draggable/draggable-handle.js +1 -1
  27. package/dist/components/draggable/draggable.js +2 -2
  28. package/dist/components/draggable-list/draggable-list-item.js +1 -1
  29. package/dist/components/draggable-list/draggable-list.js +2 -2
  30. package/dist/components/expandable/expandable.js +3 -3
  31. package/dist/components/item-collection/item-collection.js +1 -1
  32. package/dist/components/link-input/link-input.js +11 -11
  33. package/dist/components/matrix-align/matrix-align.js +2 -1
  34. package/dist/components/menu/menu.js +3 -3
  35. package/dist/components/modal/modal.js +4 -4
  36. package/dist/components/number-picker/number-picker.js +3 -3
  37. package/dist/components/option-select/option-select.js +1 -1
  38. package/dist/components/placeholders/file-picker-shell.js +13 -8
  39. package/dist/components/placeholders/file-placeholder.js +1 -1
  40. package/dist/components/popover/popover.js +2 -2
  41. package/dist/components/radio/radio.js +2 -2
  42. package/dist/components/repeater/repeater-item.js +1 -1
  43. package/dist/components/repeater/repeater.js +2 -2
  44. package/dist/components/responsive/mini-responsive.js +2 -1
  45. package/dist/components/responsive/responsive-legacy.js +2 -1
  46. package/dist/components/responsive/responsive.js +2 -1
  47. package/dist/components/responsive-preview/responsive-preview.js +2 -1
  48. package/dist/components/select/async-multi-select.js +3 -3
  49. package/dist/components/select/async-single-select.js +2 -2
  50. package/dist/components/select/custom-select-default-components.js +1 -1
  51. package/dist/components/select/multi-select-components.js +1 -1
  52. package/dist/components/select/multi-select.js +3 -3
  53. package/dist/components/select/react-select-component-wrappers.js +1 -1
  54. package/dist/components/select/single-select.js +2 -2
  55. package/dist/components/select/v2/async-multi-select.js +7 -6
  56. package/dist/components/select/v2/async-select.js +7 -6
  57. package/dist/components/select/v2/multi-select.js +8 -7
  58. package/dist/components/select/v2/shared.js +1 -1
  59. package/dist/components/select/v2/single-select.js +7 -7
  60. package/dist/components/slider/column-config-slider.js +1 -1
  61. package/dist/components/slider/utils.js +1 -1
  62. package/dist/components/smart-image/smart-image.js +49 -7
  63. package/dist/components/smart-image/worker-inline.js +4 -0
  64. package/dist/components/tabs/tabs.js +6 -6
  65. package/dist/components/toggle/switch.js +1 -1
  66. package/dist/components/toggle-button/toggle-button.js +1 -1
  67. package/dist/components/tooltip/tooltip.js +2 -2
  68. package/dist/{default-i18n-CN_q3KUs.js → default-i18n-DBm-GqWM.js} +167 -50
  69. package/dist/general-6STKQIrk.js +4371 -0
  70. package/dist/icons/index.js +2 -0
  71. package/dist/icons/spinner.js +18 -0
  72. package/dist/{index-641ee5b8.esm-DVp0njHa.js → index-641ee5b8.esm-DiwvO-RP.js} +1 -1
  73. package/dist/{index-D8-Zjpbd.js → index-DjyEH0Gg.js} +1 -3
  74. package/dist/{multi-select-components-CT_W0Cy9.js → multi-select-components-B3KuDyYd.js} +1 -1
  75. package/dist/{react-select-async.esm-Zl1LPaPb.js → react-select-async.esm-_4pk-41v.js} +3 -3
  76. package/dist/{react-select.esm-Bu36HujU.js → react-select.esm-BeuAkAyY.js} +3 -3
  77. package/dist/sha256-C56UDWfQ.js +533 -0
  78. package/dist/{useButton-v9ngEj50.js → useButton-B2EaQJT_.js} +1 -1
  79. package/dist/{useDragAndDrop-C08ZXv4F.js → useDragAndDrop-DUXKDS0N.js} +5 -5
  80. package/dist/{useFilter-BlkUH1Ma.js → useFilter-BPcJ-Jzv.js} +1 -1
  81. package/dist/{useListState-RdLrYsMP.js → useListState-DZycqxCn.js} +1 -1
  82. package/dist/{useNumberField-D16dDfYF.js → useNumberField-CEA9Q4w_.js} +1 -1
  83. package/dist/{usePress-DJskZBH9.js → usePress-BCEPS3hl.js} +1 -1
  84. package/dist/{useSingleSelectListState-n0AVMr3Y.js → useSingleSelectListState-BFZEfeqI.js} +1 -1
  85. package/dist/{useToggle-DSBDAfdw.js → useToggle-DNoP2bvV.js} +1 -1
  86. package/dist/utilities/general.js +8 -4140
  87. package/dist/utilities/index.js +14 -7
  88. package/dist/utilities/web-workers.js +50 -0
  89. package/dist/workers/image-analysis.worker.js +52 -0
  90. package/package.json +13 -10
@@ -2,19 +2,24 @@ 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-6STKQIrk.js";
6
+ import { c as c2 } from "../lite-DVmmD_-j.js";
7
+ import { s as sha256Exports } from "../sha256-C56UDWfQ.js";
8
+ const sha224 = sha256Exports.sha224;
9
+ const sha256 = sha256Exports.sha256;
7
10
  export {
8
- analyzeImage,
11
+ a as analyzeImage,
12
+ b as analyzeImageAsync,
13
+ d as analyzeImageData,
9
14
  arrayMoveMultiple,
10
15
  camelCase,
11
- checkTransparency,
12
- c as clsx,
16
+ c as checkTransparency,
17
+ c2 as clsx,
13
18
  debounce,
14
19
  fixIds,
15
- getFileExtension,
20
+ g as getFileExtension,
16
21
  has,
17
- isColorDark,
22
+ i as isColorDark,
18
23
  isEmpty,
19
24
  isEqual,
20
25
  isObject,
@@ -23,6 +28,8 @@ export {
23
28
  kebabCase,
24
29
  lowerFirst,
25
30
  pascalCase,
31
+ sha224,
32
+ sha256,
26
33
  snakeCase,
27
34
  throttle,
28
35
  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-6STKQIrk.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.0",
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
  },
@@ -55,18 +56,18 @@
55
56
  "@eslint/compat": "^1.4.0",
56
57
  "@react-stately/collections": "^3.12.8",
57
58
  "@stylistic/eslint-plugin-js": "^4.4.1",
58
- "@tailwindcss/vite": "^4.1.14",
59
+ "@tailwindcss/vite": "^4.1.15",
59
60
  "@types/react": "^18.3.26",
60
61
  "@types/react-dom": "^18.3.7",
61
62
  "@vitejs/plugin-react-swc": "^4.1.0",
62
- "@wordpress/i18n": "^6.5.0",
63
+ "@wordpress/i18n": "^6.6.0",
63
64
  "autoprefixer": "^10.4.21",
64
65
  "class-variance-authority": "^0.7.1",
65
66
  "clsx": "^2.1.1",
66
67
  "css-gradient-parser": "^0.0.18",
67
- "eslint": "^9.37.0",
68
+ "eslint": "^9.38.0",
68
69
  "eslint-config-prettier": "^10.1.8",
69
- "eslint-plugin-jsdoc": "^61.1.0",
70
+ "eslint-plugin-jsdoc": "^61.1.5",
70
71
  "eslint-plugin-prettier": "^5.5.4",
71
72
  "glob": "^11.0.3",
72
73
  "globals": "^16.4.0",
@@ -79,7 +80,7 @@
79
80
  "lightningcss": "^1.30.2",
80
81
  "postcss": "^8.5.6",
81
82
  "prettier": "^3.6.2",
82
- "prettier-plugin-tailwindcss": "^0.6.14",
83
+ "prettier-plugin-tailwindcss": "^0.7.1",
83
84
  "react": "^18.3.1",
84
85
  "react-aria": "^3.44.0",
85
86
  "react-aria-components": "^1.13.0",
@@ -89,18 +90,20 @@
89
90
  "react-select": "^5.10.2",
90
91
  "react-stately": "^3.42.0",
91
92
  "svg-to-jsx-string": "^0.1.1",
92
- "tailwindcss": "^4.1.14",
93
+ "tailwindcss": "^4.1.15",
93
94
  "tailwindcss-motion": "^1.1.1",
94
95
  "tailwindcss-react-aria-components": "^2.0.1",
95
- "vite": "^7.1.9",
96
+ "vite": "^7.1.11",
96
97
  "vite-plugin-lib-inject-css": "^2.2.2"
97
98
  },
98
99
  "dependencies": {
100
+ "@atom-universe/use-web-worker": "^2.2.1",
99
101
  "@fontsource-variable/geist": "^5.2.8",
100
102
  "@fontsource-variable/geist-mono": "^5.2.7",
101
103
  "@thi.ng/color": "^5.7.62",
102
104
  "@thi.ng/pixel": "^7.5.10",
103
105
  "@thi.ng/pixel-analysis": "^2.0.9",
104
- "@thi.ng/pixel-dominant-colors": "^2.0.14"
106
+ "@thi.ng/pixel-dominant-colors": "^2.0.14",
107
+ "js-sha256": "^0.11.1"
105
108
  }
106
109
  }